UM1786 User Manual Description of STM32F3xx HAL drivers Introduction TM STMCube is an STMicroelectronics original initiative to ease developers life by reducing development efforts, time and cost. STM32Cube covers STM32 portfolio. STM32Cube Version 1.x includes: The STM32CubeMX, a graphical software configuration tool that allows generating C initialization code using graphical wizards. A comprehensive embedded software platform, delivered per series (such as STM32CubeF3 for STM32F3 series) The STM32Cube HAL, an STM32 abstraction layer embedded software, ensuring maximized portability across STM32 portfolio A consistent set of middleware components such as RTOS, USB, TCP/IP, Graphics All embedded software utilities coming with a full set of examples. The HAL drivers layer provides a generic multi instance simple set of APIs (application programming interfaces) to interact with the upper layer (application, libraries and stacks). It is composed of generic and extension APIs. It is directly built around a generic architecture and allows the built-upon layers, such as the middleware layer, to implement their functions without knowing in-depth how to use the MCU. This structure improves the library code reusability and guarantees an easy portability on other devices. The HAL drivers include a complete set of ready-to-use APIs which simplify the user application implementation. As an example, the communication peripherals contain APIs to initialize and configure the peripheral, to manage data transfers based on polling, to handle interrupts or DMA, and to manage communication errors. The HAL drivers APIs are split into two categories: generic APIs which provide common and generic functions for all the STM32 series and extension APIs which include specific and customized functions for a given family or part number. The HAL drivers are feature-oriented instead of IP-oriented. As an example, the timer APIs are split into several categories following the functions offered by the IP: basic timer, capture, pulse width modulation (PWM), etc.. The drivers source code is developed in Strict ANSI-C which makes it independent from the TM development tools. It is checked with CodeSonar static analysis tool. It is fully documented and is MISRA-C 2004 compliant. The HAL drivers layer implements run-time failure detection by checking the input values of all functions. Such dynamic checking contributes to enhance the firmware robustness. Run-time detection is also suitable for user application development and debugging. This user manual is structured as follows: Overview of the HAL drivers Detailed description of each peripheral driver: configuration structures, functions, and how to use the given API to build your application. June 2016 DOCID026526 Rev 4 1/832 www.st.com Contents UM1786 Contents 1 Acronyms and definitions............................................................. 22 2 Overview of HAL drivers ............................................................... 24 2.1 2.2 2.1.1 HAL driver files ................................................................................. 24 2.1.2 User-application files ........................................................................ 25 HAL data structures ........................................................................ 27 2.2.1 Peripheral handle structures ............................................................ 27 2.2.2 Initialization and configuration structure ........................................... 28 2.2.3 Specific process structures .............................................................. 28 2.3 API classification ............................................................................. 29 2.4 Devices supported by HAL drivers .................................................. 30 2.5 HAL drivers rules............................................................................. 34 2.5.1 HAL API naming rules ...................................................................... 34 2.5.2 HAL general naming rules ................................................................ 35 2.5.3 HAL interrupt handler and callback functions ................................... 36 2.6 HAL generic APIs ............................................................................ 37 2.7 HAL extension APIs ........................................................................ 38 2.7.1 HAL extension model overview ........................................................ 38 2.7.2 HAL extension model cases ............................................................. 39 2.8 File inclusion model......................................................................... 41 2.9 HAL common resources .................................................................. 41 2.10 HAL configuration............................................................................ 42 2.11 HAL system peripheral handling ..................................................... 43 2.12 2/832 HAL and user-application files......................................................... 24 2.11.1 Clock ................................................................................................. 43 2.11.2 GPIOs ............................................................................................... 44 2.11.3 Cortex NVIC and SysTick timer........................................................ 45 2.11.4 PWR ................................................................................................. 46 2.11.5 EXTI .................................................................................................. 46 2.11.6 DMA .................................................................................................. 47 How to use HAL drivers .................................................................. 49 2.12.1 HAL usage models ........................................................................... 49 2.12.2 HAL initialization ............................................................................... 50 2.12.3 HAL IO operation process ................................................................ 52 2.12.4 Timeout and error management ....................................................... 55 DOCID026526 Rev 4 UM1786 3 Contents HAL System Driver ........................................................................ 59 3.1 3.2 HAL Firmware driver API description .............................................. 59 3.1.1 How to use this driver ....................................................................... 59 3.1.2 Initialization and de-initialization functions ....................................... 59 3.1.3 HAL Control functions....................................................................... 59 3.1.4 Detailed description of functions ...................................................... 60 HAL Firmware driver defines ........................................................... 64 3.2.1 4 HAL ADC Generic Driver ............................................................... 67 4.1 ADC Firmware driver registers structures ....................................... 67 4.1.1 4.2 4.3 __ADC_HandleTypeDef ................................................................... 67 ADC Firmware driver API description.............................................. 67 4.2.1 ADC peripheral features ................................................................... 67 4.2.2 How to use this driver ....................................................................... 68 4.2.3 Initialization and de-initialization functions ....................................... 72 4.2.4 IO operation functions ...................................................................... 72 4.2.5 Peripheral Control functions ............................................................. 73 4.2.6 Peripheral state and errors functions ............................................... 73 4.2.7 Detailed description of functions ...................................................... 73 ADC Firmware driver defines .......................................................... 79 4.3.1 5 HAL ................................................................................................... 64 ADC .................................................................................................. 79 HAL ADC Extension Driver ........................................................... 82 5.1 5.2 5.3 ADCEx Firmware driver registers structures ................................... 82 5.1.1 ADC_InitTypeDef .............................................................................. 82 5.1.2 ADC_ChannelConfTypeDef ............................................................. 84 5.1.3 ADC_InjectionConfTypeDef ............................................................. 85 5.1.4 ADC_InjectionConfigTypeDef .......................................................... 88 5.1.5 ADC_AnalogWDGConfTypeDef ....................................................... 88 5.1.6 ADC_MultiModeTypeDef .................................................................. 89 ADCEx Firmware driver API description ......................................... 89 5.2.1 Initialization and de-initialization functions ....................................... 89 5.2.2 IO operation functions ...................................................................... 90 5.2.3 Peripheral Control functions ............................................................. 91 5.2.4 Detailed description of functions ...................................................... 91 ADCEx Firmware driver defines ...................................................... 98 5.3.1 ADCEx .............................................................................................. 98 DOCID026526 Rev 4 3/832 Contents 6 UM1786 HAL CAN Generic Driver ............................................................. 112 6.1 6.2 6.3 CAN Firmware driver registers structures ..................................... 112 6.1.1 CAN_InitTypeDef ............................................................................ 112 6.1.2 CAN_FilterConfTypeDef ................................................................. 113 6.1.3 CanTxMsgTypeDef......................................................................... 114 6.1.4 CanRxMsgTypeDef ........................................................................ 114 6.1.5 CAN_HandleTypeDef ..................................................................... 115 CAN Firmware driver API description ............................................ 116 6.2.1 How to use this driver ..................................................................... 116 6.2.2 Initialization and de-initialization functions ..................................... 117 6.2.3 Peripheral State and Error functions .............................................. 117 6.2.4 Detailed description of functions .................................................... 117 CAN Firmware driver defines ........................................................ 121 6.3.1 7 HAL CEC Generic Driver ............................................................. 128 7.1 7.2 7.3 CEC Firmware driver registers structures ..................................... 128 7.1.1 CEC_InitTypeDef ............................................................................ 128 7.1.2 CEC_HandleTypeDef ..................................................................... 129 CEC Firmware driver API description ............................................ 130 7.2.1 How to use this driver ..................................................................... 130 7.2.2 Initialization and Configuration functions ........................................ 130 7.2.3 IO operation function ...................................................................... 131 7.2.4 Peripheral Control functions ........................................................... 131 7.2.5 Detailed description of functions .................................................... 132 CEC Firmware driver defines ........................................................ 135 7.3.1 8 CEC ................................................................................................ 135 HAL COMP Generic Driver .......................................................... 143 8.1 8.2 4/832 CAN ................................................................................................ 121 COMP Firmware driver registers structures .................................. 143 8.1.1 COMP_InitTypeDef ........................................................................ 143 8.1.2 COMP_HandleTypeDef .................................................................. 144 COMP Firmware driver API description ........................................ 144 8.2.1 COMP Peripheral features ............................................................. 144 8.2.2 How to use this driver ..................................................................... 145 8.2.3 Initialization and de-initialization functions ..................................... 145 8.2.4 Start Stop operation functions ........................................................ 145 8.2.5 Peripheral Control functions ........................................................... 146 8.2.6 Peripheral State functions .............................................................. 146 DOCID026526 Rev 4 UM1786 Contents 8.2.7 8.3 COMP Firmware driver defines ..................................................... 149 8.3.1 9 COMPEx Firmware driver defines ................................................. 151 9.1.1 CORTEX Firmware driver registers structures .............................. 168 10.1.1 10.2 10.3 10.2.1 How to use this driver ..................................................................... 169 10.2.2 Initialization and de-initialization functions ..................................... 170 10.2.3 Peripheral Control functions ........................................................... 170 10.2.4 Detailed description of functions .................................................... 170 CORTEX Firmware driver defines ................................................. 175 CORTEX ......................................................................................... 175 HAL CRC Generic Driver ............................................................. 178 11.1 11.2 11.3 CRC Firmware driver registers structures ..................................... 178 11.1.1 CRC_InitTypeDef ........................................................................... 178 11.1.2 CRC_HandleTypeDef ..................................................................... 179 CRC Firmware driver API description ........................................... 179 11.2.1 How to use this driver ..................................................................... 179 11.2.2 Initialization and de-initialization functions ..................................... 180 11.2.3 Peripheral Control functions ........................................................... 180 11.2.4 Peripheral State functions .............................................................. 180 11.2.5 Detailed description of functions .................................................... 180 CRC Firmware driver defines ........................................................ 182 11.3.1 CRC ................................................................................................ 182 HAL CRC Extension Driver ......................................................... 185 12.1 12.2 CRCEx Firmware driver API description ....................................... 185 12.1.1 How to use this driver ..................................................................... 185 12.1.2 Detailed description of functions .................................................... 185 CRCEx Firmware driver defines .................................................... 186 12.2.1 13 MPU_Region_InitTypeDef .............................................................. 168 CORTEX Firmware driver API description .................................... 169 10.3.1 12 COMPEx ......................................................................................... 151 HAL CORTEX Generic Driver ...................................................... 168 10.1 11 COMP ............................................................................................. 149 HAL COMP Extension Driver ...................................................... 151 9.1 10 Detailed description of functions .................................................... 146 CRCEx ............................................................................................ 186 HAL DAC Generic Driver ............................................................. 188 13.1 DAC Firmware driver registers structures ..................................... 188 DOCID026526 Rev 4 5/832 Contents 13.2 13.3 13.1.1 UM1786 DAC_ChannelConfTypeDef ........................................................... 188 13.1.2 __DAC_HandleTypeDef ................................................................. 188 DAC Firmware driver API description ............................................ 189 13.2.1 DAC Peripheral features................................................................. 189 13.2.2 How to use this driver ..................................................................... 190 13.2.3 Initialization and de-initialization functions ..................................... 191 13.2.4 IO operation functions .................................................................... 191 13.2.5 Peripheral Control functions ........................................................... 192 13.2.6 DAC Peripheral State and Error functions...................................... 192 13.2.7 Detailed description of functions .................................................... 192 DAC Firmware driver defines ........................................................ 197 13.3.1 14 HAL DAC Extension Driver ......................................................... 202 14.1 14.2 DACEx Firmware driver API description ....................................... 202 14.1.1 How to use this driver ..................................................................... 202 14.1.2 Peripheral Control functions ........................................................... 202 14.1.3 IO operation functions .................................................................... 202 14.1.4 Detailed description of functions .................................................... 203 DACEx Firmware driver defines .................................................... 206 14.2.1 15 15.2 15.3 DMA Firmware driver registers structures ..................................... 207 15.1.1 DMA_InitTypeDef ........................................................................... 207 15.1.2 __DMA_HandleTypeDef................................................................. 207 DMA Firmware driver API description ........................................... 208 15.2.1 How to use this driver ..................................................................... 208 15.2.2 Initialization and de-initialization functions ..................................... 209 15.2.3 IO operation functions .................................................................... 210 15.2.4 State and Errors functions .............................................................. 210 15.2.5 Detailed description of functions .................................................... 210 DMA Firmware driver defines ........................................................ 213 15.3.1 DMAEx Firmware driver defines.................................................... 217 16.1.1 6/832 DMA ................................................................................................ 213 HAL DMA Extension Driver......................................................... 217 16.1 17 DACEx ............................................................................................ 206 HAL DMA Generic Driver ............................................................ 207 15.1 16 DAC ................................................................................................ 197 DMAEx............................................................................................ 217 HAL FLASH Generic Driver......................................................... 219 DOCID026526 Rev 4 UM1786 Contents 17.1 FLASH Firmware driver registers structures ................................. 219 17.1.1 17.2 17.3 FLASH Firmware driver API description ........................................ 219 17.2.1 FLASH peripheral features ............................................................. 219 17.2.2 How to use this driver ..................................................................... 220 17.2.3 Peripheral Control functions ........................................................... 220 17.2.4 Peripheral errors functions ............................................................. 220 17.2.5 Detailed description of functions .................................................... 221 FLASH Firmware driver defines .................................................... 223 17.3.1 18 18.2 18.3 FLASHEx Firmware driver registers structures ............................. 227 18.1.1 FLASH_EraseInitTypeDef .............................................................. 227 18.1.2 FLASH_OBProgramInitTypeDef .................................................... 227 FLASHEx Firmware driver API description.................................... 228 18.2.1 FLASH Erasing Programming functions ......................................... 228 18.2.2 Option Bytes Programming functions ............................................. 228 18.2.3 Detailed description of functions .................................................... 228 FLASHEx Firmware driver defines ................................................ 230 18.3.1 GPIO Firmware driver registers structures .................................... 233 19.1.1 19.2 19.3 GPIO_InitTypeDef .......................................................................... 233 GPIO Firmware driver API description .......................................... 233 19.2.1 GPIO Peripheral features ............................................................... 233 19.2.2 How to use this driver ..................................................................... 234 19.2.3 Initialization and de-initialization functions ..................................... 234 19.2.4 IO operation functions .................................................................... 235 19.2.5 Detailed description of functions .................................................... 235 GPIO Firmware driver defines ....................................................... 237 19.3.1 GPIO ............................................................................................... 237 HAL GPIO Extension Driver ........................................................ 240 20.1 GPIOEx Firmware driver defines................................................... 240 20.1.1 21 FLASHEx ........................................................................................ 230 HAL GPIO Generic Driver............................................................ 233 19.1 20 FLASH ............................................................................................ 223 HAL FLASH Extension Driver ..................................................... 227 18.1 19 FLASH_ProcessTypeDef ............................................................... 219 GPIOEx .......................................................................................... 240 HAL HRTIM Generic Driver ......................................................... 243 21.1 HRTIM Firmware driver registers structures.................................. 243 DOCID026526 Rev 4 7/832 Contents 21.2 21.3 21.1.1 UM1786 HRTIM_InitTypeDef ........................................................................ 243 21.1.2 HRTIM_TimerParamTypeDef ......................................................... 243 21.1.3 __HRTIM_HandleTypeDef ............................................................. 244 21.1.4 HRTIM_TimeBaseCfgTypeDef ....................................................... 245 21.1.5 HRTIM_SimpleOCChannelCfgTypeDef ......................................... 245 21.1.6 HRTIM_SimplePWMChannelCfgTypeDef...................................... 246 21.1.7 HRTIM_SimpleCaptureChannelCfgTypeDef.................................. 246 21.1.8 HRTIM_SimpleOnePulseChannelCfgTypeDef .............................. 247 21.1.9 HRTIM_TimerCfgTypeDef .............................................................. 247 21.1.10 HRTIM_CompareCfgTypeDef ........................................................ 249 21.1.11 HRTIM_CaptureCfgTypeDef .......................................................... 250 21.1.12 HRTIM_OutputCfgTypeDef ............................................................ 250 21.1.13 HRTIM_TimerEventFilteringCfgTypeDef ........................................ 251 21.1.14 HRTIM_DeadTimeCfgTypeDef ...................................................... 251 21.1.15 HRTIM_ChopperModeCfgTypeDef ................................................ 252 21.1.16 HRTIM_EventCfgTypeDef .............................................................. 253 21.1.17 HRTIM_FaultCfgTypeDef ............................................................... 253 21.1.18 HRTIM_BurstModeCfgTypeDef ..................................................... 254 21.1.19 HRTIM_ADCTriggerCfgTypeDef .................................................... 254 HRTIM Firmware driver API description ........................................ 255 21.2.1 Simple mode v.s. waveform mode ................................................. 255 21.2.2 How to use this driver ..................................................................... 255 21.2.3 Initialization and Time Base Configuration functions ..................... 259 21.2.4 Simple time base mode functions .................................................. 259 21.2.5 Simple output compare functions ................................................... 260 21.2.6 Simple PWM output functions ........................................................ 260 21.2.7 Simple input capture functions ....................................................... 260 21.2.8 Simple one pulse functions ............................................................ 261 21.2.9 HRTIM configuration functions ....................................................... 261 21.2.10 HRTIM timer configuration and control functions ........................... 262 21.2.11 Peripheral State functions .............................................................. 263 21.2.12 Detailed description of functions .................................................... 263 HRTIM Firmware driver defines .................................................... 308 21.3.1 22 HAL I2C Generic Driver ............................................................... 349 22.1 8/832 HRTIM ............................................................................................ 308 I2C Firmware driver registers structures ....................................... 349 22.1.1 I2C_InitTypeDef .............................................................................. 349 22.1.2 __I2C_HandleTypeDef ................................................................... 349 DOCID026526 Rev 4 UM1786 Contents 22.2 22.3 I2C Firmware driver API description .............................................. 351 22.2.1 How to use this driver ..................................................................... 351 22.2.2 Initialization and de-initialization functions ..................................... 355 22.2.3 IO operation functions .................................................................... 355 22.2.4 Peripheral State, Mode and Error functions ................................... 357 22.2.5 Detailed description of functions .................................................... 357 I2C Firmware driver defines .......................................................... 369 22.3.1 23 HAL I2C Extension Driver ........................................................... 375 23.1 23.2 I2CEx Firmware driver API description ......................................... 375 23.1.1 I2C peripheral Extended features ................................................... 375 23.1.2 How to use this driver ..................................................................... 375 23.1.3 Extended features functions ........................................................... 375 23.1.4 Detailed description of functions .................................................... 375 I2CEx Firmware driver defines ...................................................... 377 23.2.1 24 I2CEx .............................................................................................. 377 HAL I2S Generic Driver ............................................................... 378 24.1 24.2 24.3 I2S Firmware driver registers structures ....................................... 378 24.1.1 I2S_InitTypeDef .............................................................................. 378 24.1.2 I2S_HandleTypeDef ....................................................................... 378 I2S Firmware driver API description .............................................. 379 24.2.1 How to use this driver ..................................................................... 379 24.2.2 Initialization and de-initialization functions ..................................... 381 24.2.3 IO operation functions .................................................................... 382 24.2.4 Peripheral State and Errors functions ............................................ 382 24.2.5 Detailed description of functions .................................................... 383 I2S Firmware driver defines .......................................................... 388 24.3.1 25 I2C .................................................................................................. 369 I2S .................................................................................................. 388 HAL I2S Extension Driver ........................................................... 393 25.1 25.2 I2SEx Firmware driver API description .......................................... 393 25.1.1 I2S Extended features .................................................................... 393 25.1.2 How to use this driver ..................................................................... 393 25.1.3 Extended features Functions .......................................................... 394 25.1.4 Detailed description of functions .................................................... 394 I2SEx Firmware driver defines ...................................................... 397 25.2.1 I2SEx .............................................................................................. 397 DOCID026526 Rev 4 9/832 Contents 26 UM1786 HAL IRDA Generic Driver ............................................................ 399 26.1 26.2 26.3 IRDA Firmware driver registers structures .................................... 399 26.1.1 IRDA_InitTypeDef ........................................................................... 399 26.1.2 IRDA_HandleTypeDef .................................................................... 399 IRDA Firmware driver API description ........................................... 400 26.2.1 How to use this driver ..................................................................... 400 26.2.2 Initialization and Configuration functions ........................................ 402 26.2.3 IO operation functions .................................................................... 403 26.2.4 Peripheral State and Errors functions ............................................ 404 26.2.5 Detailed description of functions .................................................... 404 IRDA Firmware driver defines ....................................................... 409 26.3.1 27 HAL IRDA Extension Driver ........................................................ 418 27.1 IRDAEx Firmware driver defines ................................................... 418 27.1.1 28 28.2 28.3 IWDG Firmware driver registers structures ................................... 419 28.1.1 IWDG_InitTypeDef ......................................................................... 419 28.1.2 IWDG_HandleTypeDef ................................................................... 419 IWDG Firmware driver API description ......................................... 420 28.2.1 IWDG Generic features .................................................................. 420 28.2.2 How to use this driver ..................................................................... 420 28.2.3 Initialization and de-initialization functions ..................................... 421 28.2.4 IO operation functions .................................................................... 421 28.2.5 Peripheral State functions .............................................................. 421 28.2.6 Detailed description of functions .................................................... 421 IWDG Firmware driver defines ...................................................... 422 28.3.1 IWDG .............................................................................................. 422 HAL NAND Generic Driver .......................................................... 424 29.1 29.2 NAND Firmware driver registers structures ................................... 424 29.1.1 NAND_IDTypeDef .......................................................................... 424 29.1.2 NAND_AddressTypeDef................................................................. 424 29.1.3 NAND_InfoTypeDef ........................................................................ 424 29.1.4 NAND_HandleTypeDef .................................................................. 425 NAND Firmware driver API description ......................................... 425 29.2.1 10/832 IRDAEx ........................................................................................... 418 HAL IWDG Generic Driver ........................................................... 419 28.1 29 IRDA ............................................................................................... 409 How to use this driver ..................................................................... 425 DOCID026526 Rev 4 UM1786 Contents 29.3 29.2.2 NAND Initialization and de-initialization functions .......................... 426 29.2.3 NAND Input and Output functions .................................................. 426 29.2.4 NAND Control functions ................................................................. 427 29.2.5 NAND State functions..................................................................... 427 29.2.6 Detailed description of functions .................................................... 427 NAND Firmware driver defines...................................................... 431 29.3.1 30 HAL NOR Generic Driver............................................................. 433 30.1 30.2 30.3 NOR Firmware driver registers structures ..................................... 433 30.1.1 NOR_IDTypeDef ............................................................................ 433 30.1.2 NOR_CFITypeDef .......................................................................... 433 30.1.3 NOR_HandleTypeDef..................................................................... 434 NOR Firmware driver API description ........................................... 434 30.2.1 How to use this driver ..................................................................... 434 30.2.2 NOR Initialization and de_initialization functions ........................... 435 30.2.3 NOR Input and Output functions .................................................... 435 30.2.4 NOR Control functions.................................................................... 435 30.2.5 NOR State functions ....................................................................... 435 30.2.6 Detailed description of functions .................................................... 436 NOR Firmware driver defines ........................................................ 440 30.3.1 31 NOR ................................................................................................ 440 HAL OPAMP Generic Driver ....................................................... 441 31.1 31.2 31.3 OPAMP Firmware driver registers structures ................................ 441 31.1.1 OPAMP_InitTypeDef ...................................................................... 441 31.1.2 OPAMP_HandleTypeDef................................................................ 442 OPAMP Firmware driver API description ...................................... 442 31.2.1 OPAMP Peripheral Features .......................................................... 442 31.2.2 How to use this driver ..................................................................... 443 31.2.3 Initialization and de-initialization functions ..................................... 444 31.2.4 IO operation functions .................................................................... 444 31.2.5 Peripheral Control functions ........................................................... 444 31.2.6 Peripheral State functions .............................................................. 445 31.2.7 Detailed description of functions .................................................... 445 OPAMP Firmware driver defines ................................................... 447 31.3.1 32 NAND.............................................................................................. 431 OPAMP ........................................................................................... 447 HAL OPAMP Extension Driver .................................................... 450 DOCID026526 Rev 4 11/832 Contents UM1786 32.1 OPAMPEx Firmware driver API description .................................. 450 32.1.1 33 HAL PCCARD Generic Driver ..................................................... 451 33.1 PCCARD Firmware driver registers structures .............................. 451 33.1.1 33.2 33.3 33.2.1 How to use this driver ..................................................................... 451 33.2.2 PCCARD Initialization and de-initialization functions ..................... 452 33.2.3 PCCARD Input Output and memory functions ............................... 452 33.2.4 PCCARD Peripheral State functions .............................................. 452 33.2.5 Detailed description of functions .................................................... 452 PCCARD Firmware driver defines................................................. 456 34.2 34.3 PCD Firmware driver registers structures ..................................... 457 34.1.1 PCD_InitTypeDef ............................................................................ 457 34.1.2 PCD_EPTypeDef ............................................................................ 457 34.1.3 PCD_HandleTypeDef ..................................................................... 458 PCD Firmware driver API description............................................ 459 34.2.1 How to use this driver ..................................................................... 459 34.2.2 Initialization and de-initialization functions ..................................... 459 34.2.3 IO operation functions .................................................................... 460 34.2.4 Peripheral Control functions ........................................................... 460 34.2.5 Peripheral State functions .............................................................. 460 34.2.6 Detailed description of functions .................................................... 461 PCD Firmware driver defines ........................................................ 468 34.3.1 35.2 PCDEx Firmware driver API description ....................................... 470 35.1.1 Extended Peripheral Control functions ........................................... 470 35.1.2 Detailed description of functions .................................................... 470 PCDEx Firmware driver defines .................................................... 470 35.2.1 PCDEx ............................................................................................ 470 HAL PWR Generic Driver ............................................................ 472 36.1 PWR Firmware driver API description ........................................... 472 36.1.1 12/832 PCD ................................................................................................ 468 HAL PCD Extension Driver ......................................................... 470 35.1 36 PCCARD ........................................................................................ 456 HAL PCD Generic Driver ............................................................. 457 34.1 35 PCCARD_HandleTypeDef ............................................................. 451 PCCARD Firmware driver API description .................................... 451 33.3.1 34 Detailed description of functions .................................................... 450 Initialization and de-initialization functions ..................................... 472 DOCID026526 Rev 4 UM1786 Contents 36.2 36.1.2 Peripheral Control functions ........................................................... 472 36.1.3 Detailed description of functions .................................................... 474 PWR Firmware driver defines ....................................................... 477 36.2.1 37 HAL PWR Extension Driver ........................................................ 480 37.1 PWREx Firmware driver registers structures ................................ 480 37.1.1 37.2 37.3 37.2.1 Peripheral Extended control functions............................................ 480 37.2.2 Detailed description of functions .................................................... 481 PWREx Firmware driver defines ................................................... 482 38.2 38.3 RCC Firmware driver registers structures ..................................... 485 38.1.1 RCC_PLLInitTypeDef ..................................................................... 485 38.1.2 RCC_OscInitTypeDef ..................................................................... 485 38.1.3 RCC_ClkInitTypeDef ...................................................................... 486 RCC Firmware driver API description ........................................... 486 38.2.1 RCC specific features ..................................................................... 486 38.2.2 RCC Limitations .............................................................................. 487 38.2.3 Initialization and de-initialization functions ..................................... 487 38.2.4 Peripheral Control functions ........................................................... 488 38.2.5 Detailed description of functions .................................................... 488 RCC Firmware driver defines ........................................................ 493 38.3.1 RCC ................................................................................................ 493 HAL RCC Extension Driver ......................................................... 511 39.1 RCCEx Firmware driver registers structures ................................. 511 39.1.1 39.2 39.3 RCC_PeriphCLKInitTypeDef .......................................................... 511 RCCEx Firmware driver API description ....................................... 512 39.2.1 Extended Peripheral Control functions ........................................... 512 39.2.2 Detailed description of functions .................................................... 512 RCCEx Firmware driver defines .................................................... 513 39.3.1 40 PWREx ........................................................................................... 482 HAL RCC Generic Driver ............................................................. 485 38.1 39 PWR_PVDTypeDef ........................................................................ 480 PWREx Firmware driver API description ....................................... 480 37.3.1 38 PWR ............................................................................................... 477 RCCEx ............................................................................................ 513 HAL RTC Generic Driver ............................................................. 529 40.1 RTC Firmware driver registers structures ..................................... 529 40.1.1 RTC_InitTypeDef ............................................................................ 529 DOCID026526 Rev 4 13/832 Contents 40.2 40.3 40.1.2 UM1786 RTC_TimeTypeDef......................................................................... 529 40.1.3 RTC_DateTypeDef ......................................................................... 530 40.1.4 RTC_AlarmTypeDef ....................................................................... 531 40.1.5 RTC_HandleTypeDef ..................................................................... 531 RTC Firmware driver API description ............................................ 532 40.2.1 RTC Operating Condition ............................................................... 532 40.2.2 Backup Domain Reset .................................................................... 532 40.2.3 Backup Domain Access.................................................................. 532 40.2.4 How to use RTC Driver................................................................... 533 40.2.5 RTC and low power modes ............................................................ 534 40.2.6 Initialization and de-initialization functions ..................................... 534 40.2.7 RTC Time and Date functions ........................................................ 534 40.2.8 RTC Alarm functions ...................................................................... 535 40.2.9 Detailed description of functions .................................................... 535 RTC Firmware driver defines ........................................................ 540 40.3.1 41 HAL RTC Extension Driver ......................................................... 550 41.1 RTCEx Firmware driver registers structures ................................. 550 41.1.1 41.2 41.3 41.2.1 How to use this driver ..................................................................... 550 41.2.2 RTC TimeStamp and Tamper functions ......................................... 551 41.2.3 RTC Wake-up functions ................................................................. 552 41.2.4 Extended Peripheral Control functions ........................................... 552 41.2.5 Extended features functions ........................................................... 552 41.2.6 Detailed description of functions .................................................... 553 RTCEx Firmware driver defines .................................................... 561 RTCEx ............................................................................................ 561 HAL SDADC Generic Driver ........................................................ 579 42.1 42.2 14/832 RTC_TamperTypeDef .................................................................... 550 RTCEx Firmware driver API description ........................................ 550 41.3.1 42 RTC ................................................................................................ 540 SDADC Firmware driver registers structures ................................ 579 42.1.1 SDADC_InitTypeDef....................................................................... 579 42.1.2 SDADC_HandleTypeDef ................................................................ 579 42.1.3 SDADC_ConfParamTypeDef ......................................................... 580 SDADC Firmware driver API description ....................................... 581 42.2.1 SDADC specific features ................................................................ 581 42.2.2 How to use this driver ..................................................................... 581 42.2.3 Initialization and de-initialization functions ..................................... 583 DOCID026526 Rev 4 UM1786 Contents 42.3 42.2.4 Peripheral control functions ............................................................ 583 42.2.5 IO operation functions .................................................................... 584 42.2.6 ADC Peripheral State functions ...................................................... 585 42.2.7 Detailed description of functions .................................................... 585 SDADC Firmware driver defines ................................................... 597 42.3.1 43 HAL SMARTCARD Generic Driver.............................................. 603 43.1 43.2 43.3 SMARTCARD Firmware driver registers structures ...................... 603 43.1.1 SMARTCARD_InitTypeDef ............................................................ 603 43.1.2 SMARTCARD_AdvFeatureInitTypeDef .......................................... 604 43.1.3 SMARTCARD_HandleTypeDef ...................................................... 605 SMARTCARD Firmware driver API description............................. 606 43.2.1 How to use this driver ..................................................................... 606 43.2.2 Initialization and Configuration functions ........................................ 608 43.2.3 IO operation functions .................................................................... 609 43.2.4 Peripheral State and Errors functions ............................................ 610 43.2.5 Detailed description of functions .................................................... 610 SMARTCARD Firmware driver defines ......................................... 614 43.3.1 44 SMARTCARD ................................................................................. 614 HAL SMARTCARD Extension Driver .......................................... 626 44.1 44.2 SMARTCARDEx Firmware driver API description ........................ 626 44.1.1 Peripheral Control functions ........................................................... 626 44.1.2 Detailed description of functions .................................................... 626 SMARTCARDEx Firmware driver defines ..................................... 627 44.2.1 45 SDADC ........................................................................................... 597 SMARTCARDEx ............................................................................. 627 HAL SMBUS Generic Driver ........................................................ 628 45.1 45.2 45.3 SMBUS Firmware driver registers structures ................................ 628 45.1.1 SMBUS_InitTypeDef ...................................................................... 628 45.1.2 SMBUS_HandleTypeDef ................................................................ 629 SMBUS Firmware driver API description ...................................... 630 45.2.1 How to use this driver ..................................................................... 630 45.2.2 Initialization and de-initialization functions ..................................... 631 45.2.3 IO operation functions .................................................................... 632 45.2.4 Peripheral State and Errors functions ............................................ 633 45.2.5 Detailed description of functions .................................................... 633 SMBUS Firmware driver defines ................................................... 639 DOCID026526 Rev 4 15/832 Contents 45.3.1 46 HAL SPI Generic Driver ............................................................... 646 46.1 46.2 46.3 SPI Firmware driver registers structures ....................................... 646 46.1.1 SPI_InitTypeDef ............................................................................. 646 46.1.2 __SPI_HandleTypeDef ................................................................... 647 SPI Firmware driver API description ............................................. 648 46.2.1 How to use this driver ..................................................................... 648 46.2.2 Initialization and de-initialization functions ..................................... 649 46.2.3 IO operation functions .................................................................... 649 46.2.4 Peripheral State and Errors functions ............................................ 650 46.2.5 Detailed description of functions .................................................... 650 SPI Firmware driver defines .......................................................... 656 46.3.1 47 SPIEx Firmware driver API description ......................................... 662 47.1.1 IO operation functions .................................................................... 662 47.1.2 Detailed description of functions .................................................... 662 HAL SRAM Generic Driver .......................................................... 663 48.1 SRAM Firmware driver registers structures................................... 663 48.1.1 48.2 48.3 48.2.1 How to use this driver ..................................................................... 663 48.2.2 SRAM Initialization and de_initialization functions ......................... 664 48.2.3 SRAM Input and Output functions .................................................. 664 48.2.4 SRAM Control functions ................................................................. 664 48.2.5 SRAM State functions .................................................................... 665 48.2.6 Detailed description of functions .................................................... 665 SRAM Firmware driver defines ..................................................... 669 SRAM ............................................................................................. 669 HAL TIM Generic Driver .............................................................. 670 49.1 16/832 SRAM_HandleTypeDef .................................................................. 663 SRAM Firmware driver API description ......................................... 663 48.3.1 49 SPI .................................................................................................. 656 HAL SPI Extension Driver ........................................................... 662 47.1 48 UM1786 SMBUS ........................................................................................... 639 TIM Firmware driver registers structures ....................................... 670 49.1.1 TIM_Base_InitTypeDef ................................................................... 670 49.1.2 TIM_OC_InitTypeDef...................................................................... 670 49.1.3 TIM_OnePulse_InitTypeDef ........................................................... 671 49.1.4 TIM_IC_InitTypeDef ....................................................................... 672 49.1.5 TIM_Encoder_InitTypeDef ............................................................. 672 49.1.6 TIM_ClockConfigTypeDef .............................................................. 673 DOCID026526 Rev 4 UM1786 Contents 49.2 49.3 49.1.7 TIM_ClearInputConfigTypeDef ....................................................... 674 49.1.8 TIM_SlaveConfigTypeDef .............................................................. 674 49.1.9 TIM_HandleTypeDef ...................................................................... 675 TIM Firmware driver API description ............................................. 675 49.2.1 TIMER Generic features ................................................................. 675 49.2.2 How to use this driver ..................................................................... 676 49.2.3 Time Base functions ....................................................................... 676 49.2.4 Time Output Compare functions .................................................... 677 49.2.5 Time PWM functions ...................................................................... 677 49.2.6 Time Input Capture functions ......................................................... 678 49.2.7 Time One Pulse functions .............................................................. 678 49.2.8 Time Encoder functions .................................................................. 679 49.2.9 IRQ handler management .............................................................. 679 49.2.10 Peripheral Control functions ........................................................... 679 49.2.11 TIM Callbacks functions ................................................................. 680 49.2.12 Peripheral State functions .............................................................. 680 49.2.13 Detailed description of functions .................................................... 680 TIM Firmware driver defines.......................................................... 706 49.3.1 50 TIM.................................................................................................. 706 HAL TIM Extension Driver........................................................... 722 50.1 50.2 50.3 TIMEx Firmware driver registers structures................................... 722 50.1.1 TIM_HallSensor_InitTypeDef ......................................................... 722 50.1.2 TIM_BreakDeadTimeConfigTypeDef ............................................. 722 50.1.3 TIM_MasterConfigTypeDef ............................................................ 723 TIMEx Firmware driver API description ......................................... 724 50.2.1 TIMER Extended features .............................................................. 724 50.2.2 How to use this driver ..................................................................... 724 50.2.3 Timer Hall Sensor functions ........................................................... 724 50.2.4 Timer Complementary Output Compare functions ......................... 725 50.2.5 Timer Complementary PWM functions ........................................... 725 50.2.6 Timer Complementary One Pulse functions................................... 726 50.2.7 Peripheral Control functions ........................................................... 726 50.2.8 Extended Callbacks functions ........................................................ 726 50.2.9 Extended Peripheral State functions .............................................. 727 50.2.10 Detailed description of functions .................................................... 727 TIMEx Firmware driver defines ..................................................... 738 50.3.1 TIMEx ............................................................................................. 738 DOCID026526 Rev 4 17/832 Contents 51 UM1786 HAL TSC Generic Driver ............................................................. 742 51.1 51.2 51.3 TSC Firmware driver registers structures ...................................... 742 51.1.1 TSC_InitTypeDef ............................................................................ 742 51.1.2 TSC_IOConfigTypeDef................................................................... 743 51.1.3 TSC_HandleTypeDef ..................................................................... 743 TSC Firmware driver API description ............................................ 744 51.2.1 TSC specific features ..................................................................... 744 51.2.2 How to use this driver ..................................................................... 744 51.2.3 Initialization and de-initialization functions ..................................... 744 51.2.4 IO Operation functions.................................................................... 745 51.2.5 Peripheral Control functions ........................................................... 745 51.2.6 State and Errors functions .............................................................. 745 51.2.7 Detailed description of functions .................................................... 745 TSC Firmware driver defines......................................................... 749 51.3.1 52 HAL UART Generic Driver........................................................... 758 52.1 52.2 52.3 UART Firmware driver registers structures ................................... 758 52.1.1 UART_InitTypeDef ......................................................................... 758 52.1.2 UART_AdvFeatureInitTypeDef ....................................................... 759 52.1.3 UART_WakeUpTypeDef ................................................................ 759 52.1.4 UART_HandleTypeDef ................................................................... 760 UART Firmware driver API description ......................................... 761 52.2.1 How to use this driver ..................................................................... 761 52.2.2 Initialization and Configuration functions ........................................ 763 52.2.3 IO operation functions .................................................................... 764 52.2.4 Peripheral Control functions ........................................................... 764 52.2.5 Peripheral State and Error functions .............................................. 765 52.2.6 Detailed description of functions .................................................... 765 UART Firmware driver defines ...................................................... 773 52.3.1 53 UART .............................................................................................. 773 HAL UART Extension Driver ....................................................... 789 53.1 18/832 TSC................................................................................................. 749 UARTEx Firmware driver API description ..................................... 789 53.1.1 UART peripheral extended features ............................................... 789 53.1.2 Initialization and Configuration functions ........................................ 789 53.1.3 IO operation function ...................................................................... 789 53.1.4 Peripheral Control function ............................................................. 789 53.1.5 Detailed description of functions .................................................... 790 DOCID026526 Rev 4 UM1786 Contents 53.2 UARTEx Firmware driver defines .................................................. 792 53.2.1 54 HAL USART Generic Driver ........................................................ 793 54.1 54.2 54.3 USART Firmware driver registers structures ................................. 793 54.1.1 USART_InitTypeDef ....................................................................... 793 54.1.2 USART_HandleTypeDef ................................................................ 794 USART Firmware driver API description ....................................... 795 54.2.1 How to use this driver ..................................................................... 795 54.2.2 Initialization and Configuration functions ........................................ 797 54.2.3 IO operation functions .................................................................... 797 54.2.4 Peripheral State and Error functions .............................................. 798 54.2.5 Detailed description of functions .................................................... 798 USART Firmware driver defines.................................................... 804 54.3.1 55 USART............................................................................................ 804 HAL USART Extension Driver .................................................... 813 55.1 USARTEx Firmware driver defines ............................................... 813 55.1.1 56 UARTEx .......................................................................................... 792 USARTEx ....................................................................................... 813 HAL WWDG Generic Driver ........................................................ 814 56.1 56.2 56.3 WWDG Firmware driver registers structures ................................. 814 56.1.1 WWDG_InitTypeDef ....................................................................... 814 56.1.2 WWDG_HandleTypeDef ................................................................ 814 WWDG Firmware driver API description ....................................... 815 56.2.1 WWDG specific features ................................................................ 815 56.2.2 How to use this driver ..................................................................... 815 56.2.3 Initialization and de-initialization functions ..................................... 815 56.2.4 IO operation functions .................................................................... 816 56.2.5 Peripheral State functions .............................................................. 816 56.2.6 Detailed description of functions .................................................... 816 WWDG Firmware driver defines.................................................... 819 56.3.1 WWDG............................................................................................ 819 57 FAQs............................................................................................. 823 58 Revision history .......................................................................... 827 DOCID026526 Rev 4 19/832 List of tables UM1786 List of tables Table 1: Acronyms and definitions ............................................................................................................ 22 Table 2: HAL drivers files .......................................................................................................................... 24 Table 3: User-application files .................................................................................................................. 25 Table 4: APIs classification ....................................................................................................................... 29 Table 5: List of devices supported by HAL drivers ................................................................................... 31 Table 6: HAL API naming rules ................................................................................................................ 34 Table 7: Macros handling interrupts and specific clock configurations .................................................... 35 Table 8: Callback functions ....................................................................................................................... 36 Table 9: HAL generic APIs ....................................................................................................................... 37 Table 10: HAL extension APIs .................................................................................................................. 38 Table 11: Define statements used for HAL configuration ......................................................................... 42 Table 12: Description of GPIO_InitTypeDef structure .............................................................................. 44 Table 13: Description of EXTI configuration macros ................................................................................ 46 Table 14: MSP functions ........................................................................................................................... 51 Table 15: Timeout values ......................................................................................................................... 55 Table 16: Document revision history ...................................................................................................... 827 20/832 DOCID026526 Rev 4 UM1786 List of figures List of figures Figure 1: Example of project template ...................................................................................................... 26 Figure 2: Adding device-specific functions ............................................................................................... 39 Figure 3: Adding family-specific functions ................................................................................................ 39 Figure 4: Adding new peripherals ............................................................................................................. 40 Figure 5: Updating existing APIs .............................................................................................................. 40 Figure 6: File inclusion model ................................................................................................................... 41 Figure 7: HAL driver model ....................................................................................................................... 49 DOCID026526 Rev 4 21/832 Acronyms and definitions 1 UM1786 Acronyms and definitions Table 1: Acronyms and definitions 22/832 Acronym Definition ADC Analog-to-digital converter ANSI American National Standards Institute API Application Programming Interface BSP Board Support Package COMP Comparator CMSIS Cortex Microcontroller Software Interface Standard CPU Central Processing Unit CRYP Cryptographic processor unit CRC CRC calculation unit DAC Digital to analog converter DMA Direct Memory Access EXTI External interrupt/event controller FLASH Flash memory FMC Flexible Memory Controller GPIO General purpose I/Os HAL Hardware abstraction layer HRTIM High Resolution Timer I2C Inter-integrated circuit I2S Inter-integrated sound IRDA InfraRed Data Association IWDG Independent watchdog LCD Liquid Crystal Display Controler MSP MCU Specific Package NAND NAND Flash memory NOR NOR Flash memory NVIC Nested Vectored Interrupt Controller PCD USB Peripheral Controller Driver PWR Power controller RCC Reset and clock controller RNG Random Number Generator RTC Real-time clock SD Secure Digital SDADC Sigma-delta Analog-to-digital Converter SRAM SRAM external memory DOCID026526 Rev 4 UM1786 Acronyms and definitions Acronym Definition SMARTCARD Smartcard IC SPI Serial Peripheral interface SysTick System tick timer TIM Advanced-control, general-purpose or basic timer TSC Touch Sensing Controller UART Universal asynchronous receiver/transmitter USART Universal synchronous receiver/transmitter WWDG Window watchdog USB Universal Serial Bus PPP STM32 peripheral or block DOCID026526 Rev 4 23/832 Overview of HAL drivers 2 UM1786 Overview of HAL drivers The HAL drivers were designed to offer a rich set of APIs and to interact easily with the application upper layers. Each driver consists of a set of functions covering the most common peripheral features. The development of each driver is driven by a common API which standardizes the driver structure, the functions and the parameter names. The HAL drivers consist of a set of driver modules, each module being linked to a standalone peripheral. However, in some cases, the module is linked to a peripheral functional mode. As an example, several modules exist for the USART peripheral: UART driver module, USART driver module, SMARTCARD driver module and IRDA driver module. The HAL main features are the following: Cross-family portable set of APIs covering the common peripheral features as well as extension APIs in case of specific peripheral features. Three API programming models: polling, interrupt and DMA. APIs are RTOS compliant: Fully reentrant APIs Systematic usage of timeouts in polling mode. Peripheral multi-instance support allowing concurrent API calls for multiple instances of a given peripheral (USART1, USART2...) All HAL APIs implement user-callback functions mechanism: Peripheral Init/DeInit HAL APIs can call user-callback functions to perform peripheral system level Initialization/De-Initialization (clock, GPIOs, interrupt, DMA) Peripherals interrupt events Error events. Object locking mechanism: safe hardware access to prevent multiple spurious accesses to shared resources. Timeout used for all blocking processes: the timeout can be a simple counter or a timebase. 2.1 HAL and user-application files 2.1.1 HAL driver files A HAL drivers are composed of the following set of files: Table 2: HAL drivers files File 24/832 Description stm32f3xx_hal_ppp.c Main peripheral/module driver file. It includes the APIs that are common to all STM32 devices. Example: stm32f3xx_hal_adc.c, stm32f3xx_hal_irda.c, … stm32f3xx_hal_ppp.h Header file of the main driver C file It includes common data, handle and enumeration structures, define statements and macros, as well as the exported generic APIs. Example: stm32f3xx_hal_adc.h, stm32f3xx_hal_irda.h, … DOCID026526 Rev 4 UM1786 Overview of HAL drivers File Description stm32f3xx_hal_ppp_ex.c Extension file of a peripheral/module driver. It includes the specific APIs for a given part number or family, as well as the newly defined APIs that overwrite the default generic APIs if the internal process is implemented in different way. Example: stm32f3xx_hal_adc_ex.c, stm32f3xx_hal_dma_ex.c, … stm32f3xx_hal_ppp_ex.h Header file of the extension C file. It includes the specific data and enumeration structures, define statements and macros, as well as the exported device part number specific APIs Example: stm32f3xx_hal_adc_ex.h, stm32f3xx_hal_dma_ex.h, … stm32f3xx_hal.c This file is used for HAL initialization and contains DBGMCU, Remap and Time Delay based on systick APIs. stm32f3xx_hal.h stm32f3xx_hal.c header file stm32f3xx_hal_msp_template.c Template file to be copied to the user application folder. It contains the MSP initialization and de-initialization (main routine and callbacks) of the peripheral used in the user application. stm32f3xx_hal_conf_template.h Template file allowing to customize the drivers for a given application. stm32f3xx_hal_def.h 2.1.2 Common HAL resources such as common define statements, enumerations, structures and macros. User-application files The minimum files required to build an application using the HAL are listed in the table below: Table 3: User-application files File system_stm32f3xx.c Description This file contains SystemInit() which is called at startup just after reset and before branching to the main program. It does not configure the system clock at startup (contrary to the standard library). This is to be done using the HAL APIs in the user files. It allows to : relocate the vector table in internal SRAM. startup_stm32f3xx.s Toolchain specific file that contains reset handler and exception vectors. For some toolchains, it allows adapting the stack/heap size to fit the application requirements. stm32f3xx_flash.icf (optional) Linker file for EWARM toolchain allowing mainly to adapt the stack/heap size to fit the application requirements. stm32f3xx_hal_msp.c This file contains the MSP initialization and de-initialization (main routine and callbacks) of the peripheral used in the user application. stm32f3xx_hal_conf.h This file allows the user to customize the HAL drivers for a specific application. It is not mandatory to modify this configuration. The application can use the default configuration without any modification. DOCID026526 Rev 4 25/832 Overview of HAL drivers UM1786 File stm32f3xx_it.c/.h Description This file contains the exceptions handler and peripherals interrupt service routine, and calls HAL_IncTick() at regular time intervals to increment a local variable (declared in stm32f3xx_hal.c) used as HAL timebase. By default, this function is called each 1ms in Systick ISR. . The PPP_IRQHandler() routine must call HAL_PPP_IRQHandler() if an interrupt based process is used within the application. This file contains the main program routine, mainly: main.c/.h the call to HAL_Init() assert_failed() implementation system clock configuration peripheral HAL initialization and user application code. The STM32Cube package comes with ready-to-use project templates, one for each supported board. Each project contains the files listed above and a preconfigured project for the supported toolchains. Each project template provides empty main loop function and can be used as a starting point to get familiar with project settings for STM32Cube. Their characteristics are the following: It contains sources of HAL, CMSIS and BSP drivers which are the minimal components to develop a code on a given board. It contains the include paths for all the firmware components. It defines the STM32 device supported, and allows to configure the CMSIS and HAL drivers accordingly. It provides ready to use user files preconfigured as defined below: HAL is initialized SysTick ISR implemented for HAL_Delay() System clock configured with the maximum frequency of the device If an existing project is copied to another location, then include paths must be updated. Figure 1: Example of project template 26/832 DOCID026526 Rev 4 UM1786 2.2 Overview of HAL drivers HAL data structures Each HAL driver can contain the following data structures: 2.2.1 Peripheral handle structures Initialization and configuration structures Specific process structures. Peripheral handle structures The APIs have a modular generic multi-instance architecture that allows working with several IP instances simultaneously. PPP_HandleTypeDef *handle is the main structure that is implemented in the HAL drivers. It handles the peripheral/module configuration and registers and embeds all the structures and variables needed to follow the peripheral device flow. The peripheral handle is used for the following purposes: Multi instance support: each peripheral/module instance has its own handle. As a result instance resources are independent. Peripheral process intercommunication: the handle is used to manage shared data resources between the process routines. Example: global pointers, DMA handles, state machine. Storage : this handle is used also to manage global variables within a given HAL driver. An example of peripheral structure is shown below: typedef struct { USART_TypeDef *Instance; /* USART registers base address */ USART_InitTypeDef Init; /* Usart communication parameters */ uint8_t *pTxBuffPtr;/* Pointer to Usart Tx transfer Buffer */ uint16_t TxXferSize; /* Usart Tx Transfer size */ __IO uint16_t TxXferCount;/* Usart Tx Transfer Counter */ uint8_t *pRxBuffPtr;/* Pointer to Usart Rx transfer Buffer */ uint16_t RxXferSize; /* Usart Rx Transfer size */ __IO uint16_t RxXferCount; /* Usart Rx Transfer Counter */ DMA_HandleTypeDef *hdmatx; /* Usart Tx DMA Handle parameters */ DMA_HandleTypeDef *hdmarx; /* Usart Rx DMA Handle parameters */ HAL_LockTypeDef Lock; /* Locking object */ __IO HAL_USART_StateTypeDef State; /* Usart communication state */ __IO HAL_USART_ErrorTypeDef ErrorCode;/* USART Error code */ }USART_HandleTypeDef; 1) The multi-instance feature implies that all the APIs used in the application are re-entrant and avoid using global variables because subroutines can fail to be reentrant if they rely on a global variable to remain unchanged but that variable is modified when the subroutine is recursively invoked. For this reason, the following rules are respected: Re-entrant code does not hold any static (or global) non-constant data: reentrant functions can work with global data. For example, a re-entrant interrupt service routine can grab a piece of hardware status to work with (e.g. serial port read buffer) which is not only global, but volatile. Still, typical use of static variables and global data is not advised, in the sense that only atomic read-modify-write instructions should be used in these variables. It should not be possible for an interrupt or signal to occur during the execution of such an instruction. Reentrant code does not modify its own code. DOCID026526 Rev 4 27/832 Overview of HAL drivers UM1786 2) When a peripheral can manage several processes simultaneously using the DMA (full duplex case), the DMA interface handle for each process is added in the PPP_HandleTypeDef. 3) For the shared and system peripherals, no handle or instance object is used. The peripherals concerned by this exception are the following: 2.2.2 GPIO SYSTICK NVIC PWR RCC FLASH. Initialization and configuration structure These structures are defined in the generic driver header file when it is common to all part numbers. When they can change from one part number to another, the structures are defined in the extension header file for each part number. typedef struct { uint32_t BaudRate; /*!< This member configures the UART communication baudrate.*/ uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.*/ uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.*/ uint32_t Parity; /*!< Specifies the parity mode. */ uint32_t Mode; /*!< Specifies wether the Receive or Transmit mode is enabled or disabled.*/ uint32_t HwFlowCtl; /*!< Specifies wether the hardware flow control mode is enabled or disabled.*/ uint32_t OverSampling; /*!< Specifies wether the Over sampling 8 is enabled or disabled, to achieve higher speed (up to fPCLK/8).*/ }UART_InitTypeDef; The config structure is used to initialize the sub-modules or sub-instances. See below example: HAL_ADC_ConfigChannel (ADC_HandleTypeDef* hadc, ADC_ChannelConfTypeDef* sConfig) 2.2.3 Specific process structures The specific process structures are used for specific process (common APIs). They are defined in the generic driver header file. Example: HAL_PPP_Process (PPP_HandleTypeDef* hadc,PPP_ProcessConfig* sConfig) 28/832 DOCID026526 Rev 4 UM1786 2.3 Overview of HAL drivers API classification The HAL APIs are classified into three categories: Generic APIs: common generic APIs applying to all STM32 devices. These APIs are consequently present in the generic HAL drivers files of all STM32 microcontrollers. HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc); HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc); HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef* hadc); HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef* hadc); HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef* hadc); HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef* hadc); void HAL_ADC_IRQHandler(ADC_HandleTypeDef* hadc); Extension APIs: This set of API is divided into two sub-categories : Family specific APIs: APIs applying to a given family. They are located in the extension HAL driver file (see example below related to the ADC). HAL_StatusTypeDef HAL_ADCEx_Calibration_Start(ADC_HandleTypeDef* hadc, uint32_t SingleDiff); uint32_t HAL_ADCEx_Calibration_GetValue(ADC_HandleTypeDef* hadc, uint32_t SingleDiff); Device part number specific APIs: These APIs are implemented in the extension file and delimited by specific define statements relative to a given part number. #if defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \ defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \ defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx) || \ defined(STM32F373xC) || defined(STM32F378xx) #endif /* STM32F302xC || STM32F303xC || STM32F358xx || */ /* STM32F303x8 || STM32F334x8 || STM32F328xx || */ /* STM32F301x8 || STM32F302x8 || STM32F318xx */ /* STM32F373xC || STM32F378xx */ The data structure related to the specific APIs is delimited by the device part number define statement. It is located in the corresponding extension header C file. The following table summarizes the location of the different categories of HAL APIs in the driver files. Table 4: APIs classification Generic file Common APIs X Extension file X (1) Family specific APIs X Device specific APIs X Notes: (1) In some cases, the implementation for a specific device part number may change . In this case the generic API is declared as weak function in the extension file. The API is implemented again to overwrite the default function DOCID026526 Rev 4 29/832 Overview of HAL drivers UM1786 Family specific APIs are only related to a given family. This means that if a specific API is implemented in another family, and the arguments of this latter family are different, additional structures and arguments might need to be added. The IRQ handlers are used for common and family specific processes. 2.4 30/832 Devices supported by HAL drivers DOCID026526 Rev 4 UM1786 Overview of HAL drivers IP/Module STM32F301x6/x8 STM32F302x6/x8 STM32F302xB/xC STM32F302xE STM32F303x6/x8 STM32F303xC STM32F303xE STM32F373xB/xC STM32F334x6/x8 STM32F318xx STM32F328xx STM32F358xx STM32F378xx STM32F398xx Table 5: List of devices supported by HAL drivers stm32f3xx_hal.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_adc.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_adc_ex.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_can.c No Yes Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes stm32f3xx_hal_cec.c No No No No No No No Yes No No No No Yes No stm32f3xx_hal_comp.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_cortex.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_crc.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_crc_ex.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_dac.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_dac_ex.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_dma.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_flash.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_flash_ex.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_gpio.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_hrtim.c No No No No No No No No Yes No Yes No No No stm32f3xx_hal_i2c.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_i2c_ex.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_i2s.c Yes Yes Yes Yes No Yes Yes Yes No Yes No Yes Yes Yes stm32f3xx_hal_i2s_ex.c Yes Yes Yes Yes No Yes Yes Yes No Yes No Yes Yes Yes DOCID026526 Rev 4 31/832 32/832 IP/Module STM32F302x6/x8 STM32F302xB/xC STM32F302xE STM32F303x6/x8 STM32F303xC STM32F303xE STM32F373xB/xC STM32F334x6/x8 STM32F318xx STM32F328xx STM32F358xx STM32F378xx STM32F398xx UM1786 STM32F301x6/x8 Overview of HAL drivers stm32f3xx_hal_irda.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_iwdg.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_msp_template.c NA NA NA NA NA NA NA NA NA NA NA NA NA NA stm32f3xx_hal_nand.c No No No Yes No No Yes No No No No No No Yes stm32f3xx_hal_nor.c No No No Yes No No Yes No No No No No No Yes stm32f3xx_hal_opamp.c Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes No Yes stm32f3xx_hal_opamp_ex.c Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes No Yes stm32f3xx_hal_pcd.c No Yes Yes Yes No Yes Yes Yes No No No No No Yes stm32f3xx_hal_pcd_ex.c No Yes Yes Yes No Yes Yes Yes No No No No No Yes stm32f3xx_hal_pccard.c No No No Yes No No Yes No No No No No No Yes stm32f3xx_hal_pwr.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_pwr_ex.c Yes Yes Yes Yes Yes Yes Yes Yes Yes No No No Yes Yes stm32f3xx_hal_rcc.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_rcc_ex.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_rtc.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_rtc_ex.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_sdadc.c No No No No No No No Yes No No No No Yes No stm32f3xx_hal_smartcard.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_smartcard_ex.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_smbus.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes DOCID026526 Rev 4 IP/Module STM32F302x6/x8 STM32F302xB/xC STM32F302xE STM32F303x6/x8 STM32F303xC STM32F303xE STM32F373xB/xC STM32F334x6/x8 STM32F318xx STM32F328xx STM32F358xx STM32F378xx STM32F398xx Overview of HAL drivers STM32F301x6/x8 UM1786 stm32f3xx_hal_spi.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_sram.c No No No Yes No No Yes No No No No No No Yes stm32f3xx_hal_tim.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_tim_ex.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_tsc.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_uart.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_uart_ex.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_usart.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_hal_wwdg.c Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes stm32f3xx_ll_fmc.c No No No Yes No No Yes No No No No No No Yes DOCID026526 Rev 4 33/832 UM1786 2.5 HAL drivers rules 2.5.1 HAL API naming rules The following naming rules are used in HAL drivers: Table 6: HAL API naming rules File names Generic Family specific Device specific stm32f3xx_hal_ppp (c/h) stm32f3xx_hal_ppp_ex (c/h) stm32f3xx_ hal_ppp_ex (c/h) Module name Functio n name HAL_PPP_Function HAL_PPP_FeatureFunction_ MODE HAL_PPPEx_Function HAL_PPPEx_FeatureFunction_ MODE HAL_PPPEx_Function HAL_PPPEx_FeatureFunction_ MODE Handle name PPP_HandleTypedef NA NA Init structu re name PPP_InitTypeDef NA PPP_InitTypeDef Enum name HAL_PPP_StructnameTypeD ef NA NA 34/832 HAL_PPP_ MODULE The PPP prefix refers to the peripheral functional mode and not to the peripheral itself. For example, if the USART, PPP can be USART, IRDA, UART or SMARTCARD depending on the peripheral mode. The constants used in one file are defined within this file. A constant used in several files is defined in a header file. All constants are written in uppercase, except for peripheral driver function parameters. typedef variable names should be suffixed with _TypeDef. Registers are considered as constants. In most cases, their name is in uppercase and uses the same acronyms as in the STM32F3xx reference manuals. Peripheral registers are declared in the PPP_TypeDef structure (e.g. ADC_TypeDef) in the CMSIS header file corresponding to the selected platform: stm32f301x8.h, stm32f302x8.h, stm32f302xc.h, stm32f302xe.h, stm32f303x8.h, stm32f303xc.h, stm32f303xe.h, stm32f318xx.h, stm32f328xx.h, stm32f334x8.h, stm32f358xx.h, stm32f373xc.h, stm32f378xx.h and stm32f398xx.h . The platform is selected by enabling the compilation switch in the compilation toolchain directive or in the stm32f3xx.h file. Peripheral function names are prefixed by HAL_, then the corresponding peripheral acronym in uppercase followed by an underscore. The first letter of each word is in uppercase (e.g. HAL_UART_Transmit()). Only one underscore is allowed in a function name to separate the peripheral acronym from the rest of the function name. The structure containing the PPP peripheral initialization parameters are named PPP_InitTypeDef (e.g. ADC_InitTypeDef). The structure containing the Specific configuration parameters for the PPP peripheral are named PPP_xxxxConfTypeDef (e.g. ADC_ChannelConfTypeDef). Peripheral handle structures are named PPP_HandleTypedef (e.g DMA_HandleTypeDef) The functions used to initialize the PPP peripheral according to parameters specified in PPP_InitTypeDef are named HAL_PPP_Init (e.g. HAL_TIM_Init()). DOCID026526 Rev 4 UM1786 2.5.2 The functions used to reset the PPP peripheral registers to their default values are named PPP_DeInit, e.g. TIM_DeInit. The MODE suffix refers to the process mode, which can be polling, interrupt or DMA. As an example, when the DMA is used in addition to the native resources, the function should be called: HAL_PPP_Function_DMA (). The Feature prefix should refer to the new feature. Example: HAL_ADC_Start() refers to the injection mode HAL general naming rules For the shared and system peripherals, no handle or instance object is used. This rule applies to the following peripherals: GPIO SYSTICK NVIC RCC FLASH. Example: The HAL_GPIO_Init() requires only the GPIO address and its configuration parameters. HAL_StatusTypeDef HAL_GPIO_Init (GPIO_TypeDef* GPIOx, GPIO_InitTypeDef *Init) { /*GPIO Initialization body */ } The macros that handle interrupts and specific clock configurations are defined in each peripheral/module driver. These macros are exported in the peripheral driver header files so that they can be used by the extension file. The list of these macros is defined below: This list is not exhaustive and other macros related to peripheral features can be added, so that they can be used in the user application. Table 7: Macros handling interrupts and specific clock configurations Macros Description __HAL_PPP_ENABLE_IT(__HANDLE__, __INTERRUPT__) Enables a specific peripheral interrupt __HAL_PPP_DISABLE_IT(__HANDLE__, __INTERRUPT__) Disables a specific peripheral interrupt __HAL_PPP_GET_IT (__HANDLE__, __ INTERRUPT __) Gets a specific peripheral interrupt status __HAL_PPP_CLEAR_IT (__HANDLE__, __ INTERRUPT __) Clears a specific peripheral interrupt status __HAL_PPP_GET_FLAG (__HANDLE__, __FLAG__) Gets a specific peripheral flag status __HAL_PPP_CLEAR_FLAG (__HANDLE__, __FLAG__) Clears a specific peripheral flag status __HAL_PPP_ENABLE(__HANDLE__) Enables a peripheral __HAL_PPP_DISABLE(__HANDLE__) Disables a peripheral __HAL_PPP_XXXX (__HANDLE__, __PARAM__) Specific PPP HAL driver macro __HAL_PPP_GET_ IT_SOURCE (__HANDLE__, __ INTERRUPT __) Checks the source of specified interrupt DOCID026526 Rev 4 35/832 UM1786 NVIC and SYSTICK are two ARM Cortex core features. The APIs related to these features are located in the stm32f3xx_hal_cortex.c file. When a status bit or a flag is read from registers, it is composed of shifted values depending on the number of read values and of their size. In this case, the returned status width is 32 bits. Example : STATUS = XX | (YY << 16) or STATUS = XX | (YY << 8) | (YY << 16) | (YY << 24)". The PPP handles are valid before using the HAL_PPP_Init() API. The init function performs a check before modifying the handle fields. HAL_PPP_Init(PPP_HandleTypeDef) if(hppp == NULL) { return HAL_ERROR; } The macros defined below are used: Conditional macro:#define ABS(x) (((x) > 0) ? (x) : -(x)) Pseudo-code macro (multiple instructions macro): #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD_, __DMA_HANDLE_) \ do{ \ (__HANDLE__)->__PPP_DMA_FIELD_ = &(__DMA_HANDLE_); \ (__DMA_HANDLE_).Parent = (__HANDLE__); \ } while(0) 2.5.3 HAL interrupt handler and callback functions Besides the APIs, HAL peripheral drivers include: HAL_PPP_IRQHandler() peripheral interrupt handler that should be called from stm32f3xx_it.c User callback functions. The user callback functions are defined as empty functions with “weak” attribute. They have to be defined in the user code. There are three types of user callbacks functions: Peripheral system level initialization/ de-Initialization callbacks: HAL_PPP_MspInit() and HAL_PPP_MspDeInit Process complete callbacks : HAL_PPP_ProcessCpltCallback Error callback: HAL_PPP_ErrorCallback. Table 8: Callback functions Callback functions HAL_PPP_MspInit() / _DeInit() Ex: HAL_USART_MspInit() Called from HAL_PPP_Init() API function to perform peripheral system level initialization (GPIOs, clock, DMA, interrupt) HAL_PPP_ProcessCpltCallback Ex: HAL_USART_TxCpltCallback Called by peripheral or DMA interrupt handler when the process completes HAL_PPP_ErrorCallback 36/832 Example Ex: HAL_USART_ErrorCallback Called by peripheral or DMA interrupt handler when an error occurs DOCID026526 Rev 4 UM1786 2.6 HAL generic APIs The generic APIs provide common generic functions applying to all STM32 devices. They are composed of four APIs groups: Initialization and de-initialization functions:HAL_PPP_Init(), HAL_PPP_DeInit() IO operation functions: HAL_PPP_Read(), HAL_PPP_Write(),HAL_PPP_Transmit(), HAL_PPP_Receive() Control functions: HAL_PPP_Set (), HAL_PPP_Get (). State and Errors functions: HAL_PPP_GetState (), HAL_PPP_GetError (). For some peripheral/module drivers, these groups are modified depending on the peripheral/module implementation. Example: in the timer driver, the API grouping is based on timer features (PWM, OC, IC...). The initialization and de-initialization functions allow initializing a peripheral and configuring the low-level resources, mainly clocks, GPIO, alternate functions (AF) and possibly DMA and interrupts. The HAL_DeInit()function restores the peripheral default state, frees the low-level resources and removes any direct dependency with the hardware. The IO operation functions perform a row access to the peripheral payload data in write and read modes. The control functions are used to change dynamically the peripheral configuration and set another operating mode. The peripheral state and errors functions allow retrieving in runtime the peripheral and data flow states, and identifying the type of errors that occurred. The example below is based on the ADC peripheral. The list of generic APIs is not exhaustive. It is only given as an example. Table 9: HAL generic APIs Function Group Common API Name Description HAL_ADC_Init() This function initializes the peripheral and configures the low -level resources (clocks, GPIO, AF..) HAL_ADC_DeInit() This function restores the peripheral default state, frees the low-level resources and removes any direct dependency with the hardware. HAL_ADC_Start () This function starts ADC conversions when the polling method is used HAL_ADC_Stop () This function stops ADC conversions when the polling method is used HAL_ADC_PollForConversion() This function allows waiting for the end of conversions when the polling method is used. In this case, a timout value is specified by the user according to the application. HAL_ADC_Start_IT() This function starts ADC conversions when the interrupt method is used HAL_ADC_Stop_IT() This function stops ADC conversions when the interrupt method is used HAL_ADC_IRQHandler() This function handles ADC interrupt requests Initialization group IO operation group DOCID026526 Rev 4 37/832 UM1786 Function Group Common API Name Description HAL_ADC_ConvCpltCallback() Callback function called in the IT subroutine to indicate the end of the current process or when a DMA transfer has completed HAL_ADC_ErrorCallback() Callback function called in the IT subroutine if a peripheral error or a DMA transfer error occurred HAL_ADC_ConfigChannel() This function configures the selected ADC regular channel, the corresponding rank in the sequencer and the sample time HAL_ADC_AnalogWDGConfig This function configures the analog watchdog for the selected ADC HAL_ADC_GetState() This function allows getting in runtime the peripheral and the data flow states. HAL_ADC_GetError() This fuction allows getting in runtime the error that occurred during IT routine Control group State and Errors group 2.7 HAL extension APIs 2.7.1 HAL extension model overview The extension APIs provide specific functions or overwrite modified APIs for a specific family (series) or specific part number within the same family. The extension model consists of an additional file, stm32f3xx_hal_ppp_ex.c, that includes all the specific functions and define statements (stm32f3xx_hal_ppp_ex.h) for a given part number. Below an example based on the ADC peripheral: Table 10: HAL extension APIs 38/832 Function Group Common API Name HAL_ADCEx_Calibration_Start() This function is used to start the automatic ADC calibration HAL_ADCEx_Calibration_GetValue() This function is used to get the ADC calibration factor HAL_ADCEx_Calibration_SetValue() This function is used to set the calibration factor to overwrite automatic conversion result DOCID026526 Rev 4 UM1786 2.7.2 HAL extension model cases The specific IP features can be handled by the HAL drivers in five different ways. They are described below. Case1: Adding a part number-specific function When a new feature specific to a given device is required, the new APIs are added in the stm32f3xx_hal_adc_ex.c extension file. They are named HAL_PPPEx_Function(). Figure 2: Adding device-specific functions Example: stm32f3xx_hal_adc_ex.c/h #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \ defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \ defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \ defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx) HAL_StatusTypeDef HAL_ADCEx_Calibration_Start(struct __ADC_HandleTypeDef* hadc, uint32_t SingleDiff); uint32_t HAL_ADCEx_Calibration_GetValue(struct __ADC_HandleTypeDef *hadc, uint32_t SingleDiff); HAL_StatusTypeDef HAL_ADCEx_Calibration_SetValue(struct __ADC_HandleTypeDef *hadc, uint32_t SingleDiff, uint32_t CalibrationFactor); #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */ /* STM32F302xC || STM32F303xC || STM32F358xx || */ /* STM32F303x8 || STM32F334x8 || STM32F328xx || */ /* STM32F301x8 || STM32F302x8 || STM32F318xx */ Case2: Adding a family-specific function In this case, the API is added in the extension driver C file and named HAL_PPPEx_Function (). Figure 3: Adding family-specific functions DOCID026526 Rev 4 39/832 UM1786 Case3 : Adding a new peripheral (specific to a device belonging to a given family) When a peripheral which is available only in a specific device is required, the APIs corresponding to this new peripheral/module are added in stm32f3xx_hal_newppp.c. However the inclusion of this file is selected in the stm32f3xx_hal_conf.h using the macro: #define HAL_NEWPPP_MODULE_ENABLED Figure 4: Adding new peripherals Example: stm32f3xx_hal_sdadc.c/h Case4: Updating existing common APIs In this case, the routines are defined with the same names in the stm32f3xx_hal_ppp_ex.c extension file, while the generic API is defined as weak, so that the compiler will overwrite the original routine by the new defined function. Figure 5: Updating existing APIs Case5 : Updating existing data structures The data structure for a specific device part number (e.g. PPP_InitTypeDef) can have different fields. In this case, the data structure is defined in the extension header file and delimited by the specific part number define statement. Example: #if defined(STM32F373xC) || defined(STM32F378xx) typedef struct { (...) }PPP_InitTypeDef; #endif /* STM32F373xC || STM32F378xx */ 40/832 DOCID026526 Rev 4 UM1786 2.8 File inclusion model The header of the common HAL driver file (stm32f3xx_hal.h) includes the common configurations for the whole HAL library. It is the only header file that is included in the user sources and the HAL C sources files to be able to use the HAL resources. Figure 6: File inclusion model A PPP driver is a standalone module which is used in a project. The user must enable the corresponding USE_HAL_PPP_MODULE define statement in the configuration file. /********************************************************************* * @file stm32f3xx_hal_conf.h * @author MCD Application Team * @version VX.Y.Z * @date dd-mm-yyyy * @brief This file contains the modules to be used ********************************************************************** (…) #define USE_HAL_USART_MODULE #define USE_HAL_IRDA_MODULE #define USE_HAL_DMA_MODULE #define USE_HAL_RCC_MODULE (…) 2.9 HAL common resources The common HAL resources, such as common define enumerations, structures and macros, are defined in stm32f3xx_hal_def.h.The main common define enumeration is HAL_StatusTypeDef. HAL Status The HAL status is used by almost all HAL APIs, except for boolean functions and IRQ handler. It returns the status of the current API operations. It has four possible values as described below: Typedef enum { HAL_OK = 0x00, HAL_ERROR = 0x01, HAL_BUSY = 0x02, HAL_TIMEOUT = 0x03 } HAL_StatusTypeDef; DOCID026526 Rev 4 41/832 UM1786 HAL Locked The HAL lock is used by all HAL APIs to prevent accessing by accident shared resources. typedef enum { HAL_UNLOCKED = 0x00, /*!<Resources unlocked */ HAL_LOCKED = 0x01 /*!< Resources locked */ } HAL_LockTypeDef; In addition to common resources, the stm32f3xx_hal_def.h file calls the stm32f3xx.h file in CMSIS library to get the data structures and the address mapping for all peripherals: Declarations of peripheral registers and bits definition. Macros to access peripheral registers hardware (Write register, Read register…etc.). Common macros Macro defining HAL_MAX_DELAY #define HAL_MAX_DELAY 0xFFFFFFFF Macro linking a PPP peripheral to a DMA structure pointer: __HAL_LINKDMA(); #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD_, __DMA_HANDLE_) \ do{ \ (__HANDLE__)->__PPP_DMA_FIELD_ = &(__DMA_HANDLE_); \ (__DMA_HANDLE_).Parent = (__HANDLE__); \ } while(0) 2.10 HAL configuration The configuration file, stm32f3xx_hal_conf.h, allows customizing the drivers for the user application. Modifying this configuration is not mandatory: the application can use the default configuration without any modification. To configure these parameters, the user should enable, disable or modify some options by uncommenting, commenting or modifying the values of the related define statements as described in the table below: Table 11: Define statements used for HAL configuration Configuration item Description Default Value HSE_VALUE Defines the value of the external oscillator (HSE) expressed in Hz. The user must adjust this define statement when using a different crystal value. 8 000 000 (Hz) Timeout for HSE start up, expressed in ms 5000 HSI_VALUE Defines the value of the internal oscillator (HSI) expressed in Hz. 16 000 000 (Hz) HSI_STARTUP_TIMEOUT Timeout for HSI start up, expressed in ms 5000 LSE_VALUE Defines the value of the external oscillator (HSE) expressed in Hz. The user must adjust this define statement when using a different crystal value. 32768 (Hz) LSE_STARTUP_TIMEOUT Timeout for LSE start up, expressed in ms 5000 LSI_VALUE Defines the value of the Internal Low Speed oscillator expressed in Hz. The real value may vary depending on the variations in voltage and temperature. 40 000 (Hz) VDD_VALUE VDD value 3300 (mV) USE_RTOS Enables the use of RTOS FALSE (for future use) HSE_STARTUP_TIMEOUT 42/832 DOCID026526 Rev 4 UM1786 Configuration item Description Default Value PREFETCH_ENABLE Enables prefetch feature TRUE The stm32f3xx_hal_conf_template.h file is located in the HAL drivers Inc folder. It should be copied to the user folder, renamed and modified as described above. By default, the values defined in the stm32f3xx_hal_conf_template.h file are the same as the ones used for the examples and demonstrations. All HAL include files are enabled so that they can be used in the user code without modifications. 2.11 HAL system peripheral handling This chapter gives an overview of how the system peripherals are handled by the HAL drivers. The full API list is provided within each peripheral driver description section. 2.11.1 Clock Two main functions can be used to configure the system clock: HAL_RCC_OscConfig (RCC_OscInitTypeDef *RCC_OscInitStruct). This function configures/enables multiple clock sources (HSE, HSI, LSE, LSI, PLL). HAL_RCC_ClockConfig (RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency). This function Selects the system clock source Configures AHB and APB clock dividers Configures the number of Flash memory wait states Updates the SysTick configuration when HCLK clock changes. Some peripheral clocks are not derived from the system clock (RTC, USB…). In this case, the clock configuration is performed by an extended API defined in stm32f3xx_hal_rcc_ex.c: HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit). Additional RCC HAL driver functions are available: HAL_RCC_DeInit() Clock de-init function that return clock configuration to reset state Get clock functions that allow retreiving various clock configurations (system clock, HCLK, PCLK1, …) MCO and CSS configuration functions A set of macros are defined in stm32f3xx_hal_rcc.h and stm32f3xx_hal_rcc_ex.h. They allow executing elementary operations on RCC block registers, such as peripherals clock gating/reset control: __PPP_CLK_ENABLE/__PPP_CLK_DISABLE to enable/disable the peripheral clock __PPP_FORCE_RESET/__PPP_RELEASE_RESET to force/release peripheral reset __PPP_CLK_SLEEP_ENABLE/__PPP_CLK_SLEEP_DISABLE to enable/disable the peripheral clock during low power (Sleep) mode. DOCID026526 Rev 4 43/832 UM1786 2.11.2 GPIOs GPIO HAL APIs are the following: HAL_GPIO_Init() / HAL_GPIO_DeInit() HAL_GPIO_ReadPin() / HAL_GPIO_WritePin() HAL_GPIO_TogglePin (). In addition to standard GPIO modes (input, output, analog), pin mode can be configured as EXTI with interrupt or event generation. When selecting EXTI mode with interrupt generation, the user must call HAL_GPIO_EXTI_IRQHandler() from stm32f3xx_it.c and implement HAL_GPIO_EXTI_Callback() The table below describes the GPIO_InitTypeDef structure field. Table 12: Description of GPIO_InitTypeDef structure Structure field Pin Description Specifies the GPIO pins to be configured. Possible values: GPIO_PIN_x or GPIO_PIN_All, where x[0..15] Specifies the operating mode for the selected pins: GPIO mode or EXTI mode. Possible values are: Mode Pull Speed 44/832 GPIO mode GPIO_MODE_INPUT : Input Floating GPIO_MODE_OUTPUT_PP : Output Push Pull GPIO_MODE_OUTPUT_OD : Output Open Drain GPIO_MODE_AF_PP : Alternate Function Push Pull GPIO_MODE_AF_OD : Alternate Function Open Drain GPIO_MODE_ANALOG : Analog mode External Interrupt Mode GPIO_MODE_IT_RISING : Rising edge trigger detection GPIO_MODE_IT_FALLING : Falling edge trigger detection GPIO_MODE_IT_RISING_FALLING : Rising/Falling edge trigger detection External Event Mode GPIO_MODE_EVT_RISING : Rising edge trigger detection GPIO_MODE_EVT_FALLING : Falling edge trigger detection GPIO_MODE_EVT_RISING_FALLING: Rising/Falling edge trigger detection Specifies the Pull-up or Pull-down activation for the selected pins. Possible values are: GPIO_NOPULL GPIO_PULLUP GPIO_PULLDOWN Specifies the speed for the selected pins Possible values are: GPIO_SPEED_FREQ_LOW GPIO_SPEED_FREQ_MEDIUM GPIO_SPEED_FREQ_HIGH DOCID026526 Rev 4 UM1786 Structure field Description Peripheral to be connected to the selected pins. Possible values: GPIO_AFx_PPP, where AFx: is the alternate function index PPP: is the peripheral instance Example: use GPIO_AF1_TIM2 to connect TIM2 IOs on AF1. These values are defined in the GPIO extended driver, since the AF mapping may change between product lines. Alternate Refer to the “Alternate function mapping” table in the datasheets for the detailed description of the system and peripheral I/O alternate functions. Please find below typical GPIO configuration examples: Configuring GPIOs as output push-pull to drive external LEDs GPIO_InitStruct.Pin = GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); Configuring PA0 as external interrupt with falling edge sensitivity: GPIO_InitStructure.Mode = GPIO_MODE_IT_FALLING; GPIO_InitStructure.Pull = GPIO_NOPULL; GPIO_InitStructure.Pin = GPIO_PIN_0; HAL_GPIO_Init(GPIOA, &GPIO_InitStructure); Configuring USART1 Tx (PA9, mapped on AF4) as alternate function: GPIO_InitStruct.Pin = GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Alternate = GPIO_AF4_USART1; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 2.11.3 Cortex NVIC and SysTick timer The Cortex HAL driver, stm32f3xx_hal_cortex.c, provides APIs to handle NVIC and Systick. The supported APIs include: HAL_NVIC_SetPriority() HAL_NVIC_EnableIRQ()/HAL_NVIC_DisableIRQ() HAL_NVIC_SystemReset() HAL_SYSTICK_IRQHandler() HAL_NVIC_GetPendingIRQ() / HAL_NVIC_SetPendingIRQ () / HAL_NVIC_ClearPendingIRQ() HAL_SYSTICK_Config() HAL_SYSTICK_CLKSourceConfig() DOCID026526 Rev 4 45/832 UM1786 2.11.4 HAL_SYSTICK_Callback() PWR The PWR HAL driver handles power management. The features shared between all STM32 Series are listed below: 2.11.5 PVD configuration, enabling/disabling and interrupt handling HAL_PWR_PVDConfig() HAL_PWR_EnablePVD() / HAL_PWR_DisablePVD() HAL_PWR_PVD_IRQHandler() HAL_PWR_PVDCallback() Wakeup pin configuration HAL_PWR_EnableWakeUpPin() / HAL_PWR_DisableWakeUpPin() Low power mode entry HAL_PWR_EnterSLEEPMode() HAL_PWR_EnterSTOPMode() HAL_PWR_EnterSTANDBYMode() Backup domain configuration HAL_PWR_EnableBkUpAccess()/ HAL_PWR_DisableBkUpAccess() EXTI The EXTI is not considered as a standalone peripheral but rather as a service used by other peripheral. As a result there are no EXTI APIs but each peripheral HAL driver implements the associated EXTI configuration and EXTI function are implemented as macros in its header file. The first 16 EXTI lines connected to the GPIOs are managed within the GPIO driver. The GPIO_InitTypeDef structure allows configuring an I/O as external interrupt or external event. The EXTI lines connected internally to the PVD, RTC, USB, and COMP are configured within the HAL drivers of these peripheral through the macros given in the table below. The EXTI internal connections depend on the targeted STM32 microcontroller (refer to the product datasheet for more details): Table 13: Description of EXTI configuration macros Macros Description Defines the EXTI line connected to the internal peripheral. Example: #define PWR_EXTI_LINE_PVD ((uint32_t)0x00010000) /*!<External interrupt line 16 Connected to the PVD EXTI Line */ PPP_EXTI_LINE_FUNCTION 46/832 __HAL_PPP_EXTI_ENABLE_IT Enables a given EXTI line Example: __HAL_PWR_PVD_EXTI_ENABLE_IT() __HAL_PPP_EXTI_DISABLE_IT Disables a given EXTI line. Example: __HAL_PWR_PVD_EXTI_DISABLE_IT() __HAL_PPP_EXTI_GET_FLAG Gets a given EXTI line interrupt flag pending bit status. Example: __HAL_PWR_PVD_EXTI_GET_FLAG() DOCID026526 Rev 4 UM1786 Macros Description __HAL_PPP_EXTI_CLEAR_FLAG __HAL_PPP_EXTI_GENERATE_SWIT Clears a given EXTI line interrupt flag pending bit. Example; __HAL_PWR_PVD_EXTI_CLEAR_FLAG() Generates a software interrupt for a given EXTI line. Example: __HAL_PWR_PVD_EXTI_GENERATE_SWIT() __HAL_PPP_EXTI_ENABLE_EVENT Enables event on a given EXTI Line Example: _HAL_PWR_PVD_EXTI_ENABLE_EVENT() __HAL_PPP_EXTI_DISABLE_EVENT Disables event on a given EXTI line Example: __HAL_PWR_PVD_EXTI_DISABLE_EVENT() If the EXTI interrupt mode is selected, the user application must call HAL_PPP_FUNCTION_IRQHandler() (for example HAL_PWR_PVD_IRQHandler()), from stm32f3xx_it.c file, and implement HAL_PPP_FUNCTIONCallback() callback function (for example HAL_PWR_PVDCallback(). 2.11.6 DMA The DMA HAL driver allows enabling and configuring the peripheral to be connected to the DMA Channels (except for internal SRAM/FLASH memory which do not require any initialization). Refer to the product reference manual for details on the DMA request corresponding to each peripheral. For a given channel, HAL_DMA_Init() API allows programming the required configuration through the following parameters: Transfer Direction Source and Destination data formats Circular, Normal or peripheral flow control mode Channels Priority level Source and Destination Increment mode FIFO mode and its Threshold (if needed) Burst mode for Source and/or Destination (if needed). Two operating modes are available: Polling mode I/O operation a. Use HAL_DMA_Start() to start DMA transfer when the source and destination addresses and the Length of data to be transferred have been configured. b. Use HAL_DMA_PollForTransfer() to poll for the end of current transfer. In this case a fixed timeout can be configured depending on the user application. Interrupt mode I/O operation a. Configure the DMA interrupt priority using HAL_NVIC_SetPriority() b. Enable the DMA IRQ handler using HAL_NVIC_EnableIRQ() c. Use HAL_DMA_Start_IT() to start DMA transfer when the source and destination addresses and the length of data to be transferred have been confgured. In this case the DMA interrupt is configured. d. Use HAL_DMA_IRQHandler() called under DMA_IRQHandler() Interrupt subroutine DOCID026526 Rev 4 47/832 e. UM1786 When data transfer is complete, HAL_DMA_IRQHandler() function is executed and a user function can be called by customizing XferCpltCallback and XferErrorCallback function pointer (i.e. a member of DMA handle structure). Additional functions and macros are available to ensure efficient DMA management: Use HAL_DMA_GetState() function to return the DMA state and HAL_DMA_GetError() in case of error detection. Use HAL_DMA_Abort() function to abort the current transfer The most used DMA HAL driver macros are the following: __HAL_DMA_ENABLE: enablse the specified DMA Channels. __HAL_DMA_DISABLE: disables the specified DMA Channels. __HAL_DMA_GET_FLAG: gets the DMA Channels pending flags. __HAL_DMA_CLEAR_FLAG: clears the DMA Channels pending flags. __HAL_DMA_ENABLE_IT: enables the specified DMA Channels interrupts. __HAL_DMA_DISABLE_IT: disables the specified DMA Channels interrupts. __HAL_DMA_GET_IT_SOURCE: checks whether the specified DMA channel interrupt has occurred or not. When a peripheral is used in DMA mode, the DMA initialization should be done in the HAL_PPP_MspInit() callback. In addition, the user application should associate the DMA handle to the PPP handle (refer to section “HAL IO operation functions”). DMA channel callbacks need to be initialized by the user application only in case of memory-to-memory transfer. However when peripheral-to-memory transfers are used, these callbacks are automatically initialized by calling a process API function that uses the DMA. 48/832 DOCID026526 Rev 4 UM1786 2.12 How to use HAL drivers 2.12.1 HAL usage models The following figure shows the typical use of the HAL driver and the interaction between the application user, the HAL driver and the interrupts. Figure 7: HAL driver model The functions implemented in the HAL driver are shown in green, the functions called from interrupt handlers in dotted lines, and the msp functions implemented in the user application in red. Non-dotted lines represent the interactions between the user application functions. Basically, the HAL driver APIs are called from user files and optionally from interrupt handlers file when the APIs based on the DMA or the PPP peripheral dedicated interrupts are used. When DMA or PPP peripheral interrupts are used, the PPP process complete callbacks are called to inform the user about the process completion in real-time event mode (interrupts). Note that the same process completion callbacks are used for DMA in interrupt mode. DOCID026526 Rev 4 49/832 UM1786 2.12.2 HAL initialization 2.12.2.1 HAL global initialization In addition to the peripheral initialization and de-initialization functions, a set of APIs are provided to initialize the HAL core implemented in file stm32f3xx_hal.c. 2.12.2.2 HAL_Init(): this function must be called at application startup to Initialize data/instruction cache and pre-fetch queue Set Systick timer to generate an interrupt each 1ms (based on HSI clock) with the lowest priority Call HAL_MspInit() user callback function to perform system level initializations (Clock, GPIOs, DMA, interrupts). HAL_MspInit() is defined as “weak” empty function in the HAL drivers. HAL_DeInit() Resets all peripherals Calls function HAL_MspDeInit() which a is user callback function to do system level De-Initalizations. HAL_GetTick(): this function gets current SysTick counter value (incremented in SysTick interrupt) used by peripherals drivers to handle timeouts. HAL_Delay(). this function implements a delay (expressed in milliseconds) using the SysTick timer. Care must be taken when using HAL_Delay() since this function provides an accurate delay (expressed in milliseconds) based on a variable incremented in SysTick ISR. This means that if HAL_Delay() is called from a peripheral ISR, then the SysTick interrupt must have highest priority (numerically lower) than the peripheral interrupt, otherwise the caller ISR will be blocked. System clock initialization The clock configuration is done at the beginning of the user code. However the user can change the configuration of the clock in his own code. Please find below the typical Clock configuration sequence: void SystemClock_Config(void) { RCC_ClkInitTypeDef RCC_ClkInitStruct; RCC_OscInitTypeDef RCC_OscInitStruct; /* Enable HSE Oscillator and activate PLL with HSE as source */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; if (HAL_RCC_OscConfig(&RCC_OscInitStruct)!= HAL_OK) { Error_Handler(); } /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2)!= HAL_OK) { Error_Handler(); } } 50/832 DOCID026526 Rev 4 UM1786 2.12.2.3 HAL MSP initialization process The peripheral initialization is done through HAL_PPP_Init() while the hardware resources initialization used by a peripheral (PPP) is performed during this initialization by calling MSP callback function HAL_PPP_MspInit(). The MspInit callback performs the low level initialization related to the different additional hardware resources: RCC, GPIO, NVIC and DMA. All the HAL drivers with handles include two MSP callbacks for initialization and deinitialization: /** * @brief Initializes the PPP MSP. * @param hppp: PPP handle * @retval None */ void __weak HAL_PPP_MspInit(PPP_HandleTypeDef *hppp) { /* NOTE : This function Should not be modified, when the callback is needed, the HAL_PPP_MspInit could be implemented in the user file */ } /** * @brief DeInitializes PPP MSP. * @param hppp: PPP handle * @retval None */ void __weak HAL_PPP_MspDeInit(PPP_HandleTypeDef *hppp) { /* NOTE : This function Should not be modified, when the callback is needed, the HAL_PPP_MspDeInit could be implemented in the user file */ } The MSP callbacks are declared empty as weak functions in each peripheral driver. The user can use them to set the low level initialization code or omit them and use his own initialization routine. The HAL MSP callback is implemented inside the stm32f3xx_hal_msp.c file in the user folders. An stm32f3xx_hal_msp_template.c file is located in the HAL folder and should be copied to the user folder. It can be generated automatically by STM32CubeMX tool and further modified. Note that all the routines are declared as weak functions and could be overwritten or removed to use user low level initialization code. stm32f3xx_hal_msp.c file contains the following functions: Table 14: MSP functions Routine Description void HAL_MspInit() Global MSP initialization routine void HAL_MspDeInit() Global MSP de-initialization routine void HAL_PPP_MspInit() PPP MSP initialization routine void HAL_PPP_MspDeInit() PPP MSP de-initialization routine By default, if no peripheral needs to be de-initialized during the program execution, the whole MSP initialization is done in Hal_MspInit() and MSP De-Initialization in the Hal_MspDeInit(). In this case the HAL_PPP_MspInit() and HAL_PPP_MspDeInit() are not implemented. When one or more peripherals needs to be de-initialized in run time and the low level resources of a given peripheral need to be released and used by another peripheral, HAL_PPP_MspDeInit() and HAL_PPP_MspInit() are implemented for the concerned peripheral and other peripherals initialization and de-Initialization are kept in the global HAL_MspInit() and the HAL_MspDeInit(). If there is nothing to be initialized by the global HAL_MspInit() and HAL_MspDeInit(), the two routines can simply be omitted. DOCID026526 Rev 4 51/832 UM1786 2.12.3 HAL IO operation process The HAL functions with internal data processing like Transmit, Receive, Write and Read are generally provided with three data processing modes as follows: 2.12.3.1 Polling mode Interrupt mode DMA mode Polling mode In polling mode, the HAL functions return the process status when the data processing in blocking mode is complete. The operation is considered complete when the function returns the HAL_OK status, otherwise an error status is returned. The user can get more information through the HAL_PPP_GetState() function. The data processing is handled internally in a loop. A timeout (expressed in ms) is used to prevent process hanging. The example below shows the typical polling mode processing sequence : HAL_StatusTypeDef HAL_PPP_Transmit ( PPP_HandleTypeDef * phandle, uint8_t pData, int16_tSize,uint32_tTimeout) { if((pData == NULL ) || (Size == 0)) { return HAL_ERROR; } (…) while (data processing is running) { if( timeout reached ) { return HAL_TIMEOUT; } } (…) return HAL_OK; } 2.12.3.2 Interrupt mode In Interrupt mode, the HAL function returns the process status after starting the data processing and enabling the appropriate interruption. The end of the operation is indicated by a callback declared as a weak function. It can be customized by the user to be informed in real-time about the process completion. The user can also get the process status through the HAL_PPP_GetState() function. In interrupt mode, four functions are declared in the driver: HAL_PPP_Process_IT(): launch the process HAL_PPP_IRQHandler(): the global PPP peripheral interruption __weak HAL_PPP_ProcessCpltCallback (): the callback relative to the process completion. __weak HAL_PPP_ProcessErrorCallback(): the callback relative to the process Error. To use a process in interrupt mode, HAL_PPP_Process_IT() is called in the user file and HAL_PPP_IRQHandler in stm32f3xx_it.c. The HAL_PPP_ProcessCpltCallback() function is declared as weak function in the driver. This means that the user can declare it again in the application. The function in the driver is not modified. An example of use is illustrated below: main.c file: 52/832 DOCID026526 Rev 4 UM1786 UART_HandleTypeDef UartHandle; int main(void) { /* Set User Parameters */ UartHandle.Init.BaudRate = 9600; UartHandle.Init.WordLength = UART_DATABITS_8; UartHandle.Init.StopBits = UART_STOPBITS_1; UartHandle.Init.Parity = UART_PARITY_NONE; UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE; UartHandle.Init.Mode = UART_MODE_TX_RX; UartHandle.Init.Instance = USART1; HAL_UART_Init(&UartHandle); HAL_UART_SendIT(&UartHandle, TxBuffer, sizeof(TxBuffer)); while (1); } void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) { } void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart) { } stm32f3xx_it.cfile: extern UART_HandleTypeDef UartHandle; void USART1_IRQHandler(void) { HAL_UART_IRQHandler(&UartHandle); } 2.12.3.3 DMA mode In DMA mode, the HAL function returns the process status after starting the data processing through the DMA and after enabling the appropriate DMA interruption. The end of the operation is indicated by a callback declared as a weak function and can be customized by the user to be informed in real-time about the process completion. The user can also get the process status through the HAL_PPP_GetState() function. For the DMA mode, three functions are declared in the driver: HAL_PPP_Process_DMA(): launch the process HAL_PPP_DMA_IRQHandler(): the DMA interruption used by the PPP peripheral __weak HAL_PPP_ProcessCpltCallback(): the callback relative to the process completion. __weak HAL_PPP_ErrorCpltCallback(): the callback relative to the process Error. To use a process in DMA mode, HAL_PPP_Process_DMA() is called in the user file and the HAL_PPP_DMA_IRQHandler() is placed in the stm32f3xx_it.c. When DMA mode is used, the DMA initialization is done in the HAL_PPP_MspInit() callback. The user should also associate the DMA handle to the PPP handle. For this purpose, the handles of all the peripheral drivers that use the DMA must be declared as follows: typedef struct { PPP_TypeDef *Instance; /* Register base address */ PPP_InitTypeDef Init; /* PPP communication parameters */ HAL_StateTypeDef State; /* PPP communication state */ (…) DMA_HandleTypeDef *hdma; /* associated DMA handle */ } PPP_HandleTypeDef; The initialization is done as follows (UART example): int main(void) { /* Set User Parameters */ UartHandle.Init.BaudRate = 9600; DOCID026526 Rev 4 53/832 UM1786 UartHandle.Init.WordLength = UART_DATABITS_8; UartHandle.Init.StopBits = UART_STOPBITS_1; UartHandle.Init.Parity = UART_PARITY_NONE; UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE; UartHandle.Init.Mode = UART_MODE_TX_RX; UartHandle.Init.Instance = UART1; HAL_UART_Init(&UartHandle); (..) } void HAL_USART_MspInit (UART_HandleTypeDef * huart) { static DMA_HandleTypeDef hdma_tx; static DMA_HandleTypeDef hdma_rx; (…) __HAL_LINKDMA(UartHandle, DMA_Handle_tx, hdma_tx); __HAL_LINKDMA(UartHandle, DMA_Handle_rx, hdma_rx); (…) } The HAL_PPP_ProcessCpltCallback() function is declared as weak function in the driver that means, the user can declare it again in the application code. The function in the driver should not be modified. An example of use is illustrated below: main.c file: UART_HandleTypeDef UartHandle; int main(void) { /* Set User Paramaters */ UartHandle.Init.BaudRate = 9600; UartHandle.Init.WordLength = UART_DATABITS_8; UartHandle.Init.StopBits = UART_STOPBITS_1; UartHandle.Init.Parity = UART_PARITY_NONE; UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE; UartHandle.Init.Mode = UART_MODE_TX_RX; UartHandle.Init.Instance = USART1; HAL_UART_Init(&UartHandle); HAL_UART_Send_DMA(&UartHandle, TxBuffer, sizeof(TxBuffer)); while (1); } void HAL_UART_TxCpltCallback(UART_HandleTypeDef *phuart) { } void HAL_UART_TxErrorCallback(UART_HandleTypeDef *phuart) { } stm32f3xx_it.c file: extern UART_HandleTypeDef UartHandle; void DMAx_IRQHandler(void) { HAL_DMA_IRQHandler(&UartHandle.DMA_Handle_tx); } HAL_USART_TxCpltCallback() and HAL_USART_ErrorCallback() should be linked in the HAL_PPP_Process_DMA() function to the DMA transfer complete callback and the DMA transfer Error callback by using the following statement: HAL_PPP_Process_DMA (PPP_HandleTypeDef *hppp, Params….) { (…) hppp->DMA_Handle->XferCpltCallback = HAL_UART_TxCpltCallback ; hppp->DMA_Handle->XferErrorCallback = HAL_UART_ErrorCallback ; (…) } 54/832 DOCID026526 Rev 4 UM1786 2.12.4 Timeout and error management 2.12.4.1 Timeout management The timeout is often used for the APIs that operate in polling mode. It defines the delay during which a blocking process should wait till an error is returned. An example is provided below: HAL_StatusTypeDef HAL_DMA_PollForTransfer(DMA_HandleTypeDef *hdma, uint32_t CompleteLevel, uint32_t Timeout) The timeout possible value are the following: Table 15: Timeout values Timeout value Description 0 No poll : Immediate process check and exit 1 ... (HAL_MAX_DELAY -1) HAL_MAX_DELAY (1) Timeout in ms Infinite poll till process is successful Notes: (1) HAL_MAX_DELAY is defined in the stm32fxxx_hal_def.h as 0xFFFFFFFF However, in some cases, a fixed timeout is used for system peripherals or internal HAL driver processes. In these cases, the timeout has the same meaning and is used in the same way, except when it is defined locally in the drivers and cannot be modified or introduced as an argument in the user application. Example of fixed timeout: #define LOCAL_PROCESS_TIMEOUT 100 HAL_StatusTypeDef HAL_PPP_Process(PPP_HandleTypeDef) { (…) timeout = HAL_GetTick() + LOCAL_PROCESS_TIMEOUT; (…) while(ProcessOngoing) { (…) if(HAL_GetTick() >= timeout) { /* Process unlocked */ __HAL_UNLOCK(hppp); hppp->State= HAL_PPP_STATE_TIMEOUT; return HAL_PPP_STATE_TIMEOUT; } } (…) } The following example shows how to use the timeout inside the polling functions: HAL_PPP_StateTypeDef HAL_PPP_Poll (PPP_HandleTypeDef *hppp, uint32_t Timeout) { (…) timeout = HAL_GetTick() + Timeout; (…) while(ProcessOngoing) { (…) if(Timeout != HAL_MAX_DELAY) { if(HAL_GetTick() >= timeout) { /* Process unlocked */ DOCID026526 Rev 4 55/832 UM1786 __HAL_UNLOCK(hppp); hppp->State= HAL_PPP_STATE_TIMEOUT; return hppp->State; } } (…) } 2.12.4.2 Error management The HAL drivers implement a check for the following items: Valid parameters: for some process the used parameters should be valid and already defined, otherwise the system can crash or go into an undefined state. These critical parameters are checked before they are used (see example below). HAL_StatusTypeDef HAL_PPP_Process(PPP_HandleTypeDef* hppp, uint32_t *pdata, uint32 Size) { if ((pData == NULL ) || (Size == 0)) { return HAL_ERROR; } } Valid handle: the PPP peripheral handle is the most important argument since it keeps the PPP driver vital parameters. It is always checked in the beginning of the HAL_PPP_Init() function. HAL_StatusTypeDef HAL_PPP_Init(PPP_HandleTypeDef* hppp) { if (hppp == NULL) //the handle should be already allocated { return HAL_ERROR; } } Timeout error: the following statement is used when a timeout error occurs: while (Process ongoing) { timeout = HAL_GetTick() + Timeout; while (data processing is running) { if(timeout) { return HAL_TIMEOUT; } } When an error occurs during a peripheral process, HAL_PPP_Process () returns with a HAL_ERROR status. The HAL PPP driver implements the HAL_PPP_GetError () to allow retrieving the origin of the error. HAL_PPP_ErrorTypeDef HAL_PPP_GetError (PPP_HandleTypeDef *hppp); In all peripheral handles, a HAL_PPP_ErrorTypeDef is defined and used to store the last error code. typedef struct { PPP_TypeDef * Instance; /* PPP registers base address */ PPP_InitTypeDef Init; /* PPP initialization parameters */ HAL_LockTypeDef Lock; /* PPP locking object */ __IO HAL_PPP_StateTypeDef State; /* PPP state */ __IO HAL_PPP_ErrorTypeDef ErrorCode; /* PPP Error code */ (…) /* PPP specific parameters */ } PPP_HandleTypeDef; The error state and the peripheral global state are always updated before returning an error: PPP->State = HAL_PPP_READY; /* Set the peripheral ready */ PP->ErrorCode = HAL_ERRORCODE ; /* Set the error code */ _HAL_UNLOCK(PPP) ; /* Unlock the PPP resources */ return HAL_ERROR; /*return with HAL error */ HAL_PPP_GetError () must be used in interrupt mode in the error callback: void HAL_PPP_ProcessCpltCallback(PPP_HandleTypeDef *hspi) { ErrorCode = HAL_PPP_GetError (hppp); /* retreive error code */ } 56/832 DOCID026526 Rev 4 UM1786 2.12.4.3 Run-time checking The HAL implements run-time failure detection by checking the input values of all HAL drivers functions. The run-time checking is achieved by using an assert_param macro. This macro is used in all the HAL drivers' functions which have an input parameter. It allows verifying that the input value lies within the parameter allowed values. To enable the run-time checking, use the assert_param macro, and leave the define USE_FULL_ASSERT uncommented in stm32f3xx_hal_conf.h file. void HAL_UART_Init(UART_HandleTypeDef *huart) { (..) /* Check the parameters */ assert_param(IS_UART_INSTANCE(huart->Instance)); assert_param(IS_UART_BAUDRATE(huart->Init.BaudRate)); assert_param(IS_UART_WORD_LENGTH(huart->Init.WordLength)); assert_param(IS_UART_STOPBITS(huart->Init.StopBits)); assert_param(IS_UART_PARITY(huart->Init.Parity)); assert_param(IS_UART_MODE(huart->Init.Mode)); assert_param(IS_UART_HARDWARE_FLOW_CONTROL(huart->Init.HwFlowCtl)); (..) /** @defgroup UART_Word_Length * @{ */ #define UART_WORDLENGTH_8B ((uint32_t)0x00000000) #define UART_WORDLENGTH_9B ((uint32_t)USART_CR1_M) #define IS_UART_WORD_LENGTH(LENGTH) (((LENGTH) == UART_WORDLENGTH_8B) || \ ((LENGTH) == UART_WORDLENGTH_9B)) If the expression passed to the assert_param macro is false, theassert_failed function is called and returns the name of the source file and the source line number of the call that failed. If the expression is true, no value is returned. The assert_param macro is implemented in stm32f3xx_hal_conf.h: /* Exported macro ------------------------------------------------------------*/ #ifdef USE_FULL_ASSERT /** * @brief The assert_param macro is used for function's parameters check. * @param expr: If expr is false, it calls assert_failed function * which reports the name of the source file and the source * line number of the call that failed. * If expr is true, it returns no value. * @retval None */ #define assert_param(expr) ((expr)?(void)0:assert_failed((uint8_t *)__FILE__, __LINE__)) /* Exported functions --------------------------------------*/ void assert_failed(uint8_t* file, uint32_t line); #else #define assert_param(expr)((void)0) #endif /* USE_FULL_ASSERT */ The assert_failed function is implemented in the main.c file or in any other user C file: #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t* file, uint32_t line) { /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* Infinite loop */ while (1) { DOCID026526 Rev 4 57/832 UM1786 } } Because of the overhead run-time checking introduces, it is recommended to use it during application code development and debugging, and to remove it from the final application to improve code size and speed. 58/832 DOCID026526 Rev 4 UM1786 3 HAL System Driver 3.1 HAL Firmware driver API description 3.1.1 How to use this driver The common HAL driver contains a set of generic and common APIs that can be used by the PPP peripheral drivers and the user to start using the HAL. The HAL contains two APIs categories: 3.1.2 HAL Initialization and de-initialization functions HAL Control functions Initialization and de-initialization functions This section provides functions allowing to: Initializes the Flash interface, the NVIC allocation and initial clock configuration. It initializes the source of time base also when timeout is needed and the backup domain when enabled. de-Initializes common part of the HAL. Configure The time base source to have 1ms time base with a dedicated Tick interrupt priority. Systick timer is used by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. Time base configuration function (HAL_InitTick ()) is called automatically at the beginning of the program after reset by HAL_Init() or at any time when clock is configured, by HAL_RCC_ClockConfig(). Source of time base is configured to generate interrupts at regular time intervals. Care must be taken if HAL_Delay() is called from a peripheral ISR process, the Tick interrupt line must have higher priority (numerically lower) than the peripheral interrupt. Otherwise the caller ISR process will be blocked. functions affecting time base configurations are declared as __Weak to make override possible in case of other implementations in user file. This section contains the following APIs: 3.1.3 HAL_Init() HAL_DeInit() HAL_MspInit() HAL_MspDeInit() HAL_InitTick() HAL Control functions This section provides functions allowing to: Provide a tick value in millisecond Provide a blocking delay in millisecond Suspend the time base source interrupt Resume the time base source interrupt Get the HAL API driver version Get the device identifier DOCID026526 Rev 4 59/832 UM1786 Get the device revision identifier Enable/Disable Debug module during Sleep mode Enable/Disable Debug module during STOP mode Enable/Disable Debug module during STANDBY mode This section contains the following APIs: 3.1.4 HAL_IncTick() HAL_GetTick() HAL_Delay() HAL_SuspendTick() HAL_ResumeTick() HAL_GetHalVersion() HAL_GetREVID() HAL_GetDEVID() HAL_DBGMCU_EnableDBGSleepMode() HAL_DBGMCU_DisableDBGSleepMode() HAL_DBGMCU_EnableDBGStopMode() HAL_DBGMCU_DisableDBGStopMode() HAL_DBGMCU_EnableDBGStandbyMode() HAL_DBGMCU_DisableDBGStandbyMode() Detailed description of functions HAL_Init Function Name HAL_StatusTypeDef HAL_Init (void ) Function Description This function configures the Flash prefetch, Configures time base source, NVIC and Low level hardware. Return values HAL: status Notes This function is called at the beginning of program after reset and before the clock configuration The Systick configuration is based on HSI clock, as HSI is the clock used after a system Reset and the NVIC configuration is set to Priority group 4 The time base configuration is based on MSI clock when exting from Reset. Once done, time base tick start incrementing. In the default implementation,Systick is used as source of time base. The tick variable is incremented each 1ms in its ISR. HAL_DeInit 60/832 Function Name HAL_StatusTypeDef HAL_DeInit (void ) Function Description This function de-Initializes common part of the HAL and stops the source of time base. Return values HAL: status Notes This function is optional. DOCID026526 Rev 4 UM1786 HAL_MspInit Function Name void HAL_MspInit (void ) Function Description Initializes the MSP. Return values None: HAL_MspDeInit Function Name void HAL_MspDeInit (void ) Function Description DeInitializes the MSP. Return values None: HAL_InitTick Function Name HAL_StatusTypeDef HAL_InitTick (uint32_t TickPriority) Function Description This function configures the source of the time base. Parameters TickPriority: Tick interrupt priority. Return values HAL: status Notes This function is called automatically at the beginning of program after reset by HAL_Init() or at any time when clock is reconfigured by HAL_RCC_ClockConfig(). In the default implementation , SysTick timer is the source of time base. It is used to generate interrupts at regular time intervals. Care must be taken if HAL_Delay() is called from a peripheral ISR process, The the SysTick interrupt must have higher priority (numerically lower) than the peripheral interrupt. Otherwise the caller ISR process will be blocked. The function is declared as __Weak to be overwritten in case of other implementation in user file. HAL_IncTick Function Name void HAL_IncTick (void ) Function Description This function is called to increment a global variable "uwTick" used as application time base. Return values None: Notes In the default implementation, this variable is incremented each 1ms in Systick ISR. This function is declared as __weak to be overwritten in case of other implementations in user file. HAL_Delay Function Name void HAL_Delay (__IO uint32_t Delay) Function Description This function provides accurate delay (in milliseconds) based on variable incremented. Parameters Delay: specifies the delay time length, in milliseconds. DOCID026526 Rev 4 61/832 UM1786 Return values None: Notes In the default implementation , SysTick timer is the source of time base. It is used to generate interrupts at regular time intervals where uwTick is incremented. The function is declared as __Weak to be overwritten in case of other implementations in user file. HAL_SuspendTick Function Name void HAL_SuspendTick (void ) Function Description Suspend Tick increment. Return values None: Notes In the default implementation , SysTick timer is the source of time base. It is used to generate interrupts at regular time intervals. Once HAL_SuspendTick() is called, the the SysTick interrupt will be disabled and so Tick increment is suspended. This function is declared as __weak to be overwritten in case of other implementations in user file. HAL_ResumeTick Function Name void HAL_ResumeTick (void ) Function Description Resume Tick increment. Return values None: Notes In the default implementation , SysTick timer is the source of time base. It is used to generate interrupts at regular time intervals. Once HAL_ResumeTick() is called, the the SysTick interrupt will be enabled and so Tick increment is resumed. The function is declared as __Weak to be overwritten in case of other implementations in user file. HAL_GetTick Function Name uint32_t HAL_GetTick (void ) Function Description Povides a tick value in millisecond. Return values tick: value Notes The function is declared as __Weak to be overwritten in case of other implementations in user file. HAL_GetHalVersion 62/832 Function Name uint32_t HAL_GetHalVersion (void ) Function Description This function returns the HAL revision. Return values version: : 0xXYZR (8bits for each decimal, R for RC) DOCID026526 Rev 4 UM1786 HAL_GetREVID Function Name uint32_t HAL_GetREVID (void ) Function Description Returns the device revision identifier. Return values Device: revision identifier HAL_GetDEVID Function Name uint32_t HAL_GetDEVID (void ) Function Description Returns the device identifier. Return values Device: identifier HAL_DBGMCU_EnableDBGSleepMode Function Name void HAL_DBGMCU_EnableDBGSleepMode (void ) Function Description Enable the Debug Module during SLEEP mode. Return values None: HAL_DBGMCU_DisableDBGSleepMode Function Name void HAL_DBGMCU_DisableDBGSleepMode (void ) Function Description Disable the Debug Module during SLEEP mode. Return values None: HAL_DBGMCU_EnableDBGStopMode Function Name void HAL_DBGMCU_EnableDBGStopMode (void ) Function Description Enable the Debug Module during STOP mode. Return values None: HAL_DBGMCU_DisableDBGStopMode Function Name void HAL_DBGMCU_DisableDBGStopMode (void ) Function Description Disable the Debug Module during STOP mode. Return values None: HAL_DBGMCU_EnableDBGStandbyMode Function Name void HAL_DBGMCU_EnableDBGStandbyMode (void ) Function Description Enable the Debug Module during STANDBY mode. Return values None: HAL_DBGMCU_DisableDBGStandbyMode Function Name void HAL_DBGMCU_DisableDBGStandbyMode (void ) Function Description Disable the Debug Module during STANDBY mode. DOCID026526 Rev 4 63/832 UM1786 Return values None: 3.2 HAL Firmware driver defines 3.2.1 HAL CAN Error Code HAL_CAN_ERROR_NONE No error HAL_CAN_ERROR_EWG EWG error HAL_CAN_ERROR_EPV EPV error HAL_CAN_ERROR_BOF BOF error HAL_CAN_ERROR_STF Stuff error HAL_CAN_ERROR_FOR Form error HAL_CAN_ERROR_ACK Acknowledgment error HAL_CAN_ERROR_BR Bit recessive HAL_CAN_ERROR_BD LEC dominant HAL_CAN_ERROR_CRC LEC transfer error CRC aliases for Exported Functions HAL_CRC_Input_Data_Reverse HAL_CRC_Output_Data_Reverse HAL DMA Remapping 64/832 HAL_REMAPDMA_ADC24_DMA2_CH34 ADC24 DMA remap (STM32F303xB/C/E, STM32F358xx and STM32F398xx devices) 1: Remap (ADC24 DMA requests mapped on DMA2 channels 3 and 4) HAL_REMAPDMA_TIM16_DMA1_CH6 TIM16 DMA request remap 1: Remap (TIM16_CH1 and TIM16_UP DMA requests mapped on DMA1 channel 6) HAL_REMAPDMA_TIM17_DMA1_CH7 TIM17 DMA request remap 1: Remap (TIM17_CH1 and TIM17_UP DMA requests mapped on DMA1 channel 7) HAL_REMAPDMA_TIM6_DAC1_CH1_DMA1_CH3 TIM6 and DAC channel1 DMA remap (STM32F303xB/C/E, STM32F358xx and STM32F398xx devices) 1: Remap (TIM6_UP and DAC_CH1 DMA requests mapped on DMA1 channel 3) HAL_REMAPDMA_TIM7_DAC1_CH2_DMA1_CH4 TIM7 and DAC channel2 DMA remap (STM32F303xB/C/E, STM32F358xx and STM32F398xx devices) 1: Remap (TIM7_UP and DOCID026526 Rev 4 UM1786 DAC_CH2 DMA requests mapped on DMA1 channel 4) HAL_REMAPDMA_DAC2_CH1_DMA1_CH5 DAC2 channel1 DMA remap (STM32F303x4/6/8 devices only) 1: Remap (DAC2_CH1 DMA requests mapped on DMA1 channel 5) HAL_REMAPDMA_TIM18_DAC2_CH1_DMA1_CH5 DAC2 channel1 DMA remap (STM32F303x4/6/8 devices only) 1: Remap (DAC2_CH1 DMA requests mapped on DMA1 channel 5) IS_DMA_REMAP HAL CCM RAM page write protection HAL_SYSCFG_WP_PAGE0 ICODE SRAM Write protection page 0 HAL_SYSCFG_WP_PAGE1 ICODE SRAM Write protection page 1 HAL_SYSCFG_WP_PAGE2 ICODE SRAM Write protection page 2 HAL_SYSCFG_WP_PAGE3 ICODE SRAM Write protection page 3 HAL_SYSCFG_WP_PAGE4 ICODE SRAM Write protection page 4 HAL_SYSCFG_WP_PAGE5 ICODE SRAM Write protection page 5 HAL_SYSCFG_WP_PAGE6 ICODE SRAM Write protection page 6 HAL_SYSCFG_WP_PAGE7 ICODE SRAM Write protection page 7 IS_HAL_SYSCFG_WP_PAGE HAL state definition HAL_SMBUS_STATE_RESET SMBUS not yet initialized or disabled HAL_SMBUS_STATE_READY SMBUS initialized and ready for use HAL_SMBUS_STATE_BUSY SMBUS internal process is ongoing HAL_SMBUS_STATE_MASTER_BUSY_TX Master Data Transmission process is ongoing HAL_SMBUS_STATE_MASTER_BUSY_RX Master Data Reception process is ongoing HAL_SMBUS_STATE_SLAVE_BUSY_TX Slave Data Transmission process is ongoing HAL_SMBUS_STATE_SLAVE_BUSY_RX Slave Data Reception process is ongoing HAL_SMBUS_STATE_TIMEOUT Timeout state HAL_SMBUS_STATE_ERROR Reception process is ongoing HAL_SMBUS_STATE_LISTEN Address Listen Mode is ongoing HAL SYSCFG Interrupts HAL_SYSCFG_IT_FPU_IOC Floating Point Unit Invalid operation Interrupt HAL_SYSCFG_IT_FPU_DZC Floating Point Unit Divide-by-zero Interrupt HAL_SYSCFG_IT_FPU_UFC Floating Point Unit Underflow Interrupt HAL_SYSCFG_IT_FPU_OFC Floating Point Unit Overflow Interrupt DOCID026526 Rev 4 65/832 UM1786 HAL_SYSCFG_IT_FPU_IDC Floating Point Unit Input denormal Interrupt HAL_SYSCFG_IT_FPU_IXC Floating Point Unit Inexact Interrupt IS_HAL_SYSCFG_INTERRUPT HAL Trigger Remapping HAL_REMAPTRIGGER_DAC1_TRIG DAC trigger remap (when TSEL = 001 on STM32F303xB/C and STM32F358xx devices) 0: No remap (DAC trigger is TIM8_TRGO) 1: Remap (DAC trigger is TIM3_TRGO) HAL_REMAPTRIGGER_TIM1_ITR3 TIM1 ITR3 trigger remap 0: No remap 1: Remap (TIM1_TRG3 = TIM17_OC) IS_HAL_REMAPTRIGGER SYSCFG registers bit address in the alias region SYSCFG_OFFSET CFGR2_OFFSET BYPADDRPAR_BitNumber CFGR2_BYPADDRPAR_BB Fast-mode Plus on GPIO 66/832 SYSCFG_FASTMODEPLUS_PB6 Enable Fast-mode Plus on PB6 SYSCFG_FASTMODEPLUS_PB7 Enable Fast-mode Plus on PB7 SYSCFG_FASTMODEPLUS_PB8 Enable Fast-mode Plus on PB8 SYSCFG_FASTMODEPLUS_PB9 Enable Fast-mode Plus on PB9 DOCID026526 Rev 4 UM1786 4 HAL ADC Generic Driver 4.1 ADC Firmware driver registers structures 4.1.1 __ADC_HandleTypeDef Data Fields ADC_TypeDef * Instance ADC_InitTypeDef Init DMA_HandleTypeDef * DMA_Handle HAL_LockTypeDef Lock __IO uint32_t State __IO uint32_t ErrorCode ADC_InjectionConfigTypeDef InjectionConfig Field Documentation ADC_TypeDef* __ADC_HandleTypeDef::Instance Register base address ADC_InitTypeDef __ADC_HandleTypeDef::Init ADC required parameters DMA_HandleTypeDef* __ADC_HandleTypeDef::DMA_Handle Pointer DMA Handler HAL_LockTypeDef __ADC_HandleTypeDef::Lock ADC locking object __IO uint32_t __ADC_HandleTypeDef::State ADC communication state (bitmap of ADC states) __IO uint32_t __ADC_HandleTypeDef::ErrorCode ADC Error code ADC_InjectionConfigTypeDef __ADC_HandleTypeDef::InjectionConfig ADC injected channel configuration build-up structure 4.2 ADC Firmware driver API description 4.2.1 ADC peripheral features 12-bit, 10-bit, 8-bit or 6-bit configurable resolution (available only on STM32F30xxC devices). Interrupt generation at the end of regular conversion, end of injected conversion, and in case of analog watchdog or overrun events. Single and continuous conversion modes. Scan mode for conversion of several channels sequentially. Data alignment with in-built data coherency. Programmable sampling time (channel wise) ADC conversion of regular group and injected group. DOCID026526 Rev 4 67/832 UM1786 4.2.2 External trigger (timer or EXTI) with configurable polarity for both regular and injected groups. DMA request generation for transfer of conversions data of regular group. Multimode dual mode (available on devices with 2 ADCs or more). Configurable DMA data storage in Multimode Dual mode (available on devices with 2 DCs or more). Configurable delay between conversions in Dual interleaved mode (available on devices with 2 DCs or more). ADC calibration ADC channels selectable single/differential input (available only on STM32F30xxC devices) ADC Injected sequencer&channels configuration context queue (available only on STM32F30xxC devices) ADC offset on injected and regular groups (offset on regular group available only on STM32F30xxC devices) ADC supply requirements: 2.4 V to 3.6 V at full speed and down to 1.8 V at slower speed. ADC input range: from Vref- (connected to Vssa) to Vref+ (connected to Vdda or to an external voltage reference). How to use this driver Configuration of top level parameters related to ADC 1. 68/832 Enable the ADC interface As prerequisite, ADC clock must be configured at RCC top level. For STM32F30x/STM32F33x devices: Two possible clock sources: synchronous clock derived from AHB clock or asynchronous clock derived from ADC dedicated PLL 72MHz. - Synchronous clock is mandatory since used as ADC core clock. Synchronous clock can be used optionally as ADC conversion clock, depending on ADC init structure clock setting. Synchronous clock is configured using macro __ADCx_CLK_ENABLE(). - Asynchronous can be used optionally as ADC conversion clock, depending on ADC init structure clock setting. Asynchronous clock is configured using function HAL_RCCEx_PeriphCLKConfig(). For example, in case of device with a single ADC: Into HAL_ADC_MspInit() (recommended code location) or with other device clock parameters configuration: __HAL_RCC_ADC1_CLK_ENABLE() (mandatory) PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC (optional, if ADC conversion from asynchronous clock) PeriphClkInit.Adc1ClockSelection = RCC_ADC1PLLCLK_DIV1 (optional, if ADC conversion from asynchronous clock) HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInitStructure) (optional, if ADC conversion from asynchronous clock) For example, in case of device with 4 ADCs: if((hadc->Instance == ADC1) || (hadc->Instance == ADC2)) { __HAL_RCC_ADC12_CLK_ENABLE() (mandatory) PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC (optional, if ADC conversion from asynchronous clock) DOCID026526 Rev 4 UM1786 2. 3. 4. PeriphClkInit.Adc12ClockSelection = RCC_ADC12PLLCLK_DIV1 (optional, if ADC conversion from asynchronous clock) HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInitStructure) (optional, if ADC conversion from asynchronous clock) } else { __HAL_RCC_ADC34_CLK_ENABLE() (mandatory) PeriphClkInit.Adc34ClockSelection = RCC_ADC34PLLCLK_DIV1; (optional, if ADC conversion from asynchronous clock) HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInitStructure); (optional, if ADC conversion from asynchronous clock) } For STM32F37x devices: One clock setting is mandatory: ADC clock (core and conversion clock) from APB2 clock. Example: Into HAL_ADC_MspInit() (recommended code location) or with other device clock parameters configuration: PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC PeriphClkInit.AdcClockSelection = RCC_ADCPLLCLK_DIV2 HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) ADC pins configuration Enable the clock for the ADC GPIOs using macro __HAL_RCC_GPIOx_CLK_ENABLE() Configure these ADC pins in analog mode using function HAL_GPIO_Init() Optionally, in case of usage of ADC with interruptions: Configure the NVIC for ADC using function HAL_NVIC_EnableIRQ(ADCx_IRQn) Insert the ADC interruption handler function HAL_ADC_IRQHandler() into the function of corresponding ADC interruption vector ADCx_IRQHandler(). Optionally, in case of usage of DMA: Configure the DMA (DMA channel, mode normal or circular, ...) using function HAL_DMA_Init(). Configure the NVIC for DMA using function HAL_NVIC_EnableIRQ(DMAx_Channelx_IRQn) Insert the ADC interruption handler function HAL_ADC_IRQHandler() into the function of corresponding DMA interruption vector DMAx_Channelx_IRQHandler(). Configuration of ADC, groups regular/injected, channels parameters 1. 2. 3. 4. 5. Configure the ADC parameters (resolution, data alignment, ...) and regular group parameters (conversion trigger, sequencer, ...) using function HAL_ADC_Init(). Configure the channels for regular group parameters (channel number, channel rank into sequencer, ..., into regular group) using function HAL_ADC_ConfigChannel(). Optionally, configure the injected group parameters (conversion trigger, sequencer, ..., of injected group) and the channels for injected group parameters (channel number, channel rank into sequencer, ..., into injected group) using function HAL_ADCEx_InjectedConfigChannel(). Optionally, configure the analog watchdog parameters (channels monitored, thresholds, ...) using function HAL_ADC_AnalogWDGConfig(). Optionally, for devices with several ADC instances: configure the multimode parameters using function HAL_ADCEx_MultiModeConfigChannel(). DOCID026526 Rev 4 69/832 UM1786 Execution of ADC conversions 1. 2. 70/832 Optionally, perform an automatic ADC calibration to improve the conversion accuracy using function HAL_ADCEx_Calibration_Start(). ADC driver can be used among three modes: polling, interruption, transfer by DMA. ADC conversion by polling: Activate the ADC peripheral and start conversions using function HAL_ADC_Start() Wait for ADC conversion completion using function HAL_ADC_PollForConversion() (or for injected group: HAL_ADCEx_InjectedPollForConversion() ) Retrieve conversion results using function HAL_ADC_GetValue() (or for injected group: HAL_ADCEx_InjectedGetValue() ) Stop conversion and disable the ADC peripheral using function HAL_ADC_Stop() ADC conversion by interruption: Activate the ADC peripheral and start conversions using function HAL_ADC_Start_IT() Wait for ADC conversion completion by call of function HAL_ADC_ConvCpltCallback() (this function must be implemented in user program) (or for injected group: HAL_ADCEx_InjectedConvCpltCallback() ) Retrieve conversion results using function HAL_ADC_GetValue() (or for injected group: HAL_ADCEx_InjectedGetValue() ) Stop conversion and disable the ADC peripheral using function HAL_ADC_Stop_IT() ADC conversion with transfer by DMA: Activate the ADC peripheral and start conversions using function HAL_ADC_Start_DMA() Wait for ADC conversion completion by call of function HAL_ADC_ConvCpltCallback() or HAL_ADC_ConvHalfCpltCallback() (these functions must be implemented in user program) Conversion results are automatically transferred by DMA into destination variable address. Stop conversion and disable the ADC peripheral using function HAL_ADC_Stop_DMA() For devices with several ADCs: ADC multimode conversion with transfer by DMA: Activate the ADC peripheral (slave) using function HAL_ADC_Start() (conversion start pending ADC master) Activate the ADC peripheral (master) and start conversions using function HAL_ADCEx_MultiModeStart_DMA() Wait for ADC conversion completion by call of function HAL_ADC_ConvCpltCallback() or HAL_ADC_ConvHalfCpltCallback() (these functions must be implemented in user program) Conversion results are automatically transferred by DMA into destination variable address. Stop conversion and disable the ADC peripheral (master) using function HAL_ADCEx_MultiModeStop_DMA() Stop conversion and disable the ADC peripheral (slave) using function HAL_ADC_Stop_IT() DOCID026526 Rev 4 UM1786 Callback functions must be implemented in user program: HAL_ADC_ErrorCallback() HAL_ADC_LevelOutOfWindowCallback() (callback of analog watchdog) HAL_ADC_ConvCpltCallback() HAL_ADC_ConvHalfCpltCallback HAL_ADCEx_InjectedConvCpltCallback() HAL_ADCEx_InjectedQueueOverflowCallback() (for STM32F30x/STM32F33x devices) Deinitialization of ADC 1. Disable the ADC interface ADC clock can be hard reset and disabled at RCC top level. Hard reset of ADC peripherals using macro __ADCx_FORCE_RESET(), __ADCx_RELEASE_RESET(). ADC clock disable using the equivalent macro/functions as configuration step. For STM32F30x/STM32F33x devices: Caution: For devices with several ADCs: These settings impact both ADC of common group: ADC1&ADC2, ADC3&ADC4 if available (ADC2, ADC3, ADC4 availability depends on STM32 product) For example, in case of device with a single ADC: Into HAL_ADC_MspDeInit() (recommended code location) or with other device clock parameters configuration: __HAL_RCC_ADC1_FORCE_RESET() (optional) __HAL_RCC_ADC1_RELEASE_RESET() (optional) __HAL_RCC_ADC1_CLK_DISABLE() (mandatory) PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC (optional, if configured before) PeriphClkInit.Adc1ClockSelection = RCC_ADC1PLLCLK_OFF (optional, if configured before) HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInitStructure) (optional, if configured before) For example, in case of device with 4 ADCs: if((hadc->Instance == ADC1) || (hadc->Instance == ADC2)) { __HAL_RCC_ADC12_FORCE_RESET() (optional) __HAL_RCC_ADC12_RELEASE_RESET() (optional) __HAL_RCC_ADC12_CLK_DISABLE() (mandatory) PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC (optional, if configured before) PeriphClkInit.Adc12ClockSelection = RCC_ADC12PLLCLK_OFF (optional, if configured before) HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInitStructure) (optional, if configured before) } else { __HAL_RCC_ADC32_FORCE_RESET() (optional) __HAL_RCC_ADC32_RELEASE_RESET() (optional) __HAL_RCC_ADC34_CLK_DISABLE() (mandatory) PeriphClkInit.Adc34ClockSelection = RCC_ADC34PLLCLK_OFF (optional, if configured before) DOCID026526 Rev 4 71/832 UM1786 2. 3. 4. 4.2.3 HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInitStructure) (optional, if configured before) } For STM32F37x devices: Example: Into HAL_ADC_MspDeInit() (recommended code location) or with other device clock parameters configuration: PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC PeriphClkInit.AdcClockSelection = RCC_ADCPLLCLK_OFF HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) ADC pins configuration Disable the clock for the ADC GPIOs using macro __HAL_RCC_GPIOx_CLK_DISABLE() Optionally, in case of usage of ADC with interruptions: Disable the NVIC for ADC using function HAL_NVIC_EnableIRQ(ADCx_IRQn) Optionally, in case of usage of DMA: Deinitialize the DMA using function HAL_DMA_Init(). Disable the NVIC for DMA using function HAL_NVIC_EnableIRQ(DMAx_Channelx_IRQn) Initialization and de-initialization functions This section provides functions allowing to: Initialize and configure the ADC. De-initialize the ADC. This section contains the following APIs: 4.2.4 HAL_ADC_Init() HAL_ADC_DeInit() HAL_ADC_MspInit() HAL_ADC_MspDeInit() IO operation functions This section provides functions allowing to: Start conversion of regular group. Stop conversion of regular group. Poll for conversion complete on regular group. Poll for conversion event. Get result of regular channel conversion. Start conversion of regular group and enable interruptions. Stop conversion of regular group and disable interruptions. Handle ADC interrupt request Start conversion of regular group and enable DMA transfer. Stop conversion of regular group and disable ADC DMA transfer. This section contains the following APIs: 72/832 HAL_ADC_Start() HAL_ADC_Stop() HAL_ADC_PollForConversion() HAL_ADC_PollForEvent() HAL_ADC_Start_IT() HAL_ADC_Stop_IT() DOCID026526 Rev 4 UM1786 4.2.5 HAL_ADC_Start_DMA() HAL_ADC_Stop_DMA() HAL_ADC_GetValue() HAL_ADC_IRQHandler() HAL_ADC_ConvCpltCallback() HAL_ADC_ConvHalfCpltCallback() HAL_ADC_LevelOutOfWindowCallback() HAL_ADC_ErrorCallback() Peripheral Control functions This section provides functions allowing to: Configure channels on regular group Configure the analog watchdog This section contains the following APIs: 4.2.6 HAL_ADC_ConfigChannel() HAL_ADC_AnalogWDGConfig() Peripheral state and errors functions This subsection provides functions to get in run-time the status of the peripheral. Check the ADC state Check the ADC error code This section contains the following APIs: 4.2.7 HAL_ADC_GetState() HAL_ADC_GetError() Detailed description of functions HAL_ADC_Init Function Name HAL_StatusTypeDef HAL_ADC_Init (ADC_HandleTypeDef * hadc) Function Description Initializes the ADC peripheral and regular group according to parameters specified in structure "ADC_InitTypeDef". Parameters hadc: ADC handle Return values HAL: status Notes As prerequisite, ADC clock must be configured at RCC top level depending on both possible clock sources: PLL clock or AHB clock. See commented example code below that can be copied and uncommented into HAL_ADC_MspInit(). Possibility to update parameters on the fly: This function initializes the ADC MSP (HAL_ADC_MspInit()) only when coming from ADC state reset. Following calls to this function can be used to reconfigure some parameters of ADC_InitTypeDef structure on the fly, without modifying MSP configuration. If ADC MSP has to be modified again, HAL_ADC_DeInit() must be called before HAL_ADC_Init(). The setting of these parameters is conditioned to ADC state. For parameters constraints, see comments of structure DOCID026526 Rev 4 73/832 UM1786 "ADC_InitTypeDef". This function configures the ADC within 2 scopes: scope of entire ADC and scope of regular group. For parameters details, see comments of structure "ADC_InitTypeDef". For devices with several ADCs: parameters related to common ADC registers (ADC clock mode) are set only if all ADCs sharing the same common group are disabled. If this is not the case, these common parameters setting are bypassed without error reporting: it can be the intended behaviour in case of update of a parameter of ADC_InitTypeDef on the fly, without disabling the other ADCs sharing the same common group. HAL_ADC_DeInit Function Name HAL_StatusTypeDef HAL_ADC_DeInit (ADC_HandleTypeDef * hadc) Function Description Deinitialize the ADC peripheral registers to their default reset values, with deinitialization of the ADC MSP. Parameters hadc: ADC handle Return values HAL: status Notes For devices with several ADCs: reset of ADC common registers is done only if all ADCs sharing the same common group are disabled. If this is not the case, reset of these common parameters reset is bypassed without error reporting: it can be the intended behaviour in case of reset of a single ADC while the other ADCs sharing the same common group is still running. For devices with several ADCs: Global reset of all ADCs sharing a common group is possible. As this function is intended to reset a single ADC, to not impact other ADCs, instructions for global reset of multiple ADCs have been let commented below. If needed, the example code can be copied and uncommented into function HAL_ADC_MspDeInit(). HAL_ADC_MspInit Function Name void HAL_ADC_MspInit (ADC_HandleTypeDef * hadc) Function Description Initializes the ADC MSP. Parameters hadc: ADC handle Return values None: HAL_ADC_MspDeInit 74/832 Function Name void HAL_ADC_MspDeInit (ADC_HandleTypeDef * hadc) Function Description DeInitializes the ADC MSP. Parameters hadc: ADC handle Return values None: DOCID026526 Rev 4 UM1786 HAL_ADC_Start Function Name HAL_StatusTypeDef HAL_ADC_Start (ADC_HandleTypeDef * hadc) Function Description Enables ADC, starts conversion of regular group. Parameters hadc: ADC handle Return values HAL: status Notes : Case of multimode enabled (for devices with several ADCs): This function must be called for ADC slave first, then ADC master. For ADC slave, ADC is enabled only (conversion is not started). For ADC master, ADC is enabled and multimode conversion is started. HAL_ADC_Stop Function Name HAL_StatusTypeDef HAL_ADC_Stop (ADC_HandleTypeDef * hadc) Function Description Stop ADC conversion of regular group (and injected group in case of auto_injection mode), disable ADC peripheral. Parameters hadc: ADC handle Return values HAL: status. Notes : ADC peripheral disable is forcing stop of potential conversion on injected group. If injected group is under use, it should be preliminarily stopped using HAL_ADCEx_InjectedStop function. : Case of multimode enabled (for devices with several ADCs): This function must be called for ADC master first, then ADC slave. For ADC master, converson is stopped and ADC is disabled. For ADC slave, ADC is disabled only (conversion stop of ADC master has already stopped conversion of ADC slave). HAL_ADC_PollForConversion Function Name HAL_StatusTypeDef HAL_ADC_PollForConversion (ADC_HandleTypeDef * hadc, uint32_t Timeout) Function Description Wait for regular group conversion to be completed. Parameters hadc: ADC handle Timeout: Timeout value in millisecond. Return values HAL: status HAL_ADC_PollForEvent Function Name HAL_StatusTypeDef HAL_ADC_PollForEvent (ADC_HandleTypeDef * hadc, uint32_t EventType, uint32_t Timeout) Function Description Poll for conversion event. DOCID026526 Rev 4 75/832 UM1786 Parameters Return values hadc: ADC handle EventType: the ADC event type. This parameter can be one of the following values: ADC_AWD_EVENT: ADC Analog watchdog 1 event (main analog watchdog, present on all STM32 devices) ADC_AWD2_EVENT: ADC Analog watchdog 2 event (additional analog watchdog, present only on STM32F3 devices) ADC_AWD3_EVENT: ADC Analog watchdog 3 event (additional analog watchdog, present only on STM32F3 devices) ADC_OVR_EVENT: ADC Overrun event ADC_JQOVF_EVENT: ADC Injected context queue overflow event Timeout: Timeout value in millisecond. HAL: status HAL_ADC_Start_IT Function Name HAL_StatusTypeDef HAL_ADC_Start_IT (ADC_HandleTypeDef * hadc) Function Description Enables ADC, starts conversion of regular group with interruption. HAL_ADC_Stop_IT Function Name HAL_StatusTypeDef HAL_ADC_Stop_IT (ADC_HandleTypeDef * hadc) Function Description Stop ADC conversion of regular group (and injected group in case of auto_injection mode), disable interruption of end-of-conversion, disable ADC peripheral. Parameters hadc: ADC handle Return values HAL: status. Notes : ADC peripheral disable is forcing stop of potential conversion on injected group. If injected group is under use, it should be preliminarily stopped using HAL_ADCEx_InjectedStop function. : Case of multimode enabled (for devices with several ADCs): This function must be called for ADC master first, then ADC slave. For ADC master, conversion is stopped and ADC is disabled. For ADC slave, ADC is disabled only (conversion stop of ADC master has already stopped conversion of ADC slave). HAL_ADC_Start_DMA 76/832 Function Name HAL_StatusTypeDef HAL_ADC_Start_DMA (ADC_HandleTypeDef * hadc, uint32_t * pData, uint32_t Length) Function Description Enables ADC, starts conversion of regular group and transfers result through DMA. DOCID026526 Rev 4 UM1786 HAL_ADC_Stop_DMA Function Name HAL_StatusTypeDef HAL_ADC_Stop_DMA (ADC_HandleTypeDef * hadc) Function Description Stop ADC conversion of regular group (and injected group in case of auto_injection mode), disable ADC DMA transfer, disable ADC peripheral. Parameters hadc: ADC handle Return values HAL: status. Notes : ADC peripheral disable is forcing stop of potential conversion on injected group. If injected group is under use, it should be preliminarily stopped using HAL_ADCEx_InjectedStop function. : Case of multimode enabled (for devices with several ADCs): This function is for single-ADC mode only. For multimode, use the dedicated MultimodeStop function. HAL_ADC_GetValue Function Name uint32_t HAL_ADC_GetValue (ADC_HandleTypeDef * hadc) Function Description Get ADC regular group conversion result. Parameters hadc: ADC handle Return values Converted: value Notes Reading DR register automatically clears EOC (end of conversion of regular group) flag. Additionally, this functions clears EOS (end of sequence of regular group) flag, in case of the end of the sequence is reached. HAL_ADC_IRQHandler Function Name void HAL_ADC_IRQHandler (ADC_HandleTypeDef * hadc) Function Description Handles ADC interrupt request. Parameters hadc: ADC handle Return values None: HAL_ADC_ConvCpltCallback Function Name void HAL_ADC_ConvCpltCallback (ADC_HandleTypeDef * hadc) Function Description Conversion complete callback in non blocking mode. Parameters hadc: ADC handle Return values None: HAL_ADC_ConvHalfCpltCallback Function Name void HAL_ADC_ConvHalfCpltCallback (ADC_HandleTypeDef * hadc) DOCID026526 Rev 4 77/832 Function Description UM1786 Conversion DMA half-transfer callback in non blocking mode. Parameters hadc: ADC handle Return values None: HAL_ADC_LevelOutOfWindowCallback Function Name void HAL_ADC_LevelOutOfWindowCallback (ADC_HandleTypeDef * hadc) Function Description Analog watchdog callback in non blocking mode. Parameters hadc: ADC handle Return values None: HAL_ADC_ErrorCallback Function Name void HAL_ADC_ErrorCallback (ADC_HandleTypeDef * hadc) Function Description ADC error callback in non blocking mode (ADC conversion with interruption or transfer by DMA) Parameters hadc: ADC handle Return values None: HAL_ADC_ConfigChannel Function Name HAL_StatusTypeDef HAL_ADC_ConfigChannel (ADC_HandleTypeDef * hadc, ADC_ChannelConfTypeDef * sConfig) Function Description Configures the the selected channel to be linked to the regular group. Parameters hadc: ADC handle sConfig: Structure of ADC channel for regular group. Return values HAL: status Notes In case of usage of internal measurement channels: Vbat/VrefInt/TempSensor. The recommended sampling time is at least: For devices STM32F37x: 17.1us for temperature sensorFor the other STM32F3 devices: 2.2us for each of channels Vbat/VrefInt/TempSensor. These internal paths can be be disabled using function HAL_ADC_DeInit(). Possibility to update parameters on the fly: This function initializes channel into regular group, following calls to this function can be used to reconfigure some parameters of structure "ADC_ChannelConfTypeDef" on the fly, without reseting the ADC. The setting of these parameters is conditioned to ADC state. For parameters constraints, see comments of structure "ADC_ChannelConfTypeDef". HAL_ADC_AnalogWDGConfig Function Name 78/832 HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig (ADC_HandleTypeDef * hadc, ADC_AnalogWDGConfTypeDef * DOCID026526 Rev 4 UM1786 AnalogWDGConfig) Function Description Configures the analog watchdog. Parameters hadc: ADC handle AnalogWDGConfig: Structure of ADC analog watchdog configuration Return values HAL: status Notes Possibility to update parameters on the fly: This function initializes the selected analog watchdog, following calls to this function can be used to reconfigure some parameters of structure "ADC_AnalogWDGConfTypeDef" on the fly, without reseting the ADC. The setting of these parameters is conditioned to ADC state. For parameters constraints, see comments of structure "ADC_AnalogWDGConfTypeDef". HAL_ADC_GetState Function Name uint32_t HAL_ADC_GetState (ADC_HandleTypeDef * hadc) Function Description return the ADC state Parameters hadc: ADC handle Return values HAL: state Notes ADC state machine is managed by bitfield, state must be compared with bit by bit. For example: " if (HAL_IS_BIT_SET(HAL_ADC_GetState(hadc1), HAL_ADC_STATE_REG_BUSY)) " " if (HAL_IS_BIT_SET(HAL_ADC_GetState(hadc1), HAL_ADC_STATE_AWD1) ) " HAL_ADC_GetError Function Name uint32_t HAL_ADC_GetError (ADC_HandleTypeDef * hadc) Function Description Return the ADC error code. Parameters hadc: ADC handle Return values ADC: Error Code 4.3 ADC Firmware driver defines 4.3.1 ADC ADC Calibration Factor Length Verification IS_ADC_CALFACT Description: Calibration factor length verification (7 bits maximum) Parameters: _Calibration_Factor_: Calibration factor value Return value: None DOCID026526 Rev 4 79/832 UM1786 ADC Conversion Group ADC_REGULAR_GROUP ADC_INJECTED_GROUP ADC_REGULAR_INJECTED_GROUP ADC Exported Macros __HAL_ADC_RESET_HANDLE_STATE Description: Reset ADC handle state. Parameters: __HANDLE__: ADC handle Return value: None ADC Exported Types Notes: HAL_ADC_STATE_RESET 80/832 ADC state machine is managed by bitfields, state must be compared with bit by bit. For example: " if (HAL_IS_BIT_SET(HAL_ADC_GetState(h adc1), HAL_ADC_STATE_REG_BUSY)) " " if (HAL_IS_BIT_SET(HAL_ADC_GetState(h adc1), HAL_ADC_STATE_AWD1) ) " ADC not yet initialized or disabled HAL_ADC_STATE_READY ADC peripheral ready for use HAL_ADC_STATE_BUSY_INTERNAL ADC is busy to internal process (initialization, calibration) HAL_ADC_STATE_TIMEOUT TimeOut occurrence HAL_ADC_STATE_ERROR_INTERNAL Internal error occurrence HAL_ADC_STATE_ERROR_CONFIG Configuration error occurrence HAL_ADC_STATE_ERROR_DMA DMA error occurrence HAL_ADC_STATE_REG_BUSY A conversion on group regular is ongoing or can occur (either by continuous mode, external trigger, low power auto power-on, multimode ADC master control) HAL_ADC_STATE_REG_EOC Conversion data available on group regular HAL_ADC_STATE_REG_OVR Not available on STM32F1 device: Overrun occurrence HAL_ADC_STATE_REG_EOSMP Not available on STM32F1 device: End Of Sampling flag raised HAL_ADC_STATE_INJ_BUSY A conversion on group injected is ongoing or can occur (either by auto-injection mode, external trigger, low power auto power-on, multimode ADC master control) DOCID026526 Rev 4 UM1786 HAL_ADC_STATE_INJ_EOC Conversion data available on group injected HAL_ADC_STATE_INJ_JQOVF Not available on STM32F1 device: Injected queue overflow occurrence HAL_ADC_STATE_AWD1 Out-of-window occurrence of analog watchdog 1 HAL_ADC_STATE_AWD2 Not available on STM32F1 device: Out-ofwindow occurrence of analog watchdog 2 HAL_ADC_STATE_AWD3 Not available on STM32F1 device: Out-ofwindow occurrence of analog watchdog 3 HAL_ADC_STATE_MULTIMODE_SLAV E ADC in multimode slave state, controlled by another ADC master ( ADC Injected Conversion Number Verification IS_ADC_INJECTED_NB_CONV ADC Regular Discontinuous Mode NumberVerification IS_ADC_REGULAR_DISCONT_NUMBER ADC Regular Conversion Number Verification IS_ADC_REGULAR_NB_CONV DOCID026526 Rev 4 81/832 UM1786 5 HAL ADC Extension Driver 5.1 ADCEx Firmware driver registers structures 5.1.1 ADC_InitTypeDef Data Fields uint32_t ClockPrescaler uint32_t Resolution uint32_t DataAlign uint32_t ScanConvMode uint32_t EOCSelection uint32_t LowPowerAutoWait uint32_t ContinuousConvMode uint32_t NbrOfConversion uint32_t DiscontinuousConvMode uint32_t NbrOfDiscConversion uint32_t ExternalTrigConv uint32_t ExternalTrigConvEdge uint32_t DMAContinuousRequests uint32_t Overrun Field Documentation 82/832 uint32_t ADC_InitTypeDef::ClockPrescaler Select ADC clock source (synchronous clock derived from AHB clock or asynchronous clock derived from ADC dedicated PLL 72MHz) and clock prescaler. The clock is common for all the ADCs. This parameter can be a value of ADCEx_ClockPrescaler Note: In case of usage of channels on injected group, ADC frequency should be lower than AHB clock frequency /4 for resolution 12 or 10 bits, AHB clock frequency /3 for resolution 8 bits, AHB clock frequency /2 for resolution 6 bits. Note: In case of usage of the ADC dedicated PLL clock, this clock must be preliminarily enabled and prescaler set at RCC top level. Note: This parameter can be modified only if all ADCs of the common ADC group are disabled (for products with several ADCs) uint32_t ADC_InitTypeDef::Resolution Configures the ADC resolution. This parameter can be a value of ADCEx_Resolution uint32_t ADC_InitTypeDef::DataAlign Specifies ADC data alignment to right (for resolution 12 bits: MSB on register bit 11 and LSB on register bit 0) (default setting) or to left (for resolution 12 bits, if offset disabled: MSB on register bit 15 and LSB on register bit 4, if offset enabled: MSB on register bit 14 and LSB on register bit 3). See reference manual for alignments with other resolutions. This parameter can be a value of ADCEx_Data_align uint32_t ADC_InitTypeDef::ScanConvMode Configures the sequencer of regular and injected groups. This parameter can be associated to parameter 'DiscontinuousConvMode' to have main sequence subdivided in successive parts. If disabled: Conversion is performed in single mode (one channel converted, the one defined in rank 1). Parameters 'NbrOfConversion' and DOCID026526 Rev 4 UM1786 'InjectedNbrOfConversion' are discarded (equivalent to set to 1). If enabled: Conversions are performed in sequence mode (multiple ranks defined by 'NbrOfConversion'/'InjectedNbrOfConversion' and each channel rank). Scan direction is upward: from rank1 to rank 'n'. This parameter can be a value of ADCEx_Scan_mode uint32_t ADC_InitTypeDef::EOCSelection Specifies what EOC (End Of Conversion) flag is used for conversion by polling and interruption: end of conversion of each rank or complete sequence. This parameter can be a value of ADCEx_EOCSelection. uint32_t ADC_InitTypeDef::LowPowerAutoWait Selects the dynamic low power Auto Delay: ADC conversions are performed only when necessary. New conversion starts only when the previous conversion (for regular group) or previous sequence (for injected group) has been treated by user software. This feature automatically adapts the speed of ADC to the speed of the system that reads the data. Moreover, this avoids risk of overrun for low frequency applications. This parameter can be set to ENABLE or DISABLE. Note: Do not use with interruption or DMA (HAL_ADC_Start_IT(), HAL_ADC_Start_DMA()) since they have to clear immediately the EOC flag to free the IRQ vector sequencer. Do use with polling: 1. Start conversion with HAL_ADC_Start(), 2. Later on, when conversion data is needed: use HAL_ADC_PollForConversion() to ensure that conversion is completed and use HAL_ADC_GetValue() to retrieve conversion result and trig another conversion (in case of usage of injected group, use the equivalent functions HAL_ADCExInjected_Start(), HAL_ADCEx_InjectedGetValue(), ...). uint32_t ADC_InitTypeDef::ContinuousConvMode Specifies whether the conversion is performed in single mode (one conversion) or continuous mode for regular group, after the selected trigger occurred (software start or external trigger). This parameter can be set to ENABLE or DISABLE. uint32_t ADC_InitTypeDef::NbrOfConversion Specifies the number of ranks that will be converted within the regular group sequencer. To use the regular group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled. This parameter must be a number between Min_Data = 1 and Max_Data = 16. Note: This parameter must be modified when no conversion is on going on regular group (ADC disabled, or ADC enabled without continuous mode or external trigger that could launch a conversion). uint32_t ADC_InitTypeDef::DiscontinuousConvMode Specifies whether the conversions sequence of regular group is performed in Complete-sequence/Discontinuous-sequence (main sequence subdivided in successive parts). Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded. Discontinuous mode can be enabled only if continuous mode is disabled. If continuous mode is enabled, this parameter setting is discarded. This parameter can be set to ENABLE or DISABLE. uint32_t ADC_InitTypeDef::NbrOfDiscConversion Specifies the number of discontinuous conversions in which the main sequence of regular group (parameter NbrOfConversion) will be subdivided. If parameter 'DiscontinuousConvMode' is disabled, this parameter is discarded. This parameter must be a number between Min_Data = 1 and Max_Data = 8. uint32_t ADC_InitTypeDef::ExternalTrigConv Selects the external event used to trigger the conversion start of regular group. If set to ADC_SOFTWARE_START, external triggers are disabled. This parameter can be a value of ADCEx_External_trigger_source_Regular Caution: For devices with several ADCs, external trigger source is common to ADC common group (for example: ADC1&ADC2, ADC3&ADC4, if available) uint32_t ADC_InitTypeDef::ExternalTrigConvEdge Selects the external trigger edge of regular group. If trigger is set to DOCID026526 Rev 4 83/832 5.1.2 UM1786 ADC_SOFTWARE_START, this parameter is discarded. This parameter can be a value of ADCEx_External_trigger_edge_Regular uint32_t ADC_InitTypeDef::DMAContinuousRequests Specifies whether the DMA requests are performed in one shot mode (DMA transfer stop when number of conversions is reached) or in Continuous mode (DMA transfer unlimited, whatever number of conversions). Note: In continuous mode, DMA must be configured in circular mode. Otherwise an overrun will be triggered when DMA buffer maximum pointer is reached. This parameter can be set to ENABLE or DISABLE. Note: This parameter must be modified when no conversion is on going on both regular and injected groups (ADC disabled, or ADC enabled without continuous mode or external trigger that could launch a conversion). uint32_t ADC_InitTypeDef::Overrun Select the behaviour in case of overrun: data overwritten (default) or preserved. This parameter is for regular group only. This parameter can be a value of ADCEx_Overrun Note: Case of overrun set to data preserved and usage with end on conversion interruption (HAL_Start_IT()): ADC IRQ handler has to clear end of conversion flags, this induces the release of the preserved data. If needed, this data can be saved into function HAL_ADC_ConvCpltCallback() (called before end of conversion flags clear). Note: Error reporting in function of conversion mode:Usage with ADC conversion by polling for event or interruption: Error is reported only if overrun is set to data preserved. If overrun is set to data overwritten, user can willingly not read the conversion data each time, this is not considered as an erroneous case.Usage with ADC conversion by DMA: Error is reported whatever overrun setting (DMA is expected to process all data from data register, any data missed would be abnormal). ADC_ChannelConfTypeDef Data Fields uint32_t Channel uint32_t Rank uint32_t SamplingTime uint32_t SingleDiff uint32_t OffsetNumber uint32_t Offset Field Documentation 84/832 uint32_t ADC_ChannelConfTypeDef::Channel Specifies the channel to configure into ADC regular group. This parameter can be a value of ADCEx_channels Note: Depending on devices, some channels may not be available on package pins. Refer to device datasheet for channels availability. uint32_t ADC_ChannelConfTypeDef::Rank Specifies the rank in the regular group sequencer. This parameter can be a value of ADCEx_regular_rank Note: In case of need to disable a channel or change order of conversion sequencer, rank containing a previous channel setting can be overwritten by the new channel setting (or parameter number of conversions can be adjusted) uint32_t ADC_ChannelConfTypeDef::SamplingTime Sampling time value to be set for the selected channel. Unit: ADC clock cycles Conversion time is the addition of sampling time and processing time (12.5 ADC clock cycles at ADC resolution 12 bits, 10.5 cycles at 10 bits, 8.5 cycles at 8 bits, 6.5 cycles DOCID026526 Rev 4 UM1786 5.1.3 at 6 bits). This parameter can be a value of ADCEx_sampling_times Caution: This parameter updates the parameter property of the channel, that can be used into regular and/or injected groups. If this same channel has been previously configured in the other group (regular/injected), it will be updated to last setting. Note: In case of usage of internal measurement channels (VrefInt/Vbat/TempSensor), sampling time constraints must be respected (sampling time can be adjusted in function of ADC clock frequency and sampling time setting) Refer to device datasheet for timings values, parameters TS_vrefint, TS_vbat, TS_temp (values rough order: 2.2us min). uint32_t ADC_ChannelConfTypeDef::SingleDiff Selection of single-ended or differential input. In differential mode: Differential measurement is between the selected channel 'i' (positive input) and channel 'i+1' (negative input). Only channel 'i' has to be configured, channel 'i+1' is configured automatically. This parameter must be a value of ADCEx_SingleDifferential Caution: This parameter updates the parameter property of the channel, that can be used into regular and/or injected groups. If this same channel has been previously configured in the other group (regular/injected), it will be updated to last setting. Note: Channels 1 to 14 are available in differential mode. Channels 15, 16, 17, 18 can be used only in single-ended mode. Note: When configuring a channel 'i' in differential mode, the channel 'i+1' is not usable separately. Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion). If ADC is enabled, this parameter setting is bypassed without error reporting (as it can be the expected behaviour in case of another parameter update on the fly) uint32_t ADC_ChannelConfTypeDef::OffsetNumber Selects the offset number This parameter can be a value of ADCEx_OffsetNumber Caution: Only one channel is allowed per channel. If another channel was on this offset number, the offset will be changed to the new channel uint32_t ADC_ChannelConfTypeDef::Offset Defines the offset to be subtracted from the raw converted data when convert channels. Offset value must be a positive number. Depending of ADC resolution selected (12, 10, 8 or 6 bits), this parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF, 0x3FF, 0xFF or 0x3F respectively. Note: This parameter must be modified when no conversion is on going on both regular and injected groups (ADC disabled, or ADC enabled without continuous mode or external trigger that could launch a conversion). ADC_InjectionConfTypeDef Data Fields uint32_t InjectedChannel uint32_t InjectedRank uint32_t InjectedSamplingTime uint32_t InjectedSingleDiff uint32_t InjectedOffsetNumber uint32_t InjectedOffset uint32_t InjectedNbrOfConversion uint32_t InjectedDiscontinuousConvMode uint32_t AutoInjectedConv uint32_t QueueInjectedContext uint32_t ExternalTrigInjecConv uint32_t ExternalTrigInjecConvEdge DOCID026526 Rev 4 85/832 UM1786 Field Documentation 86/832 uint32_t ADC_InjectionConfTypeDef::InjectedChannel Configure the ADC injected channel This parameter can be a value of ADCEx_channels Note: Depending on devices, some channels may not be available on package pins. Refer to device datasheet for channels availability. uint32_t ADC_InjectionConfTypeDef::InjectedRank The rank in the regular group sequencer This parameter must be a value of ADCEx_injected_rank Note: In case of need to disable a channel or change order of conversion sequencer, rank containing a previous channel setting can be overwritten by the new channel setting (or parameter number of conversions can be adjusted) uint32_t ADC_InjectionConfTypeDef::InjectedSamplingTime Sampling time value to be set for the selected channel. Unit: ADC clock cycles Conversion time is the addition of sampling time and processing time (12.5 ADC clock cycles at ADC resolution 12 bits, 10.5 cycles at 10 bits, 8.5 cycles at 8 bits, 6.5 cycles at 6 bits). This parameter can be a value of ADCEx_sampling_times Caution: This parameter updates the parameter property of the channel, that can be used into regular and/or injected groups. If this same channel has been previously configured in the other group (regular/injected), it will be updated to last setting. Note: In case of usage of internal measurement channels (VrefInt/Vbat/TempSensor), sampling time constraints must be respected (sampling time can be adjusted in function of ADC clock frequency and sampling time setting) Refer to device datasheet for timings values, parameters TS_vrefint, TS_vbat, TS_temp (values rough order: 2.2us min). uint32_t ADC_InjectionConfTypeDef::InjectedSingleDiff Selection of single-ended or differential input. In differential mode: Differential measurement is between the selected channel 'i' (positive input) and channel 'i+1' (negative input). Only channel 'i' has to be configured, channel 'i+1' is configured automatically. This parameter must be a value of ADCEx_SingleDifferential Caution: This parameter updates the parameter property of the channel, that can be used into regular and/or injected groups. If this same channel has been previously configured in the other group (regular/injected), it will be updated to last setting. Note: Channels 1 to 14 are available in differential mode. Channels 15, 16, 17, 18 can be used only in single-ended mode. Note: When configuring a channel 'i' in differential mode, the channel 'i-1' is not usable separately. Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion). If ADC is enabled, this parameter setting is bypassed without error reporting (as it can be the expected behaviour in case of another parameter update on the fly) uint32_t ADC_InjectionConfTypeDef::InjectedOffsetNumber Selects the offset number This parameter can be a value of ADCEx_OffsetNumber Caution: Only one channel is allowed per offset number. If another channel was on this offset number, the offset will be changed to the new channel. uint32_t ADC_InjectionConfTypeDef::InjectedOffset Defines the offset to be subtracted from the raw converted data. Offset value must be a positive number. Depending of ADC resolution selected (12, 10, 8 or 6 bits), this parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF, 0x3FF, 0xFF or 0x3F respectively. uint32_t ADC_InjectionConfTypeDef::InjectedNbrOfConversion Specifies the number of ranks that will be converted within the injected group sequencer. To use the injected group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled. This parameter must be a number between Min_Data = 1 and Max_Data = 4. Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to configure a channel on injected group can impact the configuration of other channels previously set. uint32_t ADC_InjectionConfTypeDef::InjectedDiscontinuousConvMode Specifies whether the conversions sequence of injected group is performed in DOCID026526 Rev 4 UM1786 Complete-sequence/Discontinuous-sequence (main sequence subdivided in successive parts). Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded. Discontinuous mode can be enabled only if continuous mode is disabled. If continuous mode is enabled, this parameter setting is discarded. This parameter can be set to ENABLE or DISABLE. Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion). Note: For injected group, number of discontinuous ranks increment is fixed to one-by-one. Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to configure a channel on injected group can impact the configuration of other channels previously set. uint32_t ADC_InjectionConfTypeDef::AutoInjectedConv Enables or disables the selected ADC automatic injected group conversion after regular one This parameter can be set to ENABLE or DISABLE. Note: To use Automatic injected conversion, discontinuous mode must be disabled ('DiscontinuousConvMode' and 'InjectedDiscontinuousConvMode' set to DISABLE) Note: To use Automatic injected conversion, injected group external triggers must be disabled ('ExternalTrigInjecConv' set to ADC_SOFTWARE_START) Note: In case of DMA used with regular group: if DMA configured in normal mode (single shot) JAUTO will be stopped upon DMA transfer complete. To maintain JAUTO always enabled, DMA must be configured in circular mode. Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to configure a channel on injected group can impact the configuration of other channels previously set. uint32_t ADC_InjectionConfTypeDef::QueueInjectedContext Specifies whether the context queue feature is enabled. This parameter can be set to ENABLE or DISABLE. If context queue is enabled, injected sequencer&channels configurations are queued on up to 2 contexts. If a new injected context is set when queue is full, error is triggered by interruption and through function 'HAL_ADCEx_InjectedQueueOverflowCallback'. Caution: This feature request that the sequence is fully configured before injected conversion start. Therefore, configure channels with HAL_ADCEx_InjectedConfigChannel() as many times as value of 'InjectedNbrOfConversion' parameter. Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to configure a channel on injected group can impact the configuration of other channels previously set. Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion). uint32_t ADC_InjectionConfTypeDef::ExternalTrigInjecConv Selects the external event used to trigger the conversion start of injected group. If set to ADC_INJECTED_SOFTWARE_START, external triggers are disabled. This parameter can be a value of ADCEx_External_trigger_source_Injected Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to configure a channel on injected group can impact the configuration of other channels previously set. uint32_t ADC_InjectionConfTypeDef::ExternalTrigInjecConvEdge Selects the external trigger edge of injected group. This parameter can be a value of ADCEx_External_trigger_edge_Injected. If trigger is set to ADC_INJECTED_SOFTWARE_START, this parameter is discarded. Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to configure a channel on injected group can impact the configuration of other channels previously set. DOCID026526 Rev 4 87/832 UM1786 5.1.4 ADC_InjectionConfigTypeDef Data Fields uint32_t ContextQueue uint32_t ChannelCount Field Documentation 5.1.5 uint32_t ADC_InjectionConfigTypeDef::ContextQueue Injected channel configuration context: build-up over each HAL_ADCEx_InjectedConfigChannel() call to finally initialize JSQR register at HAL_ADCEx_InjectedConfigChannel() last call uint32_t ADC_InjectionConfigTypeDef::ChannelCount Number of channels in the injected sequence ADC_AnalogWDGConfTypeDef Data Fields uint32_t WatchdogNumber uint32_t WatchdogMode uint32_t Channel uint32_t ITMode uint32_t HighThreshold uint32_t LowThreshold Field Documentation 88/832 uint32_t ADC_AnalogWDGConfTypeDef::WatchdogNumber Selects which ADC analog watchdog to apply to the selected channel. For Analog Watchdog 1: Only 1 channel can be monitored (or overall group of channels by setting parameter 'WatchdogMode') For Analog Watchdog 2 and 3: Several channels can be monitored (by successive calls of 'HAL_ADC_AnalogWDGConfig()' for each channel) This parameter can be a value of ADCEx_analog_watchdog_number. uint32_t ADC_AnalogWDGConfTypeDef::WatchdogMode For Analog Watchdog 1: Configures the ADC analog watchdog mode: single channel/overall group of channels, regular/injected group. For Analog Watchdog 2 and 3: There is no configuration for overall group of channels as AWD1. Set value 'ADC_ANALOGWATCHDOG_NONE' to reset channels group programmed with parameter 'Channel', set any other value to not use this parameter. This parameter can be a value of ADCEx_analog_watchdog_mode. uint32_t ADC_AnalogWDGConfTypeDef::Channel Selects which ADC channel to monitor by analog watchdog. For Analog Watchdog 1: this parameter has an effect only if parameter 'WatchdogMode' is configured on single channel. Only 1 channel can be monitored. For Analog Watchdog 2 and 3: Several channels can be monitored (successive calls of HAL_ADC_AnalogWDGConfig() must be done, one for each channel. Channels group reset can be done by setting WatchdogMode to 'ADC_ANALOGWATCHDOG_NONE'). This parameter can be a value of ADCEx_channels. DOCID026526 Rev 4 UM1786 5.1.6 uint32_t ADC_AnalogWDGConfTypeDef::ITMode Specifies whether the analog watchdog is configured in interrupt or polling mode. This parameter can be set to ENABLE or DISABLE uint32_t ADC_AnalogWDGConfTypeDef::HighThreshold Configures the ADC analog watchdog High threshold value. Depending of ADC resolution selected (12, 10, 8 or 6 bits), this parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF, 0x3FF, 0xFF or 0x3F respectively. Note: Analog watchdog 2 and 3 are limited to a resolution of 8 bits: if ADC resolution is 12 bits the 4 LSB are ignored, if ADC resolution is 10 bits the 2 LSB are ignored. uint32_t ADC_AnalogWDGConfTypeDef::LowThreshold Configures the ADC analog watchdog High threshold value. Depending of ADC resolution selected (12, 10, 8 or 6 bits), this parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF, 0x3FF, 0xFF or 0x3F respectively. Note: Analog watchdog 2 and 3 are limited to a resolution of 8 bits: if ADC resolution is 12 bits the 4 LSB are ignored, if ADC resolution is 10 bits the 2 LSB are ignored. ADC_MultiModeTypeDef Data Fields uint32_t Mode uint32_t DMAAccessMode uint32_t TwoSamplingDelay Field Documentation uint32_t ADC_MultiModeTypeDef::Mode Configures the ADC to operate in independent or multi mode. This parameter can be a value of ADCEx_Common_mode uint32_t ADC_MultiModeTypeDef::DMAAccessMode Configures the DMA mode for multi ADC mode: selection whether 2 DMA channels (each ADC use its own DMA channel) or 1 DMA channel (one DMA channel for both ADC, DMA of ADC master) This parameter can be a value of ADCEx_Direct_memory_access_mode_for_multimode Caution: Limitations with multimode DMA access enabled (1 DMA channel used): In case of dual mode in high speed (more than 5Msps) or high activity of DMA by other peripherals, there is a risk of DMA overrun. Therefore, it is recommended to disable multimode DMA access: each ADC uses its own DMA channel. Refer to device errata sheet for more details. uint32_t ADC_MultiModeTypeDef::TwoSamplingDelay Configures the Delay between 2 sampling phases. This parameter can be a value of ADCEx_delay_between_2_sampling_phases Delay range depends on selected resolution: from 1 to 12 clock cycles for 12 bits, from 1 to 10 clock cycles for 10 bits from 1 to 8 clock cycles for 8 bits, from 1 to 6 clock cycles for 6 bits 5.2 ADCEx Firmware driver API description 5.2.1 Initialization and de-initialization functions This section provides functions allowing to: Initialize and configure the ADC. DOCID026526 Rev 4 89/832 UM1786 De-initialize the ADC. This section contains the following APIs: 5.2.2 HAL_ADC_Init() HAL_ADC_DeInit() IO operation functions This section provides functions allowing to: Start conversion of regular group. Stop conversion of regular group. Poll for conversion complete on regular group. Poll for conversion event. Get result of regular channel conversion. Start conversion of regular group and enable interruptions. Stop conversion of regular group and disable interruptions. Handle ADC interrupt request Start conversion of regular group and enable DMA transfer. Stop conversion of regular group and disable ADC DMA transfer. Start conversion of injected group. Stop conversion of injected group. Poll for conversion complete on injected group. Get result of injected channel conversion. Start conversion of injected group and enable interruptions. Stop conversion of injected group and disable interruptions. Start multimode and enable DMA transfer. Stop multimode and disable ADC DMA transfer. Get result of multimode conversion. Perform the ADC self-calibration for single or differential ending. Get calibration factors for single or differential ending. Set calibration factors for single or differential ending. This section contains the following APIs: 90/832 HAL_ADC_Start() HAL_ADC_Stop() HAL_ADC_PollForConversion() HAL_ADC_PollForEvent() HAL_ADC_Start_IT() HAL_ADC_Stop_IT() HAL_ADC_Start_DMA() HAL_ADC_Stop_DMA() HAL_ADC_GetValue() HAL_ADC_IRQHandler() HAL_ADCEx_Calibration_Start() HAL_ADCEx_Calibration_GetValue() HAL_ADCEx_Calibration_SetValue() HAL_ADCEx_InjectedStart() HAL_ADCEx_InjectedStop() HAL_ADCEx_InjectedPollForConversion() HAL_ADCEx_InjectedStart_IT() HAL_ADCEx_InjectedStop_IT() HAL_ADCEx_MultiModeStart_DMA() HAL_ADCEx_MultiModeStop_DMA() DOCID026526 Rev 4 UM1786 5.2.3 HAL_ADCEx_MultiModeGetValue() HAL_ADCEx_InjectedGetValue() HAL_ADCEx_RegularStop() HAL_ADCEx_RegularStop_IT() HAL_ADCEx_RegularStop_DMA() HAL_ADCEx_RegularMultiModeStop_DMA() HAL_ADCEx_InjectedConvCpltCallback() HAL_ADCEx_InjectedQueueOverflowCallback() HAL_ADCEx_LevelOutOfWindow2Callback() HAL_ADCEx_LevelOutOfWindow3Callback() Peripheral Control functions This section provides functions allowing to: Configure channels on regular group Configure channels on injected group Configure multimode Configure the analog watchdog This section contains the following APIs: 5.2.4 HAL_ADC_ConfigChannel() HAL_ADCEx_InjectedConfigChannel() HAL_ADC_AnalogWDGConfig() HAL_ADCEx_MultiModeConfigChannel() Detailed description of functions HAL_ADCEx_Calibration_Start Function Name HAL_StatusTypeDef HAL_ADCEx_Calibration_Start (ADC_HandleTypeDef * hadc, uint32_t SingleDiff) Function Description Perform an ADC automatic self-calibration Calibration prerequisite: ADC must be disabled (execute this function before HAL_ADC_Start() or after HAL_ADC_Stop() ). Parameters hadc: ADC handle SingleDiff: Selection of single-ended or differential input This parameter can be one of the following values: ADC_SINGLE_ENDED: Channel in mode input single ended ADC_DIFFERENTIAL_ENDED: Channel in mode input differential ended Return values HAL: status HAL_ADCEx_Calibration_GetValue Function Name uint32_t HAL_ADCEx_Calibration_GetValue (ADC_HandleTypeDef * hadc, uint32_t SingleDiff) Function Description Get the calibration factor from automatic conversion result. Parameters hadc: ADC handle SingleDiff: Selection of single-ended or differential input This parameter can be one of the following values: DOCID026526 Rev 4 91/832 UM1786 Return values ADC_SINGLE_ENDED: Channel in mode input single ended ADC_DIFFERENTIAL_ENDED: Channel in mode input differential ended Converted: value HAL_ADCEx_Calibration_SetValue Function Name HAL_StatusTypeDef HAL_ADCEx_Calibration_SetValue (ADC_HandleTypeDef * hadc, uint32_t SingleDiff, uint32_t CalibrationFactor) Function Description Set the calibration factor to overwrite automatic conversion result. Parameters Return values hadc: ADC handle SingleDiff: Selection of single-ended or differential input This parameter can be one of the following values: ADC_SINGLE_ENDED: Channel in mode input single ended ADC_DIFFERENTIAL_ENDED: Channel in mode input differential ended CalibrationFactor: Calibration factor (coded on 7 bits maximum) HAL: state HAL_ADCEx_InjectedStart Function Name HAL_StatusTypeDef HAL_ADCEx_InjectedStart (ADC_HandleTypeDef * hadc) Function Description Enables ADC, starts conversion of injected group. Parameters hadc: ADC handle Return values HAL: status Notes Case of multimode enabled (for devices with several ADCs): This function must be called for ADC slave first, then ADC master. For ADC slave, ADC is enabled only (conversion is not started). For ADC master, ADC is enabled and multimode conversion is started. HAL_ADCEx_InjectedStop 92/832 Function Name HAL_StatusTypeDef HAL_ADCEx_InjectedStop (ADC_HandleTypeDef * hadc) Function Description Stop ADC group injected conversion (potential conversion on going on ADC group regular is not impacted), disable ADC peripheral if no conversion is on going on group regular. Parameters hadc: ADC handle Return values None: Notes To stop ADC conversion of both groups regular and injected and to to disable ADC peripheral, instead of using 2 functions HAL_ADCEx_RegularStop() and DOCID026526 Rev 4 UM1786 HAL_ADCEx_InjectedStop(), use function HAL_ADC_Stop(). If injected group mode auto-injection is enabled, function HAL_ADC_Stop must be used. Case of multimode enabled (for devices with several ADCs): This function must be called for ADC master first, then ADC slave. For ADC master, conversion is stopped and ADC is disabled. For ADC slave, ADC is disabled only (conversion stop of ADC master has already stopped conversion of ADC slave). In case of auto-injection mode, HAL_ADC_Stop must be used. HAL_ADCEx_InjectedPollForConversion Function Name HAL_StatusTypeDef HAL_ADCEx_InjectedPollForConversion (ADC_HandleTypeDef * hadc, uint32_t Timeout) Function Description Wait for injected group conversion to be completed. Parameters hadc: ADC handle Timeout: Timeout value in millisecond. Return values HAL: status HAL_ADCEx_InjectedStart_IT Function Name HAL_StatusTypeDef HAL_ADCEx_InjectedStart_IT (ADC_HandleTypeDef * hadc) Function Description Enables ADC, starts conversion of injected group with interruption. HAL_ADCEx_InjectedStop_IT Function Name HAL_StatusTypeDef HAL_ADCEx_InjectedStop_IT (ADC_HandleTypeDef * hadc) Function Description Stop ADC group injected conversion (potential conversion on going on ADC group regular is not impacted), disable ADC peripheral if no conversion is on going on group regular. HAL_ADCEx_MultiModeStart_DMA Function Name HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA (ADC_HandleTypeDef * hadc, uint32_t * pData, uint32_t Length) Function Description With ADC configured in multimode, for ADC master: Enables ADC, starts conversion of regular group and transfers result through DMA. HAL_ADCEx_MultiModeStop_DMA Function Name HAL_StatusTypeDef HAL_ADCEx_MultiModeStop_DMA (ADC_HandleTypeDef * hadc) Function Description With ADC configured in multimode, for ADC master: Stop ADC group regular conversion (potential conversion on going on ADC group injected is not impacted), disable ADC DMA transfer, disable DOCID026526 Rev 4 93/832 UM1786 ADC peripheral if no conversion is on going on group injected. HAL_ADCEx_MultiModeGetValue Function Name uint32_t HAL_ADCEx_MultiModeGetValue (ADC_HandleTypeDef * hadc) Function Description Returns the last ADC Master&Slave regular conversions results data in the selected multi mode. Parameters hadc: ADC handle of ADC master (handle of ADC slave must not be used) Return values The: converted data value. Notes Reading register CDR does not clear flag ADC flag EOC (ADC group regular end of unitary conversion), as it is the case for independent mode data register. HAL_ADCEx_RegularStop Function Name HAL_StatusTypeDef HAL_ADCEx_RegularStop (ADC_HandleTypeDef * hadc) Function Description Stop ADC group regular conversion (potential conversion on going on ADC group injected is not impacted), disable ADC peripheral if no conversion is on going on group injected. Parameters hadc: ADC handle Return values HAL: status. Notes To stop ADC conversion of both groups regular and injected and to to disable ADC peripheral, instead of using 2 functions HAL_ADCEx_RegularStop() and HAL_ADCEx_InjectedStop(), use function HAL_ADC_Stop(). In case of auto-injection mode, this function also stop conversion on ADC group injected. HAL_ADCEx_RegularStop_IT Function Name HAL_StatusTypeDef HAL_ADCEx_RegularStop_IT (ADC_HandleTypeDef * hadc) Function Description Stop ADC group regular conversion (potential conversion on going on ADC group injected is not impacted), disable ADC peripheral if no conversion is on going on group injected. HAL_ADCEx_RegularStop_DMA 94/832 Function Name HAL_StatusTypeDef HAL_ADCEx_RegularStop_DMA (ADC_HandleTypeDef * hadc) Function Description Stop ADC group regular conversion (potential conversion on going on ADC group injected is not impacted), disable ADC DMA transfer, disable ADC peripheral if no conversion is on going on group injected. DOCID026526 Rev 4 UM1786 HAL_ADCEx_RegularMultiModeStop_DMA Function Name HAL_StatusTypeDef HAL_ADCEx_RegularMultiModeStop_DMA (ADC_HandleTypeDef * hadc) Function Description With ADC configured in multimode, for ADC master: Stop ADC group regular conversion (potential conversion on going on ADC group injected is not impacted), disable ADC DMA transfer, disable ADC peripheral if no conversion is on going on group injected. HAL_ADCEx_InjectedGetValue Function Name uint32_t HAL_ADCEx_InjectedGetValue (ADC_HandleTypeDef * hadc, uint32_t InjectedRank) Function Description Get ADC injected group conversion result. Parameters hadc: ADC handle InjectedRank: the converted ADC injected rank. This parameter can be one of the following values: ADC_INJECTED_RANK_1: Injected Channel1 selected ADC_INJECTED_RANK_2: Injected Channel2 selected ADC_INJECTED_RANK_3: Injected Channel3 selected ADC_INJECTED_RANK_4: Injected Channel4 selected Return values ADC: group injected conversion data Notes Reading register JDRx automatically clears ADC flag JEOC (ADC group injected end of unitary conversion). This function does not clear ADC flag JEOS (ADC group injected end of sequence conversion) Occurrence of flag JEOS rising: If sequencer is composed of 1 rank, flag JEOS is equivalent to flag JEOC.If sequencer is composed of several ranks, during the scan sequence flag JEOC only is raised, at the end of the scan sequence both flags JEOC and EOS are raised. Flag JEOS must not be cleared by this function because it would not be compliant with low power features (feature low power auto-wait, not available on all STM32 families). To clear this flag, either use function: in programming model IT: HAL_ADC_IRQHandler(), in programming model polling: HAL_ADCEx_InjectedPollForConversion() or __HAL_ADC_CLEAR_FLAG(&hadc, ADC_FLAG_JEOS). HAL_ADCEx_InjectedConvCpltCallback Function Name void HAL_ADCEx_InjectedConvCpltCallback (ADC_HandleTypeDef * hadc) Function Description Injected conversion complete callback in non blocking mode. Parameters hadc: ADC handle Return values None: DOCID026526 Rev 4 95/832 UM1786 HAL_ADCEx_InjectedQueueOverflowCallback Function Name void HAL_ADCEx_InjectedQueueOverflowCallback (ADC_HandleTypeDef * hadc) Function Description Injected context queue overflow flag callback. Parameters hadc: ADC handle Return values None: Notes This callback is called if injected context queue is enabled (parameter "QueueInjectedContext" in injected channel configuration) and if a new injected context is set when queue is full (maximum 2 contexts). HAL_ADCEx_LevelOutOfWindow2Callback Function Name void HAL_ADCEx_LevelOutOfWindow2Callback (ADC_HandleTypeDef * hadc) Function Description Analog watchdog 2 callback in non blocking mode. Parameters hadc: ADC handle Return values None: HAL_ADCEx_LevelOutOfWindow3Callback Function Name void HAL_ADCEx_LevelOutOfWindow3Callback (ADC_HandleTypeDef * hadc) Function Description Analog watchdog 3 callback in non blocking mode. Parameters hadc: ADC handle Return values None: HAL_ADCEx_InjectedConfigChannel Function Name HAL_StatusTypeDef HAL_ADCEx_InjectedConfigChannel (ADC_HandleTypeDef * hadc, ADC_InjectionConfTypeDef * sConfigInjected) Function Description Configures the ADC injected group and the selected channel to be linked to the injected group. Parameters hadc: ADC handle sConfigInjected: Structure of ADC injected group and ADC channel for injected group. Return values None: Notes Possibility to update parameters on the fly: This function initializes injected group, following calls to this function can be used to reconfigure some parameters of structure "ADC_InjectionConfTypeDef" on the fly, without reseting the ADC. The setting of these parameters is conditioned to ADC state. For parameters constraints, see comments of structure "ADC_InjectionConfTypeDef". In case of usage of internal measurement channels: 96/832 DOCID026526 Rev 4 UM1786 Vbat/VrefInt/TempSensor. The recommended sampling time is at least: For devices STM32F37x: 17.1us for temperature sensorFor the other STM32F3 devices: 2.2us for each of channels Vbat/VrefInt/TempSensor. These internal paths can be be disabled using function HAL_ADC_DeInit(). To reset injected sequencer, function HAL_ADCEx_InjectedStop() can be used. Caution: For Injected Context Queue use: a context must be fully defined before start of injected conversion: all channels configured consecutively for the same ADC instance. Therefore, Number of calls of HAL_ADCEx_InjectedConfigChannel() must correspond to value of parameter InjectedNbrOfConversion for each context. Example 1: If 1 context intended to be used (or not use of this feature: QueueInjectedContext=DISABLE) and usage of the 3 first injected ranks (InjectedNbrOfConversion=3), HAL_ADCEx_InjectedConfigChannel() must be called once for each channel (3 times) before launching a conversion. This function must not be called to configure the 4th injected channel: it would start a new context into context queue.Example 2: If 2 contexts intended to be used and usage of the 3 first injected ranks (InjectedNbrOfConversion=3), HAL_ADCEx_InjectedConfigChannel() must be called once for each channel and for each context (3 channels x 2 contexts = 6 calls). Conversion can start once the 1st context is set. The 2nd context can be set on the fly. HAL_ADCEx_MultiModeConfigChannel Function Name HAL_StatusTypeDef HAL_ADCEx_MultiModeConfigChannel (ADC_HandleTypeDef * hadc, ADC_MultiModeTypeDef * multimode) Function Description Enable ADC multimode and configure multimode parameters. Parameters hadc: ADC handle multimode: : Structure of ADC multimode configuration Return values HAL: status Notes Possibility to update parameters on the fly: This function initializes multimode parameters, following calls to this function can be used to reconfigure some parameters of structure "ADC_MultiModeTypeDef" on the fly, without reseting the ADCs (both ADCs of the common group). The setting of these parameters is conditioned to ADC state. For parameters constraints, see comments of structure "ADC_MultiModeTypeDef". To change back configuration from multimode to single mode, ADC must be reset (using function HAL_ADC_Init() ). DOCID026526 Rev 4 97/832 UM1786 5.3 ADCEx Firmware driver defines 5.3.1 ADCEx ADC Extended Analog Watchdog Mode ADC_ANALOGWATCHDOG_NONE ADC_ANALOGWATCHDOG_SINGLE_REG ADC_ANALOGWATCHDOG_SINGLE_INJEC ADC_ANALOGWATCHDOG_SINGLE_REGINJEC ADC_ANALOGWATCHDOG_ALL_REG ADC_ANALOGWATCHDOG_ALL_INJEC ADC_ANALOGWATCHDOG_ALL_REGINJEC ADC Extended Analog Watchdog Selection ADC_ANALOGWATCHDOG_1 ADC_ANALOGWATCHDOG_2 ADC_ANALOGWATCHDOG_3 ADC Extended Channels ADC_CHANNEL_1 ADC_CHANNEL_2 ADC_CHANNEL_3 ADC_CHANNEL_4 ADC_CHANNEL_5 ADC_CHANNEL_6 ADC_CHANNEL_7 ADC_CHANNEL_8 ADC_CHANNEL_9 ADC_CHANNEL_10 ADC_CHANNEL_11 ADC_CHANNEL_12 ADC_CHANNEL_13 ADC_CHANNEL_14 ADC_CHANNEL_15 ADC_CHANNEL_16 ADC_CHANNEL_17 ADC_CHANNEL_18 ADC_CHANNEL_VOPAMP1 ADC_CHANNEL_TEMPSENSOR ADC_CHANNEL_VBAT 98/832 DOCID026526 Rev 4 UM1786 ADC_CHANNEL_VOPAMP2 ADC_CHANNEL_VOPAMP3 ADC_CHANNEL_VOPAMP4 ADC_CHANNEL_VREFINT ADC Extended Clock Prescaler ADC_CLOCK_ASYNC_DIV1 ADC asynchronous clock derived from ADC dedicated PLL ADC_CLOCK_SYNC_PCLK_DIV1 ADC synchronous clock derived from AHB clock without prescaler ADC_CLOCK_SYNC_PCLK_DIV2 ADC synchronous clock derived from AHB clock divided by a prescaler of 2 ADC_CLOCK_SYNC_PCLK_DIV4 ADC synchronous clock derived from AHB clock divided by a prescaler of 4 IS_ADC_CLOCKPRESCALER ADC Extended Dual ADC Mode ADC_MODE_INDEPENDENT ADC_DUALMODE_REGSIMULT_INJECSIMULT ADC_DUALMODE_REGSIMULT_ALTERTRIG ADC_DUALMODE_REGINTERL_INJECSIMULT ADC_DUALMODE_INJECSIMULT ADC_DUALMODE_REGSIMULT ADC_DUALMODE_INTERL ADC_DUALMODE_ALTERTRIG ADC Extended Data Alignment ADC_DATAALIGN_RIGHT ADC_DATAALIGN_LEFT ADC Extended Delay Between 2 Sampling Phases ADC_TWOSAMPLINGDELAY_1CYCLE ADC_TWOSAMPLINGDELAY_2CYCLES ADC_TWOSAMPLINGDELAY_3CYCLES ADC_TWOSAMPLINGDELAY_4CYCLES ADC_TWOSAMPLINGDELAY_5CYCLES ADC_TWOSAMPLINGDELAY_6CYCLES ADC_TWOSAMPLINGDELAY_7CYCLES ADC_TWOSAMPLINGDELAY_8CYCLES ADC_TWOSAMPLINGDELAY_9CYCLES ADC_TWOSAMPLINGDELAY_10CYCLES ADC_TWOSAMPLINGDELAY_11CYCLES DOCID026526 Rev 4 99/832 UM1786 ADC_TWOSAMPLINGDELAY_12CYCLES ADC Extended DMA Mode for Dual ADC Mode ADC_DMAACCESSMODE_DISABLED DMA multimode disabled: each ADC will use its own DMA channel ADC_DMAACCESSMODE_12_10_BITS DMA multimode enabled (one DMA channel for both ADC, DMA of ADC master) for 12 and 10 bits resolution ADC_DMAACCESSMODE_8_6_BITS DMA multimode enabled (one DMA channel for both ADC, DMA of ADC master) for 8 and 6 bits resolution ADC Extended End of Regular Sequence/Conversion ADC_EOC_SINGLE_CONV ADC_EOC_SEQ_CONV ADC_EOC_SINGLE_SEQ_CONV reserved for future use ADC Extended Error Code HAL_ADC_ERROR_NONE No error HAL_ADC_ERROR_INTERNAL ADC IP internal error: if problem of clocking, enable/disable, erroneous state HAL_ADC_ERROR_OVR Overrun error HAL_ADC_ERROR_DMA DMA transfer error HAL_ADC_ERROR_JQOVF Injected context queue overflow error ADC Extended Event Type ADC_AWD1_EVENT ADC Analog watchdog 1 event (main analog watchdog, present on all STM32 devices) ADC_AWD2_EVENT ADC Analog watchdog 2 event (additional analog watchdog, not present on all STM32 families) ADC_AWD3_EVENT ADC Analog watchdog 3 event (additional analog watchdog, not present on all STM32 families) ADC_OVR_EVENT ADC overrun event ADC_JQOVF_EVENT ADC Injected Context Queue Overflow event ADC_AWD_EVENT ADCEx Exported Macros __HAL_ADC_ENABLE Description: Enable the ADC peripheral. Parameters: __HANDLE__: ADC handle Return value: None Notes: 100/832 ADC enable requires a delay for ADC DOCID026526 Rev 4 UM1786 stabilization time (refer to device datasheet, parameter tSTAB) On STM32F3 devices, some hardware constraints must be strictly respected before using this macro: ADC internal voltage regulator must be preliminarily enabled. This is performed by function HAL_ADC_Init().ADC state requirements: ADC must be disabled, no conversion on going, no calibration on going. These checks are performed by functions HAL_ADC_start_xxx(). __HAL_ADC_DISABLE Description: Disable the ADC peripheral. Parameters: __HANDLE__: ADC handle Return value: None Notes: __HAL_ADC_ENABLE_IT On STM32F3 devices, some hardware constraints must be strictly respected before using this macro: ADC state requirements: ADC must be enabled, no conversion on going. These checks are performed by functions HAL_ADC_start_xxx(). Description: Enable the ADC end of conversion interrupt. Parameters: __HANDLE__: ADC handle __INTERRUPT__: ADC Interrupt 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 ADC_IT_EOS: ADC End of Regular sequence of Conversions interrupt source ADC_IT_OVR: ADC overrun interrupt source ADC_IT_JEOC: ADC End of Injected Conversion interrupt source ADC_IT_JEOS: ADC End of Injected DOCID026526 Rev 4 101/832 UM1786 sequence of Conversions interrupt source ADC_IT_AWD1: ADC Analog watchdog 1 interrupt source (main analog watchdog, present on all STM32 devices) ADC_IT_AWD2: ADC Analog watchdog 2 interrupt source (additional analog watchdog, present only on STM32F3 devices) ADC_IT_AWD3: ADC Analog watchdog 3 interrupt source (additional analog watchdog, present only on STM32F3 devices) ADC_IT_JQOVF: ADC Injected Context Queue Overflow interrupt source Return value: __HAL_ADC_DISABLE_IT None Description: Disable the ADC end of conversion interrupt. Parameters: 102/832 __HANDLE__: ADC handle __INTERRUPT__: ADC Interrupt 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 ADC_IT_EOS: ADC End of Regular sequence of Conversions interrupt source ADC_IT_OVR: ADC overrun interrupt source ADC_IT_JEOC: ADC End of Injected Conversion interrupt source ADC_IT_JEOS: ADC End of Injected sequence of Conversions interrupt source ADC_IT_AWD1: ADC Analog watchdog 1 interrupt source (main analog watchdog, present on all STM32 devices) ADC_IT_AWD2: ADC Analog watchdog 2 interrupt source (additional analog watchdog, present only on STM32F3 devices) DOCID026526 Rev 4 UM1786 ADC_IT_AWD3: ADC Analog watchdog 3 interrupt source (additional analog watchdog, present only on STM32F3 devices) ADC_IT_JQOVF: ADC Injected Context Queue Overflow interrupt source Return value: __HAL_ADC_GET_IT_SOURCE None Description: Checks if the specified ADC interrupt source is enabled or disabled. Parameters: __HANDLE__: ADC handle __INTERRUPT__: ADC interrupt source to check 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 ADC_IT_EOS: ADC End of Regular sequence of Conversions interrupt source ADC_IT_OVR: ADC overrun interrupt source ADC_IT_JEOC: ADC End of Injected Conversion interrupt source ADC_IT_JEOS: ADC End of Injected sequence of Conversions interrupt source ADC_IT_AWD1: ADC Analog watchdog 1 interrupt source (main analog watchdog, present on all STM32 devices) ADC_IT_AWD2: ADC Analog watchdog 2 interrupt source (additional analog watchdog, present only on STM32F3 devices) ADC_IT_AWD3: ADC Analog watchdog 3 interrupt source (additional analog watchdog, present only on STM32F3 devices) ADC_IT_JQOVF: ADC Injected Context Queue Overflow interrupt source Return value: State: of interruption (SET or RESET) DOCID026526 Rev 4 103/832 UM1786 Description: __HAL_ADC_GET_FLAG Get the selected ADC's flag status. Parameters: __HANDLE__: ADC handle __FLAG__: ADC flag This parameter can be any combination of the following values: ADC_FLAG_RDY: ADC Ready (ADRDY) flag ADC_FLAG_EOSMP: ADC End of Sampling flag ADC_FLAG_EOC: ADC End of Regular Conversion flag ADC_FLAG_EOS: ADC End of Regular sequence of Conversions flag ADC_FLAG_OVR: ADC overrun flag ADC_FLAG_JEOC: ADC End of Injected Conversion flag ADC_FLAG_JEOS: ADC End of Injected sequence of Conversions flag ADC_FLAG_AWD1: ADC Analog watchdog 1 flag (main analog watchdog, present on all STM32 devices) ADC_FLAG_AWD2: ADC Analog watchdog 2 flag (additional analog watchdog, present only on STM32F3 devices) ADC_FLAG_AWD3: ADC Analog watchdog 3 flag (additional analog watchdog, present only on STM32F3 devices) ADC_FLAG_JQOVF: ADC Injected Context Queue Overflow flag Return value: __HAL_ADC_CLEAR_FLAG None Description: Clear the ADC's pending flags. Parameters: 104/832 __HANDLE__: ADC handle __FLAG__: ADC flag This parameter can be any combination of the following values: ADC_FLAG_RDY: ADC Ready (ADRDY) flag ADC_FLAG_EOSMP: ADC End of Sampling flag ADC_FLAG_EOC: ADC End of Regular Conversion flag ADC_FLAG_EOS: ADC End of Regular sequence of Conversions flag ADC_FLAG_OVR: ADC overrun flag DOCID026526 Rev 4 UM1786 ADC_FLAG_JEOC: ADC End of Injected Conversion flag ADC_FLAG_JEOS: ADC End of Injected sequence of Conversions flag ADC_FLAG_AWD1: ADC Analog watchdog 1 flag (main analog watchdog, present on all STM32 devices) ADC_FLAG_AWD2: ADC Analog watchdog 2 flag (additional analog watchdog, present only on STM32F3 devices) ADC_FLAG_AWD3: ADC Analog watchdog 3 flag (additional analog watchdog, present only on STM32F3 devices) ADC_FLAG_JQOVF: ADC Injected Context Queue Overflow flag Return value: __HAL_ADC_RESET_HANDLE_STATE None Description: Reset ADC handle state. Parameters: __HANDLE__: ADC handle Return value: None External Trigger Edge of Injected Group ADC_EXTERNALTRIGINJECCONV_EDGE_NONE ADC_EXTERNALTRIGINJECCONV_EDGE_RISING ADC_EXTERNALTRIGINJECCONV_EDGE_FALLING ADC_EXTERNALTRIGINJECCONV_EDGE_RISINGFALLING ADC Extended External trigger enable and polarity selection for regular group ADC_EXTERNALTRIGCONVEDGE_NONE ADC_EXTERNALTRIGCONVEDGE_RISING ADC_EXTERNALTRIGCONVEDGE_FALLING ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING External Trigger Source of Injected Group ADC_EXTERNALTRIGINJECCONV_T2_CC1 ADC_EXTERNALTRIGINJECCONV_T3_CC1 ADC_EXTERNALTRIGINJECCONV_T3_CC3 ADC_EXTERNALTRIGINJECCONV_T3_CC4 ADC_EXTERNALTRIGINJECCONV_T6_TRGO DOCID026526 Rev 4 105/832 UM1786 ADC_EXTERNALTRIGINJECCONV_EXT_IT15 ADC_EXTERNALTRIGINJECCONV_T1_CC3 ADC_EXTERNALTRIGINJECCONV_T4_CC3 ADC_EXTERNALTRIGINJECCONV_T4_CC4 ADC_EXTERNALTRIGINJECCONV_T7_TRGO ADC_EXTERNALTRIGINJECCONV_T8_CC2 ADC_EXTERNALTRIGINJECCONV_T1_CC4 ADC_EXTERNALTRIGINJECCONV_T1_TRGO ADC_EXTERNALTRIGINJECCONV_T1_TRGO2 ADC_EXTERNALTRIGINJECCONV_T2_TRGO ADC_EXTERNALTRIGINJECCONV_T3_TRGO ADC_EXTERNALTRIGINJECCONV_T4_TRGO ADC_EXTERNALTRIGINJECCONV_T8_CC4 ADC_EXTERNALTRIGINJECCONV_T8_TRGO ADC_EXTERNALTRIGINJECCONV_T8_TRGO2 ADC_EXTERNALTRIGINJECCONV_T15_TRGO ADC_INJECTED_SOFTWARE_START IS_ADC_EXTTRIGINJEC IS_ADC_EXTTRIGINJEC ADC Extended External trigger selection for regular group ADC_EXTERNALTRIGCONV_T1_CC1 < List of external triggers with generic trigger name, independently of ADC_EXTERNALTRIGCONV_T1_CC2 ADC_EXTERNALTRIGCONV_T2_CC2 ADC_EXTERNALTRIGCONV_T3_CC4 ADC_EXTERNALTRIGCONV_T4_CC4 ADC_EXTERNALTRIGCONV_T6_TRGO ADC_EXTERNALTRIGCONV_EXT_IT11 External triggers of regular group for ADC3&ADC4 only ADC_EXTERNALTRIGCONV_T2_CC1 ADC_EXTERNALTRIGCONV_T2_CC3 ADC_EXTERNALTRIGCONV_T3_CC1 ADC_EXTERNALTRIGCONV_T4_CC1 ADC_EXTERNALTRIGCONV_T7_TRGO ADC_EXTERNALTRIGCONV_T8_CC1 ADC_EXTERNALTRIGCONV_EXT_IT2 106/832 External triggers of regular group for ADC1&ADC2, ADC3&ADC4 DOCID026526 Rev 4 UM1786 ADC_EXTERNALTRIGCONV_T1_CC3 ADC_EXTERNALTRIGCONV_T1_TRGO ADC_EXTERNALTRIGCONV_T1_TRGO2 ADC_EXTERNALTRIGCONV_T2_TRGO ADC_EXTERNALTRIGCONV_T3_TRGO ADC_EXTERNALTRIGCONV_T4_TRGO ADC_EXTERNALTRIGCONV_T8_TRGO ADC_EXTERNALTRIGCONV_T8_TRGO2 ADC_EXTERNALTRIGCONV_T15_TRGO ADC_SOFTWARE_START ADC Extended Flags Definition ADC_FLAG_RDY ADC Ready (ADRDY) flag ADC_FLAG_EOSMP ADC End of Sampling flag ADC_FLAG_EOC ADC End of Regular Conversion flag ADC_FLAG_EOS ADC End of Regular sequence of Conversions flag ADC_FLAG_OVR ADC overrun flag ADC_FLAG_JEOC ADC End of Injected Conversion flag ADC_FLAG_JEOS ADC End of Injected sequence of Conversions flag ADC_FLAG_AWD1 ADC Analog watchdog 1 flag (main analog watchdog, present on all STM32 devices) ADC_FLAG_AWD2 ADC Analog watchdog 2 flag (additional analog watchdog, present only on STM32F3 devices) ADC_FLAG_AWD3 ADC Analog watchdog 3 flag (additional analog watchdog, present only on STM32F3 devices) ADC_FLAG_JQOVF ADC Injected Context Queue Overflow flag ADC_FLAG_AWD ADC Extended Injected Channel Rank ADC_INJECTED_RANK_1 ADC_INJECTED_RANK_2 ADC_INJECTED_RANK_3 ADC_INJECTED_RANK_4 ADC Extended Internal HAL driver trigger selection for injected group ADC1_2_EXTERNALTRIGINJEC_T1_TRGO ADC1_2_EXTERNALTRIGINJEC_T1_CC4 ADC1_2_EXTERNALTRIGINJEC_T2_TRGO ADC1_2_EXTERNALTRIGINJEC_T2_CC1 ADC1_2_EXTERNALTRIGINJEC_T3_CC4 DOCID026526 Rev 4 107/832 UM1786 ADC1_2_EXTERNALTRIGINJEC_T4_TRGO ADC1_2_EXTERNALTRIGINJEC_EXT_IT15 ADC1_2_EXTERNALTRIGINJEC_T8_CC4 ADC1_2_EXTERNALTRIGINJEC_T1_TRGO2 ADC1_2_EXTERNALTRIGINJEC_T8_TRGO ADC1_2_EXTERNALTRIGINJEC_T8_TRGO2 ADC1_2_EXTERNALTRIGINJEC_T3_CC3 ADC1_2_EXTERNALTRIGINJEC_T3_TRGO ADC1_2_EXTERNALTRIGINJEC_T3_CC1 ADC1_2_EXTERNALTRIGINJEC_T6_TRGO ADC1_2_EXTERNALTRIGINJEC_T15_TRGO ADC3_4_EXTERNALTRIGINJEC_T1_TRGO ADC3_4_EXTERNALTRIGINJEC_T1_CC4 ADC3_4_EXTERNALTRIGINJEC_T4_CC3 ADC3_4_EXTERNALTRIGINJEC_T8_CC2 ADC3_4_EXTERNALTRIGINJEC_T8_CC4 ADC3_4_EXTERNALTRIGINJEC_T4_CC4 ADC3_4_EXTERNALTRIGINJEC_T4_TRGO ADC3_4_EXTERNALTRIGINJEC_T1_TRGO2 ADC3_4_EXTERNALTRIGINJEC_T8_TRGO ADC3_4_EXTERNALTRIGINJEC_T8_TRGO2 ADC3_4_EXTERNALTRIGINJEC_T1_CC3 ADC3_4_EXTERNALTRIGINJEC_T3_TRGO ADC3_4_EXTERNALTRIGINJEC_T2_TRGO ADC3_4_EXTERNALTRIGINJEC_T7_TRGO ADC3_4_EXTERNALTRIGINJEC_T15_TRGO ADC Extended Internal HAL driver trigger selection for regular group ADC1_2_EXTERNALTRIG_T1_CC1 ADC1_2_EXTERNALTRIG_T1_CC2 ADC1_2_EXTERNALTRIG_T1_CC3 ADC1_2_EXTERNALTRIG_T2_CC2 ADC1_2_EXTERNALTRIG_T3_TRGO ADC1_2_EXTERNALTRIG_T4_CC4 ADC1_2_EXTERNALTRIG_EXT_IT11 ADC1_2_EXTERNALTRIG_T8_TRGO ADC1_2_EXTERNALTRIG_T8_TRGO2 108/832 DOCID026526 Rev 4 UM1786 ADC1_2_EXTERNALTRIG_T1_TRGO ADC1_2_EXTERNALTRIG_T1_TRGO2 ADC1_2_EXTERNALTRIG_T2_TRGO ADC1_2_EXTERNALTRIG_T4_TRGO ADC1_2_EXTERNALTRIG_T6_TRGO ADC1_2_EXTERNALTRIG_T15_TRGO ADC1_2_EXTERNALTRIG_T3_CC4 ADC3_4_EXTERNALTRIG_T3_CC1 ADC3_4_EXTERNALTRIG_T2_CC3 ADC3_4_EXTERNALTRIG_T1_CC3 ADC3_4_EXTERNALTRIG_T8_CC1 ADC3_4_EXTERNALTRIG_T8_TRGO ADC3_4_EXTERNALTRIG_EXT_IT2 ADC3_4_EXTERNALTRIG_T4_CC1 ADC3_4_EXTERNALTRIG_T2_TRGO ADC3_4_EXTERNALTRIG_T8_TRGO2 ADC3_4_EXTERNALTRIG_T1_TRGO ADC3_4_EXTERNALTRIG_T1_TRGO2 ADC3_4_EXTERNALTRIG_T3_TRGO ADC3_4_EXTERNALTRIG_T4_TRGO ADC3_4_EXTERNALTRIG_T7_TRGO ADC3_4_EXTERNALTRIG_T15_TRGO ADC3_4_EXTERNALTRIG_T2_CC1 ADC Extended Interrupts Definition 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 ADC_IT_EOS ADC End of Regular sequence of Conversions interrupt source ADC_IT_OVR ADC overrun interrupt source ADC_IT_JEOC ADC End of Injected Conversion interrupt source ADC_IT_JEOS ADC End of Injected sequence of Conversions interrupt source ADC_IT_AWD1 ADC Analog watchdog 1 interrupt source (main analog watchdog, present on all STM32 devices) ADC_IT_AWD2 ADC Analog watchdog 2 interrupt source (additional analog watchdog, present only on STM32F3 devices) ADC_IT_AWD3 ADC Analog watchdog 3 interrupt source (additional analog watchdog, present only on STM32F3 devices) DOCID026526 Rev 4 109/832 UM1786 ADC_IT_JQOVF ADC Injected Context Queue Overflow interrupt source ADC_IT_AWD ADC Extended Offset Number ADC_OFFSET_NONE ADC_OFFSET_1 ADC_OFFSET_2 ADC_OFFSET_3 ADC_OFFSET_4 ADC Extended overrun ADC_OVR_DATA_OVERWRITTEN Default setting, to be used for compatibility with other STM32 devices ADC_OVR_DATA_PRESERVED ADC Extended Range Verification IS_ADC_RANGE ADC Extended rank into regular group ADC_REGULAR_RANK_1 ADC_REGULAR_RANK_2 ADC_REGULAR_RANK_3 ADC_REGULAR_RANK_4 ADC_REGULAR_RANK_5 ADC_REGULAR_RANK_6 ADC_REGULAR_RANK_7 ADC_REGULAR_RANK_8 ADC_REGULAR_RANK_9 ADC_REGULAR_RANK_10 ADC_REGULAR_RANK_11 ADC_REGULAR_RANK_12 ADC_REGULAR_RANK_13 ADC_REGULAR_RANK_14 ADC_REGULAR_RANK_15 ADC_REGULAR_RANK_16 ADC Extended Resolution ADC_RESOLUTION_12B ADC 12-bit resolution ADC_RESOLUTION_10B ADC 10-bit resolution ADC_RESOLUTION_8B ADC 8-bit resolution ADC_RESOLUTION_6B ADC 6-bit resolution ADC Extended Sampling Times 110/832 DOCID026526 Rev 4 UM1786 ADC_SAMPLETIME_1CYCLE_5 Sampling time 1.5 ADC clock cycle ADC_SAMPLETIME_2CYCLES_5 Sampling time 2.5 ADC clock cycles ADC_SAMPLETIME_4CYCLES_5 Sampling time 4.5 ADC clock cycles ADC_SAMPLETIME_7CYCLES_5 Sampling time 7.5 ADC clock cycles ADC_SAMPLETIME_19CYCLES_5 Sampling time 19.5 ADC clock cycles ADC_SAMPLETIME_61CYCLES_5 Sampling time 61.5 ADC clock cycles ADC_SAMPLETIME_181CYCLES_5 Sampling time 181.5 ADC clock cycles ADC_SAMPLETIME_601CYCLES_5 Sampling time 601.5 ADC clock cycles ADC Extended Scan Mode ADC_SCAN_DISABLE ADC_SCAN_ENABLE ADC Extended Single-ended/Differential input mode ADC_SINGLE_ENDED ADC_DIFFERENTIAL_ENDED DOCID026526 Rev 4 111/832 UM1786 6 HAL CAN Generic Driver 6.1 CAN Firmware driver registers structures 6.1.1 CAN_InitTypeDef Data Fields uint32_t Prescaler uint32_t Mode uint32_t SJW uint32_t BS1 uint32_t BS2 uint32_t TTCM uint32_t ABOM uint32_t AWUM uint32_t NART uint32_t RFLM uint32_t TXFP Field Documentation 112/832 uint32_t CAN_InitTypeDef::Prescaler Specifies the length of a time quantum. This parameter must be a number between Min_Data = 1 and Max_Data = 1024. uint32_t CAN_InitTypeDef::Mode Specifies the CAN operating mode. This parameter can be a value of CAN_operating_mode uint32_t CAN_InitTypeDef::SJW Specifies the maximum number of time quanta the CAN hardware is allowed to lengthen or shorten a bit to perform resynchronization. This parameter can be a value of CAN_synchronisation_jump_width uint32_t CAN_InitTypeDef::BS1 Specifies the number of time quanta in Bit Segment 1. This parameter can be a value of CAN_time_quantum_in_bit_segment_1 uint32_t CAN_InitTypeDef::BS2 Specifies the number of time quanta in Bit Segment 2. This parameter can be a value of CAN_time_quantum_in_bit_segment_2 uint32_t CAN_InitTypeDef::TTCM Enable or disable the time triggered communication mode. This parameter can be set to ENABLE or DISABLE. uint32_t CAN_InitTypeDef::ABOM Enable or disable the automatic bus-off management. This parameter can be set to ENABLE or DISABLE. uint32_t CAN_InitTypeDef::AWUM Enable or disable the automatic wake-up mode. This parameter can be set to ENABLE or DISABLE. uint32_t CAN_InitTypeDef::NART Enable or disable the non-automatic retransmission mode. This parameter can be set to ENABLE or DISABLE. DOCID026526 Rev 4 UM1786 6.1.2 uint32_t CAN_InitTypeDef::RFLM Enable or disable the Receive FIFO Locked mode. This parameter can be set to ENABLE or DISABLE. uint32_t CAN_InitTypeDef::TXFP Enable or disable the transmit FIFO priority. This parameter can be set to ENABLE or DISABLE. CAN_FilterConfTypeDef Data Fields uint32_t FilterIdHigh uint32_t FilterIdLow uint32_t FilterMaskIdHigh uint32_t FilterMaskIdLow uint32_t FilterFIFOAssignment uint32_t FilterNumber uint32_t FilterMode uint32_t FilterScale uint32_t FilterActivation uint32_t BankNumber Field Documentation uint32_t CAN_FilterConfTypeDef::FilterIdHigh Specifies the filter identification number (MSBs for a 32-bit configuration, first one for a 16-bit configuration). This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. uint32_t CAN_FilterConfTypeDef::FilterIdLow Specifies the filter identification number (LSBs for a 32-bit configuration, second one for a 16-bit configuration). This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. uint32_t CAN_FilterConfTypeDef::FilterMaskIdHigh Specifies the filter mask number or identification number, according to the mode (MSBs for a 32-bit configuration, first one for a 16-bit configuration). This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. uint32_t CAN_FilterConfTypeDef::FilterMaskIdLow Specifies the filter mask number or identification number, according to the mode (LSBs for a 32-bit configuration, second one for a 16-bit configuration). This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. uint32_t CAN_FilterConfTypeDef::FilterFIFOAssignment Specifies the FIFO (0 or 1) which will be assigned to the filter. This parameter can be a value of CAN_filter_FIFO uint32_t CAN_FilterConfTypeDef::FilterNumber Specifies the filter which will be initialized. This parameter must be a number between Min_Data = 0 and Max_Data = 27. uint32_t CAN_FilterConfTypeDef::FilterMode Specifies the filter mode to be initialized. This parameter can be a value of CAN_filter_mode uint32_t CAN_FilterConfTypeDef::FilterScale Specifies the filter scale. This parameter can be a value of CAN_filter_scale DOCID026526 Rev 4 113/832 UM1786 6.1.3 uint32_t CAN_FilterConfTypeDef::FilterActivation Enable or disable the filter. This parameter can be set to ENABLE or DISABLE. uint32_t CAN_FilterConfTypeDef::BankNumber Select the start slave bank filter F3 devices don't support CAN2 interface (Slave). Therefore this parameter is meaningless but it has been kept for compatibility accross STM32 families CanTxMsgTypeDef Data Fields uint32_t StdId uint32_t ExtId uint32_t IDE uint32_t RTR uint32_t DLC uint8_t Data Field Documentation 6.1.4 uint32_t CanTxMsgTypeDef::StdId Specifies the standard identifier. This parameter must be a number between Min_Data = 0 and Max_Data = 0x7FF. uint32_t CanTxMsgTypeDef::ExtId Specifies the extended identifier. This parameter must be a number between Min_Data = 0 and Max_Data = 0x1FFFFFFF. uint32_t CanTxMsgTypeDef::IDE Specifies the type of identifier for the message that will be transmitted. This parameter can be a value of CAN_identifier_type uint32_t CanTxMsgTypeDef::RTR Specifies the type of frame for the message that will be transmitted. This parameter can be a value of CAN_remote_transmission_request uint32_t CanTxMsgTypeDef::DLC Specifies the length of the frame that will be transmitted. This parameter must be a number between Min_Data = 0 and Max_Data = 8. uint8_t CanTxMsgTypeDef::Data[8] Contains the data to be transmitted. This parameter must be a number between Min_Data = 0 and Max_Data = 0xFF. CanRxMsgTypeDef Data Fields 114/832 uint32_t StdId uint32_t ExtId uint32_t IDE uint32_t RTR uint32_t DLC uint8_t Data DOCID026526 Rev 4 UM1786 uint32_t FMI uint32_t FIFONumber Field Documentation 6.1.5 uint32_t CanRxMsgTypeDef::StdId Specifies the standard identifier. This parameter must be a number between Min_Data = 0 and Max_Data = 0x7FF. uint32_t CanRxMsgTypeDef::ExtId Specifies the extended identifier. This parameter must be a number between Min_Data = 0 and Max_Data = 0x1FFFFFFF. uint32_t CanRxMsgTypeDef::IDE Specifies the type of identifier for the message that will be received. This parameter can be a value of CAN_identifier_type uint32_t CanRxMsgTypeDef::RTR Specifies the type of frame for the received message. This parameter can be a value of CAN_remote_transmission_request uint32_t CanRxMsgTypeDef::DLC Specifies the length of the frame that will be received. This parameter must be a number between Min_Data = 0 and Max_Data = 8. uint8_t CanRxMsgTypeDef::Data[8] Contains the data to be received. This parameter must be a number between Min_Data = 0 and Max_Data = 0xFF. uint32_t CanRxMsgTypeDef::FMI Specifies the index of the filter the message stored in the mailbox passes through. This parameter must be a number between Min_Data = 0 and Max_Data = 0xFF. uint32_t CanRxMsgTypeDef::FIFONumber Specifies the receive FIFO number. This parameter can be CAN_FIFO0 or CAN_FIFO1 CAN_HandleTypeDef Data Fields CAN_TypeDef * Instance CAN_InitTypeDef Init CanTxMsgTypeDef * pTxMsg CanRxMsgTypeDef * pRxMsg HAL_LockTypeDef Lock __IO HAL_CAN_StateTypeDef State __IO uint32_t ErrorCode Field Documentation CAN_TypeDef* CAN_HandleTypeDef::Instance Register base address CAN_InitTypeDef CAN_HandleTypeDef::Init CAN required parameters CanTxMsgTypeDef* CAN_HandleTypeDef::pTxMsg Pointer to transmit structure DOCID026526 Rev 4 115/832 UM1786 CanRxMsgTypeDef* CAN_HandleTypeDef::pRxMsg Pointer to reception structure HAL_LockTypeDef CAN_HandleTypeDef::Lock CAN locking object __IO HAL_CAN_StateTypeDef CAN_HandleTypeDef::State CAN communication state __IO uint32_t CAN_HandleTypeDef::ErrorCode CAN Error code This parameter can be a value of HAL_CAN_Error_Code 6.2 CAN Firmware driver API description 6.2.1 How to use this driver 1. 2. 3. 4. 5. Enable the CAN controller interface clock using __HAL_RCC_CAN1_CLK_ENABLE(); CAN pins configuration Enable the clock for the CAN GPIOs using the following function: __HAL_RCC_GPIOx_CLK_ENABLE(); Connect and configure the involved CAN pins to AF9 using the following function HAL_GPIO_Init(); Initialise and configure the CAN using HAL_CAN_Init() function. Transmit the desired CAN frame using HAL_CAN_Transmit() function. Receive a CAN frame using HAL_CAN_Receive() function. Polling mode IO operation Start the CAN peripheral transmission and wait the end of this operation using HAL_CAN_Transmit(), at this stage user can specify the value of timeout according to his end application Start the CAN peripheral reception and wait the end of this operation using HAL_CAN_Receive(), at this stage user can specify the value of timeout according to his end application Interrupt mode IO operation Start the CAN peripheral transmission using HAL_CAN_Transmit_IT() Start the CAN peripheral reception using HAL_CAN_Receive_IT() Use HAL_CAN_IRQHandler() called under the used CAN Interrupt subroutine At CAN end of transmission HAL_CAN_TxCpltCallback() function is executed and user can add his own code by customization of function pointer HAL_CAN_TxCpltCallback In case of CAN Error, HAL_CAN_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_CAN_ErrorCallback CAN HAL driver macros list Below the list of most used macros in CAN HAL driver. 116/832 __HAL_CAN_ENABLE_IT: Enable the specified CAN interrupts __HAL_CAN_DISABLE_IT: Disable the specified CAN interrupts DOCID026526 Rev 4 UM1786 __HAL_CAN_GET_IT_SOURCE: Check if the specified CAN interrupt source is enabled or disabled __HAL_CAN_CLEAR_FLAG: Clear the CAN's pending flags __HAL_CAN_GET_FLAG: Get the selected CAN's flag status You can refer to the CAN HAL driver header file for more useful macros 6.2.2 Initialization and de-initialization functions This section provides functions allowing to: Initialize and configure the CAN. De-initialize the CAN. This section contains the following APIs: 6.2.3 HAL_CAN_Init() HAL_CAN_ConfigFilter() HAL_CAN_DeInit() HAL_CAN_MspInit() HAL_CAN_MspDeInit() Peripheral State and Error functions This subsection provides functions allowing to : Check the CAN state. Check CAN Errors detected during interrupt process This section contains the following APIs: 6.2.4 HAL_CAN_GetState() HAL_CAN_GetError() Detailed description of functions HAL_CAN_Init Function Name HAL_StatusTypeDef HAL_CAN_Init (CAN_HandleTypeDef * hcan) Function Description Initializes the CAN peripheral according to the specified parameters in the CAN_InitStruct. Parameters hcan: pointer to a CAN_HandleTypeDef structure that contains the configuration information for the specified CAN. Return values HAL: status HAL_CAN_ConfigFilter Function Name HAL_StatusTypeDef HAL_CAN_ConfigFilter (CAN_HandleTypeDef * hcan, CAN_FilterConfTypeDef * sFilterConfig) Function Description Configures the CAN reception filter according to the specified DOCID026526 Rev 4 117/832 UM1786 parameters in the CAN_FilterInitStruct. Parameters Return values hcan: pointer to a CAN_HandleTypeDef structure that contains the configuration information for the specified CAN. sFilterConfig: pointer to a CAN_FilterConfTypeDef structure that contains the filter configuration information. None: HAL_CAN_DeInit Function Name HAL_StatusTypeDef HAL_CAN_DeInit (CAN_HandleTypeDef * hcan) Function Description Deinitializes the CANx peripheral registers to their default reset values. Parameters hcan: pointer to a CAN_HandleTypeDef structure that contains the configuration information for the specified CAN. Return values HAL: status HAL_CAN_MspInit Function Name void HAL_CAN_MspInit (CAN_HandleTypeDef * hcan) Function Description Initializes the CAN MSP. Parameters hcan: pointer to a CAN_HandleTypeDef structure that contains the configuration information for the specified CAN. Return values None: HAL_CAN_MspDeInit Function Name void HAL_CAN_MspDeInit (CAN_HandleTypeDef * hcan) Function Description DeInitializes the CAN MSP. Parameters hcan: pointer to a CAN_HandleTypeDef structure that contains the configuration information for the specified CAN. Return values None: HAL_CAN_Transmit Function Name HAL_StatusTypeDef HAL_CAN_Transmit (CAN_HandleTypeDef * hcan, uint32_t Timeout) Function Description Initiates and transmits a CAN frame message. Parameters Return values hcan: pointer to a CAN_HandleTypeDef structure that contains the configuration information for the specified CAN. Timeout: Timeout duration. HAL: status HAL_CAN_Transmit_IT Function Name 118/832 HAL_StatusTypeDef HAL_CAN_Transmit_IT DOCID026526 Rev 4 UM1786 (CAN_HandleTypeDef * hcan) Function Description Initiates and transmits a CAN frame message. Parameters hcan: pointer to a CAN_HandleTypeDef structure that contains the configuration information for the specified CAN. Return values HAL: status HAL_CAN_Receive Function Name HAL_StatusTypeDef HAL_CAN_Receive (CAN_HandleTypeDef * hcan, uint8_t FIFONumber, uint32_t Timeout) Function Description Receives a correct CAN frame. Parameters Return values hcan: pointer to a CAN_HandleTypeDef structure that contains the configuration information for the specified CAN. FIFONumber: FIFO number. Timeout: Timeout duration. HAL: status None: HAL_CAN_Receive_IT Function Name HAL_StatusTypeDef HAL_CAN_Receive_IT (CAN_HandleTypeDef * hcan, uint8_t FIFONumber) Function Description Receives a correct CAN frame. Parameters Return values hcan: pointer to a CAN_HandleTypeDef structure that contains the configuration information for the specified CAN. FIFONumber: FIFO number. HAL: status None: HAL_CAN_Sleep Function Name HAL_StatusTypeDef HAL_CAN_Sleep (CAN_HandleTypeDef * hcan) Function Description Enters the Sleep (low power) mode. Parameters hcan: pointer to a CAN_HandleTypeDef structure that contains the configuration information for the specified CAN. Return values HAL: status. HAL_CAN_WakeUp Function Name HAL_StatusTypeDef HAL_CAN_WakeUp (CAN_HandleTypeDef * hcan) Function Description Wakes up the CAN peripheral from sleep mode, after that the CAN peripheral is in the normal mode. Parameters hcan: pointer to a CAN_HandleTypeDef structure that contains the configuration information for the specified CAN. DOCID026526 Rev 4 119/832 UM1786 Return values HAL: status. HAL_CAN_IRQHandler Function Name void HAL_CAN_IRQHandler (CAN_HandleTypeDef * hcan) Function Description Handles CAN interrupt request. Parameters hcan: pointer to a CAN_HandleTypeDef structure that contains the configuration information for the specified CAN. Return values None: HAL_CAN_TxCpltCallback Function Name void HAL_CAN_TxCpltCallback (CAN_HandleTypeDef * hcan) Function Description Transmission complete callback in non blocking mode. Parameters hcan: pointer to a CAN_HandleTypeDef structure that contains the configuration information for the specified CAN. Return values None: HAL_CAN_RxCpltCallback Function Name void HAL_CAN_RxCpltCallback (CAN_HandleTypeDef * hcan) Function Description Transmission complete callback in non blocking mode. Parameters hcan: pointer to a CAN_HandleTypeDef structure that contains the configuration information for the specified CAN. Return values None: HAL_CAN_ErrorCallback Function Name void HAL_CAN_ErrorCallback (CAN_HandleTypeDef * hcan) Function Description Error CAN callback. Parameters hcan: pointer to a CAN_HandleTypeDef structure that contains the configuration information for the specified CAN. Return values None: HAL_CAN_GetError Function Name uint32_t HAL_CAN_GetError (CAN_HandleTypeDef * hcan) Function Description Return the CAN error code. Parameters hcan: pointer to a CAN_HandleTypeDef structure that contains the configuration information for the specified CAN. Return values CAN: Error Code HAL_CAN_GetState Function Name 120/832 HAL_CAN_StateTypeDef HAL_CAN_GetState DOCID026526 Rev 4 UM1786 (CAN_HandleTypeDef * hcan) Function Description return the CAN state Parameters hcan: pointer to a CAN_HandleTypeDef structure that contains the configuration information for the specified CAN. Return values HAL: state 6.3 CAN Firmware driver defines 6.3.1 CAN CAN Exported Macros __HAL_CAN_RESET_HANDLE_STATE Description: Reset CAN handle state. Parameters: __HANDLE__: CAN handle. Return value: None Description: __HAL_CAN_ENABLE_IT Enable the specified CAN interrupts. Parameters: __HANDLE__: CAN handle. __INTERRUPT__: CAN Interrupt Return value: None Description: __HAL_CAN_DISABLE_IT Disable the specified CAN interrupts. Parameters: __HANDLE__: CAN handle. __INTERRUPT__: CAN Interrupt Return value: __HAL_CAN_MSG_PENDING None Description: Return the number of pending received messages. Parameters: __HANDLE__: CAN handle. __FIFONUMBER__: Receive FIFO number, CAN_FIFO0 or CAN_FIFO1. Return value: DOCID026526 Rev 4 121/832 UM1786 The: number of pending message. Description: __HAL_CAN_GET_FLAG Check whether the specified CAN flag is set or not. Parameters: __HANDLE__: specifies the CAN Handle. __FLAG__: specifies the flag to check. This parameter can be one of the following values: CAN_TSR_RQCP0: Request MailBox0 Flag CAN_TSR_RQCP1: Request MailBox1 Flag CAN_TSR_RQCP2: Request MailBox2 Flag CAN_FLAG_TXOK0: Transmission OK MailBox0 Flag CAN_FLAG_TXOK1: Transmission OK MailBox1 Flag CAN_FLAG_TXOK2: Transmission OK MailBox2 Flag CAN_FLAG_TME0: Transmit mailbox 0 empty Flag CAN_FLAG_TME1: Transmit mailbox 1 empty Flag CAN_FLAG_TME2: Transmit mailbox 2 empty Flag CAN_FLAG_FMP0: FIFO 0 Message Pending Flag CAN_FLAG_FF0: FIFO 0 Full Flag CAN_FLAG_FOV0: FIFO 0 Overrun Flag CAN_FLAG_FMP1: FIFO 1 Message Pending Flag CAN_FLAG_FF1: FIFO 1 Full Flag CAN_FLAG_FOV1: FIFO 1 Overrun Flag CAN_FLAG_WKU: Wake up Flag CAN_FLAG_SLAK: Sleep acknowledge Flag CAN_FLAG_SLAKI: Sleep acknowledge Flag CAN_FLAG_EWG: Error Warning Flag CAN_FLAG_EPV: Error Passive Flag CAN_FLAG_BOF: Bus-Off Flag Return value: __HAL_CAN_CLEAR_FLAG 122/832 The: new state of __FLAG__ (TRUE or FALSE). Description: DOCID026526 Rev 4 UM1786 Clear the specified CAN pending flag. Parameters: __HANDLE__: specifies the CAN Handle. __FLAG__: specifies the flag to check. This parameter can be one of the following values: CAN_TSR_RQCP0: Request MailBox0 Flag CAN_TSR_RQCP1: Request MailBox1 Flag CAN_TSR_RQCP2: Request MailBox2 Flag CAN_FLAG_TXOK0: Transmission OK MailBox0 Flag CAN_FLAG_TXOK1: Transmission OK MailBox1 Flag CAN_FLAG_TXOK2: Transmission OK MailBox2 Flag CAN_FLAG_TME0: Transmit mailbox 0 empty Flag CAN_FLAG_TME1: Transmit mailbox 1 empty Flag CAN_FLAG_TME2: Transmit mailbox 2 empty Flag CAN_FLAG_FMP0: FIFO 0 Message Pending Flag CAN_FLAG_FF0: FIFO 0 Full Flag CAN_FLAG_FOV0: FIFO 0 Overrun Flag CAN_FLAG_FMP1: FIFO 1 Message Pending Flag CAN_FLAG_FF1: FIFO 1 Full Flag CAN_FLAG_FOV1: FIFO 1 Overrun Flag CAN_FLAG_WKU: Wake up Flag CAN_FLAG_SLAKI: Sleep acknowledge Flag CAN_FLAG_EWG: Error Warning Flag CAN_FLAG_EPV: Error Passive Flag CAN_FLAG_BOF: Bus-Off Flag Return value: __HAL_CAN_GET_IT_SOURCE The: new state of __FLAG__ (TRUE or FALSE). Description: Check if the specified CAN interrupt source is enabled or disabled. Parameters: __HANDLE__: specifies the CAN Handle. __INTERRUPT__: specifies the CAN DOCID026526 Rev 4 123/832 UM1786 interrupt source to check. This parameter can be one of the following values: CAN_IT_TME: Transmit mailbox empty interrupt enable CAN_IT_FMP0: FIFO0 message pending interrupt enablev CAN_IT_FMP1: FIFO1 message pending interrupt enable Return value: __HAL_CAN_TRANSMIT_STATUS The: new state of __IT__ (TRUE or FALSE). Description: Check the transmission status of a CAN Frame. Parameters: __HANDLE__: CAN handle. __TRANSMITMAILBOX__: the number of the mailbox that is used for transmission. Return value: __HAL_CAN_FIFO_RELEASE The: new status of transmission (TRUE or FALSE). Description: Release the specified receive FIFO. Parameters: __HANDLE__: CAN handle. __FIFONUMBER__: Receive FIFO number, CAN_FIFO0 or CAN_FIFO1. Return value: __HAL_CAN_CANCEL_TRANSMIT None Description: Cancel a transmit request. Parameters: __HANDLE__: specifies the CAN Handle. __TRANSMITMAILBOX__: the number of the mailbox that is used for transmission. Return value: __HAL_CAN_DBG_FREEZE None Description: Enable or disables the DBG Freeze for CAN. Parameters: 124/832 __HANDLE__: specifies the CAN Handle. DOCID026526 Rev 4 UM1786 __NEWSTATE__: new state of the CAN peripheral. This parameter can be: ENABLE (CAN reception/transmission is frozen during debug. Reception FIFOs can still be accessed/controlled normally) or DISABLE (CAN is working during debug). Return value: None CAN Filter FIFO CAN_FILTER_FIFO0 Filter FIFO 0 assignment for filter x CAN_FILTER_FIFO1 Filter FIFO 1 assignment for filter x CAN Filter Mode CAN_FILTERMODE_IDMASK Identifier mask mode CAN_FILTERMODE_IDLIST Identifier list mode CAN Filter Scale CAN_FILTERSCALE_16BIT Two 16-bit filters CAN_FILTERSCALE_32BIT One 32-bit filter CAN Flags CAN_FLAG_RQCP0 Request MailBox0 flag CAN_FLAG_RQCP1 Request MailBox1 flag CAN_FLAG_RQCP2 Request MailBox2 flag CAN_FLAG_TXOK0 Transmission OK MailBox0 flag CAN_FLAG_TXOK1 Transmission OK MailBox1 flag CAN_FLAG_TXOK2 Transmission OK MailBox2 flag CAN_FLAG_TME0 Transmit mailbox 0 empty flag CAN_FLAG_TME1 Transmit mailbox 0 empty flag CAN_FLAG_TME2 Transmit mailbox 0 empty flag CAN_FLAG_FF0 FIFO 0 Full flag CAN_FLAG_FOV0 FIFO 0 Overrun flag CAN_FLAG_FF1 FIFO 1 Full flag CAN_FLAG_FOV1 FIFO 1 Overrun flag CAN_FLAG_WKU Wake up flag CAN_FLAG_SLAK Sleep acknowledge flag CAN_FLAG_SLAKI Sleep acknowledge flag CAN_FLAG_EWG Error warning flag CAN_FLAG_EPV Error passive flag CAN_FLAG_BOF Bus-Off flag CAN Identifier Type DOCID026526 Rev 4 125/832 UM1786 CAN_ID_STD Standard Id CAN_ID_EXT Extended Id CAN InitStatus CAN_INITSTATUS_FAILED CAN initialization failed CAN_INITSTATUS_SUCCESS CAN initialization OK CAN Interrupts CAN_IT_TME Transmit mailbox empty interrupt CAN_IT_FMP0 FIFO 0 message pending interrupt CAN_IT_FF0 FIFO 0 full interrupt CAN_IT_FOV0 FIFO 0 overrun interrupt CAN_IT_FMP1 FIFO 1 message pending interrupt CAN_IT_FF1 FIFO 1 full interrupt CAN_IT_FOV1 FIFO 1 overrun interrupt CAN_IT_WKU Wake-up interrupt 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 CAN Mailboxes CAN_TXMAILBOX_0 CAN_TXMAILBOX_1 CAN_TXMAILBOX_2 CAN Operating Mode CAN_MODE_NORMAL Normal mode CAN_MODE_LOOPBACK Loopback mode CAN_MODE_SILENT Silent mode CAN_MODE_SILENT_LOOPBACK Loopback combined with silent mode CAN Receive FIFO Number CAN_FIFO0 CAN FIFO 0 used to receive CAN_FIFO1 CAN FIFO 1 used to receive CAN Remote Transmission Request CAN_RTR_DATA Data frame CAN_RTR_REMOTE Remote frame CAN Synchronization Jump Width 126/832 DOCID026526 Rev 4 UM1786 CAN_SJW_1TQ 1 time quantum CAN_SJW_2TQ 2 time quantum CAN_SJW_3TQ 3 time quantum CAN_SJW_4TQ 4 time quantum CAN Time Quantum in Bit Segment 1 CAN_BS1_1TQ 1 time quantum CAN_BS1_2TQ 2 time quantum CAN_BS1_3TQ 3 time quantum CAN_BS1_4TQ 4 time quantum CAN_BS1_5TQ 5 time quantum CAN_BS1_6TQ 6 time quantum CAN_BS1_7TQ 7 time quantum CAN_BS1_8TQ 8 time quantum CAN_BS1_9TQ 9 time quantum CAN_BS1_10TQ 10 time quantum CAN_BS1_11TQ 11 time quantum CAN_BS1_12TQ 12 time quantum CAN_BS1_13TQ 13 time quantum CAN_BS1_14TQ 14 time quantum CAN_BS1_15TQ 15 time quantum CAN_BS1_16TQ 16 time quantum CAN Time Quantum in Bit Segment 2 CAN_BS2_1TQ 1 time quantum CAN_BS2_2TQ 2 time quantum CAN_BS2_3TQ 3 time quantum CAN_BS2_4TQ 4 time quantum CAN_BS2_5TQ 5 time quantum CAN_BS2_6TQ 6 time quantum CAN_BS2_7TQ 7 time quantum CAN_BS2_8TQ 8 time quantum DOCID026526 Rev 4 127/832 UM1786 7 HAL CEC Generic Driver 7.1 CEC Firmware driver registers structures 7.1.1 CEC_InitTypeDef Data Fields uint32_t SignalFreeTime uint32_t Tolerance uint32_t BRERxStop uint32_t BREErrorBitGen uint32_t LBPEErrorBitGen uint32_t BroadcastMsgNoErrorBitGen uint32_t SignalFreeTimeOption uint32_t OwnAddress uint32_t ListenMode uint8_t InitiatorAddress Field Documentation 128/832 uint32_t CEC_InitTypeDef::SignalFreeTime Set SFT field, specifies the Signal Free Time. It can be one of CEC_Signal_Free_Time and belongs to the set {0,...,7} where 0x0 is the default configuration else means 0.5 + (SignalFreeTime - 1) nominal data bit periods uint32_t CEC_InitTypeDef::Tolerance Set RXTOL bit, specifies the tolerance accepted on the received waveforms, it can be a value of CEC_Tolerance : CEC_STANDARD_TOLERANCE CEC_EXTENDED_TOLERANCE uint32_t CEC_InitTypeDef::BRERxStop Set BRESTP bit CEC_BRERxStop : specifies whether or not a Bit Rising Error stops the reception. CEC_NO_RX_STOP_ON_BRE: reception is not stopped. CEC_RX_STOP_ON_BRE: reception is stopped. uint32_t CEC_InitTypeDef::BREErrorBitGen Set BREGEN bit CEC_BREErrorBitGen : specifies whether or not an Error-Bit is generated on the CEC line upon Bit Rising Error detection. CEC_BRE_ERRORBIT_NO_GENERATION: no error-bit generation. CEC_BRE_ERRORBIT_GENERATION: error-bit generation if BRESTP is set. uint32_t CEC_InitTypeDef::LBPEErrorBitGen Set LBPEGEN bit CEC_LBPEErrorBitGen : specifies whether or not an Error-Bit is generated on the CEC line upon Long Bit Period Error detection. CEC_LBPE_ERRORBIT_NO_GENERATION: no error-bit generation. CEC_LBPE_ERRORBIT_GENERATION: error-bit generation. uint32_t CEC_InitTypeDef::BroadcastMsgNoErrorBitGen Set BRDNOGEN bit CEC_BroadCastMsgErrorBitGen : allows to avoid an Error-Bit generation on the CEC line upon an error detected on a broadcast message.It supersedes BREGEN and LBPEGEN bits for a broadcast message error handling. It can take two values:1) CEC_BROADCASTERROR_ERRORBIT_GENERATION. __ a) BRE detection: error-bit generation on the CEC line if BRESTP=CEC_RX_STOP_ON_BRE and DOCID026526 Rev 4 UM1786 7.1.2 BREGEN=CEC_BRE_ERRORBIT_NO_GENERATION. __ b) LBPE detection: errorbit generation on the CEC line if LBPGEN=CEC_LBPE_ERRORBIT_NO_GENERATION.2) CEC_BROADCASTERROR_NO_ERRORBIT_GENERATION. no error-bit generation in case neither a) nor b) are satisfied. Additionally, there is no error-bit generation in case of Short Bit Period Error detection in a broadcast message while LSTN bit is set. uint32_t CEC_InitTypeDef::SignalFreeTimeOption Set SFTOP bit CEC_SFT_Option : specifies when SFT timer starts. CEC_SFT_START_ON_TXSOM SFT: timer starts when TXSOM is set by software. CEC_SFT_START_ON_TX_RX_END: SFT timer starts automatically at the end of message transmission/reception. uint32_t CEC_InitTypeDef::OwnAddress Set OAR field, specifies CEC device address within a 15-bit long field uint32_t CEC_InitTypeDef::ListenMode Set LSTN bit CEC_Listening_Mode : specifies device listening mode. It can take two values:CEC_REDUCED_LISTENING_MODE: CEC peripheral receives only message addressed to its own address (OAR). Messages addressed to different destination are ignored. Broadcast messages are always received.CEC_FULL_LISTENING_MODE: CEC peripheral receives messages addressed to its own address (OAR) with positive acknowledge. Messages addressed to different destination are received, but without interfering with the CEC bus: no acknowledge sent. uint8_t CEC_InitTypeDef::InitiatorAddress CEC_HandleTypeDef Data Fields CEC_TypeDef * Instance CEC_InitTypeDef Init uint8_t * pTxBuffPtr uint16_t TxXferCount uint8_t * pRxBuffPtr uint16_t RxXferSize uint32_t ErrorCode HAL_LockTypeDef Lock HAL_CEC_StateTypeDef State Field Documentation CEC_TypeDef* CEC_HandleTypeDef::Instance CEC registers base address CEC_InitTypeDef CEC_HandleTypeDef::Init CEC communication parameters uint8_t* CEC_HandleTypeDef::pTxBuffPtr Pointer to CEC Tx transfer Buffer uint16_t CEC_HandleTypeDef::TxXferCount CEC Tx Transfer Counter uint8_t* CEC_HandleTypeDef::pRxBuffPtr Pointer to CEC Rx transfer Buffer uint16_t CEC_HandleTypeDef::RxXferSize CEC Rx Transfer size, 0: header received only DOCID026526 Rev 4 129/832 UM1786 uint32_t CEC_HandleTypeDef::ErrorCode For errors handling purposes, copy of ISR register in case error is reported HAL_LockTypeDef CEC_HandleTypeDef::Lock Locking object HAL_CEC_StateTypeDef CEC_HandleTypeDef::State CEC communication state 7.2 CEC Firmware driver API description 7.2.1 How to use this driver The CEC HAL driver can be used as follows: 1. 2. 3. 4. 7.2.2 Declare a CEC_HandleTypeDef handle structure. Initialize the CEC low level resources by implementing the HAL_CEC_MspInit ()API: Enable the CEC interface clock. CEC pins configuration: Enable the clock for the CEC GPIOs. Configure these CEC pins as alternate function pull-up. NVIC configuration if you need to use interrupt process (HAL_CEC_Transmit_IT() and HAL_CEC_Receive_IT() APIs): Configure the CEC interrupt priority. Enable the NVIC CEC IRQ handle. Program the Signal Free Time (SFT) and SFT option, Tolerance, reception stop in in case of Bit Rising Error, Error-Bit generation conditions, device logical address and Listen mode in the hcec Init structure. Initialize the CEC registers by calling the HAL_CEC_Init() API. This API configures also the low level Hardware GPIO, CLOCK, CORTEX...etc) by calling the customed HAL_CEC_MspInit() API. The specific CEC interrupts (Transmission complete interrupt, RXNE interrupt and Error Interrupts) will be managed using the macros __HAL_CEC_ENABLE_IT() and __HAL_CEC_DISABLE_IT() inside the transmit and receive process. Initialization and Configuration functions This subsection provides a set of functions allowing to initialize the CEC The following parameters need to be configured: SignalFreeTime Tolerance BRERxStop (RX stopped or not upon Bit Rising Error) BREErrorBitGen (Error-Bit generation in case of Bit Rising Error) LBPEErrorBitGen (Error-Bit generation in case of Long Bit Period Error) BroadcastMsgNoErrorBitGen (Error-bit generation in case of broadcast message error) SignalFreeTimeOption (SFT Timer start definition) OwnAddress (CEC device address) ListenMode This section contains the following APIs: 130/832 HAL_CEC_Init() HAL_CEC_DeInit() HAL_CEC_MspInit() HAL_CEC_MspDeInit() DOCID026526 Rev 4 UM1786 7.2.3 IO operation function This subsection provides a set of functions allowing to manage the CEC data transfers. The CEC handle must contain the initiator (TX side) and the destination (RX side) logical addresses (4-bit long addresses, 0xF for broadcast messages destination) There are two mode of transfer: Blocking mode: The communication is performed in polling mode. The HAL status of all data processing is returned by the same function after finishing transfer. Non Blocking mode: The communication is performed using Interrupts. These API's return the HAL status. The end of the data processing will be indicated through the dedicated CEC IRQ when using Interrupt mode. The HAL_CEC_TxCpltCallback(), HAL_CEC_RxCpltCallback() user callbacks will be executed respectivelly at the end of the transmit or Receive process The HAL_CEC_ErrorCallback()user callback will be executed when a communication error is detected Blocking mode API's are : HAL_CEC_Transmit() HAL_CEC_Receive() Non-Blocking mode API's with Interrupt are : HAL_CEC_Transmit_IT() HAL_CEC_Receive_IT() HAL_CEC_IRQHandler() A set of Transfer Complete Callbacks are provided in No_Blocking mode: HAL_CEC_TxCpltCallback() HAL_CEC_RxCpltCallback() HAL_CEC_ErrorCallback() This section contains the following APIs: 7.2.4 HAL_CEC_Transmit() HAL_CEC_Receive() HAL_CEC_Transmit_IT() HAL_CEC_Receive_IT() HAL_CEC_GetReceivedFrameSize() HAL_CEC_IRQHandler() HAL_CEC_TxCpltCallback() HAL_CEC_RxCpltCallback() HAL_CEC_ErrorCallback() Peripheral Control functions This subsection provides a set of functions allowing to control the CEC. HAL_CEC_GetState() API can be helpful to check in run-time the state of the CEC peripheral. HAL_CEC_GetError() API report the CEC handle error code. This section contains the following APIs: HAL_CEC_GetState() HAL_CEC_GetError() DOCID026526 Rev 4 131/832 UM1786 7.2.5 Detailed description of functions HAL_CEC_Init Function Name HAL_StatusTypeDef HAL_CEC_Init (CEC_HandleTypeDef * hcec) Function Description Initialize the CEC mode according to the specified parameters in the CEC_InitTypeDef and creates the associated handle. Parameters hcec: CEC handle. Return values HAL: status HAL_CEC_DeInit Function Name HAL_StatusTypeDef HAL_CEC_DeInit (CEC_HandleTypeDef * hcec) Function Description DeInitialize the CEC peripheral. Parameters hcec: CEC handle. Return values HAL: status HAL_CEC_MspInit Function Name void HAL_CEC_MspInit (CEC_HandleTypeDef * hcec) Function Description CEC MSP Init. Parameters hcec: CEC handle. Return values None: HAL_CEC_MspDeInit Function Name void HAL_CEC_MspDeInit (CEC_HandleTypeDef * hcec) Function Description CEC MSP DeInit. Parameters hcec: CEC handle. Return values None: HAL_CEC_Transmit 132/832 Function Name HAL_StatusTypeDef HAL_CEC_Transmit (CEC_HandleTypeDef * hcec, uint8_t DestinationAddress, uint8_t * pData, uint32_t Size, uint32_t Timeout) Function Description Send data in blocking mode. Parameters hcec: CEC handle. DestinationAddress: destination logical address. pData: pointer to input byte data buffer. Size: amount of data to be sent in bytes (without counting the header). 0 means only the header is sent (ping operation). Maximum TX size is 15 bytes (1 opcode and up to 14 operands). DOCID026526 Rev 4 UM1786 Return values Timeout: Timeout duration. HAL: status HAL_CEC_Receive Function Name HAL_StatusTypeDef HAL_CEC_Receive (CEC_HandleTypeDef * hcec, uint8_t * pData, uint32_t Timeout) Function Description Receive data in blocking mode. Parameters hcec: CEC handle pData: pointer to received data buffer. Timeout: Timeout duration. Return values HAL: status Notes The received data size is not known beforehand, the latter is known when the reception is complete and is stored in hcec>RxXferSize. hcec->RxXferSize is the sum of opcodes + operands (0 to 14 operands max). If only a header is received, hcec->RxXferSize = 0. HAL_CEC_Transmit_IT Function Name HAL_StatusTypeDef HAL_CEC_Transmit_IT (CEC_HandleTypeDef * hcec, uint8_t DestinationAddress, uint8_t * pData, uint32_t Size) Function Description Send data in interrupt mode. Parameters hcec: CEC handle. DestinationAddress: destination logical address. pData: pointer to input byte data buffer. Size: amount of data to be sent in bytes (without counting the header). 0 means only the header is sent (ping operation). Maximum TX size is 15 bytes (1 opcode and up to 14 operands). Return values HAL: status HAL_CEC_Receive_IT Function Name HAL_StatusTypeDef HAL_CEC_Receive_IT (CEC_HandleTypeDef * hcec, uint8_t * pData) Function Description Receive data in interrupt mode. Parameters hcec: CEC handle. pData: pointer to received data buffer. Return values HAL: status Notes The received data size is not known beforehand, the latter is known when the reception is complete and is stored in hcec>RxXferSize. hcec->RxXferSize is the sum of opcodes + operands (0 to 14 operands max). If only a header is received, hcec->RxXferSize = 0. DOCID026526 Rev 4 133/832 UM1786 HAL_CEC_GetReceivedFrameSize Function Name uint32_t HAL_CEC_GetReceivedFrameSize (CEC_HandleTypeDef * hcec) Function Description Get size of the received frame. Parameters hcec: CEC handle. Return values Frame: size HAL_CEC_IRQHandler Function Name void HAL_CEC_IRQHandler (CEC_HandleTypeDef * hcec) Function Description This function handles CEC interrupt requests. Parameters hcec: CEC handle. Return values None: HAL_CEC_TxCpltCallback Function Name void HAL_CEC_TxCpltCallback (CEC_HandleTypeDef * hcec) Function Description Tx Transfer completed callback. Parameters hcec: CEC handle Return values None: HAL_CEC_RxCpltCallback Function Name void HAL_CEC_RxCpltCallback (CEC_HandleTypeDef * hcec) Function Description Rx Transfer completed callback. Parameters hcec: CEC handle Return values None: HAL_CEC_ErrorCallback Function Name void HAL_CEC_ErrorCallback (CEC_HandleTypeDef * hcec) Function Description CEC error callback. Parameters hcec: CEC handle. Return values None: HAL_CEC_GetState 134/832 Function Name HAL_CEC_StateTypeDef HAL_CEC_GetState (CEC_HandleTypeDef * hcec) Function Description Return the CEC state. Parameters hcec: CEC handle. Return values HAL: state DOCID026526 Rev 4 UM1786 HAL_CEC_GetError Function Name uint32_t HAL_CEC_GetError (CEC_HandleTypeDef * hcec) Function Description Return the CEC error code. Parameters hcec: : pointer to a CEC_HandleTypeDef structure that contains the configuration information for the specified CEC. Return values CEC: Error Code 7.3 CEC Firmware driver defines 7.3.1 CEC CEC all RX or TX errors flags CEC_ISR_ALL_ERROR All Rx or Tx errors flags concatenation CEC Error Bit Generation if Bit Rise Error reported CEC_BRE_ERRORBIT_NO_GENERATION No Error-Bit on CEC line in case of BRE detection CEC_BRE_ERRORBIT_GENERATION Error-Bit on CEC line in case of BRE detection CEC Reception Stop on Error CEC_NO_RX_STOP_ON_BRE CEC reception not stopped by BRE detection CEC_RX_STOP_ON_BRE CEC reception stopped by BRE detection CEC Error Bit Generation on Broadcast message CEC_BROADCASTERROR_ERRORBIT_GENERATIO N Error-Bit on CEC line for specific error conditions on a broadcast message (cf Reference Manual) CEC_BROADCASTERROR_NO_ERRORBIT_GENERA TION No Error-Bit on CEC line for specific error conditions on a broadcast message (cf Reference Manual) CEC Error Code HAL_CEC_ERROR_NONE No error HAL_CEC_ERROR_RXOVR CEC Rx-Overrun HAL_CEC_ERROR_BRE CEC Rx Bit Rising Error HAL_CEC_ERROR_SBPE CEC Rx Short Bit period Error HAL_CEC_ERROR_LBPE CEC Rx Long Bit period Error HAL_CEC_ERROR_RXACKE CEC Rx Missing Acknowledge HAL_CEC_ERROR_ARBLST CEC Arbitration Lost HAL_CEC_ERROR_TXUDR CEC Tx-Buffer Underrun HAL_CEC_ERROR_TXERR CEC Tx-Error HAL_CEC_ERROR_TXACKE CEC Tx Missing Acknowledge DOCID026526 Rev 4 135/832 UM1786 CEC Exported Macros __HAL_CEC_RESET_HANDLE_STA TE Description: Reset CEC handle state. Parameters: __HANDLE__: CEC handle. Return value: None Description: __HAL_CEC_GET_FLAG Check whether or not the specified CEC interrupt flag is set. Parameters: __HANDLE__: specifies the CEC Handle. __FLAG__: specifies the interrupt to check. This parameter can be one of the following values: CEC_FLAG_TXACKE: Tx Missing acknowledge Error CEC_FLAG_TXERR: Tx Error. CEC_FLAG_TXUDR: Tx-Buffer Underrun. CEC_FLAG_TXEND: End of transmission (successful transmission of the last byte). CEC_FLAG_TXBR: Tx-Byte Request. CEC_FLAG_ARBLST: Arbitration Lost CEC_FLAG_RXACKE: Rx-Missing Acknowledge CEC_FLAG_LBPE: Rx Long period Error CEC_FLAG_SBPE: Rx Short period Error CEC_FLAG_BRE: Rx Bit Rissing Error CEC_FLAG_RXOVR: Rx Overrun. CEC_FLAG_RXEND: End Of Reception. CEC_FLAG_RXBR: Rx-Byte Received. Return value: __HAL_CEC_CLEAR_FLAG IT: Status Description: Clear the interrupt or status flag when raised (write at 1) Parameters: 136/832 __HANDLE__: specifies the CEC Handle. __FLAG__: specifies the interrupt/status flag to clear. This parameter can be one of the following values: DOCID026526 Rev 4 UM1786 CEC_FLAG_TXACKE: Tx Missing acknowledge Error CEC_FLAG_TXERR: Tx Error. CEC_FLAG_TXUDR: Tx-Buffer Underrun. CEC_FLAG_TXEND: End of transmission (successful transmission of the last byte). CEC_FLAG_TXBR: Tx-Byte Request. CEC_FLAG_ARBLST: Arbitration Lost CEC_FLAG_RXACKE: Rx-Missing Acknowledge CEC_FLAG_LBPE: Rx Long period Error CEC_FLAG_SBPE: Rx Short period Error CEC_FLAG_BRE: Rx Bit Rissing Error CEC_FLAG_RXOVR: Rx Overrun. CEC_FLAG_RXEND: End Of Reception. CEC_FLAG_RXBR: Rx-Byte Received. Return value: __HAL_CEC_ENABLE_IT none Description: Enable the specified CEC interrupt. Parameters: __HANDLE__: specifies the CEC Handle. __INTERRUPT__: specifies the CEC interrupt to enable. This parameter can be one of the following values: CEC_IT_TXACKE: Tx Missing acknowledge Error IT Enable CEC_IT_TXERR: Tx Error IT Enable CEC_IT_TXUDR: Tx-Buffer Underrun IT Enable CEC_IT_TXEND: End of transmission IT Enable CEC_IT_TXBR: Tx-Byte Request IT Enable CEC_IT_ARBLST: Arbitration Lost IT Enable CEC_IT_RXACKE: Rx-Missing Acknowledge IT Enable CEC_IT_LBPE: Rx Long period Error IT Enable CEC_IT_SBPE: Rx Short period Error IT Enable CEC_IT_BRE: Rx Bit Rising Error IT Enable CEC_IT_RXOVR: Rx Overrun IT Enable CEC_IT_RXEND: End Of Reception IT DOCID026526 Rev 4 137/832 UM1786 Enable CEC_IT_RXBR: Rx-Byte Received IT Enable Return value: none Description: __HAL_CEC_DISABLE_IT Disable the specified CEC interrupt. Parameters: __HANDLE__: specifies the CEC Handle. __INTERRUPT__: specifies the CEC interrupt to disable. This parameter can be one of the following values: CEC_IT_TXACKE: Tx Missing acknowledge Error IT Enable CEC_IT_TXERR: Tx Error IT Enable CEC_IT_TXUDR: Tx-Buffer Underrun IT Enable CEC_IT_TXEND: End of transmission IT Enable CEC_IT_TXBR: Tx-Byte Request IT Enable CEC_IT_ARBLST: Arbitration Lost IT Enable CEC_IT_RXACKE: Rx-Missing Acknowledge IT Enable CEC_IT_LBPE: Rx Long period Error IT Enable CEC_IT_SBPE: Rx Short period Error IT Enable CEC_IT_BRE: Rx Bit Rising Error IT Enable CEC_IT_RXOVR: Rx Overrun IT Enable CEC_IT_RXEND: End Of Reception IT Enable CEC_IT_RXBR: Rx-Byte Received IT Enable Return value: __HAL_CEC_GET_IT_SOURCE none Description: Check whether or not the specified CEC interrupt is enabled. Parameters: 138/832 __HANDLE__: specifies the CEC Handle. __INTERRUPT__: specifies the CEC interrupt to check. This parameter can be one of the following values: CEC_IT_TXACKE: Tx Missing acknowledge Error IT Enable DOCID026526 Rev 4 UM1786 CEC_IT_TXERR: Tx Error IT Enable CEC_IT_TXUDR: Tx-Buffer Underrun IT Enable CEC_IT_TXEND: End of transmission IT Enable CEC_IT_TXBR: Tx-Byte Request IT Enable CEC_IT_ARBLST: Arbitration Lost IT Enable CEC_IT_RXACKE: Rx-Missing Acknowledge IT Enable CEC_IT_LBPE: Rx Long period Error IT Enable CEC_IT_SBPE: Rx Short period Error IT Enable CEC_IT_BRE: Rx Bit Rising Error IT Enable CEC_IT_RXOVR: Rx Overrun IT Enable CEC_IT_RXEND: End Of Reception IT Enable CEC_IT_RXBR: Rx-Byte Received IT Enable Return value: Flag: Status Description: __HAL_CEC_ENABLE Enable the CEC device. Parameters: __HANDLE__: specifies the CEC Handle. Return value: none Description: __HAL_CEC_DISABLE Disable the CEC device. Parameters: __HANDLE__: specifies the CEC Handle. Return value: __HAL_CEC_FIRST_BYTE_TX_SET none Description: Set Transmission Start flag. Parameters: __HANDLE__: specifies the CEC Handle. Return value: __HAL_CEC_LAST_BYTE_TX_SET none Description: DOCID026526 Rev 4 139/832 UM1786 Set Transmission End flag. Parameters: __HANDLE__: specifies the CEC Handle. Return value: none Notes: __HAL_CEC_GET_TRANSMISSION _START_FLAG If the CEC message consists of only one byte, TXEOM must be set before TXSOM. Description: Get Transmission Start flag. Parameters: __HANDLE__: specifies the CEC Handle. Return value: __HAL_CEC_GET_TRANSMISSION _END_FLAG FlagStatus Description: Get Transmission End flag. Parameters: __HANDLE__: specifies the CEC Handle. Return value: __HAL_CEC_CLEAR_OAR FlagStatus Description: Clear OAR register. Parameters: __HANDLE__: specifies the CEC Handle. Return value: __HAL_CEC_SET_OAR none Description: Set OAR register (without resetting previously set address in case of multiaddress mode). Parameters: __HANDLE__: specifies the CEC Handle. __ADDRESS__: own address value (CEC logical address is identified by bit position) Return value: none Notes: 140/832 To reset OAR, __HAL_CEC_CLEAR_OAR() DOCID026526 Rev 4 UM1786 needs to be called beforehand. CEC flags definition CEC_FLAG_TXACKE Tx missing acknowledge error flag CEC_FLAG_TXERR Tx error flag CEC_FLAG_TXUDR Tx underrun flag CEC_FLAG_TXEND Tx end of message flag CEC_FLAG_TXBR Tx byte request flag CEC_FLAG_ARBLST Arbitration lost flag CEC_FLAG_RXACKE Rx missing acknowledge error flag CEC_FLAG_LBPE Long bit period error flag CEC_FLAG_SBPE Short bit period error flag CEC_FLAG_BRE Bit rising error flag CEC_FLAG_RXOVR Rx overrun flag CEC_FLAG_RXEND End of reception flag CEC_FLAG_RXBR RX byte received flag CEC all RX errors interrupts enabling flag CEC_IER_RX_ALL_ERR All Rx errors interruptions concatenation CEC all TX errors interrupts enabling flag CEC_IER_TX_ALL_ERR All Tx errors interruptions concatenation CEC Initiator logical address position in message header CEC_INITIATOR_LSB_POS CEC Initiator logical address position in message header CEC interrupts definition CEC_IT_TXACKE Tx missing acknowledge error interruption CEC_IT_TXERR Tx error interruption CEC_IT_TXUDR Tx underrun interruption CEC_IT_TXEND Tx end of message interruption CEC_IT_TXBR Tx byte request interruption CEC_IT_ARBLST Arbitration lost interruption CEC_IT_RXACKE Rx missing acknowledge error interruption CEC_IT_LBPE Long bit period error interruption CEC_IT_SBPE Short bit period error interruption CEC_IT_BRE Bit rising error interruption CEC_IT_RXOVR Rx overrun interruption CEC_IT_RXEND End of reception interruption CEC_IT_RXBR RX byte received interruption CEC Error Bit Generation if Long Bit Period Error reported DOCID026526 Rev 4 141/832 CEC_LBPE_ERRORBIT_NO_GENERATION CEC_LBPE_ERRORBIT_GENERATION UM1786 No Error-Bit on CEC line in case of LBPE detection Error-Bit on CEC line in case of LBPE detection CEC Listening mode option CEC_REDUCED_LISTENING_MODE CEC peripheral receives only message addressed to its own address (OAR). CEC_FULL_LISTENING_MODE CEC peripheral receives messages addressed to its own address (OAR) with positive acknowledge. Messages addressed to different destination are received, but without interfering with the CEC bus: no acknowledge sent. CEC Device Own Address position in CEC CFGR register CEC_CFGR_OAR_LSB_POS CEC Device Own Address position in CEC CFGR register CEC Signal Free Time start option CEC_SFT_START_ON_TXSOM SFT timer starts when TXSOM is set by software CEC_SFT_START_ON_TX_RX_END SFT timer starts automatically at the end of message transmission/reception CEC Signal Free Time setting parameter CEC_DEFAULT_SFT Transmission history-based signal free time (ruled by hardware) CEC_0_5_BITPERIOD_SFT 0.5 nominal data bit period CEC_1_5_BITPERIOD_SFT 1.5 nominal data bit periods CEC_2_5_BITPERIOD_SFT 2.5 nominal data bit periods CEC_3_5_BITPERIOD_SFT 3.5 nominal data bit periods CEC_4_5_BITPERIOD_SFT 4.5 nominal data bit periods CEC_5_5_BITPERIOD_SFT 5.5 nominal data bit periods CEC_6_5_BITPERIOD_SFT 6.5 nominal data bit periods CEC Receiver Tolerance 142/832 CEC_STANDARD_TOLERANCE Standard tolerance margin CEC_EXTENDED_TOLERANCE Extended Tolerance DOCID026526 Rev 4 UM1786 8 HAL COMP Generic Driver 8.1 COMP Firmware driver registers structures 8.1.1 COMP_InitTypeDef Data Fields uint32_t InvertingInput uint32_t NonInvertingInput uint32_t Output uint32_t OutputPol uint32_t Hysteresis uint32_t BlankingSrce uint32_t Mode uint32_t WindowMode uint32_t TriggerMode Field Documentation uint32_t COMP_InitTypeDef::InvertingInput Selects the inverting input of the comparator. This parameter can be a value of COMPEx_InvertingInput uint32_t COMP_InitTypeDef::NonInvertingInput Selects the non inverting input of the comparator. This parameter can be a value of COMPEx_NonInvertingInput Note: Only available on STM32F302xB/xC, STM32F303xB/xC and STM32F358xx devices uint32_t COMP_InitTypeDef::Output Selects the output redirection of the comparator. This parameter can be a value of COMPEx_Output uint32_t COMP_InitTypeDef::OutputPol Selects the output polarity of the comparator. This parameter can be a value of COMP_OutputPolarity uint32_t COMP_InitTypeDef::Hysteresis Selects the hysteresis voltage of the comparator. This parameter can be a value of COMPEx_Hysteresis Note: Only available on STM32F302xB/xC, STM32F303xB/xC, STM32F373xB/xC, STM32F358xx and STM32F378xx devices uint32_t COMP_InitTypeDef::BlankingSrce Selects the output blanking source of the comparator. This parameter can be a value of COMPEx_BlankingSrce Note: Not available on STM32F373xB/C and STM32F378xx devices uint32_t COMP_InitTypeDef::Mode Selects the operating consumption mode of the comparator to adjust the speed/consumption. This parameter can be a value of COMPEx_Mode Note: Not available on STM32F301x6/x8, STM32F302x6/x8, STM32F334x6/x8, STM32F318xx and STM32F328xx devices uint32_t COMP_InitTypeDef::WindowMode Selects the window mode of the comparator X (X=2, 4 or 6 if available). This parameter can be a value of COMPEx_WindowMode DOCID026526 Rev 4 143/832 UM1786 8.1.2 uint32_t COMP_InitTypeDef::TriggerMode Selects the trigger mode of the comparator (interrupt mode). This parameter can be a value of COMP_TriggerMode COMP_HandleTypeDef Data Fields COMP_TypeDef * Instance COMP_InitTypeDef Init HAL_LockTypeDef Lock __IO HAL_COMP_StateTypeDef State Field Documentation COMP_TypeDef* COMP_HandleTypeDef::Instance Register base address COMP_InitTypeDef COMP_HandleTypeDef::Init COMP required parameters HAL_LockTypeDef COMP_HandleTypeDef::Lock Locking object __IO HAL_COMP_StateTypeDef COMP_HandleTypeDef::State COMP communication state 8.2 COMP Firmware driver API description 8.2.1 COMP Peripheral features The STM32F3xx device family integrates up to 7 analog comparators COMP1, COMP2...COMP7: 1. 2. 3. 4. 5. 144/832 The non inverting input and inverting input can be set to GPIO pins. For STM32F3xx devices please refer to the COMP peripheral section in corresponding Reference Manual. The COMP output is available using HAL_COMP_GetOutputLevel() and can be set on GPIO pins. For STM32F3xx devices please refer to the COMP peripheral section in corresponding Reference Manual. The COMP output can be redirected to embedded timers (TIM1, TIM2, TIM3...). For STM32F3xx devices please refer to the COMP peripheral section in corresponding Reference Manual. Each couple of comparators COMP1 and COMP2, COMP3 and COMP4, COMP5 and COMP6 can be combined in window mode and respectively COMP1, COMP3 and COMP5 non inverting input is used as common non-inverting input. The seven comparators have interrupt capability with wake-up from Sleep and Stop modes (through the EXTI controller): COMP1 is internally connected to EXTI Line 21 COMP2 is internally connected to EXTI Line 22 COMP3 is internally connected to EXTI Line 29 COMP4 is internally connected to EXTI Line 30 COMP5 is internally connected to EXTI Line 31 COMP6 is internally connected to EXTI Line 32 DOCID026526 Rev 4 UM1786 8.2.2 COMP7 is internally connected to EXTI Line 33. From the corresponding IRQ handler, the right interrupt source can be retrieved with the adequate macro __HAL_COMP_COMPx_EXTI_GET_FLAG(). How to use this driver This driver provides functions to configure and program the Comparators of all STM32F3xx devices. To use the comparator, perform the following steps: 1. 2. 3. 4. 5. 6. 7. 8. 8.2.3 Fill in the HAL_COMP_MspInit() to Configure the comparator input in analog mode using HAL_GPIO_Init() Configure the comparator output in alternate function mode using HAL_GPIO_Init() to map the comparator output to the GPIO pin If required enable the COMP interrupt (EXTI line Interrupt): by configuring and enabling EXTI line in Interrupt mode and selecting the desired sensitivity level using HAL_GPIO_Init() function. After that enable the comparator interrupt vector using HAL_NVIC_SetPriority() and HAL_NVIC_EnableIRQ() functions. Configure the comparator using HAL_COMP_Init() function: Select the inverting input (input minus) Select the non-inverting input (input plus) Select the output polarity Select the output redirection Select the hysteresis level Select the power mode Select the event/interrupt mode HAL_COMP_Init() calls internally __HAL_RCC_SYSCFG_CLK_ENABLE() in order to enable the comparator(s). On-the-fly reconfiguration of comparator(s) may be done by calling again HAL_COMP_Init( function with new input parameter values; HAL_COMP_MspInit() function shall be adapted to support multi configurations. Enable the comparator using HAL_COMP_Start() or HAL_COMP_Start_IT() functions. Use HAL_COMP_TriggerCallback() and/or HAL_COMP_GetOutputLevel() functions to manage comparator outputs (events and output level). Disable the comparator using HAL_COMP_Stop() or HAL_COMP_Stop_IT() function. De-initialize the comparator using HAL_COMP_DeInit() function. For safety purposes comparator(s) can be locked using HAL_COMP_Lock() function. Only a MCU reset can reset that protection. Initialization and de-initialization functions This section provides functions to initialize and de-initialize comparators. This section contains the following APIs: 8.2.4 HAL_COMP_Init() HAL_COMP_DeInit() HAL_COMP_MspInit() HAL_COMP_MspDeInit() Start Stop operation functions This section provides functions allowing to: Start a comparator without interrupt generation. Stop a comparator without interrupt generation. Start a comparator with interrupt generation. Stop a comparator with interrupt generation. Handle interrupts from a comparator with associated callback function. DOCID026526 Rev 4 145/832 UM1786 This section contains the following APIs: 8.2.5 HAL_COMP_Start() HAL_COMP_Stop() HAL_COMP_Start_IT() HAL_COMP_Stop_IT() HAL_COMP_IRQHandler() HAL_COMP_TriggerCallback() Peripheral Control functions This subsection provides a set of functions allowing to control the comparators. This section contains the following APIs: 8.2.6 HAL_COMP_Lock() HAL_COMP_GetOutputLevel() Peripheral State functions This subsection permits to get in run-time the status of the peripheral. This section contains the following APIs: 8.2.7 HAL_COMP_GetState() Detailed description of functions HAL_COMP_Init Function Name HAL_StatusTypeDef HAL_COMP_Init (COMP_HandleTypeDef * hcomp) Function Description Initialize the COMP peripheral according to the specified parameters in the COMP_InitTypeDef and initialize the associated handle. Parameters hcomp: COMP handle Return values HAL: status Notes If the selected comparator is locked, initialization cannot be performed. To unlock the configuration, perform a system reset. HAL_COMP_DeInit 146/832 Function Name HAL_StatusTypeDef HAL_COMP_DeInit (COMP_HandleTypeDef * hcomp) Function Description DeInitialize the COMP peripheral. Parameters hcomp: COMP handle Return values HAL: status Notes If the selected comparator is locked, deinitialization cannot be performed. To unlock the configuration, perform a system reset. DOCID026526 Rev 4 UM1786 HAL_COMP_MspInit Function Name void HAL_COMP_MspInit (COMP_HandleTypeDef * hcomp) Function Description Initialize the COMP MSP. Parameters hcomp: COMP handle Return values None: HAL_COMP_MspDeInit Function Name void HAL_COMP_MspDeInit (COMP_HandleTypeDef * hcomp) Function Description DeInitialize the COMP MSP. Parameters hcomp: COMP handle Return values None: HAL_COMP_Start Function Name HAL_StatusTypeDef HAL_COMP_Start (COMP_HandleTypeDef * hcomp) Function Description Start the comparator. Parameters hcomp: COMP handle Return values HAL: status HAL_COMP_Stop Function Name HAL_StatusTypeDef HAL_COMP_Stop (COMP_HandleTypeDef * hcomp) Function Description Stop the comparator. Parameters hcomp: COMP handle Return values HAL: status HAL_COMP_Start_IT Function Name HAL_StatusTypeDef HAL_COMP_Start_IT (COMP_HandleTypeDef * hcomp) Function Description Start the comparator in Interrupt mode. Parameters hcomp: COMP handle Return values HAL: status. HAL_COMP_Stop_IT Function Name HAL_StatusTypeDef HAL_COMP_Stop_IT (COMP_HandleTypeDef * hcomp) Function Description Stop the comparator in Interrupt mode. Parameters hcomp: COMP handle DOCID026526 Rev 4 147/832 UM1786 Return values HAL: status HAL_COMP_IRQHandler Function Name void HAL_COMP_IRQHandler (COMP_HandleTypeDef * hcomp) Function Description Comparator IRQ Handler. Parameters hcomp: COMP handle Return values HAL: status HAL_COMP_TriggerCallback Function Name void HAL_COMP_TriggerCallback (COMP_HandleTypeDef * hcomp) Function Description Comparator callback. Parameters hcomp: COMP handle Return values None: HAL_COMP_Lock Function Name HAL_StatusTypeDef HAL_COMP_Lock (COMP_HandleTypeDef * hcomp) Function Description Lock the selected comparator configuration. Parameters hcomp: COMP handle Return values HAL: status Notes A system reset is required to unlock the comparator configuration. HAL_COMP_GetOutputLevel Function Name uint32_t HAL_COMP_GetOutputLevel (COMP_HandleTypeDef * hcomp) Function Description Return the output level (high or low) of the selected comparator. HAL_COMP_GetState 148/832 Function Name HAL_COMP_StateTypeDef HAL_COMP_GetState (COMP_HandleTypeDef * hcomp) Function Description Return the COMP handle state. Parameters hcomp: COMP handle Return values HAL: state DOCID026526 Rev 4 UM1786 8.3 COMP Firmware driver defines 8.3.1 COMP COMP Exported Macros __HAL_COMP_RESET_HANDLE_STATE Description: Reset COMP handle state. Parameters: __HANDLE__: COMP handle. Return value: None COMP Flag COMP_FLAG_LOCK Lock flag COMP Extended Private macro to get the EXTI line associated with a comparator handle COMP_GET_EXTI_LINE Description: Get the specified EXTI line for a comparator instance. Parameters: __INSTANCE__: specifies the COMP instance. Return value: value: of COMP Private macros to check input parameters IS_COMP_OUTPUTPOL IS_COMP_TRIGGERMODE COMP Output Level COMP_OUTPUTLEVEL_LOW COMP_OUTPUTLEVEL_HIGH COMP Output Polarity COMP_OUTPUTPOL_NONINVERTED COMP output on GPIO isn't inverted COMP_OUTPUTPOL_INVERTED COMP output on GPIO is inverted COMP State Lock COMP_STATE_BIT_LOCK COMP Trigger Mode COMP_TRIGGERMODE_NONE No External Interrupt trigger detection COMP_TRIGGERMODE_IT_RISING External Interrupt Mode with Rising edge trigger detection COMP_TRIGGERMODE_IT_FALLING External Interrupt Mode with Falling edge trigger detection DOCID026526 Rev 4 149/832 COMP_TRIGGERMODE_IT_RISING_FALLING 150/832 UM1786 External Interrupt Mode with Rising/Falling edge trigger detection COMP_TRIGGERMODE_EVENT_RISING Event Mode with Rising edge trigger detection COMP_TRIGGERMODE_EVENT_FALLING Event Mode with Falling edge trigger detection COMP_TRIGGERMODE_EVENT_RISING_FALLING Event Mode with Rising/Falling edge trigger detection DOCID026526 Rev 4 UM1786 9 HAL COMP Extension Driver 9.1 COMPEx Firmware driver defines 9.1.1 COMPEx COMP Extended Blanking Source (STM32F303xE/STM32F398xx/STM32F303xC/STM32F358xx Product devices) COMP_BLANKINGSRCE_NONE No blanking source COMP_BLANKINGSRCE_TIM1OC5 TIM1 OC5 selected as blanking source for COMP1, COMP2, COMP3 and COMP7 COMP_BLANKINGSRCE_TIM2OC3 TIM2 OC5 selected as blanking source for COMP1 and COMP2 COMP_BLANKINGSRCE_TIM3OC3 TIM2 OC3 selected as blanking source for COMP1, COMP2 and COMP5 COMP_BLANKINGSRCE_TIM2OC4 TIM2 OC4 selected as blanking source for COMP3 and COMP6 COMP_BLANKINGSRCE_TIM8OC5 TIM8 OC5 selected as blanking source for COMP4, COMP5, COMP6 and COMP7 COMP_BLANKINGSRCE_TIM3OC4 TIM3 OC4 selected as blanking source for COMP4 COMP_BLANKINGSRCE_TIM15OC1 TIM15 OC1 selected as blanking source for COMP4 COMP_BLANKINGSRCE_TIM15OC2 TIM15 OC2 selected as blanking source for COMP6 and COMP7 COMP Extended Exported Macros __HAL_COMP_ENABLE Description: Enable the specified comparator. Parameters: __HANDLE__: COMP handle. Return value: __HAL_COMP_DISABLE None Description: Disable the specified comparator. Parameters: __HANDLE__: COMP handle. Return value: __HAL_COMP_LOCK None Description: DOCID026526 Rev 4 151/832 UM1786 Lock a comparator instance. Parameters: __HANDLE__: COMP handle Return value: None. Description: __HAL_COMP_GET_FLAG Check whether the specified COMP flag is set or not. Parameters: __HANDLE__: COMP Handle. __FLAG__: flag to check. This parameter can be one of the following values: COMP_FLAG_LOCK lock flag Return value: __HAL_COMP_COMP1_EXTI_ENABLE_RISI NG_EDGE The: new state of __FLAG__ (TRUE or FALSE). Description: Enable the COMP1 EXTI line rising edge trigger. Return value: __HAL_COMP_COMP1_EXTI_DISABLE_RIS ING_EDGE None Description: Disable the COMP1 EXTI line rising edge trigger. Return value: __HAL_COMP_COMP1_EXTI_ENABLE_FAL LING_EDGE None Description: Enable the COMP1 EXTI line falling edge trigger. Return value: __HAL_COMP_COMP1_EXTI_DISABLE_FA LLING_EDGE None Description: Disable the COMP1 EXTI line falling edge trigger. Return value: __HAL_COMP_COMP1_EXTI_ENABLE_RISI NG_FALLING_EDGE 152/832 None Description: DOCID026526 Rev 4 Enable the COMP1 EXTI line rising & UM1786 falling edge trigger. Return value: __HAL_COMP_COMP1_EXTI_DISABLE_RIS ING_FALLING_EDGE None Description: Disable the COMP1 EXTI line rising & falling edge trigger. Return value: __HAL_COMP_COMP1_EXTI_ENABLE_IT None Description: Enable the COMP1 EXTI line in interrupt mode. Return value: __HAL_COMP_COMP1_EXTI_DISABLE_IT None Description: Disable the COMP1 EXTI line in interrupt mode. Return value: __HAL_COMP_COMP1_EXTI_GENERATE_ SWIT None Description: Generate a software interrupt on the COMP1 EXTI line. Return value: __HAL_COMP_COMP1_EXTI_ENABLE_EVE NT None Description: Enable the COMP1 EXTI line in event mode. Return value: __HAL_COMP_COMP1_EXTI_DISABLE_EV ENT None Description: Disable the COMP1 EXTI line in event mode. Return value: __HAL_COMP_COMP1_EXTI_GET_FLAG None Description: Check whether the COMP1 EXTI line flag is set or not. Return value: DOCID026526 Rev 4 RESET: or SET 153/832 UM1786 __HAL_COMP_COMP1_EXTI_CLEAR_FLAG Description: Clear the COMP1 EXTI flag. Return value: __HAL_COMP_COMP2_EXTI_ENABLE_RISI NG_EDGE None Description: Enable the COMP2 EXTI line rising edge trigger. Return value: __HAL_COMP_COMP2_EXTI_DISABLE_RIS ING_EDGE None Description: Disable the COMP2 EXTI line rising edge trigger. Return value: __HAL_COMP_COMP2_EXTI_ENABLE_FAL LING_EDGE None Description: Enable the COMP2 EXTI line falling edge trigger. Return value: __HAL_COMP_COMP2_EXTI_DISABLE_FA LLING_EDGE None Description: Disable the COMP2 EXTI line falling edge trigger. Return value: __HAL_COMP_COMP2_EXTI_ENABLE_RISI NG_FALLING_EDGE None Description: Enable the COMP2 EXTI line rising & falling edge trigger. Return value: __HAL_COMP_COMP2_EXTI_DISABLE_RIS ING_FALLING_EDGE None Description: Disable the COMP2 EXTI line rising & falling edge trigger. Return value: __HAL_COMP_COMP2_EXTI_ENABLE_IT None Description: Enable the COMP2 EXTI line in interrupt mode. Return value: 154/832 DOCID026526 Rev 4 UM1786 __HAL_COMP_COMP2_EXTI_DISABLE_IT None Description: Disable the COMP2 EXTI line in interrupt mode. Return value: __HAL_COMP_COMP2_EXTI_GENERATE_ SWIT None Description: Generate a software interrupt on the COMP2 EXTI line. Return value: __HAL_COMP_COMP2_EXTI_ENABLE_EVE NT None Description: Enable the COMP2 EXTI line in event mode. Return value: __HAL_COMP_COMP2_EXTI_DISABLE_EV ENT None Description: Disable the COMP2 EXTI line in event mode. Return value: __HAL_COMP_COMP2_EXTI_GET_FLAG None Description: Check whether the COMP2 EXTI line flag is set or not. Return value: __HAL_COMP_COMP2_EXTI_CLEAR_FLAG RESET: or SET Description: Clear the COMP2 EXTI flag. Return value: __HAL_COMP_COMP3_EXTI_ENABLE_RISI NG_EDGE None Description: Enable the COMP3 EXTI line rising edge trigger. Return value: __HAL_COMP_COMP3_EXTI_DISABLE_RIS ING_EDGE None Description: DOCID026526 Rev 4 Disable the COMP3 EXTI line rising edge trigger. 155/832 UM1786 Return value: __HAL_COMP_COMP3_EXTI_ENABLE_FAL LING_EDGE None Description: Enable the COMP3 EXTI line falling edge trigger. Return value: __HAL_COMP_COMP3_EXTI_DISABLE_FA LLING_EDGE None Description: Disable the COMP3 EXTI line falling edge trigger. Return value: __HAL_COMP_COMP3_EXTI_ENABLE_RISI NG_FALLING_EDGE None Description: Enable the COMP3 EXTI line rising & falling edge trigger. Return value: __HAL_COMP_COMP3_EXTI_DISABLE_RIS ING_FALLING_EDGE None Description: Disable the COMP3 EXTI line rising & falling edge trigger. Return value: __HAL_COMP_COMP3_EXTI_ENABLE_IT None Description: Enable the COMP3 EXTI line in interrupt mode. Return value: __HAL_COMP_COMP3_EXTI_DISABLE_IT None Description: Disable the COMP3 EXTI line in interrupt mode. Return value: __HAL_COMP_COMP3_EXTI_GENERATE_ SWIT None Description: Generate a software interrupt on the COMP3 EXTI line. Return value: __HAL_COMP_COMP3_EXTI_ENABLE_EVE 156/832 None Description: DOCID026526 Rev 4 UM1786 NT Enable the COMP3 EXTI line in event mode. Return value: __HAL_COMP_COMP3_EXTI_DISABLE_EV ENT None Description: Disable the COMP3 EXTI line in event mode. Return value: __HAL_COMP_COMP3_EXTI_GET_FLAG None Description: Check whether the COMP3 EXTI line flag is set or not. Return value: __HAL_COMP_COMP3_EXTI_CLEAR_FLAG RESET: or SET Description: Clear the COMP3 EXTI flag. Return value: __HAL_COMP_COMP4_EXTI_ENABLE_RISI NG_EDGE None Description: Enable the COMP4 EXTI line rising edge trigger. Return value: __HAL_COMP_COMP4_EXTI_DISABLE_RIS ING_EDGE None Description: Disable the COMP4 EXTI line rising edge trigger. Return value: __HAL_COMP_COMP4_EXTI_ENABLE_FAL LING_EDGE None Description: Enable the COMP4 EXTI line falling edge trigger. Return value: __HAL_COMP_COMP4_EXTI_DISABLE_FA LLING_EDGE None Description: Disable the COMP4 EXTI line falling edge trigger. Return value: DOCID026526 Rev 4 None 157/832 UM1786 __HAL_COMP_COMP4_EXTI_ENABLE_RISI NG_FALLING_EDGE Description: Enable the COMP4 EXTI line rising & falling edge trigger. Return value: __HAL_COMP_COMP4_EXTI_DISABLE_RIS ING_FALLING_EDGE None Description: Disable the COMP4 EXTI line rising & falling edge trigger. Return value: __HAL_COMP_COMP4_EXTI_ENABLE_IT None Description: Enable the COMP4 EXTI line in interrupt mode. Return value: __HAL_COMP_COMP4_EXTI_DISABLE_IT None Description: Disable the COMP4 EXTI line in interrupt mode. Return value: __HAL_COMP_COMP4_EXTI_GENERATE_ SWIT None Description: Generate a software interrupt on the COMP4 EXTI line. Return value: __HAL_COMP_COMP4_EXTI_ENABLE_EVE NT None Description: Enable the COMP4 EXTI line in event mode. Return value: __HAL_COMP_COMP4_EXTI_DISABLE_EV ENT None Description: Disable the COMP4 EXTI line in event mode. Return value: __HAL_COMP_COMP4_EXTI_GET_FLAG Description: 158/832 None DOCID026526 Rev 4 Check whether the COMP4 EXTI line flag is set or not. UM1786 Return value: __HAL_COMP_COMP4_EXTI_CLEAR_FLAG RESET: or SET Description: Clear the COMP4 EXTI flag. Return value: __HAL_COMP_COMP5_EXTI_ENABLE_RISI NG_EDGE None Description: Enable the COMP5 EXTI line rising edge trigger. Return value: __HAL_COMP_COMP5_EXTI_DISABLE_RIS ING_EDGE None Description: Disable the COMP5 EXTI line rising edge trigger. Return value: __HAL_COMP_COMP5_EXTI_ENABLE_FAL LING_EDGE None Description: Enable the COMP5 EXTI line falling edge trigger. Return value: __HAL_COMP_COMP5_EXTI_DISABLE_FA LLING_EDGE None Description: Disable the COMP5 EXTI line falling edge trigger. Return value: __HAL_COMP_COMP5_EXTI_ENABLE_RISI NG_FALLING_EDGE None Description: Enable the COMP5 EXTI line rising & falling edge trigger. Return value: __HAL_COMP_COMP5_EXTI_DISABLE_RIS ING_FALLING_EDGE None Description: Disable the COMP5 EXTI line rising & falling edge trigger. Return value: __HAL_COMP_COMP5_EXTI_ENABLE_IT None Description: DOCID026526 Rev 4 Enable the COMP5 EXTI line in 159/832 UM1786 interrupt mode. Return value: __HAL_COMP_COMP5_EXTI_DISABLE_IT None Description: Disable the COMP5 EXTI line in interrupt mode. Return value: __HAL_COMP_COMP5_EXTI_GENERATE_ SWIT None Description: Generate a software interrupt on the COMP5 EXTI line. Return value: __HAL_COMP_COMP5_EXTI_ENABLE_EVE NT None Description: Enable the COMP5 EXTI line in event mode. Return value: __HAL_COMP_COMP5_EXTI_DISABLE_EV ENT None Description: Disable the COMP5 EXTI line in event mode. Return value: __HAL_COMP_COMP5_EXTI_GET_FLAG None Description: Check whether the COMP5 EXTI line flag is set or not. Return value: __HAL_COMP_COMP5_EXTI_CLEAR_FLAG RESET: or SET Description: Clear the COMP5 EXTI flag. Return value: __HAL_COMP_COMP6_EXTI_ENABLE_RISI NG_EDGE None Description: Enable the COMP6 EXTI line rising edge trigger. Return value: __HAL_COMP_COMP6_EXTI_DISABLE_RIS 160/832 None Description: DOCID026526 Rev 4 UM1786 ING_EDGE Disable the COMP6 EXTI line rising edge trigger. Return value: __HAL_COMP_COMP6_EXTI_ENABLE_FAL LING_EDGE None Description: Enable the COMP6 EXTI line falling edge trigger. Return value: __HAL_COMP_COMP6_EXTI_DISABLE_FA LLING_EDGE None Description: Disable the COMP6 EXTI line falling edge trigger. Return value: __HAL_COMP_COMP6_EXTI_ENABLE_RISI NG_FALLING_EDGE None Description: Enable the COMP6 EXTI line rising & falling edge trigger. Return value: __HAL_COMP_COMP6_EXTI_DISABLE_RIS ING_FALLING_EDGE None Description: Disable the COMP6 EXTI line rising & falling edge trigger. Return value: __HAL_COMP_COMP6_EXTI_ENABLE_IT None Description: Enable the COMP6 EXTI line in interrupt mode. Return value: __HAL_COMP_COMP6_EXTI_DISABLE_IT None Description: Disable the COMP6 EXTI line in interrupt mode. Return value: __HAL_COMP_COMP6_EXTI_GENERATE_ SWIT None Description: Generate a software interrupt on the COMP6 EXTI line. Return value: DOCID026526 Rev 4 161/832 UM1786 __HAL_COMP_COMP6_EXTI_ENABLE_EVE NT None Description: Enable the COMP6 EXTI line in event mode. Return value: __HAL_COMP_COMP6_EXTI_DISABLE_EV ENT None Description: Disable the COMP6 EXTI line in event mode. Return value: __HAL_COMP_COMP6_EXTI_GET_FLAG None Description: Check whether the COMP6 EXTI line flag is set or not. Return value: __HAL_COMP_COMP6_EXTI_CLEAR_FLAG RESET: or SET Description: Clear the COMP6 EXTI flag. Return value: __HAL_COMP_COMP7_EXTI_ENABLE_RISI NG_EDGE None Description: Enable the COMP7 EXTI line rising edge trigger. Return value: __HAL_COMP_COMP7_EXTI_DISABLE_RIS ING_EDGE None Description: Disable the COMP7 EXTI line rising edge trigger. Return value: __HAL_COMP_COMP7_EXTI_ENABLE_FAL LING_EDGE None Description: Enable the COMP7 EXTI line falling edge trigger. Return value: __HAL_COMP_COMP7_EXTI_DISABLE_FA LLING_EDGE 162/832 None Description: DOCID026526 Rev 4 Disable the COMP7 EXTI line falling edge trigger. UM1786 Return value: __HAL_COMP_COMP7_EXTI_ENABLE_RISI NG_FALLING_EDGE None Description: Enable the COMP7 EXTI line rising & falling edge trigger. Return value: __HAL_COMP_COMP7_EXTI_DISABLE_RIS ING_FALLING_EDGE None Description: Disable the COMP7 EXTI line rising & falling edge trigger. Return value: __HAL_COMP_COMP7_EXTI_ENABLE_IT None Description: Enable the COMP7 EXTI line in interrupt mode. Return value: __HAL_COMP_COMP7_EXTI_DISABLE_IT None Description: Disable the COMP7 EXTI line in interrupt mode. Return value: __HAL_COMP_COMP7_EXTI_GENERATE_ SWIT None Description: Generate a software interrupt on the COMP7 EXTI line. Return value: __HAL_COMP_COMP7_EXTI_ENABLE_EVE NT None Description: Enable the COMP7 EXTI line in event mode. Return value: __HAL_COMP_COMP7_EXTI_DISABLE_EV ENT None Description: Disable the COMP7 EXTI line in event mode. Return value: __HAL_COMP_COMP7_EXTI_GET_FLAG None Description: DOCID026526 Rev 4 163/832 UM1786 Check whether the COMP7 EXTI line flag is set or not. Return value: __HAL_COMP_COMP7_EXTI_CLEAR_FLAG RESET: or SET Description: Clear the COMP7 EXTI flag. Return value: None COMP Extended EXTI lines COMP_EXTI_LINE_COMP1 External interrupt line 21 connected to COMP1 COMP_EXTI_LINE_COMP2 External interrupt line 22 connected to COMP2 COMP_EXTI_LINE_COMP3 External interrupt line 29 connected to COMP3 COMP_EXTI_LINE_COMP4 External interrupt line 30 connected to COMP4 COMP_EXTI_LINE_COMP5 External interrupt line 31 connected to COMP5 COMP_EXTI_LINE_COMP6 External interrupt line 32 connected to COMP6 COMP_EXTI_LINE_COMP7 External interrupt line 33 connected to COMP7 COMP_EXTI_LINE_REG2_MASK Mask for External interrupt line control in register xxx2 COMP Extended Hysteresis COMP_HYSTERESIS_NONE No hysteresis COMP_HYSTERESIS_LOW Hysteresis level low COMP_HYSTERESIS_MEDIUM Hysteresis level medium COMP_HYSTERESIS_HIGH Hysteresis level high COMP Extended InvertingInput (STM32F302xE/STM32F303xE/STM32F398xx/STM32F302xC/STM32F303xC/STM32F35 8xx Product devices) 164/832 COMP_INVERTINGINPUT_1_4VREFINT 1/4 VREFINT connected to comparator inverting input COMP_INVERTINGINPUT_1_2VREFINT 1/2 VREFINT connected to comparator inverting input COMP_INVERTINGINPUT_3_4VREFINT 3/4 VREFINT connected to comparator inverting input COMP_INVERTINGINPUT_VREFINT VREFINT connected to comparator inverting input COMP_INVERTINGINPUT_DAC1_CH1 DAC1_CH1_OUT (PA4) connected to comparator inverting input COMP_INVERTINGINPUT_DAC1_CH2 DAC1_CH2_OUT (PA5) connected to comparator inverting input COMP_INVERTINGINPUT_IO1 IO1 (PA0 for COMP1, PA2 for COMP2, PD15 for COMP3, PE8 for COMP4, PD13 for COMP5, PD10 for COMP6, PC0 for COMP7) DOCID026526 Rev 4 UM1786 connected to comparator inverting input COMP_INVERTINGINPUT_IO2 IO2 (PB12 for COMP3, PB2 for COMP4, PB10 for COMP5, PB15 for COMP6) connected to comparator inverting input COMP_INVERTINGINPUT_DAC1 COMP_INVERTINGINPUT_DAC2 COMP Extended Private macros to check input parameters IS_COMP_INVERTINGINPUT IS_COMP_NONINVERTINGINPUT IS_COMP_NONINVERTINGINPUT_INSTANCE IS_COMP_WINDOWMODE IS_COMP_MODE IS_COMP_HYSTERESIS IS_COMP_OUTPUT IS_COMP_OUTPUT_INSTANCE IS_COMP_BLANKINGSRCE IS_COMP_BLANKINGSRCE_INSTANCE COMP Extended miscellaneous defines COMP_CSR_COMPxINSEL_MASK COMP_CSR_COMPxINSEL Mask COMP_CSR_COMPxOUTSEL_MASK COMP_CSR_COMPxOUTSEL Mask COMP_CSR_COMPxPOL_MASK COMP_CSR_COMPxPOL Mask COMP_CSR_RESET_VALUE COMP_CSR_COMPxNONINSEL_MASK COMP_CSR_COMPxNONINSEL mask COMP_CSR_COMPxWNDWEN_MASK COMP_CSR_COMPxWNDWEN mask COMP_CSR_COMPxMODE_MASK COMP_CSR_COMPxMODE Mask COMP_CSR_COMPxHYST_MASK COMP_CSR_COMPxHYST Mask COMP_CSR_COMPxBLANKING_MASK COMP_CSR_COMPxBLANKING mask COMP Extended Mode COMP_MODE_HIGHSPEED High Speed COMP_MODE_MEDIUMSPEED Medium Speed COMP_MODE_LOWPOWER Low power mode COMP_MODE_ULTRALOWPOWER Ultra-low power mode COMP Extended NonInvertingInput (STM32F302xC/STM32F303xC/STM32F358xx Product devices) COMP_NONINVERTINGINPUT_IO1 DOCID026526 Rev 4 IO1 (PA1 for COMP1, PA7 for COMP2, PB14 for COMP3, PB0 for COMP4, PD12 for COMP5, PD11 for COMP6, PA0 for COMP7) connected to 165/832 UM1786 comparator non inverting input COMP_NONINVERTINGINPUT_IO2 IO2 (PA3 for COMP2, PD14 for COMP3, PE7 for COMP4, PB13 for COMP5, PB11 for COMP6, PC1 for COMP7) connected to comparator non inverting input COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED DAC ouput connected to comparator COMP1 non inverting input COMP Extended Output (STM32F303xC/STM32F358xx Product devices) 166/832 COMP_OUTPUT_NONE COMP1, COMP2... or COMP7 output isn't connected to other peripherals COMP_OUTPUT_TIM1BKIN COMP1, COMP2... or COMP7 output connected to TIM1 Break Input (BKIN) COMP_OUTPUT_TIM1BKIN2 COMP1, COMP2... or COMP7 output connected to TIM1 Break Input 2 (BKIN2) COMP_OUTPUT_TIM8BKIN COMP1, COMP2... or COMP7 output connected to TIM8 Break Input (BKIN) COMP_OUTPUT_TIM8BKIN2 COMP1, COMP2... or COMP7 output connected to TIM8 Break Input 2 (BKIN2) COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2 COMP1, COMP2... or COMP7 output connected to TIM1 Break Input 2 and TIM8 Break Input 2 COMP_OUTPUT_TIM1OCREFCLR COMP1, COMP2, COMP3 or COMP7 output connected to TIM1 OCREF Clear COMP_OUTPUT_TIM2OCREFCLR COMP1, COMP2 or COMP3 output connected to TIM2 OCREF Clear COMP_OUTPUT_TIM3OCREFCLR COMP1, COMP2, COMP4 or COMP5 output connected to TIM3 OCREF Clear COMP_OUTPUT_TIM8OCREFCLR COMP4, COMP5, COMP6 or COMP7 output connected to TIM8 OCREF Clear COMP_OUTPUT_TIM1IC1 COMP1 or COMP2 output connected to TIM1 Input Capture 1 COMP_OUTPUT_TIM2IC4 COMP1 or COMP2 output connected to TIM2 Input Capture 4 COMP_OUTPUT_TIM3IC1 COMP1 or COMP2 output connected to TIM3 Input Capture 1 COMP_OUTPUT_TIM4IC1 COMP3 output connected to TIM4 Input Capture 1 COMP_OUTPUT_TIM3IC2 COMP3 output connected to TIM3 Input Capture 2 COMP_OUTPUT_TIM15IC1 COMP3 output connected to TIM15 Input Capture 1 COMP_OUTPUT_TIM15BKIN COMP3 output connected to TIM15 Break DOCID026526 Rev 4 UM1786 Input (BKIN) COMP_OUTPUT_TIM3IC3 COMP4 output connected to TIM3 Input Capture 3 COMP_OUTPUT_TIM15IC2 COMP4 output connected to TIM15 Input Capture 2 COMP_OUTPUT_TIM4IC2 COMP4 output connected to TIM4 Input Capture 2 COMP_OUTPUT_TIM15OCREFCLR COMP4 output connected to TIM15 OCREF Clear COMP_OUTPUT_TIM2IC1 COMP5 output connected to TIM2 Input Capture 1 COMP_OUTPUT_TIM17IC1 COMP5 output connected to TIM17 Input Capture 1 COMP_OUTPUT_TIM4IC3 COMP5 output connected to TIM4 Input Capture 3 COMP_OUTPUT_TIM16BKIN COMP5 output connected to TIM16 Break Input (BKIN) COMP_OUTPUT_TIM2IC2 COMP6 output connected to TIM2 Input Capture 2 COMP_OUTPUT_COMP6_TIM2OCREFCLR COMP6 output connected to TIM2 OCREF Clear COMP_OUTPUT_TIM16OCREFCLR COMP6 output connected to TIM16 OCREF Clear COMP_OUTPUT_TIM16IC1 COMP6 output connected to TIM16 Input Capture 1 COMP_OUTPUT_TIM4IC4 COMP6 output connected to TIM4 Input Capture 4 COMP_OUTPUT_TIM2IC3 COMP7 output connected to TIM2 Input Capture 3 COMP_OUTPUT_TIM1IC2 COMP7 output connected to TIM1 Input Capture 2 COMP_OUTPUT_TIM17OCREFCLR COMP7 output connected to TIM17 OCREF Clear COMP_OUTPUT_TIM17BKIN COMP7 output connected to TIM17 Break Input (BKIN) COMP Extended WindowMode (STM32F302xC/STM32F303xC/STM32F358xx Product devices) COMP_WINDOWMODE_DISABLE Window mode disabled COMP_WINDOWMODE_ENABLE Window mode enabled: non inverting input of comparator X (x=2,4,6) is connected to the non inverting input of comparator X-1 DOCID026526 Rev 4 167/832 UM1786 10 HAL CORTEX Generic Driver 10.1 CORTEX Firmware driver registers structures 10.1.1 MPU_Region_InitTypeDef Data Fields uint8_t Enable uint8_t Number uint32_t BaseAddress uint8_t Size uint8_t SubRegionDisable uint8_t TypeExtField uint8_t AccessPermission uint8_t DisableExec uint8_t IsShareable uint8_t IsCacheable uint8_t IsBufferable Field Documentation 168/832 uint8_t MPU_Region_InitTypeDef::Enable Specifies the status of the region. This parameter can be a value of CORTEX_MPU_Region_Enable uint8_t MPU_Region_InitTypeDef::Number Specifies the number of the region to protect. This parameter can be a value of CORTEX_MPU_Region_Number uint32_t MPU_Region_InitTypeDef::BaseAddress Specifies the base address of the region to protect. uint8_t MPU_Region_InitTypeDef::Size Specifies the size of the region to protect. This parameter can be a value of CORTEX_MPU_Region_Size uint8_t MPU_Region_InitTypeDef::SubRegionDisable Specifies the number of the subregion protection to disable. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF uint8_t MPU_Region_InitTypeDef::TypeExtField Specifies the TEX field level. This parameter can be a value of CORTEX_MPU_TEX_Levels uint8_t MPU_Region_InitTypeDef::AccessPermission Specifies the region access permission type. This parameter can be a value of CORTEX_MPU_Region_Permission_Attributes uint8_t MPU_Region_InitTypeDef::DisableExec Specifies the instruction access status. This parameter can be a value of CORTEX_MPU_Instruction_Access uint8_t MPU_Region_InitTypeDef::IsShareable Specifies the shareability status of the protected region. This parameter can be a value of CORTEX_MPU_Access_Shareable DOCID026526 Rev 4 UM1786 uint8_t MPU_Region_InitTypeDef::IsCacheable Specifies the cacheable status of the region protected. This parameter can be a value of CORTEX_MPU_Access_Cacheable uint8_t MPU_Region_InitTypeDef::IsBufferable Specifies the bufferable status of the protected region. This parameter can be a value of CORTEX_MPU_Access_Bufferable 10.2 CORTEX Firmware driver API description 10.2.1 How to use this driver How to configure Interrupts using CORTEX HAL driver This section provides functions allowing to configure the NVIC interrupts (IRQ). The Cortex-M4 exceptions are managed by CMSIS functions. 1. 2. 3. Configure the NVIC Priority Grouping using HAL_NVIC_SetPriorityGrouping() function according to the following table. @brief CORTEX_NVIC_Priority_Table The table below gives the allowed values of the pre-emption priority and subpriority according to the Priority Grouping configuration performed by HAL_NVIC_SetPriorityGrouping() function. Configure the priority of the selected IRQ Channels using HAL_NVIC_SetPriority() Enable the selected IRQ Channels using HAL_NVIC_EnableIRQ() When the NVIC_PRIORITYGROUP_0 is selected, IRQ pre-emption is no more possible. The pending IRQ priority will be managed only by the sub priority. IRQ priority order (sorted by highest to lowest priority): Lowest pre-emption priority Lowest sub priority Lowest hardware priority (IRQ number) How to configure Systick using CORTEX HAL driver Setup SysTick Timer for time base The HAL_SYSTICK_Config()function calls the SysTick_Config() function which is a CMSIS function that: Configures the SysTick Reload register with value passed as function parameter. Configures the SysTick IRQ priority to the lowest value (0x0F). Resets the SysTick Counter register. Configures the SysTick Counter clock source to be Core Clock Source (HCLK). Enables the SysTick Interrupt. Starts the SysTick Counter. You can change the SysTick Clock source to be HCLK_Div8 by calling the macro __HAL_CORTEX_SYSTICKCLK_CONFIG(SYSTICK_CLKSOURCE_HCLK_DIV8) just after the HAL_SYSTICK_Config() function call. The __HAL_CORTEX_SYSTICKCLK_CONFIG() macro is defined inside the stm32f3xx_hal_cortex.h file. You can change the SysTick IRQ priority by calling the HAL_NVIC_SetPriority(SysTick_IRQn,...) function just after the HAL_SYSTICK_Config() function call. The HAL_NVIC_SetPriority() call the NVIC_SetPriority() function which is a CMSIS function. To adjust the SysTick time base, use the following formula: Reload Value = SysTick Counter Clock (Hz) x Desired Time base (s) DOCID026526 Rev 4 169/832 UM1786 10.2.2 Reload Value is the parameter to be passed for HAL_SYSTICK_Config() function Reload Value should not exceed 0xFFFFFF Initialization and de-initialization functions This section provides the CORTEX HAL driver functions allowing to configure Interrupts Systick functionalities This section contains the following APIs: 10.2.3 HAL_NVIC_SetPriorityGrouping() HAL_NVIC_SetPriority() HAL_NVIC_EnableIRQ() HAL_NVIC_DisableIRQ() HAL_NVIC_SystemReset() HAL_SYSTICK_Config() Peripheral Control functions This subsection provides a set of functions allowing to control the CORTEX (NVIC, SYSTICK, MPU) functionalities. This section contains the following APIs: 10.2.4 HAL_MPU_ConfigRegion() HAL_NVIC_GetPriorityGrouping() HAL_NVIC_GetPriority() HAL_NVIC_SetPendingIRQ() HAL_NVIC_GetPendingIRQ() HAL_NVIC_ClearPendingIRQ() HAL_NVIC_GetActive() HAL_SYSTICK_CLKSourceConfig() HAL_SYSTICK_IRQHandler() HAL_SYSTICK_Callback() Detailed description of functions HAL_NVIC_SetPriorityGrouping 170/832 Function Name void HAL_NVIC_SetPriorityGrouping (uint32_t PriorityGroup) Function Description Sets the priority grouping field (pre-emption priority and subpriority) using the required unlock sequence. Parameters PriorityGroup: The priority grouping bits length. This parameter can be one of the following values: NVIC_PRIORITYGROUP_0: 0 bits for pre-emption priority 4 bits for subpriority NVIC_PRIORITYGROUP_1: 1 bits for pre-emption priority 3 bits for subpriority NVIC_PRIORITYGROUP_2: 2 bits for pre-emption priority 2 bits for subpriority NVIC_PRIORITYGROUP_3: 3 bits for pre-emption priority 1 bits for subpriority NVIC_PRIORITYGROUP_4: 4 bits for pre-emption priority 0 bits for subpriority DOCID026526 Rev 4 UM1786 Return values None: Notes When the NVIC_PriorityGroup_0 is selected, IRQ pre-emption is no more possible. The pending IRQ priority will be managed only by the subpriority. HAL_NVIC_SetPriority Function Name void HAL_NVIC_SetPriority (IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority) Function Description Sets the priority of an interrupt. Parameters Return values IRQn: External interrupt number This parameter can be an enumerator of IRQn_Type enumeration (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32f3xxxx.h)) PreemptPriority: The pre-emption priority for the IRQn channel. This parameter can be a value between 0 and 15 as described in the table CORTEX_NVIC_Priority_Table A lower priority value indicates a higher priority SubPriority: the subpriority level for the IRQ channel. This parameter can be a value between 0 and 15 as described in the table CORTEX_NVIC_Priority_Table A lower priority value indicates a higher priority. None: HAL_NVIC_EnableIRQ Function Name void HAL_NVIC_EnableIRQ (IRQn_Type IRQn) Function Description Enables a device specific interrupt in the NVIC interrupt controller. Parameters IRQn: External interrupt number This parameter can be an enumerator of IRQn_Type enumeration (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32f3xxxx.h)) Return values None: Notes To configure interrupts priority correctly, the NVIC_PriorityGroupConfig() function should be called before. HAL_NVIC_DisableIRQ Function Name void HAL_NVIC_DisableIRQ (IRQn_Type IRQn) Function Description Disables a device specific interrupt in the NVIC interrupt controller. Parameters IRQn: External interrupt number This parameter can be an enumerator of IRQn_Type enumeration (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32f3xxxx.h)) Return values None: DOCID026526 Rev 4 171/832 UM1786 HAL_NVIC_SystemReset Function Name void HAL_NVIC_SystemReset (void ) Function Description Initiates a system reset request to reset the MCU. Return values None: HAL_SYSTICK_Config Function Name uint32_t HAL_SYSTICK_Config (uint32_t TicksNumb) Function Description Initializes the System Timer and its interrupt, and starts the System Tick Timer. Parameters TicksNumb: Specifies the ticks Number of ticks between two interrupts. Return values status: - 0 Function succeeded. 1 Function failed. HAL_MPU_ConfigRegion Function Name void HAL_MPU_ConfigRegion (MPU_Region_InitTypeDef * MPU_Init) Function Description Initializes and configures the Region and the memory to be protected. Parameters MPU_Init: Pointer to a MPU_Region_InitTypeDef structure that contains the initialization and configuration information. Return values None: HAL_NVIC_GetPriorityGrouping Function Name uint32_t HAL_NVIC_GetPriorityGrouping (void ) Function Description Gets the priority grouping field from the NVIC Interrupt Controller. Return values Priority: grouping field (SCB->AIRCR [10:8] PRIGROUP field) HAL_NVIC_GetPriority Function Name void HAL_NVIC_GetPriority (IRQn_Type IRQn, uint32_t PriorityGroup, uint32_t * pPreemptPriority, uint32_t * pSubPriority) Function Description Gets the priority of an interrupt. Parameters 172/832 IRQn: External interrupt number This parameter can be an enumerator of IRQn_Type enumeration (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32f3xxxx.h)) PriorityGroup: the priority grouping bits length. This parameter can be one of the following values: NVIC_PRIORITYGROUP_0: 0 bits for pre-emption priority 4 bits for subpriority NVIC_PRIORITYGROUP_1: 1 bits for pre-emption DOCID026526 Rev 4 UM1786 priority 3 bits for subpriority NVIC_PRIORITYGROUP_2: 2 bits for pre-emption priority 2 bits for subpriority NVIC_PRIORITYGROUP_3: 3 bits for pre-emption priority 1 bits for subpriority NVIC_PRIORITYGROUP_4: 4 bits for pre-emption priority 0 bits for subpriority pPreemptPriority: Pointer on the Preemptive priority value (starting from 0). pSubPriority: Pointer on the Subpriority value (starting from 0). Return values None: HAL_NVIC_GetPendingIRQ Function Name uint32_t HAL_NVIC_GetPendingIRQ (IRQn_Type IRQn) Function Description Gets Pending Interrupt (reads the pending register in the NVIC and returns the pending bit for the specified interrupt). Parameters IRQn: External interrupt number This parameter can be an enumerator of IRQn_Type enumeration (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32f3xxxx.h)) Return values status: - 0 Interrupt status is not pending. 1 Interrupt status is pending. HAL_NVIC_SetPendingIRQ Function Name void HAL_NVIC_SetPendingIRQ (IRQn_Type IRQn) Function Description Sets Pending bit of an external interrupt. Parameters IRQn: External interrupt number This parameter can be an enumerator of IRQn_Type enumeration (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32f3xxxx.h)) Return values None: HAL_NVIC_ClearPendingIRQ Function Name void HAL_NVIC_ClearPendingIRQ (IRQn_Type IRQn) Function Description Clears the pending bit of an external interrupt. Parameters IRQn: External interrupt number This parameter can be an enumerator of IRQn_Type enumeration (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32f3xxxx.h)) Return values None: HAL_NVIC_GetActive Function Name uint32_t HAL_NVIC_GetActive (IRQn_Type IRQn) DOCID026526 Rev 4 173/832 Function Description UM1786 Gets active interrupt ( reads the active register in NVIC and returns the active bit). Parameters IRQn: External interrupt number This parameter can be an enumerator of IRQn_Type enumeration (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32f3xxxx.h)) Return values status: - 0 Interrupt status is not pending. 1 Interrupt status is pending. HAL_SYSTICK_CLKSourceConfig Function Name void HAL_SYSTICK_CLKSourceConfig (uint32_t CLKSource) Function Description Configures the SysTick clock source. Parameters CLKSource: specifies the SysTick clock source. This parameter can be one of the following values: SYSTICK_CLKSOURCE_HCLK_DIV8: AHB clock divided by 8 selected as SysTick clock source. SYSTICK_CLKSOURCE_HCLK: AHB clock selected as SysTick clock source. Return values None: HAL_SYSTICK_IRQHandler Function Name void HAL_SYSTICK_IRQHandler (void ) Function Description This function handles SYSTICK interrupt request. Return values None: HAL_SYSTICK_Callback Function Name void HAL_SYSTICK_Callback (void ) Function Description SYSTICK callback. Return values None: HAL_MPU_Disable Function Name __STATIC_INLINE void HAL_MPU_Disable (void ) Function Description Disables the MPU. Return values None: HAL_MPU_Enable 174/832 Function Name __STATIC_INLINE void HAL_MPU_Enable (uint32_t MPU_Control) Function Description Enables the MPU. Parameters MPU_Control: Specifies the control mode of the MPU during hard fault, NMI, FAULTMASK and privileged access to the default memory This parameter can be one of the following DOCID026526 Rev 4 UM1786 values: MPU_HFNMI_PRIVDEF_NONE MPU_HARDFAULT_NMI MPU_PRIVILEGED_DEFAULT MPU_HFNMI_PRIVDEF Return values None: 10.3 CORTEX Firmware driver defines 10.3.1 CORTEX CORTEX MPU Instruction Access Bufferable MPU_ACCESS_BUFFERABLE MPU_ACCESS_NOT_BUFFERABLE CORTEX MPU Instruction Access Cacheable MPU_ACCESS_CACHEABLE MPU_ACCESS_NOT_CACHEABLE CORTEX MPU Instruction Access Shareable MPU_ACCESS_SHAREABLE MPU_ACCESS_NOT_SHAREABLE MPU HFNMI and PRIVILEGED Access control MPU_HFNMI_PRIVDEF_NONE MPU_HARDFAULT_NMI MPU_PRIVILEGED_DEFAULT MPU_HFNMI_PRIVDEF CORTEX MPU Instruction Access MPU_INSTRUCTION_ACCESS_ENABLE MPU_INSTRUCTION_ACCESS_DISABLE CORTEX MPU Region Enable MPU_REGION_ENABLE MPU_REGION_DISABLE CORTEX MPU Region Number MPU_REGION_NUMBER0 MPU_REGION_NUMBER1 MPU_REGION_NUMBER2 MPU_REGION_NUMBER3 MPU_REGION_NUMBER4 MPU_REGION_NUMBER5 MPU_REGION_NUMBER6 DOCID026526 Rev 4 175/832 UM1786 MPU_REGION_NUMBER7 CORTEX MPU Region Permission Attributes MPU_REGION_NO_ACCESS MPU_REGION_PRIV_RW MPU_REGION_PRIV_RW_URO MPU_REGION_FULL_ACCESS MPU_REGION_PRIV_RO MPU_REGION_PRIV_RO_URO CORTEX MPU Region Size MPU_REGION_SIZE_32B MPU_REGION_SIZE_64B MPU_REGION_SIZE_128B MPU_REGION_SIZE_256B MPU_REGION_SIZE_512B MPU_REGION_SIZE_1KB MPU_REGION_SIZE_2KB MPU_REGION_SIZE_4KB MPU_REGION_SIZE_8KB MPU_REGION_SIZE_16KB MPU_REGION_SIZE_32KB MPU_REGION_SIZE_64KB MPU_REGION_SIZE_128KB MPU_REGION_SIZE_256KB MPU_REGION_SIZE_512KB MPU_REGION_SIZE_1MB MPU_REGION_SIZE_2MB MPU_REGION_SIZE_4MB MPU_REGION_SIZE_8MB MPU_REGION_SIZE_16MB MPU_REGION_SIZE_32MB MPU_REGION_SIZE_64MB MPU_REGION_SIZE_128MB MPU_REGION_SIZE_256MB MPU_REGION_SIZE_512MB MPU_REGION_SIZE_1GB MPU_REGION_SIZE_2GB 176/832 DOCID026526 Rev 4 UM1786 MPU_REGION_SIZE_4GB MPU TEX Levels MPU_TEX_LEVEL0 MPU_TEX_LEVEL1 MPU_TEX_LEVEL2 CORTEX Preemption Priority Group NVIC_PRIORITYGROUP_0 0 bits for pre-emption priority 4 bits for subpriority NVIC_PRIORITYGROUP_1 1 bits for pre-emption priority 3 bits for subpriority NVIC_PRIORITYGROUP_2 2 bits for pre-emption priority 2 bits for subpriority NVIC_PRIORITYGROUP_3 3 bits for pre-emption priority 1 bits for subpriority NVIC_PRIORITYGROUP_4 4 bits for pre-emption priority 0 bits for subpriority CORTEX SysTick clock source SYSTICK_CLKSOURCE_HCLK_DIV8 SYSTICK_CLKSOURCE_HCLK DOCID026526 Rev 4 177/832 UM1786 11 HAL CRC Generic Driver 11.1 CRC Firmware driver registers structures 11.1.1 CRC_InitTypeDef Data Fields uint8_t DefaultPolynomialUse uint8_t DefaultInitValueUse uint32_t GeneratingPolynomial uint32_t CRCLength uint32_t InitValue uint32_t InputDataInversionMode uint32_t OutputDataInversionMode Field Documentation 178/832 uint8_t CRC_InitTypeDef::DefaultPolynomialUse This parameter is a value of CRC_Default_Polynomial and indicates if default polynomial is used. If set to DEFAULT_POLYNOMIAL_ENABLE, resort to default X^32 + X^26 + X^23 + X^22 + X^16 + X^12 + X^11 + X^10 +X^8 + X^7 + X^5 + X^4 + X^2+ X +1. In that case, there is no need to set GeneratingPolynomial field. If otherwise set to DEFAULT_POLYNOMIAL_DISABLE, GeneratingPolynomial and CRCLength fields must be set. uint8_t CRC_InitTypeDef::DefaultInitValueUse This parameter is a value of CRC_Default_InitValue_Use and indicates if default init value is used. If set to DEFAULT_INIT_VALUE_ENABLE, resort to default 0xFFFFFFFF value. In that case, there is no need to set InitValue field. If otherwise set to DEFAULT_INIT_VALUE_DISABLE, InitValue field must be set. uint32_t CRC_InitTypeDef::GeneratingPolynomial Set CRC generating polynomial as a 7, 8, 16 or 32-bit long value for a polynomial degree respectively equal to 7, 8, 16 or 32. This field is written in normal representation, e.g., for a polynomial of degree 7, X^7 + X^6 + X^5 + X^2 + 1 is written 0x65. No need to specify it if DefaultPolynomialUse is set to DEFAULT_POLYNOMIAL_ENABLE. uint32_t CRC_InitTypeDef::CRCLength This parameter is a value of CRC_Polynomial_Sizes and indicates CRC length. Value can be either one of CRC_POLYLENGTH_32B (32-bit CRC), CRC_POLYLENGTH_16B (16-bit CRC), CRC_POLYLENGTH_8B (8-bit CRC), CRC_POLYLENGTH_7B (7-bit CRC). uint32_t CRC_InitTypeDef::InitValue Init value to initiate CRC computation. No need to specify it if DefaultInitValueUse is set to DEFAULT_INIT_VALUE_ENABLE. uint32_t CRC_InitTypeDef::InputDataInversionMode This parameter is a value of CRCEx_Input_Data_Inversion and specifies input data inversion mode. Can be either one of the following values CRC_INPUTDATA_INVERSION_NONE, no input data inversion CRC_INPUTDATA_INVERSION_BYTE, byte-wise inversion, 0x1A2B3C4D becomes 0x58D43CB2 CRC_INPUTDATA_INVERSION_HALFWORD, halfword-wise inversion, DOCID026526 Rev 4 UM1786 11.1.2 0x1A2B3C4D becomes 0xD458B23C CRC_INPUTDATA_INVERSION_WORD, wordwise inversion, 0x1A2B3C4D becomes 0xB23CD458 uint32_t CRC_InitTypeDef::OutputDataInversionMode This parameter is a value of CRCEx_Output_Data_Inversion and specifies output data (i.e. CRC) inversion mode. Can be either CRC_OUTPUTDATA_INVERSION_DISABLE: no CRC inversion, CRC_OUTPUTDATA_INVERSION_ENABLE: CRC 0x11223344 is converted into 0x22CC4488 CRC_HandleTypeDef Data Fields CRC_TypeDef * Instance CRC_InitTypeDef Init HAL_LockTypeDef Lock __IO HAL_CRC_StateTypeDef State uint32_t InputDataFormat Field Documentation CRC_TypeDef* CRC_HandleTypeDef::Instance Register base address CRC_InitTypeDef CRC_HandleTypeDef::Init CRC configuration parameters HAL_LockTypeDef CRC_HandleTypeDef::Lock CRC Locking object __IO HAL_CRC_StateTypeDef CRC_HandleTypeDef::State CRC communication state uint32_t CRC_HandleTypeDef::InputDataFormat This parameter is a value of CRC_Input_Buffer_Format and specifies input data format. Can be either CRC_INPUTDATA_FORMAT_BYTES, input data is a stream of bytes (8-bit data) CRC_INPUTDATA_FORMAT_HALFWORDS, input data is a stream of half-words (16-bit data) CRC_INPUTDATA_FORMAT_WORDS, input data is a stream of words (32-bit data) Note that constant CRC_INPUT_FORMAT_UNDEFINED is defined but an initialization error must occur if InputBufferFormat is not one of the three values listed above 11.2 CRC Firmware driver API description 11.2.1 How to use this driver Enable CRC AHB clock using __HAL_RCC_CRC_CLK_ENABLE(); Initialize CRC calculator specify generating polynomial (IP default or non-default one) specify initialization value (IP default or non-default one) specify input data format specify input or output data inversion mode if any DOCID026526 Rev 4 179/832 UM1786 11.2.2 Use HAL_CRC_Accumulate() function to compute the CRC value of the input data buffer starting with the previously computed CRC as initialization value Use HAL_CRC_Calculate() function to compute the CRC value of the input data buffer starting with the defined initialization value (default or non-default) to initiate CRC calculation Initialization and de-initialization functions This section provides functions allowing to: Initialize the CRC according to the specified parameters in the CRC_InitTypeDef and create the associated handle DeInitialize the CRC peripheral Initialize the CRC MSP (MCU Specific Package) DeInitialize the CRC MSP This section contains the following APIs: 11.2.3 HAL_CRC_Init() HAL_CRC_DeInit() HAL_CRC_MspInit() HAL_CRC_MspDeInit() Peripheral Control functions This section provides functions allowing to: compute the 7, 8, 16 or 32-bit CRC value of an 8, 16 or 32-bit data buffer using the combination of the previous CRC value and the new one or compute the 7, 8, 16 or 32-bit CRC value of an 8, 16 or 32-bit data buffer independently of the previous CRC value. This section contains the following APIs: 11.2.4 HAL_CRC_Accumulate() HAL_CRC_Calculate() Peripheral State functions This subsection permits to get in run-time the status of the peripheral. This section contains the following APIs: 11.2.5 HAL_CRC_GetState() Detailed description of functions HAL_CRC_Init 180/832 Function Name HAL_StatusTypeDef HAL_CRC_Init (CRC_HandleTypeDef * hcrc) Function Description Initialize the CRC according to the specified parameters in the CRC_InitTypeDef and initialize the associated handle. Parameters hcrc: CRC handle Return values HAL: status DOCID026526 Rev 4 UM1786 HAL_CRC_DeInit Function Name HAL_StatusTypeDef HAL_CRC_DeInit (CRC_HandleTypeDef * hcrc) Function Description DeInitialize the CRC peripheral. Parameters hcrc: CRC handle Return values HAL: status HAL_CRC_MspInit Function Name void HAL_CRC_MspInit (CRC_HandleTypeDef * hcrc) Function Description Initializes the CRC MSP. Parameters hcrc: CRC handle Return values None: HAL_CRC_MspDeInit Function Name void HAL_CRC_MspDeInit (CRC_HandleTypeDef * hcrc) Function Description DeInitialize the CRC MSP. Parameters hcrc: CRC handle Return values None: HAL_CRC_Accumulate Function Name uint32_t HAL_CRC_Accumulate (CRC_HandleTypeDef * hcrc, uint32_t pBuffer, uint32_t BufferLength) Function Description Compute the 7, 8, 16 or 32-bit CRC value of an 8, 16 or 32-bit data buffer starting with the previously computed CRC as initialization value. Parameters hcrc: CRC handle pBuffer: pointer to the input data buffer, exact input data format is provided by hcrc->InputDataFormat. BufferLength: input data buffer length (number of bytes if pBuffer type is * uint8_t, number of half-words if pBuffer type is * uint16_t, number of words if pBuffer type is * uint32_t). Return values uint32_t: CRC (returned value LSBs for CRC shorter than 32 bits) Notes By default, the API expects a uint32_t pointer as input buffer parameter. Input buffer pointers with other types simply need to be cast in uint32_t and the API will internally adjust its input data processing based on the handle field hcrc>InputDataFormat. HAL_CRC_Calculate Function Name uint32_t HAL_CRC_Calculate (CRC_HandleTypeDef * hcrc, uint32_t pBuffer, uint32_t BufferLength) DOCID026526 Rev 4 181/832 Function Description Parameters UM1786 Compute the 7, 8, 16 or 32-bit CRC value of an 8, 16 or 32-bit data buffer starting with hcrc->Instance->INIT as initialization value. hcrc: CRC handle pBuffer: pointer to the input data buffer, exact input data format is provided by hcrc->InputDataFormat. BufferLength: input data buffer length (number of bytes if pBuffer type is * uint8_t, number of half-words if pBuffer type is * uint16_t, number of words if pBuffer type is * uint32_t). Return values uint32_t: CRC (returned value LSBs for CRC shorter than 32 bits) Notes By default, the API expects a uint32_t pointer as input buffer parameter. Input buffer pointers with other types simply need to be cast in uint32_t and the API will internally adjust its input data processing based on the handle field hcrc>InputDataFormat. HAL_CRC_GetState Function Name HAL_CRC_StateTypeDef HAL_CRC_GetState (CRC_HandleTypeDef * hcrc) Function Description Return the CRC handle state. Parameters hcrc: CRC handle Return values HAL: state 11.3 CRC Firmware driver defines 11.3.1 CRC Default CRC computation initialization value DEFAULT_CRC_INITVALUE Initial CRC default value Indicates whether or not default init value is used DEFAULT_INIT_VALUE_ENABLE Enable initial CRC default value DEFAULT_INIT_VALUE_DISABLE Disable initial CRC default value Indicates whether or not default polynomial is used DEFAULT_POLYNOMIAL_ENABLE Enable default generating polynomial 0x04C11DB7 DEFAULT_POLYNOMIAL_DISABLE Disable default generating polynomial 0x04C11DB7 Default CRC generating polynomial DEFAULT_CRC32_POLY X^32 + X^26 + X^23 + X^22 + X^16 + X^12 + X^11 + X^10 +X^8 + X^7 + X^5 + X^4 + X^2+ X +1 CRC Exported Macros __HAL_CRC_RESET_HANDLE_STATE Description: Reset CRC handle state. Parameters: 182/832 DOCID026526 Rev 4 UM1786 __HANDLE__: CRC handle. Return value: None Description: __HAL_CRC_DR_RESET Reset CRC Data Register. Parameters: __HANDLE__: CRC handle Return value: __HAL_CRC_INITIALCRCVALUE_CONFIG None Description: Set CRC INIT non-default value. Parameters: __HANDLE__: CRC handle __INIT__: 32-bit initial value Return value: None Description: __HAL_CRC_SET_IDR Store a 8-bit data in the Independent Data(ID) register. Parameters: __HANDLE__: CRC handle __VALUE__: 8-bit value to be stored in the ID register Return value: None Description: __HAL_CRC_GET_IDR Return the 8-bit data stored in the Independent Data(ID) register. Parameters: __HANDLE__: CRC handle Return value: 8-bit: value of the ID register Input Buffer Format CRC_INPUTDATA_FORMAT_UNDEFINED Undefined input data format CRC_INPUTDATA_FORMAT_BYTES Input data in byte format CRC_INPUTDATA_FORMAT_HALFWORDS Input data in half-word format CRC_INPUTDATA_FORMAT_WORDS Input data in word format Polynomial sizes to configure the IP DOCID026526 Rev 4 183/832 UM1786 CRC_POLYLENGTH_32B Resort to a 32-bit long generating polynomial CRC_POLYLENGTH_16B Resort to a 16-bit long generating polynomial CRC_POLYLENGTH_8B Resort to a 8-bit long generating polynomial CRC_POLYLENGTH_7B Resort to a 7-bit long generating polynomial CRC polynomial possible sizes actual definitions 184/832 HAL_CRC_LENGTH_32B 32-bit long CRC HAL_CRC_LENGTH_16B 16-bit long CRC HAL_CRC_LENGTH_8B 8-bit long CRC HAL_CRC_LENGTH_7B 7-bit long CRC DOCID026526 Rev 4 UM1786 12 HAL CRC Extension Driver 12.1 CRCEx Firmware driver API description 12.1.1 How to use this driver 12.1.2 Set user-defined generating polynomial thru HAL_CRCEx_Polynomial_Set() Configure Input or Output data inversion Detailed description of functions HAL_CRCEx_Polynomial_Set Function Name HAL_StatusTypeDef HAL_CRCEx_Polynomial_Set (CRC_HandleTypeDef * hcrc, uint32_t Pol, uint32_t PolyLength) Function Description Initialize the CRC polynomial if different from default one. Parameters Return values hcrc: CRC handle Pol: CRC generating polynomial (7, 8, 16 or 32-bit long). This parameter is written in normal representation, e.g. for a polynomial of degree 7, X^7 + X^6 + X^5 + X^2 + 1 is written 0x65 for a polynomial of degree 16, X^16 + X^12 + X^5 + 1 is written 0x1021 PolyLength: CRC polynomial length. This parameter can be one of the following values: CRC_POLYLENGTH_7B: 7-bit long CRC (generating polynomial of degree 7) CRC_POLYLENGTH_8B: 8-bit long CRC (generating polynomial of degree 8) CRC_POLYLENGTH_16B: 16-bit long CRC (generating polynomial of degree 16) CRC_POLYLENGTH_32B: 32-bit long CRC (generating polynomial of degree 32) HAL: status HAL_CRCEx_Input_Data_Reverse Function Name HAL_StatusTypeDef HAL_CRCEx_Input_Data_Reverse (CRC_HandleTypeDef * hcrc, uint32_t InputReverseMode) Function Description Set the Reverse Input data mode. Parameters hcrc: CRC handle InputReverseMode: Input Data inversion mode. This parameter can be one of the following values: CRC_INPUTDATA_NOINVERSION: no change in bit order (default value) CRC_INPUTDATA_INVERSION_BYTE: Byte-wise bit reversal DOCID026526 Rev 4 185/832 UM1786 Return values CRC_INPUTDATA_INVERSION_HALFWORD: HalfWord-wise bit reversal CRC_INPUTDATA_INVERSION_WORD: Word-wise bit reversal HAL: status HAL_CRCEx_Output_Data_Reverse Function Name HAL_StatusTypeDef HAL_CRCEx_Output_Data_Reverse (CRC_HandleTypeDef * hcrc, uint32_t OutputReverseMode) Function Description Set the Reverse Output data mode. Parameters hcrc: CRC handle OutputReverseMode: Output Data inversion mode. This parameter can be one of the following values: CRC_OUTPUTDATA_INVERSION_DISABLE: no CRC inversion (default value) CRC_OUTPUTDATA_INVERSION_ENABLE: bit-level inversion (e.g. for a 8-bit CRC: 0xB5 becomes 0xAD) Return values HAL: status 12.2 CRCEx Firmware driver defines 12.2.1 CRCEx CRC Extended Exported Macros __HAL_CRC_OUTPUTREVERSAL_ENABLE Description: Set CRC output reversal. Parameters: __HANDLE__: CRC handle Return value: __HAL_CRC_OUTPUTREVERSAL_DISABLE None. Description: Unset CRC output reversal. Parameters: __HANDLE__: CRC handle Return value: __HAL_CRC_POLYNOMIAL_CONFIG None. Description: Set CRC non-default polynomial. Parameters: 186/832 DOCID026526 Rev 4 __HANDLE__: CRC handle __POLYNOMIAL__: 7, 8, 16 or 32-bit polynomial UM1786 Return value: None. CRC Extended Input Data Inversion Modes CRC_INPUTDATA_INVERSION_NONE No input data inversion CRC_INPUTDATA_INVERSION_BYTE Byte-wise input data inversion CRC_INPUTDATA_INVERSION_HALFWORD HalfWord-wise input data inversion CRC_INPUTDATA_INVERSION_WORD Word-wise input data inversion CRC Extended Output Data Inversion Modes CRC_OUTPUTDATA_INVERSION_DISABLE No output data inversion CRC_OUTPUTDATA_INVERSION_ENABLE Bit-wise output data inversion DOCID026526 Rev 4 187/832 UM1786 13 HAL DAC Generic Driver 13.1 DAC Firmware driver registers structures 13.1.1 DAC_ChannelConfTypeDef Data Fields uint32_t DAC_Trigger uint32_t DAC_OutputBuffer uint32_t DAC_OutputSwitch Field Documentation 13.1.2 uint32_t DAC_ChannelConfTypeDef::DAC_Trigger Specifies the external trigger for the selected DAC channel. This parameter can be a value of DACEx_trigger_selection uint32_t DAC_ChannelConfTypeDef::DAC_OutputBuffer Specifies whether the DAC channel output buffer is enabled or disabled. This parameter can be a value of DAC_output_buffer For a given DAC channel, is this paramater applies then DAC_OutputSwitch does not apply uint32_t DAC_ChannelConfTypeDef::DAC_OutputSwitch Specifies whether the DAC channel output switch is enabled or disabled. This parameter can be a value of DAC_OutputSwitch For a given DAC channel, is this paramater applies then DAC_OutputBuffer does not apply __DAC_HandleTypeDef Data Fields DAC_TypeDef * Instance __IO HAL_DAC_StateTypeDef State HAL_LockTypeDef Lock DMA_HandleTypeDef * DMA_Handle1 DMA_HandleTypeDef * DMA_Handle2 __IO uint32_t ErrorCode Field Documentation 188/832 DAC_TypeDef* __DAC_HandleTypeDef::Instance Register base address __IO HAL_DAC_StateTypeDef __DAC_HandleTypeDef::State DAC communication state HAL_LockTypeDef __DAC_HandleTypeDef::Lock DAC locking object DMA_HandleTypeDef* __DAC_HandleTypeDef::DMA_Handle1 Pointer DMA handler for channel 1 DOCID026526 Rev 4 UM1786 DMA_HandleTypeDef* __DAC_HandleTypeDef::DMA_Handle2 Pointer DMA handler for channel 2 __IO uint32_t __DAC_HandleTypeDef::ErrorCode DAC Error code 13.2 DAC Firmware driver API description 13.2.1 DAC Peripheral features DAC Channels The device integrates up to 3 12-bit Digital Analog Converters that can be used independently or simultaneously (dual mode): 1. 2. 3. DAC1 channel1 with DAC1_OUT1 (PA4) as output DAC1 channel2 with DAC1_OUT2 (PA5) as output (for STM32F3 devices having 2 channels on DAC1) DAC2 channel1 with DAC2_OUT1 (PA6) as output (for STM32F3 devices having 2 DAC) DAC Triggers Digital to Analog conversion can be non-triggered using DAC_TRIGGER_NONE and DAC1_OUT1/DAC1_OUT2/DAC2_OUT1 is available once writing to DHRx register. Digital to Analog conversion can be triggered by: 1. 2. 3. External event: EXTI Line 9 (any GPIOx_PIN_9) using DAC_TRIGGER_EXT_IT9. The used pin (GPIOx_PIN_9) must be configured in input mode. Timers TRGO: TIM2, TIM4, TIM5, TIM6, TIM7 and TIM8 (DAC_TRIGGER_T2_TRGO, DAC_TRIGGER_T4_TRGO...) Software using DAC_TRIGGER_SOFTWARE DAC Buffer mode feature Each DAC channel integrates an output buffer that can be used to reduce the output impedance, and to drive external loads directly without having to add an external operational amplifier. To enable, the output buffer use sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE; Or An output switch (in STM32F303x4, STM32F303x6, STM32F303x8 c, STM32F334x6, STM32F334x8 & STM32F334xx). To enable, the output switch sConfig.DAC_OutputSwitch = DAC_OUTPUTSWITCH_ENABLE; Refer to the device datasheet for more details about output impedance value with and without output buffer. GPIO configurations guidelines When a DAC channel is used (ex channel1 on PA4) and the other is not (ex channel2 on PA5 is configured in Analog and disabled). Channel1 may disturb channel2 as coupling effect. Note that there is no coupling on channel2 as soon as channel2 is turned on. Coupling on adjacent channel could be avoided as follows: when unused PA5 is configured as INPUT PULL-UP or DOWN. PA5 is configured in ANALOG just before it is turned on. DOCID026526 Rev 4 189/832 UM1786 DAC wave generation feature Both DAC channels of DAC1 can be used to generate note that wave generation is not available in DAC2. 1. 2. Noise wave Triangle wave Wave generation is NOT available in DAC2. DAC data format The DAC data format can be: 1. 2. 3. 8-bit right alignment using DAC_ALIGN_8B_R 12-bit left alignment using DAC_ALIGN_12B_L 12-bit right alignment using DAC_ALIGN_12B_R DAC data value to voltage correspondance The analog output voltage on each DAC channel pin is determined by the following equation: DAC_OUTx = VREF+ * DOR / 4095 with DOR is the Data Output Register VEF+ is the input voltage reference (refer to the device datasheet) e.g. To set DAC_OUT1 to 0.7V, use Assuming that VREF+ = 3.3V, DAC_OUT1 = (3.3 * 868) / 4095 = 0.7V DMA requests A DMA1 or DMA2 request can be generated when an external trigger (but not a software trigger) occurs if DMA1 or DMA2 requests are enabled using HAL_DAC_Start_DMA(). For Dual mode and specific signal (Triangle and noise) generation please refer to Extended Features Driver description 13.2.2 How to use this driver DAC APB clock must be enabled to get write access to DAC registers using HAL_DAC_Init() Configure DAC_OUTx (DAC_OUT1: PA4, DAC_OUT2: PA5) in analog mode. Configure the DAC channel using HAL_DAC_ConfigChannel() function. Enable the DAC channel using HAL_DAC_Start() or HAL_DAC_Start_DMA() functions Polling mode IO operation 190/832 Start the DAC peripheral using HAL_DAC_Start() To read the DAC last data output value, use the HAL_DAC_GetValue() function. Stop the DAC peripheral using HAL_DAC_Stop() DOCID026526 Rev 4 UM1786 DMA mode IO operation Start the DAC peripheral using HAL_DAC_Start_DMA(), at this stage the user specify the length of data to be transferred at each end of conversion At the middle of data transfer HAL_DAC_ConvHalfCpltCallbackCh1() or HAL_DACEx_ConvHalfCpltCallbackCh2() function is executed and user can add his own code by customization of function pointer HAL_DAC_ConvHalfCpltCallbackCh1() or HAL_DACEx_ConvHalfCpltCallbackCh2() At The end of data transfer HAL_DAC_ConvCpltCallbackCh1() or HAL_DACEx_ConvHalfCpltCallbackCh2() function is executed and user can add his own code by customization of function pointer HAL_DAC_ConvCpltCallbackCh1() or HAL_DACEx_ConvHalfCpltCallbackCh2() In case of transfer Error, HAL_DAC_ErrorCallbackCh1() function is executed and user can add his own code by customization of function pointer HAL_DAC_ErrorCallbackCh1 In case of DMA underrun, DAC interruption triggers and execute internal function HAL_DAC_IRQHandler. HAL_DAC_DMAUnderrunCallbackCh1() or HAL_DACEx_DMAUnderrunCallbackCh2() function is executed and user can add his own code by customization of function pointer HAL_DAC_DMAUnderrunCallbackCh1() or HAL_DACEx_DMAUnderrunCallbackCh2() and add his own code by customization of function pointer HAL_DAC_ErrorCallbackCh1() Stop the DAC peripheral using HAL_DAC_Stop_DMA() DAC HAL driver macros list Below the list of most used macros in DAC HAL driver. __HAL_DAC_ENABLE : Enable the DAC peripheral __HAL_DAC_DISABLE : Disable the DAC peripheral __HAL_DAC_CLEAR_FLAG: Clear the DAC's pending flags __HAL_DAC_GET_FLAG: Get the selected DAC's flag status You can refer to the DAC HAL driver header file for more useful macros 13.2.3 Initialization and de-initialization functions This section provides functions allowing to: Initialize and configure the DAC. De-initialize the DAC. This section contains the following APIs: 13.2.4 HAL_DAC_Init() HAL_DAC_DeInit() HAL_DAC_MspInit() HAL_DAC_MspDeInit() IO operation functions This section provides functions allowing to: DOCID026526 Rev 4 191/832 UM1786 Start conversion. Stop conversion. Start conversion and enable DMA transfer. Stop conversion and disable DMA transfer. Get result of conversion. Get result of dual mode conversion. This section contains the following APIs: 13.2.5 HAL_DAC_Start() HAL_DAC_Stop() HAL_DAC_Stop_DMA() HAL_DAC_GetValue() HAL_DACEx_DualGetValue() HAL_DAC_ConvCpltCallbackCh1() HAL_DAC_ConvHalfCpltCallbackCh1() HAL_DAC_ErrorCallbackCh1() HAL_DAC_DMAUnderrunCallbackCh1() HAL_DAC_Start_DMA() HAL_DAC_ConfigChannel() HAL_DAC_IRQHandler() Peripheral Control functions This section provides functions allowing to: Configure channels. Configure Triangle wave generation. Configure Noise wave generation. Set the specified data holding register value for DAC channel. Set the specified data holding register value for Dual DAC channels. This section contains the following APIs: 13.2.6 HAL_DAC_ConfigChannel() HAL_DAC_SetValue() HAL_DACEx_DualSetValue() DAC Peripheral State and Error functions This subsection provides functions allowing to Check the DAC state. Check the DAC Errors. This section contains the following APIs: 13.2.7 HAL_DAC_GetState() HAL_DAC_GetError() Detailed description of functions HAL_DAC_Init 192/832 Function Name HAL_StatusTypeDef HAL_DAC_Init (DAC_HandleTypeDef * hdac) Function Description Initialize the DAC peripheral according to the specified parameters in the DAC_InitStruct and initialize the associated handle. DOCID026526 Rev 4 UM1786 Parameters hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. Return values HAL: status HAL_DAC_DeInit Function Name HAL_StatusTypeDef HAL_DAC_DeInit (DAC_HandleTypeDef * hdac) Function Description Deinitialize the DAC peripheral registers to their default reset values. Parameters hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. Return values HAL: status HAL_DAC_MspInit Function Name void HAL_DAC_MspInit (DAC_HandleTypeDef * hdac) Function Description Initialize the DAC MSP. Parameters hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. Return values None: HAL_DAC_MspDeInit Function Name void HAL_DAC_MspDeInit (DAC_HandleTypeDef * hdac) Function Description DeInitialize the DAC MSP. Parameters hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. Return values None: HAL_DAC_Start Function Name HAL_StatusTypeDef HAL_DAC_Start (DAC_HandleTypeDef * hdac, uint32_t Channel) Function Description Enables DAC and starts conversion of channel. Parameters Return values hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. Channel: The selected DAC channel. This parameter can be one of the following values: DAC_CHANNEL_1: DAC1 Channel1 selected DAC_CHANNEL_2: DAC1 Channel2 selected DAC_CHANNEL_1: DAC2 Channel1 selected HAL: status DOCID026526 Rev 4 193/832 UM1786 HAL_DAC_Stop Function Name HAL_StatusTypeDef HAL_DAC_Stop (DAC_HandleTypeDef * hdac, uint32_t Channel) Function Description Disables DAC and stop conversion of channel. Parameters Return values hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. Channel: The selected DAC channel. This parameter can be one of the following values: DAC_CHANNEL_1: DAC1 Channel1 selected DAC_CHANNEL_2: DAC1 Channel2 selected DAC_CHANNEL_1: DAC2 Channel1 selected HAL: status HAL_DAC_Start_DMA Function Name HAL_StatusTypeDef HAL_DAC_Start_DMA (DAC_HandleTypeDef * hdac, uint32_t Channel, uint32_t * pData, uint32_t Length, uint32_t Alignment) Function Description Enables DAC and starts conversion of channel. Parameters Return values hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. Channel: The selected DAC channel. This parameter can be one of the following values: DAC_CHANNEL_1: DAC1 Channel1 selected DAC_CHANNEL_2: DAC1 Channel2 selected pData: The destination peripheral Buffer address. Length: The length of data to be transferred from memory to DAC peripheral Alignment: Specifies the data alignment for DAC channel. This parameter can be one of the following values: DAC_ALIGN_8B_R: 8bit right data alignment selected DAC_ALIGN_12B_L: 12bit left data alignment selected DAC_ALIGN_12B_R: 12bit right data alignment selected HAL: status HAL_DAC_Stop_DMA Function Name HAL_StatusTypeDef HAL_DAC_Stop_DMA (DAC_HandleTypeDef * hdac, uint32_t Channel) Function Description Disables DAC and stop conversion of channel. Parameters Return values 194/832 hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. Channel: The selected DAC channel. This parameter can be one of the following values: DAC_CHANNEL_1: DAC1 Channel1 selected DAC_CHANNEL_2: DAC1 Channel2 selected DAC_CHANNEL_1: DAC2 Channel1 selected HAL: status DOCID026526 Rev 4 UM1786 HAL_DAC_GetValue Function Name uint32_t HAL_DAC_GetValue (DAC_HandleTypeDef * hdac, uint32_t Channel) Function Description Returns the last data output value of the selected DAC channel. Parameters Return values hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. Channel: The selected DAC channel. This parameter can be one of the following values: DAC_CHANNEL_1: DAC1 Channel1 selected DAC_CHANNEL_2: DAC1 Channel2 selected DAC_CHANNEL_1: DAC2 Channel1 selected The: selected DAC channel data output value. HAL_DAC_ConfigChannel Function Name HAL_StatusTypeDef HAL_DAC_ConfigChannel (DAC_HandleTypeDef * hdac, DAC_ChannelConfTypeDef * sConfig, uint32_t Channel) Function Description Configures the selected DAC channel. Parameters Return values hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. sConfig: DAC configuration structure. Channel: The selected DAC channel. This parameter can be one of the following values: DAC_CHANNEL_1: DAC1 Channel1 selected DAC_CHANNEL_2: DAC1 Channel2 selected DAC_CHANNEL_1: DAC2 Channel1 selected HAL: status HAL_DAC_IRQHandler Function Name void HAL_DAC_IRQHandler (DAC_HandleTypeDef * hdac) Function Description Handles DAC interrupt request This function uses the interruption of DMA underrun. Parameters hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. Return values None: HAL_DAC_ConvCpltCallbackCh1 Function Name void HAL_DAC_ConvCpltCallbackCh1 (DAC_HandleTypeDef * hdac) Function Description Conversion complete callback in non blocking mode for Channel1. Parameters hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. Return values None: DOCID026526 Rev 4 195/832 UM1786 HAL_DAC_ConvHalfCpltCallbackCh1 Function Name void HAL_DAC_ConvHalfCpltCallbackCh1 (DAC_HandleTypeDef * hdac) Function Description Conversion half DMA transfer callback in non blocking mode for Channel1. Parameters hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. Return values None: HAL_DAC_ErrorCallbackCh1 Function Name void HAL_DAC_ErrorCallbackCh1 (DAC_HandleTypeDef * hdac) Function Description Error DAC callback for Channel1. Parameters hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. Return values None: HAL_DAC_DMAUnderrunCallbackCh1 Function Name void HAL_DAC_DMAUnderrunCallbackCh1 (DAC_HandleTypeDef * hdac) Function Description DMA underrun DAC callback for Channel1. Parameters hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. Return values None: HAL_DAC_SetValue Function Name HAL_StatusTypeDef HAL_DAC_SetValue (DAC_HandleTypeDef * hdac, uint32_t Channel, uint32_t Alignment, uint32_t Data) Function Description HAL_DAC_GetState Function Name HAL_DAC_StateTypeDef HAL_DAC_GetState (DAC_HandleTypeDef * hdac) Function Description return the DAC handle state Parameters hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. Return values HAL: state HAL_DAC_GetError Function Name 196/832 uint32_t HAL_DAC_GetError (DAC_HandleTypeDef * hdac) DOCID026526 Rev 4 UM1786 Function Description Return the DAC error code. Parameters hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. Return values DAC: Error Code 13.3 DAC Firmware driver defines 13.3.1 DAC DAC data alignement DAC_ALIGN_12B_R DAC_ALIGN_12B_L DAC_ALIGN_8B_R DAC Error Code HAL_DAC_ERROR_NONE No error HAL_DAC_ERROR_DMAUNDERRUNCH1 DAC channel1 DMA underrun error HAL_DAC_ERROR_DMAUNDERRUNCH2 DAC channel2 DMA underrun error HAL_DAC_ERROR_DMA DMA error DAC Exported Macros __HAL_DAC_RESET_HANDLE_STATE Description: Reset DAC handle state. Parameters: __HANDLE__: specifies the DAC handle. Return value: __HAL_DAC_ENABLE None Description: Enable the DAC channel. Parameters: __HANDLE__: specifies the DAC handle. __DAC_Channel__: specifies the DAC channel Return value: __HAL_DAC_DISABLE None Description: Disable the DAC channel. Parameters: __HANDLE__: specifies the DAC handle __DAC_Channel__: specifies the DAC channel. DOCID026526 Rev 4 197/832 UM1786 Return value: DAC_DHR12R1_ALIGNMENT None Description: Set DHR12R1 alignment. Parameters: __ALIGNMENT__: specifies the DAC alignment Return value: DAC_DHR12R2_ALIGNMENT None Description: Set DHR12R2 alignment. Parameters: __ALIGNMENT__: specifies the DAC alignment Return value: DAC_DHR12RD_ALIGNMENT None Description: Set DHR12RD alignment. Parameters: __ALIGNMENT__: specifies the DAC alignment Return value: __HAL_DAC_ENABLE_IT None Description: Enable the DAC interrupt. Parameters: __HANDLE__: specifies the DAC handle __INTERRUPT__: specifies the DAC interrupt. This parameter can be any combination of the following values: DAC_IT_DMAUDR1: DAC channel 1 DMA underrun interrupt DAC_IT_DMAUDR2: DAC channel 2 DMA underrun interrupt Return value: __HAL_DAC_DISABLE_IT None Description: Disable the DAC interrupt. Parameters: 198/832 DOCID026526 Rev 4 UM1786 __HANDLE__: specifies the DAC handle __INTERRUPT__: specifies the DAC interrupt. This parameter can be any combination of the following values: DAC_IT_DMAUDR1: DAC channel 1 DMA underrun interrupt DAC_IT_DMAUDR2: DAC channel 2 DMA underrun interrupt Return value: __HAL_DAC_GET_IT_SOURCE None Description: Check whether the specified DAC interrupt source is enabled or not. Parameters: __HANDLE__: DAC handle __INTERRUPT__: DAC interrupt source to check This parameter can be any combination of the following values: DAC_IT_DMAUDR1: DAC channel 1 DMA underrun interrupt DAC_IT_DMAUDR2: DAC channel 2 DMA underrun interrupt Return value: State: of interruption (SET or RESET) Description: __HAL_DAC_GET_FLAG Get the selected DAC's flag status. Parameters: __HANDLE__: specifies the DAC handle. __FLAG__: specifies the DAC flag to get. This parameter can be any combination of the following values: DAC_FLAG_DMAUDR1: DAC channel 1 DMA underrun flag DAC_FLAG_DMAUDR2: DAC channel 2 DMA underrun flag Return value: __HAL_DAC_CLEAR_FLAG None Description: Clear the DAC's flag. Parameters: __HANDLE__: specifies the DAC handle. __FLAG__: specifies the DAC flag to clear. This parameter can be any combination of the following values: DAC_FLAG_DMAUDR1: DAC DOCID026526 Rev 4 199/832 UM1786 channel 1 DMA underrun flag DAC_FLAG_DMAUDR2: DAC channel 2 DMA underrun flag Return value: None DAC flags definition DAC_FLAG_DMAUDR1 DAC_FLAG_DMAUDR2 DAC interrupts definition DAC_IT_DMAUDR1 DAC_IT_DMAUDR2 DAC lfsrunmask triangleamplitude 200/832 DAC_LFSRUNMASK_BIT0 Unmask DAC channel LFSR bit0 for noise wave generation DAC_LFSRUNMASK_BITS1_0 Unmask DAC channel LFSR bit[1:0] for noise wave generation DAC_LFSRUNMASK_BITS2_0 Unmask DAC channel LFSR bit[2:0] for noise wave generation DAC_LFSRUNMASK_BITS3_0 Unmask DAC channel LFSR bit[3:0] for noise wave generation DAC_LFSRUNMASK_BITS4_0 Unmask DAC channel LFSR bit[4:0] for noise wave generation DAC_LFSRUNMASK_BITS5_0 Unmask DAC channel LFSR bit[5:0] for noise wave generation DAC_LFSRUNMASK_BITS6_0 Unmask DAC channel LFSR bit[6:0] for noise wave generation DAC_LFSRUNMASK_BITS7_0 Unmask DAC channel LFSR bit[7:0] for noise wave generation DAC_LFSRUNMASK_BITS8_0 Unmask DAC channel LFSR bit[8:0] for noise wave generation DAC_LFSRUNMASK_BITS9_0 Unmask DAC channel LFSR bit[9:0] for noise wave generation DAC_LFSRUNMASK_BITS10_0 Unmask DAC channel LFSR bit[10:0] for noise wave generation DAC_LFSRUNMASK_BITS11_0 Unmask DAC channel LFSR bit[11:0] for noise wave generation DAC_TRIANGLEAMPLITUDE_1 Select max triangle amplitude of 1 DAC_TRIANGLEAMPLITUDE_3 Select max triangle amplitude of 3 DAC_TRIANGLEAMPLITUDE_7 Select max triangle amplitude of 7 DAC_TRIANGLEAMPLITUDE_15 Select max triangle amplitude of 15 DAC_TRIANGLEAMPLITUDE_31 Select max triangle amplitude of 31 DOCID026526 Rev 4 UM1786 DAC_TRIANGLEAMPLITUDE_63 Select max triangle amplitude of 63 DAC_TRIANGLEAMPLITUDE_127 Select max triangle amplitude of 127 DAC_TRIANGLEAMPLITUDE_255 Select max triangle amplitude of 255 DAC_TRIANGLEAMPLITUDE_511 Select max triangle amplitude of 511 DAC_TRIANGLEAMPLITUDE_1023 Select max triangle amplitude of 1023 DAC_TRIANGLEAMPLITUDE_2047 Select max triangle amplitude of 2047 DAC_TRIANGLEAMPLITUDE_4095 Select max triangle amplitude of 4095 DAC output buffer DAC_OUTPUTBUFFER_ENABLE DAC_OUTPUTBUFFER_DISABLE DOCID026526 Rev 4 201/832 UM1786 14 HAL DAC Extension Driver 14.1 DACEx Firmware driver API description 14.1.1 How to use this driver 14.1.2 When Dual mode is enabled (i.e. DAC Channel1 and Channel2 are used simultaneously) : Use HAL_DACEx_DualGetValue() to get digital data to be converted and use HAL_DACEx_DualSetValue() to set digital value to converted simultaneously in Channel 1 and Channel 2. Use HAL_DACEx_TriangleWaveGenerate() to generate Triangle signal. Use HAL_DACEx_NoiseWaveGenerate() to generate Noise signal. Peripheral Control functions This section provides functions allowing to: Set the specified data holding register value for DAC channel. Set the specified data holding register value for dual DAC channel (when DAC channel 2 is present in DAC 1) This section contains the following APIs: 14.1.3 HAL_DAC_SetValue() HAL_DACEx_DualSetValue() IO operation functions This section provides functions allowing to: Start conversion. Start conversion and enable DMA transfer. Get result of conversion. Handle DAC IRQ's. Generate triangular-wave Generate noise-wave Callback functions for DAC1 Channel2 (when supported) This section contains the following APIs: 202/832 HAL_DAC_Start() HAL_DAC_Start_DMA() HAL_DAC_GetValue() HAL_DACEx_DualGetValue() HAL_DAC_IRQHandler() HAL_DAC_ConfigChannel() HAL_DACEx_TriangleWaveGenerate() HAL_DACEx_NoiseWaveGenerate() HAL_DACEx_ConvCpltCallbackCh2() HAL_DACEx_ConvHalfCpltCallbackCh2() HAL_DACEx_ErrorCallbackCh2() HAL_DACEx_DMAUnderrunCallbackCh2() HAL_DACEx_DualSetValue() DOCID026526 Rev 4 UM1786 14.1.4 Detailed description of functions HAL_DACEx_DualGetValue Function Name uint32_t HAL_DACEx_DualGetValue (DAC_HandleTypeDef * hdac) Function Description Return the last data output value of the selected DAC channel. Parameters hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. Return values The: selected DAC channel data output value. HAL_DACEx_DualSetValue Function Name HAL_StatusTypeDef HAL_DACEx_DualSetValue (DAC_HandleTypeDef * hdac, uint32_t Alignment, uint32_t Data1, uint32_t Data2) Function Description Set the specified data holding register value for dual DAC channel. Parameters hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. Alignment: Specifies the data alignment for dual channel DAC. This parameter can be one of the following values: DAC_ALIGN_8B_R: 8bit right data alignment selected DAC_ALIGN_12B_L: 12bit left data alignment selected DAC_ALIGN_12B_R: 12bit right data alignment selected Data2: Data for DAC Channel2 to be loaded in the selected data holding register. Data1: Data for DAC Channel1 to be loaded in the selected data holding register. Return values HAL: status Notes In dual mode, a unique register access is required to write in both DAC channels at the same time. HAL_DACEx_TriangleWaveGenerate Function Name HAL_StatusTypeDef HAL_DACEx_TriangleWaveGenerate (DAC_HandleTypeDef * hdac, uint32_t Channel, uint32_t Amplitude) Function Description Enables or disables the selected DAC channel wave generation. Parameters hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. Channel: The selected DAC channel. This parameter can be one of the following values: DAC_CHANNEL_1: DAC1 Channel1 selected DAC_CHANNEL_2: DAC1 Channel2 selected Amplitude: Select max triangle amplitude. This parameter can be one of the following values: DAC_TRIANGLEAMPLITUDE_1: Select max triangle amplitude of 1 DAC_TRIANGLEAMPLITUDE_3: Select max triangle amplitude of 3 DOCID026526 Rev 4 203/832 UM1786 DAC_TRIANGLEAMPLITUDE_7: Select max triangle amplitude of 7 DAC_TRIANGLEAMPLITUDE_15: Select max triangle amplitude of 15 DAC_TRIANGLEAMPLITUDE_31: Select max triangle amplitude of 31 DAC_TRIANGLEAMPLITUDE_63: Select max triangle amplitude of 63 DAC_TRIANGLEAMPLITUDE_127: Select max triangle amplitude of 127 DAC_TRIANGLEAMPLITUDE_255: Select max triangle amplitude of 255 DAC_TRIANGLEAMPLITUDE_511: Select max triangle amplitude of 511 DAC_TRIANGLEAMPLITUDE_1023: Select max triangle amplitude of 1023 DAC_TRIANGLEAMPLITUDE_2047: Select max triangle amplitude of 2047 DAC_TRIANGLEAMPLITUDE_4095: Select max triangle amplitude of 4095 Return values HAL: status Notes Wave generation is not available in DAC2. HAL_DACEx_NoiseWaveGenerate Function Name HAL_StatusTypeDef HAL_DACEx_NoiseWaveGenerate (DAC_HandleTypeDef * hdac, uint32_t Channel, uint32_t Amplitude) Function Description Enables or disables the selected DAC channel wave generation. Parameters 204/832 hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. Channel: The selected DAC channel. This parameter can be one of the following values: DAC_CHANNEL_1: DAC1 Channel1 selected DAC_CHANNEL_2: DAC1 Channel2 selected Amplitude: Unmask DAC channel LFSR for noise wave generation. This parameter can be one of the following values: DAC_LFSRUNMASK_BIT0: Unmask DAC channel LFSR bit0 for noise wave generation DAC_LFSRUNMASK_BITS1_0: Unmask DAC channel LFSR bit[1:0] for noise wave generation DAC_LFSRUNMASK_BITS2_0: Unmask DAC channel LFSR bit[2:0] for noise wave generation DAC_LFSRUNMASK_BITS3_0: Unmask DAC channel LFSR bit[3:0] for noise wave generation DAC_LFSRUNMASK_BITS4_0: Unmask DAC channel LFSR bit[4:0] for noise wave generation DAC_LFSRUNMASK_BITS5_0: Unmask DAC channel LFSR bit[5:0] for noise wave generation DAC_LFSRUNMASK_BITS6_0: Unmask DAC channel LFSR bit[6:0] for noise wave generation DOCID026526 Rev 4 UM1786 Return values DAC_LFSRUNMASK_BITS7_0: Unmask DAC channel LFSR bit[7:0] for noise wave generation DAC_LFSRUNMASK_BITS8_0: Unmask DAC channel LFSR bit[8:0] for noise wave generation DAC_LFSRUNMASK_BITS9_0: Unmask DAC channel LFSR bit[9:0] for noise wave generation DAC_LFSRUNMASK_BITS10_0: Unmask DAC channel LFSR bit[10:0] for noise wave generation DAC_LFSRUNMASK_BITS11_0: Unmask DAC channel LFSR bit[11:0] for noise wave generation HAL: status HAL_DACEx_ConvCpltCallbackCh2 Function Name void HAL_DACEx_ConvCpltCallbackCh2 (DAC_HandleTypeDef * hdac) Function Description Conversion complete callback in non blocking mode for Channel2. Parameters hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. Return values None: HAL_DACEx_ConvHalfCpltCallbackCh2 Function Name void HAL_DACEx_ConvHalfCpltCallbackCh2 (DAC_HandleTypeDef * hdac) Function Description Conversion half DMA transfer callback in non blocking mode for Channel2. Parameters hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. Return values None: HAL_DACEx_ErrorCallbackCh2 Function Name void HAL_DACEx_ErrorCallbackCh2 (DAC_HandleTypeDef * hdac) Function Description Error DAC callback for Channel2. Parameters hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. Return values None: HAL_DACEx_DMAUnderrunCallbackCh2 Function Name void HAL_DACEx_DMAUnderrunCallbackCh2 (DAC_HandleTypeDef * hdac) Function Description DMA underrun DAC callback for channel2. Parameters hdac: pointer to a DAC_HandleTypeDef structure that contains the configuration information for the specified DAC. DOCID026526 Rev 4 205/832 UM1786 Return values None: 14.2 DACEx Firmware driver defines 14.2.1 DACEx DACEx Channel selection DAC_CHANNEL_1 DAC Channel 1 DAC_CHANNEL_2 DAC Channel 2 DACEx trigger selection DAC_TRIGGER_NONE Conversion is automatic once the DAC1_DHRxxxx register has been loaded, and not by external trigger DAC_TRIGGER_T2_TRGO TIM2 TRGO selected as external conversion trigger for DAC channel DAC_TRIGGER_T4_TRGO TIM4 TRGO selected as external conversion trigger for DAC channel DAC_TRIGGER_T15_TRGO TIM5 TRGO selected as external conversion trigger for DAC channel DAC_TRIGGER_T6_TRGO TIM6 TRGO selected as external conversion trigger for DAC channel DAC_TRIGGER_T7_TRGO TIM7 TRGO selected as external conversion trigger for DAC channel DAC_TRIGGER_T3_TRGO TIM3 TRGO selected as external conversion trigger for DAC channel Use DAC_TRIGGER_T8_TRGO TIM8 TRGO selected as external conversion trigger for DAC channel Use DAC_TRIGGER_EXT_IT9 EXTI Line9 event selected as external conversion trigger for DAC channel DAC_TRIGGER_SOFTWARE Conversion started by software trigger for DAC channel IS_DAC_TRIGGER 206/832 DOCID026526 Rev 4 UM1786 15 HAL DMA Generic Driver 15.1 DMA Firmware driver registers structures 15.1.1 DMA_InitTypeDef Data Fields uint32_t Direction uint32_t PeriphInc uint32_t MemInc uint32_t PeriphDataAlignment uint32_t MemDataAlignment uint32_t Mode uint32_t Priority Field Documentation 15.1.2 uint32_t DMA_InitTypeDef::Direction Specifies if the data will be transferred from memory to peripheral, from memory to memory or from peripheral to memory. This parameter can be a value of DMA_Data_transfer_direction uint32_t DMA_InitTypeDef::PeriphInc Specifies whether the Peripheral address register should be incremented or not. This parameter can be a value of DMA_Peripheral_incremented_mode uint32_t DMA_InitTypeDef::MemInc Specifies whether the memory address register should be incremented or not. This parameter can be a value of DMA_Memory_incremented_mode uint32_t DMA_InitTypeDef::PeriphDataAlignment Specifies the Peripheral data width. This parameter can be a value of DMA_Peripheral_data_size uint32_t DMA_InitTypeDef::MemDataAlignment Specifies the Memory data width. This parameter can be a value of DMA_Memory_data_size uint32_t DMA_InitTypeDef::Mode Specifies the operation mode of the DMAy Channelx. This parameter can be a value of DMA_mode Note:The circular buffer mode cannot be used if the memory-to-memory data transfer is configured on the selected Channel uint32_t DMA_InitTypeDef::Priority Specifies the software priority for the DMAy Channelx. This parameter can be a value of DMA_Priority_level __DMA_HandleTypeDef Data Fields DMA_Channel_TypeDef * Instance DOCID026526 Rev 4 207/832 UM1786 DMA_InitTypeDef Init HAL_LockTypeDef Lock HAL_DMA_StateTypeDef State void * Parent void(* XferCpltCallback void(* XferHalfCpltCallback void(* XferErrorCallback void(* XferAbortCallback __IO uint32_t ErrorCode Field Documentation DMA_Channel_TypeDef* __DMA_HandleTypeDef::Instance Register base address DMA_InitTypeDef __DMA_HandleTypeDef::Init DMA communication parameters HAL_LockTypeDef __DMA_HandleTypeDef::Lock DMA locking object HAL_DMA_StateTypeDef __DMA_HandleTypeDef::State DMA transfer state void* __DMA_HandleTypeDef::Parent Parent object state void(* __DMA_HandleTypeDef::XferCpltCallback)(struct __DMA_HandleTypeDef *hdma) DMA transfer complete callback void(* __DMA_HandleTypeDef::XferHalfCpltCallback)(struct __DMA_HandleTypeDef *hdma) DMA Half transfer complete callback void(* __DMA_HandleTypeDef::XferErrorCallback)(struct __DMA_HandleTypeDef *hdma) DMA transfer error callback void(* __DMA_HandleTypeDef::XferAbortCallback)(struct __DMA_HandleTypeDef *hdma) DMA transfer abort callback __IO uint32_t __DMA_HandleTypeDef::ErrorCode DMA Error code 15.2 DMA Firmware driver API description 15.2.1 How to use this driver 1. 2. 3. 208/832 Enable and configure the peripheral to be connected to the DMA Channel (except for internal SRAM / FLASH memories: no initialization is necessary) please refer to Reference manual for connection between peripherals and DMA requests . For a given Channel, program the required configuration through the following parameters: Transfer Direction, Source and Destination data formats, Circular or Normal mode, Channel Priority level, Source and Destination Increment mode, using HAL_DMA_Init() function. Use HAL_DMA_GetState() function to return the DMA state and HAL_DMA_GetError() in case of error detection. DOCID026526 Rev 4 UM1786 4. Use HAL_DMA_Abort() function to abort the current transfer In Memory-to-Memory transfer mode, Circular mode is not allowed. Polling mode IO operation Use HAL_DMA_Start() to start DMA transfer after the configuration of Source address and destination address and the Length of data to be transferred Use HAL_DMA_PollForTransfer() to poll for the end of current transfer, in this case a fixed Timeout can be configured by User depending from his application. Interrupt mode IO operation Configure the DMA interrupt priority using HAL_NVIC_SetPriority() Enable the DMA IRQ handler using HAL_NVIC_EnableIRQ() Use HAL_DMA_Start_IT() to start DMA transfer after the configuration of Source address and destination address and the Length of data to be transferred. In this case the DMA interrupt is configured Use HAL_DMAy_Channelx_IRQHandler() called under DMA_IRQHandler() Interrupt subroutine At the end of data transfer HAL_DMA_IRQHandler() function is executed and user can add his own function by customization of function pointer XferCpltCallback and XferErrorCallback (i.e a member of DMA handle structure). DMA HAL driver macros list Below the list of most used macros in DMA HAL driver. __HAL_DMA_ENABLE: Enable the specified DMA Channel. __HAL_DMA_DISABLE: Disable the specified DMA Channel. __HAL_DMA_GET_FLAG: Get the DMA Channel pending flags. __HAL_DMA_CLEAR_FLAG: Clear the DMA Channel pending flags. __HAL_DMA_ENABLE_IT: Enable the specified DMA Channel interrupts. __HAL_DMA_DISABLE_IT: Disable the specified DMA Channel interrupts. __HAL_DMA_GET_IT_SOURCE: Check whether the specified DMA Channel interrupt has occurred or not. You can refer to the DMA HAL driver header file for more useful macros 15.2.2 Initialization and de-initialization functions This section provides functions allowing to initialize the DMA Channel source and destination addresses, incrementation and data sizes, transfer direction, circular/normal mode selection, memory-to-memory mode selection and Channel priority value. The HAL_DMA_Init() function follows the DMA configuration procedures as described in reference manual. This section contains the following APIs: HAL_DMA_Init() HAL_DMA_DeInit() DOCID026526 Rev 4 209/832 UM1786 15.2.3 IO operation functions This section provides functions allowing to: Configure the source, destination address and data length and Start DMA transfer Configure the source, destination address and data length and Start DMA transfer with interrupt Abort DMA transfer Poll for transfer complete Handle DMA interrupt request This section contains the following APIs: 15.2.4 HAL_DMA_Start() HAL_DMA_Start_IT() HAL_DMA_Abort() HAL_DMA_Abort_IT() HAL_DMA_PollForTransfer() HAL_DMA_IRQHandler() State and Errors functions This subsection provides functions allowing to Check the DMA state Get error code This section contains the following APIs: 15.2.5 HAL_DMA_GetState() HAL_DMA_GetError() Detailed description of functions HAL_DMA_Init Function Name HAL_StatusTypeDef HAL_DMA_Init (DMA_HandleTypeDef * hdma) Function Description Initializes the DMA according to the specified parameters in the DMA_InitTypeDef and create the associated handle. Parameters hdma: Pointer to a DMA_HandleTypeDef structure that contains the configuration information for the specified DMA Channel. Return values HAL: status HAL_DMA_DeInit 210/832 Function Name HAL_StatusTypeDef HAL_DMA_DeInit (DMA_HandleTypeDef * hdma) Function Description DeInitializes the DMA peripheral. Parameters hdma: pointer to a DMA_HandleTypeDef structure that contains the configuration information for the specified DMA Channel. Return values HAL: status DOCID026526 Rev 4 UM1786 HAL_DMA_Start Function Name HAL_StatusTypeDef HAL_DMA_Start (DMA_HandleTypeDef * hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength) Function Description Starts the DMA Transfer. Parameters Return values hdma: pointer to a DMA_HandleTypeDef structure that contains the configuration information for the specified DMA Channel. SrcAddress: The source memory Buffer address DstAddress: The destination memory Buffer address DataLength: The length of data to be transferred from source to destination HAL: status HAL_DMA_Start_IT Function Name HAL_StatusTypeDef HAL_DMA_Start_IT (DMA_HandleTypeDef * hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength) Function Description Start the DMA Transfer with interrupt enabled. Parameters Return values hdma: pointer to a DMA_HandleTypeDef structure that contains the configuration information for the specified DMA Channel. SrcAddress: The source memory Buffer address DstAddress: The destination memory Buffer address DataLength: The length of data to be transferred from source to destination HAL: status HAL_DMA_Abort Function Name HAL_StatusTypeDef HAL_DMA_Abort (DMA_HandleTypeDef * hdma) Function Description Aborts the DMA Transfer. Parameters hdma: pointer to a DMA_HandleTypeDef structure that contains the configuration information for the specified DMA Channel. Return values HAL: status Notes After disabling a DMA Channel, a check for wait until the DMA Channel is effectively disabled is added. If a Channel is disabled while a data transfer is ongoing, the current data will be transferred and the Channel will be effectively disabled only after the transfer of this single data is finished. HAL_DMA_Abort_IT Function Name HAL_StatusTypeDef HAL_DMA_Abort_IT (DMA_HandleTypeDef * hdma) DOCID026526 Rev 4 211/832 UM1786 Function Description Aborts the DMA Transfer in Interrupt mode. Parameters hdma: : pointer to a DMA_HandleTypeDef structure that contains the configuration information for the specified DMA Stream. Return values HAL: status HAL_DMA_PollForTransfer Function Name HAL_StatusTypeDef HAL_DMA_PollForTransfer (DMA_HandleTypeDef * hdma, uint32_t CompleteLevel, uint32_t Timeout) Function Description Polling for transfer complete. Parameters Return values hdma: pointer to a DMA_HandleTypeDef structure that contains the configuration information for the specified DMA Channel. CompleteLevel: Specifies the DMA level complete. Timeout: Timeout duration. HAL: status HAL_DMA_IRQHandler Function Name void HAL_DMA_IRQHandler (DMA_HandleTypeDef * hdma) Function Description Handles DMA interrupt request. Parameters hdma: pointer to a DMA_HandleTypeDef structure that contains the configuration information for the specified DMA Channel. Return values None: HAL_DMA_GetState Function Name HAL_DMA_StateTypeDef HAL_DMA_GetState (DMA_HandleTypeDef * hdma) Function Description Returns the DMA state. Parameters hdma: pointer to a DMA_HandleTypeDef structure that contains the configuration information for the specified DMA Channel. Return values HAL: state HAL_DMA_GetError 212/832 Function Name uint32_t HAL_DMA_GetError (DMA_HandleTypeDef * hdma) Function Description Return the DMA error code. Parameters hdma: pointer to a DMA_HandleTypeDef structure that contains the configuration information for the specified DMA Channel. Return values DMA: Error Code DOCID026526 Rev 4 UM1786 15.3 DMA Firmware driver defines 15.3.1 DMA DMA Data transfer direction DMA_PERIPH_TO_MEMORY Peripheral to memory direction DMA_MEMORY_TO_PERIPH Memory to peripheral direction DMA_MEMORY_TO_MEMORY Memory to memory direction DMA Error Code HAL_DMA_ERROR_NONE No error HAL_DMA_ERROR_TE Transfer error HAL_DMA_ERROR_NO_XFER no ongoin transfer HAL_DMA_ERROR_TIMEOUT Timeout error DMA Exported Macros __HAL_DMA_RESET_HANDLE_STATE Description: Reset DMA handle state. Parameters: __HANDLE__: DMA handle. Return value: __HAL_DMA_ENABLE None Description: Enable the specified DMA Channel. Parameters: __HANDLE__: DMA handle Return value: __HAL_DMA_DISABLE None. Description: Disable the specified DMA Channel. Parameters: __HANDLE__: DMA handle Return value: __HAL_DMA_ENABLE_IT None. Description: Enables the specified DMA Channel interrupts. Parameters: __HANDLE__: DMA handle __INTERRUPT__: specifies the DMA interrupt sources to be enabled or DOCID026526 Rev 4 213/832 UM1786 disabled. This parameter can be any combination of the following values: DMA_IT_TC: Transfer complete interrupt mask DMA_IT_HT: Half transfer complete interrupt mask DMA_IT_TE: Transfer error interrupt mask Return value: None Description: __HAL_DMA_DISABLE_IT Disables the specified DMA Channel interrupts. Parameters: __HANDLE__: DMA handle __INTERRUPT__: specifies the DMA interrupt sources to be enabled or disabled. This parameter can be any combination of the following values: DMA_IT_TC: Transfer complete interrupt mask DMA_IT_HT: Half transfer complete interrupt mask DMA_IT_TE: Transfer error interrupt mask Return value: __HAL_DMA_GET_IT_SOURCE None Description: Checks whether the specified DMA Channel interrupt is enabled or disabled. Parameters: __HANDLE__: DMA handle __INTERRUPT__: specifies the DMA interrupt source to check. This parameter can be one of the following values: DMA_IT_TC: Transfer complete interrupt mask DMA_IT_HT: Half transfer complete interrupt mask DMA_IT_TE: Transfer error interrupt mask Return value: __HAL_DMA_GET_COUNTER Description: 214/832 The: state of DMA_IT (SET or RESET). Returns the number of remaining data units in the current DMAy Channelx DOCID026526 Rev 4 UM1786 transfer. Parameters: __HANDLE__: DMA handle Return value: The: number of remaining data units in the current DMA Channel transfer. DMA flag definitions DMA_FLAG_GL1 DMA_FLAG_TC1 DMA_FLAG_HT1 DMA_FLAG_TE1 DMA_FLAG_GL2 DMA_FLAG_TC2 DMA_FLAG_HT2 DMA_FLAG_TE2 DMA_FLAG_GL3 DMA_FLAG_TC3 DMA_FLAG_HT3 DMA_FLAG_TE3 DMA_FLAG_GL4 DMA_FLAG_TC4 DMA_FLAG_HT4 DMA_FLAG_TE4 DMA_FLAG_GL5 DMA_FLAG_TC5 DMA_FLAG_HT5 DMA_FLAG_TE5 DMA_FLAG_GL6 DMA_FLAG_TC6 DMA_FLAG_HT6 DMA_FLAG_TE6 DMA_FLAG_GL7 DMA_FLAG_TC7 DMA_FLAG_HT7 DMA_FLAG_TE7 DMA interrupt enable definitions DMA_IT_TC DOCID026526 Rev 4 215/832 UM1786 DMA_IT_HT DMA_IT_TE DMA Memory data size DMA_MDATAALIGN_BYTE Memory data alignment : Byte DMA_MDATAALIGN_HALFWORD Memory data alignment : HalfWord DMA_MDATAALIGN_WORD Memory data alignment : Word DMA Memory incremented mode DMA_MINC_ENABLE Memory increment mode Enable DMA_MINC_DISABLE Memory increment mode Disable DMA mode DMA_NORMAL Normal mode DMA_CIRCULAR Circular mode DMA Peripheral data size DMA_PDATAALIGN_BYTE Peripheral data alignment : Byte DMA_PDATAALIGN_HALFWORD Peripheral data alignment : HalfWord DMA_PDATAALIGN_WORD Peripheral data alignment : Word DMA Peripheral incremented mode DMA_PINC_ENABLE Peripheral increment mode Enable DMA_PINC_DISABLE Peripheral increment mode Disable DMA Priority level DMA_PRIORITY_LOW Priority level : Low DMA_PRIORITY_MEDIUM Priority level : Medium DMA_PRIORITY_HIGH Priority level : High DMA_PRIORITY_VERY_HIGH Priority level : Very_High DMA Remap Enable __HAL_DMA_REMAP_CHANNEL_ENABLE Description: DMA remapping enable/disable macros. Parameters: __HAL_DMA_REMAP_CHANNEL_DISABLE 216/832 DOCID026526 Rev 4 __DMA_REMAP__: This parameter can be a value of UM1786 16 HAL DMA Extension Driver 16.1 DMAEx Firmware driver defines 16.1.1 DMAEx DMA Extended Exported Macros __HAL_DMA_GET_TC_FLAG_INDEX Description: Returns the current DMA Channel transfer complete flag. Parameters: __HANDLE__: DMA handle Return value: __HAL_DMA_GET_HT_FLAG_INDEX The: specified transfer complete flag index. Description: Returns the current DMA Channel half transfer complete flag. Parameters: __HANDLE__: DMA handle Return value: __HAL_DMA_GET_TE_FLAG_INDEX The: specified half transfer complete flag index. Description: Returns the current DMA Channel transfer error flag. Parameters: __HANDLE__: DMA handle Return value: __HAL_DMA_GET_GI_FLAG_INDEX The: specified transfer error flag index. Description: Return the current DMA Channel Global interrupt flag. Parameters: __HANDLE__: DMA handle Return value: __HAL_DMA_GET_FLAG The: specified transfer error flag index. Description: Get the DMA Channel pending flags. DOCID026526 Rev 4 217/832 UM1786 Parameters: __HANDLE__: DMA handle __FLAG__: Get the specified flag. This parameter can be any combination of the following values: DMA_FLAG_TCx: Transfer complete flag DMA_FLAG_HTx: Half transfer complete flag DMA_FLAG_TEx: Transfer error flag Where x can be 1_7 or 1_5 (depending on DMA1 or DMA2) to select the DMA Channel flag. Return value: __HAL_DMA_CLEAR_FLAG The: state of FLAG (SET or RESET). Description: Clears the DMA Channel pending flags. Parameters: __HANDLE__: DMA handle __FLAG__: specifies the flag to clear. This parameter can be any combination of the following values: DMA_FLAG_TCx: Transfer complete flag DMA_FLAG_HTx: Half transfer complete flag DMA_FLAG_TEx: Transfer error flag Where x can be 1_7 or 1_5 (depending on DMA1 or DMA2) to select the DMA Channel flag. Return value: 218/832 None DOCID026526 Rev 4 UM1786 17 HAL FLASH Generic Driver 17.1 FLASH Firmware driver registers structures 17.1.1 FLASH_ProcessTypeDef Data Fields __IO FLASH_ProcedureTypeDef ProcedureOnGoing __IO uint32_t DataRemaining __IO uint32_t Address __IO uint64_t Data HAL_LockTypeDef Lock __IO uint32_t ErrorCode Field Documentation __IO FLASH_ProcedureTypeDef FLASH_ProcessTypeDef::ProcedureOnGoing Internal variable to indicate which procedure is ongoing or not in IT context __IO uint32_t FLASH_ProcessTypeDef::DataRemaining Internal variable to save the remaining pages to erase or half-word to program in IT context __IO uint32_t FLASH_ProcessTypeDef::Address Internal variable to save address selected for program or erase __IO uint64_t FLASH_ProcessTypeDef::Data Internal variable to save data to be programmed HAL_LockTypeDef FLASH_ProcessTypeDef::Lock FLASH locking object __IO uint32_t FLASH_ProcessTypeDef::ErrorCode FLASH error code This parameter can be a value of FLASH_Error_Codes 17.2 FLASH Firmware driver API description 17.2.1 FLASH peripheral features The Flash memory interface manages CPU AHB I-Code and D-Code accesses to the Flash memory. It implements the erase and program Flash memory operations and the read and write protection mechanisms. The Flash memory interface accelerates code execution with a system of instruction prefetch. The FLASH main features are: Flash memory read operations Flash memory program/erase operations Read / write protections Prefetch on I-Code Option Bytes programming DOCID026526 Rev 4 219/832 UM1786 17.2.2 How to use this driver This driver provides functions and macros to configure and program the FLASH memory of all STM32F3xx devices. 1. 2. 3. FLASH Memory I/O Programming functions: this group includes all needed functions to erase and program the main memory: Lock and Unlock the FLASH interface Erase function: Erase page, erase all pages Program functions: half word, word and doubleword FLASH Option Bytes Programming functions: this group includes all needed functions to manage the Option Bytes: Lock and Unlock the Option Bytes Set/Reset the write protection Set the Read protection Level Program the user Option Bytes Launch the Option Bytes loader Erase Option Bytes Program the data Option Bytes Get the Write protection. Get the user option bytes. Interrupts and flags management functions : this group includes all needed functions to: Handle FLASH interrupts Wait for last FLASH operation according to its status Get error flag status In addition to these function, this driver includes a set of macros allowing to handle the following operations: 17.2.3 Set/Get the latency Enable/Disable the prefetch buffer Enable/Disable the half cycle access Enable/Disable the FLASH interrupts Monitor the FLASH flags status Peripheral Control functions This subsection provides a set of functions allowing to control the FLASH memory operations. This section contains the following APIs: 17.2.4 HAL_FLASH_Unlock() HAL_FLASH_Lock() HAL_FLASH_OB_Unlock() HAL_FLASH_OB_Lock() HAL_FLASH_OB_Launch() Peripheral errors functions This subsection permit to get in run-time errors of the FLASH peripheral. This section contains the following APIs: 220/832 HAL_FLASH_GetError() DOCID026526 Rev 4 UM1786 17.2.5 Detailed description of functions HAL_FLASH_Program Function Name HAL_StatusTypeDef HAL_FLASH_Program (uint32_t TypeProgram, uint32_t Address, uint64_t Data) Function Description Program halfword, word or double word at a specified address. Parameters TypeProgram: Indicate the way to program at a specified address. This parameter can be a value of FLASH Type Program Address: Specifies the address to be programmed. Data: Specifies the data to be programmed Return values HAL_StatusTypeDef: HAL Status Notes The function HAL_FLASH_Unlock() should be called before to unlock the FLASH interface The function HAL_FLASH_Lock() should be called after to lock the FLASH interface If an erase and a program operations are requested simultaneously, the erase operation is performed before the program one. FLASH should be previously erased before new programmation (only exception to this is when 0x0000 is programmed) HAL_FLASH_Program_IT Function Name HAL_StatusTypeDef HAL_FLASH_Program_IT (uint32_t TypeProgram, uint32_t Address, uint64_t Data) Function Description Program halfword, word or double word at a specified address with interrupt enabled. Parameters TypeProgram: Indicate the way to program at a specified address. This parameter can be a value of FLASH Type Program Address: Specifies the address to be programmed. Data: Specifies the data to be programmed Return values HAL_StatusTypeDef: HAL Status Notes The function HAL_FLASH_Unlock() should be called before to unlock the FLASH interface The function HAL_FLASH_Lock() should be called after to lock the FLASH interface If an erase and a program operations are requested simultaneously, the erase operation is performed before the program one. HAL_FLASH_IRQHandler Function Name void HAL_FLASH_IRQHandler (void ) Function Description This function handles FLASH interrupt request. Return values None: DOCID026526 Rev 4 221/832 UM1786 HAL_FLASH_EndOfOperationCallback Function Name void HAL_FLASH_EndOfOperationCallback (uint32_t ReturnValue) Function Description FLASH end of operation interrupt callback. Parameters ReturnValue: The value saved in this parameter depends on the ongoing procedure Mass Erase: No return value expected Pages Erase: Address of the page which has been erased (if 0xFFFFFFFF, it means that all the selected pages have been erased) Program: Address which was selected for data program Return values none: HAL_FLASH_OperationErrorCallback Function Name void HAL_FLASH_OperationErrorCallback (uint32_t ReturnValue) Function Description FLASH operation error interrupt callback. Parameters ReturnValue: The value saved in this parameter depends on the ongoing procedure Mass Erase: No return value expected Pages Erase: Address of the page which returned an error Program: Address which was selected for data program Return values none: HAL_FLASH_Unlock Function Name HAL_StatusTypeDef HAL_FLASH_Unlock (void ) Function Description Unlock the FLASH control register access. Return values HAL: Status HAL_FLASH_Lock Function Name HAL_StatusTypeDef HAL_FLASH_Lock (void ) Function Description Locks the FLASH control register access. Return values HAL: Status HAL_FLASH_OB_Unlock 222/832 Function Name HAL_StatusTypeDef HAL_FLASH_OB_Unlock (void ) Function Description Unlock the FLASH Option Control Registers access. Return values HAL: Status DOCID026526 Rev 4 UM1786 HAL_FLASH_OB_Lock Function Name HAL_StatusTypeDef HAL_FLASH_OB_Lock (void ) Function Description Lock the FLASH Option Control Registers access. Return values HAL: Status HAL_FLASH_OB_Launch Function Name HAL_StatusTypeDef HAL_FLASH_OB_Launch (void ) Function Description Launch the option byte loading. Return values HAL: Status Notes This function will reset automatically the MCU. HAL_FLASH_GetError Function Name uint32_t HAL_FLASH_GetError (void ) Function Description Get the specific FLASH error flag. Return values FLASH_ErrorCode: The returned value can be: FLASH Error Codes FLASH_WaitForLastOperation Function Name HAL_StatusTypeDef FLASH_WaitForLastOperation (uint32_t Timeout) Function Description Wait for a FLASH operation to complete. Parameters Timeout: maximum flash operation timeout Return values HAL: Status 17.3 FLASH Firmware driver defines 17.3.1 FLASH FLASH Error Codes HAL_FLASH_ERROR_NONE No error HAL_FLASH_ERROR_PROG Programming error HAL_FLASH_ERROR_WRP Write protection error FLASH Flag definition FLASH_FLAG_BSY FLASH Busy flag FLASH_FLAG_PGERR FLASH Programming error flag FLASH_FLAG_WRPERR FLASH Write protected error flag FLASH_FLAG_EOP FLASH End of Operation flag DOCID026526 Rev 4 223/832 UM1786 FLASH Half Cycle __HAL_FLASH_HALF_CYCLE_ACCESS_ENABLE Description: Enable the FLASH half cycle access. Return value: __HAL_FLASH_HALF_CYCLE_ACCESS_DISABLE None Description: Disable the FLASH half cycle access. Return value: None FLASH Interrupts __HAL_FLASH_ENABLE_IT Description: Enable the specified FLASH interrupt. Parameters: __INTERRUPT__: FLASH interrupt This parameter can be any combination of the following values: FLASH_IT_EOP End of FLASH Operation Interrupt FLASH_IT_ERR Error Interrupt Return value: __HAL_FLASH_DISABLE_IT none Description: Disable the specified FLASH interrupt. Parameters: __INTERRUPT__: FLASH interrupt This parameter can be any combination of the following values: FLASH_IT_EOP End of FLASH Operation Interrupt FLASH_IT_ERR Error Interrupt Return value: __HAL_FLASH_GET_FLAG none Description: Get the specified FLASH flag status. Parameters: 224/832 __FLAG__: specifies the FLASH flag to check. This parameter can be one of the following values: FLASH_FLAG_BSY FLASH Busy flag FLASH_FLAG_EOP FLASH End of Operation flag FLASH_FLAG_WRPERR FLASH Write DOCID026526 Rev 4 UM1786 protected error flag FLASH_FLAG_PGERR FLASH Programming error flag Return value: __HAL_FLASH_CLEAR_FLAG The: new state of __FLAG__ (SET or RESET). Description: Clear the specified FLASH flag. Parameters: __FLAG__: specifies the FLASH flags to clear. This parameter can be any combination of the following values: FLASH_FLAG_EOP FLASH End of Operation flag FLASH_FLAG_WRPERR FLASH Write protected error flag FLASH_FLAG_PGERR FLASH Programming error flag Return value: none FLASH Interrupt definition FLASH_IT_EOP End of FLASH Operation Interrupt source FLASH_IT_ERR Error Interrupt source FLASH Latency FLASH_LATENCY_0 FLASH Zero Latency cycle FLASH_LATENCY_1 FLASH One Latency cycle FLASH_LATENCY_2 FLASH Two Latency cycles FLASH Prefetch __HAL_FLASH_PREFETCH_BUFFER_ENABLE Description: Enable the FLASH prefetch buffer. Return value: __HAL_FLASH_PREFETCH_BUFFER_DISABLE None Description: Disable the FLASH prefetch buffer. Return value: DOCID026526 Rev 4 None 225/832 UM1786 FLASH Type Program 226/832 FLASH_TYPEPROGRAM_HALFWORD Program a half-word (16-bit) at a specified address. FLASH_TYPEPROGRAM_WORD Program a word (32-bit) at a specified address. FLASH_TYPEPROGRAM_DOUBLEWORD Program a double word (64-bit) at a specified address DOCID026526 Rev 4 UM1786 18 HAL FLASH Extension Driver 18.1 FLASHEx Firmware driver registers structures 18.1.1 FLASH_EraseInitTypeDef Data Fields uint32_t TypeErase uint32_t PageAddress uint32_t NbPages Field Documentation 18.1.2 uint32_t FLASH_EraseInitTypeDef::TypeErase TypeErase: Mass erase or page erase. This parameter can be a value of FLASHEx_Type_Erase uint32_t FLASH_EraseInitTypeDef::PageAddress PageAdress: Initial FLASH page address to erase when mass erase is disabled This parameter must be a number between Min_Data = FLASH_BASE and Max_Data = FLASH_BANK1_END uint32_t FLASH_EraseInitTypeDef::NbPages NbPages: Number of pagess to be erased. This parameter must be a value between Min_Data = 1 and Max_Data = (max number of pages - value of initial page) FLASH_OBProgramInitTypeDef Data Fields uint32_t OptionType uint32_t WRPState uint32_t WRPPage uint8_t RDPLevel uint8_t USERConfig uint32_t DATAAddress uint8_t DATAData Field Documentation uint32_t FLASH_OBProgramInitTypeDef::OptionType OptionType: Option byte to be configured. This parameter can be a value of FLASHEx_OB_Type uint32_t FLASH_OBProgramInitTypeDef::WRPState WRPState: Write protection activation or deactivation. This parameter can be a value of FLASHEx_OB_WRP_State uint32_t FLASH_OBProgramInitTypeDef::WRPPage WRPPage: specifies the page(s) to be write protected This parameter can be a value of FLASHEx_OB_Write_Protection DOCID026526 Rev 4 227/832 UM1786 uint8_t FLASH_OBProgramInitTypeDef::RDPLevel RDPLevel: Set the read protection level.. This parameter can be a value of FLASHEx_OB_Read_Protection uint8_t FLASH_OBProgramInitTypeDef::USERConfig USERConfig: Program the FLASH User Option Byte: IWDG / STOP / STDBY / BOOT1 / VDDA_ANALOG / SRAM_PARITY / SDADC12_VDD_MONITOR This parameter can be a combination of FLASHEx_OB_IWatchdog, FLASHEx_OB_nRST_STOP, FLASHEx_OB_nRST_STDBY, FLASHEx_OB_BOOT1, FLASHEx_OB_VDDA_Analog_Monitoring, FLASHEx_OB_RAM_Parity_Check_Enable. uint32_t FLASH_OBProgramInitTypeDef::DATAAddress DATAAddress: Address of the option byte DATA to be programmed This parameter can be a value of FLASHEx_OB_Data_Address uint8_t FLASH_OBProgramInitTypeDef::DATAData DATAData: Data to be stored in the option byte DATA This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF 18.2 FLASHEx Firmware driver API description 18.2.1 FLASH Erasing Programming functions The FLASH Memory Erasing functions, includes the following functions: @ref HAL_FLASHEx_Erase: return only when erase has been done @ref HAL_FLASHEx_Erase_IT: end of erase is done when @ref HAL_FLASH_EndOfOperationCallback is called with parameter 0xFFFFFFFF Any operation of erase should follow these steps: 1. 2. 3. Call the @ref HAL_FLASH_Unlock() function to enable the flash control register and program memory access. Call the desired function to erase page. Call the @ref HAL_FLASH_Lock() to disable the flash program memory access (recommended to protect the FLASH memory against possible unwanted operation). This section contains the following APIs: 18.2.2 HAL_FLASHEx_Erase() HAL_FLASHEx_Erase_IT() Option Bytes Programming functions This subsection provides a set of functions allowing to control the FLASH option bytes operations. This section contains the following APIs: 18.2.3 HAL_FLASHEx_OBErase() HAL_FLASHEx_OBProgram() HAL_FLASHEx_OBGetConfig() HAL_FLASHEx_OBGetUserData() Detailed description of functions HAL_FLASHEx_Erase Function Name 228/832 HAL_StatusTypeDef HAL_FLASHEx_Erase DOCID026526 Rev 4 UM1786 (FLASH_EraseInitTypeDef * pEraseInit, uint32_t * PageError) Function Description Perform a mass erase or erase the specified FLASH memory pages. Parameters pEraseInit: pointer to an FLASH_EraseInitTypeDef structure that contains the configuration information for the erasing. PageError: pointer to variable that contains the configuration information on faulty page in case of error (0xFFFFFFFF means that all the pages have been correctly erased) Return values HAL_StatusTypeDef: HAL Status Notes To correctly run this function, the HAL_FLASH_Unlock() function must be called before. Call the HAL_FLASH_Lock() to disable the flash memory access (recommended to protect the FLASH memory against possible unwanted operation) HAL_FLASHEx_Erase_IT Function Name HAL_StatusTypeDef HAL_FLASHEx_Erase_IT (FLASH_EraseInitTypeDef * pEraseInit) Function Description Perform a mass erase or erase the specified FLASH memory pages with interrupt enabled. Parameters pEraseInit: pointer to an FLASH_EraseInitTypeDef structure that contains the configuration information for the erasing. Return values HAL_StatusTypeDef: HAL Status Notes To correctly run this function, the HAL_FLASH_Unlock() function must be called before. Call the HAL_FLASH_Lock() to disable the flash memory access (recommended to protect the FLASH memory against possible unwanted operation) HAL_FLASHEx_OBErase Function Name HAL_StatusTypeDef HAL_FLASHEx_OBErase (void ) Function Description Erases the FLASH option bytes. Return values HAL: status Notes This functions erases all option bytes except the Read protection (RDP). The function HAL_FLASH_Unlock() should be called before to unlock the FLASH interface The function HAL_FLASH_OB_Unlock() should be called before to unlock the options bytes The function HAL_FLASH_OB_Launch() should be called after to force the reload of the options bytes (system reset will occur) HAL_FLASHEx_OBProgram Function Name HAL_StatusTypeDef HAL_FLASHEx_OBProgram (FLASH_OBProgramInitTypeDef * pOBInit) Function Description Program option bytes. Parameters pOBInit: pointer to an FLASH_OBInitStruct structure that DOCID026526 Rev 4 229/832 UM1786 contains the configuration information for the programming. Return values HAL_StatusTypeDef: HAL Status Notes The function HAL_FLASH_Unlock() should be called before to unlock the FLASH interface The function HAL_FLASH_OB_Unlock() should be called before to unlock the options bytes The function HAL_FLASH_OB_Launch() should be called after to force the reload of the options bytes (system reset will occur) HAL_FLASHEx_OBGetConfig Function Name void HAL_FLASHEx_OBGetConfig (FLASH_OBProgramInitTypeDef * pOBInit) Function Description Get the Option byte configuration. Parameters pOBInit: pointer to an FLASH_OBInitStruct structure that contains the configuration information for the programming. Return values None: HAL_FLASHEx_OBGetUserData Function Name uint32_t HAL_FLASHEx_OBGetUserData (uint32_t DATAAdress) Function Description Get the Option byte user data. Parameters DATAAdress: Address of the option byte DATA This parameter can be one of the following values: OB_DATA_ADDRESS_DATA0 OB_DATA_ADDRESS_DATA1 Return values Value: programmed in USER data 18.3 FLASHEx Firmware driver defines 18.3.1 FLASHEx Option Byte BOOT1 OB_BOOT1_RESET BOOT1 Reset OB_BOOT1_SET BOOT1 Set Option Byte Data Address OB_DATA_ADDRESS_DATA0 OB_DATA_ADDRESS_DATA1 Option Byte IWatchdog OB_IWDG_SW Software IWDG selected OB_IWDG_HW Hardware IWDG selected Option Byte nRST STDBY OB_STDBY_NO_RST 230/832 No reset generated when entering in STANDBY DOCID026526 Rev 4 UM1786 OB_STDBY_RST Reset generated when entering in STANDBY Option Byte nRST STOP OB_STOP_NO_RST No reset generated when entering in STOP OB_STOP_RST Reset generated when entering in STOP Option Byte SRAM Parity Check Enable OB_SRAM_PARITY_SET SRAM parity check enable set OB_SRAM_PARITY_RESET SRAM parity check enable reset Option Byte Read Protection OB_RDP_LEVEL_0 OB_RDP_LEVEL_1 OB_RDP_LEVEL_2 Warning: When enabling read protection level 2 it's no more possible to go back to level 1 or 0 Option Bytes Type OPTIONBYTE_WRP WRP option byte configuration OPTIONBYTE_RDP RDP option byte configuration OPTIONBYTE_USER USER option byte configuration OPTIONBYTE_DATA DATA option byte configuration Option Byte VDDA Analog Monitoring OB_VDDA_ANALOG_ON Analog monitoring on VDDA Power source ON OB_VDDA_ANALOG_OFF Analog monitoring on VDDA Power source OFF FLASHEx OB Write Protection OB_WRP_PAGES0TO1 OB_WRP_PAGES2TO3 OB_WRP_PAGES4TO5 OB_WRP_PAGES6TO7 OB_WRP_PAGES8TO9 OB_WRP_PAGES10TO11 OB_WRP_PAGES12TO13 OB_WRP_PAGES14TO15 OB_WRP_PAGES16TO17 OB_WRP_PAGES18TO19 OB_WRP_PAGES20TO21 OB_WRP_PAGES22TO23 OB_WRP_PAGES24TO25 OB_WRP_PAGES26TO27 OB_WRP_PAGES28TO29 OB_WRP_PAGES30TO31 DOCID026526 Rev 4 231/832 UM1786 OB_WRP_PAGES32TO33 OB_WRP_PAGES34TO35 OB_WRP_PAGES36TO37 OB_WRP_PAGES38TO39 OB_WRP_PAGES40TO41 OB_WRP_PAGES42TO43 OB_WRP_PAGES44TO45 OB_WRP_PAGES46TO47 OB_WRP_PAGES48TO49 OB_WRP_PAGES50TO51 OB_WRP_PAGES52TO53 OB_WRP_PAGES54TO55 OB_WRP_PAGES56TO57 OB_WRP_PAGES58TO59 OB_WRP_PAGES60TO61 OB_WRP_PAGES62TO127 OB_WRP_PAGES0TO15MASK OB_WRP_PAGES16TO31MASK OB_WRP_PAGES32TO47MASK OB_WRP_PAGES32TO47MASK OB_WRP_PAGES48TO127MASK OB_WRP_PAGES48TO127MASK OB_WRP_ALLPAGES Write protection of all pages Option Byte WRP State OB_WRPSTATE_DISABLE Disable the write protection of the desired pages OB_WRPSTATE_ENABLE Enable the write protection of the desired pagess FLASHEx Page Size FLASH_PAGE_SIZE FLASH Type Erase 232/832 FLASH_TYPEERASE_PAGES Pages erase only FLASH_TYPEERASE_MASSERASE Flash mass erase activation DOCID026526 Rev 4 UM1786 19 HAL GPIO Generic Driver 19.1 GPIO Firmware driver registers structures 19.1.1 GPIO_InitTypeDef Data Fields uint32_t Pin uint32_t Mode uint32_t Pull uint32_t Speed uint32_t Alternate Field Documentation uint32_t GPIO_InitTypeDef::Pin Specifies the GPIO pins to be configured. This parameter can be any value of GPIO_pins uint32_t GPIO_InitTypeDef::Mode Specifies the operating mode for the selected pins. This parameter can be a value of GPIO_mode uint32_t GPIO_InitTypeDef::Pull Specifies the Pull-up or Pull-Down activation for the selected pins. This parameter can be a value of GPIO_pull uint32_t GPIO_InitTypeDef::Speed Specifies the speed for the selected pins. This parameter can be a value of GPIO_speed uint32_t GPIO_InitTypeDef::Alternate Peripheral to be connected to the selected pins This parameter can be a value of GPIOEx_Alternate_function_selection 19.2 GPIO Firmware driver API description 19.2.1 GPIO Peripheral features Each port bit of the general-purpose I/O (GPIO) ports can be individually configured by software in several modes: Input mode Analog mode Output mode Alternate function mode External interrupt/event lines During and just after reset, the alternate functions and external interrupt lines are not active and the I/O ports are configured in input floating mode. All GPIO pins have weak internal pull-up and pull-down resistors, which can be activated or not. DOCID026526 Rev 4 233/832 UM1786 19.2.2 How to use this driver 1. 2. 3. 4. 5. 6. 7. 8. 9. 19.2.3 In Output or Alternate mode, each IO can be configured on open-drain or push-pull type and the IO speed can be selected depending on the VDD value. The microcontroller IO pins are connected to onboard peripherals/modules through a multiplexer that allows only one peripheral alternate function (AF) connected to an IO pin at a time. In this way, there can be no conflict between peripherals sharing the same IO pin. All ports have external interrupt/event capability. To use external interrupt lines, the port must be configured in input mode. All available GPIO pins are connected to the 16 external interrupt/event lines from EXTI0 to EXTI15. The external interrupt/event controller consists of up to 23 edge detectors (16 lines are connected to GPIO) for generating event/interrupt requests (each input line can be independently configured to select the type (interrupt or event) and the corresponding trigger event (rising or falling or both). Each line can also be masked independently. Enable the GPIO AHB clock using the following function: __HAL_RCC_GPIOx_CLK_ENABLE(). Configure the GPIO pin(s) using HAL_GPIO_Init(). Configure the IO mode using "Mode" member from GPIO_InitTypeDef structure Activate Pull-up, Pull-down resistor using "Pull" member from GPIO_InitTypeDef structure. In case of Output or alternate function mode selection: the speed is configured through "Speed" member from GPIO_InitTypeDef structure. In alternate mode is selection, the alternate function connected to the IO is configured through "Alternate" member from GPIO_InitTypeDef structure. Analog mode is required when a pin is to be used as ADC channel or DAC output. In case of external interrupt/event selection the "Mode" member from GPIO_InitTypeDef structure select the type (interrupt or event) and the corresponding trigger event (rising or falling or both). In case of external interrupt/event mode selection, configure NVIC IRQ priority mapped to the EXTI line using HAL_NVIC_SetPriority() and enable it using HAL_NVIC_EnableIRQ(). To get the level of a pin configured in input mode use HAL_GPIO_ReadPin(). To set/reset the level of a pin configured in output mode use HAL_GPIO_WritePin()/HAL_GPIO_TogglePin(). To lock pin configuration until next reset use HAL_GPIO_LockPin(). During and just after reset, the alternate functions are not active and the GPIO pins are configured in input floating mode (except JTAG pins). The LSE oscillator pins OSC32_IN and OSC32_OUT can be used as general purpose (PC14 and PC15, respectively) when the LSE oscillator is off. The LSE has priority over the GPIO function. The HSE oscillator pins OSC_IN/OSC_OUT can be used as general purpose PF0 and PF1, respectively, when the HSE oscillator is off. The HSE has priority over the GPIO function. Initialization and de-initialization functions This section contains the following APIs: 234/832 HAL_GPIO_Init() HAL_GPIO_DeInit() DOCID026526 Rev 4 UM1786 19.2.4 IO operation functions This section contains the following APIs: 19.2.5 HAL_GPIO_ReadPin() HAL_GPIO_WritePin() HAL_GPIO_TogglePin() HAL_GPIO_LockPin() HAL_GPIO_EXTI_IRQHandler() HAL_GPIO_EXTI_Callback() Detailed description of functions HAL_GPIO_Init Function Name void HAL_GPIO_Init (GPIO_TypeDef * GPIOx, GPIO_InitTypeDef * GPIO_Init) Function Description Initialize the GPIOx peripheral according to the specified parameters in the GPIO_Init. Parameters Return values GPIOx: where x can be (A..F) to select the GPIO peripheral for STM32F3 family devices GPIO_Init: pointer to a GPIO_InitTypeDef structure that contains the configuration information for the specified GPIO peripheral. None: HAL_GPIO_DeInit Function Name void HAL_GPIO_DeInit (GPIO_TypeDef * GPIOx, uint32_t GPIO_Pin) Function Description De-initialize the GPIOx peripheral registers to their default reset values. Parameters Return values GPIOx: where x can be (A..F) to select the GPIO peripheral for STM32F30X device or STM32F37X device GPIO_Pin: specifies the port bit to be written. This parameter can be one of GPIO_PIN_x where x can be (0..15). None: HAL_GPIO_ReadPin Function Name GPIO_PinState HAL_GPIO_ReadPin (GPIO_TypeDef * GPIOx, uint16_t GPIO_Pin) Function Description Read the specified input port pin. Parameters Return values GPIOx: where x can be (A..F) to select the GPIO peripheral for STM32F3 family GPIO_Pin: specifies the port bit to read. This parameter can be GPIO_PIN_x where x can be (0..15). The: input port pin value. DOCID026526 Rev 4 235/832 UM1786 HAL_GPIO_WritePin Function Name void HAL_GPIO_WritePin (GPIO_TypeDef * GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState) Function Description Set or clear the selected data port bit. Parameters GPIOx: where x can be (A..F) to select the GPIO peripheral for STM32F3 family GPIO_Pin: specifies the port bit to be written. This parameter can be one of GPIO_PIN_x where x can be (0..15). PinState: specifies the value to be written to the selected bit. This parameter can be one of the GPIO_PinState enum values: GPIO_PIN_RESET: to clear the port pin GPIO_PIN_SET: to set the port pin Return values None: Notes This function uses GPIOx_BSRR and GPIOx_BRR registers to allow atomic read/modify accesses. In this way, there is no risk of an IRQ occurring between the read and the modify access. HAL_GPIO_TogglePin Function Name void HAL_GPIO_TogglePin (GPIO_TypeDef * GPIOx, uint16_t GPIO_Pin) Function Description Toggle the specified GPIO pin. Parameters Return values GPIOx: where x can be (A..F) to select the GPIO peripheral for STM32F3 family GPIO_Pin: specifies the pin to be toggled. None: HAL_GPIO_LockPin Function Name HAL_StatusTypeDef HAL_GPIO_LockPin (GPIO_TypeDef * GPIOx, uint16_t GPIO_Pin) Function Description Lock GPIO Pins configuration registers. Parameters GPIOx: where x can be (A..F) to select the GPIO peripheral for STM32L4 family GPIO_Pin: specifies the port bits to be locked. This parameter can be any combination of GPIO_Pin_x where x can be (0..15). Return values None: Notes The locked registers are GPIOx_MODER, GPIOx_OTYPER, GPIOx_OSPEEDR, GPIOx_PUPDR, GPIOx_AFRL and GPIOx_AFRH. The configuration of the locked GPIO pins can no longer be modified until the next reset. 236/832 DOCID026526 Rev 4 UM1786 HAL_GPIO_EXTI_IRQHandler Function Name void HAL_GPIO_EXTI_IRQHandler (uint16_t GPIO_Pin) Function Description Handle EXTI interrupt request. Parameters GPIO_Pin: Specifies the port pin connected to corresponding EXTI line. Return values None: HAL_GPIO_EXTI_Callback Function Name void HAL_GPIO_EXTI_Callback (uint16_t GPIO_Pin) Function Description EXTI line detection callback. Parameters GPIO_Pin: Specifies the port pin connected to corresponding EXTI line. Return values None: 19.3 GPIO Firmware driver defines 19.3.1 GPIO GPIO Exported Macros __HAL_GPIO_EXTI_GET_FLAG Description: Check whether the specified EXTI line flag is set or not. Parameters: __EXTI_LINE__: specifies the EXTI line flag to check. This parameter can be GPIO_PIN_x where x can be(0..15) Return value: __HAL_GPIO_EXTI_CLEAR_FLAG The: new state of __EXTI_LINE__ (SET or RESET). Description: Clear the EXTI's line pending flags. Parameters: __EXTI_LINE__: specifies the EXTI lines flags to clear. This parameter can be any combination of GPIO_PIN_x where x can be (0..15) Return value: __HAL_GPIO_EXTI_GET_IT None Description: Check whether the specified EXTI line is asserted or not. DOCID026526 Rev 4 237/832 UM1786 Parameters: __EXTI_LINE__: specifies the EXTI line to check. This parameter can be GPIO_PIN_x where x can be(0..15) Return value: __HAL_GPIO_EXTI_CLEAR_IT The: new state of __EXTI_LINE__ (SET or RESET). Description: Clear the EXTI's line pending bits. Parameters: __EXTI_LINE__: specifies the EXTI lines to clear. This parameter can be any combination of GPIO_PIN_x where x can be (0..15) Return value: __HAL_GPIO_EXTI_GENERATE_SWIT None Description: Generate a Software interrupt on selected EXTI line. Parameters: __EXTI_LINE__: specifies the EXTI line to check. This parameter can be GPIO_PIN_x where x can be(0..15) Return value: None GPIO mode 238/832 GPIO_MODE_INPUT Input Floating Mode GPIO_MODE_OUTPUT_PP Output Push Pull Mode GPIO_MODE_OUTPUT_OD Output Open Drain Mode GPIO_MODE_AF_PP Alternate Function Push Pull Mode GPIO_MODE_AF_OD Alternate Function Open Drain Mode GPIO_MODE_ANALOG Analog Mode GPIO_MODE_IT_RISING External Interrupt Mode with Rising edge trigger detection GPIO_MODE_IT_FALLING External Interrupt Mode with Falling edge trigger detection GPIO_MODE_IT_RISING_FALLING External Interrupt Mode with Rising/Falling edge trigger detection GPIO_MODE_EVT_RISING External Event Mode with Rising edge trigger detection DOCID026526 Rev 4 UM1786 GPIO_MODE_EVT_FALLING External Event Mode with Falling edge trigger detection GPIO_MODE_EVT_RISING_FALLING External Event Mode with Rising/Falling edge trigger detection GPIO pins GPIO_PIN_0 GPIO_PIN_1 GPIO_PIN_2 GPIO_PIN_3 GPIO_PIN_4 GPIO_PIN_5 GPIO_PIN_6 GPIO_PIN_7 GPIO_PIN_8 GPIO_PIN_9 GPIO_PIN_10 GPIO_PIN_11 GPIO_PIN_12 GPIO_PIN_13 GPIO_PIN_14 GPIO_PIN_15 GPIO_PIN_All GPIO_PIN_MASK GPIO pull GPIO_NOPULL No Pull-up or Pull-down activation GPIO_PULLUP Pull-up activation GPIO_PULLDOWN Pull-down activation GPIO speed GPIO_SPEED_FREQ_LOW range up to 2 MHz, please refer to the product datasheet GPIO_SPEED_FREQ_MEDIUM range 4 MHz to 10 MHz, please refer to the product datasheet GPIO_SPEED_FREQ_HIGH range 10 MHz to 50 MHz, please refer to the product datasheet DOCID026526 Rev 4 239/832 UM1786 20 HAL GPIO Extension Driver 20.1 GPIOEx Firmware driver defines 20.1.1 GPIOEx GPIOEx Alternate function selection GPIO_AF0_RTC_50Hz GPIO_AF0_MCO GPIO_AF0_TAMPER GPIO_AF0_SWJ GPIO_AF0_TRACE GPIO_AF1_TIM2 GPIO_AF1_TIM15 GPIO_AF1_TIM16 GPIO_AF1_TIM17 GPIO_AF1_EVENTOUT GPIO_AF2_TIM1 GPIO_AF2_TIM2 GPIO_AF2_TIM3 GPIO_AF2_TIM4 GPIO_AF2_TIM8 GPIO_AF2_TIM15 GPIO_AF2_COMP1 GPIO_AF3_TSC GPIO_AF3_TIM8 GPIO_AF3_COMP7 GPIO_AF3_TIM15 GPIO_AF4_TIM1 GPIO_AF4_TIM8 GPIO_AF4_TIM16 GPIO_AF4_TIM17 GPIO_AF4_I2C1 GPIO_AF4_I2C2 GPIO_AF5_SPI1 GPIO_AF5_SPI2 GPIO_AF5_SPI3 240/832 DOCID026526 Rev 4 UM1786 GPIO_AF5_I2S GPIO_AF5_I2S2ext GPIO_AF5_TIM8 GPIO_AF5_IR GPIO_AF5_UART4 GPIO_AF5_UART5 GPIO_AF6_SPI2 GPIO_AF6_SPI3 GPIO_AF6_I2S3ext GPIO_AF6_TIM1 GPIO_AF6_TIM8 GPIO_AF6_IR GPIO_AF7_USART1 GPIO_AF7_USART2 GPIO_AF7_USART3 GPIO_AF7_COMP3 GPIO_AF7_COMP5 GPIO_AF7_COMP6 GPIO_AF7_CAN GPIO_AF8_COMP1 GPIO_AF8_COMP2 GPIO_AF8_COMP3 GPIO_AF8_COMP4 GPIO_AF8_COMP5 GPIO_AF8_COMP6 GPIO_AF9_CAN GPIO_AF9_TIM1 GPIO_AF9_TIM8 GPIO_AF9_TIM15 GPIO_AF10_TIM2 GPIO_AF10_TIM3 GPIO_AF10_TIM4 GPIO_AF10_TIM8 GPIO_AF10_TIM17 GPIO_AF11_TIM1 GPIO_AF11_TIM8 DOCID026526 Rev 4 241/832 UM1786 GPIO_AF12_TIM1 GPIO_AF14_USB GPIO_AF15_EVENTOUT IS_GPIO_AF GPIOEx_Get Port Index GPIO_GET_INDEX 242/832 DOCID026526 Rev 4 UM1786 21 HAL HRTIM Generic Driver 21.1 HRTIM Firmware driver registers structures 21.1.1 HRTIM_InitTypeDef Data Fields uint32_t HRTIMInterruptResquests uint32_t SyncOptions uint32_t SyncInputSource uint32_t SyncOutputSource uint32_t SyncOutputPolarity Field Documentation 21.1.2 uint32_t HRTIM_InitTypeDef::HRTIMInterruptResquests Specifies which interrupts requests must enabled for the HRTIM instance. This parameter can be any combination of HRTIM_Common_Interrupt_Enable uint32_t HRTIM_InitTypeDef::SyncOptions Specifies how the HRTIM instance handles the external synchronization signals. The HRTIM instance can be configured to act as a slave (waiting for a trigger to be synchronized) or a master (generating a synchronization signal) or both. This parameter can be a combination of HRTIM_Synchronization_Options. uint32_t HRTIM_InitTypeDef::SyncInputSource Specifies the external synchronization input source (significant only when the HRTIM instance is configured as a slave). This parameter can be a value of HRTIM_Synchronization_Input_Source. uint32_t HRTIM_InitTypeDef::SyncOutputSource Specifies the source and event to be sent on the external synchronization outputs (significant only when the HRTIM instance is configured as a master). This parameter can be a value of HRTIM_Synchronization_Output_Source uint32_t HRTIM_InitTypeDef::SyncOutputPolarity Specifies the conditioning of the event to be sent on the external synchronization outputs (significant only when the HRTIM instance is configured as a master). This parameter can be a value of HRTIM_Synchronization_Output_Polarity HRTIM_TimerParamTypeDef Data Fields uint32_t CaptureTrigger1 uint32_t CaptureTrigger2 uint32_t InterruptRequests uint32_t DMARequests uint32_t DMASrcAddress uint32_t DMADstAddress uint32_t DMASize DOCID026526 Rev 4 243/832 UM1786 Field Documentation 21.1.3 uint32_t HRTIM_TimerParamTypeDef::CaptureTrigger1 Event(s) triggering capture unit 1. When the timer operates in Simple mode, this parameter can be a value of HRTIM_External_Event_Channels. When the timer operates in Waveform mode, this parameter can be a combination of HRTIM_Capture_Unit_Trigger. uint32_t HRTIM_TimerParamTypeDef::CaptureTrigger2 Event(s) triggering capture unit 2. When the timer operates in Simple mode, this parameter can be a value of HRTIM_External_Event_Channels. When the timer operates in Waveform mode, this parameter can be a combination of HRTIM_Capture_Unit_Trigger. uint32_t HRTIM_TimerParamTypeDef::InterruptRequests Interrupts requests enabled for the timer. uint32_t HRTIM_TimerParamTypeDef::DMARequests DMA requests enabled for the timer. uint32_t HRTIM_TimerParamTypeDef::DMASrcAddress Address of the source address of the DMA transfer. uint32_t HRTIM_TimerParamTypeDef::DMADstAddress Address of the destination address of the DMA transfer. uint32_t HRTIM_TimerParamTypeDef::DMASize Size of the DMA transfer __HRTIM_HandleTypeDef Data Fields HRTIM_TypeDef * Instance HRTIM_InitTypeDef Init HRTIM_TimerParamTypeDef TimerParam HAL_LockTypeDef Lock __IO HAL_HRTIM_StateTypeDef State DMA_HandleTypeDef * hdmaMaster DMA_HandleTypeDef * hdmaTimerA DMA_HandleTypeDef * hdmaTimerB DMA_HandleTypeDef * hdmaTimerC DMA_HandleTypeDef * hdmaTimerD DMA_HandleTypeDef * hdmaTimerE Field Documentation 244/832 HRTIM_TypeDef* __HRTIM_HandleTypeDef::Instance Register base address HRTIM_InitTypeDef __HRTIM_HandleTypeDef::Init HRTIM required parameters HRTIM_TimerParamTypeDef __HRTIM_HandleTypeDef::TimerParam[MAX_HRTIM_TIMER] HRTIM timers - including the master - parameters HAL_LockTypeDef __HRTIM_HandleTypeDef::Lock Locking object DOCID026526 Rev 4 UM1786 21.1.4 __IO HAL_HRTIM_StateTypeDef __HRTIM_HandleTypeDef::State HRTIM communication state DMA_HandleTypeDef* __HRTIM_HandleTypeDef::hdmaMaster Master timer DMA handle parameters DMA_HandleTypeDef* __HRTIM_HandleTypeDef::hdmaTimerA Timer A DMA handle parameters DMA_HandleTypeDef* __HRTIM_HandleTypeDef::hdmaTimerB Timer B DMA handle parameters DMA_HandleTypeDef* __HRTIM_HandleTypeDef::hdmaTimerC Timer C DMA handle parameters DMA_HandleTypeDef* __HRTIM_HandleTypeDef::hdmaTimerD Timer D DMA handle parameters DMA_HandleTypeDef* __HRTIM_HandleTypeDef::hdmaTimerE Timer E DMA handle parameters HRTIM_TimeBaseCfgTypeDef Data Fields uint32_t Period uint32_t RepetitionCounter uint32_t PrescalerRatio uint32_t Mode Field Documentation 21.1.5 uint32_t HRTIM_TimeBaseCfgTypeDef::Period Specifies the timer period. The period value must be above 3 periods of the fHRTIM clock. Maximum value is = 0xFFDF uint32_t HRTIM_TimeBaseCfgTypeDef::RepetitionCounter Specifies the timer repetition period. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF. uint32_t HRTIM_TimeBaseCfgTypeDef::PrescalerRatio Specifies the timer clock prescaler ratio. This parameter can be any value of HRTIM_Prescaler_Ratio uint32_t HRTIM_TimeBaseCfgTypeDef::Mode Specifies the counter operating mode. This parameter can be any value of HRTIM_Counter_Operating_Mode HRTIM_SimpleOCChannelCfgTypeDef Data Fields uint32_t Mode uint32_t Pulse uint32_t Polarity uint32_t IdleLevel Field Documentation DOCID026526 Rev 4 245/832 UM1786 21.1.6 uint32_t HRTIM_SimpleOCChannelCfgTypeDef::Mode Specifies the output compare mode (toggle, active, inactive). This parameter can be any value of of HRTIM_Simple_OC_Mode uint32_t HRTIM_SimpleOCChannelCfgTypeDef::Pulse Specifies the compare value to be loaded into the Compare Register. The compare value must be above or equal to 3 periods of the fHRTIM clock uint32_t HRTIM_SimpleOCChannelCfgTypeDef::Polarity Specifies the output polarity. This parameter can be any value of HRTIM_Output_Polarity uint32_t HRTIM_SimpleOCChannelCfgTypeDef::IdleLevel Specifies whether the output level is active or inactive when in IDLE state. This parameter can be any value of HRTIM_Output_IDLE_Level HRTIM_SimplePWMChannelCfgTypeDef Data Fields uint32_t Pulse uint32_t Polarity uint32_t IdleLevel Field Documentation 21.1.7 uint32_t HRTIM_SimplePWMChannelCfgTypeDef::Pulse Specifies the compare value to be loaded into the Compare Register. The compare value must be above or equal to 3 periods of the fHRTIM clock uint32_t HRTIM_SimplePWMChannelCfgTypeDef::Polarity Specifies the output polarity. This parameter can be any value of HRTIM_Output_Polarity uint32_t HRTIM_SimplePWMChannelCfgTypeDef::IdleLevel Specifies whether the output level is active or inactive when in IDLE state. This parameter can be any value of HRTIM_Output_IDLE_Level HRTIM_SimpleCaptureChannelCfgTypeDef Data Fields uint32_t Event uint32_t EventPolarity uint32_t EventSensitivity uint32_t EventFilter Field Documentation 246/832 uint32_t HRTIM_SimpleCaptureChannelCfgTypeDef::Event Specifies the external event triggering the capture. This parameter can be any 'EEVx' value of HRTIM_External_Event_Channels DOCID026526 Rev 4 UM1786 21.1.8 uint32_t HRTIM_SimpleCaptureChannelCfgTypeDef::EventPolarity Specifies the polarity of the external event (in case of level sensitivity). This parameter can be a value of HRTIM_External_Event_Polarity uint32_t HRTIM_SimpleCaptureChannelCfgTypeDef::EventSensitivity Specifies the sensitivity of the external event. This parameter can be a value of HRTIM_External_Event_Sensitivity uint32_t HRTIM_SimpleCaptureChannelCfgTypeDef::EventFilter Defines the frequency used to sample the External Event and the length of the digital filter. This parameter can be a value of HRTIM_External_Event_Filter HRTIM_SimpleOnePulseChannelCfgTypeDef Data Fields uint32_t Pulse uint32_t OutputPolarity uint32_t OutputIdleLevel uint32_t Event uint32_t EventPolarity uint32_t EventSensitivity uint32_t EventFilter Field Documentation 21.1.9 uint32_t HRTIM_SimpleOnePulseChannelCfgTypeDef::Pulse Specifies the compare value to be loaded into the Compare Register. The compare value must be above or equal to 3 periods of the fHRTIM clock uint32_t HRTIM_SimpleOnePulseChannelCfgTypeDef::OutputPolarity Specifies the output polarity. This parameter can be any value of HRTIM_Output_Polarity uint32_t HRTIM_SimpleOnePulseChannelCfgTypeDef::OutputIdleLevel Specifies whether the output level is active or inactive when in IDLE state. This parameter can be any value of HRTIM_Output_IDLE_Level uint32_t HRTIM_SimpleOnePulseChannelCfgTypeDef::Event Specifies the external event triggering the pulse generation. This parameter can be any 'EEVx' value of HRTIM_External_Event_Channels uint32_t HRTIM_SimpleOnePulseChannelCfgTypeDef::EventPolarity Specifies the polarity of the external event (in case of level sensitivity). This parameter can be a value of HRTIM_External_Event_Polarity uint32_t HRTIM_SimpleOnePulseChannelCfgTypeDef::EventSensitivity Specifies the sensitivity of the external event. This parameter can be a value of HRTIM_External_Event_Sensitivity. uint32_t HRTIM_SimpleOnePulseChannelCfgTypeDef::EventFilter Defines the frequency used to sample the External Event and the length of the digital filter. This parameter can be a value of HRTIM_External_Event_Filter HRTIM_TimerCfgTypeDef Data Fields DOCID026526 Rev 4 247/832 UM1786 uint32_t InterruptRequests uint32_t DMARequests uint32_t DMASrcAddress uint32_t DMADstAddress uint32_t DMASize uint32_t HalfModeEnable uint32_t StartOnSync uint32_t ResetOnSync uint32_t DACSynchro uint32_t PreloadEnable uint32_t UpdateGating uint32_t BurstMode uint32_t RepetitionUpdate uint32_t PushPull uint32_t FaultEnable uint32_t FaultLock uint32_t DeadTimeInsertion uint32_t DelayedProtectionMode uint32_t UpdateTrigger uint32_t ResetTrigger uint32_t ResetUpdate Field Documentation 248/832 uint32_t HRTIM_TimerCfgTypeDef::InterruptRequests Relevant for all HRTIM timers, including the master. Specifies which interrupts requests must enabled for the timer. This parameter can be any combination of HRTIM_Master_Interrupt_Enable or HRTIM_Timing_Unit_Interrupt_Enable uint32_t HRTIM_TimerCfgTypeDef::DMARequests Relevant for all HRTIM timers, including the master. Specifies which DMA requests must be enabled for the timer. This parameter can be any combination of HRTIM_Master_DMA_Request_Enable or HRTIM_Timing_Unit_DMA_Request_Enable uint32_t HRTIM_TimerCfgTypeDef::DMASrcAddress Relevant for all HRTIM timers, including the master. Specifies the address of the source address of the DMA transfer uint32_t HRTIM_TimerCfgTypeDef::DMADstAddress Relevant for all HRTIM timers, including the master. Specifies the address of the destination address of the DMA transfer uint32_t HRTIM_TimerCfgTypeDef::DMASize Relevant for all HRTIM timers, including the master. Specifies the size of the DMA transfer uint32_t HRTIM_TimerCfgTypeDef::HalfModeEnable Relevant for all HRTIM timers, including the master. Specifies whether or not hald mode is enabled This parameter can be any value of HRTIM_Half_Mode_Enable uint32_t HRTIM_TimerCfgTypeDef::StartOnSync Relevant for all HRTIM timers, including the master. Specifies whether or not timer is reset by a rising edge on the synchronization input (when enabled). This parameter can be any value of HRTIM_Start_On_Sync_Input_Event uint32_t HRTIM_TimerCfgTypeDef::ResetOnSync Relevant for all HRTIM timers, including the master. Specifies whether or not timer is reset by a rising edge on the synchronization input (when enabled). This parameter can be any value of HRTIM_Reset_On_Sync_Input_Event DOCID026526 Rev 4 UM1786 21.1.10 uint32_t HRTIM_TimerCfgTypeDef::DACSynchro Relevant for all HRTIM timers, including the master. Indicates whether or not the a DAC synchronization event is generated. This parameter can be any value of HRTIM_DAC_Synchronization uint32_t HRTIM_TimerCfgTypeDef::PreloadEnable Relevant for all HRTIM timers, including the master. Specifies whether or not register preload is enabled. This parameter can be any value of HRTIM_Register_Preload_Enable uint32_t HRTIM_TimerCfgTypeDef::UpdateGating Relevant for all HRTIM timers, including the master. Specifies how the update occurs with respect to a burst DMA transaction or update enable inputs (Slave timers only). This parameter can be any value of HRTIM_Update_Gating uint32_t HRTIM_TimerCfgTypeDef::BurstMode Relevant for all HRTIM timers, including the master. Specifies how the timer behaves during a burst mode operation. This parameter can be any value of HRTIM_Timer_Burst_Mode uint32_t HRTIM_TimerCfgTypeDef::RepetitionUpdate Relevant for all HRTIM timers, including the master. Specifies whether or not registers update is triggered by the repetition event. This parameter can be any value of HRTIM_Timer_Repetition_Update uint32_t HRTIM_TimerCfgTypeDef::PushPull Relevant for Timer A to Timer E. Specifies whether or not the push-pull mode is enabled. This parameter can be any value of HRTIM_Timer_Push_Pull_Mode uint32_t HRTIM_TimerCfgTypeDef::FaultEnable Relevant for Timer A to Timer E. Specifies which fault channels are enabled for the timer. This parameter can be a combination of HRTIM_Timer_Fault_Enabling uint32_t HRTIM_TimerCfgTypeDef::FaultLock Relevant for Timer A to Timer E. Specifies whether or not fault enabling status is write protected. This parameter can be a value of HRTIM_Timer_Fault_Lock uint32_t HRTIM_TimerCfgTypeDef::DeadTimeInsertion Relevant for Timer A to Timer E. Specifies whether or not dead-time insertion is enabled for the timer. This parameter can be a value of HRTIM_Timer_Deadtime_Insertion uint32_t HRTIM_TimerCfgTypeDef::DelayedProtectionMode Relevant for Timer A to Timer E. Specifies the delayed protection mode. This parameter can be a value of HRTIM_Timer_Delayed_Protection_Mode uint32_t HRTIM_TimerCfgTypeDef::UpdateTrigger Relevant for Timer A to Timer E. Specifies source(s) triggering the timer registers update. This parameter can be a combination of HRTIM_Timer_Update_Trigger uint32_t HRTIM_TimerCfgTypeDef::ResetTrigger Relevant for Timer A to Timer E. Specifies source(s) triggering the timer counter reset. This parameter can be a combination of HRTIM_Timer_Reset_Trigger uint32_t HRTIM_TimerCfgTypeDef::ResetUpdate Relevant for Timer A to Timer E. Specifies whether or not registers update is triggered when the timer counter is reset. This parameter can be a value of HRTIM_Timer_Reset_Update HRTIM_CompareCfgTypeDef Data Fields uint32_t CompareValue uint32_t AutoDelayedMode DOCID026526 Rev 4 249/832 UM1786 uint32_t AutoDelayedTimeout Field Documentation 21.1.11 uint32_t HRTIM_CompareCfgTypeDef::CompareValue Specifies the compare value of the timer compare unit. The minimum value must be greater than or equal to 3 periods of the fHRTIM clock. The maximum value must be less than or equal to 0xFFFF - 1 periods of the fHRTIM clock uint32_t HRTIM_CompareCfgTypeDef::AutoDelayedMode Specifies the auto delayed mode for compare unit 2 or 4. This parameter can be a value of HRTIM_Compare_Unit_Auto_Delayed_Mode uint32_t HRTIM_CompareCfgTypeDef::AutoDelayedTimeout Specifies compare value for timing unit 1 or 3 when auto delayed mode with time out is selected. CompareValue + AutoDelayedTimeout must be less than 0xFFFF HRTIM_CaptureCfgTypeDef Data Fields uint32_t Trigger Field Documentation 21.1.12 uint32_t HRTIM_CaptureCfgTypeDef::Trigger Specifies source(s) triggering the capture. This parameter can be a combination of HRTIM_Capture_Unit_Trigger HRTIM_OutputCfgTypeDef Data Fields uint32_t Polarity uint32_t SetSource uint32_t ResetSource uint32_t IdleMode uint32_t IdleLevel uint32_t FaultLevel uint32_t ChopperModeEnable uint32_t BurstModeEntryDelayed Field Documentation 250/832 uint32_t HRTIM_OutputCfgTypeDef::Polarity Specifies the output polarity. This parameter can be any value of HRTIM_Output_Polarity uint32_t HRTIM_OutputCfgTypeDef::SetSource Specifies the event(s) transitioning the output from its inactive level to its active level. This parameter can be a combination of HRTIM_Output_Set_Source DOCID026526 Rev 4 UM1786 21.1.13 uint32_t HRTIM_OutputCfgTypeDef::ResetSource Specifies the event(s) transitioning the output from its active level to its inactive level. This parameter can be a combination of HRTIM_Output_Reset_Source uint32_t HRTIM_OutputCfgTypeDef::IdleMode Specifies whether or not the output is affected by a burst mode operation. This parameter can be any value of HRTIM_Output_Idle_Mode uint32_t HRTIM_OutputCfgTypeDef::IdleLevel Specifies whether the output level is active or inactive when in IDLE state. This parameter can be any value of HRTIM_Output_IDLE_Level uint32_t HRTIM_OutputCfgTypeDef::FaultLevel Specifies whether the output level is active or inactive when in FAULT state. This parameter can be any value of HRTIM_Output_FAULT_Level uint32_t HRTIM_OutputCfgTypeDef::ChopperModeEnable Indicates whether or not the chopper mode is enabled This parameter can be any value of HRTIM_Output_Chopper_Mode_Enable uint32_t HRTIM_OutputCfgTypeDef::BurstModeEntryDelayed Indicates whether or not dead-time is inserted when entering the IDLE state during a burst mode operation. This parameters can be any value of HRTIM_Output_Burst_Mode_Entry_Delayed HRTIM_TimerEventFilteringCfgTypeDef Data Fields uint32_t Filter uint32_t Latch Field Documentation 21.1.14 uint32_t HRTIM_TimerEventFilteringCfgTypeDef::Filter Specifies the type of event filtering within the timing unit. This parameter can be a value of HRTIM_Timer_External_Event_Filter uint32_t HRTIM_TimerEventFilteringCfgTypeDef::Latch Specifies whether or not the signal is latched. This parameter can be a value of HRTIM_Timer_External_Event_Latch HRTIM_DeadTimeCfgTypeDef Data Fields uint32_t Prescaler uint32_t RisingValue uint32_t RisingSign uint32_t RisingLock uint32_t RisingSignLock uint32_t FallingValue uint32_t FallingSign uint32_t FallingLock uint32_t FallingSignLock DOCID026526 Rev 4 251/832 UM1786 Field Documentation 21.1.15 uint32_t HRTIM_DeadTimeCfgTypeDef::Prescaler Specifies the Deadtime Prescaler. This parameter can be a value of HRTIM_Deadtime_Prescaler_Ratio uint32_t HRTIM_DeadTimeCfgTypeDef::RisingValue Specifies the Deadtime following a rising edge. This parameter can be a number between 0x0 and 0x1FF uint32_t HRTIM_DeadTimeCfgTypeDef::RisingSign Specifies whether the deadtime is positive or negative on rising edge. This parameter can be a value of HRTIM_Deadtime_Rising_Sign uint32_t HRTIM_DeadTimeCfgTypeDef::RisingLock Specifies whether or not deadtime rising settings (value and sign) are write protected. This parameter can be a value of HRTIM_Deadtime_Rising_Lock uint32_t HRTIM_DeadTimeCfgTypeDef::RisingSignLock Specifies whether or not deadtime rising sign is write protected. This parameter can be a value of HRTIM_Deadtime_Rising_Sign_Lock uint32_t HRTIM_DeadTimeCfgTypeDef::FallingValue Specifies the Deadtime following a falling edge. This parameter can be a number between 0x0 and 0x1FF uint32_t HRTIM_DeadTimeCfgTypeDef::FallingSign Specifies whether the deadtime is positive or negative on falling edge. This parameter can be a value of HRTIM_Deadtime_Falling_Sign uint32_t HRTIM_DeadTimeCfgTypeDef::FallingLock Specifies whether or not deadtime falling settings (value and sign) are write protected. This parameter can be a value of HRTIM_Deadtime_Falling_Lock uint32_t HRTIM_DeadTimeCfgTypeDef::FallingSignLock Specifies whether or not deadtime falling sign is write protected. This parameter can be a value of HRTIM_Deadtime_Falling_Sign_Lock HRTIM_ChopperModeCfgTypeDef Data Fields uint32_t CarrierFreq uint32_t DutyCycle uint32_t StartPulse Field Documentation 252/832 uint32_t HRTIM_ChopperModeCfgTypeDef::CarrierFreq Specifies the Timer carrier frequency value. This parameter can be a value of HRTIM_Chopper_Frequency uint32_t HRTIM_ChopperModeCfgTypeDef::DutyCycle Specifies the Timer chopper duty cycle value. This parameter can be a value of HRTIM_Chopper_Duty_Cycle uint32_t HRTIM_ChopperModeCfgTypeDef::StartPulse Specifies the Timer pulse width value. This parameter can be a value of HRTIM_Chopper_Start_Pulse_Width DOCID026526 Rev 4 UM1786 21.1.16 HRTIM_EventCfgTypeDef Data Fields uint32_t Source uint32_t Polarity uint32_t Sensitivity uint32_t Filter uint32_t FastMode Field Documentation 21.1.17 uint32_t HRTIM_EventCfgTypeDef::Source Identifies the source of the external event. This parameter can be a value of HRTIM_External_Event_Sources uint32_t HRTIM_EventCfgTypeDef::Polarity Specifies the polarity of the external event (in case of level sensitivity). This parameter can be a value of HRTIM_External_Event_Polarity uint32_t HRTIM_EventCfgTypeDef::Sensitivity Specifies the sensitivity of the external event. This parameter can be a value of HRTIM_External_Event_Sensitivity uint32_t HRTIM_EventCfgTypeDef::Filter Defines the frequency used to sample the External Event and the length of the digital filter. This parameter can be a value of HRTIM_External_Event_Filter uint32_t HRTIM_EventCfgTypeDef::FastMode Indicates whether or not low latency mode is enabled for the external event. This parameter can be a value of HRTIM_External_Event_Fast_Mode HRTIM_FaultCfgTypeDef Data Fields uint32_t Source uint32_t Polarity uint32_t Filter uint32_t Lock Field Documentation uint32_t HRTIM_FaultCfgTypeDef::Source Identifies the source of the fault. This parameter can be a value of HRTIM_Fault_Sources uint32_t HRTIM_FaultCfgTypeDef::Polarity Specifies the polarity of the fault event. This parameter can be a value of HRTIM_Fault_Polarity uint32_t HRTIM_FaultCfgTypeDef::Filter Defines the frequency used to sample the Fault input and the length of the digital filter. This parameter can be a value of HRTIM_Fault_Filter DOCID026526 Rev 4 253/832 UM1786 21.1.18 uint32_t HRTIM_FaultCfgTypeDef::Lock Indicates whether or not fault programming bits are write protected. This parameter can be a value of HRTIM_Fault_Lock HRTIM_BurstModeCfgTypeDef Data Fields uint32_t Mode uint32_t ClockSource uint32_t Prescaler uint32_t PreloadEnable uint32_t Trigger uint32_t IdleDuration uint32_t Period Field Documentation 21.1.19 uint32_t HRTIM_BurstModeCfgTypeDef::Mode Specifies the burst mode operating mode. This parameter can be a value of HRTIM_Burst_Mode_Operating_Mode uint32_t HRTIM_BurstModeCfgTypeDef::ClockSource Specifies the burst mode clock source. This parameter can be a value of HRTIM_Burst_Mode_Clock_Source uint32_t HRTIM_BurstModeCfgTypeDef::Prescaler Specifies the burst mode prescaler. This parameter can be a value of HRTIM_Burst_Mode_Prescaler uint32_t HRTIM_BurstModeCfgTypeDef::PreloadEnable Specifies whether or not preload is enabled for burst mode related registers (HRTIM_BMCMPR and HRTIM_BMPER). This parameter can be a combination of HRTIM_Burst_Mode_Register_Preload_Enable uint32_t HRTIM_BurstModeCfgTypeDef::Trigger Specifies the event(s) triggering the burst operation. This parameter can be a combination of HRTIM_Burst_Mode_Trigger uint32_t HRTIM_BurstModeCfgTypeDef::IdleDuration Specifies number of periods during which the selected timers are in idle state. This parameter can be a number between 0x0 and 0xFFFF uint32_t HRTIM_BurstModeCfgTypeDef::Period Specifies burst mode repetition period. This parameter can be a number between 0x1 and 0xFFFF HRTIM_ADCTriggerCfgTypeDef Data Fields 254/832 uint32_t UpdateSource uint32_t Trigger DOCID026526 Rev 4 UM1786 Field Documentation uint32_t HRTIM_ADCTriggerCfgTypeDef::UpdateSource Specifies the ADC trigger update source. This parameter can be a combination of HRTIM_ADC_Trigger_Update_Source uint32_t HRTIM_ADCTriggerCfgTypeDef::Trigger Specifies the event(s) triggering the ADC conversion. This parameter can be a value of HRTIM_ADC_Trigger_Event 21.2 HRTIM Firmware driver API description 21.2.1 Simple mode v.s. waveform mode The HRTIM HAL API is split into 2 categories: 1. 2. 21.2.2 Simple functions: these functions allow for using a HRTIM timer as a general purpose timer with high resolution capabilities. HRTIM simple modes are managed through the set of functions named HAL_HRTIM_Simple<Function>. These functions are similar in name and usage to the one defined for the TIM peripheral. When a HRTIM timer operates in simple mode, only a very limited set of HRTIM features are used. Following simple modes are proposed: Output compare mode, PWM output mode, Input capture mode, One pulse mode. Waveform functions: These functions allow taking advantage of the HRTIM flexibility to produce numerous types of control signal. When a HRTIM timer operates in waveform mode, all the HRTIM features are accessible without any restriction. HRTIM waveform modes are managed through the set of functions named HAL_HRTIM_Waveform<Function> How to use this driver 1. Initialize the HRTIM low level resources by implementing the HAL_HRTIM_MspInit() function: a. Enable the HRTIM clock source using __HRTIMx_CLK_ENABLE() b. Connect HRTIM pins to MCU I/Os Enable the clock for the HRTIM GPIOs using the following function: __HAL_RCC_GPIOx_CLK_ENABLE() Configure these GPIO pins in Alternate Function mode using HAL_GPIO_Init() c. When using DMA to control data transfer (e.g HAL_HRTIM_SimpleBaseStart_DMA()) Enable the DMAx interface clock using __DMAx_CLK_ENABLE() Initialize the DMA handle Associate the initialized DMA handle to the appropriate DMA handle of the HRTIM handle using __HAL_LINKDMA() Initialize the DMA channel using HAL_DMA_Init() Configure the priority and enable the NVIC for the transfer complete interrupt on the DMA channel using HAL_NVIC_SetPriority() and HAL_NVIC_EnableIRQ() d. In case of using interrupt mode (e.g HAL_HRTIM_SimpleBaseStart_IT()) DOCID026526 Rev 4 255/832 UM1786 2. 3. 4. 5. 6. 256/832 Configure the priority and enable the NVIC for the concerned HRTIM interrupt using HAL_NVIC_SetPriority() and HAL_NVIC_EnableIRQ() Initialize the HRTIM HAL using HAL_HRTIM_Init(). The HRTIM configuration structure (field of the HRTIM handle) specifies which global interrupt of whole HRTIM must be enabled (Burst mode period, System fault, Faults). It also contains the HRTIM external synchronization configuration. HRTIM can act as a master (generating a synchronization signal) or as a slave (waiting for a trigger to be synchronized). Start the high resolution unit using HAL_HRTIM_DLLCalibrationStart(). DLL calibration is executed periodically and compensate for potential voltage and temperature drifts. DLL calibration period is specified by the CalibrationRate argument. HRTIM timers cannot be used until the high resolution unit is ready. This can be checked using HAL_HRTIM_PollForDLLCalibration(): this function returns HAL_OK if DLL calibration is completed or HAL_TIMEOUT if the DLL calibration is still going on when timeout given as argument expires. DLL calibration can also be started in interrupt mode using HAL_HRTIM_DLLCalibrationStart_IT(). In that case an interrupt is generated when the DLL calibration is completed. Note that as DLL calibration is executed on a periodic basis an interrupt will be generated at the end of every DLL calibration operation (worst case: one interrupt every 14 micro seconds !). Configure HRTIM resources shared by all HRTIM timers a. Burst Mode Controller: HAL_HRTIM_BurstModeConfig(): configures the HRTIM burst mode controller: operating mode (continuous or one-shot mode), clock (source, prescaler) , trigger(s), period, idle duration. b. External Events Conditionning: HAL_HRTIM_EventConfig(): configures the conditioning of an external event channel: source, polarity, edge-sensitivity. External event can be used as triggers (timer reset, input capture, burst mode, ADC triggers, delayed protection) They can also be used to set or reset timer outputs. Up to 10 event channels are available. HAL_HRTIM_EventPrescalerConfig(): configures the external event sampling clock (used for digital filtering). c. Fault Conditionning: HAL_HRTIM_FaultConfig(): configures the conditioning of a fault channel: source, polarity, edge-sensitivity. Fault channels are used to disable the outputs in case of an abnormal operation. Up to 5 fault channels are available. HAL_HRTIM_FaultPrescalerConfig(): configures the fault sampling clock (used for digital filtering). HAL_HRTIM_FaultModeCtl(): Enables or disables fault input(s) circuitry. By default all fault inputs are disabled. d. ADC trigger: HAL_HRTIM_ADCTriggerConfig(): configures the source triggering the update of the ADC trigger register and the ADC trigger. 4 independent triggers are available to start both the regular and the injected sequencers of the 2 ADCs Configure HRTIM timer time base using HAL_HRTIM_TimeBaseConfig(). This function must be called whatever the HRTIM timer operating mode is (simple v.s. waveform). It configures mainly: a. The HRTIM timer counter operating mode (continuous v.s. one shot) b. The HRTIM timer clock prescaler c. The HRTIM timer period d. The HRTIM timer repetition counter DOCID026526 Rev 4 UM1786 If the HRTIM timer operates in simple mode 1. Start or Stop simple timers Simple time base: HAL_HRTIM_SimpleBaseStart(),HAL_HRTIM_SimpleBaseStop(), HAL_HRTIM_SimpleBaseStart_IT(),HAL_HRTIM_SimpleBaseStop_IT(), HAL_HRTIM_SimpleBaseStart_DMA(),HAL_HRTIM_SimpleBaseStop_DMA(). Simple output compare: HAL_HRTIM_SimpleOCChannelConfig(), HAL_HRTIM_SimpleOCStart(),HAL_HRTIM_SimpleOCStop(), HAL_HRTIM_SimpleOCStart_IT(),HAL_HRTIM_SimpleOCStop_IT(), HAL_HRTIM_SimpleOCStart_DMA(),HAL_HRTIM_SimpleOCStop_DMA(), Simple PWM output: HAL_HRTIM_SimplePWMChannelConfig(), HAL_HRTIM_SimplePWMStart(),HAL_HRTIM_SimplePWMStop(), HAL_HRTIM_SimplePWMStart_IT(),HAL_HRTIM_SimplePWMStop_IT(), HAL_HRTIM_SimplePWMStart_DMA(),HAL_HRTIM_SimplePWMStop_DMA(), Simple input capture: HAL_HRTIM_SimpleCaptureChannelConfig(), HAL_HRTIM_SimpleCaptureStart(),HAL_HRTIM_SimpleCaptureStop(), HAL_HRTIM_SimpleCaptureStart_IT(),HAL_HRTIM_SimpleCaptureStop_IT(), HAL_HRTIM_SimpleCaptureStart_DMA(),HAL_HRTIM_SimpleCaptureStop_DM A(). Simple one pulse: HAL_HRTIM_SimpleOnePulseChannelConfig(), HAL_HRTIM_SimpleOnePulseStart(),HAL_HRTIM_SimpleOnePulseStop(), HAL_HRTIM_SimpleOnePulseStart_IT(),HAL_HRTIM_SimpleOnePulseStop_It(). If the HRTIM timer operates in waveform mode 1. Completes waveform timer configuration HAL_HRTIM_WaveformTimerConfig(): configuration of a HRTIM timer operating in wave form mode mainly consists in: Enabling the HRTIM timer interrupts and DMA requests. Enabling the half mode for the HRTIM timer. Defining how the HRTIM timer reacts to external synchronization input. Enabling the push-pull mode for the HRTIM timer. Enabling the fault channels for the HRTIM timer. Enabling the dead-time insertion for the HRTIM timer. Setting the delayed protection mode for the HRTIM timer (source and outputs on which the delayed protection are applied). Specifying the HRTIM timer update and reset triggers. Specifying the HRTIM timer registers update policy (e.g. pre-load enabling). HAL_HRTIM_TimerEventFilteringConfig(): configures external event blanking and windowing circuitry of a HRTIM timer: Blanking: to mask external events during a defined time period a defined time period Windowing, to enable external events only during a defined time period HAL_HRTIM_DeadTimeConfig(): configures the dead-time insertion unit for a HRTIM timer. Allows to generate a couple of complementary signals from a single reference waveform, with programmable delays between active state. HAL_HRTIM_ChopperModeConfig(): configures the parameters of the highfrequency carrier signal added on top of the timing unit output. Chopper mode can be enabled or disabled for each timer output separately (see HAL_HRTIM_WaveformOutputConfig()). DOCID026526 Rev 4 257/832 UM1786 2. 3. 4. 5. 6. 7. 258/832 HAL_HRTIM_BurstDMAConfig(): configures the burst DMA burst controller. Allows having multiple HRTIM registers updated with a single DMA request. The burst DMA operation is started by calling HAL_HRTIM_BurstDMATransfer(). HAL_HRTIM_WaveformCompareConfig():configures the compare unit of a HRTIM timer. This operation consists in setting the compare value and possibly specifying the auto delayed mode for compare units 2 and 4 (allows to have compare events generated relatively to capture events). Note that when auto delayed mode is needed, the capture unit associated to the compare unit must be configured separately. HAL_HRTIM_WaveformCaptureConfig(): configures the capture unit of a HRTIM timer. This operation consists in specifying the source(s) triggering the capture (timer register update event, external event, timer output set/reset event, other HRTIM timer related events). HAL_HRTIM_WaveformOutputConfig(): configuration of a HRTIM timer output mainly consists in: Setting the output polarity (active high or active low), Defining the set/reset crossbar for the output, Specifying the fault level (active or inactive) in IDLE and FAULT states., Set waveform timer output(s) level HAL_HRTIM_WaveformSetOutputLevel(): forces the output to its active or inactive level. For example, when deadtime insertion is enabled it is necessary to force the output level by software to have the outputs in a complementary state as soon as the RUN mode is entered. Enable or Disable waveform timer output(s) HAL_HRTIM_WaveformOutputStart(),HAL_HRTIM_WaveformOutputStop(). Start or Stop waveform HRTIM timer(s). HAL_HRTIM_WaveformCounterStart(),HAL_HRTIM_WaveformCounterStop(), HAL_HRTIM_WaveformCounterStart_IT(),HAL_HRTIM_WaveformCounterStop_I T(), HAL_HRTIM_WaveformCounterStart()_DMA,HAL_HRTIM_WaveformCounterSto p_DMA(), Burst mode controller enabling: HAL_HRTIM_BurstModeCtl(): activates or de-activates the burst mode controller. Some HRTIM operations can be triggered by software: HAL_HRTIM_BurstModeSoftwareTrigger(): calling this function trigs the burst operation. HAL_HRTIM_SoftwareCapture(): calling this function trigs the capture of the HRTIM timer counter. HAL_HRTIM_SoftwareUpdate(): calling this function trigs the update of the preloadable registers of the HRTIM timer HAL_HRTIM_SoftwareReset():calling this function resets the HRTIM timer counter. Some functions can be used any time to retrieve HRTIM timer related information HAL_HRTIM_GetCapturedValue(): returns actual value of the capture register of the designated capture unit. HAL_HRTIM_WaveformGetOutputLevel(): returns actual level (ACTIVE/INACTIVE) of the designated timer output. HAL_HRTIM_WaveformGetOutputState():returns actual state (IDLE/RUN/FAULT) of the designated timer output. HAL_HRTIM_GetDelayedProtectionStatus():returns actual level (ACTIVE/INACTIVE) of the designated output when the delayed protection was triggered. HAL_HRTIM_GetBurstStatus(): returns the actual status (ACTIVE/INACTIVE) of the burst mode controller. DOCID026526 Rev 4 UM1786 8. 21.2.3 HAL_HRTIM_GetCurrentPushPullStatus(): when the push-pull mode is enabled for the HRTIM timer (see HAL_HRTIM_WaveformTimerConfig()), the push-pull status indicates on which output the signal is currently active (e.g signal applied on output 1 and output 2 forced inactive or vice versa). HAL_HRTIM_GetIdlePushPullStatus(): when the push-pull mode is enabled for the HRTIM timer (see HAL_HRTIM_WaveformTimerConfig()), the idle push-pull status indicates during which period the delayed protection request occurred (e.g. protection occurred when the output 1 was active and output 2 forced inactive or vice versa). Some functions can be used any time to retrieve actual HRTIM status HAL_HRTIM_GetState(): returns actual HRTIM instance HAL state. Initialization and Time Base Configuration functions This section provides functions allowing to: Initialize a HRTIM instance De-initialize a HRTIM instance Initialize the HRTIM MSP De-initialize the HRTIM MSP Start the high-resolution unit (start DLL calibration) Check that the high resolution unit is ready (DLL calibration done) Configure the time base unit of a HRTIM timer This section contains the following APIs: 21.2.4 HAL_HRTIM_Init() HAL_HRTIM_DeInit() HAL_HRTIM_MspInit() HAL_HRTIM_MspDeInit() HAL_HRTIM_DLLCalibrationStart() HAL_HRTIM_DLLCalibrationStart_IT() HAL_HRTIM_PollForDLLCalibration() HAL_HRTIM_TimeBaseConfig() Simple time base mode functions This section provides functions allowing to: Start simple time base Stop simple time base Start simple time base and enable interrupt Stop simple time base and disable interrupt Start simple time base and enable DMA transfer Stop simple time base and disable DMA transfer When a HRTIM timer operates in simple time base mode, the timer counter counts from 0 to the period value. This section contains the following APIs: HAL_HRTIM_SimpleBaseStart() HAL_HRTIM_SimpleBaseStop() HAL_HRTIM_SimpleBaseStart_IT() HAL_HRTIM_SimpleBaseStop_IT() HAL_HRTIM_SimpleBaseStart_DMA() HAL_HRTIM_SimpleBaseStop_DMA() DOCID026526 Rev 4 259/832 UM1786 21.2.5 Simple output compare functions This section provides functions allowing to: Configure simple output channel Start simple output compare Stop simple output compare Start simple output compare and enable interrupt Stop simple output compare and disable interrupt Start simple output compare and enable DMA transfer Stop simple output compare and disable DMA transfer When a HRTIM timer operates in simple output compare mode the output level is set to a programmable value when a match is found between the compare register and the counter. Compare unit 1 is automatically associated to output 1 Compare unit 2 is automatically associated to output 2 This section contains the following APIs: 21.2.6 HAL_HRTIM_SimpleOCChannelConfig() HAL_HRTIM_SimpleOCStart() HAL_HRTIM_SimpleOCStop() HAL_HRTIM_SimpleOCStart_IT() HAL_HRTIM_SimpleOCStop_IT() HAL_HRTIM_SimpleOCStart_DMA() HAL_HRTIM_SimpleOCStop_DMA() Simple PWM output functions This section provides functions allowing to: Configure simple PWM output channel Start simple PWM output Stop simple PWM output Start simple PWM output and enable interrupt Stop simple PWM output and disable interrupt Start simple PWM output and enable DMA transfer Stop simple PWM output and disable DMA transfer When a HRTIM timer operates in simple PWM output mode the output level is set to a programmable value when a match is found between the compare register and the counter and reset when the timer period is reached. Duty cycle is determined by the comparison value. Compare unit 1 is automatically associated to output 1 Compare unit 2 is automatically associated to output 2 This section contains the following APIs: 21.2.7 HAL_HRTIM_SimplePWMChannelConfig() HAL_HRTIM_SimplePWMStart() HAL_HRTIM_SimplePWMStop() HAL_HRTIM_SimplePWMStart_IT() HAL_HRTIM_SimplePWMStop_IT() HAL_HRTIM_SimplePWMStart_DMA() HAL_HRTIM_SimplePWMStop_DMA() Simple input capture functions This section provides functions allowing to: 260/832 Configure simple input capture channel DOCID026526 Rev 4 UM1786 Start simple input capture Stop simple input capture Start simple input capture and enable interrupt Stop simple input capture and disable interrupt Start simple input capture and enable DMA transfer Stop simple input capture and disable DMA transfer When a HRTIM timer operates in simple input capture mode the Capture Register (HRTIM_CPT1/2xR) is used to latch the value of the timer counter counter after a transition detected on a given external event input. This section contains the following APIs: 21.2.8 HAL_HRTIM_SimpleCaptureChannelConfig() HAL_HRTIM_SimpleCaptureStart() HAL_HRTIM_SimpleCaptureStop() HAL_HRTIM_SimpleCaptureStart_IT() HAL_HRTIM_SimpleCaptureStop_IT() HAL_HRTIM_SimpleCaptureStart_DMA() HAL_HRTIM_SimpleCaptureStop_DMA() Simple one pulse functions This section provides functions allowing to: Configure one pulse channel Start one pulse generation Stop one pulse generation Start one pulse generation and enable interrupt Stop one pulse generation and disable interrupt When a HRTIM timer operates in simple one pulse mode the timer counter is started in response to transition detected on a given external event input to generate a pulse with a programmable length after a programmable delay. This section contains the following APIs: 21.2.9 HAL_HRTIM_SimpleOnePulseChannelConfig() HAL_HRTIM_SimpleOnePulseStart() HAL_HRTIM_SimpleOnePulseStop() HAL_HRTIM_SimpleOnePulseStart_IT() HAL_HRTIM_SimpleOnePulseStop_IT() HRTIM configuration functions This section provides functions allowing to configure the HRTIM resources shared by all the HRTIM timers operating in waveform mode: Configure the burst mode controller Configure an external event conditionning Configure the external events sampling clock Configure a fault conditionning Enable or disable fault inputs Configure the faults sampling clock Configure an ADC trigger This section contains the following APIs: HAL_HRTIM_BurstModeConfig() HAL_HRTIM_EventConfig() DOCID026526 Rev 4 261/832 UM1786 21.2.10 HAL_HRTIM_EventPrescalerConfig() HAL_HRTIM_FaultConfig() HAL_HRTIM_FaultPrescalerConfig() HAL_HRTIM_FaultModeCtl() HAL_HRTIM_ADCTriggerConfig() HRTIM timer configuration and control functions This section provides functions used to configure and control a HRTIM timer operating in waveform mode: Configure HRTIM timer general behavior Configure HRTIM timer event filtering Configure HRTIM timer deadtime insertion Configure HRTIM timer chopper mode Configure HRTIM timer burst DMA Configure HRTIM timer compare unit Configure HRTIM timer capture unit Configure HRTIM timer output Set HRTIM timer output level Enable HRTIM timer output Disable HRTIM timer output Start HRTIM timer Stop HRTIM timer Start HRTIM timer and enable interrupt Stop HRTIM timer and disable interrupt Start HRTIM timer and enable DMA transfer Stop HRTIM timer and disable DMA transfer Enable or disable the burst mode controller Start the burst mode controller (by software) Trigger a Capture (by software) Update the HRTIM timer preloadable registers (by software) Reset the HRTIM timer counter (by software) Start a burst DMA transfer Enable timer register update Disable timer register update This section contains the following APIs: 262/832 HAL_HRTIM_WaveformTimerConfig() HAL_HRTIM_TimerEventFilteringConfig() HAL_HRTIM_DeadTimeConfig() HAL_HRTIM_ChopperModeConfig() HAL_HRTIM_BurstDMAConfig() HAL_HRTIM_WaveformCompareConfig() HAL_HRTIM_WaveformCaptureConfig() HAL_HRTIM_WaveformOutputConfig() HAL_HRTIM_WaveformSetOutputLevel() HAL_HRTIM_WaveformOutputStart() HAL_HRTIM_WaveformOutputStop() HAL_HRTIM_WaveformCounterStart() HAL_HRTIM_WaveformCounterStop() HAL_HRTIM_WaveformCounterStart_IT() HAL_HRTIM_WaveformCounterStop_IT() HAL_HRTIM_WaveformCounterStart_DMA() DOCID026526 Rev 4 UM1786 21.2.11 HAL_HRTIM_WaveformCounterStop_DMA() HAL_HRTIM_BurstModeCtl() HAL_HRTIM_BurstModeSoftwareTrigger() HAL_HRTIM_SoftwareCapture() HAL_HRTIM_SoftwareUpdate() HAL_HRTIM_SoftwareReset() HAL_HRTIM_BurstDMATransfer() HAL_HRTIM_UpdateEnable() HAL_HRTIM_UpdateDisable() Peripheral State functions This section provides functions used to get HRTIM or HRTIM timer specific information: Get HRTIM HAL state Get captured value Get HRTIM timer output level Get HRTIM timer output state Get delayed protection status Get burst status Get current push-pull status Get idle push-pull status This section contains the following APIs: 21.2.12 HAL_HRTIM_GetState() HAL_HRTIM_GetCapturedValue() HAL_HRTIM_WaveformGetOutputLevel() HAL_HRTIM_WaveformGetOutputState() HAL_HRTIM_GetDelayedProtectionStatus() HAL_HRTIM_GetBurstStatus() HAL_HRTIM_GetCurrentPushPullStatus() HAL_HRTIM_GetIdlePushPullStatus() Detailed description of functions HAL_HRTIM_Init Function Name HAL_StatusTypeDef HAL_HRTIM_Init (HRTIM_HandleTypeDef * hhrtim) Function Description Initializes a HRTIM instance. Parameters hhrtim: pointer to HAL HRTIM handle Return values HAL: status HAL_HRTIM_DeInit Function Name HAL_StatusTypeDef HAL_HRTIM_DeInit (HRTIM_HandleTypeDef * hhrtim) Function Description De-initializes a HRTIM instance. Parameters hhrtim: pointer to HAL HRTIM handle Return values HAL: status DOCID026526 Rev 4 263/832 UM1786 HAL_HRTIM_MspInit Function Name void HAL_HRTIM_MspInit (HRTIM_HandleTypeDef * hhrtim) Function Description MSP initialization for a HRTIM instance. Parameters hhrtim: pointer to HAL HRTIM handle Return values None: HAL_HRTIM_MspDeInit Function Name void HAL_HRTIM_MspDeInit (HRTIM_HandleTypeDef * hhrtim) Function Description MSP de-initialization for a for a HRTIM instance. Parameters hhrtim: pointer to HAL HRTIM handle Return values None: HAL_HRTIM_TimeBaseConfig Function Name HAL_StatusTypeDef HAL_HRTIM_TimeBaseConfig (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, HRTIM_TimeBaseCfgTypeDef * pTimeBaseCfg) Function Description Configures the time base unit of a timer. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_MASTER for master timer HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E pTimeBaseCfg: pointer to the time base configuration structure Return values HAL: status Notes This function must be called prior starting the timer The time-base unit initialization parameters specify: The timer counter operating mode (continuous, one shot), The timer clock prescaler, The timer period , The timer repetition counter. HAL_HRTIM_DLLCalibrationStart 264/832 Function Name HAL_StatusTypeDef HAL_HRTIM_DLLCalibrationStart (HRTIM_HandleTypeDef * hhrtim, uint32_t CalibrationRate) Function Description Starts the DLL calibration. Parameters hhrtim: pointer to HAL HRTIM handle CalibrationRate: DLL calibration period This parameter can be one of the following values: HRTIM_SINGLE_CALIBRATION: One shot DLL calibration DOCID026526 Rev 4 UM1786 HRTIM_CALIBRATIONRATE_7300: Periodic DLL calibration. T=7.3 ms HRTIM_CALIBRATIONRATE_910: Periodic DLL calibration. T=910 us HRTIM_CALIBRATIONRATE_114: Periodic DLL calibration. T=114 us HRTIM_CALIBRATIONRATE_14: Periodic DLL calibration. T=14 us Return values HAL: status Notes This function locks the HRTIM instance. HRTIM instance is unlocked within the HAL_HRTIM_PollForDLLCalibration function, just before exiting the function. HAL_HRTIM_DLLCalibrationStart_IT Function Name HAL_StatusTypeDef HAL_HRTIM_DLLCalibrationStart_IT (HRTIM_HandleTypeDef * hhrtim, uint32_t CalibrationRate) Function Description Starts the DLL calibration. Parameters hhrtim: pointer to HAL HRTIM handle CalibrationRate: DLL calibration period This parameter can be one of the following values: HRTIM_SINGLE_CALIBRATION: One shot DLL calibration HRTIM_CALIBRATIONRATE_7300: Periodic DLL calibration. T=7.3 ms HRTIM_CALIBRATIONRATE_910: Periodic DLL calibration. T=910 us HRTIM_CALIBRATIONRATE_114: Periodic DLL calibration. T=114 us HRTIM_CALIBRATIONRATE_14: Periodic DLL calibration. T=14 us Return values HAL: status Notes This function locks the HRTIM instance. HRTIM instance is unlocked within the IRQ processing function when processing the DLL ready interrupt. If this function is called for periodic calibration, the DLLRDY interrupt is generated every time the calibration completes which will significantly increases the overall interrupt rate. HAL_HRTIM_PollForDLLCalibration Function Name HAL_StatusTypeDef HAL_HRTIM_PollForDLLCalibration (HRTIM_HandleTypeDef * hhrtim, uint32_t Timeout) Function Description Polls the DLL calibration ready flag and returns when the flag is set (DLL calibration completed) or upon timeout expiration. Parameters hhrtim: pointer to HAL HRTIM handle Timeout: Timeout duration in millisecond Return values HAL: status DOCID026526 Rev 4 265/832 UM1786 HAL_HRTIM_SimpleBaseStart Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleBaseStart (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx) Function Description Starts the counter of a timer operating in simple time base mode. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index. This parameter can be one of the following values: HRTIM_TIMERINDEX_MASTER for master timer HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E Return values HAL: status HAL_HRTIM_SimpleBaseStop Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleBaseStop (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx) Function Description Stops the counter of a timer operating in simple time base mode. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index. This parameter can be one of the following values: HRTIM_TIMERINDEX_MASTER for master timer HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E Return values HAL: status HAL_HRTIM_SimpleBaseStart_IT 266/832 Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleBaseStart_IT (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx) Function Description Starts the counter of a timer operating in simple time base mode (Timer repetition interrupt is enabled). Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index. This parameter can be one of the following values: HRTIM_TIMERINDEX_MASTER for master timer HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E Return values HAL: status DOCID026526 Rev 4 UM1786 HAL_HRTIM_SimpleBaseStop_IT Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleBaseStop_IT (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx) Function Description Stops the counter of a timer operating in simple time base mode (Timer repetition interrupt is disabled). Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index. This parameter can be one of the following values: HRTIM_TIMERINDEX_MASTER for master timer HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E Return values HAL: status HAL_HRTIM_SimpleBaseStart_DMA Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleBaseStart_DMA (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t SrcAddr, uint32_t DestAddr, uint32_t Length) Function Description Starts the counter of a timer operating in simple time base mode (Timer repetition DMA request is enabled). Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index. This parameter can be one of the following values: HRTIM_TIMERINDEX_MASTER for master timer HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E SrcAddr: DMA transfer source address DestAddr: DMA transfer destination address Length: The length of data items (data size) to be transferred from source to destination HAL_HRTIM_SimpleBaseStop_DMA Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleBaseStop_DMA (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx) Function Description Stops the counter of a timer operating in simple time base mode (Timer repetition DMA request is disabled). Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index. This parameter can be one of the following values: HRTIM_TIMERINDEX_MASTER for master timer HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B DOCID026526 Rev 4 267/832 UM1786 Return values HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E HAL: status HAL_HRTIM_SimpleOCChannelConfig Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleOCChannelConfig (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t OCChannel, HRTIM_SimpleOCChannelCfgTypeDef * pSimpleOCChannelCfg) Function Description Configures an output in simple output compare mode. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E OCChannel: Timer output This parameter can be one of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 pSimpleOCChannelCfg: pointer to the simple output compare output configuration structure Return values HAL: status Notes When the timer operates in simple output compare mode: Output 1 is implicitly controlled by the compare unit 1 Output 2 is implicitly controlled by the compare unit 2 Output Set/Reset crossbar is set according to the selected output compare mode: Toggle: SETxyR = RSTxyR = CMPy Active: SETxyR = CMPy, RSTxyR = 0 Inactive: SETxy =0, RSTxy = CMPy HAL_HRTIM_SimpleOCStart 268/832 Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleOCStart (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t OCChannel) Function Description Starts the output compare signal generation on the designed timer output. DOCID026526 Rev 4 UM1786 Parameters Return values hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E OCChannel: Timer output This parameter can be one of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 HAL: status HAL_HRTIM_SimpleOCStop Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleOCStop (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t OCChannel) Function Description Stops the output compare signal generation on the designed timer output. Parameters Return values hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E OCChannel: Timer output This parameter can be one of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 HAL: status DOCID026526 Rev 4 269/832 UM1786 HAL_HRTIM_SimpleOCStart_IT Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleOCStart_IT (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t OCChannel) Function Description Starts the output compare signal generation on the designed timer output (Interrupt is enabled (see note note below)). Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E OCChannel: Timer output This parameter can be one of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 Return values HAL: status Notes Interrupt enabling depends on the chosen output compare mode Output toggle: compare match interrupt is enabled Output set active: output set interrupt is enabled Output set inactive: output reset interrupt is enabled HAL_HRTIM_SimpleOCStop_IT Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleOCStop_IT (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t OCChannel) Function Description Stops the output compare signal generation on the designed timer output (Interrupt is disabled). Parameters 270/832 hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E OCChannel: Timer output This parameter can be one of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 DOCID026526 Rev 4 UM1786 Return values HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 HAL: status HAL_HRTIM_SimpleOCStart_DMA Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleOCStart_DMA (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t OCChannel, uint32_t SrcAddr, uint32_t DestAddr, uint32_t Length) Function Description Starts the output compare signal generation on the designed timer output (DMA request is enabled (see note below)). Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E OCChannel: Timer output This parameter can be one of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 SrcAddr: DMA transfer source address DestAddr: DMA transfer destination address Length: The length of data items (data size) to be transferred from source to destination Return values HAL: status Notes DMA request enabling depends on the chosen output compare mode Output toggle: compare match DMA request is enabled Output set active: output set DMA request is enabled Output set inactive: output reset DMA request is enabled DOCID026526 Rev 4 271/832 UM1786 HAL_HRTIM_SimpleOCStop_DMA Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleOCStop_DMA (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t OCChannel) Function Description Stops the output compare signal generation on the designed timer output (DMA request is disabled). Parameters Return values hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E OCChannel: Timer output This parameter can be one of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 HAL: status HAL_HRTIM_SimplePWMChannelConfig Function Name HAL_StatusTypeDef HAL_HRTIM_SimplePWMChannelConfig (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t PWMChannel, HRTIM_SimplePWMChannelCfgTypeDef * pSimplePWMChannelCfg) Function Description Configures an output in simple PWM mode. Parameters 272/832 hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E PWMChannel: Timer output This parameter can be one of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 DOCID026526 Rev 4 UM1786 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 pSimplePWMChannelCfg: pointer to the simple PWM output configuration structure Return values HAL: status Notes When the timer operates in simple PWM output mode: Output 1 is implicitly controlled by the compare unit 1 Output 2 is implicitly controlled by the compare unit 2 Output Set/Reset crossbar is set as follows: Output 1: SETx1R = CMP1, RSTx1R = PER Output 2: SETx2R = CMP2, RST2R = PER When Simple PWM mode is used the registers preload mechanism is enabled (otherwise the behavior is not guaranteed). HAL_HRTIM_SimplePWMStart Function Name HAL_StatusTypeDef HAL_HRTIM_SimplePWMStart (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t PWMChannel) Function Description Starts the PWM output signal generation on the designed timer output. Parameters Return values hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E PWMChannel: Timer output This parameter can be one of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 HAL: status HAL_HRTIM_SimplePWMStop Function Name HAL_StatusTypeDef HAL_HRTIM_SimplePWMStop (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t DOCID026526 Rev 4 273/832 UM1786 PWMChannel) Function Description Stops the PWM output signal generation on the designed timer output. Parameters Return values hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E PWMChannel: Timer output This parameter can be one of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 HAL: status HAL_HRTIM_SimplePWMStart_IT Function Name HAL_StatusTypeDef HAL_HRTIM_SimplePWMStart_IT (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t PWMChannel) Function Description Starts the PWM output signal generation on the designed timer output (The compare interrupt is enabled). Parameters 274/832 hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E PWMChannel: Timer output This parameter can be one of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 DOCID026526 Rev 4 UM1786 Return values HRTIM_OUTPUT_TE2: Timer E - Output 2 HAL: status HAL_HRTIM_SimplePWMStop_IT Function Name HAL_StatusTypeDef HAL_HRTIM_SimplePWMStop_IT (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t PWMChannel) Function Description Stops the PWM output signal generation on the designed timer output (The compare interrupt is disabled). Parameters Return values hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E PWMChannel: Timer output This parameter can be one of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 HAL: status HAL_HRTIM_SimplePWMStart_DMA Function Name HAL_StatusTypeDef HAL_HRTIM_SimplePWMStart_DMA (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t PWMChannel, uint32_t SrcAddr, uint32_t DestAddr, uint32_t Length) Function Description Starts the PWM output signal generation on the designed timer output (The compare DMA request is enabled). Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E PWMChannel: Timer output This parameter can be one of the following values: DOCID026526 Rev 4 275/832 UM1786 Return values HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 SrcAddr: DMA transfer source address DestAddr: DMA transfer destination address Length: The length of data items (data size) to be transferred from source to destination HAL: status HAL_HRTIM_SimplePWMStop_DMA Function Name HAL_StatusTypeDef HAL_HRTIM_SimplePWMStop_DMA (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t PWMChannel) Function Description Stops the PWM output signal generation on the designed timer output (The compare DMA request is disabled). Parameters Return values hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E PWMChannel: Timer output This parameter can be one of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 HAL: status HAL_HRTIM_SimpleCaptureChannelConfig Function Name 276/832 HAL_StatusTypeDef HAL_HRTIM_SimpleCaptureChannelConfig (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t CaptureChannel, HRTIM_SimpleCaptureChannelCfgTypeDef * DOCID026526 Rev 4 UM1786 pSimpleCaptureChannelCfg) Function Description Configures a simple capture. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E CaptureChannel: Capture unit This parameter can be one of the following values: HRTIM_CAPTUREUNIT_1: Capture unit 1 HRTIM_CAPTUREUNIT_2: Capture unit 2 pSimpleCaptureChannelCfg: pointer to the simple capture configuration structure Return values HAL: status Notes When the timer operates in simple capture mode the capture is trigerred by the designated external event and GPIO input is implicitly used as event source. The cature can be triggered by a rising edge, a falling edge or both edges on event channel. HAL_HRTIM_SimpleCaptureStart Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleCaptureStart (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t CaptureChannel) Function Description Enables a simple capture on the designed capture unit. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E CaptureChannel: Timer output This parameter can be one of the following values: HRTIM_CAPTUREUNIT_1: Capture unit 1 HRTIM_CAPTUREUNIT_2: Capture unit 2 Return values HAL: status Notes The external event triggering the capture is available for all timing units. It can be used directly and is active as soon as the timing unit counter is enabled. HAL_HRTIM_SimpleCaptureStop Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleCaptureStop (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t DOCID026526 Rev 4 277/832 UM1786 CaptureChannel) Function Description Disables a simple capture on the designed capture unit. Parameters Return values hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E CaptureChannel: Timer output This parameter can be one of the following values: HRTIM_CAPTUREUNIT_1: Capture unit 1 HRTIM_CAPTUREUNIT_2: Capture unit 2 HAL: status HAL_HRTIM_SimpleCaptureStart_IT Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleCaptureStart_IT (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t CaptureChannel) Function Description Enables a simple capture on the designed capture unit (Capture interrupt is enabled). Parameters Return values hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E CaptureChannel: Timer output This parameter can be one of the following values: HRTIM_CAPTUREUNIT_1: Capture unit 1 HRTIM_CAPTUREUNIT_2: Capture unit 2 HAL: status HAL_HRTIM_SimpleCaptureStop_IT 278/832 Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleCaptureStop_IT (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t CaptureChannel) Function Description Disables a simple capture on the designed capture unit (Capture interrupt is disabled). Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B DOCID026526 Rev 4 UM1786 Return values HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E CaptureChannel: Timer output This parameter can be one of the following values: HRTIM_CAPTUREUNIT_1: Capture unit 1 HRTIM_CAPTUREUNIT_2: Capture unit 2 HAL: status HAL_HRTIM_SimpleCaptureStart_DMA Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleCaptureStart_DMA (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t CaptureChannel, uint32_t SrcAddr, uint32_t DestAddr, uint32_t Length) Function Description Enables a simple capture on the designed capture unit (Capture DMA request is enabled). Parameters Return values hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E CaptureChannel: Timer output This parameter can be one of the following values: HRTIM_CAPTUREUNIT_1: Capture unit 1 HRTIM_CAPTUREUNIT_2: Capture unit 2 SrcAddr: DMA transfer source address DestAddr: DMA transfer destination address Length: The length of data items (data size) to be transferred from source to destination HAL: status HAL_HRTIM_SimpleCaptureStop_DMA Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleCaptureStop_DMA (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t CaptureChannel) Function Description Disables a simple capture on the designed capture unit (Capture DMA request is disabled). Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E DOCID026526 Rev 4 279/832 UM1786 Return values CaptureChannel: Timer output This parameter can be one of the following values: HRTIM_CAPTUREUNIT_1: Capture unit 1 HRTIM_CAPTUREUNIT_2: Capture unit 2 HAL: status HAL_HRTIM_SimpleOnePulseChannelConfig Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleOnePulseChannelConfig (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t OnePulseChannel, HRTIM_SimpleOnePulseChannelCfgTypeDef * pSimpleOnePulseChannelCfg) Function Description Configures an output simple one pulse mode. Parameters Return values HAL: status Notes When the timer operates in simple one pulse mode: the timer counter is implicitly started by the reset event, the reset of the timer counter is triggered by the designated external event GPIO input is implicitly used as event source, Output 1 is implicitly controlled by the compare unit 1, Output 2 is implicitly controlled by the compare unit 2. Output Set/Reset crossbar is set as follows: Output 1: SETx1R = CMP1, RSTx1R = PER Output 2: SETx2R = CMP2, RST2R = PER If HAL_HRTIM_SimpleOnePulseChannelConfig is called for both timer outputs, the reset event related configuration data provided in the second call will override the reset event related configuration data provided in the first call. 280/832 hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E OnePulseChannel: Timer output This parameter can be one of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 pSimpleOnePulseChannelCfg: pointer to the simple one pulse output configuration structure DOCID026526 Rev 4 UM1786 HAL_HRTIM_SimpleOnePulseStart Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleOnePulseStart (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t OnePulseChannel) Function Description Enables the simple one pulse signal generation on the designed output. Parameters Return values hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E OnePulseChannel: Timer output This parameter can be one of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 HAL: status HAL_HRTIM_SimpleOnePulseStop Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleOnePulseStop (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t OnePulseChannel) Function Description Disables the simple one pulse signal generation on the designed output. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E OnePulseChannel: Timer output This parameter can be one of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 DOCID026526 Rev 4 281/832 UM1786 Return values HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 HAL: status HAL_HRTIM_SimpleOnePulseStart_IT Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleOnePulseStart_IT (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t OnePulseChannel) Function Description Enables the simple one pulse signal generation on the designed output (The compare interrupt is enabled (pulse start)). Parameters Return values hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E OnePulseChannel: Timer output This parameter can be one of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 HAL: status HAL_HRTIM_SimpleOnePulseStop_IT 282/832 Function Name HAL_StatusTypeDef HAL_HRTIM_SimpleOnePulseStop_IT (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t OnePulseChannel) Function Description Disables the simple one pulse signal generation on the designed output (The compare interrupt is disabled). Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D DOCID026526 Rev 4 UM1786 Return values HRTIM_TIMERINDEX_TIMER_E for timer E OnePulseChannel: Timer output This parameter can be one of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 HAL: status HAL_HRTIM_BurstModeConfig Function Name HAL_StatusTypeDef HAL_HRTIM_BurstModeConfig (HRTIM_HandleTypeDef * hhrtim, HRTIM_BurstModeCfgTypeDef * pBurstModeCfg) Function Description Configures the burst mode feature of the HRTIM. Parameters hhrtim: pointer to HAL HRTIM handle pBurstModeCfg: pointer to the burst mode configuration structure Return values HAL: status Notes This function must be called before starting the burst mode controller HAL_HRTIM_EventConfig Function Name HAL_StatusTypeDef HAL_HRTIM_EventConfig (HRTIM_HandleTypeDef * hhrtim, uint32_t Event, HRTIM_EventCfgTypeDef * pEventCfg) Function Description Configures the conditioning of an external event. Parameters hhrtim: pointer to HAL HRTIM handle Event: external event to configure This parameter can be one of the following values: HRTIM_EVENT_1: External event 1 HRTIM_EVENT_2: External event 2 HRTIM_EVENT_3: External event 3 HRTIM_EVENT_4: External event 4 HRTIM_EVENT_5: External event 5 HRTIM_EVENT_6: External event 6 HRTIM_EVENT_7: External event 7 HRTIM_EVENT_8: External event 8 HRTIM_EVENT_9: External event 9 HRTIM_EVENT_10: External event 10 pEventCfg: pointer to the event conditioning configuration structure DOCID026526 Rev 4 283/832 UM1786 Return values HAL: status Notes This function must be called before starting the timer HAL_HRTIM_EventPrescalerConfig Function Name HAL_StatusTypeDef HAL_HRTIM_EventPrescalerConfig (HRTIM_HandleTypeDef * hhrtim, uint32_t Prescaler) Function Description Configures the external event conditioning block prescaler. Parameters hhrtim: pointer to HAL HRTIM handle Prescaler: Prescaler value This parameter can be one of the following values: HRTIM_EVENTPRESCALER_DIV1: fEEVS=fHRTIM HRTIM_EVENTPRESCALER_DIV2: fEEVS=fHRTIM / 2 HRTIM_EVENTPRESCALER_DIV4: fEEVS=fHRTIM / 4 HRTIM_EVENTPRESCALER_DIV8: fEEVS=fHRTIM / 8 Return values HAL: status Notes This function must be called before starting the timer HAL_HRTIM_FaultConfig Function Name HAL_StatusTypeDef HAL_HRTIM_FaultConfig (HRTIM_HandleTypeDef * hhrtim, uint32_t Fault, HRTIM_FaultCfgTypeDef * pFaultCfg) Function Description Configures the conditioning of fault input. Parameters hhrtim: pointer to HAL HRTIM handle Fault: fault input to configure This parameter can be one of the following values: HRTIM_FAULT_1: Fault input 1 HRTIM_FAULT_2: Fault input 2 HRTIM_FAULT_3: Fault input 3 HRTIM_FAULT_4: Fault input 4 HRTIM_FAULT_5: Fault input 5 pFaultCfg: pointer to the fault conditioning configuration structure Return values HAL: status Notes This function must be called before starting the timer and before enabling faults inputs HAL_HRTIM_FaultPrescalerConfig 284/832 Function Name HAL_StatusTypeDef HAL_HRTIM_FaultPrescalerConfig (HRTIM_HandleTypeDef * hhrtim, uint32_t Prescaler) Function Description Configures the fault conditioning block prescaler. Parameters hhrtim: pointer to HAL HRTIM handle Prescaler: Prescaler value This parameter can be one of the following values: HRTIM_FAULTPRESCALER_DIV1: fFLTS=fHRTIM HRTIM_FAULTPRESCALER_DIV2: fFLTS=fHRTIM / 2 DOCID026526 Rev 4 UM1786 HRTIM_FAULTPRESCALER_DIV4: fFLTS=fHRTIM / 4 HRTIM_FAULTPRESCALER_DIV8: fFLTS=fHRTIM / 8 Return values HAL: status Notes This function must be called before starting the timer and before enabling faults inputs HAL_HRTIM_FaultModeCtl Function Name void HAL_HRTIM_FaultModeCtl (HRTIM_HandleTypeDef * hhrtim, uint32_t Faults, uint32_t Enable) Function Description Enables or disables the HRTIMx Fault mode. Parameters Return values hhrtim: pointer to HAL HRTIM handle Faults: fault input(s) to enable or disable This parameter can be any combination of the following values: HRTIM_FAULT_1: Fault input 1 HRTIM_FAULT_2: Fault input 2 HRTIM_FAULT_3: Fault input 3 HRTIM_FAULT_4: Fault input 4 HRTIM_FAULT_5: Fault input 5 Enable: Fault(s) enabling This parameter can be one of the following values: HRTIM_FAULTMODECTL_ENABLED: Fault(s) enabled HRTIM_FAULTMODECTL_DISABLED: Fault(s) disabled None: HAL_HRTIM_ADCTriggerConfig Function Name HAL_StatusTypeDef HAL_HRTIM_ADCTriggerConfig (HRTIM_HandleTypeDef * hhrtim, uint32_t ADCTrigger, HRTIM_ADCTriggerCfgTypeDef * pADCTriggerCfg) Function Description Configures both the ADC trigger register update source and the ADC trigger source. Parameters hhrtim: pointer to HAL HRTIM handle ADCTrigger: ADC trigger to configure This parameter can be one of the following values: HRTIM_ADCTRIGGER_1: ADC trigger 1 HRTIM_ADCTRIGGER_2: ADC trigger 2 HRTIM_ADCTRIGGER_3: ADC trigger 3 HRTIM_ADCTRIGGER_4: ADC trigger 4 pADCTriggerCfg: pointer to the ADC trigger configuration structure Return values HAL: status Notes This function must be called before starting the timer HAL_HRTIM_WaveformTimerConfig Function Name HAL_StatusTypeDef HAL_HRTIM_WaveformTimerConfig (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, DOCID026526 Rev 4 285/832 UM1786 HRTIM_TimerCfgTypeDef * pTimerCfg) Function Description Configures the general behavior of a timer operating in waveform mode. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_MASTER for master timer HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E pTimerCfg: pointer to the timer configuration structure Return values HAL: status Notes When the timer operates in waveform mode, all the features supported by the HRTIM are available without any limitation. This function must be called before starting the timer HAL_HRTIM_WaveformCompareConfig Function Name HAL_StatusTypeDef HAL_HRTIM_WaveformCompareConfig (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t CompareUnit, HRTIM_CompareCfgTypeDef * pCompareCfg) Function Description Configures the compare unit of a timer operating in waveform mode. Parameters 286/832 hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_MASTER for master timer HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E CompareUnit: Compare unit to configure This parameter can be one of the following values: HRTIM_COMPAREUNIT_1: Compare unit 1 HRTIM_COMPAREUNIT_2: Compare unit 2 HRTIM_COMPAREUNIT_3: Compare unit 3 HRTIM_COMPAREUNIT_4: Compare unit 4 pCompareCfg: pointer to the compare unit configuration structure Return values HAL: status Notes When auto delayed mode is required for compare unit 2 or compare unit 4, application has to configure separately the capture unit. Capture unit to configure in that case depends on the compare unit auto delayed mode is applied to (see below): Auto delayed on output compare 2: capture unit 1 must be configured Auto delayed on output compare 4: capture unit 2 must be configured DOCID026526 Rev 4 UM1786 This function must be called before starting the timer HAL_HRTIM_WaveformCaptureConfig Function Name HAL_StatusTypeDef HAL_HRTIM_WaveformCaptureConfig (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t CaptureUnit, HRTIM_CaptureCfgTypeDef * pCaptureCfg) Function Description Configures the capture unit of a timer operating in waveform mode. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E CaptureUnit: Capture unit to configure This parameter can be one of the following values: HRTIM_CAPTUREUNIT_1: Capture unit 1 HRTIM_CAPTUREUNIT_2: Capture unit 2 pCaptureCfg: pointer to the compare unit configuration structure Return values HAL: status Notes This function must be called before starting the timer HAL_HRTIM_WaveformOutputConfig Function Name HAL_StatusTypeDef HAL_HRTIM_WaveformOutputConfig (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t Output, HRTIM_OutputCfgTypeDef * pOutputCfg) Function Description Configures the output of a timer operating in waveform mode. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E Output: Timer output This parameter can be one of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 DOCID026526 Rev 4 287/832 UM1786 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 pOutputCfg: pointer to the timer output configuration structure Return values HAL: status Notes This function must be called before configuring the timer and after configuring the deadtime insertion feature (if required). HAL_HRTIM_WaveformSetOutputLevel Function Name HAL_StatusTypeDef HAL_HRTIM_WaveformSetOutputLevel (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t Output, uint32_t OutputLevel) Function Description Forces the timer output to its active or inactive state. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E Output: Timer output This parameter can be one of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 OutputLevel: indicates whether the output is forced to its active or inactive level This parameter can be one of the following values: HRTIM_OUTPUTLEVEL_ACTIVE: output is forced to its active level HRTIM_OUTPUTLEVEL_INACTIVE: output is forced to its inactive level Return values HAL: status Notes The 'software set/reset trigger' bit in the output set/reset registers is automatically reset by hardware HAL_HRTIM_TimerEventFilteringConfig Function Name 288/832 HAL_StatusTypeDef HAL_HRTIM_TimerEventFilteringConfig (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t Event, HRTIM_TimerEventFilteringCfgTypeDef * DOCID026526 Rev 4 UM1786 pTimerEventFilteringCfg) Function Description Configures the event filtering capabilities of a timer (blanking, windowing) Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E Event: external event for which timer event filtering must be configured This parameter can be one of the following values: HRTIM_EVENT_NONE: Reset timer event filtering configuration HRTIM_EVENT_1: External event 1 HRTIM_EVENT_2: External event 2 HRTIM_EVENT_3: External event 3 HRTIM_EVENT_4: External event 4 HRTIM_EVENT_5: External event 5 HRTIM_EVENT_6: External event 6 HRTIM_EVENT_7: External event 7 HRTIM_EVENT_8: External event 8 HRTIM_EVENT_9: External event 9 HRTIM_EVENT_10: External event 10 pTimerEventFilteringCfg: pointer to the timer event filtering configuration structure Return values HAL: status Notes This function must be called before starting the timer HAL_HRTIM_DeadTimeConfig Function Name HAL_StatusTypeDef HAL_HRTIM_DeadTimeConfig (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, HRTIM_DeadTimeCfgTypeDef * pDeadTimeCfg) Function Description Configures the deadtime insertion feature for a timer. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E pDeadTimeCfg: pointer to the deadtime insertion configuration structure Return values HAL: status Notes This function must be called before starting the timer DOCID026526 Rev 4 289/832 UM1786 HAL_HRTIM_ChopperModeConfig Function Name HAL_StatusTypeDef HAL_HRTIM_ChopperModeConfig (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, HRTIM_ChopperModeCfgTypeDef * pChopperModeCfg) Function Description Configures the chopper mode feature for a timer. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E pChopperModeCfg: pointer to the chopper mode configuration structure Return values HAL: status Notes This function must be called before configuring the timer output(s) HAL_HRTIM_BurstDMAConfig Function Name HAL_StatusTypeDef HAL_HRTIM_BurstDMAConfig (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t RegistersToUpdate) Function Description Configures the burst DMA controller for a timer. Parameters 290/832 hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_MASTER for master timer HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E RegistersToUpdate: registers to be written by DMA This parameter can be any combination of the following values: HRTIM_BURSTDMA_CR: HRTIM_MCR or HRTIM_TIMxCR HRTIM_BURSTDMA_ICR: HRTIM_MICR or HRTIM_TIMxICR HRTIM_BURSTDMA_DIER: HRTIM_MDIER or HRTIM_TIMxDIER HRTIM_BURSTDMA_CNT: HRTIM_MCNT or HRTIM_TIMxCNT HRTIM_BURSTDMA_PER: HRTIM_MPER or HRTIM_TIMxPER HRTIM_BURSTDMA_REP: HRTIM_MREP or HRTIM_TIMxREP HRTIM_BURSTDMA_CMP1: HRTIM_MCMP1 or HRTIM_TIMxCMP1 DOCID026526 Rev 4 UM1786 HRTIM_BURSTDMA_CMP2: HRTIM_MCMP2 or HRTIM_TIMxCMP2 HRTIM_BURSTDMA_CMP3: HRTIM_MCMP3 or HRTIM_TIMxCMP3 HRTIM_BURSTDMA_CMP4: HRTIM_MCMP4 or HRTIM_TIMxCMP4 HRTIM_BURSTDMA_DTR: HRTIM_TIMxDTR HRTIM_BURSTDMA_SET1R: HRTIM_TIMxSET1R HRTIM_BURSTDMA_RST1R: HRTIM_TIMxRST1R HRTIM_BURSTDMA_SET2R: HRTIM_TIMxSET2R HRTIM_BURSTDMA_RST2R: HRTIM_TIMxRST2R HRTIM_BURSTDMA_EEFR1: HRTIM_TIMxEEFR1 HRTIM_BURSTDMA_EEFR2: HRTIM_TIMxEEFR2 HRTIM_BURSTDMA_RSTR: HRTIM_TIMxRSTR HRTIM_BURSTDMA_CHPR: HRTIM_TIMxCHPR HRTIM_BURSTDMA_OUTR: HRTIM_TIMxOUTR HRTIM_BURSTDMA_FLTR: HRTIM_TIMxFLTR Return values HAL: status Notes This function must be called before starting the timer HAL_HRTIM_WaveformCounterStart Function Name HAL_StatusTypeDef HAL_HRTIM_WaveformCounterStart (HRTIM_HandleTypeDef * hhrtim, uint32_t Timers) Function Description Starts the counter of the designated timer(s) operating in waveform mode Timers can be combined (ORed) to allow for simultaneous counter start. Parameters hhrtim: pointer to HAL HRTIM handle Timers: Timer counter(s) to start This parameter can be any combination of the following values: HRTIM_TIMERID_MASTER HRTIM_TIMERID_TIMER_A HRTIM_TIMERID_TIMER_B HRTIM_TIMERID_TIMER_C HRTIM_TIMERID_TIMER_D HRTIM_TIMERID_TIMER_E Return values HAL: status HAL_HRTIM_WaveformCounterStop Function Name HAL_StatusTypeDef HAL_HRTIM_WaveformCounterStop (HRTIM_HandleTypeDef * hhrtim, uint32_t Timers) Function Description Stops the counter of the designated timer(s) operating in waveform mode Timers can be combined (ORed) to allow for simultaneous counter stop. Parameters hhrtim: pointer to HAL HRTIM handle Timers: Timer counter(s) to stop This parameter can be any combination of the following values: HRTIM_TIMER_MASTER HRTIM_TIMER_A DOCID026526 Rev 4 291/832 UM1786 HRTIM_TIMER_B HRTIM_TIMER_C HRTIM_TIMER_D HRTIM_TIMER_E Return values HAL: status Notes The counter of a timer is stopped only if all timer outputs are disabled HAL_HRTIM_WaveformCounterStart_IT Function Name HAL_StatusTypeDef HAL_HRTIM_WaveformCounterStart_IT (HRTIM_HandleTypeDef * hhrtim, uint32_t Timers) Function Description Starts the counter of the designated timer(s) operating in waveform mode Timers can be combined (ORed) to allow for simultaneous counter start. Parameters hhrtim: pointer to HAL HRTIM handle Timers: Timer counter(s) to start This parameter can be any combination of the following values: HRTIM_TIMERID_MASTER HRTIM_TIMERID_A HRTIM_TIMERID_B HRTIM_TIMERID_C HRTIM_TIMERID_D HRTIM_TIMERID_E Return values HAL: status Notes HRTIM interrupts (e.g. faults interrupts) and interrupts related to the timers to start are enabled within this function. Interrupts to enable are selected through HAL_HRTIM_WaveformTimerConfig function. HAL_HRTIM_WaveformCounterStop_IT 292/832 Function Name HAL_StatusTypeDef HAL_HRTIM_WaveformCounterStop_IT (HRTIM_HandleTypeDef * hhrtim, uint32_t Timers) Function Description Stops the counter of the designated timer(s) operating in waveform mode Timers can be combined (ORed) to allow for simultaneous counter stop. Parameters hhrtim: pointer to HAL HRTIM handle Timers: Timer counter(s) to stop This parameter can be any combination of the following values: HRTIM_TIMER_MASTER HRTIM_TIMER_A HRTIM_TIMER_B HRTIM_TIMER_C HRTIM_TIMER_D HRTIM_TIMER_E Return values HAL: status Notes The counter of a timer is stopped only if all timer outputs are DOCID026526 Rev 4 UM1786 disabled All enabled timer related interrupts are disabled. HAL_HRTIM_WaveformCounterStart_DMA Function Name HAL_StatusTypeDef HAL_HRTIM_WaveformCounterStart_DMA (HRTIM_HandleTypeDef * hhrtim, uint32_t Timers) Function Description Starts the counter of the designated timer(s) operating in waveform mode Timers can be combined (ORed) to allow for simultaneous counter start. Parameters hhrtim: pointer to HAL HRTIM handle Timers: Timer counter(s) to start This parameter can be any combination of the following values: HRTIM_TIMER_MASTER HRTIM_TIMER_A HRTIM_TIMER_B HRTIM_TIMER_C HRTIM_TIMER_D HRTIM_TIMER_E Return values HAL: status Notes This function enables the dma request(s) mentionned in the timer configuration data structure for every timers to start. The source memory address, the destination memory address and the size of each DMA transfer are specified at timer configuration time (see HAL_HRTIM_WaveformTimerConfig) HAL_HRTIM_WaveformCounterStop_DMA Function Name HAL_StatusTypeDef HAL_HRTIM_WaveformCounterStop_DMA (HRTIM_HandleTypeDef * hhrtim, uint32_t Timers) Function Description Stops the counter of the designated timer(s) operating in waveform mode Timers can be combined (ORed) to allow for simultaneous counter stop. Parameters hhrtim: pointer to HAL HRTIM handle Timers: Timer counter(s) to stop This parameter can be any combination of the following values: HRTIM_TIMER_MASTER HRTIM_TIMER_A HRTIM_TIMER_B HRTIM_TIMER_C HRTIM_TIMER_D HRTIM_TIMER_E Return values HAL: status Notes The counter of a timer is stopped only if all timer outputs are disabled All enabled timer related DMA requests are disabled. DOCID026526 Rev 4 293/832 UM1786 HAL_HRTIM_WaveformOutputStart Function Name HAL_StatusTypeDef HAL_HRTIM_WaveformOutputStart (HRTIM_HandleTypeDef * hhrtim, uint32_t OutputsToStart) Function Description Enables the generation of the waveform signal on the designated output(s) Outputs can be combined (ORed) to allow for simultaneous output enabling. Parameters hhrtim: pointer to HAL HRTIM handle OutputsToStart: Timer output(s) to enable This parameter can be any combination of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 Return values HAL: status HAL_HRTIM_WaveformOutputStop Function Name HAL_StatusTypeDef HAL_HRTIM_WaveformOutputStop (HRTIM_HandleTypeDef * hhrtim, uint32_t OutputsToStop) Function Description Disables the generation of the waveform signal on the designated output(s) Outputs can be combined (ORed) to allow for simultaneous output disabling. Parameters hhrtim: pointer to HAL HRTIM handle OutputsToStop: Timer output(s) to disable This parameter can be any combination of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 Return values HAL: status HAL_HRTIM_BurstModeCtl 294/832 Function Name HAL_StatusTypeDef HAL_HRTIM_BurstModeCtl (HRTIM_HandleTypeDef * hhrtim, uint32_t Enable) Function Description Enables or disables the HRTIM burst mode controller. DOCID026526 Rev 4 UM1786 Parameters hhrtim: pointer to HAL HRTIM handle Enable: Burst mode controller enabling This parameter can be one of the following values: HRTIM_BURSTMODECTL_ENABLED: Burst mode enabled HRTIM_BURSTMODECTL_DISABLED: Burst mode disabled Return values HAL: status Notes This function must be called after starting the timer(s) HAL_HRTIM_BurstModeSoftwareTrigger Function Name HAL_StatusTypeDef HAL_HRTIM_BurstModeSoftwareTrigger (HRTIM_HandleTypeDef * hhrtim) Function Description Triggers the burst mode operation. Parameters hhrtim: pointer to HAL HRTIM handle Return values HAL: status HAL_HRTIM_SoftwareCapture Function Name HAL_StatusTypeDef HAL_HRTIM_SoftwareCapture (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t CaptureUnit) Function Description Triggers a software capture on the designed capture unit. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E CaptureUnit: Capture unit to trig This parameter can be one of the following values: HRTIM_CAPTUREUNIT_1: Capture unit 1 HRTIM_CAPTUREUNIT_2: Capture unit 2 Return values HAL: status Notes The 'software capture' bit in the capure configuration register is automatically reset by hardware HAL_HRTIM_SoftwareUpdate Function Name HAL_StatusTypeDef HAL_HRTIM_SoftwareUpdate (HRTIM_HandleTypeDef * hhrtim, uint32_t Timers) Function Description Triggers the update of the registers of one or several timers. Parameters hhrtim: pointer to HAL HRTIM handle Timers: timers concerned with the software register update This parameter can be any combination of the following DOCID026526 Rev 4 295/832 UM1786 values: HRTIM_TIMERUPDATE_MASTER HRTIM_TIMERUPDATE_A HRTIM_TIMERUPDATE_B HRTIM_TIMERUPDATE_C HRTIM_TIMERUPDATE_D HRTIM_TIMERUPDATE_E Return values HAL: status Notes The 'software update' bits in the HRTIM conrol register 2 register are automatically reset by hardware HAL_HRTIM_SoftwareReset Function Name HAL_StatusTypeDef HAL_HRTIM_SoftwareReset (HRTIM_HandleTypeDef * hhrtim, uint32_t Timers) Function Description Triggers the reset of one or several timers. Parameters hhrtim: pointer to HAL HRTIM handle Timers: timers concerned with the software counter reset This parameter can be any combination of the following values: HRTIM_TIMERRESET_MASTER HRTIM_TIMERRESET_TIMER_A HRTIM_TIMERRESET_TIMER_B HRTIM_TIMERRESET_TIMER_C HRTIM_TIMERRESET_TIMER_D HRTIM_TIMERRESET_TIMER_E Return values HAL: status Notes The 'software reset' bits in the HRTIM conrol register 2 are automatically reset by hardware HAL_HRTIM_BurstDMATransfer Function Name HAL_StatusTypeDef HAL_HRTIM_BurstDMATransfer (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t BurstBufferAddress, uint32_t BurstBufferLength) Function Description Starts a burst DMA operation to update HRTIM control registers content. Parameters 296/832 hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_MASTER for master timer HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E BurstBufferAddress: address of the buffer the HRTIM control registers content will be updated from. BurstBufferLength: size (in WORDS) of the burst buffer. DOCID026526 Rev 4 UM1786 Return values HAL: status Notes The TimerIdx parameter determines the dma channel to be used by the DMA burst controller (see below) HRTIM_TIMERINDEX_MASTER: DMA channel 2 is used by the DMA burst controller HRTIM_TIMERINDEX_TIMER_A: DMA channel 3 is used by the DMA burst controller HRTIM_TIMERINDEX_TIMER_B: DMA channel 4 is used by the DMA burst controller HRTIM_TIMERINDEX_TIMER_C: DMA channel 5 is used by the DMA burst controller HRTIM_TIMERINDEX_TIMER_D: DMA channel 6 is used by the DMA burst controller HRTIM_TIMERINDEX_TIMER_E: DMA channel 7 is used by the DMA burst controller HAL_HRTIM_UpdateEnable Function Name HAL_StatusTypeDef HAL_HRTIM_UpdateEnable (HRTIM_HandleTypeDef * hhrtim, uint32_t Timers) Function Description Enables the transfer from preload to active registers for one or several timing units (including master timer). Parameters hhrtim: pointer to HAL HRTIM handle Timers: Timer(s) concerned by the register preload enabling command This parameter can be any combination of the following values: HRTIM_TIMERUPDATE_MASTER HRTIM_TIMERUPDATE_A HRTIM_TIMERUPDATE_B HRTIM_TIMERUPDATE_C HRTIM_TIMERUPDATE_D HRTIM_TIMERUPDATE_E Return values HAL: status HAL_HRTIM_UpdateDisable Function Name HAL_StatusTypeDef HAL_HRTIM_UpdateDisable (HRTIM_HandleTypeDef * hhrtim, uint32_t Timers) Function Description Disables the transfer from preload to active registers for one or several timing units (including master timer). Parameters hhrtim: pointer to HAL HRTIM handle Timers: Timer(s) concerned by the register preload disabling command This parameter can be any combination of the following values: HRTIM_TIMERUPDATE_MASTER HRTIM_TIMERUPDATE_A HRTIM_TIMERUPDATE_B HRTIM_TIMERUPDATE_C HRTIM_TIMERUPDATE_D HRTIM_TIMERUPDATE_E Return values HAL: status DOCID026526 Rev 4 297/832 UM1786 HAL_HRTIM_GetState Function Name HAL_HRTIM_StateTypeDef HAL_HRTIM_GetState (HRTIM_HandleTypeDef * hhrtim) Function Description return the HRTIM HAL state Parameters hhrtim: pointer to HAL HRTIM handle Return values HAL: state HAL_HRTIM_GetCapturedValue Function Name uint32_t HAL_HRTIM_GetCapturedValue (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t CaptureUnit) Function Description Returns actual value of the capture register of the designated capture unit. Parameters Return values hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E CaptureUnit: Capture unit to trig This parameter can be one of the following values: HRTIM_CAPTUREUNIT_1: Capture unit 1 HRTIM_CAPTUREUNIT_2: Capture unit 2 Captured: value HAL_HRTIM_WaveformGetOutputLevel Function Name uint32_t HAL_HRTIM_WaveformGetOutputLevel (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t Output) Function Description Returns actual level (active or inactive) of the designated output. Parameters 298/832 hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E Output: Timer output This parameter can be one of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 DOCID026526 Rev 4 UM1786 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 Return values Output: level Notes Returned output level is taken before the output stage (chopper, polarity). HAL_HRTIM_WaveformGetOutputState Function Name uint32_t HAL_HRTIM_WaveformGetOutputState (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t Output) Function Description Returns actual state (RUN, IDLE, FAULT) of the designated output. Parameters Return values hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E Output: Timer output This parameter can be one of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TE1: Timer E - Output 1 HRTIM_OUTPUT_TE2: Timer E - Output 2 Output: state HAL_HRTIM_GetDelayedProtectionStatus Function Name uint32_t HAL_HRTIM_GetDelayedProtectionStatus (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t Output) Function Description Returns the level (active or inactive) of the designated output when the delayed protection was triggered. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B DOCID026526 Rev 4 299/832 UM1786 Return values HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E Output: Timer output This parameter can be one of the following values: HRTIM_OUTPUT_TA1: Timer A - Output 1 HRTIM_OUTPUT_TA2: Timer A - Output 2 HRTIM_OUTPUT_TB1: Timer B - Output 1 HRTIM_OUTPUT_TB2: Timer B - Output 2 HRTIM_OUTPUT_TC1: Timer C - Output 1 HRTIM_OUTPUT_TC2: Timer C - Output 2 HRTIM_OUTPUT_TD1: Timer D - Output 1 HRTIM_OUTPUT_TD2: Timer D - Output 2 HRTIM_OUTPUT_TD1: Timer E - Output 1 HRTIM_OUTPUT_TD2: Timer E - Output 2 Delayed: protection status HAL_HRTIM_GetBurstStatus Function Name uint32_t HAL_HRTIM_GetBurstStatus (HRTIM_HandleTypeDef * hhrtim) Function Description Returns the actual status (active or inactive) of the burst mode controller. Parameters hhrtim: pointer to HAL HRTIM handle Return values Burst: mode controller status HAL_HRTIM_GetCurrentPushPullStatus Function Name uint32_t HAL_HRTIM_GetCurrentPushPullStatus (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx) Function Description Indicates on which output the signal is currently active (when the push pull mode is enabled). Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E Return values Burst: mode controller status HAL_HRTIM_GetIdlePushPullStatus 300/832 Function Name uint32_t HAL_HRTIM_GetIdlePushPullStatus (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx) Function Description Indicates on which output the signal was applied, in push-pull mode, balanced fault mode or delayed idle mode, when the protection was triggered. DOCID026526 Rev 4 UM1786 Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E Return values Idle: Push Pull Status HAL_HRTIM_IRQHandler Function Name void HAL_HRTIM_IRQHandler (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx) Function Description This function handles HRTIM interrupt request. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be any value of HRTIM Timer Index Return values None: HAL_HRTIM_Fault1Callback Function Name void HAL_HRTIM_Fault1Callback (HRTIM_HandleTypeDef * hhrtim) Function Description Callback function invoked when a fault 1 interrupt occured. Parameters hhrtim: pointer to HAL HRTIM handle * Return values None: None: HAL_HRTIM_Fault2Callback Function Name void HAL_HRTIM_Fault2Callback (HRTIM_HandleTypeDef * hhrtim) Function Description Callback function invoked when a fault 2 interrupt occured. Parameters hhrtim: pointer to HAL HRTIM handle Return values None: HAL_HRTIM_Fault3Callback Function Name void HAL_HRTIM_Fault3Callback (HRTIM_HandleTypeDef * hhrtim) Function Description Callback function invoked when a fault 3 interrupt occured. Parameters hhrtim: pointer to HAL HRTIM handle Return values None: DOCID026526 Rev 4 301/832 UM1786 HAL_HRTIM_Fault4Callback Function Name void HAL_HRTIM_Fault4Callback (HRTIM_HandleTypeDef * hhrtim) Function Description Callback function invoked when a fault 4 interrupt occured. Parameters hhrtim: pointer to HAL HRTIM handle Return values None: HAL_HRTIM_Fault5Callback Function Name void HAL_HRTIM_Fault5Callback (HRTIM_HandleTypeDef * hhrtim) Function Description Callback function invoked when a fault 5 interrupt occured. Parameters hhrtim: pointer to HAL HRTIM handle Return values None: HAL_HRTIM_SystemFaultCallback Function Name void HAL_HRTIM_SystemFaultCallback (HRTIM_HandleTypeDef * hhrtim) Function Description Callback function invoked when a system fault interrupt occured. Parameters hhrtim: pointer to HAL HRTIM handle Return values None: HAL_HRTIM_DLLCalbrationReadyCallback Function Name void HAL_HRTIM_DLLCalbrationReadyCallback (HRTIM_HandleTypeDef * hhrtim) Function Description Callback function invoked when the DLL calibration is completed. Parameters hhrtim: pointer to HAL HRTIM handle Return values None: HAL_HRTIM_BurstModePeriodCallback Function Name void HAL_HRTIM_BurstModePeriodCallback (HRTIM_HandleTypeDef * hhrtim) Function Description Callback function invoked when the end of the burst mode period is reached. Parameters hhrtim: pointer to HAL HRTIM handle Return values None: HAL_HRTIM_SynchronizationEventCallback 302/832 Function Name void HAL_HRTIM_SynchronizationEventCallback (HRTIM_HandleTypeDef * hhrtim) Function Description Callback function invoked when a synchronization input event is DOCID026526 Rev 4 UM1786 received. Parameters hhrtim: pointer to HAL HRTIM handle Return values None: HAL_HRTIM_RegistersUpdateCallback Function Name void HAL_HRTIM_RegistersUpdateCallback (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx) Function Description Callback function invoked when timer registers are updated. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_MASTER for master timer HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E Return values None: HAL_HRTIM_RepetitionEventCallback Function Name void HAL_HRTIM_RepetitionEventCallback (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx) Function Description Callback function invoked when timer repetition period has elapsed. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_MASTER for master timer HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E Return values None: HAL_HRTIM_Compare1EventCallback Function Name void HAL_HRTIM_Compare1EventCallback (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx) Function Description Callback function invoked when the timer counter matches the value programmed in the compare 1 register. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_MASTER for master timer HRTIM_TIMERINDEX_TIMER_A for timer A DOCID026526 Rev 4 303/832 UM1786 Return values HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E None: HAL_HRTIM_Compare2EventCallback Function Name void HAL_HRTIM_Compare2EventCallback (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx) Function Description Callback function invoked when the timer counter matches the value programmed in the compare 2 register. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_MASTER for master timer HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E Return values None: HAL_HRTIM_Compare3EventCallback Function Name void HAL_HRTIM_Compare3EventCallback (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx) Function Description Callback function invoked when the timer counter matches the value programmed in the compare 3 register. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_MASTER for master timer HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E Return values None: HAL_HRTIM_Compare4EventCallback 304/832 Function Name void HAL_HRTIM_Compare4EventCallback (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx) Function Description Callback function invoked when the timer counter matches the value programmed in the compare 4 register. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: DOCID026526 Rev 4 UM1786 Return values HRTIM_TIMERINDEX_MASTER for master timer HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E None: HAL_HRTIM_Capture1EventCallback Function Name void HAL_HRTIM_Capture1EventCallback (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx) Function Description Callback function invoked when the timer x capture 1 event occurs. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E Return values None: HAL_HRTIM_Capture2EventCallback Function Name void HAL_HRTIM_Capture2EventCallback (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx) Function Description Callback function invoked when the timer x capture 2 event occurs. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E Return values None: HAL_HRTIM_DelayedProtectionCallback Function Name void HAL_HRTIM_DelayedProtectionCallback (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx) Function Description Callback function invoked when the delayed idle or balanced idle mode is entered. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: DOCID026526 Rev 4 305/832 UM1786 Return values HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E None: HAL_HRTIM_CounterResetCallback Function Name void HAL_HRTIM_CounterResetCallback (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx) Function Description Callback function invoked when the timer x counter reset/roll-over event occurs. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E Return values None: HAL_HRTIM_Output1SetCallback Function Name void HAL_HRTIM_Output1SetCallback (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx) Function Description Callback function invoked when the timer x output 1 is set. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E Return values None: HAL_HRTIM_Output1ResetCallback 306/832 Function Name void HAL_HRTIM_Output1ResetCallback (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx) Function Description Callback function invoked when the timer x output 1 is reset. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C DOCID026526 Rev 4 UM1786 Return values HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E None: HAL_HRTIM_Output2SetCallback Function Name void HAL_HRTIM_Output2SetCallback (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx) Function Description Callback function invoked when the timer x output 2 is set. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E Return values None: HAL_HRTIM_Output2ResetCallback Function Name void HAL_HRTIM_Output2ResetCallback (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx) Function Description Callback function invoked when the timer x output 2 is reset. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D HRTIM_TIMERINDEX_TIMER_E for timer E Return values None: HAL_HRTIM_BurstDMATransferCallback Function Name void HAL_HRTIM_BurstDMATransferCallback (HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx) Function Description Callback function invoked when a DMA burst transfer is completed. Parameters hhrtim: pointer to HAL HRTIM handle TimerIdx: Timer index This parameter can be one of the following values: HRTIM_TIMERINDEX_MASTER for master timer HRTIM_TIMERINDEX_TIMER_A for timer A HRTIM_TIMERINDEX_TIMER_B for timer B HRTIM_TIMERINDEX_TIMER_C for timer C HRTIM_TIMERINDEX_TIMER_D for timer D DOCID026526 Rev 4 307/832 UM1786 Return values HRTIM_TIMERINDEX_TIMER_E for timer E None: HAL_HRTIM_ErrorCallback Function Name void HAL_HRTIM_ErrorCallback (HRTIM_HandleTypeDef * hhrtim) Function Description Callback function invoked when a DMA error occurs. Parameters hhrtim: pointer to HAL HRTIM handle Return values None: 21.3 HRTIM Firmware driver defines 21.3.1 HRTIM HRTIM ADC Trigger HRTIM_ADCTRIGGER_1 ADC trigger 1 identifier HRTIM_ADCTRIGGER_2 ADC trigger 2 identifier HRTIM_ADCTRIGGER_3 ADC trigger 3 identifier HRTIM_ADCTRIGGER_4 ADC trigger 4 identifier IS_HRTIM_ADCTRIGGER HRTIM ADC Trigger Event 308/832 HRTIM_ADCTRIGGEREVENT13_NONE No ADC trigger event HRTIM_ADCTRIGGEREVENT13_MASTER_CMP1 ADC Trigger on master compare 1 HRTIM_ADCTRIGGEREVENT13_MASTER_CMP2 ADC Trigger on master compare 2 HRTIM_ADCTRIGGEREVENT13_MASTER_CMP3 ADC Trigger on master compare 3 HRTIM_ADCTRIGGEREVENT13_MASTER_CMP4 ADC Trigger on master compare 4 HRTIM_ADCTRIGGEREVENT13_MASTER_PERIOD ADC Trigger on master period HRTIM_ADCTRIGGEREVENT13_EVENT_1 ADC Trigger on external event 1 HRTIM_ADCTRIGGEREVENT13_EVENT_2 ADC Trigger on external event 2 HRTIM_ADCTRIGGEREVENT13_EVENT_3 ADC Trigger on external event 3 HRTIM_ADCTRIGGEREVENT13_EVENT_4 ADC Trigger on external event 4 HRTIM_ADCTRIGGEREVENT13_EVENT_5 ADC Trigger on external event 5 HRTIM_ADCTRIGGEREVENT13_TIMERA_CMP2 ADC Trigger on Timer A compare 2 HRTIM_ADCTRIGGEREVENT13_TIMERA_CMP3 ADC Trigger on Timer A compare 3 HRTIM_ADCTRIGGEREVENT13_TIMERA_CMP4 ADC Trigger on Timer A compare 4 HRTIM_ADCTRIGGEREVENT13_TIMERA_PERIOD ADC Trigger on Timer A period DOCID026526 Rev 4 UM1786 HRTIM_ADCTRIGGEREVENT13_TIMERA_RESET ADC Trigger on Timer A reset HRTIM_ADCTRIGGEREVENT13_TIMERB_CMP2 ADC Trigger on Timer B compare 2 HRTIM_ADCTRIGGEREVENT13_TIMERB_CMP3 ADC Trigger on Timer B compare 3 HRTIM_ADCTRIGGEREVENT13_TIMERB_CMP4 ADC Trigger on Timer B compare 4 HRTIM_ADCTRIGGEREVENT13_TIMERB_PERIOD ADC Trigger on Timer B period HRTIM_ADCTRIGGEREVENT13_TIMERB_RESET ADC Trigger on Timer B reset HRTIM_ADCTRIGGEREVENT13_TIMERC_CMP2 ADC Trigger on Timer C compare 2 HRTIM_ADCTRIGGEREVENT13_TIMERC_CMP3 ADC Trigger on Timer C compare 3 HRTIM_ADCTRIGGEREVENT13_TIMERC_CMP4 ADC Trigger on Timer C compare 4 HRTIM_ADCTRIGGEREVENT13_TIMERC_PERIOD ADC Trigger on Timer C period HRTIM_ADCTRIGGEREVENT13_TIMERD_CMP2 ADC Trigger on Timer D compare 2 HRTIM_ADCTRIGGEREVENT13_TIMERD_CMP3 ADC Trigger on Timer D compare 3 HRTIM_ADCTRIGGEREVENT13_TIMERD_CMP4 ADC Trigger on Timer D compare 4 HRTIM_ADCTRIGGEREVENT13_TIMERD_PERIOD ADC Trigger on Timer D period HRTIM_ADCTRIGGEREVENT13_TIMERE_CMP2 ADC Trigger on Timer E compare 2 HRTIM_ADCTRIGGEREVENT13_TIMERE_CMP3 ADC Trigger on Timer E compare 3 HRTIM_ADCTRIGGEREVENT13_TIMERE_CMP4 ADC Trigger on Timer E compare 4 HRTIM_ADCTRIGGEREVENT13_TIMERE_PERIOD ADC Trigger on Timer E period HRTIM_ADCTRIGGEREVENT24_NONE No ADC trigger event HRTIM_ADCTRIGGEREVENT24_MASTER_CMP1 ADC Trigger on master compare 1 HRTIM_ADCTRIGGEREVENT24_MASTER_CMP2 ADC Trigger on master compare 2 HRTIM_ADCTRIGGEREVENT24_MASTER_CMP3 ADC Trigger on master compare 3 HRTIM_ADCTRIGGEREVENT24_MASTER_CMP4 ADC Trigger on master compare 4 HRTIM_ADCTRIGGEREVENT24_MASTER_PERIOD ADC Trigger on master period HRTIM_ADCTRIGGEREVENT24_EVENT_6 ADC Trigger on external event 6 HRTIM_ADCTRIGGEREVENT24_EVENT_7 ADC Trigger on external event 7 HRTIM_ADCTRIGGEREVENT24_EVENT_8 ADC Trigger on external event 8 HRTIM_ADCTRIGGEREVENT24_EVENT_9 ADC Trigger on external event 9 DOCID026526 Rev 4 309/832 UM1786 ADC Trigger on external event 10 HRTIM_ADCTRIGGEREVENT24_EVENT_10 HRTIM_ADCTRIGGEREVENT24_TIMERA_CMP2 ADC Trigger on Timer A compare 2 HRTIM_ADCTRIGGEREVENT24_TIMERA_CMP3 ADC Trigger on Timer A compare 3 HRTIM_ADCTRIGGEREVENT24_TIMERA_CMP4 ADC Trigger on Timer A compare 4 HRTIM_ADCTRIGGEREVENT24_TIMERA_PERIOD ADC Trigger on Timer A period HRTIM_ADCTRIGGEREVENT24_TIMERB_CMP2 ADC Trigger on Timer B compare 2 HRTIM_ADCTRIGGEREVENT24_TIMERB_CMP3 ADC Trigger on Timer B compare 3 HRTIM_ADCTRIGGEREVENT24_TIMERB_CMP4 ADC Trigger on Timer B compare 4 HRTIM_ADCTRIGGEREVENT24_TIMERB_PERIOD ADC Trigger on Timer B period HRTIM_ADCTRIGGEREVENT24_TIMERC_CMP2 ADC Trigger on Timer C compare 2 HRTIM_ADCTRIGGEREVENT24_TIMERC_CMP3 ADC Trigger on Timer C compare 3 HRTIM_ADCTRIGGEREVENT24_TIMERC_CMP4 ADC Trigger on Timer C compare 4 HRTIM_ADCTRIGGEREVENT24_TIMERC_PERIOD ADC Trigger on Timer C period HRTIM_ADCTRIGGEREVENT24_TIMERC_RESET ADC Trigger on Timer C reset HRTIM_ADCTRIGGEREVENT24_TIMERD_CMP2 ADC Trigger on Timer D compare 2 HRTIM_ADCTRIGGEREVENT24_TIMERD_CMP3 ADC Trigger on Timer D compare 3 HRTIM_ADCTRIGGEREVENT24_TIMERD_CMP4 ADC Trigger on Timer D compare 4 HRTIM_ADCTRIGGEREVENT24_TIMERD_PERIOD ADC Trigger on Timer D period HRTIM_ADCTRIGGEREVENT24_TIMERD_RESET ADC Trigger on Timer D reset HRTIM_ADCTRIGGEREVENT24_TIMERE_CMP2 ADC Trigger on Timer E compare 2 HRTIM_ADCTRIGGEREVENT24_TIMERE_CMP3 ADC Trigger on Timer E compare 3 HRTIM_ADCTRIGGEREVENT24_TIMERE_CMP4 ADC Trigger on Timer E compare 4 HRTIM_ADCTRIGGEREVENT24_TIMERE_RESET ADC Trigger on Timer E reset HRTIM ADC Trigger Update Source 310/832 HRTIM_ADCTRIGGERUPDATE_MASTER Master timer HRTIM_ADCTRIGGERUPDATE_TIMER_A Timer A DOCID026526 Rev 4 UM1786 HRTIM_ADCTRIGGERUPDATE_TIMER_B Timer B HRTIM_ADCTRIGGERUPDATE_TIMER_C Timer C HRTIM_ADCTRIGGERUPDATE_TIMER_D Timer D HRTIM_ADCTRIGGERUPDATE_TIMER_E Timer E HRTIM Burst DMA Registers Update HRTIM_BURSTDMA_NONE No register is updated by Burst DMA accesses HRTIM_BURSTDMA_CR MCR or TIMxCR register is updated by Burst DMA accesses HRTIM_BURSTDMA_ICR MICR or TIMxICR register is updated by Burst DMA accesses HRTIM_BURSTDMA_DIER MDIER or TIMxDIER register is updated by Burst DMA accesses HRTIM_BURSTDMA_CNT MCNTR or CNTxCR register is updated by Burst DMA accesses HRTIM_BURSTDMA_PER MPER or PERxR register is updated by Burst DMA accesses HRTIM_BURSTDMA_REP MREPR or REPxR register is updated by Burst DMA accesses HRTIM_BURSTDMA_CMP1 MCMP1R or CMP1xR register is updated by Burst DMA accesses HRTIM_BURSTDMA_CMP2 MCMP2R or CMP2xR register is updated by Burst DMA accesses HRTIM_BURSTDMA_CMP3 MCMP3R or CMP3xR register is updated by Burst DMA accesses HRTIM_BURSTDMA_CMP4 MCMP4R or CMP4xR register is updated by Burst DMA accesses HRTIM_BURSTDMA_DTR TDxR register is updated by Burst DMA accesses HRTIM_BURSTDMA_SET1R SET1R register is updated by Burst DMA accesses HRTIM_BURSTDMA_RST1R RST1R register is updated by Burst DMA accesses HRTIM_BURSTDMA_SET2R SET2R register is updated by Burst DMA accesses HRTIM_BURSTDMA_RST2R RST1R register is updated by Burst DMA accesses HRTIM_BURSTDMA_EEFR1 EEFxR1 register is updated by Burst DMA accesses HRTIM_BURSTDMA_EEFR2 EEFxR2 register is updated by Burst DMA accesses HRTIM_BURSTDMA_RSTR RSTxR register is updated by Burst DMA accesses HRTIM_BURSTDMA_CHPR CHPxR register is updated by Burst DMA accesses HRTIM_BURSTDMA_OUTR OUTxR register is updated by Burst DMA accesses HRTIM_BURSTDMA_FLTR FLTxR register is updated by Burst DMA accesses HRTIM Burst Mode Clock Source HRTIM_BURSTMODECLOCKSOURCE_MASTER DOCID026526 Rev 4 Master timer counter reset/rollover is used as clock source for 311/832 UM1786 the burst mode counter HRTIM_BURSTMODECLOCKSOURCE_TIMER_A Timer A counter reset/roll-over is used as clock source for the burst mode counter HRTIM_BURSTMODECLOCKSOURCE_TIMER_B Timer B counter reset/roll-over is used as clock source for the burst mode counter HRTIM_BURSTMODECLOCKSOURCE_TIMER_C Timer C counter reset/roll-over is used as clock source for the burst mode counter HRTIM_BURSTMODECLOCKSOURCE_TIMER_D Timer D counter reset/roll-over is used as clock source for the burst mode counter HRTIM_BURSTMODECLOCKSOURCE_TIMER_E Timer E counter reset/roll-over is used as clock source for the burst mode counter HRTIM_BURSTMODECLOCKSOURCE_TIM16_OC On-chip Event 1 (BMClk[1]), acting as a burst mode counter clock HRTIM_BURSTMODECLOCKSOURCE_TIM17_OC On-chip Event 2 (BMClk[2]), acting as a burst mode counter clock HRTIM_BURSTMODECLOCKSOURCE_TIM7_TRGO On-chip Event 3 (BMClk[3]), acting as a burst mode counter clock HRTIM_BURSTMODECLOCKSOURCE_FHRTIM Prescaled fHRTIM clock is used as clock source for the burst mode counter HRTIM Burst Mode Control HRTIM_BURSTMODECTL_DISABLED Burst mode disabled HRTIM_BURSTMODECTL_ENABLED Burst mode enabled HRTIM Burst Mode Operating Mode HRTIM_BURSTMODE_SINGLESHOT Burst mode operates in single shot mode HRTIM_BURSTMODE_CONTINOUS Burst mode operates in continuous mode HRTIM Burst Mode Prescaler 312/832 HRTIM_BURSTMODEPRESCALER_DIV1 fBRST = fHRTIM HRTIM_BURSTMODEPRESCALER_DIV2 fBRST = fHRTIM/2 HRTIM_BURSTMODEPRESCALER_DIV4 fBRST = fHRTIM/4 HRTIM_BURSTMODEPRESCALER_DIV8 fBRST = fHRTIM/8 HRTIM_BURSTMODEPRESCALER_DIV16 fBRST = fHRTIM/16 HRTIM_BURSTMODEPRESCALER_DIV32 fBRST = fHRTIM/32 HRTIM_BURSTMODEPRESCALER_DIV64 fBRST = fHRTIM/64 HRTIM_BURSTMODEPRESCALER_DIV128 fBRST = fHRTIM/128 DOCID026526 Rev 4 UM1786 HRTIM_BURSTMODEPRESCALER_DIV256 fBRST = fHRTIM/256 HRTIM_BURSTMODEPRESCALER_DIV512 fBRST = fHRTIM/512 HRTIM_BURSTMODEPRESCALER_DIV1024 fBRST = fHRTIM/1024 HRTIM_BURSTMODEPRESCALER_DIV2048 fBRST = fHRTIM/2048 HRTIM_BURSTMODEPRESCALER_DIV4096 fBRST = fHRTIM/4096 HRTIM_BURSTMODEPRESCALER_DIV8192 fBRST = fHRTIM/8192 HRTIM_BURSTMODEPRESCALER_DIV16384 fBRST = fHRTIM/16384 HRTIM_BURSTMODEPRESCALER_DIV32768 fBRST = fHRTIM/32768 HRTIM Burst Mode Register Preload Enable HRIM_BURSTMODEPRELOAD_DISABLED Preload disabled: the write access is directly done into active registers HRIM_BURSTMODEPRELOAD_ENABLED Preload enabled: the write access is done into preload registers HRTIM Burst Mode Status HRTIM_BURSTMODESTATUS_NORMAL Normal operation HRTIM_BURSTMODESTATUS_ONGOING Burst operation on-going HRTIM Burst Mode Trigger HRTIM_BURSTMODETRIGGER_NONE No trigger HRTIM_BURSTMODETRIGGER_MASTER_RESET Master reset HRTIM_BURSTMODETRIGGER_MASTER_REPETITION Master repetition HRTIM_BURSTMODETRIGGER_MASTER_CMP1 Master compare 1 HRTIM_BURSTMODETRIGGER_MASTER_CMP2 Master compare 2 HRTIM_BURSTMODETRIGGER_MASTER_CMP3 Master compare 3 HRTIM_BURSTMODETRIGGER_MASTER_CMP4 Master compare 4 HRTIM_BURSTMODETRIGGER_TIMERA_RESET Timer A reset HRTIM_BURSTMODETRIGGER_TIMERA_REPETITION Timer A repetition HRTIM_BURSTMODETRIGGER_TIMERA_CMP1 Timer A compare 1 HRTIM_BURSTMODETRIGGER_TIMERA_CMP2 Timer A compare 2 HRTIM_BURSTMODETRIGGER_TIMERB_RESET Timer B reset HRTIM_BURSTMODETRIGGER_TIMERB_REPETITION Timer B repetition HRTIM_BURSTMODETRIGGER_TIMERB_CMP1 Timer B compare 1 HRTIM_BURSTMODETRIGGER_TIMERB_CMP2 Timer B compare 2 HRTIM_BURSTMODETRIGGER_TIMERC_RESET Timer C reset HRTIM_BURSTMODETRIGGER_TIMERC_REPETITION Timer C repetition HRTIM_BURSTMODETRIGGER_TIMERC_CMP1 Timer C compare 1 HRTIM_BURSTMODETRIGGER_TIMERC_CMP2 Timer C compare 2 HRTIM_BURSTMODETRIGGER_TIMERD_RESET Timer D reset DOCID026526 Rev 4 313/832 UM1786 HRTIM_BURSTMODETRIGGER_TIMERD_REPETITION Timer D repetition HRTIM_BURSTMODETRIGGER_TIMERD_CMP1 Timer D compare 1 HRTIM_BURSTMODETRIGGER_TIMERD_CMP2 Timer D compare 2 HRTIM_BURSTMODETRIGGER_TIMERE_RESET Timer E reset HRTIM_BURSTMODETRIGGER_TIMERE_REPETITION Timer E repetition HRTIM_BURSTMODETRIGGER_TIMERE_CMP1 Timer E compare 1 HRTIM_BURSTMODETRIGGER_TIMERE_CMP2 Timer E compare 2 HRTIM_BURSTMODETRIGGER_TIMERA_EVENT7 Timer A period following External Event 7 HRTIM_BURSTMODETRIGGER_TIMERD_EVENT8 Timer D period following External Event 8 HRTIM_BURSTMODETRIGGER_EVENT_7 External Event 7 (timer A filters applied) HRTIM_BURSTMODETRIGGER_EVENT_8 External Event 8 (timer D filters applied) HRTIM_BURSTMODETRIGGER_EVENT_ONCHIP On-chip Event HRTIM Capture Unit HRTIM_CAPTUREUNIT_1 Capture unit 1 identifier HRTIM_CAPTUREUNIT_2 Capture unit 2 identifier HRTIM Capture Unit Trigger 314/832 HRTIM_CAPTURETRIGGER_NONE Capture trigger is disabled HRTIM_CAPTURETRIGGER_UPDATE The update event triggers the Capture HRTIM_CAPTURETRIGGER_EEV_1 The External event 1 triggers the Capture HRTIM_CAPTURETRIGGER_EEV_2 The External event 2 triggers the Capture HRTIM_CAPTURETRIGGER_EEV_3 The External event 3 triggers the Capture HRTIM_CAPTURETRIGGER_EEV_4 The External event 4 triggers the Capture HRTIM_CAPTURETRIGGER_EEV_5 The External event 5 triggers the Capture HRTIM_CAPTURETRIGGER_EEV_6 The External event 6 triggers the Capture HRTIM_CAPTURETRIGGER_EEV_7 The External event 7 triggers the Capture HRTIM_CAPTURETRIGGER_EEV_8 The External event 8 triggers the Capture HRTIM_CAPTURETRIGGER_EEV_9 The External event 9 triggers the Capture HRTIM_CAPTURETRIGGER_EEV_10 The External event 10 triggers the Capture HRTIM_CAPTURETRIGGER_TA1_SET Capture is triggered by TA1 output inactive to active transition HRTIM_CAPTURETRIGGER_TA1_RESET Capture is triggered by TA1 output active to inactive transition HRTIM_CAPTURETRIGGER_TIMERA_CMP1 Timer A Compare 1 triggers Capture HRTIM_CAPTURETRIGGER_TIMERA_CMP2 Timer A Compare 2 triggers Capture DOCID026526 Rev 4 UM1786 HRTIM_CAPTURETRIGGER_TB1_SET Capture is triggered by TB1 output inactive to active transition HRTIM_CAPTURETRIGGER_TB1_RESET Capture is triggered by TB1 output active to inactive transition HRTIM_CAPTURETRIGGER_TIMERB_CMP1 Timer B Compare 1 triggers Capture HRTIM_CAPTURETRIGGER_TIMERB_CMP2 Timer B Compare 2 triggers Capture HRTIM_CAPTURETRIGGER_TC1_SET Capture is triggered by TC1 output inactive to active transition HRTIM_CAPTURETRIGGER_TC1_RESET Capture is triggered by TC1 output active to inactive transition HRTIM_CAPTURETRIGGER_TIMERC_CMP1 Timer C Compare 1 triggers Capture HRTIM_CAPTURETRIGGER_TIMERC_CMP2 Timer C Compare 2 triggers Capture HRTIM_CAPTURETRIGGER_TD1_SET Capture is triggered by TD1 output inactive to active transition HRTIM_CAPTURETRIGGER_TD1_RESET Capture is triggered by TD1 output active to inactive transition HRTIM_CAPTURETRIGGER_TIMERD_CMP1 Timer D Compare 1 triggers Capture HRTIM_CAPTURETRIGGER_TIMERD_CMP2 Timer D Compare 2 triggers Capture HRTIM_CAPTURETRIGGER_TE1_SET Capture is triggered by TE1 output inactive to active transition HRTIM_CAPTURETRIGGER_TE1_RESET Capture is triggered by TE1 output active to inactive transition HRTIM_CAPTURETRIGGER_TIMERE_CMP1 Timer E Compare 1 triggers Capture HRTIM_CAPTURETRIGGER_TIMERE_CMP2 Timer E Compare 2 triggers Capture HRTIM Chopper Duty Cycle HRTIM_CHOPPER_DUTYCYCLE_0 Only 1st pulse is present HRTIM_CHOPPER_DUTYCYCLE_125 Duty cycle of the carrier signal is 12.5 % HRTIM_CHOPPER_DUTYCYCLE_250 Duty cycle of the carrier signal is 25 % HRTIM_CHOPPER_DUTYCYCLE_375 Duty cycle of the carrier signal is 37.5 % HRTIM_CHOPPER_DUTYCYCLE_500 Duty cycle of the carrier signal is 50 % HRTIM_CHOPPER_DUTYCYCLE_625 Duty cycle of the carrier signal is 62.5 % HRTIM_CHOPPER_DUTYCYCLE_750 Duty cycle of the carrier signal is 75 % HRTIM_CHOPPER_DUTYCYCLE_875 Duty cycle of the carrier signal is 87.5 % HRTIM Chopper Frequency HRTIM_CHOPPER_PRESCALERRATIO_DIV16 fCHPFRQ = fHRTIM / 16 HRTIM_CHOPPER_PRESCALERRATIO_DIV32 fCHPFRQ = fHRTIM / 32 HRTIM_CHOPPER_PRESCALERRATIO_DIV48 fCHPFRQ = fHRTIM / 48 HRTIM_CHOPPER_PRESCALERRATIO_DIV64 fCHPFRQ = fHRTIM / 64 HRTIM_CHOPPER_PRESCALERRATIO_DIV80 fCHPFRQ = fHRTIM / 80 DOCID026526 Rev 4 315/832 UM1786 HRTIM_CHOPPER_PRESCALERRATIO_DIV96 fCHPFRQ = fHRTIM / 96 HRTIM_CHOPPER_PRESCALERRATIO_DIV112 fCHPFRQ = fHRTIM / 112 HRTIM_CHOPPER_PRESCALERRATIO_DIV128 fCHPFRQ = fHRTIM / 128 HRTIM_CHOPPER_PRESCALERRATIO_DIV144 fCHPFRQ = fHRTIM / 144 HRTIM_CHOPPER_PRESCALERRATIO_DIV160 fCHPFRQ = fHRTIM / 160 HRTIM_CHOPPER_PRESCALERRATIO_DIV176 fCHPFRQ = fHRTIM / 176 HRTIM_CHOPPER_PRESCALERRATIO_DIV192 fCHPFRQ = fHRTIM / 192 HRTIM_CHOPPER_PRESCALERRATIO_DIV208 fCHPFRQ = fHRTIM / 208 HRTIM_CHOPPER_PRESCALERRATIO_DIV224 fCHPFRQ = fHRTIM / 224 HRTIM_CHOPPER_PRESCALERRATIO_DIV240 fCHPFRQ = fHRTIM / 240 HRTIM_CHOPPER_PRESCALERRATIO_DIV256 fCHPFRQ = fHRTIM / 256 HRTIM Chopper Start Pulse Width HRTIM_CHOPPER_PULSEWIDTH_16 tSTPW = tHRTIM x 16 HRTIM_CHOPPER_PULSEWIDTH_32 tSTPW = tHRTIM x 32 HRTIM_CHOPPER_PULSEWIDTH_48 tSTPW = tHRTIM x 48 HRTIM_CHOPPER_PULSEWIDTH_64 tSTPW = tHRTIM x 64 HRTIM_CHOPPER_PULSEWIDTH_80 tSTPW = tHRTIM x 80 HRTIM_CHOPPER_PULSEWIDTH_96 tSTPW = tHRTIM x 96 HRTIM_CHOPPER_PULSEWIDTH_112 tSTPW = tHRTIM x 112 HRTIM_CHOPPER_PULSEWIDTH_128 tSTPW = tHRTIM x 128 HRTIM_CHOPPER_PULSEWIDTH_144 tSTPW = tHRTIM x 144 HRTIM_CHOPPER_PULSEWIDTH_160 tSTPW = tHRTIM x 160 HRTIM_CHOPPER_PULSEWIDTH_176 tSTPW = tHRTIM x 176 HRTIM_CHOPPER_PULSEWIDTH_192 tSTPW = tHRTIM x 192 HRTIM_CHOPPER_PULSEWIDTH_208 tSTPW = tHRTIM x 208 HRTIM_CHOPPER_PULSEWIDTH_224 tSTPW = tHRTIM x 224 HRTIM_CHOPPER_PULSEWIDTH_240 tSTPW = tHRTIM x 240 HRTIM_CHOPPER_PULSEWIDTH_256 tSTPW = tHRTIM x 256 HRTIM Common Interrupt Enable 316/832 HRTIM_IT_NONE No interrupt enabled HRTIM_IT_FLT1 Fault 1 interrupt enable HRTIM_IT_FLT2 Fault 2 interrupt enable HRTIM_IT_FLT3 Fault 3 interrupt enable HRTIM_IT_FLT4 Fault 4 interrupt enable HRTIM_IT_FLT5 Fault 5 interrupt enable HRTIM_IT_SYSFLT System Fault interrupt enable DOCID026526 Rev 4 UM1786 HRTIM_IT_DLLRDY DLL ready interrupt enable HRTIM_IT_BMPER Burst mode period interrupt enable HRTIM Common Interrupt Flag HRTIM_FLAG_FLT1 Fault 1 interrupt flag HRTIM_FLAG_FLT2 Fault 2 interrupt flag HRTIM_FLAG_FLT3 Fault 3 interrupt flag HRTIM_FLAG_FLT4 Fault 4 interrupt flag HRTIM_FLAG_FLT5 Fault 5 interrupt flag HRTIM_FLAG_SYSFLT System Fault interrupt flag HRTIM_FLAG_DLLRDY DLL ready interrupt flag HRTIM_FLAG_BMPER Burst mode period interrupt flag HRTIM Compare Unit HRTIM_COMPAREUNIT_1 Compare unit 1 identifier HRTIM_COMPAREUNIT_2 Compare unit 2 identifier HRTIM_COMPAREUNIT_3 Compare unit 3 identifier HRTIM_COMPAREUNIT_4 Compare unit 4 identifier HRTIM Compare Unit Auto Delayed Mode HRTIM_AUTODELAYEDMODE_REGULAR standard compare mode HRTIM_AUTODELAYEDMODE_AUTODELAYED_NOTIMEOUT Compare event generated only if a capture has occurred HRTIM_AUTODELAYEDMODE_AUTODELAYED_TIMEOUTCMP1 Compare event generated if a capture has occurred or after a Compare 1 match (timeout if capture event is missing) HRTIM_AUTODELAYEDMODE_AUTODELAYED_TIMEOUTCMP3 Compare event generated if a capture has occurred or after a Compare 3 match (timeout if capture event is missing) HRTIM Counter Operating Mode HRTIM_MODE_CONTINUOUS The timer operates in continuous (free-running) mode HRTIM_MODE_SINGLESHOT The timer operates in non retriggerable single-shot mode HRTIM_MODE_SINGLESHOT_RETRIGGERABLE The timer operates in retriggerable DOCID026526 Rev 4 317/832 UM1786 single-shot mode HRTIM Current Push Pull Status HRTIM_PUSHPULL_CURRENTSTATUS_OUTPUT1 Signal applied on output 1 and output 2 forced inactive HRTIM_PUSHPULL_CURRENTSTATUS_OUTPUT2 Signal applied on output 2 and output 1 forced inactive HRTIM DAC Synchronization HRTIM_DACSYNC_NONE No DAC synchronization event generated HRTIM_DACSYNC_DACTRIGOUT_1 DAC synchronization event generated on DACTrigOut1 output upon timer update HRTIM_DACSYNC_DACTRIGOUT_2 DAC synchronization event generated on DACTrigOut2 output upon timer update HRTIM_DACSYNC_DACTRIGOUT_3 DAC update generated on DACTrigOut3 output upon timer update HRTIM Deadtime Falling Lock HRTIM_TIMDEADTIME_FALLINGLOCK_WRITE Deadtime falling value and sign is writeable HRTIM_TIMDEADTIME_FALLINGLOCK_READONLY Deadtime falling value and sign is read-only HRTIM Deadtime Falling Sign HRTIM_TIMDEADTIME_FALLINGSIGN_POSITIVE Positive deadtime on falling edge HRTIM_TIMDEADTIME_FALLINGSIGN_NEGATIVE Negative deadtime on falling edge HRTIM Deadtime Falling Sign Lock HRTIM_TIMDEADTIME_FALLINGSIGNLOCK_WRITE Deadtime falling sign is writeable HRTIM_TIMDEADTIME_FALLINGSIGNLOCK_READONLY Deadtime falling sign is read-only HRTIM Deadtime Prescaler Ratio HRTIM_TIMDEADTIME_PRESCALERRATIO_MUL8 fDTG = fHRTIM * 8 HRTIM_TIMDEADTIME_PRESCALERRATIO_MUL4 fDTG = fHRTIM * 4 HRTIM_TIMDEADTIME_PRESCALERRATIO_MUL2 fDTG = fHRTIM * 2 HRTIM_TIMDEADTIME_PRESCALERRATIO_DIV1 fDTG = fHRTIM HRTIM_TIMDEADTIME_PRESCALERRATIO_DIV2 fDTG = fHRTIM / 2 HRTIM_TIMDEADTIME_PRESCALERRATIO_DIV4 fDTG = fHRTIM / 4 HRTIM_TIMDEADTIME_PRESCALERRATIO_DIV8 fDTG = fHRTIM / 8 HRTIM_TIMDEADTIME_PRESCALERRATIO_DIV16 fDTG = fHRTIM / 16 HRTIM Deadtime Rising Lock 318/832 HRTIM_TIMDEADTIME_RISINGLOCK_WRITE Deadtime rising value and sign is writeable HRTIM_TIMDEADTIME_RISINGLOCK_READONLY Deadtime rising value and sign is DOCID026526 Rev 4 UM1786 read-only HRTIM Deadtime Rising Sign HRTIM_TIMDEADTIME_RISINGSIGN_POSITIVE Positive deadtime on rising edge HRTIM_TIMDEADTIME_RISINGSIGN_NEGATIVE Negative deadtime on rising edge HRTIM Deadtime Rising Sign Lock HRTIM_TIMDEADTIME_RISINGSIGNLOCK_WRITE Deadtime rising sign is writeable HRTIM_TIMDEADTIME_RISINGSIGNLOCK_READONLY Deadtime rising sign is readonly HRTIM DLL Calibration Rate HRTIM_SINGLE_CALIBRATION Non periodic DLL calibration HRTIM_CALIBRATIONRATE_7300 Periodic DLL calibration: T = 1048576 * tHRTIM (7.3 ms) HRTIM_CALIBRATIONRATE_910 Periodic DLL calibration: T = 131072 * tHRTIM (910 ms) HRTIM_CALIBRATIONRATE_114 Periodic DLL calibration: T = 16384 * tHRTIM (114 ms) HRTIM_CALIBRATIONRATE_14 Periodic DLL calibration: T = 2048 * tHRTIM (14 ms) HRTIM Exported Macros __HAL_HRTIM_RESET_HANDLE_STA TE Description: Reset HRTIM handle state. Parameters: __HANDLE__: HRTIM handle. Return value: __HAL_HRTIM_ENABLE None Description: Enables or disables the timer counter(s) Parameters: __HANDLE__: specifies the HRTIM Handle. __TIMERS__: timers to enable/disable This parameter can be any combinations of the following values: HRTIM_TIMERID_MASTER: Master timer identifier HRTIM_TIMERID_TIMER_A: Timer A identifier HRTIM_TIMERID_TIMER_B: Timer B identifier HRTIM_TIMERID_TIMER_C: Timer C identifier HRTIM_TIMERID_TIMER_D: Timer D identifier DOCID026526 Rev 4 319/832 UM1786 HRTIM_TIMERID_TIMER_E: Timer E identifier Return value: None HRTIM_TAOEN_MASK HRTIM_TBOEN_MASK HRTIM_TCOEN_MASK HRTIM_TDOEN_MASK HRTIM_TEOEN_MASK __HAL_HRTIM_DISABLE __HAL_HRTIM_ENABLE_IT Description: Enables or disables the specified HRTIM common interrupts. Parameters: __HANDLE__: specifies the HRTIM Handle. __INTERRUPT__: specifies the interrupt source to enable or disable. This parameter can be one of the following values: HRTIM_IT_FLT1: Fault 1 interrupt enable HRTIM_IT_FLT2: Fault 2 interrupt enable HRTIM_IT_FLT3: Fault 3 interrupt enable HRTIM_IT_FLT4: Fault 4 interrupt enable HRTIM_IT_FLT5: Fault 5 interrupt enable HRTIM_IT_SYSFLT: System Fault interrupt enable HRTIM_IT_DLLRDY: DLL ready interrupt enable HRTIM_IT_BMPER: Burst mode period interrupt enable Return value: __HAL_HRTIM_ENABLE_IT None Description: Enables or disables the specified HRTIM common interrupts. Parameters: 320/832 __HANDLE__: specifies the HRTIM Handle. __INTERRUPT__: specifies the interrupt source to enable or disable. This parameter DOCID026526 Rev 4 UM1786 can be one of the following values: HRTIM_IT_FLT1: Fault 1 interrupt enable HRTIM_IT_FLT2: Fault 2 interrupt enable HRTIM_IT_FLT3: Fault 3 interrupt enable HRTIM_IT_FLT4: Fault 4 interrupt enable HRTIM_IT_FLT5: Fault 5 interrupt enable HRTIM_IT_SYSFLT: System Fault interrupt enable HRTIM_IT_DLLRDY: DLL ready interrupt enable HRTIM_IT_BMPER: Burst mode period interrupt enable Return value: None __HAL_HRTIM_DISABLE_IT __HAL_HRTIM_DISABLE_IT __HAL_HRTIM_MASTER_ENABLE_IT Description: Enables or disables the specified HRTIM Master timer interrupts. Parameters: __HANDLE__: specifies the HRTIM Handle. __INTERRUPT__: specifies the interrupt source to enable or disable. This parameter can be one of the following values: HRTIM_MASTER_IT_MCMP1: Master compare 1 interrupt enable HRTIM_MASTER_IT_MCMP2: Master compare 2 interrupt enable HRTIM_MASTER_IT_MCMP3: Master compare 3 interrupt enable HRTIM_MASTER_IT_MCMP4: Master compare 4 interrupt enable HRTIM_MASTER_IT_MREP: Master Repetition interrupt enable HRTIM_MASTER_IT_SYNC: Synchronization input interrupt enable HRTIM_MASTER_IT_MUPD: Master update interrupt enable Return value: None __HAL_HRTIM_MASTER_DISABLE_IT __HAL_HRTIM_TIMER_ENABLE_IT Description: DOCID026526 Rev 4 321/832 UM1786 Enables or disables the specified HRTIM Timerx interrupts. Parameters: __HANDLE__: specifies the HRTIM Handle. __TIMER__: specified the timing unit (Timer A to E) __INTERRUPT__: specifies the interrupt source to enable or disable. This parameter can be one of the following values: HRTIM_TIM_IT_CMP1: Timer compare 1 interrupt enable HRTIM_TIM_IT_CMP2: Timer compare 2 interrupt enable HRTIM_TIM_IT_CMP3: Timer compare 3 interrupt enable HRTIM_TIM_IT_CMP4: Timer compare 4 interrupt enable HRTIM_TIM_IT_REP: Timer repetition interrupt enable HRTIM_TIM_IT_UPD: Timer update interrupt enable HRTIM_TIM_IT_CPT1: Timer capture 1 interrupt enable HRTIM_TIM_IT_CPT2: Timer capture 2 interrupt enable HRTIM_TIM_IT_SET1: Timer output 1 set interrupt enable HRTIM_TIM_IT_RST1: Timer output 1 reset interrupt enable HRTIM_TIM_IT_SET2: Timer output 2 set interrupt enable HRTIM_TIM_IT_RST2: Timer output 2 reset interrupt enable HRTIM_TIM_IT_RST: Timer reset interrupt enable HRTIM_TIM_IT_DLYPRT: Timer delay protection interrupt enable Return value: None __HAL_HRTIM_TIMER_DISABLE_IT __HAL_HRTIM_GET_ITSTATUS Description: Checks if the specified HRTIM common interrupt source is enabled or disabled. Parameters: 322/832 __HANDLE__: specifies the HRTIM Handle. __INTERRUPT__: specifies the interrupt source to check. This parameter can be one of the following values: DOCID026526 Rev 4 UM1786 HRTIM_IT_FLT1: Fault 1 interrupt enable HRTIM_IT_FLT2: Fault 2 interrupt enable HRTIM_IT_FLT3: Fault 3 enable HRTIM_IT_FLT4: Fault 4 enable HRTIM_IT_FLT5: Fault 5 enable HRTIM_IT_SYSFLT: System Fault interrupt enable HRTIM_IT_DLLRDY: DLL ready interrupt enable HRTIM_IT_BMPER: Burst mode period interrupt enable Return value: __HAL_HRTIM_MASTER_GET_ITSTA TUS The: new state of __INTERRUPT__ (TRUE or FALSE). Description: Checks if the specified HRTIM Master interrupt source is enabled or disabled. Parameters: __HANDLE__: specifies the HRTIM Handle. __INTERRUPT__: specifies the interrupt source to check. This parameter can be one of the following values: HRTIM_MASTER_IT_MCMP1: Master compare 1 interrupt enable HRTIM_MASTER_IT_MCMP2: Master compare 2 interrupt enable HRTIM_MASTER_IT_MCMP3: Master compare 3 interrupt enable HRTIM_MASTER_IT_MCMP4: Master compare 4 interrupt enable HRTIM_MASTER_IT_MREP: Master Repetition interrupt enable HRTIM_MASTER_IT_SYNC: Synchronization input interrupt enable HRTIM_MASTER_IT_MUPD: Master update interrupt enable Return value: __HAL_HRTIM_TIMER_GET_ITSTATU S The: new state of __INTERRUPT__ (TRUE or FALSE). Description: Checks if the specified HRTIM Timerx interrupt source is enabled or disabled. Parameters: __HANDLE__: specifies the HRTIM Handle. DOCID026526 Rev 4 323/832 UM1786 __TIMER__: specified the timing unit (Timer A to E) __INTERRUPT__: specifies the interrupt source to check. This parameter can be one of the following values: HRTIM_MASTER_IT_MCMP1: Master compare 1 interrupt enable HRTIM_MASTER_IT_MCMP2: Master compare 2 interrupt enable HRTIM_MASTER_IT_MCMP3: Master compare 3 interrupt enable HRTIM_MASTER_IT_MCMP4: Master compare 4 interrupt enable HRTIM_MASTER_IT_MREP: Master Repetition interrupt enable HRTIM_MASTER_IT_SYNC: Synchronization input interrupt enable HRTIM_MASTER_IT_MUPD: Master update interrupt enable HRTIM_TIM_IT_CMP1: Timer compare 1 interrupt enable HRTIM_TIM_IT_CMP2: Timer compare 2 interrupt enable HRTIM_TIM_IT_CMP3: Timer compare 3 interrupt enable HRTIM_TIM_IT_CMP4: Timer compare 4 interrupt enable HRTIM_TIM_IT_REP: Timer repetition interrupt enable HRTIM_TIM_IT_UPD: Timer update interrupt enable HRTIM_TIM_IT_CPT1: Timer capture 1 interrupt enable HRTIM_TIM_IT_CPT2: Timer capture 2 interrupt enable HRTIM_TIM_IT_SET1: Timer output 1 set interrupt enable HRTIM_TIM_IT_RST1: Timer output 1 reset interrupt enable HRTIM_TIM_IT_SET2: Timer output 2 set interrupt enable HRTIM_TIM_IT_RST2: Timer output 2 reset interrupt enable HRTIM_TIM_IT_RST: Timer reset interrupt enable HRTIM_TIM_IT_DLYPRT: Timer delay protection interrupt enable Return value: __HAL_HRTIM_CLEAR_IT Description: 324/832 The: new state of __INTERRUPT__ (TRUE or FALSE). Clears the specified HRTIM common DOCID026526 Rev 4 UM1786 pending flag. Parameters: __HANDLE__: specifies the HRTIM Handle. __INTERRUPT__: specifies the interrupt pending bit to clear. This parameter can be one of the following values: HRTIM_IT_FLT1: Fault 1 interrupt clear flag HRTIM_IT_FLT2: Fault 2 interrupt clear flag HRTIM_IT_FLT3: Fault 3 clear flag HRTIM_IT_FLT4: Fault 4 clear flag HRTIM_IT_FLT5: Fault 5 clear flag HRTIM_IT_SYSFLT: System Fault interrupt clear flag HRTIM_IT_DLLRDY: DLL ready interrupt clear flag HRTIM_IT_BMPER: Burst mode period interrupt clear flag Return value: __HAL_HRTIM_MASTER_CLEAR_IT None Description: Clears the specified HRTIM Master pending flag. Parameters: __HANDLE__: specifies the HRTIM Handle. __INTERRUPT__: specifies the interrupt pending bit to clear. This parameter can be one of the following values: HRTIM_MASTER_IT_MCMP1: Master compare 1 interrupt clear flag HRTIM_MASTER_IT_MCMP2: Master compare 2 interrupt clear flag HRTIM_MASTER_IT_MCMP3: Master compare 3 interrupt clear flag HRTIM_MASTER_IT_MCMP4: Master compare 4 interrupt clear flag HRTIM_MASTER_IT_MREP: Master Repetition interrupt clear flag HRTIM_MASTER_IT_SYNC: Synchronization input interrupt clear flag HRTIM_MASTER_IT_MUPD: Master update interrupt clear flag Return value: None DOCID026526 Rev 4 325/832 UM1786 __HAL_HRTIM_TIMER_CLEAR_IT Description: Clears the specified HRTIM Timerx pending flag. Parameters: __HANDLE__: specifies the HRTIM Handle. __TIMER__: specified the timing unit (Timer A to E) __INTERRUPT__: specifies the interrupt pending bit to clear. This parameter can be one of the following values: HRTIM_TIM_IT_CMP1: Timer compare 1 interrupt clear flag HRTIM_TIM_IT_CMP2: Timer compare 2 interrupt clear flag HRTIM_TIM_IT_CMP3: Timer compare 3 interrupt clear flag HRTIM_TIM_IT_CMP4: Timer compare 4 interrupt clear flag HRTIM_TIM_IT_REP: Timer repetition interrupt clear flag HRTIM_TIM_IT_UPD: Timer update interrupt clear flag HRTIM_TIM_IT_CPT1: Timer capture 1 interrupt clear flag HRTIM_TIM_IT_CPT2: Timer capture 2 interrupt clear flag HRTIM_TIM_IT_SET1: Timer output 1 set interrupt clear flag HRTIM_TIM_IT_RST1: Timer output 1 reset interrupt clear flag HRTIM_TIM_IT_SET2: Timer output 2 set interrupt clear flag HRTIM_TIM_IT_RST2: Timer output 2 reset interrupt clear flag HRTIM_TIM_IT_RST: Timer reset interrupt clear flag HRTIM_TIM_IT_DLYPRT: Timer output 1 delay protection interrupt clear flag Return value: __HAL_HRTIM_MASTER_ENABLE_D MA None Description: Enables or disables the specified HRTIM Master timer DMA requets. Parameters: 326/832 __HANDLE__: specifies the HRTIM Handle. __DMA__: specifies the DMA request to enable or disable. This parameter can be DOCID026526 Rev 4 UM1786 one of the following values: HRTIM_MASTER_DMA_MCMP1: Master compare 1 DMA resquest enable HRTIM_MASTER_DMA_MCMP2: Master compare 2 DMA resquest enable HRTIM_MASTER_DMA_MCMP3: Master compare 3 DMA resquest enable HRTIM_MASTER_DMA_MCMP4: Master compare 4 DMA resquest enable HRTIM_MASTER_DMA_MREP: Master Repetition DMA resquest enable HRTIM_MASTER_DMA_SYNC: Synchronization input DMA resquest enable HRTIM_MASTER_DMA_MUPD: Master update DMA resquest enable Return value: None __HAL_HRTIM_MASTER_DISABLE_D MA __HAL_HRTIM_TIMER_ENABLE_DMA Description: Enables or disables the specified HRTIM Timerx DMA requests. Parameters: __HANDLE__: specifies the HRTIM Handle. __TIMER__: specified the timing unit (Timer A to E) __DMA__: specifies the DMA request to enable or disable. This parameter can be one of the following values: HRTIM_TIM_DMA_CMP1: Timer compare 1 DMA resquest enable HRTIM_TIM_DMA_CMP2: Timer compare 2 DMA resquest enable HRTIM_TIM_DMA_CMP3: Timer compare 3 DMA resquest enable HRTIM_TIM_DMA_CMP4: Timer compare 4 DMA resquest enable HRTIM_TIM_DMA_REP: Timer repetition DMA resquest enable HRTIM_TIM_DMA_UPD: Timer update DMA resquest enable HRTIM_TIM_DMA_CPT1: Timer capture 1 DMA resquest enable HRTIM_TIM_DMA_CPT2: Timer DOCID026526 Rev 4 327/832 UM1786 capture 2 DMA resquest enable HRTIM_TIM_DMA_SET1: Timer output 1 set DMA resquest enable HRTIM_TIM_DMA_RST1: Timer output 1 reset DMA resquest enable HRTIM_TIM_DMA_SET2: Timer output 2 set DMA resquest enable HRTIM_TIM_DMA_RST2: Timer output 2 reset DMA resquest enable HRTIM_TIM_DMA_RST: Timer reset DMA resquest enable HRTIM_TIM_DMA_DLYPRT: Timer delay protection DMA resquest enable Return value: None __HAL_HRTIM_TIMER_DISABLE_DM A __HAL_HRTIM_GET_FLAG __HAL_HRTIM_CLEAR_FLAG __HAL_HRTIM_MASTER_GET_FLAG __HAL_HRTIM_MASTER_CLEAR_FLA G __HAL_HRTIM_TIMER_GET_FLAG __HAL_HRTIM_TIMER_CLEAR_FLAG __HAL_HRTIM_SETCOUNTER Description: Sets the HRTIM timer Counter Register value on runtime. Parameters: __HANDLE__: HRTIM Handle. __TIMER__: HRTIM timer This parameter can be one of the following values: 0x5 for master timer 0x0 to 0x4 for timers A to E __COUNTER__: specifies the Counter Register new value. Return value: __HAL_HRTIM_GETCOUNTER None Description: Gets the HRTIM timer Counter Register value on runtime. Parameters: 328/832 __HANDLE__: HRTIM Handle. __TIMER__: HRTIM timer This parameter can be one of the following values: 0x5 for master timer DOCID026526 Rev 4 UM1786 0x0 to 0x4 for timers A to E Return value: __HAL_HRTIM_SETPERIOD HRTIM: timer Counter Register value Description: Sets the HRTIM timer Period value on runtime. Parameters: __HANDLE__: HRTIM Handle. __TIMER__: HRTIM timer This parameter can be one of the following values: 0x5 for master timer 0x0 to 0x4 for timers A to E __PERIOD__: specifies the Period Register new value. Return value: __HAL_HRTIM_GETPERIOD None Description: Gets the HRTIM timer Period Register value on runtime. Parameters: __HANDLE__: HRTIM Handle. __TIMER__: HRTIM timer This parameter can be one of the following values: 0x5 for master timer 0x0 to 0x4 for timers A to E Return value: __HAL_HRTIM_SETCLOCKPRESCAL ER timer: Period Register Description: Sets the HRTIM timer clock prescaler value on runtime. Parameters: __HANDLE__: HRTIM Handle. __TIMER__: HRTIM timer This parameter can be one of the following values: 0x5 for master timer 0x0 to 0x4 for timers A to E __PRESCALER__: specifies the clock prescaler new value. This parameter can be one of the following values: HRTIM_PRESCALERRATIO_MUL32: fHRCK: 4.608 GHz - Resolution: 217 ps - Min PWM frequency: 70.3 kHz (fHRTIM=144MHz) HRTIM_PRESCALERRATIO_MUL16: fHRCK: 2.304 GHz - Resolution: 434 DOCID026526 Rev 4 329/832 UM1786 ps - Min PWM frequency: 35.1 KHz (fHRTIM=144MHz) HRTIM_PRESCALERRATIO_MUL8: fHRCK: 1.152 GHz - Resolution: 868 ps - Min PWM frequency: 17.6 kHz (fHRTIM=144MHz) HRTIM_PRESCALERRATIO_MUL4: fHRCK: 576 MHz - Resolution: 1.73 ns - Min PWM frequency: 8.8 kHz (fHRTIM=144MHz) HRTIM_PRESCALERRATIO_MUL2: fHRCK: 288 MHz - Resolution: 3.47 ns - Min PWM frequency: 4.4 kHz (fHRTIM=144MHz) HRTIM_PRESCALERRATIO_DIV1: fHRCK: 144 MHz - Resolution: 6.95 ns - Min PWM frequency: 2.2 kHz (fHRTIM=144MHz) HRTIM_PRESCALERRATIO_DIV2: fHRCK: 72 MHz - Resolution: 13.88 ns- Min PWM frequency: 1.1 kHz (fHRTIM=144MHz) HRTIM_PRESCALERRATIO_DIV4: fHRCK: 36 MHz - Resolution: 27.7 nsMin PWM frequency: 550Hz (fHRTIM=144MHz) Return value: __HAL_HRTIM_GETCLOCKPRESCAL ER None Description: Gets the HRTIM timer clock prescaler value on runtime. Parameters: __HANDLE__: HRTIM Handle. __TIMER__: HRTIM timer This parameter can be one of the following values: 0x5 for master timer 0x0 to 0x4 for timers A to E Return value: __HAL_HRTIM_SETCOMPARE timer: clock prescaler value Description: Sets the HRTIM timer Compare Register value on runtime. Parameters: 330/832 __HANDLE__: HRTIM Handle. __TIMER__: HRTIM timer This parameter can be one of the following values: 0x0 to 0x4 for timers A to E __COMPAREUNIT__: timer compare unit DOCID026526 Rev 4 UM1786 This parameter can be one of the following values: HRTIM_COMPAREUNIT_1: Compare unit 1 HRTIM_COMPAREUNIT_2: Compare unit 2 HRTIM_COMPAREUNIT_3: Compare unit 3 HRTIM_COMPAREUNIT_4: Compare unit 4 __COMPARE__: specifies the Compare new value. Return value: __HAL_HRTIM_GETCOMPARE None Description: Gets the HRTIM timer Compare Register value on runtime. Parameters: __HANDLE__: HRTIM Handle. __TIMER__: HRTIM timer This parameter can be one of the following values: 0x0 to 0x4 for timers A to E __COMPAREUNIT__: timer compare unit This parameter can be one of the following values: HRTIM_COMPAREUNIT_1: Compare unit 1 HRTIM_COMPAREUNIT_2: Compare unit 2 HRTIM_COMPAREUNIT_3: Compare unit 3 HRTIM_COMPAREUNIT_4: Compare unit 4 Return value: Compare: value HRTIM External Event Channels HRTIM_EVENT_NONE Undefined event channel HRTIM_EVENT_1 External event channel 1 identifier HRTIM_EVENT_2 External event channel 2 identifier HRTIM_EVENT_3 External event channel 3 identifier HRTIM_EVENT_4 External event channel 4 identifier HRTIM_EVENT_5 External event channel 5 identifier HRTIM_EVENT_6 External event channel 6 identifier HRTIM_EVENT_7 External event channel 7 identifier HRTIM_EVENT_8 External event channel 8 identifier DOCID026526 Rev 4 331/832 UM1786 HRTIM_EVENT_9 External event channel 9 identifier HRTIM_EVENT_10 External event channel 10 identifier HRTIM External Event Fast Mode HRTIM_EVENTFASTMODE_DISABLE External Event is acting asynchronously on outputs (low latency mode) HRTIM_EVENTFASTMODE_ENABLE External Event is re-synchronized by the HRTIM logic before acting on outputs HRTIM External Event Filter HRTIM_EVENTFILTER_NONE Filter disabled HRTIM_EVENTFILTER_1 fSAMPLING= fHRTIM, N=2 HRTIM_EVENTFILTER_2 fSAMPLING= fHRTIM, N=4 HRTIM_EVENTFILTER_3 fSAMPLING= fHRTIM, N=8 HRTIM_EVENTFILTER_4 fSAMPLING= fEEVS/2, N=6 HRTIM_EVENTFILTER_5 fSAMPLING= fEEVS/2, N=8 HRTIM_EVENTFILTER_6 fSAMPLING= fEEVS/4, N=6 HRTIM_EVENTFILTER_7 fSAMPLING= fEEVS/4, N=8 HRTIM_EVENTFILTER_8 fSAMPLING= fEEVS/8, N=6 HRTIM_EVENTFILTER_9 fSAMPLING= fEEVS/8, N=8 HRTIM_EVENTFILTER_10 fSAMPLING= fEEVS/16, N=5 HRTIM_EVENTFILTER_11 fSAMPLING= fEEVS/16, N=6 HRTIM_EVENTFILTER_12 fSAMPLING= fEEVS/16, N=8 HRTIM_EVENTFILTER_13 fSAMPLING= fEEVS/32, N=5 HRTIM_EVENTFILTER_14 fSAMPLING= fEEVS/32, N=6 HRTIM_EVENTFILTER_15 fSAMPLING= fEEVS/32, N=8 HRTIM External Event Polarity HRTIM_EVENTPOLARITY_HIGH External event is active high HRTIM_EVENTPOLARITY_LOW External event is active low HRTIM External Event Prescaler HRTIM_EVENTPRESCALER_DIV1 fEEVS=fHRTIM HRTIM_EVENTPRESCALER_DIV2 fEEVS=fHRTIM / 2 HRTIM_EVENTPRESCALER_DIV4 fEEVS=fHRTIM / 4 HRTIM_EVENTPRESCALER_DIV8 fEEVS=fHRTIM / 8 HRTIM External Event Sensitivity 332/832 HRTIM_EVENTSENSITIVITY_LEVEL External event is active on level HRTIM_EVENTSENSITIVITY_RISINGEDGE External event is active on Rising edge HRTIM_EVENTSENSITIVITY_FALLINGEDGE External event is active on Falling edge HRTIM_EVENTSENSITIVITY_BOTHEDGES External event is active on Rising and DOCID026526 Rev 4 UM1786 Falling edges HRTIM External Event Sources HRTIM_EVENTSRC_1 External event source 1 HRTIM_EVENTSRC_2 External event source 2 HRTIM_EVENTSRC_3 External event source 3 HRTIM_EVENTSRC_4 External event source 4 HRTIM External Fault Prescaler HRTIM_FAULTPRESCALER_DIV1 fFLTS=fHRTIM HRTIM_FAULTPRESCALER_DIV2 fFLTS=fHRTIM / 2 HRTIM_FAULTPRESCALER_DIV4 fFLTS=fHRTIM / 4 HRTIM_FAULTPRESCALER_DIV8 fFLTS=fHRTIM / 8 HRTIM Fault Channel HRTIM_FAULT_1 Fault channel 1 identifier HRTIM_FAULT_2 Fault channel 2 identifier HRTIM_FAULT_3 Fault channel 3 identifier HRTIM_FAULT_4 Fault channel 4 identifier HRTIM_FAULT_5 Fault channel 5 identifier HRTIM Fault Filter HRTIM_FAULTFILTER_NONE Filter disabled HRTIM_FAULTFILTER_1 fSAMPLING= fHRTIM, N=2 HRTIM_FAULTFILTER_2 fSAMPLING= fHRTIM, N=4 HRTIM_FAULTFILTER_3 fSAMPLING= fHRTIM, N=8 HRTIM_FAULTFILTER_4 fSAMPLING= fFLTS/2, N=6 HRTIM_FAULTFILTER_5 fSAMPLING= fFLTS/2, N=8 HRTIM_FAULTFILTER_6 fSAMPLING= fFLTS/4, N=6 HRTIM_FAULTFILTER_7 fSAMPLING= fFLTS/4, N=8 HRTIM_FAULTFILTER_8 fSAMPLING= fFLTS/8, N=6 HRTIM_FAULTFILTER_9 fSAMPLING= fFLTS/8, N=8 HRTIM_FAULTFILTER_10 fSAMPLING= fFLTS/16, N=5 HRTIM_FAULTFILTER_11 fSAMPLING= fFLTS/16, N=6 HRTIM_FAULTFILTER_12 fSAMPLING= fFLTS/16, N=8 HRTIM_FAULTFILTER_13 fSAMPLING= fFLTS/32, N=5 HRTIM_FAULTFILTER_14 fSAMPLING= fFLTS/32, N=6 HRTIM_FAULTFILTER_15 fSAMPLING= fFLTS/32, N=8 HRTIM Fault Lock HRTIM_FAULTLOCK_READWRITE Fault settings bits are read/write DOCID026526 Rev 4 333/832 UM1786 HRTIM_FAULTLOCK_READONLY Fault settings bits are read only HRTIM Fault Mode Control HRTIM_FAULTMODECTL_DISABLED Fault channel is disabled HRTIM_FAULTMODECTL_ENABLED Fault channel is enabled IS_HRTIM_FAULTMODECTL HRTIM Fault Polarity HRTIM_FAULTPOLARITY_LOW Fault input is active low HRTIM_FAULTPOLARITY_HIGH Fault input is active high HRTIM Fault Sources HRTIM_FAULTSOURCE_DIGITALINPUT Fault input is FLT input pin HRTIM_FAULTSOURCE_INTERNAL Fault input is FLT_Int signal (e.g. internal comparator) HRTIM Half Mode Enable HRTIM_HALFMODE_DISABLED Half mode is disabled HRTIM_HALFMODE_ENABLED Half mode is enabled HRTIM Idle Push Pull Status HRTIM_PUSHPULL_IDLESTATUS_OUTPUT1 Protection occurred when the output 1 was active and output 2 forced inactive HRTIM_PUSHPULL_IDLESTATUS_OUTPUT2 Protection occurred when the output 2 was active and output 1 forced inactive HRTIM Master DMA Request Enable HRTIM_MASTER_DMA_NONE No DMA request enable HRTIM_MASTER_DMA_MCMP1 Master compare 1 DMA request enable HRTIM_MASTER_DMA_MCMP2 Master compare 2 DMA request enable HRTIM_MASTER_DMA_MCMP3 Master compare 3 DMA request enable HRTIM_MASTER_DMA_MCMP4 Master compare 4 DMA request enable HRTIM_MASTER_DMA_MREP Master Repetition DMA request enable HRTIM_MASTER_DMA_SYNC Synchronization input DMA request enable HRTIM_MASTER_DMA_MUPD Master update DMA request enable HRTIM Master Interrupt Enable 334/832 HRTIM_MASTER_IT_NONE No interrupt enabled HRTIM_MASTER_IT_MCMP1 Master compare 1 interrupt enable HRTIM_MASTER_IT_MCMP2 Master compare 2 interrupt enable HRTIM_MASTER_IT_MCMP3 Master compare 3 interrupt enable HRTIM_MASTER_IT_MCMP4 Master compare 4 interrupt enable HRTIM_MASTER_IT_MREP Master Repetition interrupt enable HRTIM_MASTER_IT_SYNC Synchronization input interrupt enable DOCID026526 Rev 4 UM1786 HRTIM_MASTER_IT_MUPD Master update interrupt enable HRTIM Master Interrupt Flag HRTIM_MASTER_FLAG_MCMP1 Master compare 1 interrupt flag HRTIM_MASTER_FLAG_MCMP2 Master compare 2 interrupt flag HRTIM_MASTER_FLAG_MCMP3 Master compare 3 interrupt flag HRTIM_MASTER_FLAG_MCMP4 Master compare 4 interrupt flag HRTIM_MASTER_FLAG_MREP Master Repetition interrupt flag HRTIM_MASTER_FLAG_SYNC Synchronization input interrupt flag HRTIM_MASTER_FLAG_MUPD Master update interrupt flag HRTIM Max Timer MAX_HRTIM_TIMER HRTIM Output Burst Mode Entry Delayed HRTIM_OUTPUTBURSTMODEENTRY_REGULAR The programmed Idle state is applied immediately to the Output HRTIM_OUTPUTBURSTMODEENTRY_DELAYED Deadtime is inserted on output before entering the idle mode HRTIM Output Chopper Mode Enable HRTIM_OUTPUTCHOPPERMODE_DISABLED Output signal is not altered HRTIM_OUTPUTCHOPPERMODE_ENABLED Output signal is chopped by a carrier signal HRTIM Output FAULT Level HRTIM_OUTPUTFAULTLEVEL_NONE The output is not affected by the fault input HRTIM_OUTPUTFAULTLEVEL_ACTIVE Output at active level when in FAULT state HRTIM_OUTPUTFAULTLEVEL_INACTIVE Output at inactive level when in FAULT state HRTIM_OUTPUTFAULTLEVEL_HIGHZ Output is tri-stated when in FAULT state HRTIM Output IDLE Level HRTIM_OUTPUTIDLELEVEL_INACTIVE Output at inactive level when in IDLE state HRTIM_OUTPUTIDLELEVEL_ACTIVE Output at active level when in IDLE state HRTIM Output Idle Mode HRTIM_OUTPUTIDLEMODE_NONE The output is not affected by the burst mode operation HRTIM_OUTPUTIDLEMODE_IDLE The output is in idle state when requested by the burst mode controller HRTIM Output Level HRTIM_OUTPUTLEVEL_ACTIVE Forces the output to its active state HRTIM_OUTPUTLEVEL_INACTIVE Forces the output to its inactive state IS_HRTIM_OUTPUTLEVEL HRTIM Output Polarity DOCID026526 Rev 4 335/832 UM1786 HRTIM_OUTPUTPOLARITY_HIGH Output is acitve HIGH HRTIM_OUTPUTPOLARITY_LOW Output is active LOW HRTIM Output Reset Source 336/832 HRTIM_OUTPUTRESET_NONE Reset the output reset crossbar HRTIM_OUTPUTRESET_RESYNC Timer reset event coming solely from software or SYNC input forces the output to its inactive state HRTIM_OUTPUTRESET_TIMPER Timer period event forces the output to its inactive state HRTIM_OUTPUTRESET_TIMCMP1 Timer compare 1 event forces the output to its inactive state HRTIM_OUTPUTRESET_TIMCMP2 Timer compare 2 event forces the output to its inactive state HRTIM_OUTPUTRESET_TIMCMP3 Timer compare 3 event forces the output to its inactive state HRTIM_OUTPUTRESET_TIMCMP4 Timer compare 4 event forces the output to its inactive state HRTIM_OUTPUTRESET_MASTERPER The master timer period event forces the output to its inactive state HRTIM_OUTPUTRESET_MASTERCMP1 Master Timer compare 1 event forces the output to its inactive state HRTIM_OUTPUTRESET_MASTERCMP2 Master Timer compare 2 event forces the output to its inactive state HRTIM_OUTPUTRESET_MASTERCMP3 Master Timer compare 3 event forces the output to its inactive state HRTIM_OUTPUTRESET_MASTERCMP4 Master Timer compare 4 event forces the output to its inactive state HRTIM_OUTPUTRESET_TIMEV_1 Timer event 1 forces the output to its inactive state HRTIM_OUTPUTRESET_TIMEV_2 Timer event 2 forces the output to its inactive state HRTIM_OUTPUTRESET_TIMEV_3 Timer event 3 forces the output to its inactive state HRTIM_OUTPUTRESET_TIMEV_4 Timer event 4 forces the output to its inactive state HRTIM_OUTPUTRESET_TIMEV_5 Timer event 5 forces the output to its inactive state HRTIM_OUTPUTRESET_TIMEV_6 Timer event 6 forces the output to its inactive state HRTIM_OUTPUTRESET_TIMEV_7 Timer event 7 forces the output to its inactive state HRTIM_OUTPUTRESET_TIMEV_8 Timer event 8 forces the output to its inactive state DOCID026526 Rev 4 UM1786 HRTIM_OUTPUTRESET_TIMEV_9 Timer event 9 forces the output to its inactive state HRTIM_OUTPUTRESET_EEV_1 External event 1 forces the output to its inactive state HRTIM_OUTPUTRESET_EEV_2 External event 2 forces the output to its inactive state HRTIM_OUTPUTRESET_EEV_3 External event 3 forces the output to its inactive state HRTIM_OUTPUTRESET_EEV_4 External event 4 forces the output to its inactive state HRTIM_OUTPUTRESET_EEV_5 External event 5 forces the output to its inactive state HRTIM_OUTPUTRESET_EEV_6 External event 6 forces the output to its inactive state HRTIM_OUTPUTRESET_EEV_7 External event 7 forces the output to its inactive state HRTIM_OUTPUTRESET_EEV_8 External event 8 forces the output to its inactive state HRTIM_OUTPUTRESET_EEV_9 External event 9 forces the output to its inactive state HRTIM_OUTPUTRESET_EEV_10 External event 10 forces the output to its inactive state HRTIM_OUTPUTRESET_UPDATE Timer register update event forces the output to its inactive state HRTIM Output Set Source HRTIM_OUTPUTSET_NONE Reset the output set crossbar HRTIM_OUTPUTSET_RESYNC Timer reset event coming solely from software or SYNC input forces the output to its active state HRTIM_OUTPUTSET_TIMPER Timer period event forces the output to its active state HRTIM_OUTPUTSET_TIMCMP1 Timer compare 1 event forces the output to its active state HRTIM_OUTPUTSET_TIMCMP2 Timer compare 2 event forces the output to its active state HRTIM_OUTPUTSET_TIMCMP3 Timer compare 3 event forces the output to its active state HRTIM_OUTPUTSET_TIMCMP4 Timer compare 4 event forces the output to its active state HRTIM_OUTPUTSET_MASTERPER The master timer period event forces the output to its active state HRTIM_OUTPUTSET_MASTERCMP1 Master Timer compare 1 event forces the output to its active state HRTIM_OUTPUTSET_MASTERCMP2 Master Timer compare 2 event forces the output to its active state DOCID026526 Rev 4 337/832 HRTIM_OUTPUTSET_MASTERCMP3 UM1786 Master Timer compare 3 event forces the output to its active state HRTIM_OUTPUTSET_MASTERCMP4 Master Timer compare 4 event forces the output to its active state HRTIM_OUTPUTSET_TIMEV_1 Timer event 1 forces the output to its active state HRTIM_OUTPUTSET_TIMEV_2 Timer event 2 forces the output to its active state HRTIM_OUTPUTSET_TIMEV_3 Timer event 3 forces the output to its active state HRTIM_OUTPUTSET_TIMEV_4 Timer event 4 forces the output to its active state HRTIM_OUTPUTSET_TIMEV_5 Timer event 5 forces the output to its active state HRTIM_OUTPUTSET_TIMEV_6 Timer event 6 forces the output to its active state HRTIM_OUTPUTSET_TIMEV_7 Timer event 7 forces the output to its active state HRTIM_OUTPUTSET_TIMEV_8 Timer event 8 forces the output to its active state HRTIM_OUTPUTSET_TIMEV_9 Timer event 9 forces the output to its active state HRTIM_OUTPUTSET_EEV_1 External event 1 forces the output to its active state HRTIM_OUTPUTSET_EEV_2 External event 2 forces the output to its active state HRTIM_OUTPUTSET_EEV_3 External event 3 forces the output to its active state HRTIM_OUTPUTSET_EEV_4 External event 4 forces the output to its active state HRTIM_OUTPUTSET_EEV_5 External event 5 forces the output to its active state HRTIM_OUTPUTSET_EEV_6 External event 6 forces the output to its active state HRTIM_OUTPUTSET_EEV_7 External event 7 forces the output to its active state HRTIM_OUTPUTSET_EEV_8 External event 8 forces the output to its active state HRTIM_OUTPUTSET_EEV_9 External event 9 forces the output to its active state HRTIM_OUTPUTSET_EEV_10 External event 10 forces the output to its active state HRTIM_OUTPUTSET_UPDATE Timer register update event forces the output to its active state HRTIM Output State 338/832 HRTIM_OUTPUTSTATE_IDLE Main operating mode, where the output can take the active or inactive level as programmed in the crossbar unit HRTIM_OUTPUTSTATE_RUN Default operating state (e.g. after an HRTIM reset, when the outputs are disabled by software or during a burst mode operation DOCID026526 Rev 4 UM1786 HRTIM_OUTPUTSTATE_FAULT Safety state, entered in case of a shut-down request on FAULTx inputs HRTIM Prescaler Ratio HRTIM_PRESCALERRATIO_MUL32 fHRCK: fHRTIM x 32 = 4.608 GHz - Resolution: 217 ps - Min PWM frequency: 70.3 kHz (fHRTIM=144MHz) HRTIM_PRESCALERRATIO_MUL16 fHRCK: fHRTIM x 16 = 2.304 GHz - Resolution: 434 ps - Min PWM frequency: 35.1 KHz (fHRTIM=144MHz) HRTIM_PRESCALERRATIO_MUL8 fHRCK: fHRTIM x 8 = 1.152 GHz - Resolution: 868 ps - Min PWM frequency: 17.6 kHz (fHRTIM=144MHz) HRTIM_PRESCALERRATIO_MUL4 fHRCK: fHRTIM x 4 = 576 MHz - Resolution: 1.73 ns - Min PWM frequency: 8.8 kHz (fHRTIM=144MHz) HRTIM_PRESCALERRATIO_MUL2 fHRCK: fHRTIM x 2 = 288 MHz - Resolution: 3.47 ns - Min PWM frequency: 4.4 kHz (fHRTIM=144MHz) HRTIM_PRESCALERRATIO_DIV1 fHRCK: fHRTIM = 144 MHz - Resolution: 6.95 ns Min PWM frequency: 2.2 kHz (fHRTIM=144MHz) HRTIM_PRESCALERRATIO_DIV2 fHRCK: fHRTIM / 2 = 72 MHz - Resolution: 13.88 ns- Min PWM frequency: 1.1 kHz (fHRTIM=144MHz) HRTIM_PRESCALERRATIO_DIV4 fHRCK: fHRTIM / 4 = 36 MHz - Resolution: 27.7 ns- Min PWM frequency: 550Hz (fHRTIM=144MHz) HRTIM Register Preload Enable HRTIM_PRELOAD_DISABLED Preload disabled: the write access is directly done into the active register HRTIM_PRELOAD_ENABLED Preload enabled: the write access is done into the preload register HRTIM Reset On Sync Input Event HRTIM_SYNCRESET_DISABLED Synchronization input event has effect on the timer HRTIM_SYNCRESET_ENABLED Synchronization input event resets the timer HRTIM Simple OC Mode HRTIM_BASICOCMODE_TOGGLE Output toggles when the timer counter reaches the compare value HRTIM_BASICOCMODE_INACTIVE Output forced to active level when the timer counter reaches the compare value HRTIM_BASICOCMODE_ACTIVE Output forced to inactive level when the timer counter reaches the compare value IS_HRTIM_BASICOCMODE HRTIM Software Timer Reset HRTIM_TIMERRESET_MASTER Resets the master timer counter DOCID026526 Rev 4 339/832 UM1786 HRTIM_TIMERRESET_TIMER_A Resets the timer A counter HRTIM_TIMERRESET_TIMER_B Resets the timer B counter HRTIM_TIMERRESET_TIMER_C Resets the timer C counter HRTIM_TIMERRESET_TIMER_D Resets the timer D counter HRTIM_TIMERRESET_TIMER_E Resets the timer E counter HRTIM Software Timer Update HRTIM_TIMERUPDATE_MASTER Forces an immediate transfer from the preload to the active register in the master timer HRTIM_TIMERUPDATE_A Forces an immediate transfer from the preload to the active register in the timer A HRTIM_TIMERUPDATE_B Forces an immediate transfer from the preload to the active register in the timer B HRTIM_TIMERUPDATE_C Forces an immediate transfer from the preload to the active register in the timer C HRTIM_TIMERUPDATE_D Forces an immediate transfer from the preload to the active register in the timer D HRTIM_TIMERUPDATE_E Forces an immediate transfer from the preload to the active register in the timer E HRTIM Start On Sync Input Event HRTIM_SYNCSTART_DISABLED Synchronization input event has effect on the timer HRTIM_SYNCSTART_ENABLED Synchronization input event starts the timer HRTIM Synchronization Input Source HRTIM_SYNCINPUTSOURCE_NONE disabled. HRTIM is not synchronized and runs in standalone mode HRTIM_SYNCINPUTSOURCE_INTERNALEVENT The HRTIM is synchronized with the on-chip timer HRTIM_SYNCINPUTSOURCE_EXTERNALEVENT A positive pulse on SYNCIN input triggers the HRTIM HRTIM Synchronization Options HRTIM_SYNCOPTION_NONE HRTIM instance doesn't handle external synchronization signals (SYNCIN, SYNCOUT) HRTIM_SYNCOPTION_MASTER HRTIM instance acts as a MASTER, i.e. generates external synchronization output (SYNCOUT) HRTIM_SYNCOPTION_SLAVE HRTIM instance acts as a SLAVE, i.e. it is synchronized by external sources (SYNCIN) HRTIM Synchronization Output Polarity 340/832 HRTIM_SYNCOUTPUTPOLARITY_NONE Synchronization output event is disabled HRTIM_SYNCOUTPUTPOLARITY_POSITIVE SCOUT pin has a low idle level and issues a positive pulse of 16 fHRTIM clock cycles length for the synchronization DOCID026526 Rev 4 UM1786 HRTIM_SYNCOUTPUTPOLARITY_NEGATIVE SCOUT pin has a high idle level and issues a negative pulse of 16 fHRTIM clock cycles length for the synchronization HRTIM Synchronization Output Source HRTIM_SYNCOUTPUTSOURCE_MASTER_START A pulse is sent on the SYNCOUT output upon master timer start event HRTIM_SYNCOUTPUTSOURCE_MASTER_CMP1 A pulse is sent on the SYNCOUT output upon master timer compare 1 event HRTIM_SYNCOUTPUTSOURCE_TIMA_START A pulse is sent on the SYNCOUT output upon timer A start or reset events HRTIM_SYNCOUTPUTSOURCE_TIMA_CMP1 A pulse is sent on the SYNCOUT output upon timer A compare 1 event HRTIM Timer Burst Mode HRTIM_TIMERBURSTMODE_MAINTAINCLOCK Timer counter clock is maintained and the timer operates normally HRTIM_TIMERBURSTMODE_RESETCOUNTER Timer counter clock is stopped and the counter is reset HRTIM Timer Deadtime Insertion HRTIM_TIMDEADTIMEINSERTION_DISABLED Output 1 and output 2 signals are independent HRTIM_TIMDEADTIMEINSERTION_ENABLED Deadtime is inserted between output 1 and output 2 HRTIM Timer Delayed Protection Mode HRTIM_TIMER_A_B_C_DELAYEDPROTECTION _DISABLED No action HRTIM_TIMER_A_B_C_DELAYEDPROTECTION _DELAYEDOUT1_EEV6 Timers A, B, C: Output 1 delayed Idle on external Event 6 HRTIM_TIMER_A_B_C_DELAYEDPROTECTION _DELAYEDOUT2_EEV6 Timers A, B, C: Output 2 delayed Idle on external Event 6 HRTIM_TIMER_A_B_C_DELAYEDPROTECTION _DELAYEDBOTH_EEV6 Timers A, B, C: Output 1 and output 2 delayed Idle on external Event 6 HRTIM_TIMER_A_B_C_DELAYEDPROTECTION _BALANCED_EEV6 Timers A, B, C: Balanced Idle on external Event 6 HRTIM_TIMER_A_B_C_DELAYEDPROTECTION _DELAYEDOUT1_DEEV7 Timers A, B, C: Output 1 delayed Idle on external Event 7 HRTIM_TIMER_A_B_C_DELAYEDPROTECTION _DELAYEDOUT2_DEEV7 Timers A, B, C: Output 2 delayed Idle on external Event 7 HRTIM_TIMER_A_B_C_DELAYEDPROTECTION _DELAYEDBOTH_EEV7 Timers A, B, C: Output 1 and output2 delayed Idle on external Event 7 HRTIM_TIMER_A_B_C_DELAYEDPROTECTION Timers A, B, C: Balanced Idle on DOCID026526 Rev 4 341/832 UM1786 _BALANCED_EEV7 external Event 7 HRTIM_TIMER_D_E_DELAYEDPROTECTION_D ISABLED No action HRTIM_TIMER_D_E_DELAYEDPROTECTION_D ELAYEDOUT1_EEV8 Timers D, E: Output 1 delayed Idle on external Event 6 HRTIM_TIMER_D_E_DELAYEDPROTECTION_D ELAYEDOUT2_EEV8 Timers D, E: Output 2 delayed Idle on external Event 6 HRTIM_TIMER_D_E_DELAYEDPROTECTION_D ELAYEDBOTH_EEV8 Timers D, E: Output 1 and output 2 delayed Idle on external Event 6 HRTIM_TIMER_D_E_DELAYEDPROTECTION_B ALANCED_EEV8 Timers D, E: Balanced Idle on external Event 6 HRTIM_TIMER_D_E_DELAYEDPROTECTION_D ELAYEDOUT1_DEEV9 Timers D, E: Output 1 delayed Idle on external Event 7 HRTIM_TIMER_D_E_DELAYEDPROTECTION_D ELAYEDOUT2_DEEV9 Timers D, E: Output 2 delayed Idle on external Event 7 HRTIM_TIMER_D_E_DELAYEDPROTECTION_D ELAYEDBOTH_EEV9 Timers D, E: Output 1 and output2 delayed Idle on external Event 7 HRTIM_TIMER_D_E_DELAYEDPROTECTION_B ALANCED_EEV9 Timers D, E: Balanced Idle on external Event 7 HRTIM Timer External Event Filter HRTIM_TIMEVENTFILTER_NONE 342/832 HRTIM_TIMEVENTFILTER_BLANKINGCMP1 Blanking from counter reset/roll-over to Compare 1 HRTIM_TIMEVENTFILTER_BLANKINGCMP2 Blanking from counter reset/roll-over to Compare 2 HRTIM_TIMEVENTFILTER_BLANKINGCMP3 Blanking from counter reset/roll-over to Compare 3 HRTIM_TIMEVENTFILTER_BLANKINGCMP4 Blanking from counter reset/roll-over to Compare 4 HRTIM_TIMEVENTFILTER_BLANKINGFLTR1 Blanking from another timing unit: TIMFLTR1 source HRTIM_TIMEVENTFILTER_BLANKINGFLTR2 Blanking from another timing unit: TIMFLTR2 source HRTIM_TIMEVENTFILTER_BLANKINGFLTR3 Blanking from another timing unit: TIMFLTR3 source HRTIM_TIMEVENTFILTER_BLANKINGFLTR4 Blanking from another timing unit: TIMFLTR4 source HRTIM_TIMEVENTFILTER_BLANKINGFLTR5 Blanking from another timing unit: TIMFLTR5 source HRTIM_TIMEVENTFILTER_BLANKINGFLTR6 Blanking from another timing unit: TIMFLTR6 source HRTIM_TIMEVENTFILTER_BLANKINGFLTR7 Blanking from another timing unit: TIMFLTR7 source DOCID026526 Rev 4 UM1786 HRTIM_TIMEVENTFILTER_BLANKINGFLTR8 Blanking from another timing unit: TIMFLTR8 source HRTIM_TIMEVENTFILTER_WINDOWINGCMP2 Windowing from counter reset/roll-over to Compare 2 HRTIM_TIMEVENTFILTER_WINDOWINGCMP3 Windowing from counter reset/roll-over to Compare 3 HRTIM_TIMEVENTFILTER_WINDOWINGTIM Windowing from another timing unit: TIMWIN source HRTIM Timer External Event Latch HRTIM_TIMEVENTLATCH_DISABLED Event is ignored if it happens during a blank, or passed through during a window HRTIM_TIMEVENTLATCH_ENABLED Event is latched and delayed till the end of the blanking or windowing period HRTIM Timer Fault Enabling HRTIM_TIMFAULTENABLE_NONE No fault enabled HRTIM_TIMFAULTENABLE_FAULT1 Fault 1 enabled HRTIM_TIMFAULTENABLE_FAULT2 Fault 2 enabled HRTIM_TIMFAULTENABLE_FAULT3 Fault 3 enabled HRTIM_TIMFAULTENABLE_FAULT4 Fault 4 enabled HRTIM_TIMFAULTENABLE_FAULT5 Fault 5 enabled HRTIM Timer Fault Lock HRTIM_TIMFAULTLOCK_READWRITE Timer fault enabling bits are read/write HRTIM_TIMFAULTLOCK_READONLY Timer fault enabling bits are read only HRTIM Timer identifier HRTIM_TIMERID_MASTER Master identifier HRTIM_TIMERID_TIMER_A Timer A identifier HRTIM_TIMERID_TIMER_B Timer B identifier HRTIM_TIMERID_TIMER_C Timer C identifier HRTIM_TIMERID_TIMER_D Timer D identifier HRTIM_TIMERID_TIMER_E Timer E identifier HRTIM Timer Index HRTIM_TIMERINDEX_TIMER_A Index used to access timer A registers HRTIM_TIMERINDEX_TIMER_B Index used to access timer B registers HRTIM_TIMERINDEX_TIMER_C Index used to access timer C registers HRTIM_TIMERINDEX_TIMER_D Index used to access timer D registers HRTIM_TIMERINDEX_TIMER_E Index used to access timer E registers HRTIM_TIMERINDEX_MASTER Index used to access master registers HRTIM_TIMERINDEX_COMMON Index used to access HRTIM common registers HRTIM Timer Output DOCID026526 Rev 4 343/832 UM1786 HRTIM_OUTPUT_TA1 Timer A - Output 1 identifier HRTIM_OUTPUT_TA2 Timer A - Output 2 identifier HRTIM_OUTPUT_TB1 Timer B - Output 1 identifier HRTIM_OUTPUT_TB2 Timer B - Output 2 identifier HRTIM_OUTPUT_TC1 Timer C - Output 1 identifier HRTIM_OUTPUT_TC2 Timer C - Output 2 identifier HRTIM_OUTPUT_TD1 Timer D - Output 1 identifier HRTIM_OUTPUT_TD2 Timer D - Output 2 identifier HRTIM_OUTPUT_TE1 Timer E - Output 1 identifier HRTIM_OUTPUT_TE2 Timer E - Output 2 identifier HRTIM Timer Push Pull Mode HRTIM_TIMPUSHPULLMODE_DISABLED Push-Pull mode disabled HRTIM_TIMPUSHPULLMODE_ENABLED Push-Pull mode enabled HRTIM Timer Repetition Update HRTIM_UPDATEONREPETITION_DISABLED Update on repetition disabled HRTIM_UPDATEONREPETITION_ENABLED Update on repetition enabled HRTIM Timer Reset Trigger 344/832 HRTIM_TIMRESETTRIGGER_NONE No counter reset trigger HRTIM_TIMRESETTRIGGER_UPDATE The timer counter is reset upon update event HRTIM_TIMRESETTRIGGER_CMP2 The timer counter is reset upon Timer Compare 2 event HRTIM_TIMRESETTRIGGER_CMP4 The timer counter is reset upon Timer Compare 4 event HRTIM_TIMRESETTRIGGER_MASTER_PER The timer counter is reset upon master timer period event HRTIM_TIMRESETTRIGGER_MASTER_CMP1 The timer counter is reset upon master timer Compare 1 event HRTIM_TIMRESETTRIGGER_MASTER_CMP2 The timer counter is reset upon master timer Compare 2 event HRTIM_TIMRESETTRIGGER_MASTER_CMP3 The timer counter is reset upon master timer Compare 3 event HRTIM_TIMRESETTRIGGER_MASTER_CMP4 The timer counter is reset upon master timer Compare 4 event HRTIM_TIMRESETTRIGGER_EEV_1 The timer counter is reset upon external event 1 HRTIM_TIMRESETTRIGGER_EEV_2 The timer counter is reset upon external event 2 HRTIM_TIMRESETTRIGGER_EEV_3 The timer counter is reset upon external event 3 DOCID026526 Rev 4 UM1786 HRTIM_TIMRESETTRIGGER_EEV_4 The timer counter is reset upon external event 4 HRTIM_TIMRESETTRIGGER_EEV_5 The timer counter is reset upon external event 5 HRTIM_TIMRESETTRIGGER_EEV_6 The timer counter is reset upon external event 6 HRTIM_TIMRESETTRIGGER_EEV_7 The timer counter is reset upon external event 7 HRTIM_TIMRESETTRIGGER_EEV_8 The timer counter is reset upon external event 8 HRTIM_TIMRESETTRIGGER_EEV_9 The timer counter is reset upon external event 9 HRTIM_TIMRESETTRIGGER_EEV_10 The timer counter is reset upon external event 10 HRTIM_TIMRESETTRIGGER_OTHER1_CMP1 The timer counter is reset upon other timer Compare 1 event HRTIM_TIMRESETTRIGGER_OTHER1_CMP2 The timer counter is reset upon other timer Compare 2 event HRTIM_TIMRESETTRIGGER_OTHER1_CMP4 The timer counter is reset upon other timer Compare 4 event HRTIM_TIMRESETTRIGGER_OTHER2_CMP1 The timer counter is reset upon other timer Compare 1 event HRTIM_TIMRESETTRIGGER_OTHER2_CMP2 The timer counter is reset upon other timer Compare 2 event HRTIM_TIMRESETTRIGGER_OTHER2_CMP4 The timer counter is reset upon other timer Compare 4 event HRTIM_TIMRESETTRIGGER_OTHER3_CMP1 The timer counter is reset upon other timer Compare 1 event HRTIM_TIMRESETTRIGGER_OTHER3_CMP2 The timer counter is reset upon other timer Compare 2 event HRTIM_TIMRESETTRIGGER_OTHER3_CMP4 The timer counter is reset upon other timer Compare 4 event HRTIM_TIMRESETTRIGGER_OTHER4_CMP1 The timer counter is reset upon other timer Compare 1 event HRTIM_TIMRESETTRIGGER_OTHER4_CMP2 The timer counter is reset upon other timer Compare 2 event HRTIM_TIMRESETTRIGGER_OTHER4_CMP4 The timer counter is reset upon other timer Compare 4 event HRTIM Timer Reset Update HRTIM_TIMUPDATEONRESET_DISABLED Update by timer x reset / roll-over disabled HRTIM_TIMUPDATEONRESET_ENABLED Update by timer x reset / roll-over enabled HRTIM Timer Update Trigger HRTIM_TIMUPDATETRIGGER_NONE Register update is disabled DOCID026526 Rev 4 345/832 HRTIM_TIMUPDATETRIGGER_MASTER UM1786 Register update is triggered by the master timer update HRTIM_TIMUPDATETRIGGER_TIMER_A Register update is triggered by the timer A update HRTIM_TIMUPDATETRIGGER_TIMER_B Register update is triggered by the timer B update HRTIM_TIMUPDATETRIGGER_TIMER_C Register update is triggered by the timer C update HRTIM_TIMUPDATETRIGGER_TIMER_D Register update is triggered by the timer D update HRTIM_TIMUPDATETRIGGER_TIMER_E Register update is triggered by the timer E update HRTIM Timing Unit DMA Request Enable HRTIM_TIM_DMA_NONE No DMA request enable HRTIM_TIM_DMA_CMP1 Timer compare 1 DMA request enable HRTIM_TIM_DMA_CMP2 Timer compare 2 DMA request enable HRTIM_TIM_DMA_CMP3 Timer compare 3 DMA request enable HRTIM_TIM_DMA_CMP4 Timer compare 4 DMA request enable HRTIM_TIM_DMA_REP Timer repetition DMA request enable HRTIM_TIM_DMA_UPD Timer update DMA request enable HRTIM_TIM_DMA_CPT1 Timer capture 1 DMA request enable HRTIM_TIM_DMA_CPT2 Timer capture 2 DMA request enable HRTIM_TIM_DMA_SET1 Timer output 1 set DMA request enable HRTIM_TIM_DMA_RST1 Timer output 1 reset DMA request enable HRTIM_TIM_DMA_SET2 Timer output 2 set DMA request enable HRTIM_TIM_DMA_RST2 Timer output 2 reset DMA request enable HRTIM_TIM_DMA_RST Timer reset DMA request enable HRTIM_TIM_DMA_DLYPRT Timer delay protection DMA request enable HRTIM Timing Unit Interrupt Enable 346/832 HRTIM_TIM_IT_NONE No interrupt enabled HRTIM_TIM_IT_CMP1 Timer compare 1 interrupt enable HRTIM_TIM_IT_CMP2 Timer compare 2 interrupt enable HRTIM_TIM_IT_CMP3 Timer compare 3 interrupt enable HRTIM_TIM_IT_CMP4 Timer compare 4 interrupt enable HRTIM_TIM_IT_REP Timer repetition interrupt enable HRTIM_TIM_IT_UPD Timer update interrupt enable HRTIM_TIM_IT_CPT1 Timer capture 1 interrupt enable HRTIM_TIM_IT_CPT2 Timer capture 2 interrupt enable DOCID026526 Rev 4 UM1786 HRTIM_TIM_IT_SET1 Timer output 1 set interrupt enable HRTIM_TIM_IT_RST1 Timer output 1 reset interrupt enable HRTIM_TIM_IT_SET2 Timer output 2 set interrupt enable HRTIM_TIM_IT_RST2 Timer output 2 reset interrupt enable HRTIM_TIM_IT_RST Timer reset interrupt enable HRTIM_TIM_IT_DLYPRT Timer delay protection interrupt enable HRTIM Timing Unit Interrupt Flag HRTIM_TIM_FLAG_CMP1 Timer compare 1 interrupt flag HRTIM_TIM_FLAG_CMP2 Timer compare 2 interrupt flag HRTIM_TIM_FLAG_CMP3 Timer compare 3 interrupt flag HRTIM_TIM_FLAG_CMP4 Timer compare 4 interrupt flag HRTIM_TIM_FLAG_REP Timer repetition interrupt flag HRTIM_TIM_FLAG_UPD Timer update interrupt flag HRTIM_TIM_FLAG_CPT1 Timer capture 1 interrupt flag HRTIM_TIM_FLAG_CPT2 Timer capture 2 interrupt flag HRTIM_TIM_FLAG_SET1 Timer output 1 set interrupt flag HRTIM_TIM_FLAG_RST1 Timer output 1 reset interrupt flag HRTIM_TIM_FLAG_SET2 Timer output 2 set interrupt flag HRTIM_TIM_FLAG_RST2 Timer output 2 reset interrupt flag HRTIM_TIM_FLAG_RST Timer reset interrupt flag HRTIM_TIM_FLAG_DLYPRT Timer delay protection interrupt flag HRTIM Update Gating HRTIM_UPDATEGATING_INDEPENDENT Update done independently from the DMA burst transfer completion HRTIM_UPDATEGATING_DMABURST Update done when the DMA burst transfer is completed HRTIM_UPDATEGATING_DMABURST_UPDATE Update done on timer roll-over following a DMA burst transfer completion HRTIM_UPDATEGATING_UPDEN1 Slave timer only - Update done on a rising edge of HRTIM update enable input 1 HRTIM_UPDATEGATING_UPDEN2 Slave timer only - Update done on a rising edge of HRTIM update enable input 2 HRTIM_UPDATEGATING_UPDEN3 Slave timer only - Update done on a rising edge of HRTIM update enable input 3 HRTIM_UPDATEGATING_UPDEN1_UPDATE Slave timer only - Update done on the update event following a rising edge DOCID026526 Rev 4 347/832 UM1786 of HRTIM update enable input 1 348/832 HRTIM_UPDATEGATING_UPDEN2_UPDATE Slave timer only - Update done on the update event following a rising edge of HRTIM update enable input 2 HRTIM_UPDATEGATING_UPDEN3_UPDATE Slave timer only - Update done on the update event following a rising edge of HRTIM update enable input 3 DOCID026526 Rev 4 UM1786 22 HAL I2C Generic Driver 22.1 I2C Firmware driver registers structures 22.1.1 I2C_InitTypeDef Data Fields uint32_t Timing uint32_t OwnAddress1 uint32_t AddressingMode uint32_t DualAddressMode uint32_t OwnAddress2 uint32_t OwnAddress2Masks uint32_t GeneralCallMode uint32_t NoStretchMode Field Documentation 22.1.2 uint32_t I2C_InitTypeDef::Timing Specifies the I2C_TIMINGR_register value. This parameter calculated by referring to I2C initialization section in Reference manual uint32_t I2C_InitTypeDef::OwnAddress1 Specifies the first device own address. This parameter can be a 7-bit or 10-bit address. uint32_t I2C_InitTypeDef::AddressingMode Specifies if 7-bit or 10-bit addressing mode is selected. This parameter can be a value of I2C_ADDRESSING_MODE uint32_t I2C_InitTypeDef::DualAddressMode Specifies if dual addressing mode is selected. This parameter can be a value of I2C_DUAL_ADDRESSING_MODE uint32_t I2C_InitTypeDef::OwnAddress2 Specifies the second device own address if dual addressing mode is selected This parameter can be a 7-bit address. uint32_t I2C_InitTypeDef::OwnAddress2Masks Specifies the acknowledge mask address second device own address if dual addressing mode is selected This parameter can be a value of I2C_OWN_ADDRESS2_MASKS uint32_t I2C_InitTypeDef::GeneralCallMode Specifies if general call mode is selected. This parameter can be a value of I2C_GENERAL_CALL_ADDRESSING_MODE uint32_t I2C_InitTypeDef::NoStretchMode Specifies if nostretch mode is selected. This parameter can be a value of I2C_NOSTRETCH_MODE __I2C_HandleTypeDef Data Fields DOCID026526 Rev 4 349/832 UM1786 I2C_TypeDef * Instance I2C_InitTypeDef Init uint8_t * pBuffPtr uint16_t XferSize __IO uint16_t XferCount __IO uint32_t XferOptions __IO uint32_t PreviousState HAL_StatusTypeDef(* XferISR DMA_HandleTypeDef * hdmatx DMA_HandleTypeDef * hdmarx HAL_LockTypeDef Lock __IO HAL_I2C_StateTypeDef State __IO HAL_I2C_ModeTypeDef Mode __IO uint32_t ErrorCode __IO uint32_t AddrEventCount Field Documentation 350/832 I2C_TypeDef* __I2C_HandleTypeDef::Instance I2C registers base address I2C_InitTypeDef __I2C_HandleTypeDef::Init I2C communication parameters uint8_t* __I2C_HandleTypeDef::pBuffPtr Pointer to I2C transfer buffer uint16_t __I2C_HandleTypeDef::XferSize I2C transfer size __IO uint16_t __I2C_HandleTypeDef::XferCount I2C transfer counter __IO uint32_t __I2C_HandleTypeDef::XferOptions I2C sequantial transfer options, this parameter can be a value of I2C_XFEROPTIONS __IO uint32_t __I2C_HandleTypeDef::PreviousState I2C communication Previous state HAL_StatusTypeDef(* __I2C_HandleTypeDef::XferISR)(struct __I2C_HandleTypeDef *hi2c, uint32_t ITFlags, uint32_t ITSources) I2C transfer IRQ handler function pointer DMA_HandleTypeDef* __I2C_HandleTypeDef::hdmatx I2C Tx DMA handle parameters DMA_HandleTypeDef* __I2C_HandleTypeDef::hdmarx I2C Rx DMA handle parameters HAL_LockTypeDef __I2C_HandleTypeDef::Lock I2C locking object __IO HAL_I2C_StateTypeDef __I2C_HandleTypeDef::State I2C communication state __IO HAL_I2C_ModeTypeDef __I2C_HandleTypeDef::Mode I2C communication mode __IO uint32_t __I2C_HandleTypeDef::ErrorCode I2C Error code __IO uint32_t __I2C_HandleTypeDef::AddrEventCount I2C Address Event counter DOCID026526 Rev 4 UM1786 22.2 I2C Firmware driver API description 22.2.1 How to use this driver The I2C HAL driver can be used as follows: 1. 2. 3. 4. 5. 6. Declare a I2C_HandleTypeDef handle structure, for example: I2C_HandleTypeDef hi2c; Initialize the I2C low level resources by implementing the HAL_I2C_MspInit() API: a. Enable the I2Cx interface clock b. I2C pins configuration Enable the clock for the I2C GPIOs Configure I2C pins as alternate function open-drain c. NVIC configuration if you need to use interrupt process Configure the I2Cx interrupt priority Enable the NVIC I2C IRQ Channel d. DMA Configuration if you need to use DMA process Declare a DMA_HandleTypeDef handle structure for the transmit or receive channel Enable the DMAx interface clock using Configure the DMA handle parameters Configure the DMA Tx or Rx channel Associate the initialized DMA handle to the hi2c DMA Tx or Rx handle Configure the priority and enable the NVIC for the transfer complete interrupt on the DMA Tx or Rx channel Configure the Communication Clock Timing, Own Address1, Master Addressing mode, Dual Addressing mode, Own Address2, Own Address2 Mask, General call and Nostretch mode in the hi2c Init structure. Initialize the I2C registers by calling the HAL_I2C_Init(), configures also the low level Hardware (GPIO, CLOCK, NVIC...etc) by calling the customized HAL_I2C_MspInit(&hi2c) API. To check if target device is ready for communication, use the function HAL_I2C_IsDeviceReady() For I2C IO and IO MEM operations, three operation modes are available within this driver : Polling mode IO operation Transmit in master mode an amount of data in blocking mode using HAL_I2C_Master_Transmit() Receive in master mode an amount of data in blocking mode using HAL_I2C_Master_Receive() Transmit in slave mode an amount of data in blocking mode using HAL_I2C_Slave_Transmit() Receive in slave mode an amount of data in blocking mode using HAL_I2C_Slave_Receive() Polling mode IO MEM operation Write an amount of data in blocking mode to a specific memory address using HAL_I2C_Mem_Write() Read an amount of data in blocking mode from a specific memory address using HAL_I2C_Mem_Read() DOCID026526 Rev 4 351/832 UM1786 Interrupt mode IO operation Transmit in master mode an amount of data in non-blocking mode using HAL_I2C_Master_Transmit_IT() At transmission end of transfer, HAL_I2C_MasterTxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_I2C_MasterTxCpltCallback() Receive in master mode an amount of data in non-blocking mode using HAL_I2C_Master_Receive_IT() At reception end of transfer, HAL_I2C_MasterRxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_I2C_MasterRxCpltCallback() Transmit in slave mode an amount of data in non-blocking mode using HAL_I2C_Slave_Transmit_IT() At transmission end of transfer, HAL_I2C_SlaveTxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_I2C_SlaveTxCpltCallback() Receive in slave mode an amount of data in non-blocking mode using HAL_I2C_Slave_Receive_IT() At reception end of transfer, HAL_I2C_SlaveRxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_I2C_SlaveRxCpltCallback() In case of transfer Error, HAL_I2C_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_I2C_ErrorCallback() Abort a master I2C process communication with Interrupt using HAL_I2C_Master_Abort_IT() End of abort process, HAL_I2C_AbortCpltCallback() is executed and user can add his own code by customization of function pointer HAL_I2C_AbortCpltCallback() Discard a slave I2C process communication using __HAL_I2C_GENERATE_NACK() macro. This action will inform Master to generate a Stop condition to discard the communication. Interrupt mode IO sequential operation These interfaces allow to manage a sequential transfer with a repeated start condition when a direction change during transfer 352/832 A specific option field manage the different steps of a sequential transfer Option field values are defined through @ref I2C_XFEROPTIONS and are listed below: I2C_FIRST_AND_LAST_FRAME: No sequential usage, functionnal is same as associated interfaces in no sequential mode I2C_FIRST_FRAME: Sequential usage, this option allow to manage a sequence with start condition, address and data to transfer without a final stop condition I2C_NEXT_FRAME: Sequential usage, this option allow to manage a sequence with a restart condition, address and with new data to transfer if the direction change or manage only the new data to transfer if no direction change and without a final stop condition in both cases I2C_LAST_FRAME: Sequential usage, this option allow to manage a sequance with a restart condition, address and with new data to transfer if the direction DOCID026526 Rev 4 UM1786 change or manage only the new data to transfer if no direction change and with a final stop condition in both cases Differents sequential I2C interfaces are listed below: Sequential transmit in master I2C mode an amount of data in non-blocking mode using HAL_I2C_Master_Sequential_Transmit_IT() At transmission end of current frame transfer, HAL_I2C_MasterTxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_I2C_MasterTxCpltCallback() Sequential receive in master I2C mode an amount of data in non-blocking mode using HAL_I2C_Master_Sequential_Receive_IT() At reception end of current frame transfer, HAL_I2C_MasterRxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_I2C_MasterRxCpltCallback() Abort a master I2C process communication with Interrupt using HAL_I2C_Master_Abort_IT() End of abort process, HAL_I2C_AbortCpltCallback() is executed and user can add his own code by customization of function pointer HAL_I2C_AbortCpltCallback() mean HAL_I2C_MasterTxCpltCallback() in case of previous state was master transmit mean HAL_I2c_MasterRxCpltCallback() in case of previous state was master receive Enable/disable the Address listen mode in slave I2C mode using HAL_I2C_EnableListen_IT() HAL_I2C_DisableListen_IT() When address slave I2C match, HAL_I2C_AddrCallback() is executed and user can add his own code to check the Address Match Code and the transmission direction request by master (Write/Read). At Listen mode end HAL_I2C_ListenCpltCallback() is executed and user can add his own code by customization of function pointer HAL_I2C_ListenCpltCallback() Sequential transmit in slave I2C mode an amount of data in non-blocking mode using HAL_I2C_Slave_Sequential_Transmit_IT() At transmission end of current frame transfer, HAL_I2C_SlaveTxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_I2C_SlaveTxCpltCallback() Sequential receive in slave I2C mode an amount of data in non-blocking mode using HAL_I2C_Slave_Sequential_Receive_IT() At reception end of current frame transfer, HAL_I2C_SlaveRxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_I2C_SlaveRxCpltCallback() In case of transfer Error, HAL_I2C_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_I2C_ErrorCallback() Abort a master I2C process communication with Interrupt using HAL_I2C_Master_Abort_IT() End of abort process, HAL_I2C_AbortCpltCallback() is executed and user can add his own code by customization of function pointer HAL_I2C_AbortCpltCallback() Discard a slave I2C process communication using __HAL_I2C_GENERATE_NACK() macro. This action will inform Master to generate a Stop condition to discard the communication. Interrupt mode IO MEM operation DOCID026526 Rev 4 353/832 UM1786 Write an amount of data in non-blocking mode with Interrupt to a specific memory address using HAL_I2C_Mem_Write_IT() At Memory end of write transfer, HAL_I2C_MemTxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_I2C_MemTxCpltCallback() Read an amount of data in non-blocking mode with Interrupt from a specific memory address using HAL_I2C_Mem_Read_IT() At Memory end of read transfer, HAL_I2C_MemRxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_I2C_MemRxCpltCallback() In case of transfer Error, HAL_I2C_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_I2C_ErrorCallback() DMA mode IO operation Transmit in master mode an amount of data in non-blocking mode (DMA) using HAL_I2C_Master_Transmit_DMA() At transmission end of transfer, HAL_I2C_MasterTxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_I2C_MasterTxCpltCallback() Receive in master mode an amount of data in non-blocking mode (DMA) using HAL_I2C_Master_Receive_DMA() At reception end of transfer, HAL_I2C_MasterRxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_I2C_MasterRxCpltCallback() Transmit in slave mode an amount of data in non-blocking mode (DMA) using HAL_I2C_Slave_Transmit_DMA() At transmission end of transfer, HAL_I2C_SlaveTxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_I2C_SlaveTxCpltCallback() Receive in slave mode an amount of data in non-blocking mode (DMA) using HAL_I2C_Slave_Receive_DMA() At reception end of transfer, HAL_I2C_SlaveRxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_I2C_SlaveRxCpltCallback() In case of transfer Error, HAL_I2C_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_I2C_ErrorCallback() Abort a master I2C process communication with Interrupt using HAL_I2C_Master_Abort_IT() End of abort process, HAL_I2C_AbortCpltCallback() is executed and user can add his own code by customization of function pointer HAL_I2C_AbortCpltCallback() Discard a slave I2C process communication using __HAL_I2C_GENERATE_NACK() macro. This action will inform Master to generate a Stop condition to discard the communication. DMA mode IO MEM operation 354/832 Write an amount of data in non-blocking mode with DMA to a specific memory address using HAL_I2C_Mem_Write_DMA() At Memory end of write transfer, HAL_I2C_MemTxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_I2C_MemTxCpltCallback() DOCID026526 Rev 4 UM1786 Read an amount of data in non-blocking mode with DMA from a specific memory address using HAL_I2C_Mem_Read_DMA() At Memory end of read transfer, HAL_I2C_MemRxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_I2C_MemRxCpltCallback() In case of transfer Error, HAL_I2C_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_I2C_ErrorCallback() I2C HAL driver macros list Below the list of most used macros in I2C HAL driver. __HAL_I2C_ENABLE: Enable the I2C peripheral __HAL_I2C_DISABLE: Disable the I2C peripheral __HAL_I2C_GENERATE_NACK: Generate a Non-Acknowledge I2C peripheral in Slave mode __HAL_I2C_GET_FLAG: Check whether the specified I2C flag is set or not __HAL_I2C_CLEAR_FLAG: Clear the specified I2C pending flag __HAL_I2C_ENABLE_IT: Enable the specified I2C interrupt __HAL_I2C_DISABLE_IT: Disable the specified I2C interrupt You can refer to the I2C HAL driver header file for more useful macros 22.2.2 Initialization and de-initialization functions This subsection provides a set of functions allowing to initialize and deinitialize the I2Cx peripheral: User must Implement HAL_I2C_MspInit() function in which he configures all related peripherals resources (CLOCK, GPIO, DMA, IT and NVIC ). Call the function HAL_I2C_Init() to configure the selected device with the selected configuration: Clock Timing Own Address 1 Addressing mode (Master, Slave) Dual Addressing mode Own Address 2 Own Address 2 Mask General call mode Nostretch mode Call the function HAL_I2C_DeInit() to restore the default configuration of the selected I2Cx peripheral. This section contains the following APIs: 22.2.3 HAL_I2C_Init() HAL_I2C_DeInit() HAL_I2C_MspInit() HAL_I2C_MspDeInit() IO operation functions This subsection provides a set of functions allowing to manage the I2C data transfers. DOCID026526 Rev 4 355/832 1. 2. 3. 4. 5. UM1786 There are two modes of transfer: Blocking mode : The communication is performed in the polling mode. The status of all data processing is returned by the same function after finishing transfer. No-Blocking mode : The communication is performed using Interrupts or DMA. These functions return the status of the transfer startup. The end of the data processing will be indicated through the dedicated I2C IRQ when using Interrupt mode or the DMA IRQ when using DMA mode. Blocking mode functions are : HAL_I2C_Master_Transmit() HAL_I2C_Master_Receive() HAL_I2C_Slave_Transmit() HAL_I2C_Slave_Receive() HAL_I2C_Mem_Write() HAL_I2C_Mem_Read() HAL_I2C_IsDeviceReady() No-Blocking mode functions with Interrupt are : HAL_I2C_Master_Transmit_IT() HAL_I2C_Master_Receive_IT() HAL_I2C_Slave_Transmit_IT() HAL_I2C_Slave_Receive_IT() HAL_I2C_Mem_Write_IT() HAL_I2C_Mem_Read_IT() No-Blocking mode functions with DMA are : HAL_I2C_Master_Transmit_DMA() HAL_I2C_Master_Receive_DMA() HAL_I2C_Slave_Transmit_DMA() HAL_I2C_Slave_Receive_DMA() HAL_I2C_Mem_Write_DMA() HAL_I2C_Mem_Read_DMA() A set of Transfer Complete Callbacks are provided in non Blocking mode: HAL_I2C_MemTxCpltCallback() HAL_I2C_MemRxCpltCallback() HAL_I2C_MasterTxCpltCallback() HAL_I2C_MasterRxCpltCallback() HAL_I2C_SlaveTxCpltCallback() HAL_I2C_SlaveRxCpltCallback() HAL_I2C_ErrorCallback() This section contains the following APIs: 356/832 HAL_I2C_Master_Transmit() HAL_I2C_Master_Receive() HAL_I2C_Slave_Transmit() HAL_I2C_Slave_Receive() HAL_I2C_Master_Transmit_IT() HAL_I2C_Master_Receive_IT() HAL_I2C_Slave_Transmit_IT() HAL_I2C_Slave_Receive_IT() HAL_I2C_Master_Transmit_DMA() HAL_I2C_Master_Receive_DMA() HAL_I2C_Slave_Transmit_DMA() HAL_I2C_Slave_Receive_DMA() HAL_I2C_Mem_Write() DOCID026526 Rev 4 UM1786 22.2.4 HAL_I2C_Mem_Read() HAL_I2C_Mem_Write_IT() HAL_I2C_Mem_Read_IT() HAL_I2C_Mem_Write_DMA() HAL_I2C_Mem_Read_DMA() HAL_I2C_IsDeviceReady() HAL_I2C_Master_Sequential_Transmit_IT() HAL_I2C_Master_Sequential_Receive_IT() HAL_I2C_Slave_Sequential_Transmit_IT() HAL_I2C_Slave_Sequential_Receive_IT() HAL_I2C_EnableListen_IT() HAL_I2C_DisableListen_IT() HAL_I2C_Master_Abort_IT() Peripheral State, Mode and Error functions This subsection permit to get in run-time the status of the peripheral and the data flow. This section contains the following APIs: 22.2.5 HAL_I2C_GetState() HAL_I2C_GetMode() HAL_I2C_GetError() Detailed description of functions HAL_I2C_Init Function Name HAL_StatusTypeDef HAL_I2C_Init (I2C_HandleTypeDef * hi2c) Function Description Initializes the I2C according to the specified parameters in the I2C_InitTypeDef and initialize the associated handle. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. Return values HAL: status HAL_I2C_DeInit Function Name HAL_StatusTypeDef HAL_I2C_DeInit (I2C_HandleTypeDef * hi2c) Function Description DeInitialize the I2C peripheral. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. Return values HAL: status HAL_I2C_MspInit Function Name void HAL_I2C_MspInit (I2C_HandleTypeDef * hi2c) Function Description Initialize the I2C MSP. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. DOCID026526 Rev 4 357/832 UM1786 Return values None: HAL_I2C_MspDeInit Function Name void HAL_I2C_MspDeInit (I2C_HandleTypeDef * hi2c) Function Description DeInitialize the I2C MSP. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. Return values None: HAL_I2C_Master_Transmit Function Name HAL_StatusTypeDef HAL_I2C_Master_Transmit (I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint8_t * pData, uint16_t Size, uint32_t Timeout) Function Description Transmits in master mode an amount of data in blocking mode. Parameters Return values hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. DevAddress: Target device address pData: Pointer to data buffer Size: Amount of data to be sent Timeout: Timeout duration HAL: status HAL_I2C_Master_Receive Function Name HAL_StatusTypeDef HAL_I2C_Master_Receive (I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint8_t * pData, uint16_t Size, uint32_t Timeout) Function Description Receives in master mode an amount of data in blocking mode. Parameters Return values hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. DevAddress: Target device address pData: Pointer to data buffer Size: Amount of data to be sent Timeout: Timeout duration HAL: status HAL_I2C_Slave_Transmit Function Name HAL_StatusTypeDef HAL_I2C_Slave_Transmit (I2C_HandleTypeDef * hi2c, uint8_t * pData, uint16_t Size, uint32_t Timeout) Function Description Transmits in slave mode an amount of data in blocking mode. Parameters 358/832 hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. pData: Pointer to data buffer Size: Amount of data to be sent DOCID026526 Rev 4 UM1786 Return values Timeout: Timeout duration HAL: status HAL_I2C_Slave_Receive Function Name HAL_StatusTypeDef HAL_I2C_Slave_Receive (I2C_HandleTypeDef * hi2c, uint8_t * pData, uint16_t Size, uint32_t Timeout) Function Description Receive in slave mode an amount of data in blocking mode. Parameters Return values hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. pData: Pointer to data buffer Size: Amount of data to be sent Timeout: Timeout duration HAL: status HAL_I2C_Mem_Write Function Name HAL_StatusTypeDef HAL_I2C_Mem_Write (I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t * pData, uint16_t Size, uint32_t Timeout) Function Description Write an amount of data in blocking mode to a specific memory address. Parameters Return values hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. DevAddress: Target device address MemAddress: Internal memory address MemAddSize: Size of internal memory address pData: Pointer to data buffer Size: Amount of data to be sent Timeout: Timeout duration HAL: status HAL_I2C_Mem_Read Function Name HAL_StatusTypeDef HAL_I2C_Mem_Read (I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t * pData, uint16_t Size, uint32_t Timeout) Function Description Read an amount of data in blocking mode from a specific memory address. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. DevAddress: Target device address MemAddress: Internal memory address MemAddSize: Size of internal memory address pData: Pointer to data buffer Size: Amount of data to be sent DOCID026526 Rev 4 359/832 UM1786 Return values Timeout: Timeout duration HAL: status HAL_I2C_IsDeviceReady Function Name HAL_StatusTypeDef HAL_I2C_IsDeviceReady (I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint32_t Trials, uint32_t Timeout) Function Description Checks if target device is ready for communication. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. DevAddress: Target device address Trials: Number of trials Timeout: Timeout duration Return values HAL: status Notes This function is used with Memory devices HAL_I2C_Master_Transmit_IT Function Name HAL_StatusTypeDef HAL_I2C_Master_Transmit_IT (I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint8_t * pData, uint16_t Size) Function Description Transmit in master mode an amount of data in non-blocking mode with Interrupt. Parameters Return values hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. DevAddress: Target device address pData: Pointer to data buffer Size: Amount of data to be sent HAL: status HAL_I2C_Master_Receive_IT Function Name HAL_StatusTypeDef HAL_I2C_Master_Receive_IT (I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint8_t * pData, uint16_t Size) Function Description Receive in master mode an amount of data in non-blocking mode with Interrupt. Parameters Return values 360/832 hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. DevAddress: Target device address pData: Pointer to data buffer Size: Amount of data to be sent HAL: status DOCID026526 Rev 4 UM1786 HAL_I2C_Slave_Transmit_IT Function Name HAL_StatusTypeDef HAL_I2C_Slave_Transmit_IT (I2C_HandleTypeDef * hi2c, uint8_t * pData, uint16_t Size) Function Description Transmit in slave mode an amount of data in non-blocking mode with Interrupt. Parameters Return values hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. pData: Pointer to data buffer Size: Amount of data to be sent HAL: status HAL_I2C_Slave_Receive_IT Function Name HAL_StatusTypeDef HAL_I2C_Slave_Receive_IT (I2C_HandleTypeDef * hi2c, uint8_t * pData, uint16_t Size) Function Description Receive in slave mode an amount of data in non-blocking mode with Interrupt. Parameters Return values hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. pData: Pointer to data buffer Size: Amount of data to be sent HAL: status HAL_I2C_Mem_Write_IT Function Name HAL_StatusTypeDef HAL_I2C_Mem_Write_IT (I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t * pData, uint16_t Size) Function Description Write an amount of data in non-blocking mode with Interrupt to a specific memory address. Parameters Return values hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. DevAddress: Target device address MemAddress: Internal memory address MemAddSize: Size of internal memory address pData: Pointer to data buffer Size: Amount of data to be sent HAL: status HAL_I2C_Mem_Read_IT Function Name HAL_StatusTypeDef HAL_I2C_Mem_Read_IT (I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t * pData, uint16_t Size) Function Description Read an amount of data in non-blocking mode with Interrupt from a specific memory address. DOCID026526 Rev 4 361/832 UM1786 Parameters Return values hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. DevAddress: Target device address MemAddress: Internal memory address MemAddSize: Size of internal memory address pData: Pointer to data buffer Size: Amount of data to be sent HAL: status HAL_I2C_Master_Sequential_Transmit_IT Function Name HAL_StatusTypeDef HAL_I2C_Master_Sequential_Transmit_IT (I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint8_t * pData, uint16_t Size, uint32_t XferOptions) Function Description Sequential transmit in master I2C mode an amount of data in nonblocking mode with Interrupt. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. DevAddress: Target device address pData: Pointer to data buffer Size: Amount of data to be sent XferOptions: Options of Transfer, value of I2C Sequential Transfer Options Return values HAL: status Notes This interface allow to manage repeated start condition when a direction change during transfer HAL_I2C_Master_Sequential_Receive_IT Function Name HAL_StatusTypeDef HAL_I2C_Master_Sequential_Receive_IT (I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint8_t * pData, uint16_t Size, uint32_t XferOptions) Function Description Sequential receive in master I2C mode an amount of data in nonblocking mode with Interrupt. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. DevAddress: Target device address pData: Pointer to data buffer Size: Amount of data to be sent XferOptions: Options of Transfer, value of I2C Sequential Transfer Options Return values HAL: status Notes This interface allow to manage repeated start condition when a direction change during transfer HAL_I2C_Slave_Sequential_Transmit_IT Function Name 362/832 HAL_StatusTypeDef HAL_I2C_Slave_Sequential_Transmit_IT DOCID026526 Rev 4 UM1786 (I2C_HandleTypeDef * hi2c, uint8_t * pData, uint16_t Size, uint32_t XferOptions) Function Description Sequential transmit in slave/device I2C mode an amount of data in non-blocking mode with Interrupt. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. pData: Pointer to data buffer Size: Amount of data to be sent XferOptions: Options of Transfer, value of I2C Sequential Transfer Options Return values HAL: status Notes This interface allow to manage repeated start condition when a direction change during transfer HAL_I2C_Slave_Sequential_Receive_IT Function Name HAL_StatusTypeDef HAL_I2C_Slave_Sequential_Receive_IT (I2C_HandleTypeDef * hi2c, uint8_t * pData, uint16_t Size, uint32_t XferOptions) Function Description Sequential receive in slave/device I2C mode an amount of data in non-blocking mode with Interrupt. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. pData: Pointer to data buffer Size: Amount of data to be sent XferOptions: Options of Transfer, value of I2C Sequential Transfer Options Return values HAL: status Notes This interface allow to manage repeated start condition when a direction change during transfer HAL_I2C_EnableListen_IT Function Name HAL_StatusTypeDef HAL_I2C_EnableListen_IT (I2C_HandleTypeDef * hi2c) Function Description Enable the Address listen mode with Interrupt. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. Return values HAL: status HAL_I2C_DisableListen_IT Function Name HAL_StatusTypeDef HAL_I2C_DisableListen_IT (I2C_HandleTypeDef * hi2c) Function Description Disable the Address listen mode with Interrupt. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C DOCID026526 Rev 4 363/832 UM1786 Return values HAL: status HAL_I2C_Master_Abort_IT Function Name HAL_StatusTypeDef HAL_I2C_Master_Abort_IT (I2C_HandleTypeDef * hi2c, uint16_t DevAddress) Function Description Abort a master I2C IT or DMA process communication with Interrupt. Parameters Return values hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. DevAddress: Target device address HAL: status HAL_I2C_Master_Transmit_DMA Function Name HAL_StatusTypeDef HAL_I2C_Master_Transmit_DMA (I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint8_t * pData, uint16_t Size) Function Description Transmit in master mode an amount of data in non-blocking mode with DMA. Parameters Return values hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. DevAddress: Target device address pData: Pointer to data buffer Size: Amount of data to be sent HAL: status HAL_I2C_Master_Receive_DMA Function Name HAL_StatusTypeDef HAL_I2C_Master_Receive_DMA (I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint8_t * pData, uint16_t Size) Function Description Receive in master mode an amount of data in non-blocking mode with DMA. Parameters Return values hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. DevAddress: Target device address pData: Pointer to data buffer Size: Amount of data to be sent HAL: status HAL_I2C_Slave_Transmit_DMA 364/832 Function Name HAL_StatusTypeDef HAL_I2C_Slave_Transmit_DMA (I2C_HandleTypeDef * hi2c, uint8_t * pData, uint16_t Size) Function Description Transmit in slave mode an amount of data in non-blocking mode with DMA. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains DOCID026526 Rev 4 UM1786 Return values the configuration information for the specified I2C. pData: Pointer to data buffer Size: Amount of data to be sent HAL: status HAL_I2C_Slave_Receive_DMA Function Name HAL_StatusTypeDef HAL_I2C_Slave_Receive_DMA (I2C_HandleTypeDef * hi2c, uint8_t * pData, uint16_t Size) Function Description Receive in slave mode an amount of data in non-blocking mode with DMA. Parameters Return values hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. pData: Pointer to data buffer Size: Amount of data to be sent HAL: status HAL_I2C_Mem_Write_DMA Function Name HAL_StatusTypeDef HAL_I2C_Mem_Write_DMA (I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t * pData, uint16_t Size) Function Description Write an amount of data in non-blocking mode with DMA to a specific memory address. Parameters Return values hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. DevAddress: Target device address MemAddress: Internal memory address MemAddSize: Size of internal memory address pData: Pointer to data buffer Size: Amount of data to be sent HAL: status HAL_I2C_Mem_Read_DMA Function Name HAL_StatusTypeDef HAL_I2C_Mem_Read_DMA (I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t * pData, uint16_t Size) Function Description Reads an amount of data in non-blocking mode with DMA from a specific memory address. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. DevAddress: Target device address MemAddress: Internal memory address MemAddSize: Size of internal memory address pData: Pointer to data buffer Size: Amount of data to be read DOCID026526 Rev 4 365/832 UM1786 Return values HAL: status HAL_I2C_EV_IRQHandler Function Name void HAL_I2C_EV_IRQHandler (I2C_HandleTypeDef * hi2c) Function Description This function handles I2C event interrupt request. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. Return values None: HAL_I2C_ER_IRQHandler Function Name void HAL_I2C_ER_IRQHandler (I2C_HandleTypeDef * hi2c) Function Description This function handles I2C error interrupt request. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. Return values None: HAL_I2C_MasterTxCpltCallback Function Name void HAL_I2C_MasterTxCpltCallback (I2C_HandleTypeDef * hi2c) Function Description Master Tx Transfer completed callback. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. Return values None: HAL_I2C_MasterRxCpltCallback Function Name void HAL_I2C_MasterRxCpltCallback (I2C_HandleTypeDef * hi2c) Function Description Master Rx Transfer completed callback. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. Return values None: HAL_I2C_SlaveTxCpltCallback 366/832 Function Name void HAL_I2C_SlaveTxCpltCallback (I2C_HandleTypeDef * hi2c) Function Description Slave Tx Transfer completed callback. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. Return values None: DOCID026526 Rev 4 UM1786 HAL_I2C_SlaveRxCpltCallback Function Name void HAL_I2C_SlaveRxCpltCallback (I2C_HandleTypeDef * hi2c) Function Description Slave Rx Transfer completed callback. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. Return values None: HAL_I2C_AddrCallback Function Name void HAL_I2C_AddrCallback (I2C_HandleTypeDef * hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode) Function Description Slave Address Match callback. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. TransferDirection: Master request Transfer Direction (Write/Read), value of I2C Sequential Transfer Options AddrMatchCode: Address Match Code None: Return values HAL_I2C_ListenCpltCallback Function Name void HAL_I2C_ListenCpltCallback (I2C_HandleTypeDef * hi2c) Function Description Listen Complete callback. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. Return values None: HAL_I2C_MemTxCpltCallback Function Name void HAL_I2C_MemTxCpltCallback (I2C_HandleTypeDef * hi2c) Function Description Memory Tx Transfer completed callback. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. Return values None: HAL_I2C_MemRxCpltCallback Function Name void HAL_I2C_MemRxCpltCallback (I2C_HandleTypeDef * hi2c) Function Description Memory Rx Transfer completed callback. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. Return values None: DOCID026526 Rev 4 367/832 UM1786 HAL_I2C_ErrorCallback Function Name void HAL_I2C_ErrorCallback (I2C_HandleTypeDef * hi2c) Function Description I2C error callback. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. Return values None: HAL_I2C_AbortCpltCallback Function Name void HAL_I2C_AbortCpltCallback (I2C_HandleTypeDef * hi2c) Function Description I2C abort callback. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. Return values None: HAL_I2C_GetState Function Name HAL_I2C_StateTypeDef HAL_I2C_GetState (I2C_HandleTypeDef * hi2c) Function Description Return the I2C handle state. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. Return values HAL: state HAL_I2C_GetMode Function Name HAL_I2C_ModeTypeDef HAL_I2C_GetMode (I2C_HandleTypeDef * hi2c) Function Description Returns the I2C Master, Slave, Memory or no mode. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for I2C module Return values HAL: mode HAL_I2C_GetError 368/832 Function Name uint32_t HAL_I2C_GetError (I2C_HandleTypeDef * hi2c) Function Description Return the I2C error code. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2C. Return values I2C: Error Code DOCID026526 Rev 4 UM1786 22.3 I2C Firmware driver defines 22.3.1 I2C I2C Addressing Mode I2C_ADDRESSINGMODE_7BIT I2C_ADDRESSINGMODE_10BIT I2C Dual Addressing Mode I2C_DUALADDRESS_DISABLE I2C_DUALADDRESS_ENABLE I2C Error Code definition HAL_I2C_ERROR_NONE No error HAL_I2C_ERROR_BERR BERR error HAL_I2C_ERROR_ARLO ARLO error HAL_I2C_ERROR_AF ACKF error HAL_I2C_ERROR_OVR OVR error HAL_I2C_ERROR_DMA DMA transfer error HAL_I2C_ERROR_TIMEOUT Timeout error HAL_I2C_ERROR_SIZE Size Management error I2C Exported Macros __HAL_I2C_RESET_HANDLE_STATE Description: Reset I2C handle state. Parameters: __HANDLE__: specifies the I2C Handle. Return value: __HAL_I2C_ENABLE_IT None Description: Enable the specified I2C interrupt. Parameters: __HANDLE__: specifies the I2C Handle. __INTERRUPT__: specifies the interrupt source to enable. This parameter can be one of the following values: I2C_IT_ERRI Errors interrupt enable I2C_IT_TCI Transfer complete interrupt enable I2C_IT_STOPI STOP detection interrupt enable I2C_IT_NACKI NACK received interrupt enable I2C_IT_ADDRI Address match interrupt enable DOCID026526 Rev 4 369/832 UM1786 I2C_IT_RXI RX interrupt enable I2C_IT_TXI TX interrupt enable Return value: None Description: __HAL_I2C_DISABLE_IT Disable the specified I2C interrupt. Parameters: __HANDLE__: specifies the I2C Handle. __INTERRUPT__: specifies the interrupt source to disable. This parameter can be one of the following values: I2C_IT_ERRI Errors interrupt enable I2C_IT_TCI Transfer complete interrupt enable I2C_IT_STOPI STOP detection interrupt enable I2C_IT_NACKI NACK received interrupt enable I2C_IT_ADDRI Address match interrupt enable I2C_IT_RXI RX interrupt enable I2C_IT_TXI TX interrupt enable Return value: __HAL_I2C_GET_IT_SOURCE None Description: Check whether the specified I2C interrupt source is enabled or not. Parameters: __HANDLE__: specifies the I2C Handle. __INTERRUPT__: specifies the I2C interrupt source to check. This parameter can be one of the following values: I2C_IT_ERRI Errors interrupt enable I2C_IT_TCI Transfer complete interrupt enable I2C_IT_STOPI STOP detection interrupt enable I2C_IT_NACKI NACK received interrupt enable I2C_IT_ADDRI Address match interrupt enable I2C_IT_RXI RX interrupt enable I2C_IT_TXI TX interrupt enable Return value: 370/832 The: new state of __INTERRUPT__ (SET or RESET). DOCID026526 Rev 4 UM1786 __HAL_I2C_GET_FLAG Description: Check whether the specified I2C flag is set or not. Parameters: __HANDLE__: specifies the I2C Handle. __FLAG__: specifies the flag to check. This parameter can be one of the following values: I2C_FLAG_TXE Transmit data register empty I2C_FLAG_TXIS Transmit interrupt status I2C_FLAG_RXNE Receive data register not empty I2C_FLAG_ADDR Address matched (slave mode) I2C_FLAG_AF Acknowledge failure received flag I2C_FLAG_STOPF STOP detection flag I2C_FLAG_TC Transfer complete (master mode) I2C_FLAG_TCR Transfer complete reload I2C_FLAG_BERR Bus error I2C_FLAG_ARLO Arbitration lost I2C_FLAG_OVR Overrun/Underrun I2C_FLAG_PECERR PEC error in reception I2C_FLAG_TIMEOUT Timeout or Tlow detection flag I2C_FLAG_ALERT SMBus alert I2C_FLAG_BUSY Bus busy I2C_FLAG_DIR Transfer direction (slave mode) Return value: __HAL_I2C_CLEAR_FLAG The: new state of __FLAG__ (SET or RESET). Description: Clear the I2C pending flags which are cleared by writing 1 in a specific bit. Parameters: __HANDLE__: specifies the I2C Handle. __FLAG__: specifies the flag to clear. This parameter can be any combination of the following values: I2C_FLAG_TXE Transmit data register empty I2C_FLAG_ADDR Address matched DOCID026526 Rev 4 371/832 UM1786 (slave mode) I2C_FLAG_AF Acknowledge failure received flag I2C_FLAG_STOPF STOP detection flag I2C_FLAG_BERR Bus error I2C_FLAG_ARLO Arbitration lost I2C_FLAG_OVR Overrun/Underrun I2C_FLAG_PECERR PEC error in reception I2C_FLAG_TIMEOUT Timeout or Tlow detection flag I2C_FLAG_ALERT SMBus alert Return value: None Description: __HAL_I2C_ENABLE Enable the specified I2C peripheral. Parameters: __HANDLE__: specifies the I2C Handle. Return value: None Description: __HAL_I2C_DISABLE Disable the specified I2C peripheral. Parameters: __HANDLE__: specifies the I2C Handle. Return value: __HAL_I2C_GENERATE_NACK None Description: Generate a Non-Acknowledge I2C peripheral in Slave mode. Parameters: __HANDLE__: specifies the I2C Handle. Return value: None I2C Flag definition I2C_FLAG_TXE I2C_FLAG_TXIS I2C_FLAG_RXNE I2C_FLAG_ADDR I2C_FLAG_AF 372/832 DOCID026526 Rev 4 UM1786 I2C_FLAG_STOPF I2C_FLAG_TC I2C_FLAG_TCR I2C_FLAG_BERR I2C_FLAG_ARLO I2C_FLAG_OVR I2C_FLAG_PECERR I2C_FLAG_TIMEOUT I2C_FLAG_ALERT I2C_FLAG_BUSY I2C_FLAG_DIR I2C General Call Addressing Mode I2C_GENERALCALL_DISABLE I2C_GENERALCALL_ENABLE I2C Interrupt configuration definition I2C_IT_ERRI I2C_IT_TCI I2C_IT_STOPI I2C_IT_NACKI I2C_IT_ADDRI I2C_IT_RXI I2C_IT_TXI I2C Memory Address Size I2C_MEMADD_SIZE_8BIT I2C_MEMADD_SIZE_16BIT I2C No-Stretch Mode I2C_NOSTRETCH_DISABLE I2C_NOSTRETCH_ENABLE I2C Own Address2 Masks I2C_OA2_NOMASK I2C_OA2_MASK01 I2C_OA2_MASK02 I2C_OA2_MASK03 I2C_OA2_MASK04 I2C_OA2_MASK05 I2C_OA2_MASK06 DOCID026526 Rev 4 373/832 UM1786 I2C_OA2_MASK07 I2C Reload End Mode I2C_RELOAD_MODE I2C_AUTOEND_MODE I2C_SOFTEND_MODE I2C Start or Stop Mode I2C_NO_STARTSTOP I2C_GENERATE_STOP I2C_GENERATE_START_READ I2C_GENERATE_START_WRITE I2C Transfer Direction I2C_DIRECTION_TRANSMIT I2C_DIRECTION_RECEIVE I2C Sequential Transfer Options I2C_NO_OPTION_FRAME I2C_FIRST_FRAME I2C_NEXT_FRAME I2C_FIRST_AND_LAST_FRAME I2C_LAST_FRAME 374/832 DOCID026526 Rev 4 UM1786 23 HAL I2C Extension Driver 23.1 I2CEx Firmware driver API description 23.1.1 I2C peripheral Extended features Comparing to other previous devices, the I2C interface for STM32F3xx devices contains the following additional features 23.1.2 Possibility to disable or enable Analog Noise Filter Use of a configured Digital Noise Filter Disable or enable wakeup from Stop mode How to use this driver This driver provides functions to configure Noise Filter and Wake Up Feature 1. 2. 3. 4. 23.1.3 Configure I2C Analog noise filter using the function HAL_I2CEx_ConfigAnalogFilter() Configure I2C Digital noise filter using the function HAL_I2CEx_ConfigDigitalFilter() Configure the enable or disable of I2C Wake Up Mode using the functions : HAL_I2CEx_EnableWakeUp() HAL_I2CEx_DisableWakeUp() Configure the enable or disable of fast mode plus driving capability using the functions : HAL_I2CEx_EnableFastModePlus() HAL_I2CEx_DisbleFastModePlus() Extended features functions This section provides functions allowing to: Configure Noise Filters Configure Wake Up Feature This section contains the following APIs: 23.1.4 HAL_I2CEx_ConfigAnalogFilter() HAL_I2CEx_ConfigDigitalFilter() HAL_I2CEx_EnableWakeUp() HAL_I2CEx_DisableWakeUp() HAL_I2CEx_EnableFastModePlus() HAL_I2CEx_DisableFastModePlus() Detailed description of functions HAL_I2CEx_ConfigAnalogFilter Function Name HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter (I2C_HandleTypeDef * hi2c, uint32_t AnalogFilter) Function Description Configure I2C Analog noise filter. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2Cx peripheral. AnalogFilter: New state of the Analog filter. DOCID026526 Rev 4 375/832 UM1786 Return values HAL: status HAL_I2CEx_ConfigDigitalFilter Function Name HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter (I2C_HandleTypeDef * hi2c, uint32_t DigitalFilter) Function Description Configure I2C Digital noise filter. Parameters Return values hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2Cx peripheral. DigitalFilter: Coefficient of digital noise filter between 0x00 and 0x0F. HAL: status HAL_I2CEx_EnableWakeUp Function Name HAL_StatusTypeDef HAL_I2CEx_EnableWakeUp (I2C_HandleTypeDef * hi2c) Function Description Enable I2C wakeup from stop mode. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2Cx peripheral. Return values HAL: status HAL_I2CEx_DisableWakeUp Function Name HAL_StatusTypeDef HAL_I2CEx_DisableWakeUp (I2C_HandleTypeDef * hi2c) Function Description Disable I2C wakeup from stop mode. Parameters hi2c: Pointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2Cx peripheral. Return values HAL: status HAL_I2CEx_EnableFastModePlus Function Name void HAL_I2CEx_EnableFastModePlus (uint32_t ConfigFastModePlus) Function Description Enable the I2C fast mode plus driving capability. Parameters ConfigFastModePlus: Selects the pin. This parameter can be one of the I2C Extended Fast Mode Plus values Return values None: HAL_I2CEx_DisableFastModePlus 376/832 Function Name void HAL_I2CEx_DisableFastModePlus (uint32_t ConfigFastModePlus) Function Description Disable the I2C fast mode plus driving capability. Parameters ConfigFastModePlus: Selects the pin. This parameter can DOCID026526 Rev 4 UM1786 be one of the I2C Extended Fast Mode Plus values Return values None: 23.2 I2CEx Firmware driver defines 23.2.1 I2CEx I2C Extended Analog Filter I2C_ANALOGFILTER_ENABLE I2C_ANALOGFILTER_DISABLE I2C Extended Fast Mode Plus I2C_FASTMODEPLUS_PB6 Enable Fast Mode Plus on PB6 I2C_FASTMODEPLUS_PB7 Enable Fast Mode Plus on PB7 I2C_FASTMODEPLUS_PB8 Enable Fast Mode Plus on PB8 I2C_FASTMODEPLUS_PB9 Enable Fast Mode Plus on PB9 I2C_FASTMODEPLUS_I2C1 Enable Fast Mode Plus on I2C1 pins I2C_FASTMODEPLUS_I2C2 Enable Fast Mode Plus on I2C2 pins DOCID026526 Rev 4 377/832 UM1786 24 HAL I2S Generic Driver 24.1 I2S Firmware driver registers structures 24.1.1 I2S_InitTypeDef Data Fields uint32_t Mode uint32_t Standard uint32_t DataFormat uint32_t MCLKOutput uint32_t AudioFreq uint32_t CPOL uint32_t ClockSource uint32_t FullDuplexMode Field Documentation 24.1.2 uint32_t I2S_InitTypeDef::Mode Specifies the I2S operating mode. This parameter can be a value of I2S_Mode uint32_t I2S_InitTypeDef::Standard Specifies the standard used for the I2S communication. This parameter can be a value of I2S_Standard uint32_t I2S_InitTypeDef::DataFormat Specifies the data format for the I2S communication. This parameter can be a value of I2S_Data_Format uint32_t I2S_InitTypeDef::MCLKOutput Specifies whether the I2S MCLK output is enabled or not. This parameter can be a value of I2S_MCLK_Output uint32_t I2S_InitTypeDef::AudioFreq Specifies the frequency selected for the I2S communication. This parameter can be a value of I2S_Audio_Frequency uint32_t I2S_InitTypeDef::CPOL Specifies the idle state of the I2S clock. This parameter can be a value of I2S_Clock_Polarity uint32_t I2S_InitTypeDef::ClockSource Specifies the I2S Clock Source. This parameter can be a value of I2S_Clock_Source uint32_t I2S_InitTypeDef::FullDuplexMode Specifies the I2S FullDuplex mode. This parameter can be a value of I2S_FullDuplex_Mode I2S_HandleTypeDef Data Fields 378/832 SPI_TypeDef * Instance I2S_InitTypeDef Init DOCID026526 Rev 4 UM1786 uint16_t * pTxBuffPtr __IO uint16_t TxXferSize __IO uint16_t TxXferCount uint16_t * pRxBuffPtr __IO uint16_t RxXferSize __IO uint16_t RxXferCount DMA_HandleTypeDef * hdmatx DMA_HandleTypeDef * hdmarx __IO HAL_LockTypeDef Lock __IO HAL_I2S_StateTypeDef State __IO uint32_t ErrorCode Field Documentation SPI_TypeDef* I2S_HandleTypeDef::Instance I2S registers base address I2S_InitTypeDef I2S_HandleTypeDef::Init I2S communication parameters uint16_t* I2S_HandleTypeDef::pTxBuffPtr Pointer to I2S Tx transfer buffer __IO uint16_t I2S_HandleTypeDef::TxXferSize I2S Tx transfer size __IO uint16_t I2S_HandleTypeDef::TxXferCount I2S Tx transfer Counter uint16_t* I2S_HandleTypeDef::pRxBuffPtr Pointer to I2S Rx transfer buffer __IO uint16_t I2S_HandleTypeDef::RxXferSize I2S Rx transfer size __IO uint16_t I2S_HandleTypeDef::RxXferCount I2S Rx transfer counter (This field is initialized at the same value as transfer size at the beginning of the transfer and decremented when a sample is received. NbSamplesReceived = RxBufferSize-RxBufferCount) DMA_HandleTypeDef* I2S_HandleTypeDef::hdmatx I2S Tx DMA handle parameters DMA_HandleTypeDef* I2S_HandleTypeDef::hdmarx I2S Rx DMA handle parameters __IO HAL_LockTypeDef I2S_HandleTypeDef::Lock I2S locking object __IO HAL_I2S_StateTypeDef I2S_HandleTypeDef::State I2S communication state __IO uint32_t I2S_HandleTypeDef::ErrorCode I2S Error code This parameter can be a value of I2S_Error 24.2 I2S Firmware driver API description 24.2.1 How to use this driver The I2S HAL driver can be used as follows: 1. 2. Declare a I2S_HandleTypeDef handle structure. Initialize the I2S low level resources by implement the HAL_I2S_MspInit() API: a. Enable the SPIx interface clock. b. I2S pins configuration: DOCID026526 Rev 4 379/832 UM1786 3. 4. Enable the clock for the I2S GPIOs. Configure these I2S pins as alternate function pull-up. c. NVIC configuration if you need to use interrupt process (HAL_I2S_Transmit_IT() and HAL_I2S_Receive_IT() APIs). Configure the I2Sx interrupt priority. Enable the NVIC I2S IRQ handle. d. DMA Configuration if you need to use DMA process (HAL_I2S_Transmit_DMA() and HAL_I2S_Receive_DMA() APIs: Declare a DMA handle structure for the Tx/Rx channel. Enable the DMAx interface clock. Configure the declared DMA handle structure with the required Tx/Rx parameters. Configure the DMA Tx/Rx Channel. Associate the initilalized DMA handle to the I2S DMA Tx/Rx handle. Configure the priority and enable the NVIC for the transfer complete interrupt on the DMA Tx/Rx Channel. Program the Mode, Standard, Data Format, MCLK Output, Audio frequency and Polarity using HAL_I2S_Init() function. The specific I2S interrupts (Transmission complete interrupt, RXNE interrupt and Error Interrupts) will be managed using the macros __HAL_I2S_ENABLE_IT() and __HAL_I2S_DISABLE_IT() inside the transmit and receive process. Make sure that either: I2S clock is configured based on SYSCLK or External clock source is configured after setting correctly the define constant EXTERNAL_CLOCK_VALUE in the stm32f3xx_hal_conf.h file. Three mode of operations are available within this driver : Polling mode IO operation Send an amount of data in blocking mode using HAL_I2S_Transmit() Receive an amount of data in blocking mode using HAL_I2S_Receive() Interrupt mode IO operation Send an amount of data in non blocking mode using HAL_I2S_Transmit_IT() At transmission end of half transfer HAL_I2S_TxHalfCpltCallback is executed and user can add his own code by customization of function pointer HAL_I2S_TxHalfCpltCallback At transmission end of transfer HAL_I2S_TxCpltCallback is executed and user can add his own code by customization of function pointer HAL_I2S_TxCpltCallback Receive an amount of data in non blocking mode using HAL_I2S_Receive_IT() At reception end of half transfer HAL_I2S_RxHalfCpltCallback is executed and user can add his own code by customization of function pointer HAL_I2S_RxHalfCpltCallback At reception end of transfer HAL_I2S_RxCpltCallback is executed and user can add his own code by customization of function pointer HAL_I2S_RxCpltCallback In case of transfer Error, HAL_I2S_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_I2S_ErrorCallback DMA mode IO operation 380/832 Send an amount of data in non blocking mode (DMA) using HAL_I2S_Transmit_DMA() DOCID026526 Rev 4 UM1786 At transmission end of half transfer HAL_I2S_TxHalfCpltCallback is executed and user can add his own code by customization of function pointer HAL_I2S_TxHalfCpltCallback At transmission end of transfer HAL_I2S_TxCpltCallback is executed and user can add his own code by customization of function pointer HAL_I2S_TxCpltCallback Receive an amount of data in non blocking mode (DMA) using HAL_I2S_Receive_DMA() At reception end of half transfer HAL_I2S_RxHalfCpltCallback is executed and user can add his own code by customization of function pointer HAL_I2S_RxHalfCpltCallback At reception end of transfer HAL_I2S_RxCpltCallback is executed and user can add his own code by customization of function pointer HAL_I2S_RxCpltCallback In case of transfer Error, HAL_I2S_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_I2S_ErrorCallback Pause the DMA Transfer using HAL_I2S_DMAPause() Resume the DMA Transfer using HAL_I2S_DMAResume() Stop the DMA Transfer using HAL_I2S_DMAStop() I2S HAL driver macros list Below the list of most used macros in I2S HAL driver. __HAL_I2S_ENABLE: Enable the specified SPI peripheral (in I2S mode) __HAL_I2S_DISABLE: Disable the specified SPI peripheral (in I2S mode) __HAL_I2S_ENABLE_IT : Enable the specified I2S interrupts __HAL_I2S_DISABLE_IT : Disable the specified I2S interrupts __HAL_I2S_GET_FLAG: Check whether the specified I2S flag is set or not You can refer to the I2S HAL driver header file for more useful macros 24.2.2 Initialization and de-initialization functions This subsection provides a set of functions allowing to initialize and de-initialiaze the I2Sx peripheral in simplex mode: User must Implement HAL_I2S_MspInit() function in which he configures all related peripherals resources (CLOCK, GPIO, DMA, IT and NVIC ). Call the function HAL_I2S_Init() to configure the selected device with the selected configuration: Mode Standard Data Format MCLK Output Audio frequency Polarity Full duplex mode Call the function HAL_I2S_DeInit() to restore the default configuration of the selected I2Sx periperal. This section contains the following APIs: HAL_I2S_Init() HAL_I2S_DeInit() DOCID026526 Rev 4 381/832 UM1786 24.2.3 HAL_I2S_MspInit() HAL_I2S_MspDeInit() IO operation functions This subsection provides a set of functions allowing to manage the I2S data transfers. 1. 2. 3. 4. 5. There are two modes of transfer: Blocking mode : The communication is performed in the polling mode. The status of all data processing is returned by the same function after finishing transfer. No-Blocking mode : The communication is performed using Interrupts or DMA. These functions return the status of the transfer startup. The end of the data processing will be indicated through the dedicated I2S IRQ when using Interrupt mode or the DMA IRQ when using DMA mode. Blocking mode functions are : HAL_I2S_Transmit() HAL_I2S_Receive() No-Blocking mode functions with Interrupt are : HAL_I2S_Transmit_IT() HAL_I2S_Receive_IT() No-Blocking mode functions with DMA are : HAL_I2S_Transmit_DMA() HAL_I2S_Receive_DMA() A set of Transfer Complete Callbacks are provided in non Blocking mode: HAL_I2S_TxCpltCallback() HAL_I2S_RxCpltCallback() HAL_I2S_ErrorCallback() This section contains the following APIs: 24.2.4 HAL_I2S_Transmit() HAL_I2S_Receive() HAL_I2S_Transmit_IT() HAL_I2S_Receive_IT() HAL_I2S_Transmit_DMA() HAL_I2S_Receive_DMA() HAL_I2S_DMAPause() HAL_I2S_DMAResume() HAL_I2S_DMAStop() HAL_I2S_IRQHandler() HAL_I2S_TxHalfCpltCallback() HAL_I2S_TxCpltCallback() HAL_I2S_RxHalfCpltCallback() HAL_I2S_RxCpltCallback() HAL_I2S_ErrorCallback() HAL_I2S_FullDuplex_IRQHandler() HAL_I2S_TxRxCpltCallback() Peripheral State and Errors functions This subsection permits to get in run-time the status of the peripheral and the data flow. This section contains the following APIs: 382/832 HAL_I2S_GetState() HAL_I2S_GetError() DOCID026526 Rev 4 UM1786 24.2.5 HAL_I2S_DMAPause() HAL_I2S_DMAResume() HAL_I2S_DMAStop() Detailed description of functions HAL_I2S_Init Function Name HAL_StatusTypeDef HAL_I2S_Init (I2S_HandleTypeDef * hi2s) Function Description Initializes the I2S according to the specified parameters in the I2S_InitTypeDef and create the associated handle. Parameters Return values hi2s: pointer to a I2S_HandleTypeDef structure that contains the configuration information for I2S module hi2s: I2S handle HAL: status HAL: status HAL_I2S_DeInit Function Name HAL_StatusTypeDef HAL_I2S_DeInit (I2S_HandleTypeDef * hi2s) Function Description DeInitializes the I2S peripheral. Parameters hi2s: pointer to a I2S_HandleTypeDef structure that contains the configuration information for I2S module Return values HAL: status HAL_I2S_MspInit Function Name void HAL_I2S_MspInit (I2S_HandleTypeDef * hi2s) Function Description I2S MSP Init. Parameters hi2s: pointer to a I2S_HandleTypeDef structure that contains the configuration information for I2S module Return values None: HAL_I2S_MspDeInit Function Name void HAL_I2S_MspDeInit (I2S_HandleTypeDef * hi2s) Function Description I2S MSP DeInit. Parameters hi2s: pointer to a I2S_HandleTypeDef structure that contains the configuration information for I2S module Return values None: HAL_I2S_Transmit Function Name HAL_StatusTypeDef HAL_I2S_Transmit (I2S_HandleTypeDef * hi2s, uint16_t * pData, uint16_t Size, uint32_t Timeout) Function Description Transmit an amount of data in blocking mode. DOCID026526 Rev 4 383/832 UM1786 Parameters hi2s: pointer to a I2S_HandleTypeDef structure that contains the configuration information for I2S module pData: a 16-bit pointer to data buffer. Size: number of data sample to be sent: Timeout: Timeout duration Return values HAL: status Notes When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S configuration phase, the Size parameter means the number of 16-bit data length in the transaction and when a 24-bit data frame or a 32-bit data frame is selected the Size parameter means the number of 16-bit data length. The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization between Master and Slave(example: audio streaming). HAL_I2S_Receive Function Name HAL_StatusTypeDef HAL_I2S_Receive (I2S_HandleTypeDef * hi2s, uint16_t * pData, uint16_t Size, uint32_t Timeout) Function Description Receive an amount of data in blocking mode. Parameters hi2s: pointer to a I2S_HandleTypeDef structure that contains the configuration information for I2S module pData: a 16-bit pointer to data buffer. Size: number of data sample to be sent: Timeout: Timeout duration Return values HAL: status Notes When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S configuration phase, the Size parameter means the number of 16-bit data length in the transaction and when a 24-bit data frame or a 32-bit data frame is selected the Size parameter means the number of 16-bit data length. The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization between Master and Slave(example: audio streaming). In I2S Master Receiver mode, just after enabling the peripheral the clock will be generate in continouse way and as the I2S is not disabled at the end of the I2S transaction. HAL_I2S_Transmit_IT Function Name HAL_StatusTypeDef HAL_I2S_Transmit_IT (I2S_HandleTypeDef * hi2s, uint16_t * pData, uint16_t Size) Function Description Transmit an amount of data in non-blocking mode with Interrupt. Parameters 384/832 hi2s: pointer to a I2S_HandleTypeDef structure that contains the configuration information for I2S module pData: a 16-bit pointer to data buffer. Size: number of data sample to be sent: DOCID026526 Rev 4 UM1786 Return values HAL: status Notes When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S configuration phase, the Size parameter means the number of 16-bit data length in the transaction and when a 24-bit data frame or a 32-bit data frame is selected the Size parameter means the number of 16-bit data length. The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization between Master and Slave(example: audio streaming). HAL_I2S_Receive_IT Function Name HAL_StatusTypeDef HAL_I2S_Receive_IT (I2S_HandleTypeDef * hi2s, uint16_t * pData, uint16_t Size) Function Description Receive an amount of data in non-blocking mode with Interrupt. Parameters hi2s: pointer to a I2S_HandleTypeDef structure that contains the configuration information for I2S module pData: a 16-bit pointer to the Receive data buffer. Size: number of data sample to be sent: Return values HAL: status Notes When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S configuration phase, the Size parameter means the number of 16-bit data length in the transaction and when a 24-bit data frame or a 32-bit data frame is selected the Size parameter means the number of 16-bit data length. The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization between Master and Slave(example: audio streaming). It is recommended to use DMA for the I2S receiver to avoid de-synchronisation between Master and Slave otherwise the I2S interrupt should be optimized. HAL_I2S_IRQHandler Function Name void HAL_I2S_IRQHandler (I2S_HandleTypeDef * hi2s) Function Description This function handles I2S interrupt request. Parameters hi2s: pointer to a I2S_HandleTypeDef structure that contains the configuration information for I2S module Return values None: HAL_I2S_Transmit_DMA Function Name HAL_StatusTypeDef HAL_I2S_Transmit_DMA (I2S_HandleTypeDef * hi2s, uint16_t * pData, uint16_t Size) Function Description Transmit an amount of data in non-blocking mode with DMA. Parameters hi2s: pointer to a I2S_HandleTypeDef structure that contains the configuration information for I2S module DOCID026526 Rev 4 385/832 UM1786 pData: a 16-bit pointer to the Transmit data buffer. Size: number of data sample to be sent: Return values HAL: status Notes When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S configuration phase, the Size parameter means the number of 16-bit data length in the transaction and when a 24-bit data frame or a 32-bit data frame is selected the Size parameter means the number of 16-bit data length. The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization between Master and Slave(example: audio streaming). HAL_I2S_Receive_DMA Function Name HAL_StatusTypeDef HAL_I2S_Receive_DMA (I2S_HandleTypeDef * hi2s, uint16_t * pData, uint16_t Size) Function Description Receive an amount of data in non-blocking mode with DMA. Parameters hi2s: pointer to a I2S_HandleTypeDef structure that contains the configuration information for I2S module pData: a 16-bit pointer to the Receive data buffer. Size: number of data sample to be sent: Return values HAL: status Notes When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S configuration phase, the Size parameter means the number of 16-bit data length in the transaction and when a 24-bit data frame or a 32-bit data frame is selected the Size parameter means the number of 16-bit data length. The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization between Master and Slave(example: audio streaming). HAL_I2S_DMAPause Function Name HAL_StatusTypeDef HAL_I2S_DMAPause (I2S_HandleTypeDef * hi2s) Function Description Pauses the audio stream playing from the Media. Parameters hi2s: pointer to a I2S_HandleTypeDef structure that contains the configuration information for I2S module Return values HAL: status HAL_I2S_DMAResume 386/832 Function Name HAL_StatusTypeDef HAL_I2S_DMAResume (I2S_HandleTypeDef * hi2s) Function Description Resumes the audio stream playing from the Media. Parameters hi2s: pointer to a I2S_HandleTypeDef structure that contains DOCID026526 Rev 4 UM1786 the configuration information for I2S module Return values HAL: status HAL_I2S_DMAStop Function Name HAL_StatusTypeDef HAL_I2S_DMAStop (I2S_HandleTypeDef * hi2s) Function Description Resumes the audio stream playing from the Media. Parameters hi2s: pointer to a I2S_HandleTypeDef structure that contains the configuration information for I2S module Return values HAL: status HAL_I2S_TxHalfCpltCallback Function Name void HAL_I2S_TxHalfCpltCallback (I2S_HandleTypeDef * hi2s) Function Description Tx Transfer Half completed callbacks. Parameters hi2s: pointer to a I2S_HandleTypeDef structure that contains the configuration information for I2S module Return values None: HAL_I2S_TxCpltCallback Function Name void HAL_I2S_TxCpltCallback (I2S_HandleTypeDef * hi2s) Function Description Tx Transfer completed callbacks. Parameters hi2s: pointer to a I2S_HandleTypeDef structure that contains the configuration information for I2S module Return values None: HAL_I2S_RxHalfCpltCallback Function Name void HAL_I2S_RxHalfCpltCallback (I2S_HandleTypeDef * hi2s) Function Description Rx Transfer half completed callbacks. Parameters hi2s: pointer to a I2S_HandleTypeDef structure that contains the configuration information for I2S module Return values None: HAL_I2S_RxCpltCallback Function Name void HAL_I2S_RxCpltCallback (I2S_HandleTypeDef * hi2s) Function Description Rx Transfer completed callbacks. Parameters hi2s: pointer to a I2S_HandleTypeDef structure that contains the configuration information for I2S module Return values None: DOCID026526 Rev 4 387/832 UM1786 HAL_I2S_ErrorCallback Function Name void HAL_I2S_ErrorCallback (I2S_HandleTypeDef * hi2s) Function Description I2S error callbacks. Parameters hi2s: pointer to a I2S_HandleTypeDef structure that contains the configuration information for I2S module Return values None: HAL_I2S_GetState Function Name HAL_I2S_StateTypeDef HAL_I2S_GetState (I2S_HandleTypeDef * hi2s) Function Description Return the I2S state. Parameters hi2s: pointer to a I2S_HandleTypeDef structure that contains the configuration information for I2S module Return values HAL: state HAL_I2S_GetError Function Name uint32_t HAL_I2S_GetError (I2S_HandleTypeDef * hi2s) Function Description Return the I2S error code. Parameters hi2s: pointer to a I2S_HandleTypeDef structure that contains the configuration information for I2S module Return values I2S: Error Code 24.3 I2S Firmware driver defines 24.3.1 I2S I2S Audio Frequency I2S_AUDIOFREQ_192K I2S_AUDIOFREQ_96K I2S_AUDIOFREQ_48K I2S_AUDIOFREQ_44K I2S_AUDIOFREQ_32K I2S_AUDIOFREQ_22K I2S_AUDIOFREQ_16K I2S_AUDIOFREQ_11K I2S_AUDIOFREQ_8K I2S_AUDIOFREQ_DEFAULT IS_I2S_AUDIO_FREQ I2S Clock Polarity I2S_CPOL_LOW 388/832 DOCID026526 Rev 4 UM1786 I2S_CPOL_HIGH IS_I2S_CPOL I2S Clock Source I2S_CLOCK_EXTERNAL I2S_CLOCK_SYSCLK IS_I2S_CLOCKSOURCE I2S Data Format I2S_DATAFORMAT_16B I2S_DATAFORMAT_16B_EXTENDED I2S_DATAFORMAT_24B I2S_DATAFORMAT_32B IS_I2S_DATA_FORMAT I2S Error HAL_I2S_ERROR_NONE No error HAL_I2S_ERROR_TIMEOUT Timeout error HAL_I2S_ERROR_OVR OVR error HAL_I2S_ERROR_UDR UDR error HAL_I2S_ERROR_DMA DMA transfer error HAL_I2S_ERROR_UNKNOW Unknow Error error I2S Exported Macros __HAL_I2S_RESET_HANDLE_STATE Description: Reset I2S handle state. Parameters: __HANDLE__: I2S handle. Return value: __HAL_I2S_ENABLE None Description: Enable or disable the specified SPI peripheral (in I2S mode). Parameters: __HANDLE__: specifies the I2S Handle. Return value: None __HAL_I2S_DISABLE __HAL_I2S_ENABLE_IT Description: Enable or disable the specified I2S interrupts. DOCID026526 Rev 4 389/832 UM1786 Parameters: __HANDLE__: specifies the I2S Handle. __INTERRUPT__: specifies the interrupt source to enable or disable. This parameter can be one of the following values: I2S_IT_TXE: Tx buffer empty interrupt enable I2S_IT_RXNE: RX buffer not empty interrupt enable I2S_IT_ERR: Error interrupt enable Return value: None __HAL_I2S_DISABLE_IT __HAL_I2S_GET_IT_SOURCE Description: Checks if the specified I2S interrupt source is enabled or disabled. Parameters: __HANDLE__: specifies the I2S Handle. This parameter can be I2S where x: 1, 2, or 3 to select the I2S peripheral. __INTERRUPT__: specifies the I2S interrupt source to check. This parameter can be one of the following values: I2S_IT_TXE: Tx buffer empty interrupt enable I2S_IT_RXNE: RX buffer not empty interrupt enable I2S_IT_ERR: Error interrupt enable Return value: __HAL_I2S_GET_FLAG The: new state of __IT__ (TRUE or FALSE). Description: Checks whether the specified I2S flag is set or not. Parameters: 390/832 __HANDLE__: specifies the I2S Handle. __FLAG__: specifies the flag to check. This parameter can be one of the following values: I2S_FLAG_RXNE: Receive buffer not empty flag I2S_FLAG_TXE: Transmit buffer empty flag I2S_FLAG_UDR: Underrun flag I2S_FLAG_OVR: Overrun flag I2S_FLAG_FRE: Frame error flag I2S_FLAG_CHSIDE: Channel Side flag DOCID026526 Rev 4 UM1786 I2S_FLAG_BSY: Busy flag Return value: __HAL_I2S_CLEAR_OVRFLAG The: new state of __FLAG__ (TRUE or FALSE). Description: Clears the I2S OVR pending flag. Parameters: __HANDLE__: specifies the I2S Handle. Return value: __HAL_I2S_CLEAR_UDRFLAG None Description: Clears the I2S UDR pending flag. Parameters: __HANDLE__: specifies the I2S Handle. Return value: None I2S Flag definition I2S_FLAG_TXE I2S_FLAG_RXNE I2S_FLAG_UDR I2S_FLAG_OVR I2S_FLAG_FRE I2S_FLAG_CHSIDE I2S_FLAG_BSY I2S Full Duplex Mode I2S_FULLDUPLEXMODE_DISABLE I2S_FULLDUPLEXMODE_ENABLE IS_I2S_FULLDUPLEX_MODE I2S Interrupt configuration definition I2S_IT_TXE I2S_IT_RXNE I2S_IT_ERR I2S MCLK Output I2S_MCLKOUTPUT_ENABLE I2S_MCLKOUTPUT_DISABLE IS_I2S_MCLK_OUTPUT I2S Mode DOCID026526 Rev 4 391/832 UM1786 I2S_MODE_SLAVE_TX I2S_MODE_SLAVE_RX I2S_MODE_MASTER_TX I2S_MODE_MASTER_RX IS_I2S_MODE I2S Standard I2S_STANDARD_PHILIPS I2S_STANDARD_MSB I2S_STANDARD_LSB I2S_STANDARD_PCM_SHORT I2S_STANDARD_PCM_LONG IS_I2S_STANDARD 392/832 DOCID026526 Rev 4 UM1786 25 HAL I2S Extension Driver 25.1 I2SEx Firmware driver API description 25.1.1 I2S Extended features 1. 2. 3. 25.1.2 In I2S full duplex mode, each SPI peripheral is able to manage sending and receiving data simultaneously using two data lines. Each SPI peripheral has an extended block called I2Sxext ie. I2S2ext for SPI2 and I2S3ext for SPI3). The Extended block is not a full SPI IP, it is used only as I2S slave to implement full duplex mode. The Extended block uses the same clock sources as its master. Both I2Sx and I2Sx_ext can be configured as transmitters or receivers. Only I2Sx can deliver SCK and WS to I2Sx_ext in full duplex mode, where I2Sx can be I2S2 or I2S3. How to use this driver Three mode of operations are available within this driver : Polling mode IO operation Send and receive in the same time an amount of data in blocking mode using HAL_I2S_TransmitReceive() Interrupt mode IO operation Send and receive in the same time an amount of data in non blocking mode using HAL_I2S_TransmitReceive_IT() At transmission end of half transfer HAL_I2S_TxHalfCpltCallback is executed and user can add his own code by customization of function pointer HAL_I2S_TxHalfCpltCallback At transmission end of transfer HAL_I2S_TxCpltCallback is executed and user can add his own code by customization of function pointer HAL_I2S_TxCpltCallback At reception end of half transfer HAL_I2S_RxHalfCpltCallback is executed and user can add his own code by customization of function pointer HAL_I2S_RxHalfCpltCallback At reception end of transfer HAL_I2S_RxCpltCallback is executed and user can add his own code by customization of function pointer HAL_I2S_RxCpltCallback In case of transfer Error, HAL_I2S_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_I2S_ErrorCallback DMA mode IO operation Send and receive an amount of data in non blocking mode (DMA) using HAL_I2S_TransmitReceive_DMA() At transmission end of half transfer HAL_I2S_TxHalfCpltCallback is executed and user can add his own code by customization of function pointer HAL_I2S_TxHalfCpltCallback DOCID026526 Rev 4 393/832 UM1786 25.1.3 At transmission end of transfer HAL_I2S_TxCpltCallback is executed and user can add his own code by customization of function pointer HAL_I2S_TxCpltCallback At reception end of half transfer HAL_I2S_RxHalfCpltCallback is executed and user can add his own code by customization of function pointer HAL_I2S_RxHalfCpltCallback At reception end of transfer HAL_I2S_RxCpltCallback is executed and user can add his own code by customization of function pointer HAL_I2S_RxCpltCallback In case of transfer Error, HAL_I2S_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_I2S_ErrorCallback Pause the DMA Transfer using HAL_I2S_DMAPause() Resume the DMA Transfer using HAL_I2S_DMAResume() Stop the DMA Transfer using HAL_I2S_DMAStop() Extended features Functions This subsection provides a set of functions allowing to manage the I2S data transfers. 1. 2. 3. 4. 5. There is two mode of transfer: Blocking mode: The communication is performed in the polling mode. The status of all data processing is returned by the same function after finishing transfer. No-Blocking mode: The communication is performed using Interrupts or DMA. These functions return the status of the transfer startup. The end of the data processing will be indicated through the dedicated I2S IRQ when using Interrupt mode or the DMA IRQ when using DMA mode. Blocking mode functions are : HAL_I2S_TransmitReceive() No-Blocking mode functions with Interrupt are: HAL_I2S_TransmitReceive_IT() HAL_I2SFullDuplex_IRQHandler() No-Blocking mode functions with DMA are: HAL_I2S_TransmitReceive_DMA() A set of Transfer Complete Callbacks are provided in No_Blocking mode: HAL_I2S_TxRxCpltCallback() HAL_I2S_TxRxErrorCallback() This section contains the following APIs: 25.1.4 HAL_I2SEx_TransmitReceive() HAL_I2SEx_TransmitReceive_IT() HAL_I2SEx_TransmitReceive_DMA() Detailed description of functions HAL_I2SEx_TransmitReceive 394/832 Function Name HAL_StatusTypeDef HAL_I2SEx_TransmitReceive (I2S_HandleTypeDef * hi2s, uint16_t * pTxData, uint16_t * pRxData, uint16_t Size, uint32_t Timeout) Function Description Full-Duplex Transmit/Receive data in blocking mode. Parameters hi2s: I2S handle pTxData: a 16-bit pointer to the Transmit data buffer. pRxData: a 16-bit pointer to the Receive data buffer. Size: number of data sample to be sent: Timeout: Timeout duration DOCID026526 Rev 4 UM1786 Return values HAL: status Notes When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S configuration phase, the Size parameter means the number of 16-bit data length in the transaction and when a 24-bit data frame or a 32-bit data frame is selected the Size parameter means the number of 16-bit data length. The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization between Master and Slave(example: audio streaming). HAL_I2SEx_TransmitReceive_IT Function Name HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_IT (I2S_HandleTypeDef * hi2s, uint16_t * pTxData, uint16_t * pRxData, uint16_t Size) Function Description Full-Duplex Transmit/Receive data in non-blocking mode using Interrupt. Parameters hi2s: I2S handle pTxData: a 16-bit pointer to the Transmit data buffer. pRxData: a 16-bit pointer to the Receive data buffer. Size: number of data sample to be sent: Return values HAL: status Notes When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S configuration phase, the Size parameter means the number of 16-bit data length in the transaction and when a 24-bit data frame or a 32-bit data frame is selected the Size parameter means the number of 16-bit data length. The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization between Master and Slave(example: audio streaming). HAL_I2SEx_TransmitReceive_DMA Function Name HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_DMA (I2S_HandleTypeDef * hi2s, uint16_t * pTxData, uint16_t * pRxData, uint16_t Size) Function Description Full-Duplex Transmit/Receive data in non-blocking mode using DMA. Parameters hi2s: I2S handle pTxData: a 16-bit pointer to the Transmit data buffer. pRxData: a 16-bit pointer to the Receive data buffer. Size: number of data sample to be sent: Return values HAL: status Notes When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S configuration phase, the Size parameter means the number of 16-bit data length in the transaction and when a 24-bit data frame or a 32-bit data frame is selected the Size parameter means the number of DOCID026526 Rev 4 395/832 UM1786 16-bit data length. The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization between Master and Slave(example: audio streaming). HAL_I2S_FullDuplex_IRQHandler Function Name void HAL_I2S_FullDuplex_IRQHandler (I2S_HandleTypeDef * hi2s) Function Description This function handles I2S/I2Sext interrupt requests in full-duplex mode. Parameters hi2s: I2S handle Return values HAL: status HAL_I2S_TxRxCpltCallback Function Name void HAL_I2S_TxRxCpltCallback (I2S_HandleTypeDef * hi2s) Function Description Tx and Rx Transfer completed callbacks. Parameters hi2s: I2S handle Return values None: HAL_I2S_DMAPause Function Name HAL_StatusTypeDef HAL_I2S_DMAPause (I2S_HandleTypeDef * hi2s) Function Description Pauses the audio stream playing from the Media. Parameters hi2s: : I2S handle Return values None: HAL_I2S_DMAResume Function Name HAL_StatusTypeDef HAL_I2S_DMAResume (I2S_HandleTypeDef * hi2s) Function Description Resumes the audio stream playing from the Media. Parameters hi2s: : I2S handle Return values None: HAL_I2S_DMAStop 396/832 Function Name HAL_StatusTypeDef HAL_I2S_DMAStop (I2S_HandleTypeDef * hi2s) Function Description Resumes the audio stream playing from the Media. Parameters hi2s: I2S handle Return values None: DOCID026526 Rev 4 UM1786 25.2 I2SEx Firmware driver defines 25.2.1 I2SEx I2S Extended Exported Macros I2SxEXT Description: __HAL_I2SEXT_ENABLE Enable or disable the specified I2SExt peripheral. Parameters: __HANDLE__: specifies the I2S Handle. Return value: None __HAL_I2SEXT_DISABLE __HAL_I2SEXT_ENABLE_IT Description: Enable or disable the specified I2SExt interrupts. Parameters: __HANDLE__: specifies the I2S Handle. __INTERRUPT__: specifies the interrupt source to enable or disable. This parameter can be one of the following values: I2S_IT_TXE: Tx buffer empty interrupt enable I2S_IT_RXNE: RX buffer not empty interrupt enable I2S_IT_ERR: Error interrupt enable Return value: None __HAL_I2SEXT_DISABLE_IT __HAL_I2SEXT_GET_IT_SOURCE Description: Checks if the specified I2SExt interrupt source is enabled or disabled. Parameters: __HANDLE__: specifies the I2S Handle. This parameter can be I2S where x: 1, 2, or 3 to select the I2S peripheral. __INTERRUPT__: specifies the I2S interrupt source to check. This parameter can be one of the following values: I2S_IT_TXE: Tx buffer empty interrupt enable I2S_IT_RXNE: RX buffer not empty interrupt enable DOCID026526 Rev 4 397/832 UM1786 I2S_IT_ERR: Error interrupt enable Return value: __HAL_I2SEXT_GET_FLAG The: new state of __IT__ (TRUE or FALSE). Description: Checks whether the specified I2SExt flag is set or not. Parameters: __HANDLE__: specifies the I2S Handle. __FLAG__: specifies the flag to check. This parameter can be one of the following values: I2S_FLAG_RXNE: Receive buffer not empty flag I2S_FLAG_TXE: Transmit buffer empty flag I2S_FLAG_UDR: Underrun flag I2S_FLAG_OVR: Overrun flag I2S_FLAG_FRE: Frame error flag I2S_FLAG_CHSIDE: Channel Side flag I2S_FLAG_BSY: Busy flag Return value: __HAL_I2SEXT_CLEAR_OVRFLAG The: new state of __FLAG__ (TRUE or FALSE). Description: Clears the I2SExt OVR pending flag. Parameters: __HANDLE__: specifies the I2S Handle. Return value: __HAL_I2SEXT_CLEAR_UDRFLAG None Description: Clears the I2SExt UDR pending flag. Parameters: __HANDLE__: specifies the I2S Handle. Return value: 398/832 None DOCID026526 Rev 4 UM1786 26 HAL IRDA Generic Driver 26.1 IRDA Firmware driver registers structures 26.1.1 IRDA_InitTypeDef Data Fields uint32_t BaudRate uint32_t WordLength uint32_t Parity uint32_t Mode uint8_t Prescaler uint16_t PowerMode Field Documentation 26.1.2 uint32_t IRDA_InitTypeDef::BaudRate This member configures the IRDA communication baud rate. The baud rate register is computed using the following formula: Baud Rate Register = ((PCLKx) / ((hirda>Init.BaudRate))) uint32_t IRDA_InitTypeDef::WordLength Specifies the number of data bits transmitted or received in a frame. This parameter can be a value of IRDAEx_Word_Length uint32_t IRDA_InitTypeDef::Parity Specifies the parity mode. This parameter can be a value of IRDA_Parity Note:When parity is enabled, the computed parity is inserted at the MSB position of the transmitted data (9th bit when the word length is set to 9 data bits; 8th bit when the word length is set to 8 data bits). uint32_t IRDA_InitTypeDef::Mode Specifies whether the Receive or Transmit mode is enabled or disabled. This parameter can be a value of IRDA_Transfer_Mode uint8_t IRDA_InitTypeDef::Prescaler Specifies the Prescaler value for dividing the UART/USART source clock to achieve low-power frequency. Note:Prescaler value 0 is forbidden uint16_t IRDA_InitTypeDef::PowerMode Specifies the IRDA power mode. This parameter can be a value of IRDA_Low_Power IRDA_HandleTypeDef Data Fields USART_TypeDef * Instance IRDA_InitTypeDef Init uint8_t * pTxBuffPtr uint16_t TxXferSize DOCID026526 Rev 4 399/832 UM1786 uint16_t TxXferCount uint8_t * pRxBuffPtr uint16_t RxXferSize uint16_t RxXferCount uint16_t Mask DMA_HandleTypeDef * hdmatx DMA_HandleTypeDef * hdmarx HAL_LockTypeDef Lock __IO HAL_IRDA_StateTypeDef gState __IO HAL_IRDA_StateTypeDef RxState __IO uint32_t ErrorCode Field Documentation USART_TypeDef* IRDA_HandleTypeDef::Instance USART registers base address IRDA_InitTypeDef IRDA_HandleTypeDef::Init IRDA communication parameters uint8_t* IRDA_HandleTypeDef::pTxBuffPtr Pointer to IRDA Tx transfer Buffer uint16_t IRDA_HandleTypeDef::TxXferSize IRDA Tx Transfer size uint16_t IRDA_HandleTypeDef::TxXferCount IRDA Tx Transfer Counter uint8_t* IRDA_HandleTypeDef::pRxBuffPtr Pointer to IRDA Rx transfer Buffer uint16_t IRDA_HandleTypeDef::RxXferSize IRDA Rx Transfer size uint16_t IRDA_HandleTypeDef::RxXferCount IRDA Rx Transfer Counter uint16_t IRDA_HandleTypeDef::Mask USART RX RDR register mask DMA_HandleTypeDef* IRDA_HandleTypeDef::hdmatx IRDA Tx DMA Handle parameters DMA_HandleTypeDef* IRDA_HandleTypeDef::hdmarx IRDA Rx DMA Handle parameters HAL_LockTypeDef IRDA_HandleTypeDef::Lock Locking object __IO HAL_IRDA_StateTypeDef IRDA_HandleTypeDef::gState IRDA state information related to global Handle management and also related to Tx operations. This parameter can be a value of HAL_IRDA_StateTypeDef __IO HAL_IRDA_StateTypeDef IRDA_HandleTypeDef::RxState IRDA state information related to Rx operations. This parameter can be a value of HAL_IRDA_StateTypeDef __IO uint32_t IRDA_HandleTypeDef::ErrorCode IRDA Error code This parameter can be a value of IRDA_Error 26.2 IRDA Firmware driver API description 26.2.1 How to use this driver The IRDA HAL driver can be used as follows: 400/832 DOCID026526 Rev 4 UM1786 1. 2. 3. 4. 5. Declare a IRDA_HandleTypeDef handle structure (eg. IRDA_HandleTypeDef hirda). Initialize the IRDA low level resources by implementing the HAL_IRDA_MspInit() API in setting the associated USART or UART in IRDA mode: Enable the USARTx/UARTx interface clock. USARTx/UARTx pins configuration: Enable the clock for the USARTx/UARTx GPIOs. Configure these USARTx/UARTx pins (TX as alternate function pull-up, RX as alternate function Input). NVIC configuration if you need to use interrupt process (HAL_IRDA_Transmit_IT() and HAL_IRDA_Receive_IT() APIs): Configure the USARTx/UARTx interrupt priority. Enable the NVIC USARTx/UARTx IRQ handle. The specific IRDA interrupts (Transmission complete interrupt, RXNE interrupt and Error Interrupts) will be managed using the macros __HAL_IRDA_ENABLE_IT() and __HAL_IRDA_DISABLE_IT() inside the transmit and receive process. DMA Configuration if you need to use DMA process (HAL_IRDA_Transmit_DMA() and HAL_IRDA_Receive_DMA() APIs): Declare a DMA handle structure for the Tx/Rx channel. Enable the DMAx interface clock. Configure the declared DMA handle structure with the required Tx/Rx parameters. Configure the DMA Tx/Rx channel. Associate the initialized DMA handle to the IRDA DMA Tx/Rx handle. Configure the priority and enable the NVIC for the transfer complete interrupt on the DMA Tx/Rx channel. Program the Baud Rate, Word Length and Parity and Mode(Receiver/Transmitter), the normal or low power mode and the clock prescaler in the hirda handle Init structure. Initialize the IRDA registers by calling the HAL_IRDA_Init() API: This API configures also the low level Hardware (GPIO, CLOCK, CORTEX...etc) by calling the customized HAL_IRDA_MspInit() API. Three operation modes are available within this driver : Polling mode IO operation Send an amount of data in blocking mode using HAL_IRDA_Transmit() Receive an amount of data in blocking mode using HAL_IRDA_Receive() Interrupt mode IO operation Send an amount of data in non-blocking mode using HAL_IRDA_Transmit_IT() At transmission end of transfer HAL_IRDA_TxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_IRDA_TxCpltCallback() Receive an amount of data in non-blocking mode using HAL_IRDA_Receive_IT() At reception end of transfer HAL_IRDA_RxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_IRDA_RxCpltCallback() In case of transfer Error, HAL_IRDA_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_IRDA_ErrorCallback() DOCID026526 Rev 4 401/832 UM1786 DMA mode IO operation Send an amount of data in non-blocking mode (DMA) using HAL_IRDA_Transmit_DMA() At transmission half of transfer HAL_IRDA_TxHalfCpltCallback() is executed and user can add his own code by customization of function pointer HAL_IRDA_TxHalfCpltCallback() At transmission end of transfer HAL_IRDA_TxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_IRDA_TxCpltCallback() Receive an amount of data in non-blocking mode (DMA) using HAL_IRDA_Receive_DMA() At reception half of transfer HAL_IRDA_RxHalfCpltCallback() is executed and user can add his own code by customization of function pointer HAL_IRDA_RxHalfCpltCallback() At reception end of transfer HAL_IRDA_RxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_IRDA_RxCpltCallback() In case of transfer Error, HAL_IRDA_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_IRDA_ErrorCallback() IRDA HAL driver macros list Below the list of most used macros in IRDA HAL driver. __HAL_IRDA_ENABLE: Enable the IRDA peripheral __HAL_IRDA_DISABLE: Disable the IRDA peripheral __HAL_IRDA_GET_FLAG : Check whether the specified IRDA flag is set or not __HAL_IRDA_CLEAR_FLAG : Clear the specified IRDA pending flag __HAL_IRDA_ENABLE_IT: Enable the specified IRDA interrupt __HAL_IRDA_DISABLE_IT: Disable the specified IRDA interrupt __HAL_IRDA_GET_IT_SOURCE: Check whether or not the specified IRDA interrupt is enabled You can refer to the IRDA HAL driver header file for more useful macros 26.2.2 Initialization and Configuration functions This subsection provides a set of functions allowing to initialize the USARTx in asynchronous IRDA mode. For the asynchronous mode only these parameters can be configured: Baud Rate Word Length Parity Power mode Prescaler setting Receiver/transmitter modes The HAL_IRDA_Init() API follows the USART asynchronous configuration procedures (details for the procedures are available in reference manual). This section contains the following APIs: 402/832 DOCID026526 Rev 4 UM1786 26.2.3 HAL_IRDA_Init() HAL_IRDA_DeInit() HAL_IRDA_MspInit() HAL_IRDA_MspDeInit() IO operation functions This subsection provides a set of functions allowing to manage the IRDA data transfers. IrDA is a half duplex communication protocol. If the Transmitter is busy, any data on the IrDA receive line will be ignored by the IrDA decoder and if the Receiver is busy, data on the TX from the USART to IrDA will not be encoded by IrDA. While receiving data, transmission should be avoided as the data to be transmitted could be corrupted. 1. 2. 3. 4. 5. There are two modes of transfer: Blocking mode: the communication is performed in polling mode. The HAL status of all data processing is returned by the same function after finishing transfer. No-Blocking mode: the communication is performed using Interrupts or DMA, these API's return the HAL status. The end of the data processing will be indicated through the dedicated IRDA IRQ when using Interrupt mode or the DMA IRQ when using DMA mode. The HAL_IRDA_TxCpltCallback(), HAL_IRDA_RxCpltCallback() user callbacks will be executed respectively at the end of the Transmit or Receive process The HAL_IRDA_ErrorCallback() user callback will be executed when a communication error is detected Blocking mode APIs are : HAL_IRDA_Transmit() HAL_IRDA_Receive() Non Blocking mode APIs with Interrupt are : HAL_IRDA_Transmit_IT() HAL_IRDA_Receive_IT() HAL_IRDA_IRQHandler() Non Blocking mode functions with DMA are : HAL_IRDA_Transmit_DMA() HAL_IRDA_Receive_DMA() HAL_IRDA_DMAPause() HAL_IRDA_DMAResume() HAL_IRDA_DMAStop() A set of Transfer Complete Callbacks are provided in Non Blocking mode: HAL_IRDA_TxHalfCpltCallback() HAL_IRDA_TxCpltCallback() HAL_IRDA_RxHalfCpltCallback() HAL_IRDA_RxCpltCallback() HAL_IRDA_ErrorCallback() This section contains the following APIs: HAL_IRDA_Transmit() HAL_IRDA_Receive() HAL_IRDA_Transmit_IT() HAL_IRDA_Receive_IT() HAL_IRDA_Transmit_DMA() HAL_IRDA_Receive_DMA() HAL_IRDA_DMAPause() HAL_IRDA_DMAResume() HAL_IRDA_DMAStop() HAL_IRDA_IRQHandler() DOCID026526 Rev 4 403/832 UM1786 26.2.4 HAL_IRDA_TxCpltCallback() HAL_IRDA_TxHalfCpltCallback() HAL_IRDA_RxCpltCallback() HAL_IRDA_RxHalfCpltCallback() HAL_IRDA_ErrorCallback() Peripheral State and Errors functions This subsection provides a set of functions allowing to return the State of IrDA communication process and also return Peripheral Errors occurred during communication process HAL_IRDA_GetState() API can be helpful to check in run-time the state of the IRDA peripheral handle. HAL_IRDA_GetError() checks in run-time errors that could occur during communication. This section contains the following APIs: 26.2.5 HAL_IRDA_GetState() HAL_IRDA_GetError() Detailed description of functions HAL_IRDA_Init Function Name HAL_StatusTypeDef HAL_IRDA_Init (IRDA_HandleTypeDef * hirda) Function Description Initialize the IRDA mode according to the specified parameters in the IRDA_InitTypeDef and initialize the associated handle. Parameters hirda: Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module. Return values HAL: status HAL_IRDA_DeInit Function Name HAL_StatusTypeDef HAL_IRDA_DeInit (IRDA_HandleTypeDef * hirda) Function Description DeInitialize the IRDA peripheral. Parameters hirda: Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module. Return values HAL: status HAL_IRDA_MspInit 404/832 Function Name void HAL_IRDA_MspInit (IRDA_HandleTypeDef * hirda) Function Description Initialize the IRDA MSP. Parameters hirda: Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module. DOCID026526 Rev 4 UM1786 Return values None: HAL_IRDA_MspDeInit Function Name void HAL_IRDA_MspDeInit (IRDA_HandleTypeDef * hirda) Function Description DeInitialize the IRDA MSP. Parameters hirda: Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module. Return values None: HAL_IRDA_Transmit Function Name HAL_StatusTypeDef HAL_IRDA_Transmit (IRDA_HandleTypeDef * hirda, uint8_t * pData, uint16_t Size, uint32_t Timeout) Function Description Send an amount of data in blocking mode. Parameters Return values hirda: Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module. pData: Pointer to data buffer. Size: Amount of data to be sent. Timeout: Specify timeout value. HAL: status HAL_IRDA_Receive Function Name HAL_StatusTypeDef HAL_IRDA_Receive (IRDA_HandleTypeDef * hirda, uint8_t * pData, uint16_t Size, uint32_t Timeout) Function Description Receive an amount of data in blocking mode. Parameters Return values hirda: Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module. pData: Pointer to data buffer. Size: Amount of data to be received. Timeout: Specify timeout value. HAL: status HAL_IRDA_Transmit_IT Function Name HAL_StatusTypeDef HAL_IRDA_Transmit_IT (IRDA_HandleTypeDef * hirda, uint8_t * pData, uint16_t Size) Function Description Send an amount of data in interrupt mode. Parameters hirda: Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module. pData: Pointer to data buffer. DOCID026526 Rev 4 405/832 UM1786 Return values Size: Amount of data to be sent. HAL: status HAL_IRDA_Receive_IT Function Name HAL_StatusTypeDef HAL_IRDA_Receive_IT (IRDA_HandleTypeDef * hirda, uint8_t * pData, uint16_t Size) Function Description Receive an amount of data in interrupt mode. Parameters Return values hirda: Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module. pData: Pointer to data buffer. Size: Amount of data to be received. HAL: status HAL_IRDA_Transmit_DMA Function Name HAL_StatusTypeDef HAL_IRDA_Transmit_DMA (IRDA_HandleTypeDef * hirda, uint8_t * pData, uint16_t Size) Function Description Send an amount of data in DMA mode. Parameters Return values hirda: Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module. pData: pointer to data buffer. Size: amount of data to be sent. HAL: status HAL_IRDA_Receive_DMA Function Name HAL_StatusTypeDef HAL_IRDA_Receive_DMA (IRDA_HandleTypeDef * hirda, uint8_t * pData, uint16_t Size) Function Description Receive an amount of data in DMA mode. Parameters hirda: Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module. pData: Pointer to data buffer. Size: Amount of data to be received. Return values HAL: status Notes When the IRDA parity is enabled (PCE = 1) the received data contains the parity bit (MSB position). HAL_IRDA_DMAPause 406/832 Function Name HAL_StatusTypeDef HAL_IRDA_DMAPause (IRDA_HandleTypeDef * hirda) Function Description Pause the DMA Transfer. Parameters hirda: Pointer to a IRDA_HandleTypeDef structure that DOCID026526 Rev 4 UM1786 contains the configuration information for the specified IRDA module. Return values HAL: status HAL_IRDA_DMAResume Function Name HAL_StatusTypeDef HAL_IRDA_DMAResume (IRDA_HandleTypeDef * hirda) Function Description Resume the DMA Transfer. Parameters hirda: Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified UART module. Return values HAL: status HAL_IRDA_DMAStop Function Name HAL_StatusTypeDef HAL_IRDA_DMAStop (IRDA_HandleTypeDef * hirda) Function Description Stop the DMA Transfer. Parameters hirda: Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified UART module. Return values HAL: status HAL_IRDA_IRQHandler Function Name void HAL_IRDA_IRQHandler (IRDA_HandleTypeDef * hirda) Function Description Handle IRDA interrupt request. Parameters hirda: Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module. Return values None: HAL_IRDA_TxCpltCallback Function Name void HAL_IRDA_TxCpltCallback (IRDA_HandleTypeDef * hirda) Function Description Tx Transfer completed callback. Parameters hirda: Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module. Return values None: HAL_IRDA_RxCpltCallback Function Name void HAL_IRDA_RxCpltCallback (IRDA_HandleTypeDef * hirda) DOCID026526 Rev 4 407/832 UM1786 Function Description Rx Transfer completed callback. Parameters hirda: Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module. Return values None: HAL_IRDA_TxHalfCpltCallback Function Name void HAL_IRDA_TxHalfCpltCallback (IRDA_HandleTypeDef * hirda) Function Description Tx Half Transfer completed callback. Parameters hirda: Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified USART module. Return values None: HAL_IRDA_RxHalfCpltCallback Function Name void HAL_IRDA_RxHalfCpltCallback (IRDA_HandleTypeDef * hirda) Function Description Rx Half Transfer complete callback. Parameters hirda: Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module. Return values None: HAL_IRDA_ErrorCallback Function Name void HAL_IRDA_ErrorCallback (IRDA_HandleTypeDef * hirda) Function Description IRDA error callback. Parameters hirda: Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module. Return values None: HAL_IRDA_GetState 408/832 Function Name HAL_IRDA_StateTypeDef HAL_IRDA_GetState (IRDA_HandleTypeDef * hirda) Function Description Return the IRDA handle state. Parameters hirda: Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module. Return values HAL: state DOCID026526 Rev 4 UM1786 HAL_IRDA_GetError Function Name uint32_t HAL_IRDA_GetError (IRDA_HandleTypeDef * hirda) Function Description Return the IRDA handle error code. Parameters hirda: Pointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module. Return values IRDA: Error Code 26.3 IRDA Firmware driver defines 26.3.1 IRDA IRDA DMA Rx IRDA_DMA_RX_DISABLE IRDA DMA RX disabled IRDA_DMA_RX_ENABLE IRDA DMA RX enabled IRDA DMA Tx IRDA_DMA_TX_DISABLE IRDA DMA TX disabled IRDA_DMA_TX_ENABLE IRDA DMA TX enabled IRDA Error HAL_IRDA_ERROR_NONE No error HAL_IRDA_ERROR_PE Parity error HAL_IRDA_ERROR_NE Noise error HAL_IRDA_ERROR_FE frame error HAL_IRDA_ERROR_ORE Overrun error HAL_IRDA_ERROR_DMA DMA transfer error IRDA Exported Macros __HAL_IRDA_RESET_HANDLE_STATE Description: Reset IRDA handle state. Parameters: __HANDLE__: IRDA handle. Return value: __HAL_IRDA_FLUSH_DRREGISTER None Description: Flush the IRDA Data registers. Parameters: __HANDLE__: specifies the IRDA Handle. Return value: None DOCID026526 Rev 4 409/832 UM1786 __HAL_IRDA_CLEAR_FLAG Description: Clear the specified IRDA pending flag. Parameters: __HANDLE__: specifies the IRDA Handle. __FLAG__: specifies the flag to check. This parameter can be any combination of the following values: IRDA_CLEAR_PEF IRDA_CLEAR_FEF IRDA_CLEAR_NEF IRDA_CLEAR_OREF IRDA_CLEAR_TCF IRDA_CLEAR_IDLEF Return value: __HAL_IRDA_CLEAR_PEFLAG None Description: Clear the IRDA PE pending flag. Parameters: __HANDLE__: specifies the IRDA Handle. Return value: __HAL_IRDA_CLEAR_FEFLAG None Description: Clear the IRDA FE pending flag. Parameters: __HANDLE__: specifies the IRDA Handle. Return value: __HAL_IRDA_CLEAR_NEFLAG None Description: Clear the IRDA NE pending flag. Parameters: __HANDLE__: specifies the IRDA Handle. Return value: __HAL_IRDA_CLEAR_OREFLAG None Description: Clear the IRDA ORE pending flag. Parameters: 410/832 DOCID026526 Rev 4 UM1786 __HANDLE__: specifies the IRDA Handle. Return value: __HAL_IRDA_CLEAR_IDLEFLAG None Description: Clear the IRDA IDLE pending flag. Parameters: __HANDLE__: specifies the IRDA Handle. Return value: __HAL_IRDA_GET_FLAG None Description: Check whether the specified IRDA flag is set or not. Parameters: __HANDLE__: specifies the IRDA Handle. The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or UART peripheral __FLAG__: specifies the flag to check. This parameter can be one of the following values: IRDA_FLAG_REACK: Receive enable acknowledge flag IRDA_FLAG_TEACK: Transmit enable acknowledge flag IRDA_FLAG_BUSY: Busy flag IRDA_FLAG_ABRF: Auto Baud rate detection flag IRDA_FLAG_ABRE: Auto Baud rate detection error flag IRDA_FLAG_TXE: Transmit data register empty flag IRDA_FLAG_TC: Transmission Complete flag IRDA_FLAG_RXNE: Receive data register not empty flag IRDA_FLAG_IDLE: Idle Line detection flag IRDA_FLAG_ORE: OverRun Error flag IRDA_FLAG_NE: Noise Error flag IRDA_FLAG_FE: Framing Error flag IRDA_FLAG_PE: Parity Error flag Return value: The: new state of __FLAG__ (TRUE or DOCID026526 Rev 4 411/832 UM1786 FALSE). __HAL_IRDA_ENABLE_IT Description: Enable the specified IRDA interrupt. Parameters: __HANDLE__: specifies the IRDA Handle. The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or UART peripheral __INTERRUPT__: specifies the IRDA interrupt source to enable. This parameter can be one of the following values: IRDA_IT_TXE: Transmit Data Register empty interrupt IRDA_IT_TC: Transmission complete interrupt IRDA_IT_RXNE: Receive Data register not empty interrupt IRDA_IT_IDLE: Idle line detection interrupt IRDA_IT_PE: Parity Error interrupt IRDA_IT_ERR: Error interrupt(Frame error, noise error, overrun error) Return value: __HAL_IRDA_DISABLE_IT None Description: Disable the specified IRDA interrupt. Parameters: __HANDLE__: specifies the IRDA Handle. The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or UART peripheral __INTERRUPT__: specifies the IRDA interrupt source to disable. This parameter can be one of the following values: IRDA_IT_TXE: Transmit Data Register empty interrupt IRDA_IT_TC: Transmission complete interrupt IRDA_IT_RXNE: Receive Data register not empty interrupt IRDA_IT_IDLE: Idle line detection interrupt IRDA_IT_PE: Parity Error interrupt IRDA_IT_ERR: Error interrupt(Frame error, noise error, overrun error) Return value: 412/832 None DOCID026526 Rev 4 UM1786 Description: __HAL_IRDA_GET_IT Check whether the specified IRDA interrupt has occurred or not. Parameters: __HANDLE__: specifies the IRDA Handle. The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or UART peripheral __IT__: specifies the IRDA interrupt source to check. This parameter can be one of the following values: IRDA_IT_TXE: Transmit Data Register empty interrupt IRDA_IT_TC: Transmission complete interrupt IRDA_IT_RXNE: Receive Data register not empty interrupt IRDA_IT_IDLE: Idle line detection interrupt IRDA_IT_ORE: OverRun Error interrupt IRDA_IT_NE: Noise Error interrupt IRDA_IT_FE: Framing Error interrupt IRDA_IT_PE: Parity Error interrupt Return value: __HAL_IRDA_GET_IT_SOURCE The: new state of __IT__ (TRUE or FALSE). Description: Check whether the specified IRDA interrupt source is enabled or not. Parameters: __HANDLE__: specifies the IRDA Handle. The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or UART peripheral __IT__: specifies the IRDA interrupt source to check. This parameter can be one of the following values: IRDA_IT_TXE: Transmit Data Register empty interrupt IRDA_IT_TC: Transmission complete interrupt IRDA_IT_RXNE: Receive Data register not empty interrupt IRDA_IT_IDLE: Idle line detection interrupt IRDA_IT_ORE: OverRun Error interrupt IRDA_IT_NE: Noise Error interrupt IRDA_IT_FE: Framing Error interrupt DOCID026526 Rev 4 413/832 UM1786 IRDA_IT_PE: Parity Error interrupt Return value: __HAL_IRDA_CLEAR_IT The: new state of __IT__ (TRUE or FALSE). Description: Clear the specified IRDA ISR flag, in setting the proper ICR register flag. Parameters: __HANDLE__: specifies the IRDA Handle. The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or UART peripheral __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set to clear the corresponding interrupt This parameter can be one of the following values: IRDA_CLEAR_PEF: Parity Error Clear Flag IRDA_CLEAR_FEF: Framing Error Clear Flag IRDA_CLEAR_NEF: Noise detected Clear Flag IRDA_CLEAR_OREF: OverRun Error Clear Flag IRDA_CLEAR_TCF: Transmission Complete Clear Flag Return value: __HAL_IRDA_SEND_REQ None Description: Set a specific IRDA request flag. Parameters: __HANDLE__: specifies the IRDA Handle. The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or UART peripheral __REQ__: specifies the request flag to set This parameter can be one of the following values: IRDA_AUTOBAUD_REQUEST: Auto-Baud Rate Request IRDA_RXDATA_FLUSH_REQUEST: Receive Data flush Request IRDA_TXDATA_FLUSH_REQUEST: Transmit data flush Request Return value: 414/832 None DOCID026526 Rev 4 UM1786 __HAL_IRDA_ONE_BIT_SAMPLE_ENA BLE Description: Enable the IRDA one bit sample method. Parameters: __HANDLE__: specifies the IRDA Handle. The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or UART peripheral Return value: __HAL_IRDA_ONE_BIT_SAMPLE_DISA BLE None Description: Disable the IRDA one bit sample method. Parameters: __HANDLE__: specifies the IRDA Handle. The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or UART peripheral Return value: __HAL_IRDA_ENABLE None Description: Enable UART/USART associated to IRDA Handle. Parameters: __HANDLE__: specifies the IRDA Handle. The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or UART peripheral Return value: __HAL_IRDA_DISABLE None Description: Disable UART/USART associated to IRDA Handle. Parameters: __HANDLE__: specifies the IRDA Handle. The Handle Instance can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or UART peripheral Return value: None IRDA Flags IRDA_FLAG_REACK IRDA Receive enable acknowledge flag IRDA_FLAG_TEACK IRDA Transmit enable acknowledge flag DOCID026526 Rev 4 415/832 UM1786 IRDA_FLAG_BUSY IRDA Busy flag IRDA_FLAG_ABRF IRDA Auto baud rate flag IRDA_FLAG_ABRE IRDA Auto baud rate error IRDA_FLAG_TXE IRDA Transmit data register empty IRDA_FLAG_TC IRDA Transmission complete IRDA_FLAG_RXNE IRDA Read data register not empty IRDA_FLAG_ORE IRDA Overrun error IRDA_FLAG_NE IRDA Noise error IRDA_FLAG_FE IRDA Noise error IRDA_FLAG_PE IRDA Parity error IRDA interruptions flags mask IRDA_IT_MASK IRDA Interruptions flags mask IRDA Interrupts Definition IRDA_IT_PE IRDA Parity error interruption IRDA_IT_TXE IRDA Transmit data register empty interruption IRDA_IT_TC IRDA Transmission complete interruption IRDA_IT_RXNE IRDA Read data register not empty interruption IRDA_IT_IDLE IRDA Idle interruption IRDA_IT_ERR IRDA_IT_ORE IRDA_IT_NE IRDA Noise error interruption IRDA_IT_FE IRDA Frame error interruption IRDA Interruption Clear Flags IRDA_CLEAR_PEF Parity Error Clear Flag IRDA_CLEAR_FEF Framing Error Clear Flag IRDA_CLEAR_NEF Noise detected Clear Flag IRDA_CLEAR_OREF OverRun Error Clear Flag IRDA_CLEAR_TCF Transmission Complete Clear Flag IRDA Low Power IRDA_POWERMODE_NORMAL IRDA normal power mode IRDA_POWERMODE_LOWPOWER IRDA low power mode IRDA Mode IRDA_MODE_DISABLE Associated UART disabled in IRDA mode IRDA_MODE_ENABLE Associated UART enabled in IRDA mode IRDA One Bit Sampling IRDA_ONE_BIT_SAMPLE_DISABLE 416/832 One-bit sampling disabled DOCID026526 Rev 4 UM1786 IRDA_ONE_BIT_SAMPLE_ENABLE One-bit sampling enabled IRDA Parity IRDA_PARITY_NONE No parity IRDA_PARITY_EVEN Even parity IRDA_PARITY_ODD Odd parity IRDA Request Parameters IRDA_AUTOBAUD_REQUEST Auto-Baud Rate Request IRDA_RXDATA_FLUSH_REQUEST Receive Data flush Request IRDA_TXDATA_FLUSH_REQUEST Transmit data flush Request IRDA State IRDA_STATE_DISABLE IRDA disabled IRDA_STATE_ENABLE IRDA enabled IRDA Transfer Mode IRDA_MODE_RX RX mode IRDA_MODE_TX TX mode IRDA_MODE_TX_RX RX and TX mode DOCID026526 Rev 4 417/832 UM1786 27 HAL IRDA Extension Driver 27.1 IRDAEx Firmware driver defines 27.1.1 IRDAEx IRDA Word Length 418/832 IRDA_WORDLENGTH_8B 8-bit long frame IRDA_WORDLENGTH_9B 9-bit long frame DOCID026526 Rev 4 UM1786 28 HAL IWDG Generic Driver 28.1 IWDG Firmware driver registers structures 28.1.1 IWDG_InitTypeDef Data Fields uint32_t Prescaler uint32_t Reload uint32_t Window Field Documentation 28.1.2 uint32_t IWDG_InitTypeDef::Prescaler Select the prescaler of the IWDG. This parameter can be a value of IWDG_Prescaler uint32_t IWDG_InitTypeDef::Reload Specifies the IWDG down-counter reload value. This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF uint32_t IWDG_InitTypeDef::Window Specifies the window value to be compared to the down-counter. This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF IWDG_HandleTypeDef Data Fields IWDG_TypeDef * Instance IWDG_InitTypeDef Init HAL_LockTypeDef Lock __IO HAL_IWDG_StateTypeDef State Field Documentation IWDG_TypeDef* IWDG_HandleTypeDef::Instance Register base address IWDG_InitTypeDef IWDG_HandleTypeDef::Init IWDG required parameters HAL_LockTypeDef IWDG_HandleTypeDef::Lock IWDG Locking object __IO HAL_IWDG_StateTypeDef IWDG_HandleTypeDef::State IWDG communication state DOCID026526 Rev 4 419/832 UM1786 28.2 IWDG Firmware driver API description 28.2.1 IWDG Generic features The IWDG can be started by either software or hardware (configurable through option byte). The IWDG is clocked by its own dedicated Low-Speed clock (LSI) and thus stays active even if the main clock fails. Once the IWDG is started, the LSI is forced ON and cannot be disabled (LSI cannot be disabled too), and the counter starts counting down from the reset value of 0xFFF. When it reaches the end of count value (0x000) a system reset is generated. The IWDG counter should be refreshed at regular intervals, otherwise the watchdog generates an MCU reset when the counter reaches 0. The IWDG is implemented in the VDD voltage domain that is still functional in STOP and STANDBY mode (IWDG reset can wake-up from STANDBY). IWDGRST flag in RCC_CSR register can be used to inform when an IWDG reset occurs. Min-max timeout value @41KHz (LSI): ~0.1ms / ~25.5s The IWDG timeout may vary due to LSI frequency dispersion. STM32L4xx 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. 28.2.2 How to use this driver If Window option is disabled Use IWDG using HAL_IWDG_Init() function to : Enable write access to IWDG_PR, IWDG_RLR. Configure the IWDG prescaler, counter reload value. This reload value will be loaded in the IWDG counter each time the counter is reloaded, then the IWDG will start counting down from this value. Use IWDG using HAL_IWDG_Start() function to : Reload IWDG counter with value defined in the IWDG_RLR register. Start the IWDG, when the IWDG is used in software mode (no need to enable the LSI, it will be enabled by hardware). Then the application program must refresh the IWDG counter at regular intervals during normal operation to prevent an MCU reset, using HAL_IWDG_Refresh() function. if Window option is enabled: Use IWDG using HAL_IWDG_Start() function to enable IWDG downcounter Use IWDG using HAL_IWDG_Init() function to : Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers. Configure the IWDG prescaler, reload value and window value. Then the application program must refresh the IWDG counter at regular intervals during normal operation to prevent an MCU reset, using HAL_IWDG_Refresh() function. IWDG HAL driver macros list Below the list of most used macros in IWDG HAL driver. 420/832 __HAL_IWDG_START: Enable the IWDG peripheral __HAL_IWDG_RELOAD_COUNTER: Reloads IWDG counter with value defined in the reload register DOCID026526 Rev 4 UM1786 28.2.3 __HAL_IWDG_GET_FLAG: Get the selected IWDG's flag status Initialization and de-initialization functions This section provides functions allowing to: Initialize the IWDG according to the specified parameters in the IWDG_InitTypeDef and create the associated handle Manage Window option Initialize the IWDG MSP DeInitialize the IWDG MSP This section contains the following APIs: 28.2.4 HAL_IWDG_Init() HAL_IWDG_MspInit() IO operation functions This section provides functions allowing to: Start the IWDG. Refresh the IWDG. This section contains the following APIs: 28.2.5 HAL_IWDG_Start() HAL_IWDG_Refresh() Peripheral State functions This subsection permits to get in run-time the status of the peripheral. This section contains the following APIs: 28.2.6 HAL_IWDG_GetState() Detailed description of functions HAL_IWDG_Init Function Name HAL_StatusTypeDef HAL_IWDG_Init (IWDG_HandleTypeDef * hiwdg) Function Description Initialize the IWDG according to the specified parameters in the IWDG_InitTypeDef and initialize the associated handle. Parameters hiwdg: pointer to a IWDG_HandleTypeDef structure that contains the configuration information for the specified IWDG module. Return values HAL: status HAL_IWDG_MspInit Function Name void HAL_IWDG_MspInit (IWDG_HandleTypeDef * hiwdg) Function Description Initialize the IWDG MSP. Parameters hiwdg: pointer to a IWDG_HandleTypeDef structure that contains the configuration information for the specified IWDG module. DOCID026526 Rev 4 421/832 UM1786 Return values None: HAL_IWDG_Start Function Name HAL_StatusTypeDef HAL_IWDG_Start (IWDG_HandleTypeDef * hiwdg) Function Description Start the IWDG. Parameters hiwdg: pointer to a IWDG_HandleTypeDef structure that contains the configuration information for the specified IWDG module. Return values HAL: status HAL_IWDG_Refresh Function Name HAL_StatusTypeDef HAL_IWDG_Refresh (IWDG_HandleTypeDef * hiwdg) Function Description Refresh the IWDG. Parameters hiwdg: pointer to a IWDG_HandleTypeDef structure that contains the configuration information for the specified IWDG module. Return values HAL: status HAL_IWDG_GetState Function Name HAL_IWDG_StateTypeDef HAL_IWDG_GetState (IWDG_HandleTypeDef * hiwdg) Function Description Return the IWDG handle state. Parameters hiwdg: pointer to a IWDG_HandleTypeDef structure that contains the configuration information for the specified IWDG module. Return values HAL: state 28.3 IWDG Firmware driver defines 28.3.1 IWDG IWDG Exported Macros __HAL_IWDG_RESET_HANDLE_STATE Description: Reset IWDG handle state. Parameters: __HANDLE__: IWDG handle. Return value: __HAL_IWDG_START 422/832 None Description: DOCID026526 Rev 4 UM1786 Enable the IWDG peripheral. Parameters: __HANDLE__: IWDG handle Return value: __HAL_IWDG_RELOAD_COUNTER None Description: Reload IWDG counter with value defined in the reload register. Parameters: __HANDLE__: IWDG handle Return value: __HAL_IWDG_GET_FLAG None Description: Get the selected IWDG flag status. Parameters: __HANDLE__: IWDG handle __FLAG__: specifies the flag to check. This parameter can be one of the following values: IWDG_FLAG_PVU: Watchdog counter reload value update flag IWDG_FLAG_RVU: Watchdog counter prescaler value flag IWDG_FLAG_WVU: Watchdog counter window value flag Return value: The: new state of __FLAG__ (TRUE or FALSE) . IWDG Prescaler IWDG_PRESCALER_4 IWDG prescaler set to 4 IWDG_PRESCALER_8 IWDG prescaler set to 8 IWDG_PRESCALER_16 IWDG prescaler set to 16 IWDG_PRESCALER_32 IWDG prescaler set to 32 IWDG_PRESCALER_64 IWDG prescaler set to 64 IWDG_PRESCALER_128 IWDG prescaler set to 128 IWDG_PRESCALER_256 IWDG prescaler set to 256 IWDG Window IWDG_WINDOW_DISABLE DOCID026526 Rev 4 423/832 UM1786 29 HAL NAND Generic Driver 29.1 NAND Firmware driver registers structures 29.1.1 NAND_IDTypeDef Data Fields uint8_t Maker_Id uint8_t Device_Id uint8_t Third_Id uint8_t Fourth_Id Field Documentation 29.1.2 uint8_t NAND_IDTypeDef::Maker_Id uint8_t NAND_IDTypeDef::Device_Id uint8_t NAND_IDTypeDef::Third_Id uint8_t NAND_IDTypeDef::Fourth_Id NAND_AddressTypeDef Data Fields uint16_t Page uint16_t Zone uint16_t Block Field Documentation 29.1.3 uint16_t NAND_AddressTypeDef::Page NAND memory Page address uint16_t NAND_AddressTypeDef::Zone NAND memory Zone address uint16_t NAND_AddressTypeDef::Block NAND memory Block address NAND_InfoTypeDef Data Fields 424/832 uint32_t PageSize uint32_t SpareAreaSize uint32_t BlockSize uint32_t BlockNbr DOCID026526 Rev 4 UM1786 uint32_t ZoneSize Field Documentation 29.1.4 uint32_t NAND_InfoTypeDef::PageSize NAND memory page (without spare area) size measured in K. bytes uint32_t NAND_InfoTypeDef::SpareAreaSize NAND memory spare area size measured in K. bytes uint32_t NAND_InfoTypeDef::BlockSize NAND memory block size number of pages uint32_t NAND_InfoTypeDef::BlockNbr NAND memory number of blocks uint32_t NAND_InfoTypeDef::ZoneSize NAND memory zone size measured in number of blocks NAND_HandleTypeDef Data Fields FMC_NAND_TypeDef * Instance FMC_NAND_InitTypeDef Init HAL_LockTypeDef Lock __IO HAL_NAND_StateTypeDef State NAND_InfoTypeDef Info Field Documentation FMC_NAND_TypeDef* NAND_HandleTypeDef::Instance Register base address FMC_NAND_InitTypeDef NAND_HandleTypeDef::Init NAND device control configuration parameters HAL_LockTypeDef NAND_HandleTypeDef::Lock NAND locking object __IO HAL_NAND_StateTypeDef NAND_HandleTypeDef::State NAND device access state NAND_InfoTypeDef NAND_HandleTypeDef::Info NAND characteristic information structure 29.2 NAND Firmware driver API description 29.2.1 How to use this driver This driver is a generic layered driver which contains a set of APIs used to control NAND flash memories. It uses the FMC layer functions to interface with NAND devices. This driver is used as follows: NAND flash memory configuration sequence using the function HAL_NAND_Init() with control and timing parameters for both common and attribute spaces. DOCID026526 Rev 4 425/832 UM1786 Read NAND flash memory maker and device IDs using the function HAL_NAND_Read_ID(). The read information is stored in the NAND_ID_TypeDef structure declared by the function caller. Access NAND flash memory by read/write operations using the functions HAL_NAND_Read_Page()/HAL_NAND_Read_SpareArea(), HAL_NAND_Write_Page()/HAL_NAND_Write_SpareArea() to read/write page(s)/spare area(s). These functions use specific device information (Block, page size..) predefined by the user in the HAL_NAND_Info_TypeDef structure. The read/write address information is contained by the Nand_Address_Typedef structure passed as parameter. Perform NAND flash Reset chip operation using the function HAL_NAND_Reset(). Perform NAND flash erase block operation using the function HAL_NAND_Erase_Block(). The erase block address information is contained in the Nand_Address_Typedef structure passed as parameter. Read the NAND flash status operation using the function HAL_NAND_Read_Status(). You can also control the NAND device by calling the control APIs HAL_NAND_ECC_Enable()/ HAL_NAND_ECC_Disable() to respectively enable/disable the ECC code correction feature or the function HAL_NAND_GetECC() to get the ECC correction code. You can monitor the NAND device HAL state by calling the function HAL_NAND_GetState() This driver is a set of generic APIs which handle standard NAND flash operations. If a NAND flash device contains different operations and/or implementations, it should be implemented separately. 29.2.2 NAND Initialization and de-initialization functions This section provides functions allowing to initialize/de-initialize the NAND memory This section contains the following APIs: 29.2.3 HAL_NAND_Init() HAL_NAND_DeInit() HAL_NAND_MspInit() HAL_NAND_MspDeInit() HAL_NAND_IRQHandler() HAL_NAND_ITCallback() NAND Input and Output functions This section provides functions allowing to use and control the NAND memory This section contains the following APIs: 426/832 HAL_NAND_Read_ID() HAL_NAND_Reset() HAL_NAND_Read_Page() HAL_NAND_Write_Page() HAL_NAND_Read_SpareArea() HAL_NAND_Write_SpareArea() HAL_NAND_Erase_Block() HAL_NAND_Read_Status() HAL_NAND_Address_Inc() DOCID026526 Rev 4 UM1786 29.2.4 NAND Control functions This subsection provides a set of functions allowing to control dynamically the NAND interface. This section contains the following APIs: 29.2.5 HAL_NAND_ECC_Enable() HAL_NAND_ECC_Disable() HAL_NAND_GetECC() NAND State functions This subsection permits to get in run-time the status of the NAND controller and the data flow. This section contains the following APIs: 29.2.6 HAL_NAND_GetState() HAL_NAND_Read_Status() Detailed description of functions HAL_NAND_Init Function Name HAL_StatusTypeDef HAL_NAND_Init (NAND_HandleTypeDef * hnand, FMC_NAND_PCC_TimingTypeDef * ComSpace_Timing, FMC_NAND_PCC_TimingTypeDef * AttSpace_Timing) Function Description Perform NAND memory Initialization sequence. Parameters hnand: pointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module. ComSpace_Timing: pointer to Common space timing structure AttSpace_Timing: pointer to Attribute space timing structure HAL: status Return values HAL_NAND_DeInit Function Name HAL_StatusTypeDef HAL_NAND_DeInit (NAND_HandleTypeDef * hnand) Function Description Perform NAND memory De-Initialization sequence. Parameters hnand: pointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module. Return values HAL: status HAL_NAND_MspInit Function Name void HAL_NAND_MspInit (NAND_HandleTypeDef * hnand) Function Description NAND MSP Init. Parameters hnand: pointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module. DOCID026526 Rev 4 427/832 UM1786 Return values None: HAL_NAND_MspDeInit Function Name void HAL_NAND_MspDeInit (NAND_HandleTypeDef * hnand) Function Description NAND MSP DeInit. Parameters hnand: pointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module. Return values None: HAL_NAND_IRQHandler Function Name void HAL_NAND_IRQHandler (NAND_HandleTypeDef * hnand) Function Description This function handles NAND device interrupt request. Parameters hnand: pointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module. Return values HAL: status HAL_NAND_ITCallback Function Name void HAL_NAND_ITCallback (NAND_HandleTypeDef * hnand) Function Description NAND interrupt feature callback. Parameters hnand: pointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module. Return values None: HAL_NAND_Read_ID Function Name HAL_StatusTypeDef HAL_NAND_Read_ID (NAND_HandleTypeDef * hnand, NAND_IDTypeDef * pNAND_ID) Function Description Read the NAND memory electronic signature. Parameters Return values hnand: pointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module. pNAND_ID: NAND ID structure HAL: status HAL_NAND_Reset 428/832 Function Name HAL_StatusTypeDef HAL_NAND_Reset (NAND_HandleTypeDef * hnand) Function Description NAND memory reset. Parameters hnand: pointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module. Return values HAL: status DOCID026526 Rev 4 UM1786 HAL_NAND_Read_Page Function Name HAL_StatusTypeDef HAL_NAND_Read_Page (NAND_HandleTypeDef * hnand, NAND_AddressTypeDef * pAddress, uint8_t * pBuffer, uint32_t NumPageToRead) Function Description Read Page(s) from NAND memory block. Parameters Return values hnand: pointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module. pAddress: pointer to NAND address structure pBuffer: pointer to destination read buffer NumPageToRead: number of pages to read from block HAL: status HAL_NAND_Write_Page Function Name HAL_StatusTypeDef HAL_NAND_Write_Page (NAND_HandleTypeDef * hnand, NAND_AddressTypeDef * pAddress, uint8_t * pBuffer, uint32_t NumPageToWrite) Function Description Write Page(s) to NAND memory block. Parameters Return values hnand: pointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module. pAddress: pointer to NAND address structure pBuffer: pointer to source buffer to write NumPageToWrite: number of pages to write to block HAL: status HAL_NAND_Read_SpareArea Function Name HAL_StatusTypeDef HAL_NAND_Read_SpareArea (NAND_HandleTypeDef * hnand, NAND_AddressTypeDef * pAddress, uint8_t * pBuffer, uint32_t NumSpareAreaToRead) Function Description Read Spare area(s) from NAND memory. Parameters Return values hnand: pointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module. pAddress: pointer to NAND address structure pBuffer: pointer to source buffer to write NumSpareAreaToRead: Number of spare area to read HAL: status HAL_NAND_Write_SpareArea Function Name HAL_StatusTypeDef HAL_NAND_Write_SpareArea (NAND_HandleTypeDef * hnand, NAND_AddressTypeDef * pAddress, uint8_t * pBuffer, uint32_t NumSpareAreaTowrite) Function Description Write Spare area(s) to NAND memory. Parameters hnand: pointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module. pAddress: pointer to NAND address structure pBuffer: pointer to source buffer to write DOCID026526 Rev 4 429/832 UM1786 Return values NumSpareAreaTowrite: number of spare areas to write to block HAL: status HAL_NAND_Erase_Block Function Name HAL_StatusTypeDef HAL_NAND_Erase_Block (NAND_HandleTypeDef * hnand, NAND_AddressTypeDef * pAddress) Function Description NAND memory Block erase. Parameters Return values hnand: pointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module. pAddress: pointer to NAND address structure HAL: status HAL_NAND_Read_Status Function Name uint32_t HAL_NAND_Read_Status (NAND_HandleTypeDef * hnand) Function Description NAND memory read status. Parameters hnand: pointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module. Return values NAND: status HAL_NAND_Address_Inc Function Name uint32_t HAL_NAND_Address_Inc (NAND_HandleTypeDef * hnand, NAND_AddressTypeDef * pAddress) Function Description Increment the NAND memory address. Parameters Return values hnand: pointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module. pAddress: pointer to NAND address structure The: new status of the increment address operation. It can be: NAND_VALID_ADDRESS: When the new address is valid address NAND_INVALID_ADDRESS: When the new address is invalid address HAL_NAND_ECC_Enable 430/832 Function Name HAL_StatusTypeDef HAL_NAND_ECC_Enable (NAND_HandleTypeDef * hnand) Function Description Enables dynamically NAND ECC feature. Parameters hnand: pointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module. Return values HAL: status DOCID026526 Rev 4 UM1786 HAL_NAND_ECC_Disable Function Name HAL_StatusTypeDef HAL_NAND_ECC_Disable (NAND_HandleTypeDef * hnand) Function Description Disables dynamically FMC_NAND ECC feature. Parameters hnand: pointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module. Return values HAL: status HAL_NAND_GetECC Function Name HAL_StatusTypeDef HAL_NAND_GetECC (NAND_HandleTypeDef * hnand, uint32_t * ECCval, uint32_t Timeout) Function Description Disables dynamically NAND ECC feature. Parameters Return values hnand: pointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module. ECCval: pointer to ECC value Timeout: maximum timeout to wait HAL: status HAL_NAND_GetState Function Name HAL_NAND_StateTypeDef HAL_NAND_GetState (NAND_HandleTypeDef * hnand) Function Description return the NAND state Parameters hnand: pointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module. Return values HAL: state HAL_NAND_Read_Status Function Name uint32_t HAL_NAND_Read_Status (NAND_HandleTypeDef * hnand) Function Description NAND memory read status. Parameters hnand: pointer to a NAND_HandleTypeDef structure that contains the configuration information for NAND module. Return values NAND: status 29.3 NAND Firmware driver defines 29.3.1 NAND NAND Exported Macros __HAL_NAND_RESET_HANDLE_STATE Description: Reset NAND handle state. DOCID026526 Rev 4 431/832 UM1786 Parameters: __HANDLE__: specifies the NAND handle. Return value: 432/832 None DOCID026526 Rev 4 UM1786 30 HAL NOR Generic Driver 30.1 NOR Firmware driver registers structures 30.1.1 NOR_IDTypeDef Data Fields uint16_t Manufacturer_Code uint16_t Device_Code1 uint16_t Device_Code2 uint16_t Device_Code3 Field Documentation 30.1.2 uint16_t NOR_IDTypeDef::Manufacturer_Code Defines the device's manufacturer code used to identify the memory uint16_t NOR_IDTypeDef::Device_Code1 uint16_t NOR_IDTypeDef::Device_Code2 uint16_t NOR_IDTypeDef::Device_Code3 Defines the device's codes used to identify the memory. These codes can be accessed by performing read operations with specific control signals and addresses set.They can also be accessed by issuing an Auto Select command. NOR_CFITypeDef Data Fields uint16_t CFI_1 uint16_t CFI_2 uint16_t CFI_3 uint16_t CFI_4 Field Documentation uint16_t NOR_CFITypeDef::CFI_1 uint16_t NOR_CFITypeDef::CFI_2 uint16_t NOR_CFITypeDef::CFI_3 uint16_t NOR_CFITypeDef::CFI_4 Defines the information stored in the memory's Common flash interface which contains a description of various electrical and timing parameters, density information and functions supported by the memory. DOCID026526 Rev 4 433/832 UM1786 30.1.3 NOR_HandleTypeDef Data Fields FMC_NORSRAM_TypeDef * Instance FMC_NORSRAM_EXTENDED_TypeDef * Extended FMC_NORSRAM_InitTypeDef Init HAL_LockTypeDef Lock __IO HAL_NOR_StateTypeDef State Field Documentation FMC_NORSRAM_TypeDef* NOR_HandleTypeDef::Instance Register base address FMC_NORSRAM_EXTENDED_TypeDef* NOR_HandleTypeDef::Extended Extended mode register base address FMC_NORSRAM_InitTypeDef NOR_HandleTypeDef::Init NOR device control configuration parameters HAL_LockTypeDef NOR_HandleTypeDef::Lock NOR locking object __IO HAL_NOR_StateTypeDef NOR_HandleTypeDef::State NOR device access state 30.2 NOR Firmware driver API description 30.2.1 How to use this driver This driver is a generic layered driver which contains a set of APIs used to control NOR flash memories. It uses the FMC layer functions to interface with NOR devices. This driver is used as follows: 434/832 NOR flash memory configuration sequence using the function HAL_NOR_Init() with control and timing parameters for both normal and extended mode. Read NOR flash memory manufacturer code and device IDs using the function HAL_NOR_Read_ID(). The read information is stored in the NOR_ID_TypeDef structure declared by the function caller. Access NOR flash memory by read/write data unit operations using the functions HAL_NOR_Read(), HAL_NOR_Program(). Perform NOR flash erase block/chip operations using the functions HAL_NOR_Erase_Block() and HAL_NOR_Erase_Chip(). Read the NOR flash CFI (common flash interface) IDs using the function HAL_NOR_Read_CFI(). The read information is stored in the NOR_CFI_TypeDef structure declared by the function caller. You can also control the NOR device by calling the control APIs HAL_NOR_WriteOperation_Enable()/ HAL_NOR_WriteOperation_Disable() to respectively enable/disable the NOR write operation You can monitor the NOR device HAL state by calling the function HAL_NOR_GetState() DOCID026526 Rev 4 UM1786 This driver is a set of generic APIs which handle standard NOR flash operations. If a NOR flash device contains different operations and/or implementations, it should be implemented separately. NOR HAL driver macros list Below the list of most used macros in NOR HAL driver. 30.2.2 NOR_WRITE: NOR memory write data to specified address NOR Initialization and de_initialization functions This section provides functions allowing to initialize/de-initialize the NOR memory This section contains the following APIs: 30.2.3 HAL_NOR_Init() HAL_NOR_DeInit() HAL_NOR_MspInit() HAL_NOR_MspDeInit() HAL_NOR_MspWait() NOR Input and Output functions This section provides functions allowing to use and control the NOR memory This section contains the following APIs: 30.2.4 HAL_NOR_Read_ID() HAL_NOR_ReturnToReadMode() HAL_NOR_Read() HAL_NOR_Program() HAL_NOR_ReadBuffer() HAL_NOR_ProgramBuffer() HAL_NOR_Erase_Block() HAL_NOR_Erase_Chip() HAL_NOR_Read_CFI() NOR Control functions This subsection provides a set of functions allowing to control dynamically the NOR interface. This section contains the following APIs: 30.2.5 HAL_NOR_WriteOperation_Enable() HAL_NOR_WriteOperation_Disable() NOR State functions This subsection permits to get in run-time the status of the NOR controller and the data flow. This section contains the following APIs: HAL_NOR_GetState() HAL_NOR_GetStatus() DOCID026526 Rev 4 435/832 UM1786 30.2.6 Detailed description of functions HAL_NOR_Init Function Name HAL_StatusTypeDef HAL_NOR_Init (NOR_HandleTypeDef * hnor, FMC_NORSRAM_TimingTypeDef * Timing, FMC_NORSRAM_TimingTypeDef * ExtTiming) Function Description Perform the NOR memory Initialization sequence. Parameters Return values hnor: pointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module. Timing: pointer to NOR control timing structure ExtTiming: pointer to NOR extended mode timing structure HAL: status HAL_NOR_DeInit Function Name HAL_StatusTypeDef HAL_NOR_DeInit (NOR_HandleTypeDef * hnor) Function Description Perform NOR memory De-Initialization sequence. Parameters hnor: pointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module. Return values HAL: status HAL_NOR_MspInit Function Name void HAL_NOR_MspInit (NOR_HandleTypeDef * hnor) Function Description NOR MSP Init. Parameters hnor: pointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module. Return values None: HAL_NOR_MspDeInit Function Name void HAL_NOR_MspDeInit (NOR_HandleTypeDef * hnor) Function Description NOR MSP DeInit. Parameters hnor: pointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module. Return values None: HAL_NOR_MspWait 436/832 Function Name void HAL_NOR_MspWait (NOR_HandleTypeDef * hnor, uint32_t Timeout) Function Description NOR MSP Wait fro Ready/Busy signal. Parameters hnor: pointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module. DOCID026526 Rev 4 UM1786 Return values Timeout: Maximum timeout value None: HAL_NOR_Read_ID Function Name HAL_StatusTypeDef HAL_NOR_Read_ID (NOR_HandleTypeDef * hnor, NOR_IDTypeDef * pNOR_ID) Function Description Read NOR flash IDs. Parameters Return values hnor: pointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module. pNOR_ID: pointer to NOR ID structure HAL: status HAL_NOR_ReturnToReadMode Function Name HAL_StatusTypeDef HAL_NOR_ReturnToReadMode (NOR_HandleTypeDef * hnor) Function Description Returns the NOR memory to Read mode. Parameters hnor: pointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module. Return values HAL: status HAL_NOR_Read Function Name HAL_StatusTypeDef HAL_NOR_Read (NOR_HandleTypeDef * hnor, uint32_t * pAddress, uint16_t * pData) Function Description Read data from NOR memory. Parameters Return values hnor: pointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module. pAddress: pointer to Device address pData: pointer to read data HAL: status HAL_NOR_Program Function Name HAL_StatusTypeDef HAL_NOR_Program (NOR_HandleTypeDef * hnor, uint32_t * pAddress, uint16_t * pData) Function Description Program data to NOR memory. Parameters Return values hnor: pointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module. pAddress: Device address pData: pointer to the data to write HAL: status DOCID026526 Rev 4 437/832 UM1786 HAL_NOR_ReadBuffer Function Name HAL_StatusTypeDef HAL_NOR_ReadBuffer (NOR_HandleTypeDef * hnor, uint32_t uwAddress, uint16_t * pData, uint32_t uwBufferSize) Function Description Reads a block of data from the FMC NOR memory. Parameters hnor: pointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module. uwAddress: NOR memory internal address to read from. pData: pointer to the buffer that receives the data read from the NOR memory. uwBufferSize: number of Half word to read. HAL: status Return values HAL_NOR_ProgramBuffer Function Name HAL_StatusTypeDef HAL_NOR_ProgramBuffer (NOR_HandleTypeDef * hnor, uint32_t uwAddress, uint16_t * pData, uint32_t uwBufferSize) Function Description Writes a half-word buffer to the FMC NOR memory. Parameters hnor: pointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module. uwAddress: NOR memory internal address from which the data pData: pointer to source data buffer. uwBufferSize: number of Half words to write. Return values HAL: status Notes Some NOR memory need Address aligned to xx bytes (can be aligned to 64 bytes boundary for example). The maximum buffer size allowed is NOR memory dependent (can be 64 Bytes max for example). HAL_NOR_Erase_Block Function Name HAL_StatusTypeDef HAL_NOR_Erase_Block (NOR_HandleTypeDef * hnor, uint32_t BlockAddress, uint32_t Address) Function Description Erase the specified block of the NOR memory. Parameters Return values hnor: pointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module. BlockAddress: Block to erase address Address: Device address HAL: status HAL_NOR_Erase_Chip Function Name 438/832 HAL_StatusTypeDef HAL_NOR_Erase_Chip (NOR_HandleTypeDef * hnor, uint32_t Address) DOCID026526 Rev 4 UM1786 Function Description Erase the entire NOR chip. Parameters Return values hnor: pointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module. Address: Device address HAL: status HAL_NOR_Read_CFI Function Name HAL_StatusTypeDef HAL_NOR_Read_CFI (NOR_HandleTypeDef * hnor, NOR_CFITypeDef * pNOR_CFI) Function Description Read NOR flash CFI IDs. Parameters Return values hnor: pointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module. pNOR_CFI: pointer to NOR CFI IDs structure HAL: status HAL_NOR_WriteOperation_Enable Function Name HAL_StatusTypeDef HAL_NOR_WriteOperation_Enable (NOR_HandleTypeDef * hnor) Function Description Enables dynamically NOR write operation. Parameters hnor: pointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module. Return values HAL: status HAL_NOR_WriteOperation_Disable Function Name HAL_StatusTypeDef HAL_NOR_WriteOperation_Disable (NOR_HandleTypeDef * hnor) Function Description Disables dynamically NOR write operation. Parameters hnor: pointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module. Return values HAL: status HAL_NOR_GetState Function Name HAL_NOR_StateTypeDef HAL_NOR_GetState (NOR_HandleTypeDef * hnor) Function Description return the NOR controller state Parameters hnor: pointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module. Return values NOR: controller state HAL_NOR_GetStatus Function Name HAL_NOR_StatusTypeDef HAL_NOR_GetStatus (NOR_HandleTypeDef * hnor, uint32_t Address, uint32_t DOCID026526 Rev 4 439/832 UM1786 Timeout) Function Description Returns the NOR operation status. Parameters Return values hnor: pointer to a NOR_HandleTypeDef structure that contains the configuration information for NOR module. Address: Device address Timeout: NOR progamming Timeout NOR_Status: The returned value can be: HAL_NOR_STATUS_SUCCESS, HAL_NOR_STATUS_ERROR or HAL_NOR_STATUS_TIMEOUT 30.3 NOR Firmware driver defines 30.3.1 NOR NOR Exported Macros __HAL_NOR_RESET_HANDLE_STATE Description: Reset NOR handle state. Parameters: __HANDLE__: NOR handle Return value: 440/832 None DOCID026526 Rev 4 UM1786 31 HAL OPAMP Generic Driver 31.1 OPAMP Firmware driver registers structures 31.1.1 OPAMP_InitTypeDef Data Fields uint32_t Mode uint32_t InvertingInput uint32_t NonInvertingInput uint32_t TimerControlledMuxmode uint32_t InvertingInputSecondary uint32_t NonInvertingInputSecondary uint32_t PgaConnect uint32_t PgaGain uint32_t UserTrimming uint32_t TrimmingValueP uint32_t TrimmingValueN Field Documentation uint32_t OPAMP_InitTypeDef::Mode Specifies the OPAMP mode This parameter must be a value of OPAMP_Mode mode is either Standalone, - Follower or PGA uint32_t OPAMP_InitTypeDef::InvertingInput Specifies the inverting input in Standalone & Pga modesIn Standalone mode: i.e when mode is OPAMP_STANDALONE_MODE This parameter must be a value of OPAMP_InvertingInput InvertingInput is either VM0 or VM1In PGA mode: i.e when mode is OPAMP_PGA_MODE & in Follower mode i.e when mode is OPAMP_FOLLOWER_MODE This parameter is Not Applicable uint32_t OPAMP_InitTypeDef::NonInvertingInput Specifies the non inverting input of the opamp: This parameter must be a value of OPAMP_NonInvertingInput NonInvertingInput is either VP0, VP1, VP2 or VP3 uint32_t OPAMP_InitTypeDef::TimerControlledMuxmode Specifies if the Timer controlled Mux mode is enabled or disabled This parameter must be a value of OPAMP_TimerControlledMuxmode uint32_t OPAMP_InitTypeDef::InvertingInputSecondary Specifies the inverting input (secondary) of the opamp when TimerControlledMuxmode is enabled i.e. when TimerControlledMuxmode is OPAMP_TIMERCONTROLLEDMUXMODE_ENABLEIn Standalone mode: i.e when mode is OPAMP_STANDALONE_MODE This parameter must be a value of OPAMP_InvertingInputSecondary InvertingInputSecondary is either VM0 or VM1In PGA mode: i.e when mode is OPAMP_PGA_MODE & in Follower mode i.e when mode is OPAMP_FOLLOWER_MODE This parameter is Not Applicable uint32_t OPAMP_InitTypeDef::NonInvertingInputSecondary Specifies the non inverting input (secondary) of the opamp when TimerControlledMuxmode is enabled i.e. when TimerControlledMuxmode is OPAMP_TIMERCONTROLLEDMUXMODE_ENABLE This parameter must be a value DOCID026526 Rev 4 441/832 31.1.2 UM1786 of OPAMP_NonInvertingInputSecondary NonInvertingInput is either VP0, VP1, VP2 or VP3 uint32_t OPAMP_InitTypeDef::PgaConnect Specifies the inverting pin in PGA mode i.e. when mode is OPAMP_PGA_MODE This parameter must be a value of OPAMP_PgaConnect Either: not connected, connected to VM0, connected to VM1 (VM0 or VM1 are typically used for external filtering) uint32_t OPAMP_InitTypeDef::PgaGain Specifies the gain in PGA mode i.e. when mode is OPAMP_PGA_MODE. This parameter must be a value of OPAMP_PgaGain (2, 4, 8 or 16 ) uint32_t OPAMP_InitTypeDef::UserTrimming Specifies the trimming mode This parameter must be a value of OPAMP_UserTrimming UserTrimming is either factory or user trimming uint32_t OPAMP_InitTypeDef::TrimmingValueP Specifies the offset trimming value (PMOS) i.e. when UserTrimming is OPAMP_TRIMMING_USER. This parameter must be a number between Min_Data = 1 and Max_Data = 31 uint32_t OPAMP_InitTypeDef::TrimmingValueN Specifies the offset trimming value (NMOS) i.e. when UserTrimming is OPAMP_TRIMMING_USER. This parameter must be a number between Min_Data = 1 and Max_Data = 31 OPAMP_HandleTypeDef Data Fields OPAMP_TypeDef * Instance OPAMP_InitTypeDef Init HAL_StatusTypeDef Status HAL_LockTypeDef Lock __IO HAL_OPAMP_StateTypeDef State Field Documentation OPAMP_TypeDef* OPAMP_HandleTypeDef::Instance OPAMP instance's registers base address OPAMP_InitTypeDef OPAMP_HandleTypeDef::Init OPAMP required parameters HAL_StatusTypeDef OPAMP_HandleTypeDef::Status OPAMP peripheral status HAL_LockTypeDef OPAMP_HandleTypeDef::Lock Locking object __IO HAL_OPAMP_StateTypeDef OPAMP_HandleTypeDef::State OPAMP communication state 31.2 OPAMP Firmware driver API description 31.2.1 OPAMP Peripheral Features The device integrates up to 4 operational amplifiers OPAMP1, OPAMP2, OPAMP3 and OPAMP4: 442/832 DOCID026526 Rev 4 UM1786 1. 2. 3. 4. 5. 6. 31.2.2 The OPAMP(s) provides several exclusive running modes. Standalone mode Programmable Gain Amplifier (PGA) mode (Resistor feedback output) Follower mode The OPAMP(s) provide(s) calibration capabilities. Calibration aims at correcting some offset for running mode. The OPAMP uses either factory calibration settings OR user defined calibration (trimming) settings (i.e. trimming mode). The user defined settings can be figured out using self calibration handled by HAL_OPAMP_SelfCalibrate, HAL_OPAMPEx_SelfCalibrateAll HAL_OPAMP_SelfCalibrate: Runs automatically the calibration in 2 steps. (90% of VDDA for NMOS transistors, 10% of VDDA for PMOS transistors). (As OPAMP is Rail-to-rail input/output, these 2 steps calibration is appropriate and enough in most cases). Enables the user trimming mode Updates the init structure with trimming values with fresh calibration results. The user may store the calibration results for larger (ex monitoring the trimming as a function of temperature for instance) for STM32F3 devices having 2 or 4 OPAMPs HAL_OPAMPEx_SelfCalibrateAll runs calibration of 2 or 4 OPAMPs in parallel. For any running mode, an additional Timer-controlled Mux (multiplexer) mode can be set on top. Timer-controlled Mux mode allows Automatic switching between inverting and non-inverting input. Hence on top of defaults (primary) inverting and non-inverting inputs, the user shall select secondary inverting and non inverting inputs. TIM1 CC6 provides the alternate switching tempo between defaults (primary) and secondary inputs. Running mode: Standalone mode Gain is set externally (gain depends on external loads). Follower mode also possible externally by connecting the inverting input to the output. Running mode: Follower mode No Inverting Input is connected. Running mode: Programmable Gain Amplifier (PGA) mode (Resistor feedback output) The OPAMP(s) output(s) can be internally connected to resistor feedback output. OPAMP gain is either 2, 4, 8 or 16. How to use this driver Calibration To run the opamp calibration self calibration: 1. Start calibration using HAL_OPAMP_SelfCalibrate. Store the calibration results. Running mode To use the opamp, perform the following steps: 1. Fill in the HAL_OPAMP_MspInit() to Configure the opamp input AND output in analog mode using HAL_GPIO_Init() to map the opamp output to the GPIO pin. DOCID026526 Rev 4 443/832 2. 3. 4. 5. UM1786 Configure the opamp using HAL_OPAMP_Init() function: Select the mode Select the inverting input Select the non-inverting input Select if the Timer controlled Mux mode is enabled/disabled If the Timer controlled Mux mode is enabled, select the secondary inverting input If the Timer controlled Mux mode is enabled, Select the secondary non-inverting input If PGA mode is enabled, Select if inverting input is connected. Select either factory or user defined trimming mode. If the user defined trimming mode is enabled, select PMOS & NMOS trimming values (typ. settings returned by HAL_OPAMP_SelfCalibrate function). Enable the opamp using HAL_OPAMP_Start() function. Disable the opamp using HAL_OPAMP_Stop() function. Lock the opamp in running mode using HAL_OPAMP_Lock() function. From then The configuration can be modified After HW reset OR thanks to HAL_OPAMP_MspDeInit called (user defined) from HAL_OPAMP_DeInit. Running mode: change of configuration while OPAMP ON To Re-configure OPAMP when OPAMP is ON (change on the fly) 1. 2. 31.2.3 If needed, Fill in the HAL_OPAMP_MspInit() This is the case for instance if you wish to use new OPAMP I/O Configure the opamp using HAL_OPAMP_Init() function: As in configure case, selects first the parameters you wish to modify. Initialization and de-initialization functions This section provides functions allowing to: This section contains the following APIs: 31.2.4 HAL_OPAMP_Init() HAL_OPAMP_DeInit() HAL_OPAMP_MspInit() HAL_OPAMP_MspDeInit() IO operation functions This subsection provides a set of functions allowing to manage the OPAMP data transfers. This section contains the following APIs: 31.2.5 HAL_OPAMP_Start() HAL_OPAMP_Stop() HAL_OPAMP_SelfCalibrate() Peripheral Control functions This subsection provides a set of functions allowing to control the OPAMP data transfers. This section contains the following APIs: 444/832 HAL_OPAMP_Lock() DOCID026526 Rev 4 UM1786 31.2.6 Peripheral State functions This subsection permit to get in run-time the status of the peripheral and the data flow. This section contains the following APIs: 31.2.7 HAL_OPAMP_GetState() HAL_OPAMP_GetTrimOffset() Detailed description of functions HAL_OPAMP_Init Function Name HAL_StatusTypeDef HAL_OPAMP_Init (OPAMP_HandleTypeDef * hopamp) Function Description Initializes the OPAMP according to the specified parameters in the OPAMP_InitTypeDef and create the associated handle. Parameters hopamp: OPAMP handle Return values HAL: status Notes If the selected opamp is locked, initialization can't be performed. To unlock the configuration, perform a system reset. HAL_OPAMP_DeInit Function Name HAL_StatusTypeDef HAL_OPAMP_DeInit (OPAMP_HandleTypeDef * hopamp) Function Description DeInitializes the OPAMP peripheral. Parameters hopamp: OPAMP handle Return values HAL: status Notes Deinitialization can't be performed if the OPAMP configuration is locked. To unlock the configuration, perform a system reset. HAL_OPAMP_MspInit Function Name void HAL_OPAMP_MspInit (OPAMP_HandleTypeDef * hopamp) Function Description Initializes the OPAMP MSP. Parameters hopamp: OPAMP handle Return values None: HAL_OPAMP_MspDeInit Function Name void HAL_OPAMP_MspDeInit (OPAMP_HandleTypeDef * hopamp) Function Description DeInitializes OPAMP MSP. Parameters hopamp: OPAMP handle DOCID026526 Rev 4 445/832 UM1786 Return values None: HAL_OPAMP_Start Function Name HAL_StatusTypeDef HAL_OPAMP_Start (OPAMP_HandleTypeDef * hopamp) Function Description Start the opamp. Parameters hopamp: OPAMP handle Return values HAL: status HAL_OPAMP_Stop Function Name HAL_StatusTypeDef HAL_OPAMP_Stop (OPAMP_HandleTypeDef * hopamp) Function Description Stop the opamp. Parameters hopamp: OPAMP handle Return values HAL: status HAL_OPAMP_SelfCalibrate Function Name HAL_StatusTypeDef HAL_OPAMP_SelfCalibrate (OPAMP_HandleTypeDef * hopamp) Function Description Run the self calibration of one OPAMP. Parameters hopamp: handle Return values Updated: offset trimming values (PMOS & NMOS), user trimming is enabled HAL: status Calibration runs about 25 ms. Notes HAL_OPAMP_Lock Function Name HAL_StatusTypeDef HAL_OPAMP_Lock (OPAMP_HandleTypeDef * hopamp) Function Description Lock the selected opamp configuration. Parameters hopamp: OPAMP handle Return values HAL: status HAL_OPAMP_GetState 446/832 Function Name HAL_OPAMP_StateTypeDef HAL_OPAMP_GetState (OPAMP_HandleTypeDef * hopamp) Function Description Return the OPAMP state. Parameters hopamp: OPAMP handle Return values HAL: state DOCID026526 Rev 4 UM1786 HAL_OPAMP_GetTrimOffset Function Name OPAMP_TrimmingValueTypeDef HAL_OPAMP_GetTrimOffset (OPAMP_HandleTypeDef * hopamp, uint32_t trimmingoffset) Function Description Return the OPAMP factory trimming value. Parameters hopamp: OPAMP handle trimmingoffset: Trimming offset (P or N) Return values Trimming: value (P or N): range: 0->31 or OPAMP_FACTORYTRIMMING_DUMMY if trimming value is not available 31.3 OPAMP Firmware driver defines 31.3.1 OPAMP OPAMP CSR init register Mask OPAMP_CSR_UPDATE_PARAMETERS_INIT_MASK OPAMP Exported Macros __HAL_OPAMP_RESET_HANDLE_STATE Description: Reset OPAMP handle state. Parameters: __HANDLE__: OPAMP handle. Return value: None OPAMP Factory Trimming OPAMP_FACTORYTRIMMING_DUMMY Dummy trimming value OPAMP_FACTORYTRIMMING_N Offset trimming N OPAMP_FACTORYTRIMMING_P Offset trimming P IS_OPAMP_FACTORYTRIMMING OPAMP Input OPAMP_INPUT_INVERTING Inverting input OPAMP_INPUT_NONINVERTING Non inverting input IS_OPAMP_INPUT OPAMP Inverting Input OPAMP_INVERTINGINPUT_IO0 inverting input connected to VM0 OPAMP_INVERTINGINPUT_IO1 inverting input connected to VM1 IS_OPAMP_INVERTING_INPUT OPAMP Inverting Input Secondary OPAMP_SEC_INVERTINGINPUT_IO0 VM0 (PC5 for OPAMP1 and OPAMP2, PB10 for OPAMP3 and OPAMP4) connected to OPAMPx inverting input DOCID026526 Rev 4 447/832 UM1786 VM1 (PA3 for OPAMP1, PA5 for OPAMP2, PB2 for OPAMP3, PD8 for OPAMP4) connected to OPAMPx inverting input OPAMP_SEC_INVERTINGINPUT_IO1 IS_OPAMP_SEC_INVERTINGINPUT OPAMP Mode OPAMP_STANDALONE_MODE standalone mode OPAMP_PGA_MODE PGA mode OPAMP_FOLLOWER_MODE follower mode IS_OPAMP_FUNCTIONAL_NORMALMODE OPAMP Non Inverting Input OPAMP_NONINVERTINGINPUT_IO0 VP0 (PA1 for OPAMP1, VP0 PA7 for OPAMP2, VP0 PB0 for OPAMP3, VP0 PB13 for OPAMP4) connected to OPAMPx non inverting input OPAMP_NONINVERTINGINPUT_IO1 VP1 (PA7 for OPAMP1, VP3 PD14 for OPAMP2, VP1 PB13 for OPAMP3, VP1 PD11 for OPAMP4) connected to OPAMPx non inverting input OPAMP_NONINVERTINGINPUT_IO2 VP2 (PA3 for OPAMP1, VP2 PB0 for OPAMP2, VP2 PA1 for OPAMP3, VP3 PA4 for OPAMP4) connected to OPAMPx non inverting input OPAMP_NONINVERTINGINPUT_IO3 VP3 (PA5 for OPAMP1, VP1 PB14 for OPAMP2, VP3 PA5 for OPAMP3, VP2 PB11 for OPAMP4) connected to OPAMPx non inverting input IS_OPAMP_NONINVERTING_INPUT OPAMP Non Inverting Input Secondary OPAMP_SEC_NONINVERTINGINPUT_IO0 VP0 (PA1 for OPAMP1, PA7 for OPAMP2, PB0 for OPAMP3, PB13 for OPAMP4) connected to OPAMPx non inverting input OPAMP_SEC_NONINVERTINGINPUT_IO1 VP1 (PA7 for OPAMP1, PD14 for OPAMP2, PB13 for OPAMP3, PD11 for OPAMP4) connected to OPAMPx non inverting input OPAMP_SEC_NONINVERTINGINPUT_IO2 VP2 (PA3 for OPAMP1, PB0 for OPAMP2, PA1 for OPAMP3, PA4 for OPAMP4) connected to OPAMPx non inverting input OPAMP_SEC_NONINVERTINGINPUT_IO3 VP3 (PA5 for OPAMP1, PB14 for OPAMP2, PA5 for OPAMP3, PB11 for OPAMP4) connected to OPAMPx non inverting input IS_OPAMP_SEC_NONINVERTINGINPUT OPAMP Pga Connect 448/832 OPAMP_PGA_CONNECT_INVERTINGINPUT_NO In PGA mode, the non inverting input is not connected OPAMP_PGA_CONNECT_INVERTINGINPUT_IO0 In PGA mode, the non inverting input is connected to VM0 OPAMP_PGA_CONNECT_INVERTINGINPUT_IO1 In PGA mode, the non inverting input is connected to VM1 DOCID026526 Rev 4 UM1786 IS_OPAMP_PGACONNECT OPAMP Pga Gain OPAMP_PGA_GAIN_2 PGA gain = 2 OPAMP_PGA_GAIN_4 PGA gain = 4 OPAMP_PGA_GAIN_8 PGA gain = 8 OPAMP_PGA_GAIN_16 PGA gain = 16 IS_OPAMP_PGA_GAIN OPAMP Timer Controlled Mux mode OPAMP_TIMERCONTROLLEDMUXMODE_DISABLE Timer controlled Mux mode disabled OPAMP_TIMERCONTROLLEDMUXMODE_ENABLE Timer controlled Mux mode enabled IS_OPAMP_TIMERCONTROLLED_MUXMODE OPAMP Trimming Value IS_OPAMP_TRIMMINGVALUE OPAMP User Trimming OPAMP_TRIMMING_FACTORY Factory trimming OPAMP_TRIMMING_USER User trimming IS_OPAMP_TRIMMING OPAMP_VREF_NOTCONNECTEDTO_ADC VREF not connected to ADC OPAMP_VREF_CONNECTEDTO_ADC VREF not connected to ADC IS_OPAMP_ALLOPAMPVREF_CONNECT OPAMP VREF OPAMP_VREF_3VDDA OPMAP Vref = 3.3% VDDA OPAMP_VREF_10VDDA OPMAP Vref = 10% VDDA OPAMP_VREF_50VDDA OPMAP Vref = 50% VDDA OPAMP_VREF_90VDDA OPMAP Vref = 90% VDDA IS_OPAMP_VREF DOCID026526 Rev 4 449/832 UM1786 32 HAL OPAMP Extension Driver 32.1 OPAMPEx Firmware driver API description 32.1.1 Detailed description of functions HAL_OPAMPEx_SelfCalibrateAll Function Name HAL_StatusTypeDef HAL_OPAMPEx_SelfCalibrateAll (OPAMP_HandleTypeDef * hopamp1, OPAMP_HandleTypeDef * hopamp2, OPAMP_HandleTypeDef * hopamp3, OPAMP_HandleTypeDef * hopamp4) Function Description Run the self calibration of 4 OPAMPs in parallel. Parameters hopamp1: hopamp2: hopamp3: hopamp4: Return values HAL: status Notes Updated offset trimming values (PMOS & NMOS), user trimming is enabled Calibration runs about 25 ms. 450/832 handle handle handle handle DOCID026526 Rev 4 UM1786 33 HAL PCCARD Generic Driver 33.1 PCCARD Firmware driver registers structures 33.1.1 PCCARD_HandleTypeDef Data Fields FMC_PCCARD_TypeDef * Instance FMC_PCCARD_InitTypeDef Init __IO HAL_PCCARD_StateTypeDef State HAL_LockTypeDef Lock Field Documentation FMC_PCCARD_TypeDef* PCCARD_HandleTypeDef::Instance Register base address for PCCARD device FMC_PCCARD_InitTypeDef PCCARD_HandleTypeDef::Init PCCARD device control configuration parameters __IO HAL_PCCARD_StateTypeDef PCCARD_HandleTypeDef::State PCCARD device access state HAL_LockTypeDef PCCARD_HandleTypeDef::Lock PCCARD Lock 33.2 PCCARD Firmware driver API description 33.2.1 How to use this driver This driver is a generic layered driver which contains a set of APIs used to control PCCARD/compact flash memories. It uses the FMC layer functions to interface with PCCARD devices. This driver is used for: PCCARD/compact flash memory configuration sequence using the function HAL_PCCARD_Init() with control and timing parameters for both common and attribute spaces. Read PCCARD/compact flash memory maker and device IDs using the function HAL_PCCARD_Read_ID(). The read information is stored in the CompactFlash_ID structure declared by the function caller. Access PCCARD/compact flash memory by read/write operations using the functions HAL_PCCARD_Read_Sector()/HAL_PCCARD_Write_Sector(), to read/write sector. Perform PCCARD/compact flash Reset chip operation using the function HAL_PCCARD_Reset(). Perform PCCARD/compact flash erase sector operation using the function HAL_PCCARD_Erase_Sector(). Read the PCCARD/compact flash status operation using the function HAL_PCCARD_ReadStatus(). You can monitor the PCCARD/compact flash device HAL state by calling the function HAL_PCCARD_GetState() DOCID026526 Rev 4 451/832 UM1786 This driver is a set of generic APIs which handle standard PCCARD/compact flash operations. If a PCCARD/compact flash device contains different operations and/or implementations, it should be implemented separately. 33.2.2 PCCARD Initialization and de-initialization functions This section provides functions allowing to initialize/de-initialize the PCCARD memory This section contains the following APIs: 33.2.3 HAL_PCCARD_Init() HAL_PCCARD_DeInit() HAL_PCCARD_MspInit() HAL_PCCARD_MspDeInit() PCCARD Input Output and memory functions This section provides functions allowing to use and control the PCCARD memory This section contains the following APIs: 33.2.4 HAL_PCCARD_Read_ID() HAL_PCCARD_Read_Sector() HAL_PCCARD_Write_Sector() HAL_PCCARD_Erase_Sector() HAL_PCCARD_Reset() HAL_PCCARD_IRQHandler() HAL_PCCARD_ITCallback() PCCARD Peripheral State functions This subsection permits to get in run-time the status of the PCCARD controller and the data flow. This section contains the following APIs: 33.2.5 HAL_PCCARD_GetState() HAL_PCCARD_GetStatus() HAL_PCCARD_ReadStatus() Detailed description of functions HAL_PCCARD_Init Function Name HAL_StatusTypeDef HAL_PCCARD_Init (PCCARD_HandleTypeDef * hpccard, FMC_NAND_PCC_TimingTypeDef * ComSpaceTiming, FMC_NAND_PCC_TimingTypeDef * AttSpaceTiming, FMC_NAND_PCC_TimingTypeDef * IOSpaceTiming) Function Description Perform the PCCARD memory Initialization sequence. Parameters 452/832 hpccard: pointer to a PCCARD_HandleTypeDef structure that contains the configuration information for PCCARD module. ComSpaceTiming: Common space timing structure AttSpaceTiming: Attribute space timing structure IOSpaceTiming: IO space timing structure DOCID026526 Rev 4 UM1786 Return values HAL: status HAL_PCCARD_DeInit Function Name HAL_StatusTypeDef HAL_PCCARD_DeInit (PCCARD_HandleTypeDef * hpccard) Function Description Perform the PCCARD memory De-initialization sequence. Parameters hpccard: pointer to a PCCARD_HandleTypeDef structure that contains the configuration information for PCCARD module. Return values HAL: status HAL_PCCARD_MspInit Function Name void HAL_PCCARD_MspInit (PCCARD_HandleTypeDef * hpccard) Function Description PCCARD MSP Init. Parameters hpccard: pointer to a PCCARD_HandleTypeDef structure that contains the configuration information for PCCARD module. Return values None: HAL_PCCARD_MspDeInit Function Name void HAL_PCCARD_MspDeInit (PCCARD_HandleTypeDef * hpccard) Function Description PCCARD MSP DeInit. Parameters hpccard: pointer to a PCCARD_HandleTypeDef structure that contains the configuration information for PCCARD module. Return values None: HAL_PCCARD_Read_ID Function Name HAL_StatusTypeDef HAL_PCCARD_Read_ID (PCCARD_HandleTypeDef * hpccard, uint8_t CompactFlash_ID, uint8_t * pStatus) Function Description Read Compact Flash's ID. Parameters Return values hpccard: pointer to a PCCARD_HandleTypeDef structure that contains the configuration information for PCCARD module. CompactFlash_ID: Compact flash ID structure. pStatus: pointer to compact flash status HAL: status DOCID026526 Rev 4 453/832 UM1786 HAL_PCCARD_Write_Sector Function Name HAL_StatusTypeDef HAL_PCCARD_Write_Sector (PCCARD_HandleTypeDef * hpccard, uint16_t * pBuffer, uint16_t SectorAddress, uint8_t * pStatus) Function Description Write sector to PCCARD memory. Parameters Return values hpccard: pointer to a PCCARD_HandleTypeDef structure that contains the configuration information for PCCARD module. pBuffer: pointer to source write buffer SectorAddress: Sector address to write pStatus: pointer to CF status HAL: status HAL_PCCARD_Read_Sector Function Name HAL_StatusTypeDef HAL_PCCARD_Read_Sector (PCCARD_HandleTypeDef * hpccard, uint16_t * pBuffer, uint16_t SectorAddress, uint8_t * pStatus) Function Description Read sector from PCCARD memory. Parameters Return values hpccard: pointer to a PCCARD_HandleTypeDef structure that contains the configuration information for PCCARD module. pBuffer: pointer to destination read buffer SectorAddress: Sector address to read pStatus: pointer to CF status HAL: status HAL_PCCARD_Erase_Sector Function Name HAL_StatusTypeDef HAL_PCCARD_Erase_Sector (PCCARD_HandleTypeDef * hpccard, uint16_t SectorAddress, uint8_t * pStatus) Function Description Erase sector from PCCARD memory. Parameters Return values hpccard: pointer to a PCCARD_HandleTypeDef structure that contains the configuration information for PCCARD module. SectorAddress: Sector address to erase pStatus: pointer to CF status HAL: status HAL_PCCARD_Reset 454/832 Function Name HAL_StatusTypeDef HAL_PCCARD_Reset (PCCARD_HandleTypeDef * hpccard) Function Description Reset the PCCARD memory. Parameters hpccard: pointer to a PCCARD_HandleTypeDef structure that contains the configuration information for PCCARD DOCID026526 Rev 4 UM1786 module. Return values HAL: status HAL_PCCARD_IRQHandler Function Name void HAL_PCCARD_IRQHandler (PCCARD_HandleTypeDef * hpccard) Function Description This function handles PCCARD device interrupt request. Parameters hpccard: pointer to a PCCARD_HandleTypeDef structure that contains the configuration information for PCCARD module. Return values HAL: status HAL_PCCARD_ITCallback Function Name void HAL_PCCARD_ITCallback (PCCARD_HandleTypeDef * hpccard) Function Description PCCARD interrupt feature callback. Parameters hpccard: pointer to a PCCARD_HandleTypeDef structure that contains the configuration information for PCCARD module. Return values None: HAL_PCCARD_GetState Function Name HAL_PCCARD_StateTypeDef HAL_PCCARD_GetState (PCCARD_HandleTypeDef * hpccard) Function Description return the PCCARD controller state Parameters hpccard: pointer to a PCCARD_HandleTypeDef structure that contains the configuration information for PCCARD module. Return values HAL: state HAL_PCCARD_GetStatus Function Name HAL_PCCARD_StatusTypeDef HAL_PCCARD_GetStatus (PCCARD_HandleTypeDef * hpccard) Function Description Get the compact flash memory status. Parameters hpccard: pointer to a PCCARD_HandleTypeDef structure that contains the configuration information for PCCARD module. Return values New: status of the CF operation. This parameter can be: CompactFlash_TIMEOUT_ERROR: when the previous operation generate a Timeout error CompactFlash_READY: when memory is ready for the next operation DOCID026526 Rev 4 455/832 UM1786 HAL_PCCARD_ReadStatus Function Name HAL_PCCARD_StatusTypeDef HAL_PCCARD_ReadStatus (PCCARD_HandleTypeDef * hpccard) Function Description Reads the Compact Flash memory status using the Read status command. Parameters hpccard: pointer to a PCCARD_HandleTypeDef structure that contains the configuration information for PCCARD module. Return values The: status of the Compact Flash memory. This parameter can be: CompactFlash_BUSY: when memory is busy CompactFlash_READY: when memory is ready for the next operation CompactFlash_ERROR: when the previous operation gererates error 33.3 PCCARD Firmware driver defines 33.3.1 PCCARD PCCARD Exported Macros __HAL_PCCARD_RESET_HANDLE_STATE Description: Reset PCCARD handle state. Parameters: __HANDLE__: specifies the PCCARD handle. Return value: 456/832 DOCID026526 Rev 4 None UM1786 34 HAL PCD Generic Driver 34.1 PCD Firmware driver registers structures 34.1.1 PCD_InitTypeDef Data Fields uint32_t dev_endpoints uint32_t speed uint32_t ep0_mps uint32_t phy_itface uint32_t Sof_enable uint32_t low_power_enable uint32_t lpm_enable uint32_t battery_charging_enable Field Documentation 34.1.2 uint32_t PCD_InitTypeDef::dev_endpoints Device Endpoints number. This parameter depends on the used USB core. This parameter must be a number between Min_Data = 1 and Max_Data = 15 uint32_t PCD_InitTypeDef::speed USB Core speed. This parameter can be any value of PCD_Core_Speed uint32_t PCD_InitTypeDef::ep0_mps Set the Endpoint 0 Max Packet size. This parameter can be any value of PCD_EP0_MPS uint32_t PCD_InitTypeDef::phy_itface Select the used PHY interface. This parameter can be any value of PCD_Core_PHY uint32_t PCD_InitTypeDef::Sof_enable Enable or disable the output of the SOF signal. This parameter can be set to ENABLE or DISABLE uint32_t PCD_InitTypeDef::low_power_enable Enable or disable Low Power mode This parameter can be set to ENABLE or DISABLE uint32_t PCD_InitTypeDef::lpm_enable Enable or disable the Link Power Management . This parameter can be set to ENABLE or DISABLE uint32_t PCD_InitTypeDef::battery_charging_enable Enable or disable Battery charging. This parameter can be set to ENABLE or DISABLE PCD_EPTypeDef Data Fields uint8_t num uint8_t is_in DOCID026526 Rev 4 457/832 UM1786 uint8_t is_stall uint8_t type uint16_t pmaadress uint16_t pmaaddr0 uint16_t pmaaddr1 uint8_t doublebuffer uint32_t maxpacket uint8_t * xfer_buff uint32_t xfer_len uint32_t xfer_count Field Documentation 34.1.3 uint8_t PCD_EPTypeDef::num Endpoint number This parameter must be a number between Min_Data = 1 and Max_Data = 15 uint8_t PCD_EPTypeDef::is_in Endpoint direction This parameter must be a number between Min_Data = 0 and Max_Data = 1 uint8_t PCD_EPTypeDef::is_stall Endpoint stall condition This parameter must be a number between Min_Data = 0 and Max_Data = 1 uint8_t PCD_EPTypeDef::type Endpoint type This parameter can be any value of PCD_EP_Type uint16_t PCD_EPTypeDef::pmaadress PMA Address This parameter can be any value between Min_addr = 0 and Max_addr = 1K uint16_t PCD_EPTypeDef::pmaaddr0 PMA Address0 This parameter can be any value between Min_addr = 0 and Max_addr = 1K uint16_t PCD_EPTypeDef::pmaaddr1 PMA Address1 This parameter can be any value between Min_addr = 0 and Max_addr = 1K uint8_t PCD_EPTypeDef::doublebuffer Double buffer enable This parameter can be 0 or 1 uint32_t PCD_EPTypeDef::maxpacket Endpoint Max packet size This parameter must be a number between Min_Data = 0 and Max_Data = 64KB uint8_t* PCD_EPTypeDef::xfer_buff Pointer to transfer buffer uint32_t PCD_EPTypeDef::xfer_len Current transfer length uint32_t PCD_EPTypeDef::xfer_count Partial transfer length in case of multi packet transfer PCD_HandleTypeDef Data Fields 458/832 PCD_TypeDef * Instance PCD_InitTypeDef Init DOCID026526 Rev 4 UM1786 __IO uint8_t USB_Address PCD_EPTypeDef IN_ep PCD_EPTypeDef OUT_ep HAL_LockTypeDef Lock __IO PCD_StateTypeDef State uint32_t Setup void * pData Field Documentation PCD_TypeDef* PCD_HandleTypeDef::Instance Register base address PCD_InitTypeDef PCD_HandleTypeDef::Init PCD required parameters __IO uint8_t PCD_HandleTypeDef::USB_Address USB Address PCD_EPTypeDef PCD_HandleTypeDef::IN_ep[15] IN endpoint parameters PCD_EPTypeDef PCD_HandleTypeDef::OUT_ep[15] OUT endpoint parameters HAL_LockTypeDef PCD_HandleTypeDef::Lock PCD peripheral status __IO PCD_StateTypeDef PCD_HandleTypeDef::State PCD communication state uint32_t PCD_HandleTypeDef::Setup[12] Setup packet buffer void* PCD_HandleTypeDef::pData Pointer to upper stack Handler 34.2 PCD Firmware driver API description 34.2.1 How to use this driver The PCD HAL driver can be used as follows: 1. 2. 3. 4. 5. 6. 34.2.2 Declare a PCD_HandleTypeDef handle structure, for example: PCD_HandleTypeDef hpcd; Fill parameters of Init structure in HCD handle Call HAL_PCD_Init() API to initialize the HCD peripheral (Core, Device core, ...) Initialize the PCD low level resources through the HAL_PCD_MspInit() API: a. Enable the PCD/USB Low Level interface clock using __HAL_RCC_USB_CLK_ENABLE(); b. Initialize the related GPIO clocks c. Configure PCD pin-out d. Configure PCD NVIC interrupt Associate the Upper USB device stack to the HAL PCD Driver: a. hpcd.pData = pdev; Enable HCD transmission and reception: a. HAL_PCD_Start(); Initialization and de-initialization functions This section provides functions allowing to: DOCID026526 Rev 4 459/832 UM1786 This section contains the following APIs: 34.2.3 HAL_PCD_Init() HAL_PCD_DeInit() HAL_PCD_MspInit() HAL_PCD_MspDeInit() IO operation functions This subsection provides a set of functions allowing to manage the PCD data transfers. This section contains the following APIs: 34.2.4 HAL_PCD_Start() HAL_PCD_Stop() HAL_PCD_IRQHandler() HAL_PCD_DataOutStageCallback() HAL_PCD_DataInStageCallback() HAL_PCD_SetupStageCallback() HAL_PCD_SOFCallback() HAL_PCD_ResetCallback() HAL_PCD_SuspendCallback() HAL_PCD_ResumeCallback() HAL_PCD_ISOOUTIncompleteCallback() HAL_PCD_ISOINIncompleteCallback() HAL_PCD_ConnectCallback() HAL_PCD_DisconnectCallback() Peripheral Control functions This subsection provides a set of functions allowing to control the PCD data transfers. This section contains the following APIs: 34.2.5 HAL_PCD_DevConnect() HAL_PCD_DevDisconnect() HAL_PCD_SetAddress() HAL_PCD_EP_Open() HAL_PCD_EP_Close() HAL_PCD_EP_Receive() HAL_PCD_EP_GetRxCount() HAL_PCD_EP_Transmit() HAL_PCD_EP_SetStall() HAL_PCD_EP_ClrStall() HAL_PCD_EP_Flush() HAL_PCD_ActivateRemoteWakeup() HAL_PCD_DeActivateRemoteWakeup() HAL_PCD_ActiveRemoteWakeup() HAL_PCD_DeActiveRemoteWakeup() Peripheral State functions This subsection permits to get in run-time the status of the peripheral and the data flow. This section contains the following APIs: 460/832 HAL_PCD_GetState() DOCID026526 Rev 4 UM1786 34.2.6 Detailed description of functions HAL_PCD_Init Function Name HAL_StatusTypeDef HAL_PCD_Init (PCD_HandleTypeDef * hpcd) Function Description Initializes the PCD according to the specified parameters in the PCD_InitTypeDef and create the associated handle. Parameters hpcd: PCD handle Return values HAL: status HAL_PCD_DeInit Function Name HAL_StatusTypeDef HAL_PCD_DeInit (PCD_HandleTypeDef * hpcd) Function Description DeInitializes the PCD peripheral. Parameters hpcd: PCD handle Return values HAL: status HAL_PCD_MspInit Function Name void HAL_PCD_MspInit (PCD_HandleTypeDef * hpcd) Function Description Initializes the PCD MSP. Parameters hpcd: PCD handle Return values None: HAL_PCD_MspDeInit Function Name void HAL_PCD_MspDeInit (PCD_HandleTypeDef * hpcd) Function Description DeInitializes PCD MSP. Parameters hpcd: PCD handle Return values None: HAL_PCD_Start Function Name HAL_StatusTypeDef HAL_PCD_Start (PCD_HandleTypeDef * hpcd) Function Description Start the USB device. Parameters hpcd: PCD handle Return values HAL: status HAL_PCD_Stop Function Name HAL_StatusTypeDef HAL_PCD_Stop (PCD_HandleTypeDef * hpcd) DOCID026526 Rev 4 461/832 UM1786 Function Description Stop the USB device. Parameters hpcd: PCD handle Return values HAL: status HAL_PCD_IRQHandler Function Name void HAL_PCD_IRQHandler (PCD_HandleTypeDef * hpcd) Function Description This function handles PCD interrupt request. Parameters hpcd: PCD handle Return values HAL: status HAL_PCD_DataOutStageCallback Function Name void HAL_PCD_DataOutStageCallback (PCD_HandleTypeDef * hpcd, uint8_t epnum) Function Description Data out stage callbacks. Parameters hpcd: PCD handle epnum: endpoint number Return values None: HAL_PCD_DataInStageCallback Function Name void HAL_PCD_DataInStageCallback (PCD_HandleTypeDef * hpcd, uint8_t epnum) Function Description Data IN stage callbacks. Parameters hpcd: PCD handle epnum: endpoint number Return values None: HAL_PCD_SetupStageCallback Function Name void HAL_PCD_SetupStageCallback (PCD_HandleTypeDef * hpcd) Function Description Setup stage callback. Parameters hpcd: PCD handle Return values None: HAL_PCD_SOFCallback 462/832 Function Name void HAL_PCD_SOFCallback (PCD_HandleTypeDef * hpcd) Function Description USB Start Of Frame callbacks. Parameters hpcd: PCD handle Return values None: DOCID026526 Rev 4 UM1786 HAL_PCD_ResetCallback Function Name void HAL_PCD_ResetCallback (PCD_HandleTypeDef * hpcd) Function Description USB Reset callbacks. Parameters hpcd: PCD handle Return values None: HAL_PCD_SuspendCallback Function Name void HAL_PCD_SuspendCallback (PCD_HandleTypeDef * hpcd) Function Description Suspend event callbacks. Parameters hpcd: PCD handle Return values None: HAL_PCD_ResumeCallback Function Name void HAL_PCD_ResumeCallback (PCD_HandleTypeDef * hpcd) Function Description Resume event callbacks. Parameters hpcd: PCD handle Return values None: HAL_PCD_ISOOUTIncompleteCallback Function Name void HAL_PCD_ISOOUTIncompleteCallback (PCD_HandleTypeDef * hpcd, uint8_t epnum) Function Description Incomplete ISO OUT callbacks. Parameters hpcd: PCD handle epnum: endpoint number Return values None: HAL_PCD_ISOINIncompleteCallback Function Name void HAL_PCD_ISOINIncompleteCallback (PCD_HandleTypeDef * hpcd, uint8_t epnum) Function Description Incomplete ISO IN callbacks. Parameters hpcd: PCD handle epnum: endpoint number Return values None: HAL_PCD_ConnectCallback Function Name void HAL_PCD_ConnectCallback (PCD_HandleTypeDef * hpcd) DOCID026526 Rev 4 463/832 UM1786 Function Description Connection event callbacks. Parameters hpcd: PCD handle Return values None: HAL_PCD_DisconnectCallback Function Name void HAL_PCD_DisconnectCallback (PCD_HandleTypeDef * hpcd) Function Description Disconnection event callbacks. Parameters hpcd: PCD handle Return values None: HAL_PCD_DevConnect Function Name HAL_StatusTypeDef HAL_PCD_DevConnect (PCD_HandleTypeDef * hpcd) Function Description Connect the USB device. Parameters hpcd: PCD handle Return values HAL: status HAL_PCD_DevDisconnect Function Name HAL_StatusTypeDef HAL_PCD_DevDisconnect (PCD_HandleTypeDef * hpcd) Function Description Disconnect the USB device. Parameters hpcd: PCD handle Return values HAL: status HAL_PCD_SetAddress Function Name HAL_StatusTypeDef HAL_PCD_SetAddress (PCD_HandleTypeDef * hpcd, uint8_t address) Function Description Set the USB Device address. Parameters hpcd: PCD handle address: new device address Return values HAL: status HAL_PCD_EP_Open 464/832 Function Name HAL_StatusTypeDef HAL_PCD_EP_Open (PCD_HandleTypeDef * hpcd, uint8_t ep_addr, uint16_t ep_mps, uint8_t ep_type) Function Description Open and configure an endpoint. Parameters hpcd: PCD handle ep_addr: endpoint address DOCID026526 Rev 4 UM1786 Return values ep_mps: endpoint max packet size ep_type: endpoint type HAL: status HAL_PCD_EP_Close Function Name HAL_StatusTypeDef HAL_PCD_EP_Close (PCD_HandleTypeDef * hpcd, uint8_t ep_addr) Function Description Deactivate an endpoint. Parameters hpcd: PCD handle ep_addr: endpoint address Return values HAL: status HAL_PCD_EP_Receive Function Name HAL_StatusTypeDef HAL_PCD_EP_Receive (PCD_HandleTypeDef * hpcd, uint8_t ep_addr, uint8_t * pBuf, uint32_t len) Function Description Receive an amount of data. Parameters hpcd: PCD handle ep_addr: endpoint address pBuf: pointer to the reception buffer len: amount of data to be received Return values HAL: status HAL_PCD_EP_Transmit Function Name HAL_StatusTypeDef HAL_PCD_EP_Transmit (PCD_HandleTypeDef * hpcd, uint8_t ep_addr, uint8_t * pBuf, uint32_t len) Function Description Send an amount of data. Parameters hpcd: PCD handle ep_addr: endpoint address pBuf: pointer to the transmission buffer len: amount of data to be sent Return values HAL: status HAL_PCD_EP_GetRxCount Function Name uint16_t HAL_PCD_EP_GetRxCount (PCD_HandleTypeDef * hpcd, uint8_t ep_addr) Function Description Get Received Data Size. Parameters hpcd: PCD handle ep_addr: endpoint address Return values Data: Size DOCID026526 Rev 4 465/832 UM1786 HAL_PCD_EP_SetStall Function Name HAL_StatusTypeDef HAL_PCD_EP_SetStall (PCD_HandleTypeDef * hpcd, uint8_t ep_addr) Function Description Set a STALL condition over an endpoint. Parameters hpcd: PCD handle ep_addr: endpoint address Return values HAL: status HAL_PCD_EP_ClrStall Function Name HAL_StatusTypeDef HAL_PCD_EP_ClrStall (PCD_HandleTypeDef * hpcd, uint8_t ep_addr) Function Description Clear a STALL condition over in an endpoint. Parameters hpcd: PCD handle ep_addr: endpoint address Return values HAL: status HAL_PCD_EP_Flush Function Name HAL_StatusTypeDef HAL_PCD_EP_Flush (PCD_HandleTypeDef * hpcd, uint8_t ep_addr) Function Description Flush an endpoint. Parameters hpcd: PCD handle ep_addr: endpoint address Return values HAL: status HAL_PCD_ActivateRemoteWakeup Function Name HAL_StatusTypeDef HAL_PCD_ActivateRemoteWakeup (PCD_HandleTypeDef * hpcd) Function Description HAL_PCD_ActivateRemoteWakeup : active remote wakeup signalling. Parameters hpcd: PCD handle Return values HAL: status HAL_PCD_DeActivateRemoteWakeup 466/832 Function Name HAL_StatusTypeDef HAL_PCD_DeActivateRemoteWakeup (PCD_HandleTypeDef * hpcd) Function Description HAL_PCD_DeActivateRemoteWakeup : de-active remote wakeup signalling. Parameters hpcd: PCD handle Return values HAL: status DOCID026526 Rev 4 UM1786 HAL_PCD_GetState Function Name PCD_StateTypeDef HAL_PCD_GetState (PCD_HandleTypeDef * hpcd) Function Description Return the PCD state. Parameters hpcd: : PCD handle Return values HAL: state HAL_PCD_ActiveRemoteWakeup Function Name HAL_StatusTypeDef HAL_PCD_ActiveRemoteWakeup (PCD_HandleTypeDef * hpcd) Function Description HAL_PCD_DeActiveRemoteWakeup Function Name HAL_StatusTypeDef HAL_PCD_DeActiveRemoteWakeup (PCD_HandleTypeDef * hpcd) Function Description PCD_WritePMA Function Name void PCD_WritePMA (USB_TypeDef * USBx, uint8_t * pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes) Function Description Copy a buffer from user memory area to packet memory area (PMA) Parameters USBx: USB peripheral instance register address. pbUsrBuf: pointer to user memory area. wPMABufAddr: address into PMA. wNBytes: no. of bytes to be copied. Return values None: PCD_ReadPMA Function Name void PCD_ReadPMA (USB_TypeDef * USBx, uint8_t * pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes) Function Description Copy a buffer from user memory area to packet memory area (PMA) Parameters USBx: USB peripheral instance register address. pbUsrBuf: pointer to user memory area. wPMABufAddr: address into PMA. wNBytes: no. of bytes to be copied. Return values None: DOCID026526 Rev 4 467/832 UM1786 34.3 PCD Firmware driver defines 34.3.1 PCD PCD Core PHY PCD_PHY_EMBEDDED PCD Core Speed PCD_SPEED_HIGH PCD_SPEED_FULL PCD ENDP PCD_ENDP0 PCD_ENDP1 PCD_ENDP2 PCD_ENDP3 PCD_ENDP4 PCD_ENDP5 PCD_ENDP6 PCD_ENDP7 PCD Endpoint Kind PCD_SNG_BUF PCD_DBL_BUF PCD EP0 MPS DEP0CTL_MPS_64 DEP0CTL_MPS_32 DEP0CTL_MPS_16 DEP0CTL_MPS_8 PCD_EP0MPS_64 PCD_EP0MPS_32 PCD_EP0MPS_16 PCD_EP0MPS_08 PCD EP Type PCD_EP_TYPE_CTRL PCD_EP_TYPE_ISOC PCD_EP_TYPE_BULK PCD_EP_TYPE_INTR PCD Exported Macros __HAL_PCD_GET_FLAG __HAL_PCD_CLEAR_FLAG 468/832 DOCID026526 Rev 4 UM1786 __HAL_USB_WAKEUP_EXTI_ENABLE_IT __HAL_USB_WAKEUP_EXTI_DISABLE_IT __HAL_USB_EXTI_GENERATE_SWIT __HAL_USB_WAKEUP_EXTI_GET_FLAG __HAL_USB_WAKEUP_EXTI_CLEAR_FLAG __HAL_USB_WAKEUP_EXTI_ENABLE_RISING_EDGE __HAL_USB_WAKEUP_EXTI_ENABLE_FALLING_EDGE __HAL_USB_WAKEUP_EXTI_ENABLE_RISING_FALLING_EDGE PCD Instance definition IS_PCD_ALL_INSTANCE DOCID026526 Rev 4 469/832 UM1786 35 HAL PCD Extension Driver 35.1 PCDEx Firmware driver API description 35.1.1 Extended Peripheral Control functions This section provides functions allowing to: Update PMA configuration This section contains the following APIs: 35.1.2 HAL_PCDEx_PMAConfig() HAL_PCDEx_SetConnectionState() Detailed description of functions HAL_PCDEx_PMAConfig Function Name HAL_StatusTypeDef HAL_PCDEx_PMAConfig (PCD_HandleTypeDef * hpcd, uint16_t ep_addr, uint16_t ep_kind, uint32_t pmaadress) Function Description Configure PMA for EP. Parameters Return values hpcd: PCD handle ep_addr: endpoint address ep_kind: endpoint Kind USB_SNG_BUF: Single Buffer used USB_DBL_BUF: Double Buffer used pmaadress: EP address in The PMA: In case of single buffer endpoint this parameter is 16-bit value providing the address in PMA allocated to endpoint. In case of double buffer endpoint this parameter is a 32-bit value providing the endpoint buffer 0 address in the LSB part of 32-bit value and endpoint buffer 1 address in the MSB part of 32-bit value. :: status HAL_PCDEx_SetConnectionState Function Name void HAL_PCDEx_SetConnectionState (PCD_HandleTypeDef * hpcd, uint8_t state) Function Description Software Device Connection. Parameters hpcd: PCD handle state: Device state Return values None: 35.2 PCDEx Firmware driver defines 35.2.1 PCDEx PCD Extended Exported Macros 470/832 DOCID026526 Rev 4 UM1786 PCD_EP_TX_ADDRESS Description: Gets address in an endpoint register. Parameters: USBx: USB peripheral instance register address. bEpNum: Endpoint Number. Return value: None PCD_EP_TX_CNT PCD_EP_RX_ADDRESS PCD_EP_RX_CNT PCD_SET_EP_RX_CNT DOCID026526 Rev 4 471/832 UM1786 36 HAL PWR Generic Driver 36.1 PWR Firmware driver API description 36.1.1 Initialization and de-initialization functions After reset, the backup domain (RTC registers, RTC backup data registers and backup SRAM) is protected against possible unwanted write accesses. To enable access to the RTC Domain and RTC registers, proceed as follows: 36.1.2 Enable the Power Controller (PWR) APB1 interface clock using the __HAL_RCC_PWR_CLK_ENABLE() macro. Enable access to RTC domain using the HAL_PWR_EnableBkUpAccess() function. Peripheral Control functions WakeUp pin configuration WakeUp pin is used to wakeup the system from Standby mode. This pin is forced in input pull down configuration and is active on rising edges. There are up to three WakeUp pins: WakeUp Pin 1 on PA.00. WakeUp Pin 2 on PC.13 (STM32F303xC, STM32F303xE only). WakeUp Pin 3 on PE.06. Main and Backup Regulators configuration When the backup domain is supplied by VDD (analog switch connected to VDD) the backup SRAM is powered from VDD which replaces the VBAT power supply to save battery life. The backup SRAM is not mass erased by a tamper event. It is read protected to prevent confidential data, such as cryptographic private key, from being accessed. The backup SRAM can be erased only through the Flash interface when a protection level change from level 1 to level 0 is requested. Refer to the description of Read protection (RDP) in the Flash programming manual. Refer to the datasheets for more details. Low Power modes configuration The devices feature 3 low-power modes: Sleep mode: Cortex-M4 core stopped, peripherals kept running. Stop mode: all clocks are stopped, regulator running, regulator in low power mode Standby mode: 1.2V domain powered off (mode not available on STM32F3x8 devices). Sleep mode 472/832 DOCID026526 Rev 4 UM1786 Entry: The Sleep mode is entered by using the HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFx) functions with PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction Exit: Any peripheral interrupt acknowledged by the nested vectored interrupt controller (NVIC) can wake up the device from Sleep mode. Stop mode In Stop mode, all clocks in the 1.8V domain are stopped, the PLL, the HSI, and the HSE RC oscillators are disabled. Internal SRAM and register contents are preserved. The voltage regulator can be configured either in normal or low-power mode to minimize the consumption. Entry: The Stop mode is entered using the HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFI ) function with: Main regulator ON or Low Power regulator ON. PWR_STOPENTRY_WFI: enter STOP mode with WFI instruction or PWR_STOPENTRY_WFE: enter STOP mode with WFE instruction Exit: Any EXTI Line (Internal or External) configured in Interrupt/Event mode. Some specific communication peripherals (CEC, USART, I2C) interrupts, when programmed in wakeup mode (the peripheral must be programmed in wakeup mode and the corresponding interrupt vector must be enabled in the NVIC). Standby mode The Standby mode allows to achieve the lowest power consumption. It is based on the Cortex-M4 deep sleep mode, with the voltage regulator disabled. The 1.8V domain is consequently powered off. The PLL, the HSI oscillator and the HSE oscillator are also switched off. SRAM and register contents are lost except for the RTC registers, RTC backup registers, backup SRAM and Standby circuitry. The voltage regulator is OFF. Entry: The Standby mode is entered using the HAL_PWR_EnterSTANDBYMode() function. Exit: 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, an RTC Wakeup event, a tamper event, a time-stamp event, or a comparator event, without depending on an external interrupt (Auto-wakeup mode). RTC auto-wakeup (AWU) from the Stop and Standby modes To wake up from the Stop mode with an RTC alarm event, it is necessary to configure the RTC to generate the RTC alarm using the HAL_RTC_SetAlarm_IT() function. To wake up from the Stop mode with an RTC Tamper or time stamp event, it is necessary to configure the RTC to detect the tamper or time stamp event using the HAL_RTC_SetTimeStamp_IT() or HAL_RTC_SetTamper_IT() functions. DOCID026526 Rev 4 473/832 UM1786 To wake up from the Stop mode with an RTC WakeUp event, it is necessary to configure the RTC to generate the RTC WakeUp event using the HAL_RTC_SetWakeUpTimer_IT() function. Comparator auto-wakeup (AWU) from the Stop mode To wake up from the Stop mode with a comparator wakeup event, it is necessary to: Configure the EXTI Line associated with the comparator (example EXTI Line 22 for comparator 2) to be sensitive to to the selected edges (falling, rising or falling and rising) (Interrupt or Event modes) using the EXTI_Init() function. Configure the comparator to generate the event. This section contains the following APIs: 36.1.3 HAL_PWR_EnableWakeUpPin() HAL_PWR_DisableWakeUpPin() HAL_PWR_EnterSLEEPMode() HAL_PWR_EnterSTOPMode() HAL_PWR_EnterSTANDBYMode() HAL_PWR_EnableSleepOnExit() HAL_PWR_DisableSleepOnExit() HAL_PWR_EnableSEVOnPend() HAL_PWR_DisableSEVOnPend() HAL_PWR_EnableBkUpAccess() HAL_PWR_DisableBkUpAccess() Detailed description of functions HAL_PWR_DeInit Function Name void HAL_PWR_DeInit (void ) Function Description Deinitializes the PWR peripheral registers to their default reset values. Return values None: HAL_PWR_EnableBkUpAccess Function Name void HAL_PWR_EnableBkUpAccess (void ) Function Description Enables access to the backup domain (RTC registers, RTC backup data registers and backup SRAM). Return values None: Notes If the HSE divided by 32 is used as the RTC clock, the Backup Domain Access should be kept enabled. HAL_PWR_DisableBkUpAccess 474/832 Function Name void HAL_PWR_DisableBkUpAccess (void ) Function Description Disables access to the backup domain (RTC registers, RTC backup data registers and backup SRAM). Return values None: Notes If the HSE divided by 32 is used as the RTC clock, the DOCID026526 Rev 4 UM1786 Backup Domain Access should be kept enabled. HAL_PWR_EnableWakeUpPin Function Name void HAL_PWR_EnableWakeUpPin (uint32_t WakeUpPinx) Function Description Enables the WakeUp PINx functionality. Parameters WakeUpPinx: Specifies the Power Wake-Up pin to enable. This parameter can be one of the following values: PWR_WAKEUP_PIN1, PWR_WAKEUP_PIN2, PWR_WAKEUP_PIN3 Return values None: HAL_PWR_DisableWakeUpPin Function Name void HAL_PWR_DisableWakeUpPin (uint32_t WakeUpPinx) Function Description Disables the WakeUp PINx functionality. Parameters WakeUpPinx: Specifies the Power Wake-Up pin to disable. This parameter can be one of the following values: PWR_WAKEUP_PIN1, PWR_WAKEUP_PIN2, PWR_WAKEUP_PIN3 Return values None: HAL_PWR_EnterSTOPMode Function Name void HAL_PWR_EnterSTOPMode (uint32_t Regulator, uint8_t STOPEntry) Function Description Enters STOP mode. Parameters Regulator: Specifies the regulator state in STOP mode. This parameter can be one of the following values: PWR_MAINREGULATOR_ON: STOP mode with regulator ON PWR_LOWPOWERREGULATOR_ON: STOP mode with low power regulator ON STOPEntry: specifies if STOP mode in entered with WFI or WFE instruction. This parameter can be one of the following values: PWR_STOPENTRY_WFI:Enter STOP mode with WFI instruction PWR_STOPENTRY_WFE: Enter STOP mode with WFE instruction Return values None: Notes In Stop mode, all I/O pins keep the same state as in Run mode. When exiting Stop mode by issuing an interrupt or a wakeup event, the HSI RC oscillator is selected as system clock. When the voltage regulator operates in low power mode, an additional startup delay is incurred when waking up from Stop mode. By keeping the internal regulator ON during Stop mode, the consumption is higher although the startup time is DOCID026526 Rev 4 475/832 UM1786 reduced. HAL_PWR_EnterSLEEPMode Function Name void HAL_PWR_EnterSLEEPMode (uint32_t Regulator, uint8_t SLEEPEntry) Function Description Enters Sleep mode. Parameters Regulator: Specifies the regulator state in SLEEP mode. This parameter can be one of the following values: PWR_MAINREGULATOR_ON: SLEEP mode with regulator ON PWR_LOWPOWERREGULATOR_ON: SLEEP mode with low power regulator ON SLEEPEntry: Specifies if SLEEP mode is entered with WFI or WFE instruction. When WFI entry is used, tick interrupt have to be disabled if not desired as the interrupt wake up source. This parameter can be one of the following values: PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction Return values None: Notes In Sleep mode, all I/O pins keep the same state as in Run mode. This parameter has no effect in F3 family and is just maintained to offer full portability of other STM32 families softwares. HAL_PWR_EnterSTANDBYMode Function Name void HAL_PWR_EnterSTANDBYMode (void ) Function Description Enters STANDBY mode. Return values None: Notes In Standby mode, all I/O pins are high impedance except for: Reset pad (still available),RTC alternate function pins if configured for tamper, time-stamp, RTC Alarm out, or RTC clock calibration out,WKUP pins if enabled. HAL_PWR_EnableSleepOnExit 476/832 Function Name void HAL_PWR_EnableSleepOnExit (void ) Function Description Indicates Sleep-On-Exit when returning from Handler mode to Thread mode. Return values None: Notes Set SLEEPONEXIT bit of SCR register. When this bit is set, the processor re-enters SLEEP mode when an interruption handling is over. Setting this bit is useful when the processor is expected to run only on interruptions handling. DOCID026526 Rev 4 UM1786 HAL_PWR_DisableSleepOnExit Function Name void HAL_PWR_DisableSleepOnExit (void ) Function Description Disables Sleep-On-Exit feature when returning from Handler mode to Thread mode. Return values None: Notes Clears SLEEPONEXIT bit of SCR register. When this bit is set, the processor re-enters SLEEP mode when an interruption handling is over. HAL_PWR_EnableSEVOnPend Function Name void HAL_PWR_EnableSEVOnPend (void ) Function Description Enables CORTEX M4 SEVONPEND bit. Return values None: Notes Sets SEVONPEND bit of SCR register. When this bit is set, this causes WFE to wake up when an interrupt moves from inactive to pended. HAL_PWR_DisableSEVOnPend Function Name void HAL_PWR_DisableSEVOnPend (void ) Function Description Disables CORTEX M4 SEVONPEND bit. Return values None: Notes Clears SEVONPEND bit of SCR register. When this bit is set, this causes WFE to wake up when an interrupt moves from inactive to pended. 36.2 PWR Firmware driver defines 36.2.1 PWR PWR Alias Exported Constants PWR_OFFSET CR_OFFSET DBP_BIT_NUMBER CR_DBP_BB PVDE_BIT_NUMBER CR_PVDE_BB CSR_OFFSET EWUP1_BitNumber CSR_EWUP1_BB EWUP2_BitNumber CSR_EWUP2_BB DOCID026526 Rev 4 477/832 UM1786 EWUP3_BitNumber CSR_EWUP3_BB PWR Exported Macro Description: __HAL_PWR_GET_FLAG Check PWR flag is set or not. Parameters: __FLAG__: specifies the flag to check. This parameter can be one of the following values: PWR_FLAG_WU: Wake Up flag. This flag indicates that a wakeup event was received from the WKUP pin or from the RTC alarm (Alarm A or Alarm B), RTC Tamper event, RTC TimeStamp event or RTC Wakeup. An additional wakeup event is detected if the WKUP pin is enabled (by setting the EWUP bit) when the WKUP pin level is already high. 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 HAL_PWR_EnablePVD() function. The PVD is stopped by Standby mode For this reason, this bit is equal to 0 after Standby or reset until the PVDE bit is set. PWR_FLAG_VREFINTRDY: This flag indicates that the internal reference voltage VREFINT is ready. Return value: The: new state of __FLAG__ (TRUE or FALSE). Description: __HAL_PWR_CLEAR_FLAG Clear the PWR's pending flags. Parameters: __FLAG__: specifies the flag to clear. This parameter can be one of the following values: PWR_FLAG_WU: Wake Up flag PWR_FLAG_SB: StandBy flag PWR Flag PWR_FLAG_WU Wakeup event from wakeup pin or RTC alarm PWR_FLAG_SB Standby flag PWR_FLAG_PVDO Power Voltage Detector output flag PWR_FLAG_VREFINTRDY VREFINT reference voltage ready PWR Regulator state in STOP mode PWR_MAINREGULATOR_ON 478/832 Voltage regulator on during STOP mode DOCID026526 Rev 4 UM1786 PWR_LOWPOWERREGULATOR_ON Voltage regulator in low-power mode during STOP mode PWR SLEEP mode entry PWR_SLEEPENTRY_WFI Wait For Interruption instruction to enter SLEEP mode PWR_SLEEPENTRY_WFE Wait For Event instruction to enter SLEEP mode PWR STOP mode entry PWR_STOPENTRY_WFI Wait For Interruption instruction to enter STOP mode PWR_STOPENTRY_WFE Wait For Event instruction to enter STOP mode PWR WakeUp Pins PWR_WAKEUP_PIN1 Wakeup pin 1 PWR_WAKEUP_PIN2 Wakeup pin 2 PWR_WAKEUP_PIN3 Wakeup pin 3 DOCID026526 Rev 4 479/832 UM1786 37 HAL PWR Extension Driver 37.1 PWREx Firmware driver registers structures 37.1.1 PWR_PVDTypeDef Data Fields uint32_t PVDLevel uint32_t Mode Field Documentation uint32_t PWR_PVDTypeDef::PVDLevel PVDLevel: Specifies the PVD detection level This parameter can be a value of PWREx_PVD_detection_level uint32_t PWR_PVDTypeDef::Mode Mode: Specifies the operating mode for the selected pins. This parameter can be a value of PWREx_PVD_Mode 37.2 PWREx Firmware driver API description 37.2.1 Peripheral Extended control functions PVD configuration (present on all other devices than STM32F3x8 devices) The PVD is used to monitor the VDD power supply by comparing it to a threshold selected by the PVD Level (PLS[2:0] bits in the PWR_CR). A PVDO flag is available to indicate if VDD/VDDA is higher or lower than the PVD threshold. This event is internally connected to the EXTI line16 and can generate an interrupt if enabled. This is done through __HAL_PWR_PVD_EXTI_ENABLE_IT() macro The PVD is stopped in Standby mode. PVD is not available on STM32F3x8 Product Line Voltage regulator 480/832 The voltage regulator is always enabled after Reset. It works in three different modes. In Run mode, the regulator supplies full power to the 1.8V domain (core, memories and digital peripherals). In Stop mode, the regulator supplies low power to the 1.8V domain, preserving contents of registers and SRAM. In Stop mode, the regulator is powered off. The contents of the registers and SRAM are lost except for the Standby circuitry and the Backup Domain. Note: in the STM32F3x8xx devices, the voltage regulator is bypassed and the microcontroller must be powered from a nominal VDD = 1.8V +/-8% voltage. DOCID026526 Rev 4 UM1786 A PVDO flag is available to indicate if VDD/VDDA is higher or lower than the PVD threshold. This event is internally connected to the EXTI line16 and can generate an interrupt if enabled. This is done through __HAL_PWR_PVD_EXTI_ENABLE_IT() macro The PVD is stopped in Standby mode. SDADC power configuration On STM32F373xC/STM32F378xx devices, there are up to 3 SDADC instances that can be enabled/disabled. This section contains the following APIs: 37.2.2 HAL_PWR_ConfigPVD() HAL_PWR_EnablePVD() HAL_PWR_DisablePVD() HAL_PWR_PVD_IRQHandler() HAL_PWR_PVDCallback() Detailed description of functions HAL_PWR_ConfigPVD Function Name void HAL_PWR_ConfigPVD (PWR_PVDTypeDef * sConfigPVD) Function Description Configures the voltage threshold detected by the Power Voltage Detector(PVD). Parameters sConfigPVD: pointer to an PWR_PVDTypeDef structure that contains the configuration information for the PVD. Return values None: Notes Refer to the electrical characteristics of your device datasheet for more details about the voltage threshold corresponding to each detection level. HAL_PWR_EnablePVD Function Name void HAL_PWR_EnablePVD (void ) Function Description Enables the Power Voltage Detector(PVD). Return values None: HAL_PWR_DisablePVD Function Name void HAL_PWR_DisablePVD (void ) Function Description Disables the Power Voltage Detector(PVD). Return values None: HAL_PWR_PVD_IRQHandler Function Name void HAL_PWR_PVD_IRQHandler (void ) Function Description This function handles the PWR PVD interrupt request. DOCID026526 Rev 4 481/832 UM1786 Return values None: Notes This API should be called under the PVD_IRQHandler(). HAL_PWR_PVDCallback Function Name void HAL_PWR_PVDCallback (void ) Function Description PWR PVD interrupt callback. Return values None: 37.3 PWREx Firmware driver defines 37.3.1 PWREx PWR Extended Exported Constants PWR_EXTI_LINE_PVD External interrupt line 16 Connected to the PVD EXTI Line PWR Extended Exported Macros __HAL_PWR_PVD_EXTI_ENABLE_IT Description: Enable interrupt on PVD Exti Line 16. Return value: __HAL_PWR_PVD_EXTI_DISABLE_IT None. Description: Disable interrupt on PVD Exti Line 16. Return value: __HAL_PWR_PVD_EXTI_GENERATE_SWIT None. Description: Generate a Software interrupt on selected EXTI line. Return value: __HAL_PWR_PVD_EXTI_ENABLE_EVENT None. Description: Enable event on PVD Exti Line 16. Return value: __HAL_PWR_PVD_EXTI_DISABLE_EVENT Description: 482/832 DOCID026526 Rev 4 None. Disable event on PVD Exti Line 16. UM1786 Return value: __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE None. Description: Disable the PVD Extended Interrupt Rising Trigger. Return value: __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE None. Description: Disable the PVD Extended Interrupt Falling Trigger. Return value: __HAL_PWR_PVD_EXTI_DISABLE_RISING_FALLING_EDGE None. Description: Disable the PVD Extended Interrupt Rising & Falling Trigger. Return value: __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE None Description: PVD EXTI line configuration: set falling edge trigger. Return value: __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE None. Description: PVD EXTI line configuration: set rising edge trigger. Return value: __HAL_PWR_PVD_EXTI_ENABLE_RISING_FALLING_EDGE None. Description: Enable the PVD Extended Interrupt Rising & Falling Trigger. Return value: __HAL_PWR_PVD_EXTI_GET_FLAG DOCID026526 Rev 4 None Description: 483/832 UM1786 Check whether the specified PVD EXTI interrupt flag is set or not. Return value: EXTI: PVD Line Status. Description: __HAL_PWR_PVD_EXTI_CLEAR_FLAG Clear the PVD EXTI flag. Return value: None. PWR Extended PVD detection level PWR_PVDLEVEL_0 PVD threshold around 2.2 V PWR_PVDLEVEL_1 PVD threshold around 2.3 V PWR_PVDLEVEL_2 PVD threshold around 2.4 V PWR_PVDLEVEL_3 PVD threshold around 2.5 V PWR_PVDLEVEL_4 PVD threshold around 2.6 V PWR_PVDLEVEL_5 PVD threshold around 2.7 V PWR_PVDLEVEL_6 PVD threshold around 2.8 V PWR_PVDLEVEL_7 PVD threshold around 2.9 V PWR Extended PVD Mode 484/832 PWR_PVD_MODE_NORMAL Basic mode is used PWR_PVD_MODE_IT_RISING External Interrupt Mode with Rising edge trigger detection PWR_PVD_MODE_IT_FALLING External Interrupt Mode with Falling edge trigger detection PWR_PVD_MODE_IT_RISING_FALLING External Interrupt Mode with Rising/Falling edge trigger detection PWR_PVD_MODE_EVENT_RISING Event Mode with Rising edge trigger detection PWR_PVD_MODE_EVENT_FALLING Event Mode with Falling edge trigger detection PWR_PVD_MODE_EVENT_RISING_FALLING Event Mode with Rising/Falling edge trigger detection DOCID026526 Rev 4 UM1786 38 HAL RCC Generic Driver 38.1 RCC Firmware driver registers structures 38.1.1 RCC_PLLInitTypeDef Data Fields uint32_t PLLState uint32_t PLLSource uint32_t PLLMUL Field Documentation 38.1.2 uint32_t RCC_PLLInitTypeDef::PLLState PLLState: The new state of the PLL. This parameter can be a value of RCC_PLL_Config uint32_t RCC_PLLInitTypeDef::PLLSource PLLSource: PLL entry clock source. This parameter must be a value of RCC_PLL_Clock_Source uint32_t RCC_PLLInitTypeDef::PLLMUL PLLMUL: Multiplication factor for PLL VCO input clock This parameter must be a value of RCC_PLL_Multiplication_Factor RCC_OscInitTypeDef Data Fields uint32_t OscillatorType uint32_t HSEState uint32_t HSEPredivValue uint32_t LSEState uint32_t HSIState uint32_t HSICalibrationValue uint32_t LSIState RCC_PLLInitTypeDef PLL Field Documentation uint32_t RCC_OscInitTypeDef::OscillatorType The oscillators to be configured. This parameter can be a value of RCC_Oscillator_Type uint32_t RCC_OscInitTypeDef::HSEState The new state of the HSE. This parameter can be a value of RCC_HSE_Config uint32_t RCC_OscInitTypeDef::HSEPredivValue The HSE predivision factor value. This parameter can be a value of RCC_PLL_HSE_Prediv_Factor DOCID026526 Rev 4 485/832 UM1786 38.1.3 uint32_t RCC_OscInitTypeDef::LSEState The new state of the LSE. This parameter can be a value of RCC_LSE_Config uint32_t RCC_OscInitTypeDef::HSIState The new state of the HSI. This parameter can be a value of RCC_HSI_Config uint32_t RCC_OscInitTypeDef::HSICalibrationValue The HSI calibration trimming value (default is RCC_HSICALIBRATION_DEFAULT). This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x1F uint32_t RCC_OscInitTypeDef::LSIState The new state of the LSI. This parameter can be a value of RCC_LSI_Config RCC_PLLInitTypeDef RCC_OscInitTypeDef::PLL PLL structure parameters RCC_ClkInitTypeDef Data Fields uint32_t ClockType uint32_t SYSCLKSource uint32_t AHBCLKDivider uint32_t APB1CLKDivider uint32_t APB2CLKDivider Field Documentation uint32_t RCC_ClkInitTypeDef::ClockType The clock to be configured. This parameter can be a value of RCC_System_Clock_Type uint32_t RCC_ClkInitTypeDef::SYSCLKSource The clock source (SYSCLKS) used as system clock. This parameter can be a value of RCC_System_Clock_Source uint32_t RCC_ClkInitTypeDef::AHBCLKDivider The AHB clock (HCLK) divider. This clock is derived from the system clock (SYSCLK). This parameter can be a value of RCC_AHB_Clock_Source uint32_t RCC_ClkInitTypeDef::APB1CLKDivider The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK). This parameter can be a value of RCC_APB1_APB2_Clock_Source uint32_t RCC_ClkInitTypeDef::APB2CLKDivider The APB2 clock (PCLK2) divider. This clock is derived from the AHB clock (HCLK). This parameter can be a value of RCC_APB1_APB2_Clock_Source 38.2 RCC Firmware driver API description 38.2.1 RCC specific features After reset the device is running from Internal High Speed oscillator (HSI 8MHz) with Flash 0 wait state, Flash prefetch buffer is enabled, and all peripherals are off except internal SRAM, Flash and JTAG. 486/832 There is no prescaler on High speed (AHB) and Low speed (APB) buses; all peripherals mapped on these buses are running at HSI speed. The clock for all peripherals is switched off, except the SRAM and FLASH. DOCID026526 Rev 4 UM1786 All GPIOs are in input floating state, except the JTAG pins which are assigned to be used for debug purpose. Once the device started from reset, the user application has to: 38.2.2 Configure the clock source to be used to drive the System clock (if the application needs higher frequency/performance) Configure the System clock frequency and Flash settings Configure the AHB and APB buses prescalers Enable the clock for the peripheral(s) to be used Configure the clock source(s) for peripherals whose clocks are not derived from the System clock (RTC, ADC, I2C, I2S, TIM, USB FS) RCC Limitations A delay between an RCC peripheral clock enable and the effective peripheral enabling should be taken into account in order to manage the peripheral read/write from/to registers. This delay depends on the peripheral mapping. AHB & APB peripherals, 1 dummy read is necessary Workarounds: 1. 38.2.3 For AHB & APB peripherals, a dummy read to the peripheral register has been inserted in each __HAL_RCC_PPP_CLK_ENABLE() macro. Initialization and de-initialization functions This section provides functions allowing to configure the internal/external oscillators (HSE, HSI, LSE, LSI, PLL, CSS and MCO) and the System buses clocks (SYSCLK, AHB, APB1 and APB2). Internal/external clock and PLL configuration 1. 2. 3. 4. 5. 6. 7. HSI (high-speed internal), 8 MHz factory-trimmed RC used directly or through the PLL as System clock source. The HSI clock can be used also to clock the USART and I2C peripherals. LSI (low-speed internal), ~40 KHz low consumption RC used as IWDG and/or RTC clock source. HSE (high-speed external), 4 to 32 MHz crystal oscillator used directly or through the PLL as System clock source. Can be used also as RTC clock source. LSE (low-speed external), 32 KHz oscillator used as RTC clock source. PLL (clocked by HSI or HSE), featuring different output clocks: The first output is used to generate the high speed system clock (up to 72 MHz) The second output is used to generate the clock for the USB FS (48 MHz) The third output may be used to generate the clock for the ADC peripherals (up to 72 MHz) The fourth output may be used to generate the clock for the TIM peripherals (144 MHz) CSS (Clock security system), once enable using the macro __HAL_RCC_CSS_ENABLE() and if a HSE clock failure occurs(HSE used directly or through PLL as System clock source), the System clocks automatically switched to HSI and an interrupt is generated if enabled. The interrupt is linked to the Cortex-M4 NMI (Non-Maskable Interrupt) exception vector. MCO (microcontroller clock output), used to output SYSCLK, HSI, HSE, LSI, LSE or PLL clock (divided by 2) output on pin (such as PA8 pin). System, AHB and APB buses clocks configuration DOCID026526 Rev 4 487/832 1. 2. 3. 4. UM1786 Several clock sources can be used to drive the System clock (SYSCLK): HSI, HSE and PLL. The AHB clock (HCLK) is derived from System clock through configurable prescaler and used to clock the CPU, memory and peripherals mapped on AHB bus (DMA, GPIO...). APB1 (PCLK1) and APB2 (PCLK2) clocks are derived from AHB clock through configurable prescalers and used to clock the peripherals mapped on these buses. You can use "@ref HAL_RCC_GetSysClockFreq()" function to retrieve the frequencies of these clocks. All the peripheral clocks are derived from the System clock (SYSCLK) except: The FLASH program/erase clock which is always HSI 8MHz clock. The USB 48 MHz clock which is derived from the PLL VCO clock. The USART clock which can be derived as well from HSI 8MHz, LSI or LSE. The I2C clock which can be derived as well from HSI 8MHz clock. The ADC clock which is derived from PLL output. The RTC clock which is derived from the LSE, LSI or 1 MHz HSE_RTC (HSE divided by a programmable prescaler). The System clock (SYSCLK) frequency must be higher or equal to the RTC clock frequency. IWDG clock which is always the LSI clock. For the STM32F3xx devices, the maximum frequency of the SYSCLK, HCLK, PCLK1 and PCLK2 is 72 MHz, Depending on the SYSCLK frequency, the flash latency should be adapted accordingly. After reset, the System clock source is the HSI (8 MHz) with 0 WS and prefetch is disabled. This section contains the following APIs: 38.2.4 HAL_RCC_DeInit() HAL_RCC_OscConfig() HAL_RCC_ClockConfig() Peripheral Control functions This subsection provides a set of functions allowing to control the RCC Clocks frequencies. This section contains the following APIs: 38.2.5 HAL_RCC_MCOConfig() HAL_RCC_EnableCSS() HAL_RCC_DisableCSS() HAL_RCC_GetSysClockFreq() HAL_RCC_GetHCLKFreq() HAL_RCC_GetPCLK1Freq() HAL_RCC_GetPCLK2Freq() HAL_RCC_GetOscConfig() HAL_RCC_GetClockConfig() HAL_RCC_NMI_IRQHandler() HAL_RCC_CSSCallback() Detailed description of functions HAL_RCC_DeInit 488/832 Function Name void HAL_RCC_DeInit (void ) Function Description Resets the RCC clock configuration to the default reset state. Return values None: DOCID026526 Rev 4 UM1786 Notes The default reset state of the clock configuration is given below: HSI ON and used as system clock sourceHSE and PLL OFFAHB, APB1 and APB2 prescaler set to 1.CSS and MCO1 OFFAll interrupts disabled This function does not modify the configuration of the Peripheral clocksLSI, LSE and RTC clocks HAL_RCC_OscConfig Function Name HAL_StatusTypeDef HAL_RCC_OscConfig (RCC_OscInitTypeDef * RCC_OscInitStruct) Function Description Initializes the RCC Oscillators according to the specified parameters in the RCC_OscInitTypeDef. Parameters RCC_OscInitStruct: pointer to an RCC_OscInitTypeDef structure that contains the configuration information for the RCC Oscillators. Return values HAL: status Notes The PLL is not disabled when used as system clock. Transitions LSE Bypass to LSE On and LSE On to LSE Bypass are not supported by this macro. User should request a transition to LSE Off first and then LSE On or LSE Bypass. Transition HSE Bypass to HSE On and HSE On to HSE Bypass are not supported by this macro. User should request a transition to HSE Off first and then HSE On or HSE Bypass. HAL_RCC_ClockConfig Function Name HAL_StatusTypeDef HAL_RCC_ClockConfig (RCC_ClkInitTypeDef * RCC_ClkInitStruct, uint32_t FLatency) Function Description Initializes the CPU, AHB and APB buses clocks according to the specified parameters in the RCC_ClkInitStruct. Parameters RCC_ClkInitStruct: pointer to an RCC_OscInitTypeDef structure that contains the configuration information for the RCC peripheral. FLatency: FLASH Latency The value of this parameter depend on device used within the same series Return values HAL: status Notes The SystemCoreClock CMSIS variable is used to store System Clock Frequency and updated by HAL_RCC_GetHCLKFreq() function called within this function The HSI is used (enabled by hardware) as system clock source after start-up from Reset, wake-up from STOP and STANDBY mode, or in case of failure of the HSE used directly or indirectly as system clock (if the Clock Security System CSS is enabled). A switch from one clock source to another occurs only if the target clock source is ready (clock stable after start-up delay or PLL locked). If a clock source which is not yet ready is selected, the switch will occur when the clock source will be ready. You can use HAL_RCC_GetClockConfig() function to DOCID026526 Rev 4 489/832 UM1786 know which clock is currently used as system clock source. HAL_RCC_MCOConfig Function Name void HAL_RCC_MCOConfig (uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_MCODiv) Function Description Selects the clock source to output on MCO pin. Parameters RCC_MCOx: specifies the output direction for the clock source. This parameter can be one of the following values: RCC_MCO1 Clock source to output on MCO1 pin(PA8). RCC_MCOSource: specifies the clock source to output. This parameter can be one of the following values: RCC_MCO1SOURCE_NOCLOCK No clock selected as MCO clock RCC_MCO1SOURCE_SYSCLK System clock selected as MCO clock RCC_MCO1SOURCE_HSI HSI selected as MCO clock RCC_MCO1SOURCE_HSE HSE selected as MCO clock RCC_MCO1SOURCE_LSI LSI selected as MCO clock RCC_MCO1SOURCE_LSE LSE selected as MCO clock RCC_MCO1SOURCE_PLLCLK_DIV2 PLLCLK Divided by 2 selected as MCO clock RCC_MCODiv: specifies the MCO DIV. This parameter can be one of the following values: RCC_MCODIV_1 no division applied to MCO clock Return values None: Notes MCO pin should be configured in alternate function mode. HAL_RCC_EnableCSS Function Name void HAL_RCC_EnableCSS (void ) Function Description Enables the Clock Security System. Return values None: Notes If a failure is detected on the HSE oscillator clock, this oscillator is automatically disabled and an interrupt is generated to inform the software about the failure (Clock Security System Interrupt, CSSI), allowing the MCU to perform rescue operations. The CSSI is linked to the CortexM4 NMI (Non-Maskable Interrupt) exception vector. HAL_RCC_DisableCSS 490/832 Function Name void HAL_RCC_DisableCSS (void ) Function Description Disables the Clock Security System. Return values None: DOCID026526 Rev 4 UM1786 HAL_RCC_GetSysClockFreq Function Name uint32_t HAL_RCC_GetSysClockFreq (void ) Function Description Returns the SYSCLK frequency. Return values SYSCLK: frequency Notes The system frequency computed by this function is not the real frequency in the chip. It is calculated based on the predefined constant and the selected clock source: If SYSCLK source is HSI, function returns values based on HSI_VALUE(*) If SYSCLK source is HSE, function returns a value based on HSE_VALUE divided by PREDIV factor(**) If SYSCLK source is PLL, function returns a value based on HSE_VALUE divided by PREDIV factor(**) or HSI_VALUE(*) multiplied by the PLL factor. (*) HSI_VALUE is a constant defined in stm32f3xx_hal_conf.h file (default value 8 MHz) but the real value may vary depending on the variations in voltage and temperature. (**) HSE_VALUE is a constant defined in stm32f3xx_hal_conf.h file (default value 8 MHz), user has to ensure that HSE_VALUE is same as the real frequency of the crystal used. Otherwise, this function may have wrong result. The result of this function could be not correct when using fractional value for HSE crystal. This function can be used by the user application to compute the baud-rate for the communication peripherals or configure other parameters. Each time SYSCLK changes, this function must be called to update the right SYSCLK value. Otherwise, any configuration based on this function will be incorrect. HAL_RCC_GetHCLKFreq Function Name uint32_t HAL_RCC_GetHCLKFreq (void ) Function Description Returns the HCLK frequency. Return values HCLK: frequency Notes Each time HCLK changes, this function must be called to update the right HCLK value. Otherwise, any configuration based on this function will be incorrect. The SystemCoreClock CMSIS variable is used to store System Clock Frequency and updated within this function HAL_RCC_GetPCLK1Freq Function Name uint32_t HAL_RCC_GetPCLK1Freq (void ) Function Description Returns the PCLK1 frequency. Return values PCLK1: frequency Notes Each time PCLK1 changes, this function must be called to update the right PCLK1 value. Otherwise, any configuration DOCID026526 Rev 4 491/832 UM1786 based on this function will be incorrect. HAL_RCC_GetPCLK2Freq Function Name uint32_t HAL_RCC_GetPCLK2Freq (void ) Function Description Returns the PCLK2 frequency. Return values PCLK2: frequency Notes Each time PCLK2 changes, this function must be called to update the right PCLK2 value. Otherwise, any configuration based on this function will be incorrect. HAL_RCC_GetOscConfig Function Name void HAL_RCC_GetOscConfig (RCC_OscInitTypeDef * RCC_OscInitStruct) Function Description Configures the RCC_OscInitStruct according to the internal RCC configuration registers. Parameters RCC_OscInitStruct: pointer to an RCC_OscInitTypeDef structure that will be configured. Return values None: HAL_RCC_GetClockConfig Function Name void HAL_RCC_GetClockConfig (RCC_ClkInitTypeDef * RCC_ClkInitStruct, uint32_t * pFLatency) Function Description Get the RCC_ClkInitStruct according to the internal RCC configuration registers. Parameters Return values RCC_ClkInitStruct: pointer to an RCC_ClkInitTypeDef structure that contains the current clock configuration. pFLatency: Pointer on the Flash Latency. None: HAL_RCC_NMI_IRQHandler Function Name void HAL_RCC_NMI_IRQHandler (void ) Function Description This function handles the RCC CSS interrupt request. Return values None: Notes This API should be called under the NMI_Handler(). HAL_RCC_CSSCallback 492/832 Function Name void HAL_RCC_CSSCallback (void ) Function Description RCC Clock Security System interrupt callback. Return values none: DOCID026526 Rev 4 UM1786 38.3 RCC Firmware driver defines 38.3.1 RCC RCC AHB Clock Enable Disable __HAL_RCC_GPIOA_CLK_ENABLE __HAL_RCC_GPIOB_CLK_ENABLE __HAL_RCC_GPIOC_CLK_ENABLE __HAL_RCC_GPIOD_CLK_ENABLE __HAL_RCC_GPIOF_CLK_ENABLE __HAL_RCC_CRC_CLK_ENABLE __HAL_RCC_DMA1_CLK_ENABLE __HAL_RCC_SRAM_CLK_ENABLE __HAL_RCC_FLITF_CLK_ENABLE __HAL_RCC_TSC_CLK_ENABLE __HAL_RCC_GPIOA_CLK_DISABLE __HAL_RCC_GPIOB_CLK_DISABLE __HAL_RCC_GPIOC_CLK_DISABLE __HAL_RCC_GPIOD_CLK_DISABLE __HAL_RCC_GPIOF_CLK_DISABLE __HAL_RCC_CRC_CLK_DISABLE __HAL_RCC_DMA1_CLK_DISABLE __HAL_RCC_SRAM_CLK_DISABLE __HAL_RCC_FLITF_CLK_DISABLE __HAL_RCC_TSC_CLK_DISABLE AHB Clock Source RCC_SYSCLK_DIV1 SYSCLK not divided RCC_SYSCLK_DIV2 SYSCLK divided by 2 RCC_SYSCLK_DIV4 SYSCLK divided by 4 RCC_SYSCLK_DIV8 SYSCLK divided by 8 RCC_SYSCLK_DIV16 SYSCLK divided by 16 RCC_SYSCLK_DIV64 SYSCLK divided by 64 RCC_SYSCLK_DIV128 SYSCLK divided by 128 RCC_SYSCLK_DIV256 SYSCLK divided by 256 RCC_SYSCLK_DIV512 SYSCLK divided by 512 RCC AHB Force Release Reset __HAL_RCC_AHB_FORCE_RESET __HAL_RCC_GPIOA_FORCE_RESET DOCID026526 Rev 4 493/832 UM1786 __HAL_RCC_GPIOB_FORCE_RESET __HAL_RCC_GPIOC_FORCE_RESET __HAL_RCC_GPIOD_FORCE_RESET __HAL_RCC_GPIOF_FORCE_RESET __HAL_RCC_TSC_FORCE_RESET __HAL_RCC_AHB_RELEASE_RESET __HAL_RCC_GPIOA_RELEASE_RESET __HAL_RCC_GPIOB_RELEASE_RESET __HAL_RCC_GPIOC_RELEASE_RESET __HAL_RCC_GPIOD_RELEASE_RESET __HAL_RCC_GPIOF_RELEASE_RESET __HAL_RCC_TSC_RELEASE_RESET AHB Peripheral Clock Enable Disable Status __HAL_RCC_GPIOA_IS_CLK_ENABLED __HAL_RCC_GPIOB_IS_CLK_ENABLED __HAL_RCC_GPIOC_IS_CLK_ENABLED __HAL_RCC_GPIOD_IS_CLK_ENABLED __HAL_RCC_GPIOF_IS_CLK_ENABLED __HAL_RCC_CRC_IS_CLK_ENABLED __HAL_RCC_DMA1_IS_CLK_ENABLED __HAL_RCC_SRAM_IS_CLK_ENABLED __HAL_RCC_FLITF_IS_CLK_ENABLED __HAL_RCC_TSC_IS_CLK_ENABLED __HAL_RCC_GPIOA_IS_CLK_DISABLED __HAL_RCC_GPIOB_IS_CLK_DISABLED __HAL_RCC_GPIOC_IS_CLK_DISABLED __HAL_RCC_GPIOD_IS_CLK_DISABLED __HAL_RCC_GPIOF_IS_CLK_DISABLED __HAL_RCC_CRC_IS_CLK_DISABLED __HAL_RCC_DMA1_IS_CLK_DISABLED __HAL_RCC_SRAM_IS_CLK_DISABLED __HAL_RCC_FLITF_IS_CLK_DISABLED __HAL_RCC_TSC_IS_CLK_DISABLED APB1 APB2 Clock Source 494/832 RCC_HCLK_DIV1 HCLK not divided RCC_HCLK_DIV2 HCLK divided by 2 DOCID026526 Rev 4 UM1786 RCC_HCLK_DIV4 HCLK divided by 4 RCC_HCLK_DIV8 HCLK divided by 8 RCC_HCLK_DIV16 HCLK divided by 16 RCC APB1 Clock Enable Disable __HAL_RCC_TIM2_CLK_ENABLE __HAL_RCC_TIM6_CLK_ENABLE __HAL_RCC_WWDG_CLK_ENABLE __HAL_RCC_USART2_CLK_ENABLE __HAL_RCC_USART3_CLK_ENABLE __HAL_RCC_I2C1_CLK_ENABLE __HAL_RCC_PWR_CLK_ENABLE __HAL_RCC_DAC1_CLK_ENABLE __HAL_RCC_TIM2_CLK_DISABLE __HAL_RCC_TIM6_CLK_DISABLE __HAL_RCC_WWDG_CLK_DISABLE __HAL_RCC_USART2_CLK_DISABLE __HAL_RCC_USART3_CLK_DISABLE __HAL_RCC_I2C1_CLK_DISABLE __HAL_RCC_PWR_CLK_DISABLE __HAL_RCC_DAC1_CLK_DISABLE APB1 Peripheral Clock Enable Disable Status __HAL_RCC_TIM2_IS_CLK_ENABLED __HAL_RCC_TIM6_IS_CLK_ENABLED __HAL_RCC_WWDG_IS_CLK_ENABLED __HAL_RCC_USART2_IS_CLK_ENABLED __HAL_RCC_USART3_IS_CLK_ENABLED __HAL_RCC_I2C1_IS_CLK_ENABLED __HAL_RCC_PWR_IS_CLK_ENABLED __HAL_RCC_DAC1_IS_CLK_ENABLED __HAL_RCC_TIM2_IS_CLK_DISABLED __HAL_RCC_TIM6_IS_CLK_DISABLED __HAL_RCC_WWDG_IS_CLK_DISABLED __HAL_RCC_USART2_IS_CLK_DISABLED __HAL_RCC_USART3_IS_CLK_DISABLED __HAL_RCC_I2C1_IS_CLK_DISABLED __HAL_RCC_PWR_IS_CLK_DISABLED DOCID026526 Rev 4 495/832 UM1786 __HAL_RCC_DAC1_IS_CLK_DISABLED RCC APB1 Force Release Reset __HAL_RCC_APB1_FORCE_RESET __HAL_RCC_TIM2_FORCE_RESET __HAL_RCC_TIM6_FORCE_RESET __HAL_RCC_WWDG_FORCE_RESET __HAL_RCC_USART2_FORCE_RESET __HAL_RCC_USART3_FORCE_RESET __HAL_RCC_I2C1_FORCE_RESET __HAL_RCC_PWR_FORCE_RESET __HAL_RCC_DAC1_FORCE_RESET __HAL_RCC_APB1_RELEASE_RESET __HAL_RCC_TIM2_RELEASE_RESET __HAL_RCC_TIM6_RELEASE_RESET __HAL_RCC_WWDG_RELEASE_RESET __HAL_RCC_USART2_RELEASE_RESET __HAL_RCC_USART3_RELEASE_RESET __HAL_RCC_I2C1_RELEASE_RESET __HAL_RCC_PWR_RELEASE_RESET __HAL_RCC_DAC1_RELEASE_RESET RCC APB2 Clock Enable Disable __HAL_RCC_SYSCFG_CLK_ENABLE __HAL_RCC_TIM15_CLK_ENABLE __HAL_RCC_TIM16_CLK_ENABLE __HAL_RCC_TIM17_CLK_ENABLE __HAL_RCC_USART1_CLK_ENABLE __HAL_RCC_SYSCFG_CLK_DISABLE __HAL_RCC_TIM15_CLK_DISABLE __HAL_RCC_TIM16_CLK_DISABLE __HAL_RCC_TIM17_CLK_DISABLE __HAL_RCC_USART1_CLK_DISABLE APB2 Peripheral Clock Enable Disable Status __HAL_RCC_SYSCFG_IS_CLK_ENABLED __HAL_RCC_TIM15_IS_CLK_ENABLED __HAL_RCC_TIM16_IS_CLK_ENABLED __HAL_RCC_TIM17_IS_CLK_ENABLED 496/832 DOCID026526 Rev 4 UM1786 __HAL_RCC_USART1_IS_CLK_ENABLED __HAL_RCC_SYSCFG_IS_CLK_DISABLED __HAL_RCC_TIM15_IS_CLK_DISABLED __HAL_RCC_TIM16_IS_CLK_DISABLED __HAL_RCC_TIM17_IS_CLK_DISABLED __HAL_RCC_USART1_IS_CLK_DISABLED RCC APB2 Force Release Reset __HAL_RCC_APB2_FORCE_RESET __HAL_RCC_SYSCFG_FORCE_RESET __HAL_RCC_TIM15_FORCE_RESET __HAL_RCC_TIM16_FORCE_RESET __HAL_RCC_TIM17_FORCE_RESET __HAL_RCC_USART1_FORCE_RESET __HAL_RCC_APB2_RELEASE_RESET __HAL_RCC_SYSCFG_RELEASE_RESET __HAL_RCC_TIM15_RELEASE_RESET __HAL_RCC_TIM16_RELEASE_RESET __HAL_RCC_TIM17_RELEASE_RESET __HAL_RCC_USART1_RELEASE_RESET BitAddress AliasRegion RCC_CR_OFFSET_BB RCC_CFGR_OFFSET_BB RCC_CIR_OFFSET_BB RCC_BDCR_OFFSET_BB RCC_CSR_OFFSET_BB RCC_HSION_BIT_NUMBER RCC_CR_HSION_BB RCC_HSEON_BIT_NUMBER RCC_CR_HSEON_BB RCC_CSSON_BIT_NUMBER RCC_CR_CSSON_BB RCC_PLLON_BIT_NUMBER RCC_CR_PLLON_BB RCC_LSION_BIT_NUMBER RCC_CSR_LSION_BB RCC_RMVF_BIT_NUMBER DOCID026526 Rev 4 497/832 UM1786 RCC_CSR_RMVF_BB RCC_LSEON_BIT_NUMBER RCC_BDCR_LSEON_BB RCC_LSEBYP_BIT_NUMBER RCC_BDCR_LSEBYP_BB RCC_RTCEN_BIT_NUMBER RCC_BDCR_RTCEN_BB RCC_BDRST_BIT_NUMBER RCC_BDCR_BDRST_BB Flags RCC_FLAG_HSIRDY Internal High Speed clock ready flag RCC_FLAG_HSERDY External High Speed clock ready flag RCC_FLAG_PLLRDY PLL clock ready flag RCC_FLAG_LSIRDY Internal Low Speed oscillator Ready RCC_FLAG_V18PWRRST RCC_FLAG_OBLRST Options bytes loading reset flag RCC_FLAG_PINRST PIN reset flag RCC_FLAG_PORRST POR/PDR reset flag RCC_FLAG_SFTRST Software Reset flag RCC_FLAG_IWDGRST Independent Watchdog reset flag RCC_FLAG_WWDGRST Window watchdog reset flag RCC_FLAG_LPWRRST Low-Power reset flag RCC_FLAG_LSERDY External Low Speed oscillator Ready RCC_FLAG_MCO Microcontroller Clock Output Flag Flags Interrupts Management __HAL_RCC_ENABLE_IT Description: Enable RCC interrupt. Parameters: __HAL_RCC_DISABLE_IT 498/832 __INTERRUPT__: specifies the RCC interrupt sources to be enabled. This parameter can be any combination of the following values: 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 main PLL ready interrupt Description: DOCID026526 Rev 4 UM1786 Disable RCC interrupt. Parameters: __INTERRUPT__: specifies the RCC interrupt sources to be disabled. This parameter can be any combination of the following values: 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 main PLL ready interrupt Description: __HAL_RCC_CLEAR_IT Clear the RCC's interrupt pending bits. Parameters: __INTERRUPT__: specifies the interrupt pending bit to clear. This parameter can be any combination of the following values: 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 Main PLL ready interrupt. RCC_IT_CSS Clock Security System interrupt Description: __HAL_RCC_GET_IT Check the RCC's interrupt has occurred or not. Parameters: __INTERRUPT__: specifies the RCC interrupt source to check. This parameter can be one of the following values: 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 Main PLL ready interrupt. RCC_IT_CSS Clock Security System interrupt Return value: __HAL_RCC_CLEAR_RESET_FLAGS The: new state of __INTERRUPT__ (TRUE or FALSE). The reset flags are RCC_FLAG_PINRST, DOCID026526 Rev 4 499/832 UM1786 RCC_FLAG_PORRST, RCC_FLAG_SFTRST, RCC_FLAG_OBLRST, RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST, RCC_FLAG_LPWRRST Description: __HAL_RCC_GET_FLAG Check RCC flag is set or not. Parameters: __FLAG__: specifies the flag to check. This parameter can be one of the following values: RCC_FLAG_HSIRDY HSI oscillator clock ready. RCC_FLAG_HSERDY HSE oscillator clock ready. RCC_FLAG_PLLRDY Main PLL clock ready. RCC_FLAG_LSERDY LSE oscillator clock ready. RCC_FLAG_LSIRDY LSI oscillator clock ready. RCC_FLAG_OBLRST Option Byte Load reset RCC_FLAG_PINRST Pin reset. RCC_FLAG_PORRST POR/PDR reset. RCC_FLAG_SFTRST Software reset. RCC_FLAG_IWDGRST Independent Watchdog reset. RCC_FLAG_WWDGRST Window Watchdog reset. RCC_FLAG_LPWRRST Low Power reset. Return value: The: new state of __FLAG__ (TRUE or FALSE). Get Clock source __HAL_RCC_SYSCLK_CONFIG Description: Macro to configure the system clock source. Parameters: 500/832 __SYSCLKSOURCE__: specifies the system clock source. This parameter can be one of the following values: RCC_SYSCLKSOURCE_HSI HSI oscillator is used as system clock source. RCC_SYSCLKSOURCE_HSE HSE oscillator is used as system clock source. RCC_SYSCLKSOURCE_PLLCLK PLL output is used as system clock source. DOCID026526 Rev 4 UM1786 __HAL_RCC_GET_SYSCLK_SOU RCE Description: Macro to get the clock source used as system clock. Return value: The: clock source used as system clock. The returned value can be one of the following: RCC_SYSCLKSOURCE_STATUS_HSI HSI used as system clock RCC_SYSCLKSOURCE_STATUS_HSE HSE used as system clock RCC_SYSCLKSOURCE_STATUS_PLLCL K PLL used as system clock HSE Config RCC_HSE_OFF HSE clock deactivation RCC_HSE_ON HSE clock activation RCC_HSE_BYPASS External clock source for HSE clock HSE Configuration __HAL_RCC_HSE_CONFIG Description: Macro to configure the External High Speed oscillator (HSE). Parameters: __STATE__: specifies the new state of the HSE. This parameter can be one of the following values: RCC_HSE_OFF turn OFF the HSE oscillator, HSERDY flag goes low after 6 HSE oscillator clock cycles. RCC_HSE_ON turn ON the HSE oscillator RCC_HSE_BYPASS HSE oscillator bypassed with external clock Notes: Transition HSE Bypass to HSE On and HSE On to HSE Bypass are not supported by this macro. User should request a transition to HSE Off first and then HSE On or HSE Bypass. 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. HSE state can not be changed if it is used directly or through the PLL as system clock. In this case, you have to select another source of the system clock then change the HSE state (ex. disable it). The HSE is stopped by hardware when entering STOP and STANDBY modes. This function reset the CSSON bit, so if the clock security system(CSS) was previously enabled you have to enable it again after calling this function. HSI Config DOCID026526 Rev 4 501/832 UM1786 RCC_HSI_OFF HSI clock deactivation RCC_HSI_ON HSI clock activation RCC_HSICALIBRATION_DEFAULT HSI Configuration Notes: __HAL_RCC_HSI_ENABLE The HSI is stopped by hardware when entering STOP and STANDBY modes. It is used (enabled by hardware) as system clock source after startup from Reset, wakeup from STOP and STANDBY mode, or in case of failure of the HSE used directly or indirectly as system clock (if the Clock Security System CSS is enabled). HSI can not be stopped if it is used as system clock source. In this case, you have to select another source of the system clock then stop the HSI. After enabling the HSI, the application software should wait on HSIRDY flag to be set indicating that HSI clock is stable and can be used as system clock source. When the HSI is stopped, HSIRDY flag goes low after 6 HSI oscillator clock cycles. __HAL_RCC_HSI_DISABLE __HAL_RCC_HSI_CALIBRATIONVALUE_ADJUS T Description: Macro to adjust the Internal High Speed oscillator (HSI) calibration value. Parameters: _HSICALIBRATIONVALUE_: specifies the calibration trimming value. (default is RCC_HSICALIBRATION_DEFA ULT). This parameter must be a number between 0 and 0x1F. Notes: RCC I2C1 Clock Source 502/832 DOCID026526 Rev 4 The calibration is used to compensate for the variations in voltage and temperature that influence the frequency of the internal HSI RC. UM1786 RCC_I2C1CLKSOURCE_HSI RCC_I2C1CLKSOURCE_SYSCLK RCC I2Cx Clock Config Description: __HAL_RCC_I2C1_CONFIG Macro to configure the I2C1 clock (I2C1CLK). Parameters: __HAL_RCC_GET_I2C1_SOURCE __I2C1CLKSOURCE__: specifies the I2C1 clock source. This parameter can be one of the following values: RCC_I2C1CLKSOURCE_HSI HSI selected as I2C1 clock RCC_I2C1CLKSOURCE_SYSCLK System Clock selected as I2C1 clock Description: Macro to get the I2C1 clock source. Return value: The: clock source can be one of the following values: RCC_I2C1CLKSOURCE_HSI HSI selected as I2C1 clock RCC_I2C1CLKSOURCE_SYSCLK System Clock selected as I2C1 clock Interrupts RCC_IT_LSIRDY LSI Ready Interrupt flag RCC_IT_LSERDY LSE Ready Interrupt flag RCC_IT_HSIRDY HSI Ready Interrupt flag RCC_IT_HSERDY HSE Ready Interrupt flag RCC_IT_PLLRDY PLL Ready Interrupt flag RCC_IT_CSS Clock Security System Interrupt flag LSE Config RCC_LSE_OFF LSE clock deactivation RCC_LSE_ON LSE clock activation RCC_LSE_BYPASS External clock source for LSE clock LSE Configuration __HAL_RCC_LSE_CONFIG Description: Macro to configure the External Low Speed oscillator (LSE). Parameters: __STATE__: specifies the new state of the LSE. This parameter can be one of the following values: RCC_LSE_OFF turn OFF the LSE oscillator, DOCID026526 Rev 4 503/832 UM1786 LSERDY flag goes low after 6 LSE oscillator clock cycles. RCC_LSE_ON turn ON the LSE oscillator. RCC_LSE_BYPASS LSE oscillator bypassed with external clock. Notes: Transitions LSE Bypass to LSE On and LSE On to LSE Bypass are not supported by this macro. 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 HAL_PWR_EnableBkUpAccess() function before to configure the LSE (to be done once after reset). After enabling the LSE (RCC_LSE_ON or RCC_LSE_BYPASS), the application software should wait on LSERDY flag to be set indicating that LSE clock is stable and can be used to clock the RTC. LSI Config RCC_LSI_OFF LSI clock deactivation RCC_LSI_ON LSI clock activation LSI Configuration Notes: __HAL_RCC_LSI_ENABLE __HAL_RCC_LSI_DISABLE 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. Notes: LSI can not be disabled if the IWDG is running. When the LSI is stopped, LSIRDY flag goes low after 6 LSI oscillator clock cycles. MCO Index RCC_MCO1 RCC_MCO MCO1 to be compliant with other families with 2 MCOs Oscillator Type RCC_OSCILLATORTYPE_NONE RCC_OSCILLATORTYPE_HSE RCC_OSCILLATORTYPE_HSI RCC_OSCILLATORTYPE_LSE RCC_OSCILLATORTYPE_LSI PLL Clock Source RCC_PLLSOURCE_HSI HSI clock divided by 2 selected as PLL entry clock source RCC_PLLSOURCE_HSE HSE clock selected as PLL entry clock source PLL Config 504/832 DOCID026526 Rev 4 UM1786 RCC_PLL_NONE PLL is not configured RCC_PLL_OFF PLL deactivation RCC_PLL_ON PLL activation PLL Configuration Notes: __HAL_RCC_PLL_ENABLE __HAL_RCC_PLL_DISABLE Notes: __HAL_RCC_GET_PLL_OSCSOURCE After enabling the main PLL, the application software should wait on PLLRDY flag to be set indicating that PLL clock is stable and can be used as system clock source. The main PLL is disabled by hardware when entering STOP and STANDBY modes. The main PLL can not be disabled if it is used as system clock source Description: Get oscillator clock selected as PLL input clock. Return value: The: clock source used for PLL entry. The returned value can be one of the following: RCC_PLLSOURCE_HSI HSI oscillator clock selected as PLL input clock RCC_PLLSOURCE_HSE HSE oscillator clock selected as PLL input clock RCC PLL HSE Prediv Factor RCC_HSE_PREDIV_DIV1 RCC_HSE_PREDIV_DIV2 RCC_HSE_PREDIV_DIV3 RCC_HSE_PREDIV_DIV4 RCC_HSE_PREDIV_DIV5 RCC_HSE_PREDIV_DIV6 RCC_HSE_PREDIV_DIV7 RCC_HSE_PREDIV_DIV8 RCC_HSE_PREDIV_DIV9 RCC_HSE_PREDIV_DIV10 RCC_HSE_PREDIV_DIV11 RCC_HSE_PREDIV_DIV12 RCC_HSE_PREDIV_DIV13 RCC_HSE_PREDIV_DIV14 RCC_HSE_PREDIV_DIV15 DOCID026526 Rev 4 505/832 UM1786 RCC_HSE_PREDIV_DIV16 RCC PLL Multiplication Factor RCC_PLL_MUL2 RCC_PLL_MUL3 RCC_PLL_MUL4 RCC_PLL_MUL5 RCC_PLL_MUL6 RCC_PLL_MUL7 RCC_PLL_MUL8 RCC_PLL_MUL9 RCC_PLL_MUL10 RCC_PLL_MUL11 RCC_PLL_MUL12 RCC_PLL_MUL13 RCC_PLL_MUL14 RCC_PLL_MUL15 RCC_PLL_MUL16 Register offsets RCC_OFFSET RCC_CR_OFFSET RCC_CFGR_OFFSET RCC_CIR_OFFSET RCC_BDCR_OFFSET RCC_CSR_OFFSET RCC RTC Clock Configuration __HAL_RCC_RTC_CONFIG Description: Macro to configure the RTC clock (RTCCLK). Parameters: 506/832 __RTC_CLKSOURCE__: specifies the RTC clock source. This parameter can be one of the following values: RCC_RTCCLKSOURCE_NO_CLK No clock selected as RTC clock RCC_RTCCLKSOURCE_LSE LSE selected as RTC clock RCC_RTCCLKSOURCE_LSI LSI selected as RTC clock RCC_RTCCLKSOURCE_HSE_DIV32 HSE clock divided by 32 DOCID026526 Rev 4 UM1786 Notes: __HAL_RCC_GET_RTC_SOURCE As the RTC clock configuration bits are in the Backup domain and write access is denied to this domain after reset, you have to enable write access using the Power Backup Access macro before to configure the RTC clock source (to be done once after reset). Once the RTC clock is configured it can't be changed unless the Backup domain is reset using __HAL_RCC_BACKUPRESET_FORCE() macro, or by a Power On Reset (POR). If the LSE or LSI is used as RTC clock source, the RTC continues to work in STOP and STANDBY modes, and can be used as wakeup source. However, when the LSI clock and HSE clock divided by 32 is used as RTC clock source, the RTC cannot be used in STOP and STANDBY modes. The system must always be configured so as to get a PCLK frequency greater than or equal to the RTCCLK frequency for a proper operation of the RTC. Description: Macro to get the RTC clock source. Return value: __HAL_RCC_RTC_ENABLE Notes: __HAL_RCC_RTC_DISABLE These macros must be used only after the RTC clock source was selected. Notes: __HAL_RCC_BACKUPRESET_FORC E The: clock source can be one of the following values: RCC_RTCCLKSOURCE_NO_CLK No clock selected as RTC clock RCC_RTCCLKSOURCE_LSE LSE selected as RTC clock RCC_RTCCLKSOURCE_LSI LSI selected as RTC clock RCC_RTCCLKSOURCE_HSE_DIV32 HSE clock divided by 32 These macros must be used only after the RTC clock source was selected. Notes: This function resets the RTC peripheral (including the backup registers) and the RTC clock source selection in RCC_BDCR register. __HAL_RCC_BACKUPRESET_RELE DOCID026526 Rev 4 507/832 UM1786 ASE RTC Clock Source RCC_RTCCLKSOURCE_NO_CLK No clock RCC_RTCCLKSOURCE_LSE LSE oscillator clock used as RTC clock RCC_RTCCLKSOURCE_LSI LSI oscillator clock used as RTC clock RCC_RTCCLKSOURCE_HSE_DIV32 HSE oscillator clock divided by 32 used as RTC clock System Clock Source RCC_SYSCLKSOURCE_HSI HSI selected as system clock RCC_SYSCLKSOURCE_HSE HSE selected as system clock RCC_SYSCLKSOURCE_PLLCLK PLL selected as system clock System Clock Source Status RCC_SYSCLKSOURCE_STATUS_HSI HSI used as system clock RCC_SYSCLKSOURCE_STATUS_HSE HSE used as system clock RCC_SYSCLKSOURCE_STATUS_PLLCLK PLL used as system clock System Clock Type RCC_CLOCKTYPE_SYSCLK SYSCLK to configure RCC_CLOCKTYPE_HCLK HCLK to configure RCC_CLOCKTYPE_PCLK1 PCLK1 to configure RCC_CLOCKTYPE_PCLK2 PCLK2 to configure RCC Timeout RCC_DBP_TIMEOUT_VALUE RCC_LSE_TIMEOUT_VALUE CLOCKSWITCH_TIMEOUT_VALUE HSE_TIMEOUT_VALUE HSI_TIMEOUT_VALUE LSI_TIMEOUT_VALUE PLL_TIMEOUT_VALUE RCC USART2 Clock Source RCC_USART2CLKSOURCE_PCLK1 RCC_USART2CLKSOURCE_SYSCLK RCC_USART2CLKSOURCE_LSE RCC_USART2CLKSOURCE_HSI RCC USART3 Clock Source RCC_USART3CLKSOURCE_PCLK1 RCC_USART3CLKSOURCE_SYSCLK RCC_USART3CLKSOURCE_LSE 508/832 DOCID026526 Rev 4 UM1786 RCC_USART3CLKSOURCE_HSI RCC USARTx Clock Config __HAL_RCC_USART1_CONFIG Description: Macro to configure the USART1 clock (USART1CLK). Parameters: __HAL_RCC_GET_USART1_SOUR CE __USART1CLKSOURCE__: specifies the USART1 clock source. This parameter can be one of the following values: RCC_USART1CLKSOURCE_PCLK2 PCLK2 selected as USART1 clock RCC_USART1CLKSOURCE_HSI HSI selected as USART1 clock RCC_USART1CLKSOURCE_SYSCLK System Clock selected as USART1 clock RCC_USART1CLKSOURCE_LSE LSE selected as USART1 clock Description: Macro to get the USART1 clock source. Return value: __HAL_RCC_USART2_CONFIG The: clock source can be one of the following values: RCC_USART1CLKSOURCE_PCLK2 PCLK2 selected as USART1 clock RCC_USART1CLKSOURCE_HSI HSI selected as USART1 clock RCC_USART1CLKSOURCE_SYSCLK System Clock selected as USART1 clock RCC_USART1CLKSOURCE_LSE LSE selected as USART1 clock Description: Macro to configure the USART2 clock (USART2CLK). Parameters: __HAL_RCC_GET_USART2_SOUR CE __USART2CLKSOURCE__: specifies the USART2 clock source. This parameter can be one of the following values: RCC_USART2CLKSOURCE_PCLK1 PCLK1 selected as USART2 clock RCC_USART2CLKSOURCE_HSI HSI selected as USART2 clock RCC_USART2CLKSOURCE_SYSCLK System Clock selected as USART2 clock RCC_USART2CLKSOURCE_LSE LSE selected as USART2 clock Description: DOCID026526 Rev 4 509/832 UM1786 Macro to get the USART2 clock source. Return value: __HAL_RCC_USART3_CONFIG The: clock source can be one of the following values: RCC_USART2CLKSOURCE_PCLK1 PCLK1 selected as USART2 clock RCC_USART2CLKSOURCE_HSI HSI selected as USART2 clock RCC_USART2CLKSOURCE_SYSCLK System Clock selected as USART2 clock RCC_USART2CLKSOURCE_LSE LSE selected as USART2 clock Description: Macro to configure the USART3 clock (USART3CLK). Parameters: __HAL_RCC_GET_USART3_SOUR CE __USART3CLKSOURCE__: specifies the USART3 clock source. This parameter can be one of the following values: RCC_USART3CLKSOURCE_PCLK1 PCLK1 selected as USART3 clock RCC_USART3CLKSOURCE_HSI HSI selected as USART3 clock RCC_USART3CLKSOURCE_SYSCLK System Clock selected as USART3 clock RCC_USART3CLKSOURCE_LSE LSE selected as USART3 clock Description: Macro to get the USART3 clock source. Return value: 510/832 The: clock source can be one of the following values: RCC_USART3CLKSOURCE_PCLK1 PCLK1 selected as USART3 clock RCC_USART3CLKSOURCE_HSI HSI selected as USART3 clock RCC_USART3CLKSOURCE_SYSCLK System Clock selected as USART3 clock RCC_USART3CLKSOURCE_LSE LSE selected as USART3 clock DOCID026526 Rev 4 UM1786 39 HAL RCC Extension Driver 39.1 RCCEx Firmware driver registers structures 39.1.1 RCC_PeriphCLKInitTypeDef Data Fields uint32_t PeriphClockSelection uint32_t RTCClockSelection uint32_t Usart1ClockSelection uint32_t Usart2ClockSelection uint32_t Usart3ClockSelection uint32_t Uart4ClockSelection uint32_t Uart5ClockSelection uint32_t I2c1ClockSelection uint32_t I2c2ClockSelection uint32_t Adc12ClockSelection uint32_t Adc34ClockSelection uint32_t I2sClockSelection uint32_t Tim1ClockSelection uint32_t Tim8ClockSelection uint32_t USBClockSelection Field Documentation uint32_t RCC_PeriphCLKInitTypeDef::PeriphClockSelection The Extended Clock to be configured. This parameter can be a value of RCCEx_Periph_Clock_Selection uint32_t RCC_PeriphCLKInitTypeDef::RTCClockSelection Specifies RTC Clock Prescalers Selection This parameter can be a value of RCC_RTC_Clock_Source uint32_t RCC_PeriphCLKInitTypeDef::Usart1ClockSelection USART1 clock source This parameter can be a value of RCCEx_USART1_Clock_Source uint32_t RCC_PeriphCLKInitTypeDef::Usart2ClockSelection USART2 clock source This parameter can be a value of RCC_USART2_Clock_Source uint32_t RCC_PeriphCLKInitTypeDef::Usart3ClockSelection USART3 clock source This parameter can be a value of RCC_USART3_Clock_Source uint32_t RCC_PeriphCLKInitTypeDef::Uart4ClockSelection UART4 clock source This parameter can be a value of RCCEx_UART4_Clock_Source uint32_t RCC_PeriphCLKInitTypeDef::Uart5ClockSelection UART5 clock source This parameter can be a value of RCCEx_UART5_Clock_Source uint32_t RCC_PeriphCLKInitTypeDef::I2c1ClockSelection I2C1 clock source This parameter can be a value of RCC_I2C1_Clock_Source DOCID026526 Rev 4 511/832 UM1786 uint32_t RCC_PeriphCLKInitTypeDef::I2c2ClockSelection I2C2 clock source This parameter can be a value of RCCEx_I2C2_Clock_Source uint32_t RCC_PeriphCLKInitTypeDef::Adc12ClockSelection ADC1 & ADC2 clock source This parameter can be a value of RCCEx_ADC12_Clock_Source uint32_t RCC_PeriphCLKInitTypeDef::Adc34ClockSelection ADC3 & ADC4 clock source This parameter can be a value of RCCEx_ADC34_Clock_Source uint32_t RCC_PeriphCLKInitTypeDef::I2sClockSelection I2S clock source This parameter can be a value of RCCEx_I2S_Clock_Source uint32_t RCC_PeriphCLKInitTypeDef::Tim1ClockSelection TIM1 clock source This parameter can be a value of RCCEx_TIM1_Clock_Source uint32_t RCC_PeriphCLKInitTypeDef::Tim8ClockSelection TIM8 clock source This parameter can be a value of RCCEx_TIM8_Clock_Source uint32_t RCC_PeriphCLKInitTypeDef::USBClockSelection USB clock source This parameter can be a value of RCCEx_USB_Clock_Source 39.2 RCCEx Firmware driver API description 39.2.1 Extended Peripheral Control functions This subsection provides a set of functions allowing to control the RCC Clocks frequencies. Important note: Care must be taken when HAL_RCCEx_PeriphCLKConfig() is used to select the RTC clock source; in this case the Backup domain will be reset in order to modify the RTC Clock source, as consequence RTC registers (including the backup registers) are set to their reset values. This section contains the following APIs: 39.2.2 HAL_RCCEx_PeriphCLKConfig() HAL_RCCEx_GetPeriphCLKConfig() HAL_RCCEx_GetPeriphCLKFreq() Detailed description of functions HAL_RCCEx_PeriphCLKConfig 512/832 Function Name HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig (RCC_PeriphCLKInitTypeDef * PeriphClkInit) Function Description Initializes the RCC extended peripherals clocks according to the specified parameters in the RCC_PeriphCLKInitTypeDef. Parameters PeriphClkInit: pointer to an RCC_PeriphCLKInitTypeDef structure that contains the configuration information for the Extended Peripherals clocks (ADC, CEC, I2C, I2S, SDADC, HRTIM, TIM, USART, RTC and USB). Return values HAL: status Notes Care must be taken when HAL_RCCEx_PeriphCLKConfig() is used to select the RTC clock source; in this case the Backup domain will be reset in order to modify the RTC Clock source, DOCID026526 Rev 4 UM1786 as consequence RTC registers (including the backup registers) and RCC_BDCR register are set to their reset values. HAL_RCCEx_GetPeriphCLKConfig Function Name void HAL_RCCEx_GetPeriphCLKConfig (RCC_PeriphCLKInitTypeDef * PeriphClkInit) Function Description Get the RCC_ClkInitStruct according to the internal RCC configuration registers. Parameters PeriphClkInit: pointer to an RCC_PeriphCLKInitTypeDef structure that returns the configuration information for the Extended Peripherals clocks (ADC, CEC, I2C, I2S, SDADC, HRTIM, TIM, USART, RTC and USB clocks). Return values None: HAL_RCCEx_GetPeriphCLKFreq Function Name uint32_t HAL_RCCEx_GetPeriphCLKFreq (uint32_t PeriphClk) Function Description Returns the peripheral clock frequency. Parameters PeriphClk: Peripheral clock identifier This parameter can be one of the following values: RCC_PERIPHCLK_RTC RTC peripheral clock RCC_PERIPHCLK_USART1 USART1 peripheral clock RCC_PERIPHCLK_I2C1 I2C1 peripheral clock RCC_PERIPHCLK_USART2 USART2 peripheral clock RCC_PERIPHCLK_USART3 USART3 peripheral clock RCC_PERIPHCLK_UART4 UART4 peripheral clock RCC_PERIPHCLK_UART5 UART5 peripheral clock RCC_PERIPHCLK_I2C2 I2C2 peripheral clock RCC_PERIPHCLK_I2S I2S peripheral clock RCC_PERIPHCLK_USB USB peripheral clock RCC_PERIPHCLK_ADC12 ADC12 peripheral clock RCC_PERIPHCLK_ADC34 ADC34 peripheral clock RCC_PERIPHCLK_TIM1 TIM1 peripheral clock RCC_PERIPHCLK_TIM8 TIM8 peripheral clock Return values Frequency: in Hz (0: means that no available frequency for the peripheral) Notes Returns 0 if peripheral clock is unknown or 0xDEADDEAD if not applicable. 39.3 RCCEx Firmware driver defines 39.3.1 RCCEx RCC Extended ADC12 Clock Source RCC_ADC12PLLCLK_OFF RCC_ADC12PLLCLK_DIV1 DOCID026526 Rev 4 513/832 UM1786 RCC_ADC12PLLCLK_DIV2 RCC_ADC12PLLCLK_DIV4 RCC_ADC12PLLCLK_DIV6 RCC_ADC12PLLCLK_DIV8 RCC_ADC12PLLCLK_DIV10 RCC_ADC12PLLCLK_DIV12 RCC_ADC12PLLCLK_DIV16 RCC_ADC12PLLCLK_DIV32 RCC_ADC12PLLCLK_DIV64 RCC_ADC12PLLCLK_DIV128 RCC_ADC12PLLCLK_DIV256 RCC Extended ADC34 Clock Source RCC_ADC34PLLCLK_OFF RCC_ADC34PLLCLK_DIV1 RCC_ADC34PLLCLK_DIV2 RCC_ADC34PLLCLK_DIV4 RCC_ADC34PLLCLK_DIV6 RCC_ADC34PLLCLK_DIV8 RCC_ADC34PLLCLK_DIV10 RCC_ADC34PLLCLK_DIV12 RCC_ADC34PLLCLK_DIV16 RCC_ADC34PLLCLK_DIV32 RCC_ADC34PLLCLK_DIV64 RCC_ADC34PLLCLK_DIV128 RCC_ADC34PLLCLK_DIV256 RCC Extended ADCx Clock Config __HAL_RCC_ADC12_CONFIG Description: Macro to configure the ADC1 & ADC2 clock (ADC12CLK). Parameters: 514/832 __ADC12CLKSource__: specifies the ADC1 & ADC2 clock source. This parameter can be one of the following values: RCC_ADC12PLLCLK_OFF ADC1 & ADC2 PLL clock disabled, ADC1 & ADC2 can use AHB clock RCC_ADC12PLLCLK_DIV1 PLL clock divided by 1 selected as ADC1 & ADC2 clock RCC_ADC12PLLCLK_DIV2 PLL clock DOCID026526 Rev 4 UM1786 __HAL_RCC_GET_ADC12_SOURCE divided by 2 selected as ADC1 & ADC2 clock RCC_ADC12PLLCLK_DIV4 PLL clock divided by 4 selected as ADC1 & ADC2 clock RCC_ADC12PLLCLK_DIV6 PLL clock divided by 6 selected as ADC1 & ADC2 clock RCC_ADC12PLLCLK_DIV8 PLL clock divided by 8 selected as ADC1 & ADC2 clock RCC_ADC12PLLCLK_DIV10 PLL clock divided by 10 selected as ADC1 & ADC2 clock RCC_ADC12PLLCLK_DIV12 PLL clock divided by 12 selected as ADC1 & ADC2 clock RCC_ADC12PLLCLK_DIV16 PLL clock divided by 16 selected as ADC1 & ADC2 clock RCC_ADC12PLLCLK_DIV32 PLL clock divided by 32 selected as ADC1 & ADC2 clock RCC_ADC12PLLCLK_DIV64 PLL clock divided by 64 selected as ADC1 & ADC2 clock RCC_ADC12PLLCLK_DIV128 PLL clock divided by 128 selected as ADC1 & ADC2 clock RCC_ADC12PLLCLK_DIV256 PLL clock divided by 256 selected as ADC1 & ADC2 clock Description: Macro to get the ADC1 & ADC2 clock. Return value: The: clock source can be one of the following values: RCC_ADC12PLLCLK_OFF ADC1 & ADC2 PLL clock disabled, ADC1 & ADC2 can use AHB clock RCC_ADC12PLLCLK_DIV1 PLL clock divided by 1 selected as ADC1 & ADC2 clock RCC_ADC12PLLCLK_DIV2 PLL clock divided by 2 selected as ADC1 & ADC2 clock RCC_ADC12PLLCLK_DIV4 PLL clock divided by 4 selected as ADC1 & ADC2 clock RCC_ADC12PLLCLK_DIV6 PLL clock divided by 6 selected as ADC1 & ADC2 clock DOCID026526 Rev 4 515/832 UM1786 __HAL_RCC_ADC34_CONFIG RCC_ADC12PLLCLK_DIV8 PLL clock divided by 8 selected as ADC1 & ADC2 clock RCC_ADC12PLLCLK_DIV10 PLL clock divided by 10 selected as ADC1 & ADC2 clock RCC_ADC12PLLCLK_DIV12 PLL clock divided by 12 selected as ADC1 & ADC2 clock RCC_ADC12PLLCLK_DIV16 PLL clock divided by 16 selected as ADC1 & ADC2 clock RCC_ADC12PLLCLK_DIV32 PLL clock divided by 32 selected as ADC1 & ADC2 clock RCC_ADC12PLLCLK_DIV64 PLL clock divided by 64 selected as ADC1 & ADC2 clock RCC_ADC12PLLCLK_DIV128 PLL clock divided by 128 selected as ADC1 & ADC2 clock RCC_ADC12PLLCLK_DIV256 PLL clock divided by 256 selected as ADC1 & ADC2 clock Description: Macro to configure the ADC3 & ADC4 clock (ADC34CLK). Parameters: 516/832 __ADC34CLKSource__: specifies the ADC3 & ADC4 clock source. This parameter can be one of the following values: RCC_ADC34PLLCLK_OFF ADC3 & ADC4 PLL clock disabled, ADC3 & ADC4 can use AHB clock RCC_ADC34PLLCLK_DIV1 PLL clock divided by 1 selected as ADC3 & ADC4 clock RCC_ADC34PLLCLK_DIV2 PLL clock divided by 2 selected as ADC3 & ADC4 clock RCC_ADC34PLLCLK_DIV4 PLL clock divided by 4 selected as ADC3 & ADC4 clock RCC_ADC34PLLCLK_DIV6 PLL clock divided by 6 selected as ADC3 & ADC4 clock RCC_ADC34PLLCLK_DIV8 PLL clock divided by 8 selected as ADC3 & ADC4 clock RCC_ADC34PLLCLK_DIV10 PLL clock divided by 10 selected as ADC3 & ADC4 clock DOCID026526 Rev 4 UM1786 __HAL_RCC_GET_ADC34_SOURCE RCC_ADC34PLLCLK_DIV12 PLL clock divided by 12 selected as ADC3 & ADC4 clock RCC_ADC34PLLCLK_DIV16 PLL clock divided by 16 selected as ADC3 & ADC4 clock RCC_ADC34PLLCLK_DIV32 PLL clock divided by 32 selected as ADC3 & ADC4 clock RCC_ADC34PLLCLK_DIV64 PLL clock divided by 64 selected as ADC3 & ADC4 clock RCC_ADC34PLLCLK_DIV128 PLL clock divided by 128 selected as ADC3 & ADC4 clock RCC_ADC34PLLCLK_DIV256 PLL clock divided by 256 selected as ADC3 & ADC4 clock Description: Macro to get the ADC3 & ADC4 clock. Return value: The: clock source can be one of the following values: RCC_ADC34PLLCLK_OFF ADC3 & ADC4 PLL clock disabled, ADC3 & ADC4 can use AHB clock RCC_ADC34PLLCLK_DIV1 PLL clock divided by 1 selected as ADC3 & ADC4 clock RCC_ADC34PLLCLK_DIV2 PLL clock divided by 2 selected as ADC3 & ADC4 clock RCC_ADC34PLLCLK_DIV4 PLL clock divided by 4 selected as ADC3 & ADC4 clock RCC_ADC34PLLCLK_DIV6 PLL clock divided by 6 selected as ADC3 & ADC4 clock RCC_ADC34PLLCLK_DIV8 PLL clock divided by 8 selected as ADC3 & ADC4 clock RCC_ADC34PLLCLK_DIV10 PLL clock divided by 10 selected as ADC3 & ADC4 clock RCC_ADC34PLLCLK_DIV12 PLL clock divided by 12 selected as ADC3 & ADC4 clock RCC_ADC34PLLCLK_DIV16 PLL clock divided by 16 selected as ADC3 & ADC4 clock RCC_ADC34PLLCLK_DIV32 PLL clock divided by 32 selected as ADC3 & DOCID026526 Rev 4 517/832 UM1786 ADC4 clock RCC_ADC34PLLCLK_DIV64 PLL clock divided by 64 selected as ADC3 & ADC4 clock RCC_ADC34PLLCLK_DIV128 PLL clock divided by 128 selected as ADC3 & ADC4 clock RCC_ADC34PLLCLK_DIV256 PLL clock divided by 256 selected as ADC3 & ADC4 clock RCC Extended AHB Clock Enable Disable __HAL_RCC_DMA2_CLK_ENABLE __HAL_RCC_GPIOE_CLK_ENABLE __HAL_RCC_ADC12_CLK_ENABLE __HAL_RCC_ADC1_CLK_ENABLE __HAL_RCC_ADC2_CLK_ENABLE __HAL_RCC_DMA2_CLK_DISABLE __HAL_RCC_GPIOE_CLK_DISABLE __HAL_RCC_ADC12_CLK_DISABLE __HAL_RCC_ADC1_CLK_DISABLE __HAL_RCC_ADC2_CLK_DISABLE __HAL_RCC_ADC34_CLK_ENABLE __HAL_RCC_ADC34_CLK_DISABLE RCC Extended AHB Force Release Reset __HAL_RCC_GPIOE_FORCE_RESET __HAL_RCC_ADC12_FORCE_RESET __HAL_RCC_ADC1_FORCE_RESET __HAL_RCC_ADC2_FORCE_RESET __HAL_RCC_GPIOE_RELEASE_RESET __HAL_RCC_ADC12_RELEASE_RESET __HAL_RCC_ADC1_RELEASE_RESET __HAL_RCC_ADC2_RELEASE_RESET __HAL_RCC_ADC34_FORCE_RESET __HAL_RCC_ADC34_RELEASE_RESET RCC Extended AHB Peripheral Clock Enable Disable Status __HAL_RCC_DMA2_IS_CLK_ENABLED __HAL_RCC_GPIOE_IS_CLK_ENABLED __HAL_RCC_ADC12_IS_CLK_ENABLED __HAL_RCC_DMA2_IS_CLK_DISABLED 518/832 DOCID026526 Rev 4 UM1786 __HAL_RCC_GPIOE_IS_CLK_DISABLED __HAL_RCC_ADC12_IS_CLK_DISABLED __HAL_RCC_ADC34_IS_CLK_ENABLED __HAL_RCC_ADC34_IS_CLK_DISABLED RCC Extended APB1 Clock Enable Disable __HAL_RCC_TIM3_CLK_ENABLE __HAL_RCC_TIM4_CLK_ENABLE __HAL_RCC_SPI2_CLK_ENABLE __HAL_RCC_SPI3_CLK_ENABLE __HAL_RCC_UART4_CLK_ENABLE __HAL_RCC_UART5_CLK_ENABLE __HAL_RCC_I2C2_CLK_ENABLE __HAL_RCC_TIM3_CLK_DISABLE __HAL_RCC_TIM4_CLK_DISABLE __HAL_RCC_SPI2_CLK_DISABLE __HAL_RCC_SPI3_CLK_DISABLE __HAL_RCC_UART4_CLK_DISABLE __HAL_RCC_UART5_CLK_DISABLE __HAL_RCC_I2C2_CLK_DISABLE __HAL_RCC_TIM7_CLK_ENABLE __HAL_RCC_TIM7_CLK_DISABLE __HAL_RCC_USB_CLK_ENABLE __HAL_RCC_USB_CLK_DISABLE __HAL_RCC_CAN1_CLK_ENABLE __HAL_RCC_CAN1_CLK_DISABLE RCC Extended APB1 Peripheral Clock Enable Disable Status __HAL_RCC_TIM3_IS_CLK_ENABLED __HAL_RCC_TIM4_IS_CLK_ENABLED __HAL_RCC_SPI2_IS_CLK_ENABLED __HAL_RCC_SPI3_IS_CLK_ENABLED __HAL_RCC_UART4_IS_CLK_ENABLED __HAL_RCC_UART5_IS_CLK_ENABLED __HAL_RCC_I2C2_IS_CLK_ENABLED __HAL_RCC_TIM3_IS_CLK_DISABLED __HAL_RCC_TIM4_IS_CLK_DISABLED __HAL_RCC_SPI2_IS_CLK_DISABLED DOCID026526 Rev 4 519/832 UM1786 __HAL_RCC_SPI3_IS_CLK_DISABLED __HAL_RCC_UART4_IS_CLK_DISABLED __HAL_RCC_UART5_IS_CLK_DISABLED __HAL_RCC_I2C2_IS_CLK_DISABLED __HAL_RCC_TIM7_IS_CLK_ENABLED __HAL_RCC_TIM7_IS_CLK_DISABLED __HAL_RCC_USB_IS_CLK_ENABLED __HAL_RCC_USB_IS_CLK_DISABLED __HAL_RCC_CAN1_IS_CLK_ENABLED __HAL_RCC_CAN1_IS_CLK_DISABLED RCC Extended APB1 Force Release Reset __HAL_RCC_TIM3_FORCE_RESET __HAL_RCC_TIM4_FORCE_RESET __HAL_RCC_SPI2_FORCE_RESET __HAL_RCC_SPI3_FORCE_RESET __HAL_RCC_UART4_FORCE_RESET __HAL_RCC_UART5_FORCE_RESET __HAL_RCC_I2C2_FORCE_RESET __HAL_RCC_TIM3_RELEASE_RESET __HAL_RCC_TIM4_RELEASE_RESET __HAL_RCC_SPI2_RELEASE_RESET __HAL_RCC_SPI3_RELEASE_RESET __HAL_RCC_UART4_RELEASE_RESET __HAL_RCC_UART5_RELEASE_RESET __HAL_RCC_I2C2_RELEASE_RESET __HAL_RCC_TIM7_FORCE_RESET __HAL_RCC_TIM7_RELEASE_RESET __HAL_RCC_USB_FORCE_RESET __HAL_RCC_USB_RELEASE_RESET __HAL_RCC_CAN1_FORCE_RESET __HAL_RCC_CAN1_RELEASE_RESET RCC Extended APB2 Clock Enable Disable __HAL_RCC_SPI1_CLK_ENABLE __HAL_RCC_SPI1_CLK_DISABLE __HAL_RCC_TIM8_CLK_ENABLE __HAL_RCC_TIM8_CLK_DISABLE 520/832 DOCID026526 Rev 4 UM1786 __HAL_RCC_TIM1_CLK_ENABLE __HAL_RCC_TIM1_CLK_DISABLE RCC Extended APB2 Peripheral Clock Enable Disable Status __HAL_RCC_SPI1_IS_CLK_ENABLED __HAL_RCC_SPI1_IS_CLK_DISABLED __HAL_RCC_TIM8_IS_CLK_ENABLED __HAL_RCC_TIM8_IS_CLK_DISABLED __HAL_RCC_TIM1_IS_CLK_ENABLED __HAL_RCC_TIM1_IS_CLK_DISABLED RCC Extended APB2 Force Release Reset __HAL_RCC_SPI1_FORCE_RESET __HAL_RCC_SPI1_RELEASE_RESET __HAL_RCC_TIM8_FORCE_RESET __HAL_RCC_TIM8_RELEASE_RESET __HAL_RCC_TIM1_FORCE_RESET __HAL_RCC_TIM1_RELEASE_RESET RCC Extended HSE Configuration __HAL_RCC_HSE_PREDIV_CONFIG Description: Macro to configure the External High Speed oscillator (HSE) Predivision factor for PLL. Parameters: __HSE_PREDIV_VALUE__: specifies the division value applied to HSE. This parameter must be a number between RCC_HSE_PREDIV_DIV1 and RCC_HSE_PREDIV_DIV16. Notes: Predivision factor can not be changed if PLL is used as system clock In this case, you have to select another source of the system clock, disable the PLL and then change the HSE predivision factor. __HAL_RCC_HSE_GET_PREDIV RCC Extended I2C2 Clock Source RCC_I2C2CLKSOURCE_HSI RCC_I2C2CLKSOURCE_SYSCLK RCC Extended I2Cx Clock Config __HAL_RCC_I2C2_CONFIG Description: Macro to configure the I2C2 clock (I2C2CLK). DOCID026526 Rev 4 521/832 UM1786 Parameters: __I2C2CLKSource__: specifies the I2C2 clock source. This parameter can be one of the following values: RCC_I2C2CLKSOURCE_HSI HSI selected as I2C2 clock RCC_I2C2CLKSOURCE_SYSCLK System Clock selected as I2C2 clock Description: __HAL_RCC_GET_I2C2_SOURCE Macro to get the I2C2 clock source. Return value: The: clock source can be one of the following values: RCC_I2C2CLKSOURCE_HSI HSI selected as I2C2 clock RCC_I2C2CLKSOURCE_SYSCLK System Clock selected as I2C2 clock RCC Extended I2Sx Clock Config Description: __HAL_RCC_I2S_CONFIG Macro to configure the I2S clock source (I2SCLK). Parameters: __I2SCLKSource__: specifies the I2S clock source. This parameter can be one of the following values: RCC_I2SCLKSOURCE_SYSCLK SYSCLK clock used as I2S clock source RCC_I2SCLKSOURCE_EXT External clock mapped on the I2S_CKIN pin used as I2S clock source Notes: __HAL_RCC_GET_I2S_SOURCE This function must be called before enabling the I2S APB clock. Description: Macro to get the I2S clock source (I2SCLK). Return value: The: clock source can be one of the following values: RCC_I2SCLKSOURCE_SYSCLK SYSCLK clock used as I2S clock source RCC_I2SCLKSOURCE_EXT External clock mapped on the I2S_CKIN pin used as I2S clock source RCC Extended I2S Clock Source RCC_I2SCLKSOURCE_SYSCLK 522/832 DOCID026526 Rev 4 UM1786 RCC_I2SCLKSOURCE_EXT RCC LSE Drive Configuration RCC_LSEDRIVE_LOW Xtal mode lower driving capability RCC_LSEDRIVE_MEDIUMLOW Xtal mode medium low driving capability RCC_LSEDRIVE_MEDIUMHIGH Xtal mode medium high driving capability RCC_LSEDRIVE_HIGH Xtal mode higher driving capability LSE Drive Configuration __HAL_RCC_LSEDRIVE_CONFIG Description: Macro to configure the External Low Speed oscillator (LSE) drive capability. Parameters: __RCC_LSEDRIVE__: specifies the new state of the LSE drive capability. This parameter can be one of the following values: RCC_LSEDRIVE_LOW LSE oscillator low drive capability. RCC_LSEDRIVE_MEDIUMLOW LSE oscillator medium low drive capability. RCC_LSEDRIVE_MEDIUMHIGH LSE oscillator medium high drive capability. RCC_LSEDRIVE_HIGH LSE oscillator high drive capability. Return value: None RCC Extended MCOx Clock Config __HAL_RCC_MCO1_CONFIG Description: Macro to configure the MCO clock. Parameters: __MCOCLKSOURCE__: specifies the MCO clock source. This parameter can be one of the following values: RCC_MCO1SOURCE_NOCLOCK No clock selected as MCO clock RCC_MCO1SOURCE_SYSCLK System Clock selected as MCO clock RCC_MCO1SOURCE_HSI HSI selected as MCO clock RCC_MCO1SOURCE_HSE HSE selected as MCO clock RCC_MCO1SOURCE_LSI LSI selected as MCO clock RCC_MCO1SOURCE_LSE LSE selected as MCO clock RCC_MCO1SOURCE_PLLCLK_DIV2 PLLCLK Divided by 2 selected as MCO clock __MCODIV__: specifies the MCO clock prescaler. DOCID026526 Rev 4 523/832 UM1786 This parameter can be one of the following values: RCC_MCODIV_1 No division applied on MCO clock source RCC Extended MCOx Clock Prescaler RCC_MCODIV_1 RCC Extended MCO Clock Source RCC_MCO1SOURCE_NOCLOCK RCC_MCO1SOURCE_LSI RCC_MCO1SOURCE_LSE RCC_MCO1SOURCE_SYSCLK RCC_MCO1SOURCE_HSI RCC_MCO1SOURCE_HSE RCC_MCO1SOURCE_PLLCLK_DIV2 RCC Extended Periph Clock Selection RCC_PERIPHCLK_USART1 RCC_PERIPHCLK_USART2 RCC_PERIPHCLK_USART3 RCC_PERIPHCLK_UART4 RCC_PERIPHCLK_UART5 RCC_PERIPHCLK_I2C1 RCC_PERIPHCLK_I2C2 RCC_PERIPHCLK_ADC12 RCC_PERIPHCLK_ADC34 RCC_PERIPHCLK_I2S RCC_PERIPHCLK_TIM1 RCC_PERIPHCLK_TIM8 RCC_PERIPHCLK_RTC RCC_PERIPHCLK_USB RCC Extended PLL Configuration __HAL_RCC_PLL_CONFIG Description: Macro to configure the PLL clock source and multiplication factor. Parameters: 524/832 __RCC_PLLSource__: specifies the PLL entry clock source. This parameter can be one of the following values: RCC_PLLSOURCE_HSI HSI oscillator clock selected as PLL clock entry RCC_PLLSOURCE_HSE HSE oscillator clock selected as PLL clock entry DOCID026526 Rev 4 UM1786 __PLLMUL__: specifies the multiplication factor for PLL VCO input clock This parameter must be a number between RCC_PLL_MUL2 and RCC_PLL_MUL16. Notes: This macro must be used only when the PLL is disabled. RCC Extended TIM1 Clock Source RCC_TIM1CLK_HCLK RCC_TIM1CLK_PLLCLK RCC Extended TIM8 Clock Source RCC_TIM8CLK_HCLK RCC_TIM8CLK_PLLCLK RCC Extended TIMx Clock Config __HAL_RCC_TIM1_CONFIG Description: Macro to configure the TIM1 clock (TIM1CLK). Parameters: __HAL_RCC_GET_TIM1_SOURCE __TIM1CLKSource__: specifies the TIM1 clock source. This parameter can be one of the following values: RCC_TIM1CLK_HCLK HCLK selected as TIM1 clock RCC_TIM1CLK_PLLCLK PLL Clock selected as TIM1 clock Description: Macro to get the TIM1 clock (TIM1CLK). Return value: __HAL_RCC_TIM8_CONFIG The: clock source can be one of the following values: RCC_TIM1CLK_HCLK HCLK selected as TIM1 clock RCC_TIM1CLK_PLLCLK PLL Clock selected as TIM1 clock Description: Macro to configure the TIM8 clock (TIM8CLK). Parameters: __HAL_RCC_GET_TIM8_SOURCE __TIM8CLKSource__: specifies the TIM8 clock source. This parameter can be one of the following values: RCC_TIM8CLK_HCLK HCLK selected as TIM8 clock RCC_TIM8CLK_PLLCLK PLL Clock selected as TIM8 clock Description: DOCID026526 Rev 4 525/832 UM1786 Macro to get the TIM8 clock (TIM8CLK). Return value: The: clock source can be one of the following values: RCC_TIM8CLK_HCLK HCLK selected as TIM8 clock RCC_TIM8CLK_PLLCLK PLL Clock selected as TIM8 clock RCC Extended UART4 Clock Source RCC_UART4CLKSOURCE_PCLK1 RCC_UART4CLKSOURCE_SYSCLK RCC_UART4CLKSOURCE_LSE RCC_UART4CLKSOURCE_HSI RCC Extended UART5 Clock Source RCC_UART5CLKSOURCE_PCLK1 RCC_UART5CLKSOURCE_SYSCLK RCC_UART5CLKSOURCE_LSE RCC_UART5CLKSOURCE_HSI RCC Extended UARTx Clock Config __HAL_RCC_UART4_CONFIG Description: Macro to configure the UART4 clock (UART4CLK). Parameters: __HAL_RCC_GET_UART4_SOURC E __UART4CLKSource__: specifies the UART4 clock source. This parameter can be one of the following values: RCC_UART4CLKSOURCE_PCLK1 PCLK1 selected as UART4 clock RCC_UART4CLKSOURCE_HSI HSI selected as UART4 clock RCC_UART4CLKSOURCE_SYSCLK System Clock selected as UART4 clock RCC_UART4CLKSOURCE_LSE LSE selected as UART4 clock Description: Macro to get the UART4 clock source. Return value: 526/832 The: clock source can be one of the following values: RCC_UART4CLKSOURCE_PCLK1 PCLK1 selected as UART4 clock RCC_UART4CLKSOURCE_HSI HSI selected as UART4 clock RCC_UART4CLKSOURCE_SYSCLK DOCID026526 Rev 4 UM1786 System Clock selected as UART4 clock RCC_UART4CLKSOURCE_LSE LSE selected as UART4 clock Description: __HAL_RCC_UART5_CONFIG Macro to configure the UART5 clock (UART5CLK). Parameters: __UART5CLKSource__: specifies the UART5 clock source. This parameter can be one of the following values: RCC_UART5CLKSOURCE_PCLK1 PCLK1 selected as UART5 clock RCC_UART5CLKSOURCE_HSI HSI selected as UART5 clock RCC_UART5CLKSOURCE_SYSCLK System Clock selected as UART5 clock RCC_UART5CLKSOURCE_LSE LSE selected as UART5 clock Description: __HAL_RCC_GET_UART5_SOURC E Macro to get the UART5 clock source. Return value: The: clock source can be one of the following values: RCC_UART5CLKSOURCE_PCLK1 PCLK1 selected as UART5 clock RCC_UART5CLKSOURCE_HSI HSI selected as UART5 clock RCC_UART5CLKSOURCE_SYSCLK System Clock selected as UART5 clock RCC_UART5CLKSOURCE_LSE LSE selected as UART5 clock RCC Extended USART1 Clock Source RCC_USART1CLKSOURCE_PCLK2 RCC_USART1CLKSOURCE_SYSCLK RCC_USART1CLKSOURCE_LSE RCC_USART1CLKSOURCE_HSI RCC Extended USBx Clock Config __HAL_RCC_USB_CONFIG Description: Macro to configure the USB clock (USBCLK). Parameters: __USBCLKSource__: specifies the USB clock source. This parameter can be one of the following values: RCC_USBCLKSOURCE_PLL PLL Clock divided by 1 selected as USB clock DOCID026526 Rev 4 527/832 UM1786 __HAL_RCC_GET_USB_SOURC E RCC_USBCLKSOURCE_PLL_DIV1_5 PLL Clock divided by 1.5 selected as USB clock Description: Macro to get the USB clock source. Return value: The: clock source can be one of the following values: RCC_USBCLKSOURCE_PLL PLL Clock divided by 1 selected as USB clock RCC_USBCLKSOURCE_PLL_DIV1_5 PLL Clock divided by 1.5 selected as USB clock RCC Extended USB Clock Source RCC_USBCLKSOURCE_PLL RCC_USBCLKSOURCE_PLL_DIV1_5 528/832 DOCID026526 Rev 4 UM1786 40 HAL RTC Generic Driver 40.1 RTC Firmware driver registers structures 40.1.1 RTC_InitTypeDef Data Fields uint32_t HourFormat uint32_t AsynchPrediv uint32_t SynchPrediv uint32_t OutPut uint32_t OutPutPolarity uint32_t OutPutType Field Documentation 40.1.2 uint32_t RTC_InitTypeDef::HourFormat Specifies the RTC Hour Format. This parameter can be a value of RTC_Hour_Formats uint32_t RTC_InitTypeDef::AsynchPrediv Specifies the RTC Asynchronous Predivider value. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F uint32_t RTC_InitTypeDef::SynchPrediv Specifies the RTC Synchronous Predivider value. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFF uint32_t RTC_InitTypeDef::OutPut Specifies which signal will be routed to the RTC output. This parameter can be a value of RTCEx_Output_selection_Definitions uint32_t RTC_InitTypeDef::OutPutPolarity Specifies the polarity of the output signal. This parameter can be a value of RTC_Output_Polarity_Definitions uint32_t RTC_InitTypeDef::OutPutType Specifies the RTC Output Pin mode. This parameter can be a value of RTC_Output_Type_ALARM_OUT RTC_TimeTypeDef Data Fields uint8_t Hours uint8_t Minutes uint8_t Seconds uint8_t TimeFormat uint32_t SubSeconds uint32_t SecondFraction uint32_t DayLightSaving uint32_t StoreOperation DOCID026526 Rev 4 529/832 UM1786 Field Documentation 40.1.3 uint8_t RTC_TimeTypeDef::Hours Specifies the RTC Time Hour. This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the RTC_HourFormat_12 is selected. This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the RTC_HourFormat_24 is selected uint8_t RTC_TimeTypeDef::Minutes Specifies the RTC Time Minutes. This parameter must be a number between Min_Data = 0 and Max_Data = 59 uint8_t RTC_TimeTypeDef::Seconds Specifies the RTC Time Seconds. This parameter must be a number between Min_Data = 0 and Max_Data = 59 uint8_t RTC_TimeTypeDef::TimeFormat Specifies the RTC AM/PM Time. This parameter can be a value of RTC_AM_PM_Definitions uint32_t RTC_TimeTypeDef::SubSeconds Specifies the RTC_SSR RTC Sub Second register content. This parameter corresponds to a time unit range between [0-1] Second with [1 Sec / SecondFraction +1] granularity uint32_t RTC_TimeTypeDef::SecondFraction Specifies the range or granularity of Sub Second register content corresponding to Synchronous pre-scaler factor value (PREDIV_S) This parameter corresponds to a time unit range between [0-1] Second with [1 Sec / SecondFraction +1] granularity. This field will be used only by HAL_RTC_GetTime function uint32_t RTC_TimeTypeDef::DayLightSaving Specifies RTC_DayLightSaveOperation: the value of hour adjustment. This parameter can be a value of RTC_DayLightSaving_Definitions uint32_t RTC_TimeTypeDef::StoreOperation Specifies RTC_StoreOperation value to be written in the BCK bit in CR register to store the operation. This parameter can be a value of RTC_StoreOperation_Definitions RTC_DateTypeDef Data Fields uint8_t WeekDay uint8_t Month uint8_t Date uint8_t Year Field Documentation 530/832 uint8_t RTC_DateTypeDef::WeekDay Specifies the RTC Date WeekDay. This parameter can be a value of RTC_WeekDay_Definitions uint8_t RTC_DateTypeDef::Month Specifies the RTC Date Month (in BCD format). This parameter can be a value of RTC_Month_Date_Definitions DOCID026526 Rev 4 UM1786 40.1.4 uint8_t RTC_DateTypeDef::Date Specifies the RTC Date. This parameter must be a number between Min_Data = 1 and Max_Data = 31 uint8_t RTC_DateTypeDef::Year Specifies the RTC Date Year. This parameter must be a number between Min_Data = 0 and Max_Data = 99 RTC_AlarmTypeDef Data Fields RTC_TimeTypeDef AlarmTime uint32_t AlarmMask uint32_t AlarmSubSecondMask uint32_t AlarmDateWeekDaySel uint8_t AlarmDateWeekDay uint32_t Alarm Field Documentation 40.1.5 RTC_TimeTypeDef RTC_AlarmTypeDef::AlarmTime Specifies the RTC Alarm Time members uint32_t RTC_AlarmTypeDef::AlarmMask Specifies the RTC Alarm Masks. This parameter can be a value of RTC_AlarmMask_Definitions uint32_t RTC_AlarmTypeDef::AlarmSubSecondMask Specifies the RTC Alarm SubSeconds Masks. This parameter can be a value of RTC_Alarm_Sub_Seconds_Masks_Definitions uint32_t RTC_AlarmTypeDef::AlarmDateWeekDaySel Specifies the RTC Alarm is on Date or WeekDay. This parameter can be a value of RTC_AlarmDateWeekDay_Definitions uint8_t RTC_AlarmTypeDef::AlarmDateWeekDay Specifies the RTC Alarm Date/WeekDay. If the Alarm Date is selected, this parameter must be set to a value in the 1-31 range. If the Alarm WeekDay is selected, this parameter can be a value of RTC_WeekDay_Definitions uint32_t RTC_AlarmTypeDef::Alarm Specifies the alarm . This parameter can be a value of RTC_Alarms_Definitions RTC_HandleTypeDef Data Fields RTC_TypeDef * Instance RTC_InitTypeDef Init HAL_LockTypeDef Lock __IO HAL_RTCStateTypeDef State Field Documentation DOCID026526 Rev 4 531/832 UM1786 RTC_TypeDef* RTC_HandleTypeDef::Instance Register base address RTC_InitTypeDef RTC_HandleTypeDef::Init RTC required parameters HAL_LockTypeDef RTC_HandleTypeDef::Lock RTC locking object __IO HAL_RTCStateTypeDef RTC_HandleTypeDef::State Time communication state 40.2 RTC Firmware driver API description 40.2.1 RTC Operating Condition The real-time clock (RTC) and the RTC backup registers can be powered from the VBAT voltage when the main VDD supply is powered off. To retain the content of the RTC backup registers and supply the RTC when VDD is turned off, VBAT pin can be connected to an optional standby voltage supplied by a battery or by another source. To allow the RTC to operate even when the main digital supply (VDD) is turned off, the VBAT pin powers the following blocks: 1. 2. 3. The RTC The LSE oscillator PC13 to PC15 I/Os (when available) When the backup domain is supplied by VDD (analog switch connected to VDD), the following functions are available: 1. 2. PC14 and PC15 can be used as either GPIO or LSE pins PC13 can be used as a GPIO or as the RTC_OUT pin When the backup domain is supplied by VBAT (analog switch connected to VBAT because VDD is not present), the following functions are available: 1. 2. 40.2.2 PC14 and PC15 can be used as LSE pins only PC13 can be used as the RTC_OUT pin Backup Domain Reset The backup domain reset sets all RTC registers and the RCC_BDCR register to their reset values. A backup domain reset is generated when one of the following events occurs: 1. 2. 40.2.3 Software reset, triggered by setting the BDRST bit in the RCC Backup domain control register (RCC_BDCR). VDD or VBAT power on, if both supplies have previously been powered off. Backup Domain Access After reset, the backup domain (RTC registers, RTC backup data registers and backup SRAM) is protected against possible unwanted write accesses. To enable access to the RTC Domain and RTC registers, proceed as follows: 1. 2. 3. 4. 532/832 Enable the Power Controller (PWR) APB1 interface clock using the __HAL_RCC_PWR_CLK_ENABLE() function. Enable access to RTC domain using the HAL_PWR_EnableBkUpAccess() function. Select the RTC clock source using the __HAL_RCC_RTC_CONFIG() function. Enable RTC Clock using the __HAL_RCC_RTC_ENABLE() function. DOCID026526 Rev 4 UM1786 40.2.4 How to use RTC Driver Enable the RTC domain access (see description in the section above). Configure the RTC Prescaler (Asynchronous and Synchronous) and RTC hour format using the HAL_RTC_Init() function. Time and Date configuration To configure the RTC Calendar (Time and Date) use the HAL_RTC_SetTime() and HAL_RTC_SetDate() functions. To read the RTC Calendar, use the HAL_RTC_GetTime() and HAL_RTC_GetDate() functions. Alarm configuration To configure the RTC Alarm use the HAL_RTC_SetAlarm() function. You can also configure the RTC Alarm with interrupt mode using the HAL_RTC_SetAlarm_IT() function. To read the RTC Alarm, use the HAL_RTC_GetAlarm() function. RTC Wakeup configuration To configure the RTC Wakeup Clock source and Counter use the HAL_RTC_SetWakeUpTimer() function. You can also configure the RTC Wakeup timer with interrupt mode using the HAL_RTC_SetWakeUpTimer_IT() function. To read the RTC WakeUp Counter register, use the HAL_RTC_GetWakeUpTimer() function. TimeStamp configuration Configure the RTC_AF trigger and enables the RTC TimeStamp using the HAL_RTC_SetTimeStamp() function. You can also configure the RTC TimeStamp with interrupt mode using the HAL_RTC_SetTimeStamp_IT() function. To read the RTC TimeStamp Time and Date register, use the HAL_RTC_GetTimeStamp() function. Tamper configuration Enable the RTC Tamper and Configure the Tamper filter count, trigger Edge or Level according to the Tamper filter (if equal to 0 Edge else Level) value, sampling frequency, precharge or discharge and Pull-UP using the HAL_RTC_SetTamper() function. You can configure RTC Tamper with interrupt mode using HAL_RTC_SetTamper_IT() function. Backup Data Registers configuration DOCID026526 Rev 4 533/832 UM1786 40.2.5 To write to the RTC Backup Data registers, use the HAL_RTC_BKUPWrite() function. To read the RTC Backup Data registers, use the HAL_RTC_BKUPRead() function. 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. These RTC alternate functions can wake up the system from the Stop and Standby low power modes. The system can also wake up from low power modes without depending on an external interrupt (Auto-wakeup mode), by using the RTC alarm or the RTC wakeup events. The RTC provides a programmable time base for waking up from the Stop or Standby mode at regular intervals. Wakeup from STOP and Standby modes is possible only when the RTC clock source is LSE or LSI. 40.2.6 Initialization and de-initialization functions This section provides 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. 1. 2. 3. 4. The RTC Prescaler is programmed to generate the RTC 1Hz time base. It is split into 2 programmable prescalers to minimize power consumption. A 7-bit asynchronous prescaler and a 15-bit synchronous prescaler. When both prescalers are used, it is recommended to configure the asynchronous prescaler to a high value to minimize power consumption. All RTC registers are Write protected. Writing to the RTC registers is enabled by writing a key into the Write Protection register, RTC_WPR. To configure the RTC Calendar, user application should enter initialization mode. In this mode, the calendar counter is stopped and its value can be updated. When the initialization sequence is complete, the calendar restarts counting after 4 RTCCLK cycles. To read the calendar through the shadow registers after Calendar initialization, calendar update or after wakeup from low power modes the software must first clear the RSF flag. The software must then wait until it is set again before reading the calendar, which means that the calendar registers have been correctly copied into the RTC_TR and RTC_DR shadow registers.The HAL_RTC_WaitForSynchro() function implements the above software sequence (RSF clear and RSF check). This section contains the following APIs: 40.2.7 HAL_RTC_Init() HAL_RTC_DeInit() HAL_RTC_MspInit() HAL_RTC_MspDeInit() RTC Time and Date functions This section provides functions allowing to configure Time and Date features This section contains the following APIs: 534/832 HAL_RTC_SetTime() HAL_RTC_GetTime() HAL_RTC_SetDate() HAL_RTC_GetDate() DOCID026526 Rev 4 UM1786 40.2.8 RTC Alarm functions This section provides functions allowing to configure Alarm feature This section contains the following APIs: 40.2.9 HAL_RTC_SetAlarm() HAL_RTC_SetAlarm_IT() HAL_RTC_DeactivateAlarm() HAL_RTC_GetAlarm() HAL_RTC_AlarmIRQHandler() HAL_RTC_AlarmAEventCallback() HAL_RTC_PollForAlarmAEvent() Detailed description of functions HAL_RTC_Init Function Name HAL_StatusTypeDef HAL_RTC_Init (RTC_HandleTypeDef * hrtc) Function Description Initialize the RTC according to the specified parameters in the RTC_InitTypeDef structure and initialize the associated handle. Parameters hrtc: RTC handle Return values HAL: status HAL_RTC_DeInit Function Name HAL_StatusTypeDef HAL_RTC_DeInit (RTC_HandleTypeDef * hrtc) Function Description DeInitialize the RTC peripheral. Parameters hrtc: RTC handle Return values HAL: status Notes This function doesn't reset the RTC Backup Data registers. HAL_RTC_MspInit Function Name void HAL_RTC_MspInit (RTC_HandleTypeDef * hrtc) Function Description Initialize the RTC MSP. Parameters hrtc: RTC handle Return values None: HAL_RTC_MspDeInit Function Name void HAL_RTC_MspDeInit (RTC_HandleTypeDef * hrtc) Function Description DeInitialize the RTC MSP. Parameters hrtc: RTC handle Return values None: DOCID026526 Rev 4 535/832 UM1786 HAL_RTC_SetTime Function Name HAL_StatusTypeDef HAL_RTC_SetTime (RTC_HandleTypeDef * hrtc, RTC_TimeTypeDef * sTime, uint32_t Format) Function Description Set RTC current time. Parameters hrtc: RTC handle sTime: Pointer to Time structure 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 Return values HAL: status HAL_RTC_GetTime Function Name HAL_StatusTypeDef HAL_RTC_GetTime (RTC_HandleTypeDef * hrtc, RTC_TimeTypeDef * sTime, uint32_t Format) Function Description Get RTC current time. Parameters hrtc: RTC handle sTime: Pointer to Time structure 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 Return values HAL: status Notes You can use SubSeconds and SecondFraction (sTime structure fields returned) to convert SubSeconds value in second fraction ratio with time unit following generic formula: Second fraction ratio * time_unit= [(SecondFractionSubSeconds)/(SecondFraction+1)] * time_unit This conversion can be performed only if no shift operation is pending (ie. SHFP=0) when PREDIV_S >= SS Call HAL_RTC_GetDate() after HAL_RTC_GetTime() to unlock the values in the higher-order calendar shadow registers. HAL_RTC_SetDate 536/832 Function Name HAL_StatusTypeDef HAL_RTC_SetDate (RTC_HandleTypeDef * hrtc, RTC_DateTypeDef * sDate, uint32_t Format) Function Description Set RTC current date. Parameters hrtc: RTC handle sDate: Pointer to date structure 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 Return values HAL: status DOCID026526 Rev 4 UM1786 HAL_RTC_GetDate Function Name HAL_StatusTypeDef HAL_RTC_GetDate (RTC_HandleTypeDef * hrtc, RTC_DateTypeDef * sDate, uint32_t Format) Function Description Get RTC current date. Parameters hrtc: RTC handle sDate: Pointer to Date structure 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 Return values HAL: status HAL_RTC_SetAlarm Function Name HAL_StatusTypeDef HAL_RTC_SetAlarm (RTC_HandleTypeDef * hrtc, RTC_AlarmTypeDef * sAlarm, uint32_t Format) Function Description Set the specified RTC Alarm. Parameters hrtc: RTC handle sAlarm: Pointer to Alarm structure 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 Return values HAL: status HAL_RTC_SetAlarm_IT Function Name HAL_StatusTypeDef HAL_RTC_SetAlarm_IT (RTC_HandleTypeDef * hrtc, RTC_AlarmTypeDef * sAlarm, uint32_t Format) Function Description Set the specified RTC Alarm with Interrupt. Parameters hrtc: RTC handle sAlarm: Pointer to Alarm structure 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 Return values HAL: status Notes The Alarm register can only be written when the corresponding Alarm is disabled (Use the HAL_RTC_DeactivateAlarm()). The HAL_RTC_SetTime() must be called before enabling the Alarm feature. DOCID026526 Rev 4 537/832 UM1786 HAL_RTC_DeactivateAlarm Function Name HAL_StatusTypeDef HAL_RTC_DeactivateAlarm (RTC_HandleTypeDef * hrtc, uint32_t Alarm) Function Description Deactivate the specified RTC Alarm. Parameters hrtc: RTC handle Alarm: Specifies the Alarm. This parameter can be one of the following values: RTC_ALARM_A : AlarmA RTC_ALARM_B : AlarmB Return values HAL: status HAL_RTC_GetAlarm Function Name HAL_StatusTypeDef HAL_RTC_GetAlarm (RTC_HandleTypeDef * hrtc, RTC_AlarmTypeDef * sAlarm, uint32_t Alarm, uint32_t Format) Function Description Get the RTC Alarm value and masks. Parameters Return values hrtc: RTC handle sAlarm: Pointer to Date structure Alarm: Specifies the Alarm. This parameter can be one of the following values: RTC_ALARM_A: AlarmA RTC_ALARM_B: AlarmB 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 HAL: status HAL_RTC_AlarmIRQHandler Function Name void HAL_RTC_AlarmIRQHandler (RTC_HandleTypeDef * hrtc) Function Description Handle Alarm interrupt request. Parameters hrtc: RTC handle Return values None: HAL_RTC_PollForAlarmAEvent 538/832 Function Name HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent (RTC_HandleTypeDef * hrtc, uint32_t Timeout) Function Description Handle AlarmA Polling request. Parameters hrtc: RTC handle Timeout: Timeout duration Return values HAL: status DOCID026526 Rev 4 UM1786 HAL_RTC_AlarmAEventCallback Function Name void HAL_RTC_AlarmAEventCallback (RTC_HandleTypeDef * hrtc) Function Description Alarm A callback. Parameters hrtc: RTC handle Return values None: HAL_RTC_WaitForSynchro Function Name HAL_StatusTypeDef HAL_RTC_WaitForSynchro (RTC_HandleTypeDef * hrtc) Function Description @addtogroup RTC_Exported_Functions_Group4 Peripheral Control functions Parameters hrtc: RTC handle Return values HAL: status Notes The RTC Resynchronization mode is write protected, use the __HAL_RTC_WRITEPROTECTION_DISABLE() before calling this function. To read the calendar through the shadow registers after Calendar initialization, calendar update or after wakeup from low power modes the software must first clear the RSF flag. The software must then wait until it is set again before reading the calendar, which means that the calendar registers have been correctly copied into the RTC_TR and RTC_DR shadow registers. HAL_RTC_GetState Function Name HAL_RTCStateTypeDef HAL_RTC_GetState (RTC_HandleTypeDef * hrtc) Function Description @addtogroup RTC_Exported_Functions_Group5 Peripheral State functions Parameters hrtc: RTC handle Return values HAL: state RTC_EnterInitMode Function Name HAL_StatusTypeDef RTC_EnterInitMode (RTC_HandleTypeDef * hrtc) Function Description @addtogroup RTC_Private_Functions RTC Private Functions Parameters hrtc: RTC handle Return values An: ErrorStatus enumeration value: HAL_OK : RTC is in Init mode HAL_TIMEOUT : RTC is not in Init mode and in Timeout Notes The RTC Initialization mode is write protected, use the __HAL_RTC_WRITEPROTECTION_DISABLE() before DOCID026526 Rev 4 539/832 UM1786 calling this function. RTC_ByteToBcd2 Function Name uint8_t RTC_ByteToBcd2 (uint8_t Value) Function Description Convert a 2 digit decimal to BCD format. Parameters Value: Byte to be converted Return values Converted: byte RTC_Bcd2ToByte Function Name uint8_t RTC_Bcd2ToByte (uint8_t Value) Function Description Convert from 2 digit BCD to Binary. Parameters Value: BCD value to be converted Return values Converted: word 40.3 RTC Firmware driver defines 40.3.1 RTC RTC AlarmDateWeekDay Definitions RTC_ALARMDATEWEEKDAYSEL_DATE RTC_ALARMDATEWEEKDAYSEL_WEEKDAY RTC AlarmMask Definitions RTC_ALARMMASK_NONE RTC_ALARMMASK_DATEWEEKDAY RTC_ALARMMASK_HOURS RTC_ALARMMASK_MINUTES RTC_ALARMMASK_SECONDS RTC_ALARMMASK_ALL RTC Alarms Definitions RTC_ALARM_A RTC_ALARM_B RTC Alarm Sub Seconds Masks Definitions 540/832 RTC_ALARMSUBSECONDMASK_ALL All Alarm SS fields are masked. There is no comparison on sub seconds for Alarm RTC_ALARMSUBSECONDMASK_SS14_1 SS[14:1] are ignored in Alarm comparison. Only SS[0] is compared. RTC_ALARMSUBSECONDMASK_SS14_2 SS[14:2] are ignored in Alarm comparison. Only SS[1:0] are compared RTC_ALARMSUBSECONDMASK_SS14_3 SS[14:3] are ignored in Alarm comparison. Only SS[2:0] are compared DOCID026526 Rev 4 UM1786 RTC_ALARMSUBSECONDMASK_SS14_4 SS[14:4] are ignored in Alarm comparison. Only SS[3:0] are compared RTC_ALARMSUBSECONDMASK_SS14_5 SS[14:5] are ignored in Alarm comparison. Only SS[4:0] are compared RTC_ALARMSUBSECONDMASK_SS14_6 SS[14:6] are ignored in Alarm comparison. Only SS[5:0] are compared RTC_ALARMSUBSECONDMASK_SS14_7 SS[14:7] are ignored in Alarm comparison. Only SS[6:0] are compared RTC_ALARMSUBSECONDMASK_SS14_8 SS[14:8] are ignored in Alarm comparison. Only SS[7:0] are compared RTC_ALARMSUBSECONDMASK_SS14_9 SS[14:9] are ignored in Alarm comparison. Only SS[8:0] are compared RTC_ALARMSUBSECONDMASK_SS14_10 SS[14:10] are ignored in Alarm comparison. Only SS[9:0] are compared RTC_ALARMSUBSECONDMASK_SS14_11 SS[14:11] are ignored in Alarm comparison. Only SS[10:0] are compared RTC_ALARMSUBSECONDMASK_SS14_12 SS[14:12] are ignored in Alarm comparison.Only SS[11:0] are compared RTC_ALARMSUBSECONDMASK_SS14_13 SS[14:13] are ignored 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 RTC_ALARMSUBSECONDMASK_NONE SS[14:0] are compared and must match to activate alarm. RTC AM PM Definitions RTC_HOURFORMAT12_AM RTC_HOURFORMAT12_PM RTC DayLightSaving Definitions RTC_DAYLIGHTSAVING_NONE RTC_DAYLIGHTSAVING_SUB1H RTC_DAYLIGHTSAVING_ADD1H RTC Exported Macros __HAL_RTC_RESET_HANDLE_STATE Description: Reset RTC handle state. Parameters: __HANDLE__: RTC handle. Return value: __HAL_RTC_WRITEPROTECTION_DISABLE Description: DOCID026526 Rev 4 None Disable the write 541/832 UM1786 protection for RTC registers. Parameters: __HANDLE__: specifies the RTC handle. Return value: __HAL_RTC_WRITEPROTECTION_ENABLE None Description: Enable the write protection for RTC registers. Parameters: __HANDLE__: specifies the RTC handle. Return value: __HAL_RTC_ALARMA_ENABLE None Description: Enable the RTC ALARMA peripheral. Parameters: __HANDLE__: specifies the RTC handle. Return value: __HAL_RTC_ALARMA_DISABLE None Description: Disable the RTC ALARMA peripheral. Parameters: __HANDLE__: specifies the RTC handle. Return value: __HAL_RTC_ALARMB_ENABLE None Description: Enable the RTC ALARMB peripheral. Parameters: __HANDLE__: specifies the RTC handle. Return value: 542/832 DOCID026526 Rev 4 None UM1786 __HAL_RTC_ALARMB_DISABLE Description: Disable the RTC ALARMB peripheral. Parameters: __HANDLE__: specifies the RTC handle. Return value: __HAL_RTC_ALARM_ENABLE_IT None Description: Enable the RTC Alarm interrupt. Parameters: __HANDLE__: specifies the RTC handle. __INTERRUPT__: specifies the RTC Alarm interrupt sources to be enabled or disabled. This parameter can be any combination of the following values: RTC_IT_ALRA: Alarm A interrupt RTC_IT_ALRB: Alarm B interrupt Return value: __HAL_RTC_ALARM_DISABLE_IT None Description: Disable the RTC Alarm interrupt. Parameters: __HANDLE__: specifies the RTC handle. __INTERRUPT__: specifies the RTC Alarm interrupt sources to be enabled or disabled. This parameter can be any combination of the following values: RTC_IT_ALRA: Alarm A interrupt RTC_IT_ALRB: Alarm B interrupt Return value: DOCID026526 Rev 4 543/832 UM1786 __HAL_RTC_ALARM_GET_IT None Description: Check whether the specified RTC Alarm interrupt has occurred or not. Parameters: __HANDLE__: specifies the RTC handle. __INTERRUPT__: specifies the RTC Alarm interrupt to check. This parameter can be: RTC_IT_ALRA: Alarm A interrupt RTC_IT_ALRB: Alarm B interrupt Return value: __HAL_RTC_ALARM_GET_IT_SOURCE None Description: Check whether the specified RTC Alarm interrupt has been enabled or not. Parameters: __HANDLE__: specifies the RTC handle. __INTERRUPT__: specifies the RTC Alarm interrupt sources to check. This parameter can be: RTC_IT_ALRA: Alarm A interrupt RTC_IT_ALRB: Alarm B interrupt Return value: __HAL_RTC_ALARM_GET_FLAG None Description: Get the selected RTC Alarm's flag status. Parameters: 544/832 DOCID026526 Rev 4 __HANDLE__: specifies the RTC handle. __FLAG__: specifies the RTC Alarm Flag sources to check. This parameter UM1786 can be: RTC_FLAG_ALRAF RTC_FLAG_ALRBF RTC_FLAG_ALRAW F RTC_FLAG_ALRBW F Return value: __HAL_RTC_ALARM_CLEAR_FLAG None Description: Clear the RTC Alarm's pending flags. Parameters: __HANDLE__: specifies the RTC handle. __FLAG__: specifies the RTC Alarm Flag sources to clear. This parameter can be: RTC_FLAG_ALRAF RTC_FLAG_ALRBF Return value: __HAL_RTC_ALARM_EXTI_ENABLE_IT None Description: Enable interrupt on the RTC Alarm associated Exti line. Return value: __HAL_RTC_ALARM_EXTI_DISABLE_IT None Description: Disable interrupt on the RTC Alarm associated Exti line. Return value: __HAL_RTC_ALARM_EXTI_ENABLE_EVENT None Description: Enable event on the RTC Alarm associated Exti line. Return value: __HAL_RTC_ALARM_EXTI_DISABLE_EVENT Description: DOCID026526 Rev 4 None. Disable event on the RTC 545/832 UM1786 Alarm associated Exti line. Return value: __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE None. Description: Enable falling edge trigger on the RTC Alarm associated Exti line. Return value: __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDG E None. Description: Disable falling edge trigger on the RTC Alarm associated Exti line. Return value: __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE None. Description: Enable rising edge trigger on the RTC Alarm associated Exti line. Return value: __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE None. Description: Disable rising edge trigger on the RTC Alarm associated Exti line. Return value: __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLIN G_EDGE None. Description: Enable rising & falling edge trigger on the RTC Alarm associated Exti line. Return value: __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLIN G_EDGE None. Description: Disable rising & falling edge trigger on the RTC Alarm associated Exti line. Return value: __HAL_RTC_ALARM_EXTI_GET_FLAG 546/832 DOCID026526 Rev 4 None. Description: UM1786 Check whether the RTC Alarm associated Exti line interrupt flag is set or not. Return value: __HAL_RTC_ALARM_EXTI_CLEAR_FLAG Line: Status. Description: Clear the RTC Alarm associated Exti line flag. Return value: __HAL_RTC_ALARM_EXTI_GENERATE_SWIT None. Description: Generate a Software interrupt on RTC Alarm associated Exti line. Return value: None. RTC Flags Definitions RTC_FLAG_RECALPF RTC_FLAG_TAMP3F RTC_FLAG_TAMP2F RTC_FLAG_TAMP1F RTC_FLAG_TSOVF RTC_FLAG_TSF RTC_FLAG_WUTF RTC_FLAG_ALRBF RTC_FLAG_ALRAF RTC_FLAG_INITF RTC_FLAG_RSF RTC_FLAG_INITS RTC_FLAG_SHPF RTC_FLAG_WUTWF RTC_FLAG_ALRBWF RTC_FLAG_ALRAWF RTC Hour Formats RTC_HOURFORMAT_24 RTC_HOURFORMAT_12 RTC Input parameter format definitions RTC_FORMAT_BIN DOCID026526 Rev 4 547/832 UM1786 RTC_FORMAT_BCD RTC Interrupts Definitions RTC_IT_TS RTC_IT_WUT RTC_IT_ALRB RTC_IT_ALRA RTC_IT_TAMP RTC_IT_TAMP1 RTC_IT_TAMP2 RTC_IT_TAMP3 RTC Private macros to check input parameters IS_RTC_HOUR_FORMAT IS_RTC_OUTPUT_POL IS_RTC_OUTPUT_TYPE IS_RTC_HOUR12 IS_RTC_HOUR24 IS_RTC_ASYNCH_PREDIV IS_RTC_SYNCH_PREDIV IS_RTC_MINUTES IS_RTC_SECONDS IS_RTC_HOURFORMAT12 IS_RTC_DAYLIGHT_SAVING IS_RTC_STORE_OPERATION IS_RTC_FORMAT IS_RTC_YEAR IS_RTC_MONTH IS_RTC_DATE IS_RTC_WEEKDAY IS_RTC_ALARM_DATE_WEEKDAY_DATE IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY IS_RTC_ALARM_DATE_WEEKDAY_SEL IS_RTC_ALARM_MASK IS_RTC_ALARM IS_RTC_ALARM_SUB_SECOND_VALUE IS_RTC_ALARM_SUB_SECOND_MASK RTC Month Date Definitions 548/832 DOCID026526 Rev 4 UM1786 RTC_MONTH_JANUARY RTC_MONTH_FEBRUARY RTC_MONTH_MARCH RTC_MONTH_APRIL RTC_MONTH_MAY RTC_MONTH_JUNE RTC_MONTH_JULY RTC_MONTH_AUGUST RTC_MONTH_SEPTEMBER RTC_MONTH_OCTOBER RTC_MONTH_NOVEMBER RTC_MONTH_DECEMBER RTC Output Polarity Definitions RTC_OUTPUT_POLARITY_HIGH RTC_OUTPUT_POLARITY_LOW RTC Output Type ALARM OUT RTC_OUTPUT_TYPE_OPENDRAIN RTC_OUTPUT_TYPE_PUSHPULL RTC StoreOperation Definitions RTC_STOREOPERATION_RESET RTC_STOREOPERATION_SET RTC WeekDay Definitions RTC_WEEKDAY_MONDAY RTC_WEEKDAY_TUESDAY RTC_WEEKDAY_WEDNESDAY RTC_WEEKDAY_THURSDAY RTC_WEEKDAY_FRIDAY RTC_WEEKDAY_SATURDAY RTC_WEEKDAY_SUNDAY DOCID026526 Rev 4 549/832 UM1786 41 HAL RTC Extension Driver 41.1 RTCEx Firmware driver registers structures 41.1.1 RTC_TamperTypeDef Data Fields uint32_t Tamper uint32_t Trigger uint32_t Filter uint32_t SamplingFrequency uint32_t PrechargeDuration uint32_t TamperPullUp uint32_t TimeStampOnTamperDetection Field Documentation uint32_t RTC_TamperTypeDef::Tamper Specifies the Tamper Pin. This parameter can be a value of RTCEx_Tamper_Pins_Definitions uint32_t RTC_TamperTypeDef::Trigger Specifies the Tamper Trigger. This parameter can be a value of RTCEx_Tamper_Trigger_Definitions uint32_t RTC_TamperTypeDef::Filter Specifies the RTC Filter Tamper. This parameter can be a value of RTCEx_Tamper_Filter_Definitions uint32_t RTC_TamperTypeDef::SamplingFrequency Specifies the sampling frequency. This parameter can be a value of RTCEx_Tamper_Sampling_Frequencies_Definitions uint32_t RTC_TamperTypeDef::PrechargeDuration Specifies the Precharge Duration . This parameter can be a value of RTCEx_Tamper_Pin_Precharge_Duration_Definitions uint32_t RTC_TamperTypeDef::TamperPullUp Specifies the Tamper PullUp . This parameter can be a value of RTCEx_Tamper_Pull_UP_Definitions uint32_t RTC_TamperTypeDef::TimeStampOnTamperDetection Specifies the TimeStampOnTamperDetection. This parameter can be a value of RTCEx_Tamper_TimeStampOnTamperDetection_Definitions 41.2 RTCEx Firmware driver API description 41.2.1 How to use this driver 550/832 Enable the RTC domain access. Configure the RTC Prescaler (Asynchronous and Synchronous) and RTC hour format using the HAL_RTC_Init() function. DOCID026526 Rev 4 UM1786 RTC Wakeup configuration To configure the RTC Wakeup Clock source and Counter use the HAL_RTCEx_SetWakeUpTimer() function. You can also configure the RTC Wakeup timer with interrupt mode using the HAL_RTCEx_SetWakeUpTimer_IT() function. To read the RTC WakeUp Counter register, use the HAL_RTCEx_GetWakeUpTimer() function. TimeStamp configuration Configure the RTC_AF trigger and enable the RTC TimeStamp using the HAL_RTCEx_SetTimeStamp() function. You can also configure the RTC TimeStamp with interrupt mode using the HAL_RTCEx_SetTimeStamp_IT() function. To read the RTC TimeStamp Time and Date register, use the HAL_RTCEx_GetTimeStamp() function. The TIMESTAMP alternate function is mapped to RTC_AF1 (PC13). Tamper configuration Enable the RTC Tamper and configure the Tamper filter count, trigger Edge or Level according to the Tamper filter (if equal to 0 Edge else Level) value, sampling frequency, precharge or discharge and Pull-UP using the HAL_RTCEx_SetTamper() function. You can configure RTC Tamper with interrupt mode using HAL_RTCEx_SetTamper_IT() function. The TAMPER1 alternate function is mapped to RTC_AF1 (PC13). Backup Data Registers configuration 41.2.2 To write to the RTC Backup Data registers, use the HAL_RTCEx_BKUPWrite() function. To read the RTC Backup Data registers, use the HAL_RTCEx_BKUPRead() function. RTC TimeStamp and Tamper functions This section provides functions allowing to configure TimeStamp feature This section contains the following APIs: HAL_RTCEx_SetTimeStamp() HAL_RTCEx_SetTimeStamp_IT() HAL_RTCEx_DeactivateTimeStamp() HAL_RTCEx_GetTimeStamp() HAL_RTCEx_SetTamper() HAL_RTCEx_SetTamper_IT() HAL_RTCEx_DeactivateTamper() HAL_RTCEx_TamperTimeStampIRQHandler() HAL_RTCEx_TimeStampEventCallback() HAL_RTCEx_Tamper1EventCallback() HAL_RTCEx_Tamper2EventCallback() HAL_RTCEx_Tamper3EventCallback() HAL_RTCEx_PollForTimeStampEvent() DOCID026526 Rev 4 551/832 UM1786 41.2.3 HAL_RTCEx_PollForTamper1Event() HAL_RTCEx_PollForTamper2Event() HAL_RTCEx_PollForTamper3Event() RTC Wake-up functions This section provides functions allowing to configure Wake-up feature This section contains the following APIs: 41.2.4 HAL_RTCEx_SetWakeUpTimer() HAL_RTCEx_SetWakeUpTimer_IT() HAL_RTCEx_DeactivateWakeUpTimer() HAL_RTCEx_GetWakeUpTimer() HAL_RTCEx_WakeUpTimerIRQHandler() HAL_RTCEx_WakeUpTimerEventCallback() HAL_RTCEx_PollForWakeUpTimerEvent() Extended Peripheral Control functions This subsection provides functions allowing to Write a data in a specified RTC Backup data register Read a data in a specified RTC Backup data register Set the Coarse calibration parameters. Deactivate the Coarse calibration parameters Set the Smooth calibration parameters. Configure the Synchronization Shift Control Settings. Configure the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz). Deactivate the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz). Enable the RTC reference clock detection. Disable the RTC reference clock detection. Enable the Bypass Shadow feature. Disable the Bypass Shadow feature. This section contains the following APIs: 41.2.5 HAL_RTCEx_BKUPWrite() HAL_RTCEx_BKUPRead() HAL_RTCEx_SetSmoothCalib() HAL_RTCEx_SetSynchroShift() HAL_RTCEx_SetCalibrationOutPut() HAL_RTCEx_DeactivateCalibrationOutPut() HAL_RTCEx_SetRefClock() HAL_RTCEx_DeactivateRefClock() HAL_RTCEx_EnableBypassShadow() HAL_RTCEx_DisableBypassShadow() Extended features functions This section provides functions allowing to: RTC Alram B callback RTC Poll for Alarm B request This section contains the following APIs: 552/832 HAL_RTCEx_AlarmBEventCallback() DOCID026526 Rev 4 UM1786 41.2.6 HAL_RTCEx_PollForAlarmBEvent() Detailed description of functions HAL_RTCEx_SetTimeStamp Function Name HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp (RTC_HandleTypeDef * hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin) Function Description Set TimeStamp. Parameters hrtc: RTC handle TimeStampEdge: Specifies the pin edge on which the TimeStamp is activated. This parameter can be one of the following values: RTC_TIMESTAMPEDGE_RISING: the Time stamp event occurs on the rising edge of the related pin. RTC_TIMESTAMPEDGE_FALLING: the Time stamp event occurs on the falling edge of the related pin. RTC_TimeStampPin: specifies the RTC TimeStamp Pin. This parameter can be one of the following values: RTC_TIMESTAMPPIN_DEFAULT: PC13 is selected as RTC TimeStamp Pin. Return values HAL: status Notes This API must be called before enabling the TimeStamp feature. HAL_RTCEx_SetTimeStamp_IT Function Name HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT (RTC_HandleTypeDef * hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin) Function Description Set TimeStamp with Interrupt. Parameters hrtc: RTC handle TimeStampEdge: Specifies the pin edge on which the TimeStamp is activated. This parameter can be one of the following values: RTC_TIMESTAMPEDGE_RISING: the Time stamp event occurs on the rising edge of the related pin. RTC_TIMESTAMPEDGE_FALLING: the Time stamp event occurs on the falling edge of the related pin. RTC_TimeStampPin: Specifies the RTC TimeStamp Pin. This parameter can be one of the following values: RTC_TIMESTAMPPIN_DEFAULT: PC13 is selected as RTC TimeStamp Pin. Return values HAL: status Notes This API must be called before enabling the TimeStamp feature. DOCID026526 Rev 4 553/832 UM1786 HAL_RTCEx_DeactivateTimeStamp Function Name HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp (RTC_HandleTypeDef * hrtc) Function Description Deactivate TimeStamp. Parameters hrtc: RTC handle Return values HAL: status HAL_RTCEx_GetTimeStamp Function Name HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp (RTC_HandleTypeDef * hrtc, RTC_TimeTypeDef * sTimeStamp, RTC_DateTypeDef * sTimeStampDate, uint32_t Format) Function Description Get the RTC TimeStamp value. Parameters hrtc: RTC handle sTimeStamp: Pointer to Time structure sTimeStampDate: Pointer to Date structure 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 Return values HAL: status HAL_RTCEx_SetTamper Function Name HAL_StatusTypeDef HAL_RTCEx_SetTamper (RTC_HandleTypeDef * hrtc, RTC_TamperTypeDef * sTamper) Function Description Set Tamper. Parameters hrtc: RTC handle sTamper: Pointer to Tamper Structure. Return values HAL: status Notes By calling this API we disable the tamper interrupt for all tampers. HAL_RTCEx_SetTamper_IT 554/832 Function Name HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT (RTC_HandleTypeDef * hrtc, RTC_TamperTypeDef * sTamper) Function Description Set Tamper with interrupt. Parameters hrtc: RTC handle sTamper: Pointer to RTC Tamper. Return values HAL: status Notes By calling this API we force the tamper interrupt for all tampers. DOCID026526 Rev 4 UM1786 HAL_RTCEx_DeactivateTamper Function Name HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper (RTC_HandleTypeDef * hrtc, uint32_t Tamper) Function Description Deactivate Tamper. Parameters hrtc: RTC handle Tamper: Selected tamper pin. This parameter can be any combination of RTC_TAMPER_1, RTC_TAMPER_2 and RTC_TAMPER_3 (*) Return values HAL: status Notes (*) RTC_TAMPER_3 not present on all the devices HAL_RTCEx_TamperTimeStampIRQHandler Function Name void HAL_RTCEx_TamperTimeStampIRQHandler (RTC_HandleTypeDef * hrtc) Function Description Handle TimeStamp interrupt request. Parameters hrtc: RTC handle Return values None: HAL_RTCEx_Tamper1EventCallback Function Name void HAL_RTCEx_Tamper1EventCallback (RTC_HandleTypeDef * hrtc) Function Description Tamper 1 callback. Parameters hrtc: RTC handle Return values None: HAL_RTCEx_Tamper2EventCallback Function Name void HAL_RTCEx_Tamper2EventCallback (RTC_HandleTypeDef * hrtc) Function Description Tamper 2 callback. Parameters hrtc: RTC handle Return values None: HAL_RTCEx_Tamper3EventCallback Function Name void HAL_RTCEx_Tamper3EventCallback (RTC_HandleTypeDef * hrtc) Function Description Tamper 3 callback. Parameters hrtc: RTC handle Return values None: DOCID026526 Rev 4 555/832 UM1786 HAL_RTCEx_TimeStampEventCallback Function Name void HAL_RTCEx_TimeStampEventCallback (RTC_HandleTypeDef * hrtc) Function Description TimeStamp callback. Parameters hrtc: RTC handle Return values None: HAL_RTCEx_PollForTimeStampEvent Function Name HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent (RTC_HandleTypeDef * hrtc, uint32_t Timeout) Function Description Handle TimeStamp polling request. Parameters hrtc: RTC handle Timeout: Timeout duration Return values HAL: status HAL_RTCEx_PollForTamper1Event Function Name HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event (RTC_HandleTypeDef * hrtc, uint32_t Timeout) Function Description Handle Tamper 1 Polling. Parameters hrtc: RTC handle Timeout: Timeout duration Return values HAL: status HAL_RTCEx_PollForTamper2Event Function Name HAL_StatusTypeDef HAL_RTCEx_PollForTamper2Event (RTC_HandleTypeDef * hrtc, uint32_t Timeout) Function Description Handle Tamper 2 Polling. Parameters hrtc: RTC handle Timeout: Timeout duration Return values HAL: status HAL_RTCEx_PollForTamper3Event 556/832 Function Name HAL_StatusTypeDef HAL_RTCEx_PollForTamper3Event (RTC_HandleTypeDef * hrtc, uint32_t Timeout) Function Description Handle Tamper 3 Polling. Parameters hrtc: RTC handle Timeout: Timeout duration Return values HAL: status DOCID026526 Rev 4 UM1786 HAL_RTCEx_SetWakeUpTimer Function Name HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer (RTC_HandleTypeDef * hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock) Function Description Set wake up timer. Parameters hrtc: RTC handle WakeUpCounter: Wake up counter WakeUpClock: Wake up clock Return values HAL: status HAL_RTCEx_SetWakeUpTimer_IT Function Name HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT (RTC_HandleTypeDef * hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock) Function Description Set wake up timer with interrupt. Parameters hrtc: RTC handle WakeUpCounter: Wake up counter WakeUpClock: Wake up clock Return values HAL: status HAL_RTCEx_DeactivateWakeUpTimer Function Name uint32_t HAL_RTCEx_DeactivateWakeUpTimer (RTC_HandleTypeDef * hrtc) Function Description Deactivate wake up timer counter. Parameters hrtc: RTC handle Return values HAL: status HAL_RTCEx_GetWakeUpTimer Function Name uint32_t HAL_RTCEx_GetWakeUpTimer (RTC_HandleTypeDef * hrtc) Function Description Get wake up timer counter. Parameters hrtc: RTC handle Return values Counter: value HAL_RTCEx_WakeUpTimerIRQHandler Function Name void HAL_RTCEx_WakeUpTimerIRQHandler (RTC_HandleTypeDef * hrtc) Function Description Handle Wake Up Timer interrupt request. Parameters hrtc: RTC handle Return values None: DOCID026526 Rev 4 557/832 UM1786 HAL_RTCEx_WakeUpTimerEventCallback Function Name void HAL_RTCEx_WakeUpTimerEventCallback (RTC_HandleTypeDef * hrtc) Function Description Wake Up Timer callback. Parameters hrtc: RTC handle Return values None: HAL_RTCEx_PollForWakeUpTimerEvent Function Name HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent (RTC_HandleTypeDef * hrtc, uint32_t Timeout) Function Description Handle Wake Up Timer Polling. Parameters hrtc: RTC handle Timeout: Timeout duration Return values HAL: status HAL_RTCEx_BKUPWrite Function Name void HAL_RTCEx_BKUPWrite (RTC_HandleTypeDef * hrtc, uint32_t BackupRegister, uint32_t Data) Function Description Write a data in a specified RTC Backup data register. Parameters hrtc: RTC handle BackupRegister: RTC Backup data Register number. This parameter can be: RTC_BKP_DRx where x can be from 0 to 19 to specify the register. Data: Data to be written in the specified RTC Backup data register. Return values None: HAL_RTCEx_BKUPRead Function Name uint32_t HAL_RTCEx_BKUPRead (RTC_HandleTypeDef * hrtc, uint32_t BackupRegister) Function Description Reads data from the specified RTC Backup data Register. Parameters hrtc: RTC handle BackupRegister: RTC Backup data Register number. This parameter can be: RTC_BKP_DRx where x can be from 0 to 19 to specify the register. Return values Read: value HAL_RTCEx_SetSmoothCalib Function Name 558/832 HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib (RTC_HandleTypeDef * hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmoothCalibMinusPulsesValue) DOCID026526 Rev 4 UM1786 Function Description Set the Smooth calibration parameters. Parameters hrtc: RTC handle SmoothCalibPeriod: Select the Smooth Calibration Period. This parameter can be can be one of the following values : RTC_SMOOTHCALIB_PERIOD_32SEC: The smooth calibration period is 32s. RTC_SMOOTHCALIB_PERIOD_16SEC: The smooth calibration period is 16s. RTC_SMOOTHCALIB_PERIOD_8SEC: The smooth calibration period is 8s. SmoothCalibPlusPulses: Select to Set or reset the CALP bit. This parameter can be one of the following values: RTC_SMOOTHCALIB_PLUSPULSES_SET: Add one RTCCLK pulse every 2*11 pulses. RTC_SMOOTHCALIB_PLUSPULSES_RESET: No RTCCLK pulses are added. SmoothCalibMinusPulsesValue: Select the value of CALM[8:0] bits. This parameter can be one any value from 0 to 0x000001FF. Return values HAL: status Notes To deactivate the smooth calibration, the field SmoothCalibPlusPulses must be equal to SMOOTHCALIB_PLUSPULSES_RESET and the field SmoothCalibMinusPulsesValue mut be equal to 0. HAL_RTCEx_SetSynchroShift Function Name HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift (RTC_HandleTypeDef * hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS) Function Description Configure the Synchronization Shift Control Settings. Parameters hrtc: RTC handle ShiftAdd1S: Select to add or not 1 second to the time calendar. This parameter can be one of the following values : RTC_SHIFTADD1S_SET: Add one second to the clock calendar. RTC_SHIFTADD1S_RESET: No effect. ShiftSubFS: Select the number of Second Fractions to substitute. This parameter can be one any value from 0 to 0x7FFF. Return values HAL: status Notes When REFCKON is set, firmware must not write to Shift control register. HAL_RTCEx_SetCalibrationOutPut Function Name HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut (RTC_HandleTypeDef * hrtc, uint32_t CalibOutput) Function Description Configure the Calibration Pinout (RTC_CALIB) Selection (1Hz or DOCID026526 Rev 4 559/832 UM1786 512Hz). Parameters hrtc: RTC handle CalibOutput: Select the Calibration output Selection . This parameter can be one of the following values: RTC_CALIBOUTPUT_512HZ: A signal has a regular waveform at 512Hz. RTC_CALIBOUTPUT_1HZ: A signal has a regular waveform at 1Hz. Return values HAL: status HAL_RTCEx_DeactivateCalibrationOutPut Function Name HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut (RTC_HandleTypeDef * hrtc) Function Description Deactivate the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz). Parameters hrtc: RTC handle Return values HAL: status HAL_RTCEx_SetRefClock Function Name HAL_StatusTypeDef HAL_RTCEx_SetRefClock (RTC_HandleTypeDef * hrtc) Function Description Enable the RTC reference clock detection. Parameters hrtc: RTC handle Return values HAL: status HAL_RTCEx_DeactivateRefClock Function Name HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock (RTC_HandleTypeDef * hrtc) Function Description Disable the RTC reference clock detection. Parameters hrtc: RTC handle Return values HAL: status HAL_RTCEx_EnableBypassShadow 560/832 Function Name HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow (RTC_HandleTypeDef * hrtc) Function Description Enable the Bypass Shadow feature. Parameters hrtc: RTC handle Return values HAL: status Notes When the Bypass Shadow is enabled the calendar value are taken directly from the Calendar counter. DOCID026526 Rev 4 UM1786 HAL_RTCEx_DisableBypassShadow Function Name HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow (RTC_HandleTypeDef * hrtc) Function Description Disable the Bypass Shadow feature. Parameters hrtc: RTC handle Return values HAL: status Notes When the Bypass Shadow is enabled the calendar value are taken directly from the Calendar counter. HAL_RTCEx_AlarmBEventCallback Function Name void HAL_RTCEx_AlarmBEventCallback (RTC_HandleTypeDef * hrtc) Function Description Alarm B callback. Parameters hrtc: RTC handle Return values None: HAL_RTCEx_PollForAlarmBEvent Function Name HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent (RTC_HandleTypeDef * hrtc, uint32_t Timeout) Function Description This function handles AlarmB Polling request. Parameters hrtc: RTC handle Timeout: Timeout duration Return values HAL: status 41.3 RTCEx Firmware driver defines 41.3.1 RTCEx RTC Extended Add 1 Second Parameter Definition RTC_SHIFTADD1S_RESET RTC_SHIFTADD1S_SET RTC Extended Backup Registers Definition RTC_BKP_DR0 RTC_BKP_DR1 RTC_BKP_DR2 RTC_BKP_DR3 RTC_BKP_DR4 RTC_BKP_DR5 RTC_BKP_DR6 RTC_BKP_DR7 DOCID026526 Rev 4 561/832 UM1786 RTC_BKP_DR8 RTC_BKP_DR9 RTC_BKP_DR10 RTC_BKP_DR11 RTC_BKP_DR12 RTC_BKP_DR13 RTC_BKP_DR14 RTC_BKP_DR15 RTC Extended Calibration __HAL_RTC_CALIBRATION_OUTPUT_ENABLE Description: Enable the RTC calibration output. Parameters: __HANDLE__: specifies the RTC handle. Return value: __HAL_RTC_CALIBRATION_OUTPUT_DISABLE None Description: Disable the calibration output. Parameters: __HANDLE__: specifies the RTC handle. Return value: __HAL_RTC_CLOCKREF_DETECTION_ENABLE None Description: Enable the clock reference detection. Parameters: __HANDLE__: specifies the RTC handle. Return value: __HAL_RTC_CLOCKREF_DETECTION_DISABLE None Description: Disable the clock reference detection. Parameters: 562/832 DOCID026526 Rev 4 __HANDLE__: specifies the RTC handle. UM1786 Return value: __HAL_RTC_SHIFT_GET_FLAG None Description: Get the selected RTC shift operation's flag status. Parameters: __HANDLE__: specifies the RTC handle. __FLAG__: specifies the RTC shift operation Flag is pending or not. This parameter can be: RTC_FLAG_SHPF Return value: None RTC Extended Calib Output selection Definition RTC_CALIBOUTPUT_512HZ RTC_CALIBOUTPUT_1HZ Private macros to check input parameters IS_RTC_OUTPUT IS_RTC_BKP IS_TIMESTAMP_EDGE IS_RTC_TAMPER IS_RTC_TIMESTAMP_PIN IS_RTC_TAMPER_TRIGGER IS_RTC_TAMPER_FILTER IS_RTC_TAMPER_SAMPLING_FREQ IS_RTC_TAMPER_PRECHARGE_DURATION IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION IS_RTC_TAMPER_PULLUP_STATE IS_RTC_WAKEUP_CLOCK IS_RTC_WAKEUP_COUNTER IS_RTC_SMOOTH_CALIB_PERIOD IS_RTC_SMOOTH_CALIB_PLUS IS_RTC_SMOOTH_CALIB_MINUS IS_RTC_SHIFT_ADD1S IS_RTC_SHIFT_SUBFS IS_RTC_CALIB_OUTPUT RTC Extended Output Selection Definition DOCID026526 Rev 4 563/832 UM1786 RTC_OUTPUT_DISABLE RTC_OUTPUT_ALARMA RTC_OUTPUT_ALARMB RTC_OUTPUT_WAKEUP RTC Extended Smooth calib period Definition RTC_SMOOTHCALIB_PERIOD_32SEC If RTCCLK = 32768 Hz, Smooth calibation period is 32s, else 2exp20 RTCCLK seconds RTC_SMOOTHCALIB_PERIOD_16SEC If RTCCLK = 32768 Hz, Smooth calibation period is 16s, else 2exp19 RTCCLK seconds RTC_SMOOTHCALIB_PERIOD_8SEC If RTCCLK = 32768 Hz, Smooth calibation period is 8s, else 2exp18 RTCCLK seconds RTC Extended Smooth calib Plus pulses Definition RTC_SMOOTHCALIB_PLUSPULSES_RESET The number of RTCCLK pulses subbstited during a 32-second window = CALM[8:0] RTC_SMOOTHCALIB_PLUSPULSES_SET The number of RTCCLK pulses added during a X -second window = Y CALM[8:0] with Y = 512, 256, 128 when X = 32, 16, 8 RTC Extended Tamper __HAL_RTC_TAMPER1_ENABLE Description: Enable the RTC Tamper1 input detection. Parameters: __HANDLE__: specifies the RTC handle. Return value: __HAL_RTC_TAMPER1_DISABLE None Description: Disable the RTC Tamper1 input detection. Parameters: __HANDLE__: specifies the RTC handle. Return value: __HAL_RTC_TAMPER2_ENABLE None Description: Enable the RTC Tamper2 input detection. Parameters: 564/832 DOCID026526 Rev 4 __HANDLE__: specifies the RTC UM1786 handle. Return value: __HAL_RTC_TAMPER2_DISABLE None Description: Disable the RTC Tamper2 input detection. Parameters: __HANDLE__: specifies the RTC handle. Return value: __HAL_RTC_TAMPER3_ENABLE None Description: Enable the RTC Tamper3 input detection. Parameters: __HANDLE__: specifies the RTC handle. Return value: __HAL_RTC_TAMPER3_DISABLE None Description: Disable the RTC Tamper3 input detection. Parameters: __HANDLE__: specifies the RTC handle. Return value: __HAL_RTC_TAMPER_ENABLE_IT None Description: Enable the RTC Tamper interrupt. Parameters: __HANDLE__: specifies the RTC handle. __INTERRUPT__: specifies the RTC Tamper interrupt sources to be enabled. This parameter can be any combination of the following values: RTC_IT_TAMP: Tamper interrupt Return value: __HAL_RTC_TAMPER_DISABLE_IT None Description: DOCID026526 Rev 4 565/832 UM1786 Disable the RTC Tamper interrupt. Parameters: __HANDLE__: specifies the RTC handle. __INTERRUPT__: specifies the RTC Tamper interrupt sources to be disabled. This parameter can be any combination of the following values: RTC_IT_TAMP: Tamper interrupt Return value: __HAL_RTC_TAMPER_GET_IT None Description: Check whether the specified RTC Tamper interrupt has occurred or not. Parameters: __HANDLE__: specifies the RTC handle. __INTERRUPT__: specifies the RTC Tamper interrupt to check. This parameter can be: RTC_IT_TAMP1: Tamper1 interrupt RTC_IT_TAMP2: Tamper2 interrupt RTC_IT_TAMP3: Tamper3 interrupt (*) Return value: None Notes: __HAL_RTC_TAMPER_GET_IT_SOURCE (*) RTC_IT_TAMP3 not present on all the devices Description: Check whether the specified RTC Tamper interrupt has been enabled or not. Parameters: __HANDLE__: specifies the RTC handle. __INTERRUPT__: specifies the RTC Tamper interrupt source to check. This parameter can be: RTC_IT_TAMP: Tamper interrupt Return value: 566/832 DOCID026526 Rev 4 None UM1786 Description: __HAL_RTC_TAMPER_GET_FLAG Get the selected RTC Tamper's flag status. Parameters: __HANDLE__: specifies the RTC handle. __FLAG__: specifies the RTC Tamper Flag is pending or not. This parameter can be: RTC_FLAG_TAMP1F RTC_FLAG_TAMP2F RTC_FLAG_TAMP3F (*) Return value: None Notes: __HAL_RTC_TAMPER_CLEAR_FLAG (*) RTC_FLAG_TAMP3F not present on all the devices Description: Clear the RTC Tamper's pending flags. Parameters: __HANDLE__: specifies the RTC handle. __FLAG__: specifies the RTC Tamper Flag to clear. This parameter can be: RTC_FLAG_TAMP1F RTC_FLAG_TAMP2F RTC_FLAG_TAMP3F (*) Return value: None Notes: (*) RTC_FLAG_TAMP3F not present on all the devices RTC Extended Tamper Filter Definition RTC_TAMPERFILTER_DISABLE Tamper filter is disabled RTC_TAMPERFILTER_2SAMPLE Tamper is activated after 2 consecutive samples at the active level RTC_TAMPERFILTER_4SAMPLE Tamper is activated after 4 consecutive samples at the active level RTC_TAMPERFILTER_8SAMPLE Tamper is activated after 8 consecutive samples at the active level. RTC Extended Tamper Pins Definition RTC_TAMPER_1 DOCID026526 Rev 4 567/832 UM1786 RTC_TAMPER_2 RTC_TAMPER_3 RTC Extended Tamper Pin Precharge Duration Definition RTC_TAMPERPRECHARGEDURATION_1RTCCLK Tamper pins are pre-charged before sampling during 1 RTCCLK cycle RTC_TAMPERPRECHARGEDURATION_2RTCCLK Tamper pins are pre-charged before sampling during 2 RTCCLK cycles RTC_TAMPERPRECHARGEDURATION_4RTCCLK Tamper pins are pre-charged before sampling during 4 RTCCLK cycles RTC_TAMPERPRECHARGEDURATION_8RTCCLK Tamper pins are pre-charged before sampling during 8 RTCCLK cycles RTC Extended Tamper Pull UP Definition RTC_TAMPER_PULLUP_ENABLE Tamper pins are pre-charged before sampling RTC_TAMPER_PULLUP_DISABLE Tamper pins are not pre-charged before sampling RTC Extended Tamper Sampling Frequencies Definition RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768 Each of the tamper inputs are sampled with a frequency = RTCCLK / 32768 RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384 Each of the tamper inputs are sampled with a frequency = RTCCLK / 16384 RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192 Each of the tamper inputs are sampled with a frequency = RTCCLK / 8192 RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096 Each of the tamper inputs are sampled with a frequency = RTCCLK / 4096 RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048 Each of the tamper inputs are sampled with a frequency = RTCCLK / 2048 RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024 Each of the tamper inputs are sampled with a frequency = RTCCLK / 1024 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 EXTI RTC Extended Tamper Timestamp EXTI __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_I 568/832 DOCID026526 Rev 4 Description: UM1786 T Enable interrupt on the RTC Tamper and Timestamp associated Exti line. Return value: __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_ IT None Description: Disable interrupt on the RTC Tamper and Timestamp associated Exti line. Return value: __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_ EVENT None Description: Enable event on the RTC Tamper and Timestamp associated Exti line. Return value: __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_ EVENT None. Description: Disable event on the RTC Tamper and Timestamp associated Exti line. Return value: __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_F ALLING_EDGE None. Description: Enable falling edge trigger on the RTC Tamper and Timestamp associated Exti line. Return value: __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_F ALLING_EDGE None. Description: Disable falling edge trigger on the RTC Tamper and Timestamp associated Exti line. Return value: __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RI SING_EDGE DOCID026526 Rev 4 None. Description: Enable rising edge trigger on the RTC 569/832 UM1786 Tamper and Timestamp associated Exti line. Return value: __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_R ISING_EDGE None. Description: Disable rising edge trigger on the RTC Tamper and Timestamp associated Exti line. Return value: __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_R ISING_FALLING_EDGE None. Description: Enable rising & falling edge trigger on the RTC Tamper and Timestamp associated Exti line. Return value: __HAL_RTC_TAMPER_TIMESTAMP_EXTI_DISABLE_ RISING_FALLING_EDGE None. Description: Disable rising & falling edge trigger on the RTC Tamper and Timestamp associated Exti line. Return value: __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GET_FLAG None. Description: Check whether the RTC Tamper and Timestamp associated Exti line interrupt flag is set or not. Return value: __HAL_RTC_TAMPER_TIMESTAMP_EXTI_CLEAR_FL AG Line: Status. Description: Clear the RTC Tamper and Timestamp associated Exti line flag. Return value: __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GENERAT E_SWIT 570/832 DOCID026526 Rev 4 None. Description: Generate a Software interrupt on the RTC Tamper and Timestamp UM1786 associated Exti line. Return value: None. RTC Extended Tamper TimeStampOnTamperDetection Definition RTC_TIMESTAMPONTAMPERDETECTION_ENABLE TimeStamp on Tamper Detection event saved RTC_TIMESTAMPONTAMPERDETECTION_DISABLE TimeStamp on Tamper Detection event is not saved RTC Extended Tamper Trigger Definition RTC_TAMPERTRIGGER_RISINGEDGE RTC_TAMPERTRIGGER_FALLINGEDGE RTC_TAMPERTRIGGER_LOWLEVEL RTC_TAMPERTRIGGER_HIGHLEVEL RTC Extended Timestamp __HAL_RTC_TIMESTAMP_ENABLE Description: Enable the RTC TimeStamp peripheral. Parameters: __HANDLE__: specifies the RTC handle. Return value: __HAL_RTC_TIMESTAMP_DISABLE None Description: Disable the RTC TimeStamp peripheral. Parameters: __HANDLE__: specifies the RTC handle. Return value: __HAL_RTC_TIMESTAMP_ENABLE_IT None Description: Enable the RTC TimeStamp interrupt. Parameters: DOCID026526 Rev 4 __HANDLE__: specifies the RTC handle. __INTERRUPT__: specifies the RTC TimeStamp interrupt source to be enabled. This parameter can be: RTC_IT_TS: TimeStamp 571/832 UM1786 interrupt Return value: __HAL_RTC_TIMESTAMP_DISABLE_IT None Description: Disable the RTC TimeStamp interrupt. Parameters: __HANDLE__: specifies the RTC handle. __INTERRUPT__: specifies the RTC TimeStamp interrupt source to be disabled. This parameter can be: RTC_IT_TS: TimeStamp interrupt Return value: __HAL_RTC_TIMESTAMP_GET_IT None Description: Check whether the specified RTC TimeStamp interrupt has occurred or not. Parameters: __HANDLE__: specifies the RTC handle. __INTERRUPT__: specifies the RTC TimeStamp interrupt to check. This parameter can be: RTC_IT_TS: TimeStamp interrupt Return value: __HAL_RTC_TIMESTAMP_GET_IT_SOURCE None Description: Check whether the specified RTC Time Stamp interrupt has been enabled or not. Parameters: __HANDLE__: specifies the RTC handle. __INTERRUPT__: specifies the RTC Time Stamp interrupt source to check. This parameter can be: RTC_IT_TS: TimeStamp interrupt Return value: 572/832 DOCID026526 Rev 4 None UM1786 __HAL_RTC_TIMESTAMP_GET_FLAG Description: Get the selected RTC TimeStamp's flag status. Parameters: __HANDLE__: specifies the RTC handle. __FLAG__: specifies the RTC TimeStamp Flag is pending or not. This parameter can be: RTC_FLAG_TSF RTC_FLAG_TSOVF Return value: __HAL_RTC_TIMESTAMP_CLEAR_FLAG None Description: Clear the RTC Time Stamp's pending flags. Parameters: __HANDLE__: specifies the RTC handle. __FLAG__: specifies the RTC Alarm Flag to clear. This parameter can be: RTC_FLAG_TSF Return value: None RTC Extended TimeStamp Pin Selection RTC_TIMESTAMPPIN_DEFAULT RTC Extended Time Stamp Edges definition RTC_TIMESTAMPEDGE_RISING RTC_TIMESTAMPEDGE_FALLING RTC Extended WakeUp Timer __HAL_RTC_WAKEUPTIMER_ENABLE Description: Enable the RTC WakeUp Timer peripheral. Parameters: __HANDLE__: specifies the RTC handle. Return value: __HAL_RTC_WAKEUPTIMER_DISABLE None Description: DOCID026526 Rev 4 Disable the RTC WakeUp 573/832 UM1786 Timer peripheral. Parameters: __HANDLE__: specifies the RTC handle. Return value: __HAL_RTC_WAKEUPTIMER_ENABLE_IT None Description: Enable the RTC WakeUpTimer interrupt. Parameters: __HANDLE__: specifies the RTC handle. __INTERRUPT__: specifies the RTC WakeUpTimer interrupt sources to be enabled. This parameter can be: RTC_IT_WUT: WakeUpTimer interrupt Return value: __HAL_RTC_WAKEUPTIMER_DISABLE_IT None Description: Disable the RTC WakeUpTimer interrupt. Parameters: __HANDLE__: specifies the RTC handle. __INTERRUPT__: specifies the RTC WakeUpTimer interrupt sources to be disabled. This parameter can be: RTC_IT_WUT: WakeUpTimer interrupt Return value: __HAL_RTC_WAKEUPTIMER_GET_IT None Description: Check whether the specified RTC WakeUpTimer interrupt has occurred or not. Parameters: 574/832 DOCID026526 Rev 4 __HANDLE__: specifies the RTC handle. __INTERRUPT__: specifies UM1786 the RTC WakeUpTimer interrupt to check. This parameter can be: RTC_IT_WUT: WakeUpTimer interrupt Return value: __HAL_RTC_WAKEUPTIMER_GET_IT_SOURCE None Description: Check whether the specified RTC Wake Up timer interrupt has been enabled or not. Parameters: __HANDLE__: specifies the RTC handle. __INTERRUPT__: specifies the RTC Wake Up timer interrupt sources to check. This parameter can be: RTC_IT_WUT: WakeUpTimer interrupt Return value: __HAL_RTC_WAKEUPTIMER_GET_FLAG None Description: Get the selected RTC WakeUpTimer's flag status. Parameters: __HANDLE__: specifies the RTC handle. __FLAG__: specifies the RTC WakeUpTimer Flag is pending or not. This parameter can be: RTC_FLAG_WUTF RTC_FLAG_WUTWF Return value: __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG None Description: Clear the RTC Wake Up timer's pending flags. Parameters: DOCID026526 Rev 4 __HANDLE__: specifies the RTC handle. 575/832 UM1786 __FLAG__: specifies the RTC WakeUpTimer Flag to clear. This parameter can be: RTC_FLAG_WUTF Return value: __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT None Description: Enable interrupt on the RTC WakeUp Timer associated Exti line. Return value: __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_IT None Description: Disable interrupt on the RTC WakeUp Timer associated Exti line. Return value: __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_EVENT None Description: Enable event on the RTC WakeUp Timer associated Exti line. Return value: __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_EVEN T None. Description: Disable event on the RTC WakeUp Timer associated Exti line. Return value: __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_FALLIN G_EDGE None. Description: Enable falling edge trigger on the RTC WakeUp Timer associated Exti line. Return value: __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_FALLI NG_EDGE 576/832 DOCID026526 Rev 4 None. Description: Disable falling edge trigger on the RTC WakeUp Timer associated Exti line. UM1786 Return value: __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISIN G_EDGE None. Description: Enable rising edge trigger on the RTC WakeUp Timer associated Exti line. Return value: __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISIN G_EDGE None. Description: Disable rising edge trigger on the RTC WakeUp Timer associated Exti line. Return value: __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISIN G_FALLING_EDGE None. Description: Enable rising & falling edge trigger on the RTC WakeUp Timer associated Exti line. Return value: __HAL_RTC_WAKEUPTIMER_EXTI_DISABLE_RISIN G_FALLING_EDGE None. Description: Disable rising & falling edge trigger on the RTC WakeUp Timer associated Exti line. Return value: __HAL_RTC_WAKEUPTIMER_EXTI_GET_FLAG None. Description: Check whether the RTC WakeUp Timer associated Exti line interrupt flag is set or not. Return value: __HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG Line: Status. Description: Clear the RTC WakeUp Timer associated Exti line flag. Return value: DOCID026526 Rev 4 None. 577/832 UM1786 __HAL_RTC_WAKEUPTIMER_EXTI_GENERATE_ SWIT Description: Generate a Software interrupt on the RTC WakeUp Timer associated Exti line. Return value: RTC Extended Wakeup Timer Definition RTC_WAKEUPCLOCK_RTCCLK_DIV16 RTC_WAKEUPCLOCK_RTCCLK_DIV8 RTC_WAKEUPCLOCK_RTCCLK_DIV4 RTC_WAKEUPCLOCK_RTCCLK_DIV2 RTC_WAKEUPCLOCK_CK_SPRE_16BITS RTC_WAKEUPCLOCK_CK_SPRE_17BITS 578/832 DOCID026526 Rev 4 None. UM1786 42 HAL SDADC Generic Driver 42.1 SDADC Firmware driver registers structures 42.1.1 SDADC_InitTypeDef Data Fields uint32_t IdleLowPowerMode uint32_t FastConversionMode uint32_t SlowClockMode uint32_t ReferenceVoltage Field Documentation 42.1.2 uint32_t SDADC_InitTypeDef::IdleLowPowerMode Specifies if SDADC can enter in power down or standby when idle. This parameter can be a value of SDADC_Idle_Low_Power_Mode uint32_t SDADC_InitTypeDef::FastConversionMode Specifies if Fast conversion mode is enabled or not. This parameter can be a value of SDADC_Fast_Conv_Mode uint32_t SDADC_InitTypeDef::SlowClockMode Specifies if slow clock mode is enabled or not. This parameter can be a value of SDADC_Slow_Clock_Mode uint32_t SDADC_InitTypeDef::ReferenceVoltage Specifies the reference voltage. Note: This parameter is common to all SDADC instances. This parameter can be a value of SDADC_Reference_Voltage SDADC_HandleTypeDef Data Fields SDADC_TypeDef * Instance SDADC_InitTypeDef Init DMA_HandleTypeDef * hdma uint32_t RegularContMode uint32_t InjectedContMode uint32_t InjectedChannelsNbr uint32_t InjConvRemaining uint32_t RegularTrigger uint32_t InjectedTrigger uint32_t ExtTriggerEdge uint32_t RegularMultimode uint32_t InjectedMultimode HAL_SDADC_StateTypeDef State uint32_t ErrorCode DOCID026526 Rev 4 579/832 UM1786 Field Documentation 42.1.3 SDADC_TypeDef* SDADC_HandleTypeDef::Instance SDADC registers base address SDADC_InitTypeDef SDADC_HandleTypeDef::Init SDADC init parameters DMA_HandleTypeDef* SDADC_HandleTypeDef::hdma SDADC DMA Handle parameters uint32_t SDADC_HandleTypeDef::RegularContMode Regular conversion continuous mode uint32_t SDADC_HandleTypeDef::InjectedContMode Injected conversion continuous mode uint32_t SDADC_HandleTypeDef::InjectedChannelsNbr Number of channels in injected sequence uint32_t SDADC_HandleTypeDef::InjConvRemaining Injected conversion remaining uint32_t SDADC_HandleTypeDef::RegularTrigger Current trigger used for regular conversion uint32_t SDADC_HandleTypeDef::InjectedTrigger Current trigger used for injected conversion uint32_t SDADC_HandleTypeDef::ExtTriggerEdge Rising, falling or both edges selected uint32_t SDADC_HandleTypeDef::RegularMultimode current type of regular multimode uint32_t SDADC_HandleTypeDef::InjectedMultimode Current type of injected multimode HAL_SDADC_StateTypeDef SDADC_HandleTypeDef::State SDADC state uint32_t SDADC_HandleTypeDef::ErrorCode SDADC Error code SDADC_ConfParamTypeDef Data Fields uint32_t InputMode uint32_t Gain uint32_t CommonMode uint32_t Offset Field Documentation 580/832 uint32_t SDADC_ConfParamTypeDef::InputMode Specifies the input mode (single ended, differential...) This parameter can be any value of SDADC_InputMode uint32_t SDADC_ConfParamTypeDef::Gain Specifies the gain setting. This parameter can be any value of SDADC_Gain uint32_t SDADC_ConfParamTypeDef::CommonMode Specifies the common mode setting (VSSA, VDDA, VDDA/2). This parameter can be any value of SDADC_CommonMode DOCID026526 Rev 4 UM1786 uint32_t SDADC_ConfParamTypeDef::Offset Specifies the 12-bit offset value. This parameter can be any value lower or equal to 0x00000FFF 42.2 SDADC Firmware driver API description 42.2.1 SDADC specific features 1. 2. 3. 4. 5. 6. 7. 42.2.2 16-bit sigma delta architecture. Self calibration. Interrupt generation at the end of calibration, regular/injected conversion and in case of overrun events. Single and continuous conversion modes. External trigger option with configurable polarity for injected conversion. Multi mode (synchronized another SDADC with SDADC1). DMA request generation during regular or injected channel conversion. How to use this driver Initialization 1. 2. 3. As prerequisite, fill in the HAL_SDADC_MspInit() : Enable SDADCx clock interface with __SDADCx_CLK_ENABLE(). Configure SDADCx clock divider with HAL_RCCEx_PeriphCLKConfig. Enable power on SDADC with HAL_PWREx_EnableSDADC(). Enable the clocks for the SDADC GPIOS with __HAL_RCC_GPIOx_CLK_ENABLE(). Configure these SDADC pins in analog mode using HAL_GPIO_Init(). If interrupt mode is used, enable and configure SDADC global interrupt with HAL_NVIC_SetPriority() and HAL_NVIC_EnableIRQ(). If DMA mode is used, configure DMA with HAL_DMA_Init and link it with SDADC handle using __HAL_LINKDMA. Configure the SDADC low power mode, fast conversion mode, slow clock mode and SDADC1 reference voltage using the HAL_ADC_Init() function. Note: Common reference voltage. is common to all SDADC instances. Prepare channel configurations (input mode, common mode, gain and offset) using HAL_SDADC_PrepareChannelConfig and associate channel with one configuration using HAL_SDADC_AssociateChannelConfig. Calibration 1. 2. 3. Start calibration using HAL_SDADC_StartCalibration or HAL_SDADC_CalibrationStart_IT. In polling mode, use HAL_SDADC_PollForCalibEvent to detect the end of calibration. In interrupt mode, HAL_SDADC_CalibrationCpltCallback will be called at the end of calibration. DOCID026526 Rev 4 581/832 UM1786 Regular channel conversion 1. 2. 3. 4. 5. 6. 7. 8. Select trigger for regular conversion using HAL_SDADC_SelectRegularTrigger. Select regular channel and enable/disable continuous mode using HAL_SDADC_ConfigChannel. Start regular conversion using HAL_SDADC_Start, HAL_SDADC_Start_IT or HAL_SDADC_Start_DMA. In polling mode, use HAL_SDADC_PollForConversion to detect the end of regular conversion. In interrupt mode, HAL_SDADC_ConvCpltCallback will be called at the end of regular conversion. Get value of regular conversion using HAL_SDADC_GetValue. In DMA mode, HAL_SDADC_ConvHalfCpltCallback and HAL_SDADC_ConvCpltCallback will be called respectively at the half transfer and at the transfer complete. Stop regular conversion using HAL_SDADC_Stop, HAL_SDADC_Stop_IT or HAL_SDADC_Stop_DMA. Injected channels conversion 1. Enable/disable delay on injected conversion using HAL_SDADC_SelectInjectedDelay. 2. If external trigger is used for injected conversion, configure this trigger using HAL_SDADC_SelectInjectedExtTrigger. 3. Select trigger for injected conversion using HAL_SDADC_SelectInjectedTrigger. 4. Select injected channels and enable/disable continuous mode using HAL_SDADC_InjectedConfigChannel. 5. Start injected conversion using HAL_SDADC_InjectedStart, HAL_SDADC_InjectedStart_IT or HAL_SDADC_InjectedStart_DMA. 6. In polling mode, use HAL_SDADC_PollForInjectedConversion to detect the end of injected conversion. 7. In interrupt mode, HAL_SDADC_InjectedConvCpltCallback will be called at the end of injected conversion. 8. Get value of injected conversion and corresponding channel using HAL_SDADC_InjectedGetValue. 9. In DMA mode, HAL_SDADC_InjectedConvHalfCpltCallback and HAL_SDADC_InjectedConvCpltCallback will be called respectively at the half transfer and at the transfer complete. 10. Stop injected conversion using HAL_SDADC_InjectedStop, HAL_SDADC_InjectedStop_IT or HAL_SDADC_InjectedStop_DMA. Multi mode regular channels conversions 1. 2. 3. 4. 5. 582/832 Select type of multimode (SDADC1/SDADC2 or SDADC1/SDADC3) using HAL_SDADC_MultiModeConfigChannel. Select software trigger for SDADC1 and synchronized trigger for SDADC2 (or SDADC3) using HAL_SDADC_SelectRegularTrigger. Select regular channel for SDADC1 and SDADC2 (or SDADC3) using HAL_SDADC_ConfigChannel. Start regular conversion for SDADC2 (or SDADC3) with HAL_SDADC_Start. Start regular conversion for SDADC1 using HAL_SDADC_Start, HAL_SDADC_Start_IT or HAL_SDADC_MultiModeStart_DMA. DOCID026526 Rev 4 UM1786 6. In polling mode, use HAL_SDADC_PollForConversion to detect the end of regular conversion for SDADC1. 7. In interrupt mode, HAL_SDADC_ConvCpltCallback will be called at the end of regular conversion for SDADC1. 8. Get value of regular conversions using HAL_SDADC_MultiModeGetValue. 9. In DMA mode, HAL_SDADC_ConvHalfCpltCallback and HAL_SDADC_ConvCpltCallback will be called respectively at the half transfer and at the transfer complete for SDADC1. 10. Stop regular conversion using HAL_SDADC_Stop, HAL_SDADC_Stop_IT or HAL_SDADC_MultiModeStop_DMA for SDADC1. 11. Stop regular conversion using HAL_SDADC_Stop for SDADC2 (or SDADC3). Multi mode injected channels conversions 1. Select type of multimode (SDADC1/SDADC2 or SDADC1/SDADC3) using HAL_SDADC_InjectedMultiModeConfigChannel. 2. Select software or external trigger for SDADC1 and synchronized trigger for SDADC2 (or SDADC3) using HAL_SDADC_SelectInjectedTrigger. 3. Select injected channels for SDADC1 and SDADC2 (or SDADC3) using HAL_SDADC_InjectedConfigChannel. 4. Start injected conversion for SDADC2 (or SDADC3) with HAL_SDADC_InjectedStart. 5. Start injected conversion for SDADC1 using HAL_SDADC_InjectedStart, HAL_SDADC_InjectedStart_IT or HAL_SDADC_InjectedMultiModeStart_DMA. 6. In polling mode, use HAL_SDADC_InjectedPollForConversion to detect the end of injected conversion for SDADC1. 7. In interrupt mode, HAL_SDADC_InjectedConvCpltCallback will be called at the end of injected conversion for SDADC1. 8. Get value of injected conversions using HAL_SDADC_InjectedMultiModeGetValue. 9. In DMA mode, HAL_SDADC_InjectedConvHalfCpltCallback and HAL_SDADC_InjectedConvCpltCallback will be called respectively at the half transfer and at the transfer complete for SDADC1. 10. Stop injected conversion using HAL_SDADC_InjectedStop, HAL_SDADC_InjectedStop_IT or HAL_SDADC_InjecteddMultiModeStop_DMA for SDADC1. 11. Stop injected conversion using HAL_SDADC_InjectedStop for SDADC2 (or SDADC3). 42.2.3 Initialization and de-initialization functions This section provides functions allowing to: Initialize the SDADC. De-initialize the SDADC. This section contains the following APIs: 42.2.4 HAL_SDADC_Init() HAL_SDADC_DeInit() HAL_SDADC_MspInit() HAL_SDADC_MspDeInit() Peripheral control functions This section provides functions allowing to: Program one of the three different configurations for channels. Associate channel to one of configurations. DOCID026526 Rev 4 583/832 UM1786 Select regular and injected channels. Enable/disable continuous mode for regular and injected conversions. Select regular and injected triggers. Select and configure injected external trigger. Enable/disable delay addition for injected conversions. Configure multimode. This section contains the following APIs: 42.2.5 HAL_SDADC_PrepareChannelConfig() HAL_SDADC_AssociateChannelConfig() HAL_SDADC_ConfigChannel() HAL_SDADC_InjectedConfigChannel() HAL_SDADC_SelectRegularTrigger() HAL_SDADC_SelectInjectedTrigger() HAL_SDADC_SelectInjectedExtTrigger() HAL_SDADC_SelectInjectedDelay() HAL_SDADC_MultiModeConfigChannel() HAL_SDADC_InjectedMultiModeConfigChannel() IO operation functions This section provides functions allowing to: Start calibration. Poll for the end of calibration. Start calibration and enable interrupt. Start conversion of regular/injected channel. Poll for the end of regular/injected conversion. Stop conversion of regular/injected channel. Start conversion of regular/injected channel and enable interrupt. Stop conversion of regular/injected channel and disable interrupt. Start conversion of regular/injected channel and enable DMA transfer. Stop conversion of regular/injected channel and disable DMA transfer. Start multimode and enable DMA transfer for regular/injected conversion. Stop multimode and disable DMA transfer for regular/injected conversion.. Get result of regular channel conversion. Get result of injected channel conversion. Get result of multimode conversion. Handle SDADC interrupt request. Callbacks for calibration and regular/injected conversions. This section contains the following APIs: 584/832 HAL_SDADC_CalibrationStart() HAL_SDADC_PollForCalibEvent() HAL_SDADC_CalibrationStart_IT() HAL_SDADC_Start() HAL_SDADC_PollForConversion() HAL_SDADC_Stop() HAL_SDADC_Start_IT() HAL_SDADC_Stop_IT() HAL_SDADC_Start_DMA() HAL_SDADC_Stop_DMA() HAL_SDADC_GetValue() HAL_SDADC_InjectedStart() DOCID026526 Rev 4 UM1786 42.2.6 HAL_SDADC_PollForInjectedConversion() HAL_SDADC_InjectedStop() HAL_SDADC_InjectedStart_IT() HAL_SDADC_InjectedStop_IT() HAL_SDADC_InjectedStart_DMA() HAL_SDADC_InjectedStop_DMA() HAL_SDADC_InjectedGetValue() HAL_SDADC_MultiModeStart_DMA() HAL_SDADC_MultiModeStop_DMA() HAL_SDADC_MultiModeGetValue() HAL_SDADC_InjectedMultiModeStart_DMA() HAL_SDADC_InjectedMultiModeStop_DMA() HAL_SDADC_InjectedMultiModeGetValue() HAL_SDADC_IRQHandler() HAL_SDADC_CalibrationCpltCallback() HAL_SDADC_ConvHalfCpltCallback() HAL_SDADC_ConvCpltCallback() HAL_SDADC_InjectedConvHalfCpltCallback() HAL_SDADC_InjectedConvCpltCallback() HAL_SDADC_ErrorCallback() ADC Peripheral State functions This subsection provides functions allowing to Get the SDADC state Get the SDADC Error This section contains the following APIs: 42.2.7 HAL_SDADC_GetState() HAL_SDADC_GetError() Detailed description of functions HAL_SDADC_Init Function Name HAL_StatusTypeDef HAL_SDADC_Init (SDADC_HandleTypeDef * hsdadc) Function Description Initializes the SDADC according to the specified parameters in the SDADC_InitTypeDef structure. Parameters hsdadc: SDADC handle. Return values HAL: status. Notes If multiple SDADC are used, please configure first SDADC1 to set the common reference voltage. HAL_SDADC_DeInit Function Name HAL_StatusTypeDef HAL_SDADC_DeInit (SDADC_HandleTypeDef * hsdadc) Function Description De-initializes the SDADC. Parameters hsdadc: SDADC handle. DOCID026526 Rev 4 585/832 UM1786 Return values HAL: status. HAL_SDADC_MspInit Function Name void HAL_SDADC_MspInit (SDADC_HandleTypeDef * hsdadc) Function Description Initializes the SDADC MSP. Parameters hsdadc: SDADC handle Return values None: HAL_SDADC_MspDeInit Function Name void HAL_SDADC_MspDeInit (SDADC_HandleTypeDef * hsdadc) Function Description De-initializes the SDADC MSP. Parameters hsdadc: SDADC handle Return values None: HAL_SDADC_PrepareChannelConfig Function Name HAL_StatusTypeDef HAL_SDADC_PrepareChannelConfig (SDADC_HandleTypeDef * hsdadc, uint32_t ConfIndex, SDADC_ConfParamTypeDef * ConfParamStruct) Function Description This function allows the user to set parameters for a configuration. Parameters hsdadc: SDADC handle. ConfIndex: Index of configuration to modify. This parameter can be a value of SDADC Configuration Index. ConfParamStruct: Parameters to apply for this configuration. Return values HAL: status Notes This function should be called only when SDADC instance is in idle state (neither calibration nor regular or injected conversion ongoing) HAL_SDADC_AssociateChannelConfig Function Name HAL_StatusTypeDef HAL_SDADC_AssociateChannelConfig (SDADC_HandleTypeDef * hsdadc, uint32_t Channel, uint32_t ConfIndex) Function Description This function allows the user to associate a channel with one of the available configurations. Parameters Return values 586/832 hsdadc: SDADC handle. Channel: Channel to associate with configuration. This parameter can be a value of SDADC Channel Selection. ConfIndex: Index of configuration to associate with channel. This parameter can be a value of SDADC Configuration Index. HAL: status DOCID026526 Rev 4 UM1786 Notes This function should be called only when SDADC instance is in idle state (neither calibration nor regular or injected conversion ongoing) HAL_SDADC_ConfigChannel Function Name HAL_StatusTypeDef HAL_SDADC_ConfigChannel (SDADC_HandleTypeDef * hsdadc, uint32_t Channel, uint32_t ContinuousMode) Function Description This function allows to select channel for regular conversion and to enable/disable continuous mode for regular conversion. Parameters Return values hsdadc: SDADC handle. Channel: Channel for regular conversion. This parameter can be a value of SDADC Channel Selection. ContinuousMode: Enable/disable continuous mode for regular conversion. This parameter can be a value of SDADC Continuous Mode. HAL: status HAL_SDADC_InjectedConfigChannel Function Name HAL_StatusTypeDef HAL_SDADC_InjectedConfigChannel (SDADC_HandleTypeDef * hsdadc, uint32_t Channel, uint32_t ContinuousMode) Function Description This function allows to select channels for injected conversion and to enable/disable continuous mode for injected conversion. Parameters Return values hsdadc: SDADC handle. Channel: Channels for injected conversion. This parameter can be a values combination of SDADC Channel Selection. ContinuousMode: Enable/disable continuous mode for injected conversion. This parameter can be a value of SDADC Continuous Mode. HAL: status HAL_SDADC_SelectInjectedExtTrigger Function Name HAL_StatusTypeDef HAL_SDADC_SelectInjectedExtTrigger (SDADC_HandleTypeDef * hsdadc, uint32_t InjectedExtTrigger, uint32_t ExtTriggerEdge) Function Description This function allows to select and configure injected external trigger. Parameters Return values hsdadc: SDADC handle. InjectedExtTrigger: External trigger for injected conversions. This parameter can be a value of SDADC Injected External Trigger. ExtTriggerEdge: Edge of external injected trigger. This parameter can be a value of SDADC External Trigger Edge. HAL: status DOCID026526 Rev 4 587/832 UM1786 Notes This function should be called only when SDADC instance is in idle state (neither calibration nor regular or injected conversion ongoing) HAL_SDADC_SelectInjectedDelay Function Name HAL_StatusTypeDef HAL_SDADC_SelectInjectedDelay (SDADC_HandleTypeDef * hsdadc, uint32_t InjectedDelay) Function Description This function allows to enable/disable delay addition for injected conversions. Parameters hsdadc: SDADC handle. InjectedDelay: Enable/disable delay for injected conversions. This parameter can be a value of SDADC Injected Conversion Delay. Return values HAL: status Notes This function should be called only when SDADC instance is in idle state (neither calibration nor regular or injected conversion ongoing) HAL_SDADC_SelectRegularTrigger Function Name HAL_StatusTypeDef HAL_SDADC_SelectRegularTrigger (SDADC_HandleTypeDef * hsdadc, uint32_t Trigger) Function Description This function allows to select trigger for regular conversions. Parameters hsdadc: SDADC handle. Trigger: Trigger for regular conversions. This parameter can be one of the following value : SDADC_SOFTWARE_TRIGGER : Software trigger. SDADC_SYNCHRONOUS_TRIGGER : Synchronous with SDADC1 (only for SDADC2 and SDADC3). Return values HAL: status Notes This function should not be called if regular conversion is ongoing. HAL_SDADC_SelectInjectedTrigger 588/832 Function Name HAL_StatusTypeDef HAL_SDADC_SelectInjectedTrigger (SDADC_HandleTypeDef * hsdadc, uint32_t Trigger) Function Description This function allows to select trigger for injected conversions. Parameters hsdadc: SDADC handle. Trigger: Trigger for injected conversions. This parameter can be one of the following value : SDADC_SOFTWARE_TRIGGER : Software trigger. SDADC_SYNCHRONOUS_TRIGGER : Synchronous with SDADC1 (only for SDADC2 and SDADC3). SDADC_EXTERNAL_TRIGGER : External trigger. Return values HAL: status DOCID026526 Rev 4 UM1786 Notes This function should not be called if injected conversion is ongoing. HAL_SDADC_MultiModeConfigChannel Function Name HAL_StatusTypeDef HAL_SDADC_MultiModeConfigChannel (SDADC_HandleTypeDef * hsdadc, uint32_t MultimodeType) Function Description This function allows to configure multimode for regular conversions. Parameters hsdadc: SDADC handle. MultimodeType: Type of multimode for regular conversions. This parameter can be a value of SDADC Multimode Type. Return values HAL: status Notes This function should not be called if regular conversion is ongoing and should be could only for SDADC1. HAL_SDADC_InjectedMultiModeConfigChannel Function Name HAL_StatusTypeDef HAL_SDADC_InjectedMultiModeConfigChannel (SDADC_HandleTypeDef * hsdadc, uint32_t MultimodeType) Function Description This function allows to configure multimode for injected conversions. Parameters hsdadc: SDADC handle. MultimodeType: Type of multimode for injected conversions. This parameter can be a value of SDADC Multimode Type. Return values HAL: status Notes This function should not be called if injected conversion is ongoing and should be could only for SDADC1. HAL_SDADC_CalibrationStart Function Name HAL_StatusTypeDef HAL_SDADC_CalibrationStart (SDADC_HandleTypeDef * hsdadc, uint32_t CalibrationSequence) Function Description This function allows to start calibration in polling mode. Parameters hsdadc: SDADC handle. CalibrationSequence: Calibration sequence. This parameter can be a value of SDADC Calibration Sequence. Return values HAL: status Notes This function should be called only when SDADC instance is in idle state (neither calibration nor regular or injected conversion ongoing). DOCID026526 Rev 4 589/832 UM1786 HAL_SDADC_CalibrationStart_IT Function Name HAL_StatusTypeDef HAL_SDADC_CalibrationStart_IT (SDADC_HandleTypeDef * hsdadc, uint32_t CalibrationSequence) Function Description This function allows to start calibration in interrupt mode. Parameters hsdadc: SDADC handle. CalibrationSequence: Calibration sequence. This parameter can be a value of SDADC Calibration Sequence. Return values HAL: status Notes This function should be called only when SDADC instance is in idle state (neither calibration nor regular or injected conversion ongoing). HAL_SDADC_Start Function Name HAL_StatusTypeDef HAL_SDADC_Start (SDADC_HandleTypeDef * hsdadc) Function Description This function allows to start regular conversion in polling mode. Parameters hsdadc: SDADC handle. Return values HAL: status Notes This function should be called only when SDADC instance is in idle state or if injected conversion is ongoing. HAL_SDADC_Start_IT Function Name HAL_StatusTypeDef HAL_SDADC_Start_IT (SDADC_HandleTypeDef * hsdadc) Function Description This function allows to start regular conversion in interrupt mode. Parameters hsdadc: SDADC handle. Return values HAL: status Notes This function should be called only when SDADC instance is in idle state or if injected conversion is ongoing. HAL_SDADC_Start_DMA 590/832 Function Name HAL_StatusTypeDef HAL_SDADC_Start_DMA (SDADC_HandleTypeDef * hsdadc, uint32_t * pData, uint32_t Length) Function Description This function allows to start regular conversion in DMA mode. Parameters hsdadc: SDADC handle. pData: The destination buffer address. Length: The length of data to be transferred from SDADC peripheral to memory. Return values HAL: status Notes This function should be called only when SDADC instance is DOCID026526 Rev 4 UM1786 in idle state or if injected conversion is ongoing. HAL_SDADC_Stop Function Name HAL_StatusTypeDef HAL_SDADC_Stop (SDADC_HandleTypeDef * hsdadc) Function Description This function allows to stop regular conversion in polling mode. Parameters hsdadc: SDADC handle. Return values HAL: status Notes This function should be called only if regular conversion is ongoing. HAL_SDADC_Stop_IT Function Name HAL_StatusTypeDef HAL_SDADC_Stop_IT (SDADC_HandleTypeDef * hsdadc) Function Description This function allows to stop regular conversion in interrupt mode. Parameters hsdadc: SDADC handle. Return values HAL: status Notes This function should be called only if regular conversion is ongoing. HAL_SDADC_Stop_DMA Function Name HAL_StatusTypeDef HAL_SDADC_Stop_DMA (SDADC_HandleTypeDef * hsdadc) Function Description This function allows to stop regular conversion in DMA mode. Parameters hsdadc: SDADC handle. Return values HAL: status Notes This function should be called only if regular conversion is ongoing. HAL_SDADC_InjectedStart Function Name HAL_StatusTypeDef HAL_SDADC_InjectedStart (SDADC_HandleTypeDef * hsdadc) Function Description This function allows to start injected conversion in polling mode. Parameters hsdadc: SDADC handle. Return values HAL: status Notes This function should be called only when SDADC instance is in idle state or if regular conversion is ongoing. HAL_SDADC_InjectedStart_IT Function Name HAL_StatusTypeDef HAL_SDADC_InjectedStart_IT DOCID026526 Rev 4 591/832 UM1786 (SDADC_HandleTypeDef * hsdadc) Function Description This function allows to start injected conversion in interrupt mode. Parameters hsdadc: SDADC handle. Return values HAL: status Notes This function should be called only when SDADC instance is in idle state or if regular conversion is ongoing. HAL_SDADC_InjectedStart_DMA Function Name HAL_StatusTypeDef HAL_SDADC_InjectedStart_DMA (SDADC_HandleTypeDef * hsdadc, uint32_t * pData, uint32_t Length) Function Description This function allows to start injected conversion in DMA mode. Parameters hsdadc: SDADC handle. pData: The destination buffer address. Length: The length of data to be transferred from SDADC peripheral to memory. Return values HAL: status Notes This function should be called only when SDADC instance is in idle state or if regular conversion is ongoing. HAL_SDADC_InjectedStop Function Name HAL_StatusTypeDef HAL_SDADC_InjectedStop (SDADC_HandleTypeDef * hsdadc) Function Description This function allows to stop injected conversion in polling mode. Parameters hsdadc: SDADC handle. Return values HAL: status Notes This function should be called only if injected conversion is ongoing. HAL_SDADC_InjectedStop_IT Function Name HAL_StatusTypeDef HAL_SDADC_InjectedStop_IT (SDADC_HandleTypeDef * hsdadc) Function Description This function allows to stop injected conversion in interrupt mode. Parameters hsdadc: SDADC handle. Return values HAL: status Notes This function should be called only if injected conversion is ongoing. HAL_SDADC_InjectedStop_DMA Function Name 592/832 HAL_StatusTypeDef HAL_SDADC_InjectedStop_DMA (SDADC_HandleTypeDef * hsdadc) DOCID026526 Rev 4 UM1786 Function Description This function allows to stop injected conversion in DMA mode. Parameters hsdadc: SDADC handle. Return values HAL: status Notes This function should be called only if injected conversion is ongoing. HAL_SDADC_MultiModeStart_DMA Function Name HAL_StatusTypeDef HAL_SDADC_MultiModeStart_DMA (SDADC_HandleTypeDef * hsdadc, uint32_t * pData, uint32_t Length) Function Description This function allows to start multimode regular conversions in DMA mode. Parameters hsdadc: SDADC handle. pData: The destination buffer address. Length: The length of data to be transferred from SDADC peripheral to memory. Return values HAL: status Notes This function should be called only when SDADC instance is in idle state or if injected conversion is ongoing. HAL_SDADC_MultiModeStop_DMA Function Name HAL_StatusTypeDef HAL_SDADC_MultiModeStop_DMA (SDADC_HandleTypeDef * hsdadc) Function Description This function allows to stop multimode regular conversions in DMA mode. Parameters hsdadc: SDADC handle. Return values HAL: status Notes This function should be called only if regular conversion is ongoing. HAL_SDADC_InjectedMultiModeStart_DMA Function Name HAL_StatusTypeDef HAL_SDADC_InjectedMultiModeStart_DMA (SDADC_HandleTypeDef * hsdadc, uint32_t * pData, uint32_t Length) Function Description This function allows to start multimode injected conversions in DMA mode. Parameters hsdadc: SDADC handle. pData: The destination buffer address. Length: The length of data to be transferred from SDADC peripheral to memory. Return values HAL: status Notes This function should be called only when SDADC instance is DOCID026526 Rev 4 593/832 UM1786 in idle state or if regular conversion is ongoing. HAL_SDADC_InjectedMultiModeStop_DMA Function Name HAL_StatusTypeDef HAL_SDADC_InjectedMultiModeStop_DMA (SDADC_HandleTypeDef * hsdadc) Function Description This function allows to stop multimode injected conversions in DMA mode. Parameters hsdadc: SDADC handle. Return values HAL: status Notes This function should be called only if injected conversion is ongoing. HAL_SDADC_GetValue Function Name uint32_t HAL_SDADC_GetValue (SDADC_HandleTypeDef * hsdadc) Function Description This function allows to get regular conversion value. Parameters hsdadc: SDADC handle. Return values Regular: conversion value HAL_SDADC_InjectedGetValue Function Name uint32_t HAL_SDADC_InjectedGetValue (SDADC_HandleTypeDef * hsdadc, uint32_t * Channel) Function Description This function allows to get injected conversion value. Parameters hsdadc: SDADC handle. Channel: Corresponding channel of injected conversion. Return values Injected: conversion value HAL_SDADC_MultiModeGetValue Function Name uint32_t HAL_SDADC_MultiModeGetValue (SDADC_HandleTypeDef * hsdadc) Function Description This function allows to get multimode regular conversion value. Parameters hsdadc: SDADC handle. Return values Multimode: regular conversion value HAL_SDADC_InjectedMultiModeGetValue 594/832 Function Name uint32_t HAL_SDADC_InjectedMultiModeGetValue (SDADC_HandleTypeDef * hsdadc) Function Description This function allows to get multimode injected conversion value. Parameters hsdadc: SDADC handle. DOCID026526 Rev 4 UM1786 Return values Multimode: injected conversion value HAL_SDADC_IRQHandler Function Name void HAL_SDADC_IRQHandler (SDADC_HandleTypeDef * hsdadc) Function Description This function handles the SDADC interrupts. Parameters hsdadc: SDADC handle. Return values None: HAL_SDADC_PollForCalibEvent Function Name HAL_StatusTypeDef HAL_SDADC_PollForCalibEvent (SDADC_HandleTypeDef * hsdadc, uint32_t Timeout) Function Description This function allows to poll for the end of calibration. Parameters hsdadc: SDADC handle. Timeout: Timeout value in milliseconds. Return values HAL: status Notes This function should be called only if calibration is ongoing. HAL_SDADC_PollForConversion Function Name HAL_StatusTypeDef HAL_SDADC_PollForConversion (SDADC_HandleTypeDef * hsdadc, uint32_t Timeout) Function Description This function allows to poll for the end of regular conversion. Parameters hsdadc: SDADC handle. Timeout: Timeout value in milliseconds. Return values HAL: status Notes This function should be called only if regular conversion is ongoing. HAL_SDADC_PollForInjectedConversion Function Name HAL_StatusTypeDef HAL_SDADC_PollForInjectedConversion (SDADC_HandleTypeDef * hsdadc, uint32_t Timeout) Function Description This function allows to poll for the end of injected conversion. Parameters hsdadc: SDADC handle. Timeout: Timeout value in milliseconds. Return values HAL: status Notes This function should be called only if injected conversion is ongoing. HAL_SDADC_CalibrationCpltCallback Function Name void HAL_SDADC_CalibrationCpltCallback DOCID026526 Rev 4 595/832 UM1786 (SDADC_HandleTypeDef * hsdadc) Function Description Calibration complete callback. Parameters hsdadc: SDADC handle. Return values None: HAL_SDADC_ConvHalfCpltCallback Function Name void HAL_SDADC_ConvHalfCpltCallback (SDADC_HandleTypeDef * hsdadc) Function Description Half regular conversion complete callback. Parameters hsdadc: SDADC handle. Return values None: HAL_SDADC_ConvCpltCallback Function Name void HAL_SDADC_ConvCpltCallback (SDADC_HandleTypeDef * hsdadc) Function Description Regular conversion complete callback. Parameters hsdadc: SDADC handle. Return values None: Notes In interrupt mode, user has to read conversion value in this function using HAL_SDADC_GetValue or HAL_SDADC_MultiModeGetValue. HAL_SDADC_InjectedConvHalfCpltCallback Function Name void HAL_SDADC_InjectedConvHalfCpltCallback (SDADC_HandleTypeDef * hsdadc) Function Description Half injected conversion complete callback. Parameters hsdadc: SDADC handle. Return values None: HAL_SDADC_InjectedConvCpltCallback 596/832 Function Name void HAL_SDADC_InjectedConvCpltCallback (SDADC_HandleTypeDef * hsdadc) Function Description Injected conversion complete callback. Parameters hsdadc: SDADC handle. Return values None: Notes In interrupt mode, user has to read conversion value in this function using HAL_SDADC_InjectedGetValue or HAL_SDADC_InjectedMultiModeGetValue. DOCID026526 Rev 4 UM1786 HAL_SDADC_ErrorCallback Function Name void HAL_SDADC_ErrorCallback (SDADC_HandleTypeDef * hsdadc) Function Description Error callback. Parameters hsdadc: SDADC handle. Return values None: HAL_SDADC_GetState Function Name HAL_SDADC_StateTypeDef HAL_SDADC_GetState (SDADC_HandleTypeDef * hsdadc) Function Description This function allows to get the current SDADC state. Parameters hsdadc: SDADC handle. Return values SDADC: state. HAL_SDADC_GetError Function Name uint32_t HAL_SDADC_GetError (SDADC_HandleTypeDef * hsdadc) Function Description This function allows to get the current SDADC error code. Parameters hsdadc: SDADC handle. Return values SDADC: error code. 42.3 SDADC Firmware driver defines 42.3.1 SDADC SDADC Calibration Sequence SDADC_CALIBRATION_SEQ_1 One calibration sequence to calculate offset of conf0 (OFFSET0[11:0]) SDADC_CALIBRATION_SEQ_2 Two calibration sequences to calculate offset of conf0 and conf1 (OFFSET0[11:0] and OFFSET1[11:0]) SDADC_CALIBRATION_SEQ_3 Three calibration sequences to calculate offset of conf0, conf1 and conf2 (OFFSET0[11:0], OFFSET1[11:0], and OFFSET2[11:0]) SDADC Channel Selection SDADC_CHANNEL_0 SDADC_CHANNEL_1 SDADC_CHANNEL_2 SDADC_CHANNEL_3 SDADC_CHANNEL_4 SDADC_CHANNEL_5 SDADC_CHANNEL_6 DOCID026526 Rev 4 597/832 UM1786 SDADC_CHANNEL_7 SDADC_CHANNEL_8 SDADC Common Mode SDADC_COMMON_MODE_VSSA Select SDADC VSSA as common mode SDADC_COMMON_MODE_VDDA_2 Select SDADC VDDA/2 as common mode SDADC_COMMON_MODE_VDDA Select SDADC VDDA as common mode SDADC Configuration Index SDADC_CONF_INDEX_0 Configuration 0 Register selected SDADC_CONF_INDEX_1 Configuration 1 Register selected SDADC_CONF_INDEX_2 Configuration 2 Register selected SDADC Continuous Mode SDADC_CONTINUOUS_CONV_OFF Conversion are not continuous SDADC_CONTINUOUS_CONV_ON Conversion are continuous SDADC Error Code SDADC_ERROR_NONE No error SDADC_ERROR_REGULAR_OVERRUN Overrun occurs during regular conversion SDADC_ERROR_INJECTED_OVERRUN Overrun occurs during injected conversion SDADC_ERROR_DMA DMA error occurs SDADC Exported Macros __HAL_SDADC_ENABLE_IT Description: Enable the ADC end of conversion interrupt. Parameters: __HANDLE__: ADC handle __INTERRUPT__: ADC Interrupt This parameter can be any combination of the following values: SDADC_IT_EOCAL: End of calibration interrupt enable SDADC_IT_JEOC: Injected end of conversion interrupt enable SDADC_IT_JOVR: Injected data overrun interrupt enable SDADC_IT_REOC: Regular end of conversion interrupt enable SDADC_IT_ROVR: Regular data overrun interrupt enable Return value: __HAL_SDADC_DISABLE_IT Description: 598/832 None DOCID026526 Rev 4 Disable the ADC end of conversion UM1786 interrupt. Parameters: __HANDLE__: ADC handle __INTERRUPT__: ADC Interrupt This parameter can be any combination of the following values: SDADC_IT_EOCAL: End of calibration interrupt enable SDADC_IT_JEOC: Injected end of conversion interrupt enable SDADC_IT_JOVR: Injected data overrun interrupt enable SDADC_IT_REOC: Regular end of conversion interrupt enable SDADC_IT_ROVR: Regular data overrun interrupt enable Return value: __HAL_SDADC_GET_IT_SOURCE None Description: Checks if the specified ADC interrupt source is enabled or disabled. Parameters: __HANDLE__: ADC handle __INTERRUPT__: ADC interrupt source to check This parameter can be any combination of the following values: SDADC_IT_EOCAL: End of calibration interrupt enable SDADC_IT_JEOC: Injected end of conversion interrupt enable SDADC_IT_JOVR: Injected data overrun interrupt enable SDADC_IT_REOC: Regular end of conversion interrupt enable SDADC_IT_ROVR: Regular data overrun interrupt enable Return value: __HAL_SDADC_GET_FLAG State: of interruption (SET or RESET) Description: Get the selected ADC's flag status. Parameters: DOCID026526 Rev 4 __HANDLE__: ADC handle __FLAG__: ADC flag This parameter can be any combination of the following values: SDADC_FLAG_EOCAL: End of calibration flag 599/832 UM1786 SDADC_FLAG_JEOC: End of injected conversion flag SDADC_FLAG_JOVR: Injected conversion overrun flag SDADC_FLAG_REOC: End of regular conversion flag SDADC_FLAG_ROVR: Regular conversion overrun flag Return value: None Description: __HAL_SDADC_CLEAR_FLAG Clear the ADC's pending flags. Parameters: __HANDLE__: ADC handle __FLAG__: ADC flag This parameter can be any combination of the following values: SDADC_FLAG_EOCAL: End of calibration flag SDADC_FLAG_JEOC: End of injected conversion flag SDADC_FLAG_JOVR: Injected conversion overrun flag SDADC_FLAG_REOC: End of regular conversion flag SDADC_FLAG_ROVR: Regular conversion overrun flag Return value: __HAL_SDADC_RESET_HANDLE_STATE None Description: Reset SDADC handle state. Parameters: __HANDLE__: SDADC handle. Return value: None SDADC External Trigger Edge SDADC_EXT_TRIG_RISING_EDGE External rising edge SDADC_EXT_TRIG_FALLING_EDGE External falling edge SDADC_EXT_TRIG_BOTH_EDGES External rising and falling edges SDADC Fast Conversion Mode SDADC_FAST_CONV_DISABLE SDADC_FAST_CONV_ENABLE SDADC flags definition 600/832 DOCID026526 Rev 4 UM1786 SDADC_FLAG_EOCAL End of calibration flag SDADC_FLAG_JEOC End of injected conversion flag SDADC_FLAG_JOVR Injected conversion overrun flag SDADC_FLAG_REOC End of regular conversion flag SDADC_FLAG_ROVR Regular conversion overrun flag SDADC Gain SDADC_GAIN_1 Gain equal to 1 SDADC_GAIN_2 Gain equal to 2 SDADC_GAIN_4 Gain equal to 4 SDADC_GAIN_8 Gain equal to 8 SDADC_GAIN_16 Gain equal to 16 SDADC_GAIN_32 Gain equal to 32 SDADC_GAIN_1_2 Gain equal to 1/2 SDADC Idle Low Power Mode SDADC_LOWPOWER_NONE SDADC_LOWPOWER_POWERDOWN SDADC_LOWPOWER_STANDBY SDADC Injected Conversion Delay SDADC_INJECTED_DELAY_NONE No delay on injected conversion SDADC_INJECTED_DELAY Delay on injected conversion SDADC Injected External Trigger SDADC_EXT_TRIG_TIM13_CC1 Trigger source for SDADC1 SDADC_EXT_TRIG_TIM14_CC1 Trigger source for SDADC1 SDADC_EXT_TRIG_TIM16_CC1 Trigger source for SDADC3 SDADC_EXT_TRIG_TIM17_CC1 Trigger source for SDADC2 SDADC_EXT_TRIG_TIM12_CC1 Trigger source for SDADC2 SDADC_EXT_TRIG_TIM12_CC2 Trigger source for SDADC3 SDADC_EXT_TRIG_TIM15_CC2 Trigger source for SDADC1 SDADC_EXT_TRIG_TIM2_CC3 Trigger source for SDADC2 SDADC_EXT_TRIG_TIM2_CC4 Trigger source for SDADC3 SDADC_EXT_TRIG_TIM3_CC1 Trigger source for SDADC1 SDADC_EXT_TRIG_TIM3_CC2 Trigger source for SDADC2 SDADC_EXT_TRIG_TIM3_CC3 Trigger source for SDADC3 SDADC_EXT_TRIG_TIM4_CC1 Trigger source for SDADC1 SDADC_EXT_TRIG_TIM4_CC2 Trigger source for SDADC2 SDADC_EXT_TRIG_TIM4_CC3 Trigger source for SDADC3 DOCID026526 Rev 4 601/832 UM1786 SDADC_EXT_TRIG_TIM19_CC2 Trigger source for SDADC1 SDADC_EXT_TRIG_TIM19_CC3 Trigger source for SDADC2 SDADC_EXT_TRIG_TIM19_CC4 Trigger source for SDADC3 SDADC_EXT_TRIG_EXTI11 Trigger source for SDADC1, SDADC2 and SDADC3 SDADC_EXT_TRIG_EXTI15 Trigger source for SDADC1, SDADC2 and SDADC3 SDADC Input Mode SDADC_INPUT_MODE_DIFF Conversions are executed in differential mode SDADC_INPUT_MODE_SE_OFFSET Conversions are executed in single ended offset mode SDADC_INPUT_MODE_SE_ZERO_REFERENCE Conversions are executed in single ended zero-volt reference mode SDADC interrupts definition SDADC_IT_EOCAL End of calibration interrupt enable SDADC_IT_JEOC Injected end of conversion interrupt enable SDADC_IT_JOVR Injected data overrun interrupt enable SDADC_IT_REOC Regular end of conversion interrupt enable SDADC_IT_ROVR Regular data overrun interrupt enable SDADC Multimode Type SDADC_MULTIMODE_SDADC1_SDADC2 Get conversion values for SDADC1 and SDADC2 SDADC_MULTIMODE_SDADC1_SDADC3 Get conversion values for SDADC1 and SDADC3 SDADC Reference Voltage SDADC_VREF_EXT The reference voltage is forced externally using VREF pin SDADC_VREF_VREFINT1 The reference voltage is forced internally to 1.22V VREFINT SDADC_VREF_VREFINT2 The reference voltage is forced internally to 1.8V VREFINT SDADC_VREF_VDDA The reference voltage is forced internally to VDDA SDADC Slow Clock Mode SDADC_SLOW_CLOCK_DISABLE SDADC_SLOW_CLOCK_ENABLE SDADC Trigger 602/832 SDADC_SOFTWARE_TRIGGER Software trigger SDADC_SYNCHRONOUS_TRIGGER Synchronous with SDADC1 (only for SDADC2 and SDADC3) SDADC_EXTERNAL_TRIGGER External trigger DOCID026526 Rev 4 UM1786 43 HAL SMARTCARD Generic Driver 43.1 SMARTCARD Firmware driver registers structures 43.1.1 SMARTCARD_InitTypeDef Data Fields uint32_t BaudRate uint32_t WordLength uint32_t StopBits uint16_t Parity uint16_t Mode uint16_t CLKPolarity uint16_t CLKPhase uint16_t CLKLastBit uint16_t OneBitSampling uint8_t Prescaler uint8_t GuardTime uint16_t NACKEnable uint32_t TimeOutEnable uint32_t TimeOutValue uint8_t BlockLength uint8_t AutoRetryCount Field Documentation uint32_t SMARTCARD_InitTypeDef::BaudRate Configures the SmartCard communication baud rate. The baud rate register is computed using the following formula: Baud Rate Register = ((PCLKx) / ((hsmartcard>Init.BaudRate))) uint32_t SMARTCARD_InitTypeDef::WordLength Specifies the number of data bits transmitted or received in a frame. This parameter SMARTCARD_Word_Length can only be set to 9 (8 data + 1 parity bits). uint32_t SMARTCARD_InitTypeDef::StopBits Specifies the number of stop bits SMARTCARD_Stop_Bits. Only 1.5 stop bits are authorized in SmartCard mode. uint16_t SMARTCARD_InitTypeDef::Parity Specifies the parity mode. This parameter can be a value of SMARTCARD_Parity Note:The parity is enabled by default (PCE is forced to 1). Since the WordLength is forced to 8 bits + parity, M is forced to 1 and the parity bit is the 9th bit. uint16_t SMARTCARD_InitTypeDef::Mode Specifies whether the Receive or Transmit mode is enabled or disabled. This parameter can be a value of SMARTCARD_Mode uint16_t SMARTCARD_InitTypeDef::CLKPolarity Specifies the steady state of the serial clock. This parameter can be a value of SMARTCARD_Clock_Polarity uint16_t SMARTCARD_InitTypeDef::CLKPhase Specifies the clock transition on which the bit capture is made. This parameter can be a value of SMARTCARD_Clock_Phase DOCID026526 Rev 4 603/832 UM1786 43.1.2 uint16_t SMARTCARD_InitTypeDef::CLKLastBit Specifies whether the clock pulse corresponding to the last transmitted data bit (MSB) has to be output on the SCLK pin in synchronous mode. This parameter can be a value of SMARTCARD_Last_Bit uint16_t SMARTCARD_InitTypeDef::OneBitSampling Specifies whether a single sample or three samples' majority vote is selected. Selecting the single sample method increases the receiver tolerance to clock deviations. This parameter can be a value of SMARTCARD_OneBit_Sampling. uint8_t SMARTCARD_InitTypeDef::Prescaler Specifies the SmartCard Prescaler uint8_t SMARTCARD_InitTypeDef::GuardTime Specifies the SmartCard Guard Time uint16_t SMARTCARD_InitTypeDef::NACKEnable Specifies whether the SmartCard NACK transmission is enabled in case of parity error. This parameter can be a value of SMARTCARD_NACK_Enable uint32_t SMARTCARD_InitTypeDef::TimeOutEnable Specifies whether the receiver timeout is enabled. This parameter can be a value of SMARTCARD_Timeout_Enable uint32_t SMARTCARD_InitTypeDef::TimeOutValue Specifies the receiver time out value in number of baud blocks: it is used to implement the Character Wait Time (CWT) and Block Wait Time (BWT). It is coded over 24 bits. uint8_t SMARTCARD_InitTypeDef::BlockLength Specifies the SmartCard Block Length in T=1 Reception mode. This parameter can be any value from 0x0 to 0xFF uint8_t SMARTCARD_InitTypeDef::AutoRetryCount Specifies the SmartCard auto-retry count (number of retries in receive and transmit mode). When set to 0, retransmission is disabled. Otherwise, its maximum value is 7 (before signalling an error) SMARTCARD_AdvFeatureInitTypeDef Data Fields uint32_t AdvFeatureInit uint32_t TxPinLevelInvert uint32_t RxPinLevelInvert uint32_t DataInvert uint32_t Swap uint32_t OverrunDisable uint32_t DMADisableonRxError uint32_t MSBFirst Field Documentation 604/832 uint32_t SMARTCARD_AdvFeatureInitTypeDef::AdvFeatureInit Specifies which advanced SMARTCARD features is initialized. Several advanced features may be initialized at the same time. This parameter can be a value of SMARTCARD_Advanced_Features_Initialization_Type uint32_t SMARTCARD_AdvFeatureInitTypeDef::TxPinLevelInvert Specifies whether the TX pin active level is inverted. This parameter can be a value of SMARTCARD_Tx_Inv DOCID026526 Rev 4 UM1786 43.1.3 uint32_t SMARTCARD_AdvFeatureInitTypeDef::RxPinLevelInvert Specifies whether the RX pin active level is inverted. This parameter can be a value of SMARTCARD_Rx_Inv uint32_t SMARTCARD_AdvFeatureInitTypeDef::DataInvert Specifies whether data are inverted (positive/direct logic vs negative/inverted logic). This parameter can be a value of SMARTCARD_Data_Inv uint32_t SMARTCARD_AdvFeatureInitTypeDef::Swap Specifies whether TX and RX pins are swapped. This parameter can be a value of SMARTCARD_Rx_Tx_Swap uint32_t SMARTCARD_AdvFeatureInitTypeDef::OverrunDisable Specifies whether the reception overrun detection is disabled. This parameter can be a value of SMARTCARD_Overrun_Disable uint32_t SMARTCARD_AdvFeatureInitTypeDef::DMADisableonRxError Specifies whether the DMA is disabled in case of reception error. This parameter can be a value of SMARTCARD_DMA_Disable_on_Rx_Error uint32_t SMARTCARD_AdvFeatureInitTypeDef::MSBFirst Specifies whether MSB is sent first on UART line. This parameter can be a value of SMARTCARD_MSB_First SMARTCARD_HandleTypeDef Data Fields USART_TypeDef * Instance SMARTCARD_InitTypeDef Init SMARTCARD_AdvFeatureInitTypeDef AdvancedInit uint8_t * pTxBuffPtr uint16_t TxXferSize uint16_t TxXferCount uint8_t * pRxBuffPtr uint16_t RxXferSize uint16_t RxXferCount DMA_HandleTypeDef * hdmatx DMA_HandleTypeDef * hdmarx HAL_LockTypeDef Lock __IO HAL_SMARTCARD_StateTypeDef gState __IO HAL_SMARTCARD_StateTypeDef RxState __IO uint32_t ErrorCode Field Documentation USART_TypeDef* SMARTCARD_HandleTypeDef::Instance USART registers base address SMARTCARD_InitTypeDef SMARTCARD_HandleTypeDef::Init SmartCard communication parameters SMARTCARD_AdvFeatureInitTypeDef SMARTCARD_HandleTypeDef::AdvancedInit SmartCard advanced features initialization parameters uint8_t* SMARTCARD_HandleTypeDef::pTxBuffPtr Pointer to SmartCard Tx transfer Buffer DOCID026526 Rev 4 605/832 UM1786 uint16_t SMARTCARD_HandleTypeDef::TxXferSize SmartCard Tx Transfer size uint16_t SMARTCARD_HandleTypeDef::TxXferCount SmartCard Tx Transfer Counter uint8_t* SMARTCARD_HandleTypeDef::pRxBuffPtr Pointer to SmartCard Rx transfer Buffer uint16_t SMARTCARD_HandleTypeDef::RxXferSize SmartCard Rx Transfer size uint16_t SMARTCARD_HandleTypeDef::RxXferCount SmartCard Rx Transfer Counter DMA_HandleTypeDef* SMARTCARD_HandleTypeDef::hdmatx SmartCard Tx DMA Handle parameters DMA_HandleTypeDef* SMARTCARD_HandleTypeDef::hdmarx SmartCard Rx DMA Handle parameters HAL_LockTypeDef SMARTCARD_HandleTypeDef::Lock Locking object __IO HAL_SMARTCARD_StateTypeDef SMARTCARD_HandleTypeDef::gState SmartCard state information related to global Handle management and also related to Tx operations. This parameter can be a value of HAL_SMARTCARD_StateTypeDef __IO HAL_SMARTCARD_StateTypeDef SMARTCARD_HandleTypeDef::RxState SmartCard state information related to Rx operations. This parameter can be a value of HAL_SMARTCARD_StateTypeDef __IO uint32_t SMARTCARD_HandleTypeDef::ErrorCode SmartCard Error code This parameter can be a value of SMARTCARD_Error 43.2 SMARTCARD Firmware driver API description 43.2.1 How to use this driver The SMARTCARD HAL driver can be used as follows: 1. 2. 3. 606/832 Declare a SMARTCARD_HandleTypeDef handle structure (eg. SMARTCARD_HandleTypeDef hsmartcard). Associate a USART to the SMARTCARD handle hsmartcard. Initialize the SMARTCARD low level resources by implementing the HAL_SMARTCARD_MspInit() API: Enable the USARTx interface clock. USART pins configuration: Enable the clock for the USART GPIOs. Configure the USART pins (TX as alternate function pull-up, RX as alternate function Input). NVIC configuration if you need to use interrupt process (HAL_SMARTCARD_Transmit_IT() and HAL_SMARTCARD_Receive_IT() APIs): Configure the USARTx interrupt priority. Enable the NVIC USART IRQ handle. DMA Configuration if you need to use DMA process (HAL_SMARTCARD_Transmit_DMA() and HAL_SMARTCARD_Receive_DMA() APIs): Declare a DMA handle structure for the Tx/Rx channel. Enable the DMAx interface clock. Configure the declared DMA handle structure with the required Tx/Rx parameters. Configure the DMA Tx/Rx channel. DOCID026526 Rev 4 UM1786 4. 5. 6. Associate the initialized DMA handle to the SMARTCARD DMA Tx/Rx handle. Configure the priority and enable the NVIC for the transfer complete interrupt on the DMA Tx/Rx channel. Program the Baud Rate, Parity, Mode(Receiver/Transmitter), clock enabling/disabling and accordingly, the clock parameters (parity, phase, last bit), prescaler value, guard time and NACK on transmission error enabling or disabling in the hsmartcard handle Init structure. If required, program SMARTCARD advanced features (TX/RX pins swap, TimeOut, auto-retry counter,...) in the hsmartcard handle AdvancedInit structure. Initialize the SMARTCARD registers by calling the HAL_SMARTCARD_Init() API: This API configures also the low level Hardware (GPIO, CLOCK, CORTEX...etc) by calling the customized HAL_SMARTCARD_MspInit() API. The specific SMARTCARD interrupts (Transmission complete interrupt, RXNE interrupt and Error Interrupts) will be managed using the macros __HAL_SMARTCARD_ENABLE_IT() and __HAL_SMARTCARD_DISABLE_IT() inside the transmit and receive process. Three operation modes are available within this driver : Polling mode IO operation Send an amount of data in blocking mode using HAL_SMARTCARD_Transmit() Receive an amount of data in blocking mode using HAL_SMARTCARD_Receive() Interrupt mode IO operation Send an amount of data in non-blocking mode using HAL_SMARTCARD_Transmit_IT() At transmission end of transfer HAL_SMARTCARD_TxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_SMARTCARD_TxCpltCallback() Receive an amount of data in non-blocking mode using HAL_SMARTCARD_Receive_IT() At reception end of transfer HAL_SMARTCARD_RxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_SMARTCARD_RxCpltCallback() In case of transfer Error, HAL_SMARTCARD_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_SMARTCARD_ErrorCallback() DMA mode IO operation Send an amount of data in non-blocking mode (DMA) using HAL_SMARTCARD_Transmit_DMA() At transmission end of transfer HAL_SMARTCARD_TxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_SMARTCARD_TxCpltCallback() DOCID026526 Rev 4 607/832 UM1786 Receive an amount of data in non-blocking mode (DMA) using HAL_SMARTCARD_Receive_DMA() At reception end of transfer HAL_SMARTCARD_RxCpltCallback() is executed and user can add his own code by customization of function pointer HAL_SMARTCARD_RxCpltCallback() In case of transfer Error, HAL_SMARTCARD_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_SMARTCARD_ErrorCallback() SMARTCARD HAL driver macros list Below the list of most used macros in SMARTCARD HAL driver. __HAL_SMARTCARD_ENABLE: Enable the SMARTCARD peripheral __HAL_SMARTCARD_DISABLE: Disable the SMARTCARD peripheral __HAL_SMARTCARD_GET_FLAG : Check whether or not the specified SMARTCARD flag is set __HAL_SMARTCARD_CLEAR_FLAG : Clear the specified SMARTCARD pending flag __HAL_SMARTCARD_ENABLE_IT: Enable the specified SMARTCARD interrupt __HAL_SMARTCARD_DISABLE_IT: Disable the specified SMARTCARD interrupt __HAL_SMARTCARD_GET_IT_SOURCE: Check whether or not the specified SMARTCARD interrupt is enabled You can refer to the SMARTCARD HAL driver header file for more useful macros 43.2.2 Initialization and Configuration functions This subsection provides a set of functions allowing to initialize the USARTx associated to the SmartCard. The Smartcard interface is designed to support asynchronous protocol Smartcards as defined in the ISO 7816-3 standard. The USART can provide a clock to the smartcard through the SCLK output. In smartcard mode, SCLK is not associated to the communication but is simply derived from the internal peripheral input clock through a 5-bit prescaler. 608/832 These parameters can be configured: Baud Rate Parity: should be enabled Receiver/transmitter modes Synchronous mode (and if enabled, phase, polarity and last bit parameters) Prescaler value Guard bit time NACK enabling or disabling on transmission error The following advanced features can be configured as well: TX and/or RX pin level inversion data logical level inversion RX and TX pins swap RX overrun detection disabling DMA disabling on RX error DOCID026526 Rev 4 UM1786 MSB first on communication line Time out enabling (and if activated, timeout value) Block length Auto-retry counter The HAL_SMARTCARD_Init() API follows the USART synchronous configuration procedures (details for the procedures are available in reference manual). This section contains the following APIs: 43.2.3 HAL_SMARTCARD_Init() HAL_SMARTCARD_DeInit() HAL_SMARTCARD_MspInit() HAL_SMARTCARD_MspDeInit() IO operation functions This subsection provides a set of functions allowing to manage the SMARTCARD data transfers. Smartcard is a single wire half duplex communication protocol. The Smartcard interface is designed to support asynchronous protocol Smartcards as defined in the ISO 7816-3 standard. The USART should be configured as: 8 bits plus parity: where M=1 and PCE=1 in the USART_CR1 register 1.5 stop bits when transmitting and receiving: where STOP=11 in the USART_CR2 register. There are two modes of transfer: Blocking mode: The communication is performed in polling mode. The HAL status of all data processing is returned by the same function after finishing transfer. No-Blocking mode: The communication is performed using Interrupts or DMA, the relevant API's return the HAL status. The end of the data processing will be indicated through the dedicated SMARTCARD IRQ when using Interrupt mode or the DMA IRQ when using DMA mode. The HAL_SMARTCARD_TxCpltCallback(), HAL_SMARTCARD_RxCpltCallback() user callbacks will be executed respectively at the end of the Transmit or Receive process The HAL_SMARTCARD_ErrorCallback() user callback will be executed when a communication error is detected. Blocking mode APIs are : HAL_SMARTCARD_Transmit() HAL_SMARTCARD_Receive() Non Blocking mode APIs with Interrupt are : HAL_SMARTCARD_Transmit_IT() HAL_SMARTCARD_Receive_IT() HAL_SMARTCARD_IRQHandler() Non Blocking mode functions with DMA are : HAL_SMARTCARD_Transmit_DMA() HAL_SMARTCARD_Receive_DMA() A set of Transfer Complete Callbacks are provided in non Blocking mode: HAL_SMARTCARD_TxCpltCallback() HAL_SMARTCARD_RxCpltCallback() HAL_SMARTCARD_ErrorCallback() DOCID026526 Rev 4 609/832 UM1786 This section contains the following APIs: 43.2.4 HAL_SMARTCARD_Transmit() HAL_SMARTCARD_Receive() HAL_SMARTCARD_Transmit_IT() HAL_SMARTCARD_Receive_IT() HAL_SMARTCARD_Transmit_DMA() HAL_SMARTCARD_Receive_DMA() HAL_SMARTCARD_IRQHandler() HAL_SMARTCARD_TxCpltCallback() HAL_SMARTCARD_RxCpltCallback() HAL_SMARTCARD_ErrorCallback() Peripheral State and Errors functions This subsection provides a set of functions allowing to return the State of SmartCard handle and also return Peripheral Errors occurred during communication process HAL_SMARTCARD_GetState() API can be helpful to check in run-time the state of the SMARTCARD peripheral. HAL_SMARTCARD_GetError() checks in run-time errors that could occur during communication. This section contains the following APIs: 43.2.5 HAL_SMARTCARD_GetState() HAL_SMARTCARD_GetError() Detailed description of functions HAL_SMARTCARD_Init Function Name HAL_StatusTypeDef HAL_SMARTCARD_Init (SMARTCARD_HandleTypeDef * hsmartcard) Function Description Initialize the SMARTCARD mode according to the specified parameters in the SMARTCARD_HandleTypeDef and initialize the associated handle. Parameters hsmartcard: Pointer to a SMARTCARD_HandleTypeDef structure that contains the configuration information for the specified SMARTCARD module. Return values HAL: status HAL_SMARTCARD_DeInit 610/832 Function Name HAL_StatusTypeDef HAL_SMARTCARD_DeInit (SMARTCARD_HandleTypeDef * hsmartcard) Function Description DeInitialize the SMARTCARD peripheral. Parameters hsmartcard: Pointer to a SMARTCARD_HandleTypeDef structure that contains the configuration information for the specified SMARTCARD module. Return values HAL: status DOCID026526 Rev 4 UM1786 HAL_SMARTCARD_MspInit Function Name void HAL_SMARTCARD_MspInit (SMARTCARD_HandleTypeDef * hsmartcard) Function Description Initialize the SMARTCARD MSP. Parameters hsmartcard: Pointer to a SMARTCARD_HandleTypeDef structure that contains the configuration information for the specified SMARTCARD module. Return values None: HAL_SMARTCARD_MspDeInit Function Name void HAL_SMARTCARD_MspDeInit (SMARTCARD_HandleTypeDef * hsmartcard) Function Description DeInitialize the SMARTCARD MSP. Parameters hsmartcard: Pointer to a SMARTCARD_HandleTypeDef structure that contains the configuration information for the specified SMARTCARD module. Return values None: HAL_SMARTCARD_Transmit Function Name HAL_StatusTypeDef HAL_SMARTCARD_Transmit (SMARTCARD_HandleTypeDef * hsmartcard, uint8_t * pData, uint16_t Size, uint32_t Timeout) Function Description Send an amount of data in blocking mode. Parameters Return values hsmartcard: Pointer to a SMARTCARD_HandleTypeDef structure that contains the configuration information for the specified SMARTCARD module. pData: pointer to data buffer. Size: amount of data to be sent. Timeout: : Timeout duration. HAL: status HAL_SMARTCARD_Receive Function Name HAL_StatusTypeDef HAL_SMARTCARD_Receive (SMARTCARD_HandleTypeDef * hsmartcard, uint8_t * pData, uint16_t Size, uint32_t Timeout) Function Description Receive an amount of data in blocking mode. Parameters Return values hsmartcard: Pointer to a SMARTCARD_HandleTypeDef structure that contains the configuration information for the specified SMARTCARD module. pData: pointer to data buffer. Size: amount of data to be received. Timeout: : Timeout duration. HAL: status DOCID026526 Rev 4 611/832 UM1786 HAL_SMARTCARD_Transmit_IT Function Name HAL_StatusTypeDef HAL_SMARTCARD_Transmit_IT (SMARTCARD_HandleTypeDef * hsmartcard, uint8_t * pData, uint16_t Size) Function Description Send an amount of data in interrupt mode. Parameters Return values hsmartcard: Pointer to a SMARTCARD_HandleTypeDef structure that contains the configuration information for the specified SMARTCARD module. pData: pointer to data buffer. Size: amount of data to be sent. HAL: status HAL_SMARTCARD_Receive_IT Function Name HAL_StatusTypeDef HAL_SMARTCARD_Receive_IT (SMARTCARD_HandleTypeDef * hsmartcard, uint8_t * pData, uint16_t Size) Function Description Receive an amount of data in interrupt mode. Parameters Return values hsmartcard: Pointer to a SMARTCARD_HandleTypeDef structure that contains the configuration information for the specified SMARTCARD module. pData: pointer to data buffer. Size: amount of data to be received. HAL: status HAL_SMARTCARD_Transmit_DMA Function Name HAL_StatusTypeDef HAL_SMARTCARD_Transmit_DMA (SMARTCARD_HandleTypeDef * hsmartcard, uint8_t * pData, uint16_t Size) Function Description Send an amount of data in DMA mode. Parameters Return values hsmartcard: Pointer to a SMARTCARD_HandleTypeDef structure that contains the configuration information for the specified SMARTCARD module. pData: pointer to data buffer. Size: amount of data to be sent. HAL: status HAL_SMARTCARD_Receive_DMA Function Name HAL_StatusTypeDef HAL_SMARTCARD_Receive_DMA (SMARTCARD_HandleTypeDef * hsmartcard, uint8_t * pData, uint16_t Size) Function Description Receive an amount of data in DMA mode. Parameters 612/832 hsmartcard: Pointer to a SMARTCARD_HandleTypeDef structure that contains the configuration information for the specified SMARTCARD module. pData: pointer to data buffer. DOCID026526 Rev 4 UM1786 Size: amount of data to be received. Return values HAL: status Notes The SMARTCARD-associated USART parity is enabled (PCE = 1), the received data contain the parity bit (MSB position). HAL_SMARTCARD_IRQHandler Function Name void HAL_SMARTCARD_IRQHandler (SMARTCARD_HandleTypeDef * hsmartcard) Function Description Handle SMARTCARD interrupt requests. Parameters hsmartcard: Pointer to a SMARTCARD_HandleTypeDef structure that contains the configuration information for the specified SMARTCARD module. Return values None: HAL_SMARTCARD_TxCpltCallback Function Name void HAL_SMARTCARD_TxCpltCallback (SMARTCARD_HandleTypeDef * hsmartcard) Function Description Tx Transfer completed callback. Parameters hsmartcard: Pointer to a SMARTCARD_HandleTypeDef structure that contains the configuration information for the specified SMARTCARD module. Return values None: HAL_SMARTCARD_RxCpltCallback Function Name void HAL_SMARTCARD_RxCpltCallback (SMARTCARD_HandleTypeDef * hsmartcard) Function Description Rx Transfer completed callback. Parameters hsmartcard: Pointer to a SMARTCARD_HandleTypeDef structure that contains the configuration information for the specified SMARTCARD module. Return values None: HAL_SMARTCARD_ErrorCallback Function Name void HAL_SMARTCARD_ErrorCallback (SMARTCARD_HandleTypeDef * hsmartcard) Function Description SMARTCARD error callback. Parameters hsmartcard: Pointer to a SMARTCARD_HandleTypeDef structure that contains the configuration information for the specified SMARTCARD module. Return values None: DOCID026526 Rev 4 613/832 UM1786 HAL_SMARTCARD_GetState Function Name HAL_SMARTCARD_StateTypeDef HAL_SMARTCARD_GetState (SMARTCARD_HandleTypeDef * hsmartcard) Function Description Return the SMARTCARD handle state. Parameters hsmartcard: Pointer to a SMARTCARD_HandleTypeDef structure that contains the configuration information for the specified SMARTCARD module. Return values SMARTCARD: handle state HAL_SMARTCARD_GetError Function Name uint32_t HAL_SMARTCARD_GetError (SMARTCARD_HandleTypeDef * hsmartcard) Function Description Return the SMARTCARD handle error code. Parameters hsmartcard: Pointer to a SMARTCARD_HandleTypeDef structure that contains the configuration information for the specified SMARTCARD module. Return values SMARTCARD: handle Error Code 43.3 SMARTCARD Firmware driver defines 43.3.1 SMARTCARD SMARTCARD advanced feature initialization type SMARTCARD_ADVFEATURE_NO_INIT SMARTCARD_ADVFEATURE_TXINVERT_INIT SMARTCARD_ADVFEATURE_RXINVERT_INIT SMARTCARD_ADVFEATURE_DATAINVERT_INIT SMARTCARD_ADVFEATURE_SWAP_INIT SMARTCARD_ADVFEATURE_RXOVERRUNDISABLE_INIT SMARTCARD_ADVFEATURE_DMADISABLEONERROR_INIT SMARTCARD_ADVFEATURE_MSBFIRST_INIT SMARTCARD Clock Phase SMARTCARD_PHASE_1EDGE SMARTCARD_PHASE_2EDGE SMARTCARD Clock Polarity SMARTCARD_POLARITY_LOW SMARTCARD_POLARITY_HIGH SMARTCARD auto retry counter LSB position in CR3 register SMARTCARD_CR3_SCARCNT_LSB_POS 614/832 SMARTCARD auto retry counter LSB position in CR3 register DOCID026526 Rev 4 UM1786 SMARTCARD advanced feature Binary Data inversion SMARTCARD_ADVFEATURE_DATAINV_DISABLE SMARTCARD_ADVFEATURE_DATAINV_ENABLE SMARTCARD advanced feature DMA Disable on Rx Error SMARTCARD_ADVFEATURE_DMA_ENABLEONRXERROR SMARTCARD_ADVFEATURE_DMA_DISABLEONRXERROR SMARTCARD Error HAL_SMARTCARD_ERROR_NONE No error HAL_SMARTCARD_ERROR_PE Parity error HAL_SMARTCARD_ERROR_NE Noise error HAL_SMARTCARD_ERROR_FE frame error HAL_SMARTCARD_ERROR_ORE Overrun error HAL_SMARTCARD_ERROR_DMA DMA transfer error HAL_SMARTCARD_ERROR_RTO Receiver TimeOut error SMARTCARD Exported Macros __HAL_SMARTCARD_RESET_HANDLE _STATE Description: Reset SMARTCARD handle states. Parameters: __HANDLE__: SMARTCARD handle. Return value: __HAL_SMARTCARD_FLUSH_DRREGI STER None Description: Flush the Smartcard Data registers. Parameters: __HANDLE__: specifies the SMARTCARD Handle. Return value: __HAL_SMARTCARD_CLEAR_FLAG None Description: Clear the specified SMARTCARD pending flag. Parameters: __HANDLE__: specifies the SMARTCARD Handle. __FLAG__: specifies the flag to check. This parameter can be any combination of the following values: SMARTCARD_CLEAR_PEF: Parity error clear flag DOCID026526 Rev 4 615/832 UM1786 SMARTCARD_CLEAR_FEF: Framing error clear flag SMARTCARD_CLEAR_NEF: Noise detected clear flag SMARTCARD_CLEAR_OREF: OverRun error clear flag SMARTCARD_CLEAR_IDLEF: Idle line detected clear flag SMARTCARD_CLEAR_TCF: Transmission complete clear flag SMARTCARD_CLEAR_RTOF: Receiver timeout clear flag SMARTCARD_CLEAR_EOBF: End of block clear flag Return value: __HAL_SMARTCARD_CLEAR_PEFLAG None Description: Clear the SMARTCARD PE pending flag. Parameters: __HANDLE__: specifies the SMARTCARD Handle. Return value: __HAL_SMARTCARD_CLEAR_FEFLAG None Description: Clear the SMARTCARD FE pending flag. Parameters: __HANDLE__: specifies the SMARTCARD Handle. Return value: __HAL_SMARTCARD_CLEAR_NEFLAG None Description: Clear the SMARTCARD NE pending flag. Parameters: __HANDLE__: specifies the SMARTCARD Handle. Return value: __HAL_SMARTCARD_CLEAR_OREFLA G None Description: Clear the SMARTCARD ORE pending flag. Parameters: 616/832 __HANDLE__: specifies the DOCID026526 Rev 4 UM1786 SMARTCARD Handle. Return value: __HAL_SMARTCARD_CLEAR_IDLEFLA G None Description: Clear the SMARTCARD IDLE pending flag. Parameters: __HANDLE__: specifies the SMARTCARD Handle. Return value: __HAL_SMARTCARD_GET_FLAG None Description: Check whether the specified Smartcard flag is set or not. Parameters: __HANDLE__: specifies the SMARTCARD Handle. The Handle Instance can be USARTx where x: 1, 2 or 3 to select the USART peripheral. __FLAG__: specifies the flag to check. This parameter can be one of the following values: SMARTCARD_FLAG_REACK: Receive enable acknowledge flag SMARTCARD_FLAG_TEACK: Transmit enable acknowledge flag SMARTCARD_FLAG_BUSY: Busy flag SMARTCARD_FLAG_EOBF: End of block flag SMARTCARD_FLAG_RTOF: Receiver timeout flag SMARTCARD_FLAG_TXE: Transmit data register empty flag SMARTCARD_FLAG_TC: Transmission complete flag SMARTCARD_FLAG_RXNE: Receive data register not empty flag SMARTCARD_FLAG_IDLE: Idle line detection flag SMARTCARD_FLAG_ORE: Overrun error flag SMARTCARD_FLAG_NE: Noise error flag SMARTCARD_FLAG_FE: Framing error flag SMARTCARD_FLAG_PE: Parity error flag DOCID026526 Rev 4 617/832 UM1786 Return value: __HAL_SMARTCARD_ENABLE_IT The: new state of __FLAG__ (TRUE or FALSE). Description: Enable the specified SmartCard interrupt. Parameters: __HANDLE__: specifies the SMARTCARD Handle. The Handle Instance can be USARTx where x: 1, 2 or 3 to select the USART peripheral. __INTERRUPT__: specifies the SMARTCARD interrupt to enable. This parameter can be one of the following values: SMARTCARD_IT_EOB: End of block interrupt SMARTCARD_IT_RTO: Receive timeout interrupt SMARTCARD_IT_TXE: Transmit data register empty interrupt SMARTCARD_IT_TC: Transmission complete interrupt SMARTCARD_IT_RXNE: Receive data register not empty interrupt SMARTCARD_IT_IDLE: Idle line detection interrupt SMARTCARD_IT_PE: Parity error interrupt SMARTCARD_IT_ERR: Error interrupt(frame error, noise error, overrun error) Return value: __HAL_SMARTCARD_DISABLE_IT None Description: Disable the specified SmartCard interrupt. Parameters: 618/832 __HANDLE__: specifies the SMARTCARD Handle. The Handle Instance can be USARTx where x: 1, 2 or 3 to select the USART peripheral. __INTERRUPT__: specifies the SMARTCARD interrupt to disable. This parameter can be one of the following values: SMARTCARD_IT_EOB: End of block interrupt SMARTCARD_IT_RTO: Receive timeout interrupt SMARTCARD_IT_TXE: Transmit DOCID026526 Rev 4 UM1786 data register empty interrupt SMARTCARD_IT_TC: Transmission complete interrupt SMARTCARD_IT_RXNE: Receive data register not empty interrupt SMARTCARD_IT_IDLE: Idle line detection interrupt SMARTCARD_IT_PE: Parity error interrupt SMARTCARD_IT_ERR: Error interrupt(frame error, noise error, overrun error) Return value: __HAL_SMARTCARD_GET_IT None Description: Check whether the specified SmartCard interrupt has occurred or not. Parameters: __HANDLE__: specifies the SMARTCARD Handle. The Handle Instance can be USARTx where x: 1, 2 or 3 to select the USART peripheral. __IT__: specifies the SMARTCARD interrupt to check. This parameter can be one of the following values: SMARTCARD_IT_EOB: End of block interrupt SMARTCARD_IT_RTO: Receive timeout interrupt SMARTCARD_IT_TXE: Transmit data register empty interrupt SMARTCARD_IT_TC: Transmission complete interrupt SMARTCARD_IT_RXNE: Receive data register not empty interrupt SMARTCARD_IT_IDLE: Idle line detection interrupt SMARTCARD_IT_ORE: Overrun error interrupt SMARTCARD_IT_NE: Noise error interrupt SMARTCARD_IT_FE: Framing error interrupt SMARTCARD_IT_PE: Parity error interrupt Return value: __HAL_SMARTCARD_GET_IT_SOURC The: new state of __IT__ (TRUE or FALSE). Description: DOCID026526 Rev 4 619/832 UM1786 E Check whether the specified SmartCard interrupt source is enabled or not. Parameters: __HANDLE__: specifies the SMARTCARD Handle. The Handle Instance can be USARTx where x: 1, 2 or 3 to select the USART peripheral. __IT__: specifies the SMARTCARD interrupt source to check. This parameter can be one of the following values: SMARTCARD_IT_EOB: End of block interrupt SMARTCARD_IT_RTO: Receive timeout interrupt SMARTCARD_IT_TXE: Transmit data register empty interrupt SMARTCARD_IT_TC: Transmission complete interrupt SMARTCARD_IT_RXNE: Receive data register not empty interrupt SMARTCARD_IT_IDLE: Idle line detection interrupt SMARTCARD_IT_ORE: Overrun error interrupt SMARTCARD_IT_NE: Noise error interrupt SMARTCARD_IT_FE: Framing error interrupt SMARTCARD_IT_PE: Parity error interrupt Return value: __HAL_SMARTCARD_CLEAR_IT The: new state of __IT__ (TRUE or FALSE). Description: Clear the specified SMARTCARD ISR flag, in setting the proper ICR register flag. Parameters: 620/832 __HANDLE__: specifies the SMARTCARD Handle. The Handle Instance can be USARTx where x: 1, 2 or 3 to select the USART peripheral. __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set to clear the corresponding interrupt This parameter can be one of the following values: SMARTCARD_CLEAR_PEF: Parity error clear flag SMARTCARD_CLEAR_FEF: DOCID026526 Rev 4 UM1786 Framing error clear flag SMARTCARD_CLEAR_NEF: Noise detected clear flag SMARTCARD_CLEAR_OREF: OverRun error clear flag SMARTCARD_CLEAR_IDLEF: Idle line detection clear flag SMARTCARD_CLEAR_TCF: Transmission complete clear flag SMARTCARD_CLEAR_RTOF: Receiver timeout clear flag SMARTCARD_CLEAR_EOBF: End of block clear flag Return value: __HAL_SMARTCARD_SEND_REQ None Description: Set a specific SMARTCARD request flag. Parameters: __HANDLE__: specifies the SMARTCARD Handle. The Handle Instance can be USARTx where x: 1, 2 or 3 to select the USART peripheral. __REQ__: specifies the request flag to set This parameter can be one of the following values: SMARTCARD_RXDATA_FLUSH_R EQUEST: Receive data flush Request SMARTCARD_TXDATA_FLUSH_R EQUEST: Transmit data flush Request Return value: __HAL_SMARTCARD_ONE_BIT_SAMP LE_ENABLE None Description: Enable the SMARTCARD one bit sample method. Parameters: __HANDLE__: specifies the SMARTCARD Handle. Return value: __HAL_SMARTCARD_ONE_BIT_SAMP LE_DISABLE None Description: Disable the SMARTCARD one bit sample method. Parameters: DOCID026526 Rev 4 621/832 UM1786 __HANDLE__: specifies the SMARTCARD Handle. Return value: None Description: __HAL_SMARTCARD_ENABLE Enable the USART associated to the SMARTCARD Handle. Parameters: __HANDLE__: specifies the SMARTCARD Handle. The Handle Instance can be UARTx where x: 1, 2, 3 to select the USART peripheral Return value: None Description: __HAL_SMARTCARD_DISABLE Disable the USART associated to the SMARTCARD Handle. Parameters: __HANDLE__: specifies the SMARTCARD Handle. The Handle Instance can be UARTx where x: 1, 2, 3 to select the USART peripheral Return value: None SMARTCARDEx Exported Macros SMARTCARD_GETCLOCKSOURCE Description: Reports the SMARTCARD clock source. Parameters: __HANDLE__: specifies the SMARTCARD Handle __CLOCKSOURCE__: : output variable Return value: the: SMARTCARD clocking source, written in __CLOCKSOURCE__. SMARTCARD Flags SMARTCARD_FLAG_REACK SMARTCARD_FLAG_TEACK SMARTCARD_FLAG_BUSY SMARTCARD_FLAG_EOBF SMARTCARD_FLAG_RTOF 622/832 DOCID026526 Rev 4 UM1786 SMARTCARD_FLAG_TXE SMARTCARD_FLAG_TC SMARTCARD_FLAG_RXNE SMARTCARD_FLAG_IDLE SMARTCARD_FLAG_ORE SMARTCARD_FLAG_NE SMARTCARD_FLAG_FE SMARTCARD_FLAG_PE SMARTCARD guard time value LSB position in GTPR register SMARTCARD_GTPR_GT_LSB_POS SMARTCARD guard time value LSB position in GTPR register SMARTCARD interruptions flags mask SMARTCARD_IT_MASK SMARTCARD interruptions flags mask SMARTCARD Interrupts Definition SMARTCARD_IT_PE SMARTCARD_IT_TXE SMARTCARD_IT_TC SMARTCARD_IT_RXNE SMARTCARD_IT_IDLE SMARTCARD_IT_ERR SMARTCARD_IT_ORE SMARTCARD_IT_NE SMARTCARD_IT_FE SMARTCARD_IT_EOB SMARTCARD_IT_RTO SMARTCARD Interruption Clear Flags SMARTCARD_CLEAR_PEF Parity Error Clear Flag SMARTCARD_CLEAR_FEF Framing Error Clear Flag SMARTCARD_CLEAR_NEF Noise detected Clear Flag SMARTCARD_CLEAR_OREF OverRun Error Clear Flag SMARTCARD_CLEAR_IDLEF Idle line detected clear flag SMARTCARD_CLEAR_TCF Transmission Complete Clear Flag SMARTCARD_CLEAR_RTOF Receiver Time Out Clear Flag S