Description of STM32F3xx HAL drivers

Description of STM32F3xx HAL drivers
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.
May 2015
DOCID026526 Rev 2
1/861
www.st.com
Contents
UM1786
Contents
1
Acronyms and definitions............................................................. 45
2
Overview of HAL drivers ............................................................... 47
2.1
2.2
2.1.1
HAL driver files ................................................................................. 47
2.1.2
User-application files ........................................................................ 48
HAL data structures ........................................................................ 50
2.2.1
Peripheral handle structures ............................................................ 50
2.2.2
Initialization and configuration structure ........................................... 51
2.2.3
Specific process structures .............................................................. 51
2.3
API classification ............................................................................. 51
2.4
Devices supported by HAL drivers .................................................. 53
2.5
HAL drivers rules............................................................................. 57
2.5.1
HAL API naming rules ...................................................................... 57
2.5.2
HAL general naming rules ................................................................ 58
2.5.3
HAL interrupt handler and callback functions ................................... 59
2.6
HAL generic APIs ............................................................................ 60
2.7
HAL extension APIs ........................................................................ 61
2.7.1
HAL extension model overview ........................................................ 61
2.7.2
HAL extension model cases ............................................................. 61
2.8
File inclusion model......................................................................... 63
2.9
HAL common resources .................................................................. 64
2.10
HAL configuration............................................................................ 65
2.11
HAL system peripheral handling ..................................................... 66
2.12
2/861
HAL and user-application files......................................................... 47
2.11.1
Clock ................................................................................................. 66
2.11.2
GPIOs ............................................................................................... 66
2.11.3
Cortex NVIC and SysTick timer........................................................ 68
2.11.4
PWR ................................................................................................. 69
2.11.5
EXTI .................................................................................................. 69
2.11.6
DMA .................................................................................................. 70
How to use HAL drivers .................................................................. 72
2.12.1
HAL usage models ........................................................................... 72
2.12.2
HAL initialization ............................................................................... 73
2.12.3
HAL IO operation process ................................................................ 75
2.12.4
Timeout and error management ....................................................... 78
DOCID026526 Rev 2
UM1786
3
Contents
HAL System Driver ........................................................................ 82
3.1
3.2
HAL Firmware driver API description .............................................. 82
3.1.1
How to use this driver ....................................................................... 82
3.1.2
Initialization and de-initialization functions ....................................... 82
3.1.3
HAL Control functions....................................................................... 82
3.1.4
HAL_Init ............................................................................................ 83
3.1.5
HAL_DeInit ....................................................................................... 83
3.1.6
HAL_MspInit ..................................................................................... 84
3.1.7
HAL_MspDeInit ................................................................................ 84
3.1.8
HAL_InitTick ..................................................................................... 84
3.1.9
HAL_IncTick ..................................................................................... 84
3.1.10
HAL_GetTick .................................................................................... 85
3.1.11
HAL_Delay ....................................................................................... 85
3.1.12
HAL_SuspendTick ............................................................................ 85
3.1.13
HAL_ResumeTick............................................................................. 85
3.1.14
HAL_GetHalVersion ......................................................................... 86
3.1.15
HAL_GetREVID ................................................................................ 86
3.1.16
HAL_GetDEVID ................................................................................ 86
3.1.17
HAL_EnableDBGSleepMode ........................................................... 86
3.1.18
HAL_DisableDBGSleepMode .......................................................... 86
3.1.19
HAL_EnableDBGStopMode ............................................................. 86
3.1.20
HAL_DisableDBGStopMode ............................................................ 87
3.1.21
HAL_EnableDBGStandbyMode ....................................................... 87
3.1.22
HAL_DisableDBGStandbyMode ...................................................... 87
HAL Firmware driver defines ........................................................... 87
3.2.1
4
HAL ................................................................................................... 87
HAL ADC Generic Driver ............................................................... 92
4.1
ADC Firmware driver registers structures ....................................... 92
4.1.1
4.2
__ADC_HandleTypeDef ................................................................... 92
ADC Firmware driver API description.............................................. 92
4.2.1
ADC peripheral features ................................................................... 92
4.2.2
How to use this driver ....................................................................... 93
4.2.3
Initialization and de-initialization functions ....................................... 97
4.2.4
IO operation functions ...................................................................... 97
4.2.5
Peripheral Control functions ............................................................. 98
4.2.6
Peripheral state and errors functions ............................................... 98
4.2.7
HAL_ADC_Init .................................................................................. 98
DOCID026526 Rev 2
3/861
Contents
4.3
4.2.8
UM1786
HAL_ADC_DeInit .............................................................................. 99
4.2.9
HAL_ADC_MspInit ........................................................................... 99
4.2.10
HAL_ADC_MspDeInit ....................................................................... 99
4.2.11
HAL_ADC_Start ............................................................................. 100
4.2.12
HAL_ADC_Stop .............................................................................. 100
4.2.13
HAL_ADC_PollForConversion ....................................................... 100
4.2.14
HAL_ADC_PollForEvent ................................................................ 101
4.2.15
HAL_ADC_Start_IT ........................................................................ 101
4.2.16
HAL_ADC_Stop_IT ........................................................................ 101
4.2.17
HAL_ADC_Start_DMA ................................................................... 102
4.2.18
HAL_ADC_Stop_DMA.................................................................... 102
4.2.19
HAL_ADC_GetValue ...................................................................... 102
4.2.20
HAL_ADC_IRQHandler .................................................................. 102
4.2.21
HAL_ADC_ConvCpltCallback ........................................................ 103
4.2.22
HAL_ADC_ConvHalfCpltCallback .................................................. 103
4.2.23
HAL_ADC_LevelOutOfWindowCallback ........................................ 103
4.2.24
HAL_ADC_ErrorCallback ............................................................... 103
4.2.25
HAL_ADC_ConfigChannel ............................................................. 104
4.2.26
HAL_ADC_AnalogWDGConfig ...................................................... 104
4.2.27
HAL_ADC_GetState ....................................................................... 105
4.2.28
HAL_ADC_GetError ....................................................................... 105
ADC Firmware driver defines ........................................................ 105
4.3.1
5
HAL ADC Extension Driver ......................................................... 108
5.1
5.2
4/861
ADC ................................................................................................ 105
ADCEx Firmware driver registers structures ................................. 108
5.1.1
ADC_InitTypeDef ............................................................................ 108
5.1.2
ADC_ChannelConfTypeDef ........................................................... 110
5.1.3
ADC_InjectionConfTypeDef ........................................................... 111
5.1.4
ADC_AnalogWDGConfTypeDef ..................................................... 114
5.1.5
ADC_MultiModeTypeDef ................................................................ 115
ADCEx Firmware driver API description ....................................... 115
5.2.1
Initialization and de-initialization functions ..................................... 115
5.2.2
IO operation functions .................................................................... 115
5.2.3
Peripheral Control functions ........................................................... 116
5.2.4
HAL_ADC_Init ................................................................................ 117
5.2.5
HAL_ADC_DeInit ............................................................................ 117
5.2.6
HAL_ADC_Start ............................................................................. 118
5.2.7
HAL_ADC_Stop .............................................................................. 118
DOCID026526 Rev 2
UM1786
Contents
5.3
5.2.8
HAL_ADC_PollForConversion ....................................................... 118
5.2.9
HAL_ADC_PollForEvent ................................................................ 119
5.2.10
HAL_ADC_Start_IT ........................................................................ 119
5.2.11
HAL_ADC_Stop_IT ........................................................................ 119
5.2.12
HAL_ADC_Start_DMA ................................................................... 120
5.2.13
HAL_ADC_Stop_DMA.................................................................... 120
5.2.14
HAL_ADC_GetValue ...................................................................... 120
5.2.15
HAL_ADC_IRQHandler .................................................................. 121
5.2.16
HAL_ADCEx_Calibration_Start ...................................................... 121
5.2.17
HAL_ADCEx_Calibration_GetValue .............................................. 121
5.2.18
HAL_ADCEx_Calibration_SetValue ............................................... 121
5.2.19
HAL_ADCEx_InjectedStart ............................................................ 122
5.2.20
HAL_ADCEx_InjectedStop ............................................................. 122
5.2.21
HAL_ADCEx_InjectedPollForConversion ...................................... 122
5.2.22
HAL_ADCEx_InjectedStart_IT ....................................................... 123
5.2.23
HAL_ADCEx_InjectedStop_IT ....................................................... 123
5.2.24
HAL_ADCEx_MultiModeStart_DMA .............................................. 123
5.2.25
HAL_ADCEx_MultiModeStop_DMA ............................................... 123
5.2.26
HAL_ADCEx_MultiModeGetValue ................................................. 124
5.2.27
HAL_ADCEx_InjectedGetValue ..................................................... 124
5.2.28
HAL_ADCEx_InjectedConvCpltCallback ....................................... 124
5.2.29
HAL_ADCEx_InjectedQueueOverflowCallback ............................. 125
5.2.30
HAL_ADC_ConfigChannel ............................................................. 125
5.2.31
HAL_ADCEx_InjectedConfigChannel ............................................ 125
5.2.32
HAL_ADC_AnalogWDGConfig ...................................................... 126
5.2.33
HAL_ADCEx_MultiModeConfigChannel ........................................ 127
ADCEx Firmware driver defines .................................................... 127
5.3.1
6
ADCEx ............................................................................................ 127
HAL CAN Generic Driver ............................................................. 153
6.1
6.2
CAN Firmware driver registers structures ..................................... 153
6.1.1
CAN_InitTypeDef ............................................................................ 153
6.1.2
CAN_FilterConfTypeDef ................................................................. 154
6.1.3
CanTxMsgTypeDef......................................................................... 155
6.1.4
CanRxMsgTypeDef ........................................................................ 155
6.1.5
CAN_HandleTypeDef ..................................................................... 156
CAN Firmware driver API description ............................................ 157
6.2.1
How to use this driver ..................................................................... 157
6.2.2
Initialization and de-initialization functions ..................................... 158
DOCID026526 Rev 2
5/861
Contents
6.3
6.2.3
UM1786
IO operation functions .................................................................... 158
6.2.4
Peripheral State and Error functions .............................................. 158
6.2.5
HAL_CAN_Init ................................................................................ 159
6.2.6
HAL_CAN_ConfigFilter................................................................... 159
6.2.7
HAL_CAN_DeInit ............................................................................ 159
6.2.8
HAL_CAN_MspInit ......................................................................... 159
6.2.9
HAL_CAN_MspDeInit ..................................................................... 160
6.2.10
HAL_CAN_Transmit ....................................................................... 160
6.2.11
HAL_CAN_Transmit_IT .................................................................. 160
6.2.12
HAL_CAN_Receive ........................................................................ 160
6.2.13
HAL_CAN_Receive_IT ................................................................... 161
6.2.14
HAL_CAN_Sleep ............................................................................ 161
6.2.15
HAL_CAN_WakeUp ....................................................................... 161
6.2.16
HAL_CAN_IRQHandler .................................................................. 161
6.2.17
HAL_CAN_TxCpltCallback ............................................................. 162
6.2.18
HAL_CAN_RxCpltCallback ............................................................ 162
6.2.19
HAL_CAN_ErrorCallback ............................................................... 162
6.2.20
HAL_CAN_GetState ....................................................................... 162
6.2.21
HAL_CAN_GetError ....................................................................... 162
CAN Firmware driver defines ........................................................ 163
6.3.1
7
HAL CEC Generic Driver ............................................................. 171
7.1
7.2
6/861
CAN ................................................................................................ 163
CEC Firmware driver registers structures ..................................... 171
7.1.1
CEC_InitTypeDef ............................................................................ 171
7.1.2
CEC_HandleTypeDef ..................................................................... 172
CEC Firmware driver API description ............................................ 173
7.2.1
How to use this driver ..................................................................... 173
7.2.2
Initialization and Configuration functions ........................................ 173
7.2.3
IO operation function ...................................................................... 173
7.2.4
Peripheral Control functions ........................................................... 174
7.2.5
HAL_CEC_Init ................................................................................ 174
7.2.6
HAL_CEC_DeInit ............................................................................ 174
7.2.7
HAL_CEC_MspInit ......................................................................... 174
7.2.8
HAL_CEC_MspDeInit ..................................................................... 174
7.2.9
HAL_CEC_Transmit ....................................................................... 175
7.2.10
HAL_CEC_Receive ........................................................................ 175
7.2.11
HAL_CEC_Transmit_IT .................................................................. 175
7.2.12
HAL_CEC_Receive_IT ................................................................... 176
DOCID026526 Rev 2
UM1786
Contents
7.3
7.2.13
HAL_CEC_IRQHandler .................................................................. 176
7.2.14
HAL_CEC_TxCpltCallback ............................................................. 176
7.2.15
HAL_CEC_RxCpltCallback ............................................................ 176
7.2.16
HAL_CEC_ErrorCallback ............................................................... 177
7.2.17
HAL_CEC_GetState ....................................................................... 177
7.2.18
HAL_CEC_GetError ....................................................................... 177
CEC Firmware driver defines ........................................................ 177
7.3.1
8
HAL COMP Generic Driver .......................................................... 186
8.1
8.2
8.3
COMP Firmware driver registers structures .................................. 186
8.1.1
COMP_InitTypeDef ........................................................................ 186
8.1.2
COMP_HandleTypeDef .................................................................. 187
COMP Firmware driver API description ........................................ 187
8.2.1
COMP Peripheral features ............................................................. 187
8.2.2
How to use this driver ..................................................................... 190
8.2.3
Initialization and Configuration functions ........................................ 191
8.2.4
IO operation functions .................................................................... 191
8.2.5
Peripheral Control functions ........................................................... 191
8.2.6
Peripheral State functions .............................................................. 191
8.2.7
HAL_COMP_Init ............................................................................. 192
8.2.8
HAL_COMP_DeInit ........................................................................ 192
8.2.9
HAL_COMP_MspInit ...................................................................... 192
8.2.10
HAL_COMP_MspDeInit.................................................................. 192
8.2.11
HAL_COMP_Start .......................................................................... 192
8.2.12
HAL_COMP_Stop .......................................................................... 193
8.2.13
HAL_COMP_Start_IT ..................................................................... 193
8.2.14
HAL_COMP_Stop_IT ..................................................................... 193
8.2.15
HAL_COMP_IRQHandler ............................................................... 193
8.2.16
HAL_COMP_Lock .......................................................................... 194
8.2.17
HAL_COMP_GetOutputLevel ........................................................ 194
8.2.18
HAL_COMP_TriggerCallback ........................................................ 194
8.2.19
HAL_COMP_GetState.................................................................... 194
COMP Firmware driver defines ..................................................... 194
8.3.1
9
CEC ................................................................................................ 177
COMP ............................................................................................. 194
HAL COMP Extension Driver ...................................................... 196
9.1
COMPEx Firmware driver defines ................................................. 196
9.1.1
COMPEx ......................................................................................... 196
DOCID026526 Rev 2
7/861
Contents
10
UM1786
HAL CORTEX Generic Driver ...................................................... 201
10.1
10.2
CORTEX Firmware driver API description .................................... 201
10.1.1
How to use this driver ..................................................................... 201
10.1.2
Initialization and de-initialization functions ..................................... 202
10.1.3
Peripheral Control functions ........................................................... 202
10.1.4
HAL_NVIC_SetPriorityGrouping .................................................... 203
10.1.5
HAL_NVIC_SetPriority ................................................................... 203
10.1.6
HAL_NVIC_EnableIRQ .................................................................. 204
10.1.7
HAL_NVIC_DisableIRQ.................................................................. 204
10.1.8
HAL_NVIC_SystemReset............................................................... 204
10.1.9
HAL_SYSTICK_Config ................................................................... 204
10.1.10
HAL_NVIC_GetPriorityGrouping .................................................... 204
10.1.11
HAL_NVIC_GetPriority ................................................................... 205
10.1.12
HAL_NVIC_SetPendingIRQ ........................................................... 205
10.1.13
HAL_NVIC_GetPendingIRQ .......................................................... 205
10.1.14
HAL_NVIC_ClearPendingIRQ ........................................................ 206
10.1.15
HAL_NVIC_GetActive .................................................................... 206
10.1.16
HAL_SYSTICK_CLKSourceConfig ................................................ 206
10.1.17
HAL_SYSTICK_IRQHandler .......................................................... 206
10.1.18
HAL_SYSTICK_Callback ............................................................... 207
CORTEX Firmware driver defines ................................................. 207
10.2.1
11
HAL CRC Generic Driver ............................................................. 209
11.1
11.2
8/861
CORTEX ......................................................................................... 207
CRC Firmware driver registers structures ..................................... 209
11.1.1
CRC_InitTypeDef ........................................................................... 209
11.1.2
CRC_HandleTypeDef ..................................................................... 210
CRC Firmware driver API description ........................................... 210
11.2.1
How to use this driver ..................................................................... 210
11.2.2
Initialization and Configuration functions ........................................ 211
11.2.3
Peripheral Control functions ........................................................... 211
11.2.4
Peripheral State functions .............................................................. 211
11.2.5
HAL_CRC_Init ................................................................................ 211
11.2.6
HAL_CRC_DeInit ........................................................................... 212
11.2.7
HAL_CRC_MspInit ......................................................................... 212
11.2.8
HAL_CRC_MspDeInit..................................................................... 212
11.2.9
HAL_CRC_Accumulate .................................................................. 212
11.2.10
HAL_CRC_Calculate ...................................................................... 212
11.2.11
HAL_CRC_GetState....................................................................... 213
DOCID026526 Rev 2
UM1786
Contents
11.3
CRC Firmware driver defines ........................................................ 213
11.3.1
12
HAL CRC Extension Driver ......................................................... 215
12.1
12.2
CRCEx Firmware driver API description ....................................... 215
12.1.1
Product specific features ................................................................ 215
12.1.2
How to use this driver ..................................................................... 215
12.1.3
HAL_CRCEx_Polynomial_Set ....................................................... 215
12.1.4
HAL_CRCEx_Input_Data_Reverse ............................................... 215
12.1.5
HAL_CRCEx_Output_Data_Reverse ............................................. 216
CRCEx Firmware driver defines .................................................... 216
12.2.1
13
CRC ................................................................................................ 213
CRCEx ............................................................................................ 216
HAL DAC Generic Driver ............................................................. 218
13.1
13.2
DAC Firmware driver registers structures ..................................... 218
13.1.1
DAC_ChannelConfTypeDef ........................................................... 218
13.1.2
__DAC_HandleTypeDef ................................................................. 218
DAC Firmware driver API description............................................ 219
13.2.1
DAC Peripheral features................................................................. 219
13.2.2
How to use this driver ..................................................................... 220
13.2.3
Initialization and de-initialization functions ..................................... 221
13.2.4
IO operation functions .................................................................... 221
13.2.5
Peripheral Control functions ........................................................... 222
13.2.6
DAC Peripheral State and Error functions...................................... 222
13.2.7
HAL_DAC_Init ................................................................................ 222
13.2.8
HAL_DAC_DeInit ............................................................................ 222
13.2.9
HAL_DAC_MspInit ......................................................................... 222
13.2.10
HAL_DAC_MspDeInit ..................................................................... 223
13.2.11
HAL_DAC_Start ............................................................................. 223
13.2.12
HAL_DAC_Stop .............................................................................. 223
13.2.13
HAL_DAC_Stop_DMA.................................................................... 223
13.2.14
HAL_DAC_GetValue ...................................................................... 224
13.2.15
HAL_DACEx_DualGetValue .......................................................... 224
13.2.16
HAL_DAC_ConvCpltCallbackCh1 .................................................. 224
13.2.17
HAL_DAC_ConvHalfCpltCallbackCh1 ........................................... 224
13.2.18
HAL_DAC_ErrorCallbackCh1 ........................................................ 225
13.2.19
HAL_DAC_DMAUnderrunCallbackCh1 ......................................... 225
13.2.20
HAL_DAC_Start_DMA ................................................................... 225
13.2.21
HAL_DAC_IRQHandler .................................................................. 226
DOCID026526 Rev 2
9/861
Contents
13.3
13.2.22
UM1786
HAL_DAC_ConfigChannel ............................................................. 226
13.2.23
HAL_DAC_SetValue ...................................................................... 226
13.2.24
HAL_DACEx_DualSetValue ........................................................... 226
13.2.25
HAL_DAC_GetState ....................................................................... 227
13.2.26
HAL_DAC_GetError ....................................................................... 227
DAC Firmware driver defines ........................................................ 227
13.3.1
14
HAL DAC Extension Driver ......................................................... 231
14.1
14.2
DACEx Firmware driver API description ....................................... 231
14.1.1
How to use this driver ..................................................................... 231
14.1.2
Peripheral Control functions ........................................................... 231
14.1.3
IO operation functions .................................................................... 231
14.1.4
HAL_DAC_SetValue ...................................................................... 232
14.1.5
HAL_DACEx_DualSetValue ........................................................... 232
14.1.6
HAL_DAC_Start ............................................................................. 232
14.1.7
HAL_DAC_Start_DMA ................................................................... 232
14.1.8
HAL_DAC_GetValue ...................................................................... 233
14.1.9
HAL_DACEx_DualGetValue .......................................................... 233
14.1.10
HAL_DAC_IRQHandler .................................................................. 233
14.1.11
HAL_DACEx_TriangleWaveGenerate ........................................... 234
14.1.12
HAL_DACEx_NoiseWaveGenerate ............................................... 234
14.1.13
HAL_DACEx_ConvCpltCallbackCh2 ............................................. 235
14.1.14
HAL_DACEx_ConvHalfCpltCallbackCh2 ....................................... 235
14.1.15
HAL_DACEx_ErrorCallbackCh2 .................................................... 236
14.1.16
HAL_DACEx_DMAUnderrunCallbackCh2 ..................................... 236
DACEx Firmware driver defines .................................................... 236
14.2.1
15
DACEx ............................................................................................ 236
HAL DMA Generic Driver ............................................................ 238
15.1
15.2
10/861
DAC ................................................................................................ 227
DMA Firmware driver registers structures ..................................... 238
15.1.1
DMA_InitTypeDef ........................................................................... 238
15.1.2
__DMA_HandleTypeDef................................................................. 238
DMA Firmware driver API description ........................................... 239
15.2.1
How to use this driver ..................................................................... 239
15.2.2
Initialization and de-initialization functions ..................................... 240
15.2.3
IO operation functions .................................................................... 241
15.2.4
State and Errors functions .............................................................. 241
15.2.5
HAL_DMA_Init ................................................................................ 241
15.2.6
HAL_DMA_DeInit ........................................................................... 241
DOCID026526 Rev 2
UM1786
Contents
15.3
15.2.7
HAL_DMA_Start ............................................................................. 242
15.2.8
HAL_DMA_Start_IT ........................................................................ 242
15.2.9
HAL_DMA_Abort ............................................................................ 242
15.2.10
HAL_DMA_PollForTransfer ............................................................ 243
15.2.11
HAL_DMA_IRQHandler.................................................................. 243
15.2.12
HAL_DMA_GetState ...................................................................... 243
15.2.13
HAL_DMA_GetError ....................................................................... 243
DMA Firmware driver defines ........................................................ 244
15.3.1
16
HAL DMA Extension Driver......................................................... 248
16.1
DMAEx Firmware driver defines.................................................... 248
16.1.1
17
DMAEx............................................................................................ 248
HAL FLASH Generic Driver......................................................... 250
17.1
17.2
17.3
FLASH Firmware driver registers structures ................................. 250
17.1.1
FLASH_EraseInitTypeDef .............................................................. 250
17.1.2
FLASH_OBProgramInitTypeDef .................................................... 250
17.1.3
FLASH_ProcessTypeDef ............................................................... 251
FLASH Firmware driver API description ........................................ 251
17.2.1
FLASH peripheral features ............................................................. 251
17.2.2
How to use this driver ..................................................................... 252
17.2.3
IO operation functions .................................................................... 252
17.2.4
Peripheral Control functions ........................................................... 253
17.2.5
Peripheral State functions .............................................................. 253
17.2.6
HAL_FLASH_Program ................................................................... 253
17.2.7
HAL_FLASH_Program_IT .............................................................. 253
17.2.8
HAL_FLASH_IRQHandler .............................................................. 254
17.2.9
HAL_FLASH_EndOfOperationCallback ......................................... 254
17.2.10
HAL_FLASH_OperationErrorCallback ........................................... 254
17.2.11
HAL_FLASH_Unlock ...................................................................... 255
17.2.12
HAL_FLASH_Lock ......................................................................... 255
17.2.13
HAL_FLASH_OB_Unlock ............................................................... 255
17.2.14
HAL_FLASH_OB_Lock .................................................................. 255
17.2.15
HAL_FLASH_OB_Launch .............................................................. 255
17.2.16
HAL_FLASH_GetError ................................................................... 255
FLASH Firmware driver defines .................................................... 256
17.3.1
18
DMA ................................................................................................ 244
FLASH ............................................................................................ 256
HAL FLASH Extension Driver ..................................................... 261
DOCID026526 Rev 2
11/861
Contents
UM1786
18.1
18.2
FLASHEx Firmware driver API description.................................... 261
18.1.1
IO operation functions .................................................................... 261
18.1.2
Peripheral Control functions ........................................................... 261
18.1.3
HAL_FLASHEx_Erase ................................................................... 261
18.1.4
HAL_FLASHEx_Erase_IT .............................................................. 261
18.1.5
HAL_FLASHEx_OBErase .............................................................. 262
18.1.6
HAL_FLASHEx_OBProgram .......................................................... 262
18.1.7
HAL_FLASHEx_OBGetConfig ....................................................... 262
FLASHEx Firmware driver defines ................................................ 263
18.2.1
19
HAL GPIO Generic Driver............................................................ 265
19.1
GPIO Firmware driver registers structures .................................... 265
19.1.1
19.2
19.3
19.2.1
GPIO Peripheral features ............................................................... 265
19.2.2
How to use this driver ..................................................................... 266
19.2.3
Initialization and de-initialization functions ..................................... 267
19.2.4
IO operation functions .................................................................... 267
19.2.5
HAL_GPIO_Init ............................................................................... 267
19.2.6
HAL_GPIO_DeInit .......................................................................... 267
19.2.7
HAL_GPIO_ReadPin ...................................................................... 268
19.2.8
HAL_GPIO_WritePin ...................................................................... 268
19.2.9
HAL_GPIO_TogglePin ................................................................... 268
19.2.10
HAL_GPIO_LockPin ....................................................................... 268
19.2.11
HAL_GPIO_EXTI_IRQHandler ...................................................... 269
19.2.12
HAL_GPIO_EXTI_Callback ............................................................ 269
GPIO Firmware driver defines ....................................................... 269
GPIOEx Firmware driver defines................................................... 273
20.1.1
GPIOEx .......................................................................................... 273
HAL HRTIM Generic Driver ......................................................... 276
21.1
12/861
GPIO ............................................................................................... 269
HAL GPIO Extension Driver ........................................................ 273
20.1
21
GPIO_InitTypeDef .......................................................................... 265
GPIO Firmware driver API description .......................................... 265
19.3.1
20
FLASHEx ........................................................................................ 263
HRTIM Firmware driver registers structures.................................. 276
21.1.1
HRTIM_InitTypeDef ........................................................................ 276
21.1.2
HRTIM_TimerParamTypeDef ......................................................... 276
21.1.3
__HRTIM_HandleTypeDef ............................................................. 277
21.1.4
HRTIM_TimeBaseCfgTypeDef ....................................................... 278
DOCID026526 Rev 2
UM1786
Contents
21.2
21.1.5
HRTIM_SimpleOCChannelCfgTypeDef ......................................... 278
21.1.6
HRTIM_SimplePWMChannelCfgTypeDef...................................... 279
21.1.7
HRTIM_SimpleCaptureChannelCfgTypeDef.................................. 279
21.1.8
HRTIM_SimpleOnePulseChannelCfgTypeDef .............................. 280
21.1.9
HRTIM_TimerCfgTypeDef .............................................................. 281
21.1.10
HRTIM_CompareCfgTypeDef ........................................................ 283
21.1.11
HRTIM_CaptureCfgTypeDef .......................................................... 283
21.1.12
HRTIM_OutputCfgTypeDef ............................................................ 283
21.1.13
HRTIM_TimerEventFilteringCfgTypeDef ........................................ 284
21.1.14
HRTIM_DeadTimeCfgTypeDef ...................................................... 285
21.1.15
HRTIM_ChopperModeCfgTypeDef ................................................ 286
21.1.16
HRTIM_EventCfgTypeDef .............................................................. 286
21.1.17
HRTIM_FaultCfgTypeDef ............................................................... 287
21.1.18
HRTIM_BurstModeCfgTypeDef ..................................................... 287
21.1.19
HRTIM_ADCTriggerCfgTypeDef .................................................... 288
HRTIM Firmware driver API description ........................................ 288
21.2.1
Simple mode v.s. waveform mode ................................................. 288
21.2.2
How to use this driver ..................................................................... 289
21.2.3
Initialization and Time Base Configuration functions ..................... 292
21.2.4
Simple time base mode functions .................................................. 293
21.2.5
Simple output compare functions ................................................... 293
21.2.6
Simple PWM output functions ........................................................ 294
21.2.7
Simple input capture functions ....................................................... 294
21.2.8
Simple one pulse functions ............................................................ 294
21.2.9
HRTIM configuration functions ....................................................... 295
21.2.10
HRTIM timer configuration and control functions ........................... 295
21.2.11
Peripheral State functions .............................................................. 296
21.2.12
HAL_HRTIM_Init ............................................................................ 297
21.2.13
HAL_HRTIM_DeInit ........................................................................ 297
21.2.14
HAL_HRTIM_MspInit...................................................................... 297
21.2.15
HAL_HRTIM_MspDeInit ................................................................. 297
21.2.16
HAL_HRTIM_DLLCalibrationStart .................................................. 297
21.2.17
HAL_HRTIM_DLLCalibrationStart_IT ............................................ 298
21.2.18
HAL_HRTIM_PollForDLLCalibration .............................................. 298
21.2.19
HAL_HRTIM_TimeBaseConfig ...................................................... 299
21.2.20
HAL_HRTIM_SimpleBaseStart ...................................................... 299
21.2.21
HAL_HRTIM_SimpleBaseStop ...................................................... 299
21.2.22
HAL_HRTIM_SimpleBaseStart_IT ................................................. 300
DOCID026526 Rev 2
13/861
Contents
14/861
21.2.23
UM1786
HAL_HRTIM_SimpleBaseStop_IT ................................................. 300
21.2.24
HAL_HRTIM_SimpleBaseStart_DMA ............................................ 300
21.2.25
HAL_HRTIM_SimpleBaseStop_DMA ............................................ 301
21.2.26
HAL_HRTIM_SimpleOCChannelConfig ......................................... 301
21.2.27
HAL_HRTIM_SimpleOCStart ......................................................... 302
21.2.28
HAL_HRTIM_SimpleOCStop ......................................................... 302
21.2.29
HAL_HRTIM_SimpleOCStart_IT .................................................... 303
21.2.30
HAL_HRTIM_SimpleOCStop_IT .................................................... 304
21.2.31
HAL_HRTIM_SimpleOCStart_DMA ............................................... 304
21.2.32
HAL_HRTIM_SimpleOCStop_DMA ............................................... 305
21.2.33
HAL_HRTIM_SimplePWMChannelConfig ..................................... 305
21.2.34
HAL_HRTIM_SimplePWMStart ...................................................... 306
21.2.35
HAL_HRTIM_SimplePWMStop ...................................................... 307
21.2.36
HAL_HRTIM_SimplePWMStart_IT ................................................ 307
21.2.37
HAL_HRTIM_SimplePWMStop_IT ................................................. 308
21.2.38
HAL_HRTIM_SimplePWMStart_DMA............................................ 308
21.2.39
HAL_HRTIM_SimplePWMStop_DMA ............................................ 309
21.2.40
HAL_HRTIM_SimpleCaptureChannelConfig ................................. 310
21.2.41
HAL_HRTIM_SimpleCaptureStart .................................................. 310
21.2.42
HAL_HRTIM_SimpleCaptureStop .................................................. 311
21.2.43
HAL_HRTIM_SimpleCaptureStart_IT ............................................ 311
21.2.44
HAL_HRTIM_SimpleCaptureStop_IT ............................................. 311
21.2.45
HAL_HRTIM_SimpleCaptureStart_DMA........................................ 312
21.2.46
HAL_HRTIM_SimpleCaptureStop_DMA ........................................ 312
21.2.47
HAL_HRTIM_SimpleOnePulseChannelConfig .............................. 313
21.2.48
HAL_HRTIM_SimpleOnePulseStart ............................................... 314
21.2.49
HAL_HRTIM_SimpleOnePulseStop ............................................... 314
21.2.50
HAL_HRTIM_SimpleOnePulseStart_IT ......................................... 315
21.2.51
HAL_HRTIM_SimpleOnePulseStop_IT.......................................... 315
21.2.52
HAL_HRTIM_BurstModeConfig ..................................................... 316
21.2.53
HAL_HRTIM_EventConfig ............................................................. 316
21.2.54
HAL_HRTIM_EventPrescalerConfig .............................................. 317
21.2.55
HAL_HRTIM_FaultConfig ............................................................... 317
21.2.56
HAL_HRTIM_FaultPrescalerConfig ............................................... 317
21.2.57
HAL_HRTIM_FaultModeCtl ............................................................ 318
21.2.58
HAL_HRTIM_ADCTriggerConfig .................................................... 318
21.2.59
HAL_HRTIM_WaveformTimerConfig ............................................. 318
21.2.60
HAL_HRTIM_TimerEventFilteringConfig ....................................... 319
21.2.61
HAL_HRTIM_DeadTimeConfig ...................................................... 319
DOCID026526 Rev 2
UM1786
Contents
21.2.62
HAL_HRTIM_ChopperModeConfig ................................................ 320
21.2.63
HAL_HRTIM_BurstDMAConfig ...................................................... 320
21.2.64
HAL_HRTIM_WaveformCompareConfig ....................................... 321
21.2.65
HAL_HRTIM_WaveformCaptureConfig ......................................... 322
21.2.66
HAL_HRTIM_WaveformOutputConfig ........................................... 322
21.2.67
HAL_HRTIM_WaveformSetOutputLevel ........................................ 323
21.2.68
HAL_HRTIM_WaveformOutputStart .............................................. 324
21.2.69
HAL_HRTIM_WaveformOutputStop .............................................. 324
21.2.70
HAL_HRTIM_WaveformCounterStart ............................................ 324
21.2.71
HAL_HRTIM_WaveformCounterStop ............................................ 325
21.2.72
HAL_HRTIM_WaveformCounterStart_IT ....................................... 325
21.2.73
HAL_HRTIM_WaveformCounterStop_IT ....................................... 326
21.2.74
HAL_HRTIM_WaveformCounterStart_DMA .................................. 326
21.2.75
HAL_HRTIM_WaveformCounterStop_DMA .................................. 326
21.2.76
HAL_HRTIM_BurstModeCtl ........................................................... 327
21.2.77
HAL_HRTIM_BurstModeSoftwareTrigger ...................................... 327
21.2.78
HAL_HRTIM_SoftwareCapture ...................................................... 327
21.2.79
HAL_HRTIM_SoftwareUpdate ....................................................... 328
21.2.80
HAL_HRTIM_SoftwareReset ......................................................... 328
21.2.81
HAL_HRTIM_BurstDMATransfer ................................................... 329
21.2.82
HAL_HRTIM_UpdateEnable .......................................................... 329
21.2.83
HAL_HRTIM_UpdateDisable ......................................................... 330
21.2.84
HAL_HRTIM_GetState ................................................................... 330
21.2.85
HAL_HRTIM_GetCapturedValue ................................................... 330
21.2.86
HAL_HRTIM_WaveformGetOutputLevel ....................................... 330
21.2.87
HAL_HRTIM_WaveformGetOutputState........................................ 331
21.2.88
HAL_HRTIM_GetDelayedProtectionStatus.................................... 332
21.2.89
HAL_HRTIM_GetBurstStatus ......................................................... 332
21.2.90
HAL_HRTIM_GetCurrentPushPullStatus ....................................... 332
21.2.91
HAL_HRTIM_GetIdlePushPullStatus ............................................. 333
21.2.92
HAL_HRTIM_IRQHandler .............................................................. 333
21.2.93
HAL_HRTIM_Fault1Callback ......................................................... 333
21.2.94
HAL_HRTIM_Fault2Callback ......................................................... 334
21.2.95
HAL_HRTIM_Fault3Callback ......................................................... 334
21.2.96
HAL_HRTIM_Fault4Callback ......................................................... 334
21.2.97
HAL_HRTIM_Fault5Callback ......................................................... 334
21.2.98
HAL_HRTIM_SystemFaultCallback ............................................... 334
21.2.99
HAL_HRTIM_DLLCalbrationReadyCallback .................................. 335
DOCID026526 Rev 2
15/861
Contents
UM1786
21.2.100 HAL_HRTIM_BurstModePeriodCallback ....................................... 335
21.2.101 HAL_HRTIM_SynchronizationEventCallback ................................ 335
21.2.102 HAL_HRTIM_RegistersUpdateCallback ........................................ 335
21.2.103 HAL_HRTIM_RepetitionEventCallback .......................................... 336
21.2.104 HAL_HRTIM_Compare1EventCallback ......................................... 336
21.2.105 HAL_HRTIM_Compare2EventCallback ......................................... 336
21.2.106 HAL_HRTIM_Compare3EventCallback ......................................... 337
21.2.107 HAL_HRTIM_Compare4EventCallback ......................................... 337
21.2.108 HAL_HRTIM_Capture1EventCallback ........................................... 337
21.2.109 HAL_HRTIM_Capture2EventCallback ........................................... 338
21.2.110 HAL_HRTIM_DelayedProtectionCallback ...................................... 338
21.2.111 HAL_HRTIM_CounterResetCallback ............................................. 338
21.2.112 HAL_HRTIM_Output1SetCallback ................................................. 339
21.2.113 HAL_HRTIM_Output1ResetCallback ............................................. 339
21.2.114 HAL_HRTIM_Output2SetCallback ................................................. 339
21.2.115 HAL_HRTIM_Output2ResetCallback ............................................. 340
21.2.116 HAL_HRTIM_BurstDMATransferCallback ..................................... 340
21.2.117 HAL_HRTIM_ErrorCallback ........................................................... 340
21.3
HRTIM Firmware driver defines .................................................... 340
21.3.1
22
HAL I2C Generic Driver ............................................................... 383
22.1
22.2
16/861
HRTIM ............................................................................................ 340
I2C Firmware driver registers structures ....................................... 383
22.1.1
I2C_InitTypeDef .............................................................................. 383
22.1.2
I2C_HandleTypeDef ....................................................................... 383
I2C Firmware driver API description .............................................. 384
22.2.1
How to use this driver ..................................................................... 384
22.2.2
Initialization and de-initialization functions ..................................... 387
22.2.3
IO operation functions .................................................................... 388
22.2.4
Peripheral State and Errors functions ............................................ 389
22.2.5
HAL_I2C_Init .................................................................................. 389
22.2.6
HAL_I2C_DeInit .............................................................................. 389
22.2.7
HAL_I2C_MspInit ........................................................................... 390
22.2.8
HAL_I2C_MspDeInit ....................................................................... 390
22.2.9
HAL_I2C_Master_Transmit ............................................................ 390
22.2.10
HAL_I2C_Master_Receive ............................................................. 390
22.2.11
HAL_I2C_Slave_Transmit .............................................................. 391
22.2.12
HAL_I2C_Slave_Receive ............................................................... 391
22.2.13
HAL_I2C_Master_Transmit_IT ....................................................... 391
DOCID026526 Rev 2
UM1786
Contents
22.3
22.2.14
HAL_I2C_Master_Receive_IT ........................................................ 392
22.2.15
HAL_I2C_Slave_Transmit_IT ......................................................... 392
22.2.16
HAL_I2C_Slave_Receive_IT .......................................................... 392
22.2.17
HAL_I2C_Master_Transmit_DMA .................................................. 392
22.2.18
HAL_I2C_Master_Receive_DMA ................................................... 393
22.2.19
HAL_I2C_Slave_Transmit_DMA .................................................... 393
22.2.20
HAL_I2C_Slave_Receive_DMA ..................................................... 393
22.2.21
HAL_I2C_Mem_Write..................................................................... 394
22.2.22
HAL_I2C_Mem_Read .................................................................... 394
22.2.23
HAL_I2C_Mem_Write_IT ............................................................... 394
22.2.24
HAL_I2C_Mem_Read_IT ............................................................... 395
22.2.25
HAL_I2C_Mem_Write_DMA .......................................................... 395
22.2.26
HAL_I2C_Mem_Read_DMA .......................................................... 396
22.2.27
HAL_I2C_IsDeviceReady ............................................................... 396
22.2.28
HAL_I2C_EV_IRQHandler ............................................................. 396
22.2.29
HAL_I2C_ER_IRQHandler ............................................................. 396
22.2.30
HAL_I2C_MasterTxCpltCallback .................................................... 397
22.2.31
HAL_I2C_MasterRxCpltCallback ................................................... 397
22.2.32
HAL_I2C_SlaveTxCpltCallback ...................................................... 397
22.2.33
HAL_I2C_SlaveRxCpltCallback ..................................................... 397
22.2.34
HAL_I2C_MemTxCpltCallback ....................................................... 398
22.2.35
HAL_I2C_MemRxCpltCallback ...................................................... 398
22.2.36
HAL_I2C_ErrorCallback ................................................................. 398
22.2.37
HAL_I2C_GetState ......................................................................... 398
22.2.38
HAL_I2C_GetError ......................................................................... 398
I2C Firmware driver defines .......................................................... 399
22.3.1
23
I2C .................................................................................................. 399
HAL I2C Extension Driver ........................................................... 405
23.1
23.2
I2CEx Firmware driver API description ......................................... 405
23.1.1
I2C peripheral Extended features ................................................... 405
23.1.2
How to use this driver ..................................................................... 405
23.1.3
Extended features functions ........................................................... 405
23.1.4
HAL_I2CEx_AnalogFilter_Config ................................................... 405
23.1.5
HAL_I2CEx_DigitalFilter_Config .................................................... 406
23.1.6
HAL_I2CEx_EnableWakeUp .......................................................... 406
23.1.7
HAL_I2CEx_DisableWakeUp ......................................................... 406
I2CEx Firmware driver defines ...................................................... 406
23.2.1
I2CEx .............................................................................................. 406
DOCID026526 Rev 2
17/861
Contents
24
UM1786
HAL I2S Generic Driver ............................................................... 407
24.1
24.2
24.3
I2S Firmware driver registers structures ....................................... 407
24.1.1
I2S_InitTypeDef .............................................................................. 407
24.1.2
I2S_HandleTypeDef ....................................................................... 407
I2S Firmware driver API description .............................................. 408
24.2.1
How to use this driver ..................................................................... 408
24.2.2
Initialization and de-initialization functions ..................................... 410
24.2.3
IO operation functions .................................................................... 411
24.2.4
Peripheral State and Errors functions ............................................ 411
24.2.5
HAL_I2S_Init .................................................................................. 412
24.2.6
HAL_I2S_DeInit .............................................................................. 412
24.2.7
HAL_I2S_MspInit............................................................................ 412
24.2.8
HAL_I2S_MspDeInit ....................................................................... 412
24.2.9
HAL_I2S_Transmit ......................................................................... 413
24.2.10
HAL_I2S_Receive .......................................................................... 413
24.2.11
HAL_I2S_Transmit_IT .................................................................... 413
24.2.12
HAL_I2S_Receive_IT ..................................................................... 414
24.2.13
HAL_I2S_Transmit_DMA ............................................................... 414
24.2.14
HAL_I2S_Receive_DMA ................................................................ 415
24.2.15
HAL_I2S_IRQHandler .................................................................... 415
24.2.16
HAL_I2S_TxHalfCpltCallback ........................................................ 415
24.2.17
HAL_I2S_TxCpltCallback ............................................................... 416
24.2.18
HAL_I2S_RxHalfCpltCallback ........................................................ 416
24.2.19
HAL_I2S_RxCpltCallback .............................................................. 416
24.2.20
HAL_I2S_ErrorCallback ................................................................. 416
24.2.21
HAL_I2S_FullDuplex_IRQHandler ................................................. 417
24.2.22
HAL_I2S_TxRxCpltCallback .......................................................... 417
24.2.23
HAL_I2S_GetState ......................................................................... 417
24.2.24
HAL_I2S_GetError ......................................................................... 417
24.2.25
HAL_I2S_DMAPause ..................................................................... 417
24.2.26
HAL_I2S_DMAResume .................................................................. 418
24.2.27
HAL_I2S_DMAStop ........................................................................ 418
I2S Firmware driver defines .......................................................... 418
24.3.1
25
HAL I2S Extension Driver ........................................................... 423
25.1
18/861
I2S .................................................................................................. 418
I2SEx Firmware driver API description .......................................... 423
25.1.1
I2S Extended features .................................................................... 423
25.1.2
How to use this driver ..................................................................... 423
DOCID026526 Rev 2
UM1786
Contents
25.2
25.1.3
Extended features Functions .......................................................... 424
25.1.4
HAL_I2SEx_TransmitReceive ........................................................ 424
25.1.5
HAL_I2SEx_TransmitReceive_IT ................................................... 425
25.1.6
HAL_I2SEx_TransmitReceive_DMA .............................................. 425
I2SEx Firmware driver defines ...................................................... 426
25.2.1
26
HAL IRDA Generic Driver ............................................................ 429
26.1
26.2
26.3
IRDA Firmware driver registers structures .................................... 429
26.1.1
IRDA_InitTypeDef ........................................................................... 429
26.1.2
IRDA_HandleTypeDef .................................................................... 429
IRDA Firmware driver API description ........................................... 430
26.2.1
How to use this driver ..................................................................... 430
26.2.2
Initialization and Configuration functions ........................................ 432
26.2.3
IO operation functions .................................................................... 433
26.2.4
Peripheral State and Error functions .............................................. 434
26.2.5
HAL_IRDA_Init ............................................................................... 434
26.2.6
HAL_IRDA_DeInit........................................................................... 434
26.2.7
HAL_IRDA_MspInit ........................................................................ 434
26.2.8
HAL_IRDA_MspDeInit .................................................................... 434
26.2.9
HAL_IRDA_Transmit ...................................................................... 435
26.2.10
HAL_IRDA_Receive ....................................................................... 435
26.2.11
HAL_IRDA_Transmit_IT ................................................................. 435
26.2.12
HAL_IRDA_Receive_IT .................................................................. 435
26.2.13
HAL_IRDA_Transmit_DMA ............................................................ 436
26.2.14
HAL_IRDA_Receive_DMA ............................................................. 436
26.2.15
HAL_IRDA_IRQHandler ................................................................. 436
26.2.16
HAL_IRDA_TxCpltCallback ............................................................ 436
26.2.17
HAL_IRDA_RxCpltCallback ........................................................... 437
26.2.18
HAL_IRDA_ErrorCallback .............................................................. 437
26.2.19
HAL_IRDA_GetState ...................................................................... 437
26.2.20
HAL_IRDA_GetError ...................................................................... 437
IRDA Firmware driver defines ....................................................... 437
26.3.1
27
IRDA ............................................................................................... 437
HAL IRDA Extension Driver ........................................................ 445
27.1
IRDAEx Firmware driver defines ................................................... 445
27.1.1
28
I2SEx .............................................................................................. 426
IRDAEx ........................................................................................... 445
HAL IWDG Generic Driver ........................................................... 446
DOCID026526 Rev 2
19/861
Contents
UM1786
28.1
28.2
28.3
IWDG Firmware driver registers structures ................................... 446
28.1.1
IWDG_InitTypeDef ......................................................................... 446
28.1.2
IWDG_HandleTypeDef ................................................................... 446
IWDG Firmware driver API description ......................................... 447
28.2.1
IWDG specific features ................................................................... 447
28.2.2
How to use this driver ..................................................................... 447
28.2.3
Initialization functions ..................................................................... 448
28.2.4
IO operation functions .................................................................... 448
28.2.5
Peripheral State functions .............................................................. 448
28.2.6
HAL_IWDG_Init .............................................................................. 448
28.2.7
HAL_IWDG_MspInit ....................................................................... 449
28.2.8
HAL_IWDG_Start ........................................................................... 449
28.2.9
HAL_IWDG_Refresh ...................................................................... 449
28.2.10
HAL_IWDG_GetState..................................................................... 449
IWDG Firmware driver defines ...................................................... 449
28.3.1
29
HAL NAND Generic Driver .......................................................... 453
29.1
29.2
20/861
IWDG .............................................................................................. 450
NAND Firmware driver registers structures ................................... 453
29.1.1
NAND_IDTypeDef .......................................................................... 453
29.1.2
NAND_AddressTypedef ................................................................. 453
29.1.3
NAND_InfoTypeDef ........................................................................ 453
29.1.4
NAND_HandleTypeDef .................................................................. 454
NAND Firmware driver API description ......................................... 454
29.2.1
How to use this driver ..................................................................... 455
29.2.2
NAND Initialization and de-initialization functions .......................... 455
29.2.3
NAND Input and Output functions .................................................. 455
29.2.4
NAND Control functions ................................................................. 456
29.2.5
NAND State functions..................................................................... 456
29.2.6
HAL_NAND_Init .............................................................................. 456
29.2.7
HAL_NAND_DeInit ......................................................................... 456
29.2.8
HAL_NAND_MspInit ....................................................................... 457
29.2.9
HAL_NAND_MspDeInit .................................................................. 457
29.2.10
HAL_NAND_IRQHandler ............................................................... 457
29.2.11
HAL_NAND_ITCallback ................................................................. 457
29.2.12
HAL_NAND_Read_ID .................................................................... 457
29.2.13
HAL_NAND_Reset ......................................................................... 458
29.2.14
HAL_NAND_Read_Page ............................................................... 458
29.2.15
HAL_NAND_Write_Page................................................................ 458
DOCID026526 Rev 2
UM1786
Contents
29.3
29.2.16
HAL_NAND_Read_SpareArea ...................................................... 458
29.2.17
HAL_NAND_Write_SpareArea ....................................................... 459
29.2.18
HAL_NAND_Erase_Block .............................................................. 459
29.2.19
HAL_NAND_Read_Status ............................................................. 459
29.2.20
HAL_NAND_Address_Inc .............................................................. 460
29.2.21
HAL_NAND_ECC_Enable ............................................................. 460
29.2.22
HAL_NAND_ECC_Disable ............................................................. 460
29.2.23
HAL_NAND_GetECC ..................................................................... 460
29.2.24
HAL_NAND_GetState .................................................................... 461
29.2.25
HAL_NAND_Read_Status ............................................................. 461
NAND Firmware driver defines...................................................... 461
29.3.1
30
NAND.............................................................................................. 461
HAL NOR Generic Driver............................................................. 463
30.1
30.2
NOR Firmware driver registers structures ..................................... 463
30.1.1
NOR_IDTypeDef ............................................................................ 463
30.1.2
NOR_CFITypeDef .......................................................................... 463
30.1.3
NOR_HandleTypeDef..................................................................... 464
NOR Firmware driver API description ........................................... 464
30.2.1
How to use this driver ..................................................................... 464
30.2.2
NOR Initialization and de_initialization functions ........................... 465
30.2.3
NOR Input and Output functions .................................................... 465
30.2.4
NOR Control functions.................................................................... 465
30.2.5
NOR State functions ....................................................................... 465
30.2.6
HAL_NOR_Init ................................................................................ 466
30.2.7
HAL_NOR_DeInit ........................................................................... 466
30.2.8
HAL_NOR_MspInit ......................................................................... 466
30.2.9
HAL_NOR_MspDeInit .................................................................... 466
30.2.10
HAL_NOR_MspWait....................................................................... 466
30.2.11
HAL_NOR_Read_ID ...................................................................... 467
30.2.12
HAL_NOR_ReturnToReadMode .................................................... 467
30.2.13
HAL_NOR_Read ............................................................................ 467
30.2.14
HAL_NOR_Program ....................................................................... 467
30.2.15
HAL_NOR_ReadBuffer .................................................................. 468
30.2.16
HAL_NOR_ProgramBuffer ............................................................. 468
30.2.17
HAL_NOR_Erase_Block ................................................................ 468
30.2.18
HAL_NOR_Erase_Chip .................................................................. 469
30.2.19
HAL_NOR_Read_CFI .................................................................... 469
30.2.20
HAL_NOR_WriteOperation_Enable ............................................... 469
DOCID026526 Rev 2
21/861
Contents
30.3
30.2.21
UM1786
HAL_NOR_WriteOperation_Disable .............................................. 469
30.2.22
HAL_NOR_GetState ...................................................................... 470
30.2.23
HAL_NOR_GetStatus..................................................................... 470
NOR Firmware driver defines ........................................................ 470
30.3.1
31
HAL OPAMP Generic Driver ....................................................... 472
31.1
31.2
31.3
OPAMP Firmware driver registers structures ................................ 472
31.1.1
OPAMP_InitTypeDef ...................................................................... 472
31.1.2
OPAMP_HandleTypeDef................................................................ 473
OPAMP Firmware driver API description ...................................... 473
31.2.1
OPAMP Peripheral Features .......................................................... 474
31.2.2
How to use this driver ..................................................................... 475
31.2.3
Initialization and de-initialization functions ..................................... 476
31.2.4
IO operation functions .................................................................... 476
31.2.5
Peripheral Control functions ........................................................... 476
31.2.6
Peripheral State functions .............................................................. 476
31.2.7
HAL_OPAMP_Init ........................................................................... 476
31.2.8
HAL_OPAMP_DeInit ...................................................................... 477
31.2.9
HAL_OPAMP_MspInit .................................................................... 477
31.2.10
HAL_OPAMP_MspDeInit ............................................................... 477
31.2.11
HAL_OPAMP_Start ........................................................................ 477
31.2.12
HAL_OPAMP_Stop ........................................................................ 477
31.2.13
HAL_OPAMP_SelfCalibrate ........................................................... 478
31.2.14
HAL_OPAMP_Lock ........................................................................ 478
31.2.15
HAL_OPAMP_GetState ................................................................. 478
31.2.16
HAL_OPAMP_GetTrimOffset ......................................................... 478
OPAMP Firmware driver defines ................................................... 479
31.3.1
32
OPAMPEx Firmware driver API description .................................. 482
32.1.1
32.2
HAL_OPAMPEx_SelfCalibrateAll ................................................... 482
OPAMPEx Firmware driver defines............................................... 482
32.2.1
OPAMPEx ...................................................................................... 482
HAL PCCARD Generic Driver ..................................................... 483
33.1
PCCARD Firmware driver registers structures .............................. 483
33.1.1
33.2
22/861
OPAMP ........................................................................................... 479
HAL OPAMP Extension Driver .................................................... 482
32.1
33
NOR ................................................................................................ 470
PCCARD_HandleTypeDef ............................................................. 483
PCCARD Firmware driver API description .................................... 483
DOCID026526 Rev 2
UM1786
Contents
33.2.1
How to use this driver ..................................................................... 483
33.2.2
PCCARD Initialization and de-initialization functions ..................... 484
33.2.3
PCCARD Input Output and memory functions ............................... 484
33.2.4
PCCARD Peripheral State functions .............................................. 484
33.2.5
HAL_PCCARD_Init......................................................................... 484
33.2.6
HAL_PCCARD_DeInit .................................................................... 485
33.2.7
HAL_PCCARD_MspInit .................................................................. 485
33.2.8
HAL_PCCARD_MspDeInit ............................................................. 485
33.2.9
HAL_CF_Read_ID.......................................................................... 485
33.2.10 HAL_CF_Read_Sector ................................................................... 486
33.3
33.2.11
HAL_CF_Write_Sector ................................................................... 486
33.2.12
HAL_CF_Erase_Sector .................................................................. 486
33.2.13
HAL_CF_Reset .............................................................................. 487
33.2.14
HAL_PCCARD_IRQHandler .......................................................... 487
33.2.15
HAL_PCCARD_ITCallback ............................................................ 487
33.2.16
HAL_PCCARD_GetState ............................................................... 487
33.2.17
HAL_CF_GetStatus ........................................................................ 488
33.2.18
HAL_CF_ReadStatus ..................................................................... 488
PCCARD Firmware driver defines................................................. 488
33.3.1
34
PCCARD ........................................................................................ 488
HAL PCD Generic Driver ............................................................. 490
34.1
34.2
PCD Firmware driver registers structures ..................................... 490
34.1.1
PCD_InitTypeDef ............................................................................ 490
34.1.2
PCD_EPTypeDef ............................................................................ 490
34.1.3
PCD_HandleTypeDef ..................................................................... 491
PCD Firmware driver API description ............................................ 492
34.2.1
How to use this driver ..................................................................... 492
34.2.2
Initialization and de-initialization functions ..................................... 493
34.2.3
IO operation functions .................................................................... 493
34.2.4
Peripheral Control functions ........................................................... 493
34.2.5
Peripheral State functions .............................................................. 494
34.2.6
HAL_PCD_Init ................................................................................ 494
34.2.7
HAL_PCD_DeInit ............................................................................ 494
34.2.8
HAL_PCD_MspInit ......................................................................... 494
34.2.9
HAL_PCD_MspDeInit ..................................................................... 494
34.2.10
HAL_PCD_Start ............................................................................. 494
34.2.11
HAL_PCD_Stop .............................................................................. 495
34.2.12
HAL_PCD_IRQHandler .................................................................. 495
DOCID026526 Rev 2
23/861
Contents
34.3
34.2.13
UM1786
HAL_PCD_DataOutStageCallback ................................................ 495
34.2.14
HAL_PCD_DataInStageCallback ................................................... 495
34.2.15
HAL_PCD_SetupStageCallback .................................................... 496
34.2.16
HAL_PCD_SOFCallback ................................................................ 496
34.2.17
HAL_PCD_ResetCallback .............................................................. 496
34.2.18
HAL_PCD_SuspendCallback ......................................................... 496
34.2.19
HAL_PCD_ResumeCallback .......................................................... 496
34.2.20
HAL_PCD_ISOOUTIncompleteCallback ........................................ 497
34.2.21
HAL_PCD_ISOINIncompleteCallback ............................................ 497
34.2.22
HAL_PCD_ConnectCallback .......................................................... 497
34.2.23
HAL_PCD_DisconnectCallback ..................................................... 497
34.2.24
HAL_PCD_DevConnect ................................................................. 497
34.2.25
HAL_PCD_DevDisconnect ............................................................. 498
34.2.26
HAL_PCD_SetAddress .................................................................. 498
34.2.27
HAL_PCD_EP_Open ..................................................................... 498
34.2.28
HAL_PCD_EP_Close ..................................................................... 498
34.2.29
HAL_PCD_EP_Receive ................................................................. 499
34.2.30
HAL_PCD_EP_GetRxCount .......................................................... 499
34.2.31
HAL_PCD_EP_Transmit ................................................................ 499
34.2.32
HAL_PCD_EP_SetStall .................................................................. 499
34.2.33
HAL_PCD_EP_ClrStall................................................................... 500
34.2.34
HAL_PCD_EP_Flush ..................................................................... 500
34.2.35
HAL_PCD_ActiveRemoteWakeup ................................................. 500
34.2.36
HAL_PCD_DeActiveRemoteWakeup............................................. 500
34.2.37
HAL_PCD_GetState ....................................................................... 500
34.2.38
PCD_WritePMA .............................................................................. 501
34.2.39
PCD_ReadPMA .............................................................................. 501
PCD Firmware driver defines ........................................................ 501
34.3.1
35
HAL PCD Extension Driver ......................................................... 510
35.1
35.2
PCDEx Firmware driver API description ....................................... 510
35.1.1
Peripheral extended features methods .......................................... 510
35.1.2
HAL_PCDEx_PMAConfig .............................................................. 510
35.1.3
HAL_PCDEx_SetConnectionState ................................................. 510
PCDEx Firmware driver defines .................................................... 510
35.2.1
36
PCDEx ............................................................................................ 510
HAL PWR Generic Driver ............................................................ 512
36.1
24/861
PCD ................................................................................................ 501
PWR Firmware driver API description ........................................... 512
DOCID026526 Rev 2
UM1786
Contents
36.2
36.1.1
Initialization and de-initialization functions ..................................... 512
36.1.2
Peripheral Control functions ........................................................... 512
36.1.3
HAL_PWR_EnableBkUpAccess .................................................... 514
36.1.4
HAL_PWR_DisableBkUpAccess.................................................... 514
36.1.5
HAL_PWR_EnableWakeUpPin ...................................................... 514
36.1.6
HAL_PWR_DisableWakeUpPin ..................................................... 515
36.1.7
HAL_PWR_EnterSLEEPMode ....................................................... 515
36.1.8
HAL_PWR_EnterSTOPMode ......................................................... 515
36.1.9
HAL_PWR_EnterSTANDBYMode ................................................. 516
36.1.10
HAL_PWR_EnableBkUpAccess .................................................... 516
36.1.11
HAL_PWR_DisableBkUpAccess.................................................... 516
PWR Firmware driver defines ....................................................... 517
36.2.1
37
HAL PWR Extension Driver ........................................................ 519
37.1
PWREx Firmware driver registers structures ................................ 519
37.1.1
37.2
37.3
PWR_PVDTypeDef ........................................................................ 519
PWREx Firmware driver API description ....................................... 519
37.2.1
Peripheral Extended control functions ............................................ 519
37.2.2
HAL_PWR_PVDConfig .................................................................. 520
37.2.3
HAL_PWR_EnablePVD.................................................................. 520
37.2.4
HAL_PWR_DisablePVD ................................................................. 520
37.2.5
HAL_PWR_PVD_IRQHandler ........................................................ 521
37.2.6
HAL_PWR_PVDCallback ............................................................... 521
PWREx Firmware driver defines ................................................... 521
37.3.1
38
PWR ............................................................................................... 517
PWREx ........................................................................................... 521
HAL RCC Generic Driver ............................................................. 524
38.1
RCC Firmware driver registers structures ..................................... 524
38.1.1
38.2
RCC_ClkInitTypeDef ...................................................................... 524
RCC Firmware driver API description ........................................... 524
38.2.1
RCC specific features ..................................................................... 524
38.2.2
Initialization and de-initialization functions ..................................... 525
38.2.3
Peripheral Control functions ........................................................... 526
38.2.4
HAL_RCC_DeInit ........................................................................... 526
38.2.5
HAL_RCC_OscConfig .................................................................... 527
38.2.6
HAL_RCC_ClockConfig ................................................................. 527
38.2.7
HAL_RCC_MCOConfig .................................................................. 527
38.2.8
HAL_RCC_EnableCSS .................................................................. 528
DOCID026526 Rev 2
25/861
Contents
38.3
38.2.9
UM1786
HAL_RCC_DisableCSS ................................................................. 528
38.2.10
HAL_RCC_GetSysClockFreq ........................................................ 528
38.2.11
HAL_RCC_GetHCLKFreq .............................................................. 529
38.2.12
HAL_RCC_GetPCLK1Freq ............................................................ 529
38.2.13
HAL_RCC_GetPCLK2Freq ............................................................ 529
38.2.14
HAL_RCC_GetOscConfig .............................................................. 530
38.2.15
HAL_RCC_GetClockConfig ........................................................... 530
38.2.16
HAL_RCC_NMI_IRQHandler ......................................................... 530
38.2.17
HAL_RCC_CCSCallback ............................................................... 530
RCC Firmware driver defines ........................................................ 531
38.3.1
39
HAL RCC Extension Driver ......................................................... 546
39.1
39.2
39.3
RCCEx Firmware driver registers structures ................................. 546
39.1.1
RCC_PLLInitTypeDef ..................................................................... 546
39.1.2
RCC_OscInitTypeDef ..................................................................... 546
39.1.3
RCC_PeriphCLKInitTypeDef .......................................................... 547
RCCEx Firmware driver API description ....................................... 548
39.2.1
Extended Peripheral Control functions ........................................... 549
39.2.2
HAL_RCCEx_PeriphCLKConfig ..................................................... 549
39.2.3
HAL_RCCEx_GetPeriphCLKConfig ............................................... 549
39.2.4
HAL_RCC_OscConfig .................................................................... 550
39.2.5
HAL_RCC_GetOscConfig .............................................................. 550
39.2.6
HAL_RCC_GetSysClockFreq ........................................................ 550
RCCEx Firmware driver defines .................................................... 551
39.3.1
40
RCCEx ............................................................................................ 551
HAL RTC Generic Driver ............................................................. 570
40.1
40.2
26/861
RCC ................................................................................................ 531
RTC Firmware driver registers structures ..................................... 570
40.1.1
RTC_InitTypeDef ............................................................................ 570
40.1.2
RTC_TimeTypeDef......................................................................... 570
40.1.3
RTC_DateTypeDef ......................................................................... 571
40.1.4
RTC_AlarmTypeDef ....................................................................... 572
40.1.5
RTC_HandleTypeDef ..................................................................... 572
RTC Firmware driver API description ............................................ 573
40.2.1
RTC Operating Condition ............................................................... 573
40.2.2
Backup Domain Reset .................................................................... 573
40.2.3
Backup Domain Access.................................................................. 573
40.2.4
How to use RTC Driver................................................................... 574
DOCID026526 Rev 2
UM1786
Contents
40.3
40.2.5
RTC and low power modes ............................................................ 575
40.2.6
Initialization and de-initialization functions ..................................... 575
40.2.7
RTC Time and Date functions ........................................................ 576
40.2.8
RTC Alarm functions ...................................................................... 576
40.2.9
Peripheral Control functions ........................................................... 576
40.2.10
Peripheral State functions .............................................................. 576
40.2.11
HAL_RTC_Init ................................................................................ 576
40.2.12
HAL_RTC_DeInit ............................................................................ 576
40.2.13
HAL_RTC_MspInit.......................................................................... 577
40.2.14
HAL_RTC_MspDeInit ..................................................................... 577
40.2.15
HAL_RTC_SetTime ........................................................................ 577
40.2.16
HAL_RTC_GetTime ....................................................................... 577
40.2.17
HAL_RTC_SetDate ........................................................................ 578
40.2.18
HAL_RTC_GetDate ........................................................................ 578
40.2.19
HAL_RTC_SetAlarm ...................................................................... 578
40.2.20
HAL_RTC_SetAlarm_IT ................................................................. 579
40.2.21
HAL_RTC_DeactivateAlarm ........................................................... 579
40.2.22
HAL_RTC_GetAlarm ...................................................................... 579
40.2.23
HAL_RTC_AlarmIRQHandler ......................................................... 580
40.2.24
HAL_RTC_AlarmAEventCallback .................................................. 580
40.2.25
HAL_RTC_PollForAlarmAEvent ..................................................... 580
40.2.26
HAL_RTC_WaitForSynchro ........................................................... 580
40.2.27
HAL_RTC_GetState ....................................................................... 581
RTC Firmware driver defines ........................................................ 581
40.3.1
41
RTC ................................................................................................ 581
HAL RTC Extension Driver ......................................................... 590
41.1
RTCEx Firmware driver registers structures ................................. 590
41.1.1
41.2
RTC_TamperTypeDef .................................................................... 590
RTCEx Firmware driver API description ........................................ 590
41.2.1
How to use this driver ..................................................................... 590
41.2.2
RTC TimeStamp and Tamper functions ......................................... 591
41.2.3
RTC Wake-up functions ................................................................. 592
41.2.4
Extended Peripheral Control functions ........................................... 592
41.2.5
Extended features functions ........................................................... 592
41.2.6
HAL_RTCEx_SetTimeStamp ......................................................... 593
41.2.7
HAL_RTCEx_SetTimeStamp_IT .................................................... 593
41.2.8
HAL_RTCEx_DeactivateTimeStamp ............................................. 594
41.2.9
HAL_RTCEx_GetTimeStamp ......................................................... 594
DOCID026526 Rev 2
27/861
Contents
41.3
41.2.10
UM1786
HAL_RTCEx_SetTamper ............................................................... 594
41.2.11
HAL_RTCEx_SetTamper_IT .......................................................... 594
41.2.12
HAL_RTCEx_DeactivateTamper ................................................... 595
41.2.13
HAL_RTCEx_TamperTimeStampIRQHandler ............................... 595
41.2.14
HAL_RTCEx_TimeStampEventCallback ....................................... 595
41.2.15
HAL_RTCEx_Tamper1EventCallback ........................................... 595
41.2.16
HAL_RTCEx_Tamper2EventCallback ........................................... 596
41.2.17
HAL_RTCEx_Tamper3EventCallback ........................................... 596
41.2.18
HAL_RTCEx_PollForTimeStampEvent .......................................... 596
41.2.19
HAL_RTCEx_PollForTamper1Event .............................................. 596
41.2.20
HAL_RTCEx_PollForTamper2Event .............................................. 596
41.2.21
HAL_RTCEx_PollForTamper3Event .............................................. 597
41.2.22
HAL_RTCEx_SetWakeUpTimer .................................................... 597
41.2.23
HAL_RTCEx_SetWakeUpTimer_IT ............................................... 597
41.2.24
HAL_RTCEx_DeactivateWakeUpTimer ......................................... 597
41.2.25
HAL_RTCEx_GetWakeUpTimer .................................................... 598
41.2.26
HAL_RTCEx_WakeUpTimerIRQHandler ....................................... 598
41.2.27
HAL_RTCEx_WakeUpTimerEventCallback ................................... 598
41.2.28
HAL_RTCEx_PollForWakeUpTimerEvent ..................................... 598
41.2.29
HAL_RTCEx_BKUPWrite ............................................................... 598
41.2.30
HAL_RTCEx_BKUPRead .............................................................. 599
41.2.31
HAL_RTCEx_SetSmoothCalib ....................................................... 599
41.2.32
HAL_RTCEx_SetSynchroShift ....................................................... 600
41.2.33
HAL_RTCEx_SetCalibrationOutPut ............................................... 600
41.2.34
HAL_RTCEx_DeactivateCalibrationOutPut ................................... 600
41.2.35
HAL_RTCEx_SetRefClock ............................................................. 601
41.2.36
HAL_RTCEx_DeactivateRefClock ................................................. 601
41.2.37
HAL_RTCEx_EnableBypassShadow ............................................. 601
41.2.38
HAL_RTCEx_DisableBypassShadow ............................................ 601
41.2.39
HAL_RTCEx_AlarmBEventCallback .............................................. 601
41.2.40
HAL_RTCEx_PollForAlarmBEvent ................................................ 602
RTCEx Firmware driver defines .................................................... 602
41.3.1
42
HAL SDADC Generic Driver ........................................................ 613
42.1
28/861
RTCEx ............................................................................................ 602
SDADC Firmware driver registers structures ................................ 613
42.1.1
SDADC_InitTypeDef....................................................................... 613
42.1.2
SDADC_HandleTypeDef ................................................................ 613
42.1.3
SDADC_ConfParamTypeDef ......................................................... 614
DOCID026526 Rev 2
UM1786
Contents
42.2
SDADC Firmware driver API description ....................................... 615
42.2.1
SDADC specific features ................................................................ 615
42.2.2
How to use this driver ..................................................................... 615
42.2.3
Initialization and de-initialization functions ..................................... 617
42.2.4
Peripheral control functions ............................................................ 618
42.2.5
IO operation functions .................................................................... 618
42.2.6
ADC Peripheral State functions ...................................................... 619
42.2.7
HAL_SDADC_Init ........................................................................... 619
42.2.8
HAL_SDADC_DeInit....................................................................... 619
42.2.9
HAL_SDADC_MspInit .................................................................... 620
42.2.10
HAL_SDADC_MspDeInit ................................................................ 620
42.2.11
HAL_SDADC_PrepareChannelConfig ........................................... 620
42.2.12
HAL_SDADC_AssociateChannelConfig ........................................ 620
42.2.13
HAL_SDADC_ConfigChannel ........................................................ 621
42.2.14
HAL_SDADC_InjectedConfigChannel ........................................... 621
42.2.15
HAL_SDADC_SelectRegularTrigger .............................................. 621
42.2.16
HAL_SDADC_SelectInjectedTrigger .............................................. 622
42.2.17
HAL_SDADC_SelectInjectedExtTrigger ......................................... 622
42.2.18
HAL_SDADC_SelectInjectedDelay ................................................ 623
42.2.19
HAL_SDADC_MultiModeConfigChannel ....................................... 623
42.2.20
HAL_SDADC_InjectedMultiModeConfigChannel ........................... 623
42.2.21 HAL_SDADC_CalibrationStart ....................................................... 624
42.2.22
HAL_SDADC_PollForCalibEvent ................................................... 624
42.2.23
HAL_SDADC_CalibrationStart_IT .................................................. 624
42.2.24
HAL_SDADC_Start ........................................................................ 624
42.2.25
HAL_SDADC_PollForConversion .................................................. 625
42.2.26
HAL_SDADC_Stop......................................................................... 625
42.2.27
HAL_SDADC_Start_IT ................................................................... 625
42.2.28
HAL_SDADC_Stop_IT ................................................................... 625
42.2.29
HAL_SDADC_Start_DMA .............................................................. 626
42.2.30
HAL_SDADC_Stop_DMA .............................................................. 626
42.2.31
HAL_SDADC_GetValue ................................................................. 626
42.2.32
HAL_SDADC_InjectedStart ............................................................ 626
42.2.33
HAL_SDADC_PollForInjectedConversion...................................... 627
42.2.34
HAL_SDADC_InjectedStop ............................................................ 627
42.2.35
HAL_SDADC_InjectedStart_IT ...................................................... 627
42.2.36
HAL_SDADC_InjectedStop_IT ....................................................... 628
42.2.37
HAL_SDADC_InjectedStart_DMA .................................................. 628
DOCID026526 Rev 2
29/861
Contents
42.3
42.2.38
UM1786
HAL_SDADC_InjectedStop_DMA .................................................. 628
42.2.39
HAL_SDADC_InjectedGetValue .................................................... 628
42.2.40
HAL_SDADC_MultiModeStart_DMA.............................................. 629
42.2.41
HAL_SDADC_MultiModeStop_DMA .............................................. 629
42.2.42
HAL_SDADC_MultiModeGetValue ................................................ 629
42.2.43
HAL_SDADC_InjectedMultiModeStart_DMA ................................. 629
42.2.44
HAL_SDADC_InjectedMultiModeStop_DMA ................................. 630
42.2.45
HAL_SDADC_InjectedMultiModeGetValue.................................... 630
42.2.46
HAL_SDADC_IRQHandler ............................................................. 630
42.2.47
HAL_SDADC_CalibrationCpltCallback .......................................... 630
42.2.48
HAL_SDADC_ConvHalfCpltCallback ............................................. 631
42.2.49
HAL_SDADC_ConvCpltCallback ................................................... 631
42.2.50
HAL_SDADC_InjectedConvHalfCpltCallback ................................ 631
42.2.51
HAL_SDADC_InjectedConvCpltCallback ....................................... 631
42.2.52
HAL_SDADC_ErrorCallback .......................................................... 632
42.2.53
HAL_SDADC_GetState .................................................................. 632
42.2.54
HAL_SDADC_GetError .................................................................. 632
SDADC Firmware driver defines ................................................... 632
42.3.1
43
HAL SMARTCARD Generic Driver.............................................. 639
43.1
43.2
30/861
SDADC ........................................................................................... 632
SMARTCARD Firmware driver registers structures ...................... 639
43.1.1
SMARTCARD_InitTypeDef ............................................................ 639
43.1.2
SMARTCARD_AdvFeatureInitTypeDef .......................................... 640
43.1.3
SMARTCARD_HandleTypeDef ...................................................... 641
SMARTCARD Firmware driver API description............................. 642
43.2.1
How to use this driver ..................................................................... 642
43.2.2
Initialization and Configuration functions ........................................ 644
43.2.3
IO operation functions .................................................................... 645
43.2.4
Peripheral State and Errors functions ............................................ 646
43.2.5
HAL_SMARTCARD_Init ................................................................. 646
43.2.6
HAL_SMARTCARD_DeInit ............................................................ 646
43.2.7
HAL_SMARTCARD_MspInit .......................................................... 647
43.2.8
HAL_SMARTCARD_MspDeInit ..................................................... 647
43.2.9
HAL_SMARTCARD_Transmit ........................................................ 647
43.2.10
HAL_SMARTCARD_Receive ......................................................... 647
43.2.11
HAL_SMARTCARD_Transmit_IT .................................................. 648
43.2.12
HAL_SMARTCARD_Receive_IT ................................................... 648
43.2.13
HAL_SMARTCARD_Transmit_DMA.............................................. 648
DOCID026526 Rev 2
UM1786
Contents
43.3
43.2.14
HAL_SMARTCARD_Receive_DMA ............................................... 648
43.2.15
HAL_SMARTCARD_IRQHandler ................................................... 649
43.2.16
HAL_SMARTCARD_TxCpltCallback ............................................. 649
43.2.17
HAL_SMARTCARD_RxCpltCallback ............................................. 649
43.2.18
HAL_SMARTCARD_ErrorCallback ................................................ 649
43.2.19
HAL_SMARTCARD_GetState ....................................................... 649
43.2.20
HAL_SMARTCARD_GetError ........................................................ 650
SMARTCARD Firmware driver defines ......................................... 650
43.3.1
44
HAL SMARTCARD Extension Driver .......................................... 660
44.1
44.2
SMARTCARDEx Firmware driver API description ........................ 660
44.1.1
Peripheral Control functions ........................................................... 660
44.1.2
HAL_SMARTCARDEx_BlockLength_Config ................................. 660
44.1.3
HAL_SMARTCARDEx_TimeOut_Config ....................................... 660
44.1.4
HAL_SMARTCARDEx_EnableReceiverTimeOut .......................... 661
44.1.5
HAL_SMARTCARDEx_DisableReceiverTimeOut ......................... 661
SMARTCARDEx Firmware driver defines ..................................... 661
44.2.1
45
SMARTCARD ................................................................................. 650
SMARTCARDEx ............................................................................. 661
HAL SMBUS Generic Driver ........................................................ 662
45.1
45.2
SMBUS Firmware driver registers structures ................................ 662
45.1.1
SMBUS_InitTypeDef ...................................................................... 662
45.1.2
SMBUS_HandleTypeDef ................................................................ 663
SMBUS Firmware driver API description ...................................... 664
45.2.1
How to use this driver ..................................................................... 664
45.2.2
Initialization and de-initialization functions ..................................... 665
45.2.3
IO operation functions .................................................................... 666
45.2.4
Peripheral State and Errors functions ............................................ 667
45.2.5
HAL_SMBUS_Init ........................................................................... 667
45.2.6
HAL_SMBUS_DeInit ...................................................................... 667
45.2.7
HAL_SMBUS_MspInit .................................................................... 668
45.2.8
HAL_SMBUS_MspDeInit................................................................ 668
45.2.9
HAL_SMBUS_Master_Transmit_IT ............................................... 668
45.2.10
HAL_SMBUS_Master_Receive_IT ................................................ 668
45.2.11
HAL_SMBUS_Master_Abort_IT ..................................................... 669
45.2.12
HAL_SMBUS_Slave_Transmit_IT ................................................. 669
45.2.13
HAL_SMBUS_Slave_Receive_IT .................................................. 669
45.2.14
HAL_SMBUS_Slave_Listen_IT ...................................................... 670
DOCID026526 Rev 2
31/861
Contents
45.3
45.2.15
UM1786
HAL_SMBUS_DisableListen_IT ..................................................... 670
45.2.16
HAL_SMBUS_EnableAlert_IT ........................................................ 670
45.2.17
HAL_SMBUS_DisableAlert_IT ....................................................... 670
45.2.18
HAL_SMBUS_IsDeviceReady ....................................................... 671
45.2.19
HAL_SMBUS_EV_IRQHandler ...................................................... 671
45.2.20
HAL_SMBUS_ER_IRQHandler ...................................................... 671
45.2.21
HAL_SMBUS_MasterTxCpltCallback ............................................ 672
45.2.22
HAL_SMBUS_MasterRxCpltCallback ............................................ 672
45.2.23
HAL_SMBUS_SlaveTxCpltCallback .............................................. 672
45.2.24
HAL_SMBUS_SlaveRxCpltCallback .............................................. 672
45.2.25
HAL_SMBUS_SlaveAddrCallback ................................................. 672
45.2.26
HAL_SMBUS_SlaveListenCpltCallback ......................................... 673
45.2.27
HAL_SMBUS_ErrorCallback .......................................................... 673
45.2.28
HAL_SMBUS_GetState.................................................................. 673
45.2.29
HAL_SMBUS_GetError .................................................................. 674
SMBUS Firmware driver defines ................................................... 674
45.3.1
46
HAL SPI Generic Driver ............................................................... 682
46.1
46.2
32/861
SMBUS ........................................................................................... 674
SPI Firmware driver registers structures ....................................... 682
46.1.1
SPI_InitTypeDef ............................................................................. 682
46.1.2
__SPI_HandleTypeDef ................................................................... 683
SPI Firmware driver API description ............................................. 684
46.2.1
How to use this driver ..................................................................... 684
46.2.2
Initialization and de-initialization functions ..................................... 685
46.2.3
IO operation functions .................................................................... 686
46.2.4
Peripheral Control functions ........................................................... 687
46.2.5
HAL_SPI_Init .................................................................................. 687
46.2.6
HAL_SPI_DeInit ............................................................................. 687
46.2.7
HAL_SPI_MspInit ........................................................................... 687
46.2.8
HAL_SPI_MspDeInit ....................................................................... 687
46.2.9
HAL_SPI_InitExtended ................................................................... 688
46.2.10
HAL_SPI_Transmit ......................................................................... 688
46.2.11
HAL_SPI_Receive .......................................................................... 688
46.2.12
HAL_SPI_TransmitReceive ............................................................ 688
46.2.13
HAL_SPI_Transmit_IT.................................................................... 689
46.2.14
HAL_SPI_Receive_IT..................................................................... 689
46.2.15
HAL_SPI_TransmitReceive_IT ...................................................... 689
46.2.16
HAL_SPI_Transmit_DMA ............................................................... 689
DOCID026526 Rev 2
UM1786
Contents
46.3
46.2.17
HAL_SPI_Receive_DMA ................................................................ 690
46.2.18
HAL_SPI_TransmitReceive_DMA .................................................. 690
46.2.19
HAL_SPI_IRQHandler .................................................................... 690
46.2.20
HAL_SPI_TxCpltCallback .............................................................. 691
46.2.21
HAL_SPI_RxCpltCallback .............................................................. 691
46.2.22
HAL_SPI_TxRxCpltCallback .......................................................... 691
46.2.23
HAL_SPI_ErrorCallback ................................................................. 691
46.2.24
HAL_SPI_GetState......................................................................... 691
SPI Firmware driver defines .......................................................... 692
46.3.1
47
SPI .................................................................................................. 692
HAL SRAM Generic Driver .......................................................... 699
47.1
SRAM Firmware driver registers structures................................... 699
47.1.1
47.2
47.3
SRAM_HandleTypeDef .................................................................. 699
SRAM Firmware driver API description ......................................... 699
47.2.1
How to use this driver ..................................................................... 699
47.2.2
SRAM Initialization and de_initialization functions ......................... 700
47.2.3
SRAM Input and Output functions .................................................. 700
47.2.4
SRAM Control functions ................................................................. 701
47.2.5
SRAM State functions .................................................................... 701
47.2.6
HAL_SRAM_Init ............................................................................. 701
47.2.7
HAL_SRAM_DeInit ......................................................................... 701
47.2.8
HAL_SRAM_MspInit....................................................................... 701
47.2.9
HAL_SRAM_MspDeInit .................................................................. 702
47.2.10
HAL_SRAM_DMA_XferCpltCallback ............................................. 702
47.2.11
HAL_SRAM_DMA_XferErrorCallback ............................................ 702
47.2.12
HAL_SRAM_Read_8b.................................................................... 702
47.2.13
HAL_SRAM_Write_8b .................................................................... 702
47.2.14
HAL_SRAM_Read_16b.................................................................. 703
47.2.15
HAL_SRAM_Write_16b .................................................................. 703
47.2.16
HAL_SRAM_Read_32b.................................................................. 703
47.2.17
HAL_SRAM_Write_32b .................................................................. 704
47.2.18
HAL_SRAM_Read_DMA................................................................ 704
47.2.19
HAL_SRAM_Write_DMA ................................................................ 704
47.2.20
HAL_SRAM_WriteOperation_Enable ............................................. 705
47.2.21
HAL_SRAM_WriteOperation_Disable ............................................ 705
47.2.22
HAL_SRAM_GetState .................................................................... 705
SRAM Firmware driver defines ..................................................... 705
47.3.1
SRAM ............................................................................................. 705
DOCID026526 Rev 2
33/861
Contents
48
UM1786
HAL TIM Generic Driver .............................................................. 707
48.1
48.2
34/861
TIM Firmware driver registers structures ....................................... 707
48.1.1
TIM_Base_InitTypeDef ................................................................... 707
48.1.2
TIM_OC_InitTypeDef...................................................................... 707
48.1.3
TIM_OnePulse_InitTypeDef ........................................................... 708
48.1.4
TIM_IC_InitTypeDef ....................................................................... 709
48.1.5
TIM_Encoder_InitTypeDef ............................................................. 710
48.1.6
TIM_ClockConfigTypeDef .............................................................. 710
48.1.7
TIM_ClearInputConfigTypeDef ....................................................... 711
48.1.8
TIM_SlaveConfigTypeDef .............................................................. 711
48.1.9
TIM_HandleTypeDef ...................................................................... 712
TIM Firmware driver API description ............................................. 712
48.2.1
TIMER Generic features ................................................................. 712
48.2.2
How to use this driver ..................................................................... 713
48.2.3
Time Base functions ....................................................................... 714
48.2.4
Time Output Compare functions .................................................... 714
48.2.5
Time PWM functions ...................................................................... 715
48.2.6
Time Input Capture functions ......................................................... 715
48.2.7
Time One Pulse functions .............................................................. 715
48.2.8
Time Encoder functions .................................................................. 716
48.2.9
IRQ handler management .............................................................. 716
48.2.10
Peripheral Control functions ........................................................... 716
48.2.11
TIM Callbacks functions ................................................................. 717
48.2.12
Peripheral State functions .............................................................. 717
48.2.13
HAL_TIM_Base_Init ....................................................................... 717
48.2.14
HAL_TIM_Base_DeInit ................................................................... 718
48.2.15
HAL_TIM_Base_MspInit................................................................. 718
48.2.16
HAL_TIM_Base_MspDeInit ............................................................ 718
48.2.17
HAL_TIM_Base_Start..................................................................... 718
48.2.18
HAL_TIM_Base_Stop ..................................................................... 719
48.2.19
HAL_TIM_Base_Start_IT ............................................................... 719
48.2.20
HAL_TIM_Base_Stop_IT................................................................ 719
48.2.21
HAL_TIM_Base_Start_DMA .......................................................... 719
48.2.22
HAL_TIM_Base_Stop_DMA ........................................................... 719
48.2.23
HAL_TIM_OC_Init .......................................................................... 720
48.2.24
HAL_TIM_OC_DeInit...................................................................... 720
48.2.25
HAL_TIM_OC_MspInit ................................................................... 720
48.2.26
HAL_TIM_OC_MspDeInit ............................................................... 720
DOCID026526 Rev 2
UM1786
Contents
48.2.27
HAL_TIM_OC_Start ....................................................................... 720
48.2.28
HAL_TIM_OC_Stop........................................................................ 721
48.2.29
HAL_TIM_OC_Start_IT .................................................................. 721
48.2.30
HAL_TIM_OC_Stop_IT .................................................................. 721
48.2.31
HAL_TIM_OC_Start_DMA ............................................................. 722
48.2.32
HAL_TIM_OC_Stop_DMA ............................................................. 722
48.2.33
HAL_TIM_PWM_Init ....................................................................... 722
48.2.34
HAL_TIM_PWM_DeInit .................................................................. 723
48.2.35
HAL_TIM_PWM_MspInit ................................................................ 723
48.2.36
HAL_TIM_PWM_MspDeInit ........................................................... 723
48.2.37
HAL_TIM_PWM_Start .................................................................... 723
48.2.38
HAL_TIM_PWM_Stop .................................................................... 723
48.2.39
HAL_TIM_PWM_Start_IT ............................................................... 724
48.2.40
HAL_TIM_PWM_Stop_IT ............................................................... 724
48.2.41
HAL_TIM_PWM_Start_DMA .......................................................... 724
48.2.42
HAL_TIM_PWM_Stop_DMA .......................................................... 725
48.2.43
HAL_TIM_IC_Init ............................................................................ 725
48.2.44
HAL_TIM_IC_DeInit ....................................................................... 725
48.2.45
HAL_TIM_IC_MspInit ..................................................................... 725
48.2.46
HAL_TIM_IC_MspDeInit................................................................. 726
48.2.47
HAL_TIM_IC_Start ......................................................................... 726
48.2.48
HAL_TIM_IC_Stop ......................................................................... 726
48.2.49
HAL_TIM_IC_Start_IT .................................................................... 726
48.2.50
HAL_TIM_IC_Stop_IT .................................................................... 727
48.2.51
HAL_TIM_IC_Start_DMA ............................................................... 727
48.2.52
HAL_TIM_IC_Stop_DMA ............................................................... 727
48.2.53
HAL_TIM_OnePulse_Init ................................................................ 728
48.2.54
HAL_TIM_OnePulse_DeInit ........................................................... 728
48.2.55
HAL_TIM_OnePulse_MspInit ......................................................... 728
48.2.56
HAL_TIM_OnePulse_MspDeInit .................................................... 728
48.2.57
HAL_TIM_OnePulse_Start ............................................................. 729
48.2.58
HAL_TIM_OnePulse_Stop ............................................................. 729
48.2.59
HAL_TIM_OnePulse_Start_IT ........................................................ 729
48.2.60
HAL_TIM_OnePulse_Stop_IT ........................................................ 729
48.2.61
HAL_TIM_Encoder_Init .................................................................. 730
48.2.62
HAL_TIM_Encoder_DeInit ............................................................. 730
48.2.63
HAL_TIM_Encoder_MspInit ........................................................... 730
48.2.64
HAL_TIM_Encoder_MspDeInit ....................................................... 730
DOCID026526 Rev 2
35/861
Contents
48.3
48.2.65
UM1786
HAL_TIM_Encoder_Start ............................................................... 730
48.2.66
HAL_TIM_Encoder_Stop ............................................................... 731
48.2.67
HAL_TIM_Encoder_Start_IT .......................................................... 731
48.2.68
HAL_TIM_Encoder_Stop_IT .......................................................... 731
48.2.69
HAL_TIM_Encoder_Start_DMA ..................................................... 732
48.2.70
HAL_TIM_Encoder_Stop_DMA ..................................................... 732
48.2.71
HAL_TIM_IRQHandler ................................................................... 732
48.2.72
HAL_TIM_OC_ConfigChannel ....................................................... 732
48.2.73
HAL_TIM_IC_ConfigChannel ......................................................... 733
48.2.74
HAL_TIM_PWM_ConfigChannel .................................................... 733
48.2.75
HAL_TIM_OnePulse_ConfigChannel ............................................. 733
48.2.76
HAL_TIM_DMABurst_WriteStart .................................................... 734
48.2.77
HAL_TIM_DMABurst_WriteStop .................................................... 735
48.2.78
HAL_TIM_DMABurst_ReadStart .................................................... 735
48.2.79
HAL_TIM_DMABurst_ReadStop .................................................... 735
48.2.80
HAL_TIM_GenerateEvent .............................................................. 736
48.2.81
HAL_TIM_ConfigOCrefClear .......................................................... 736
48.2.82
HAL_TIM_ConfigClockSource ....................................................... 737
48.2.83
HAL_TIM_ConfigTI1Input ............................................................... 737
48.2.84
HAL_TIM_SlaveConfigSynchronization ......................................... 737
48.2.85
HAL_TIM_SlaveConfigSynchronization_IT .................................... 737
48.2.86
HAL_TIM_SlaveConfigSynchronization_DMA ............................... 738
48.2.87
HAL_TIM_ReadCapturedValue ...................................................... 738
48.2.88
HAL_TIM_PeriodElapsedCallback ................................................. 738
48.2.89
HAL_TIM_OC_DelayElapsedCallback ........................................... 739
48.2.90
HAL_TIM_IC_CaptureCallback ...................................................... 739
48.2.91
HAL_TIM_PWM_PulseFinishedCallback ....................................... 739
48.2.92
HAL_TIM_TriggerCallback ............................................................. 739
48.2.93
HAL_TIM_ErrorCallback................................................................. 739
48.2.94
HAL_TIM_Base_GetState .............................................................. 740
48.2.95
HAL_TIM_OC_GetState ................................................................. 740
48.2.96
HAL_TIM_PWM_GetState ............................................................. 740
48.2.97
HAL_TIM_IC_GetState................................................................... 740
48.2.98
HAL_TIM_OnePulse_GetState ...................................................... 740
48.2.99
HAL_TIM_Encoder_GetState ......................................................... 741
TIM Firmware driver defines.......................................................... 741
48.3.1
49
36/861
TIM.................................................................................................. 741
HAL TIM Extension Driver........................................................... 754
DOCID026526 Rev 2
UM1786
Contents
49.1
49.2
TIMEx Firmware driver registers structures................................... 754
49.1.1
TIM_HallSensor_InitTypeDef ......................................................... 754
49.1.2
TIM_BreakDeadTimeConfigTypeDef ............................................. 754
49.1.3
TIM_MasterConfigTypeDef ............................................................ 755
TIMEx Firmware driver API description ......................................... 756
49.2.1
TIMER Extended features .............................................................. 756
49.2.2
How to use this driver ..................................................................... 756
49.2.3
Timer Hall Sensor functions ........................................................... 757
49.2.4
Timer Complementary Output Compare functions ......................... 757
49.2.5
Timer Complementary PWM functions ........................................... 757
49.2.6
Timer Complementary One Pulse functions................................... 758
49.2.7
Peripheral Control functions ........................................................... 758
49.2.8
Extended Callbacks functions ........................................................ 759
49.2.9
Extended Peripheral State functions .............................................. 759
49.2.10
HAL_TIMEx_HallSensor_Init .......................................................... 759
49.2.11
HAL_TIMEx_HallSensor_DeInit ..................................................... 759
49.2.12
HAL_TIMEx_HallSensor_MspInit ................................................... 759
49.2.13
HAL_TIMEx_HallSensor_MspDeInit .............................................. 760
49.2.14
HAL_TIMEx_HallSensor_Start ....................................................... 760
49.2.15
HAL_TIMEx_HallSensor_Stop ....................................................... 760
49.2.16
HAL_TIMEx_HallSensor_Start_IT .................................................. 760
49.2.17
HAL_TIMEx_HallSensor_Stop_IT .................................................. 760
49.2.18
HAL_TIMEx_HallSensor_Start_DMA ............................................. 761
49.2.19
HAL_TIMEx_HallSensor_Stop_DMA ............................................. 761
49.2.20
HAL_TIMEx_OCN_Start................................................................. 761
49.2.21
HAL_TIMEx_OCN_Stop ................................................................. 761
49.2.22
HAL_TIMEx_OCN_Start_IT ........................................................... 762
49.2.23
HAL_TIMEx_OCN_Stop_IT ........................................................... 762
49.2.24
HAL_TIMEx_OCN_Start_DMA ...................................................... 762
49.2.25
HAL_TIMEx_OCN_Stop_DMA ....................................................... 763
49.2.26
HAL_TIMEx_PWMN_Start ............................................................. 763
49.2.27
HAL_TIMEx_PWMN_Stop ............................................................. 763
49.2.28
HAL_TIMEx_PWMN_Start_IT ........................................................ 764
49.2.29
HAL_TIMEx_PWMN_Stop_IT ........................................................ 764
49.2.30
HAL_TIMEx_PWMN_Start_DMA ................................................... 764
49.2.31
HAL_TIMEx_PWMN_Stop_DMA ................................................... 765
49.2.32
HAL_TIMEx_OnePulseN_Start ...................................................... 765
49.2.33
HAL_TIMEx_OnePulseN_Stop ...................................................... 765
DOCID026526 Rev 2
37/861
Contents
49.3
49.2.34
UM1786
HAL_TIMEx_OnePulseN_Start_IT ................................................. 766
49.2.35
HAL_TIMEx_OnePulseN_Stop_IT ................................................. 766
49.2.36
HAL_TIMEx_ConfigCommutationEvent ......................................... 766
49.2.37
HAL_TIMEx_ConfigCommutationEvent_IT .................................... 767
49.2.38
HAL_TIMEx_ConfigCommutationEvent_DMA ............................... 767
49.2.39
HAL_TIM_OC_ConfigChannel ....................................................... 768
49.2.40
HAL_TIM_PWM_ConfigChannel .................................................... 768
49.2.41
HAL_TIM_ConfigOCrefClear .......................................................... 769
49.2.42
HAL_TIMEx_MasterConfigSynchronization ................................... 769
49.2.43
HAL_TIMEx_ConfigBreakDeadTime.............................................. 769
49.2.44
HAL_TIMEx_RemapConfig ............................................................ 770
49.2.45
HAL_TIMEx_GroupChannel5 ......................................................... 771
49.2.46
HAL_TIMEx_CommutationCallback ............................................... 771
49.2.47
HAL_TIMEx_BreakCallback ........................................................... 771
49.2.48
HAL_TIMEx_HallSensor_GetState ................................................ 771
TIMEx Firmware driver defines ..................................................... 772
49.3.1
50
TIMEx ............................................................................................. 772
HAL TSC Generic Driver ............................................................. 777
50.1
50.2
TSC Firmware driver registers structures ...................................... 777
50.1.1
TSC_InitTypeDef ............................................................................ 777
50.1.2
TSC_IOConfigTypeDef................................................................... 778
50.1.3
TSC_HandleTypeDef ..................................................................... 778
TSC Firmware driver API description ............................................ 779
50.2.1
TSC specific features ..................................................................... 779
50.2.2
How to use this driver ..................................................................... 779
50.2.3
Initialization and de-initialization functions ..................................... 780
50.2.4
IO operation functions .................................................................... 780
50.2.5
Peripheral Control functions ........................................................... 780
50.2.6
State functions ................................................................................ 780
50.2.7
HAL_TSC_Init ................................................................................. 780
50.2.8
HAL_TSC_DeInit ............................................................................ 781
50.2.9
HAL_TSC_MspInit .......................................................................... 781
50.2.10 HAL_TSC_MspDeInit ..................................................................... 781
38/861
50.2.11
HAL_TSC_Start .............................................................................. 781
50.2.12
HAL_TSC_Start_IT......................................................................... 782
50.2.13
HAL_TSC_Stop .............................................................................. 782
50.2.14
HAL_TSC_Stop_IT ......................................................................... 782
50.2.15
HAL_TSC_GroupGetStatus ........................................................... 782
DOCID026526 Rev 2
UM1786
Contents
50.3
50.2.16
HAL_TSC_GroupGetValue ............................................................ 782
50.2.17
HAL_TSC_IOConfig ....................................................................... 783
50.2.18
HAL_TSC_IODischarge ................................................................. 783
50.2.19
HAL_TSC_GetState ....................................................................... 783
50.2.20
HAL_TSC_PollForAcquisition ........................................................ 783
50.2.21
HAL_TSC_IRQHandler .................................................................. 784
50.2.22
HAL_TSC_ConvCpltCallback ......................................................... 784
50.2.23
HAL_TSC_ErrorCallback................................................................ 784
TSC Firmware driver defines......................................................... 784
50.3.1
51
TSC................................................................................................. 784
HAL UART Generic Driver........................................................... 794
51.1
51.2
UART Firmware driver registers structures ................................... 794
51.1.1
UART_InitTypeDef ......................................................................... 794
51.1.2
UART_AdvFeatureInitTypeDef ....................................................... 795
51.1.3
UART_WakeUpTypeDef ................................................................ 796
51.1.4
UART_HandleTypeDef ................................................................... 796
UART Firmware driver API description ......................................... 797
51.2.1
How to use this driver ..................................................................... 797
51.2.2
Initialization and Configuration functions ........................................ 799
51.2.3
Peripheral Control functions ........................................................... 800
51.2.4
HAL_UART_Init .............................................................................. 801
51.2.5
HAL_HalfDuplex_Init ...................................................................... 801
51.2.6
HAL_LIN_Init .................................................................................. 801
51.2.7
HAL_MultiProcessor_Init ................................................................ 802
51.2.8
HAL_UART_DeInit ......................................................................... 802
51.2.9
HAL_UART_MspInit ....................................................................... 802
51.2.10
HAL_UART_MspDeInit................................................................... 803
51.2.11
HAL_UART_Transmit ..................................................................... 803
51.2.12
HAL_UART_Receive ...................................................................... 803
51.2.13
HAL_UART_Transmit_IT................................................................ 803
51.2.14
HAL_UART_Receive_IT................................................................. 804
51.2.15
HAL_UART_Transmit_DMA ........................................................... 804
51.2.16
HAL_UART_Receive_DMA ............................................................ 804
51.2.17
HAL_UART_DMAPause................................................................. 804
51.2.18
HAL_UART_DMAResume ............................................................. 805
51.2.19
HAL_UART_DMAStop ................................................................... 805
51.2.20
HAL_UART_IRQHandler ................................................................ 805
51.2.21
UART_WaitOnFlagUntilTimeout .................................................... 805
DOCID026526 Rev 2
39/861
Contents
51.3
51.2.22
UM1786
HAL_UART_TxCpltCallback .......................................................... 805
51.2.23
HAL_UART_TxHalfCpltCallback .................................................... 806
51.2.24
HAL_UART_RxCpltCallback .......................................................... 806
51.2.25
HAL_UART_RxHalfCpltCallback .................................................... 806
51.2.26
HAL_UART_ErrorCallback ............................................................. 806
51.2.27
HAL_UART_WakeupCallback ........................................................ 806
51.2.28
HAL_MultiProcessor_EnableMuteMode ........................................ 807
51.2.29
HAL_MultiProcessor_DisableMuteMode........................................ 807
51.2.30
HAL_MultiProcessor_EnterMuteMode ........................................... 807
51.2.31
UART_SetConfig ............................................................................ 807
51.2.32
UART_AdvFeatureConfig ............................................................... 808
51.2.33
UART_CheckIdleState ................................................................... 808
51.2.34
UART_Wakeup_AddressConfig ..................................................... 808
51.2.35
HAL_HalfDuplex_EnableTransmitter ............................................. 808
51.2.36
HAL_HalfDuplex_EnableReceiver ................................................. 808
51.2.37
HAL_LIN_SendBreak ..................................................................... 809
51.2.38
HAL_UART_GetState..................................................................... 809
51.2.39
HAL_UART_GetError ..................................................................... 809
UART Firmware driver defines ...................................................... 809
51.3.1
52
HAL UART Extension Driver ....................................................... 822
52.1
52.2
UARTEx Firmware driver API description ..................................... 822
52.1.1
Initialization and Configuration functions ........................................ 822
52.1.2
Peripheral Control functions ........................................................... 823
52.1.3
HAL_RS485Ex_Init......................................................................... 823
52.1.4
HAL_MultiProcessorEx_AddressLength_Set ................................. 823
52.1.5
HAL_UARTEx_StopModeWakeUpSourceConfig .......................... 824
52.1.6
HAL_UARTEx_EnableStopMode ................................................... 824
52.1.7
HAL_UARTEx_DisableStopMode .................................................. 824
UARTEx Firmware driver defines .................................................. 824
52.2.1
53
UARTEx .......................................................................................... 825
HAL USART Generic Driver ........................................................ 826
53.1
53.2
40/861
UART .............................................................................................. 809
USART Firmware driver registers structures ................................. 826
53.1.1
USART_InitTypeDef ....................................................................... 826
53.1.2
USART_HandleTypeDef ................................................................ 827
USART Firmware driver API description ....................................... 828
53.2.1
How to use this driver ..................................................................... 828
53.2.2
Initialization and Configuration functions ........................................ 830
DOCID026526 Rev 2
UM1786
Contents
53.3
53.2.3
Peripheral Control functions ........................................................... 830
53.2.4
HAL_USART_Init ............................................................................ 831
53.2.5
HAL_USART_DeInit ....................................................................... 831
53.2.6
HAL_USART_MspInit ..................................................................... 831
53.2.7
HAL_USART_MspDeInit ................................................................ 831
53.2.8
HAL_USART_CheckIdleState ........................................................ 831
53.2.9
HAL_USART_Transmit .................................................................. 832
53.2.10
HAL_USART_Receive ................................................................... 832
53.2.11
HAL_USART_TransmitReceive ..................................................... 832
53.2.12
HAL_USART_Transmit_IT ............................................................. 833
53.2.13
HAL_USART_Receive_IT .............................................................. 833
53.2.14
HAL_USART_TransmitReceive_IT ................................................ 833
53.2.15
HAL_USART_Transmit_DMA ........................................................ 833
53.2.16
HAL_USART_Receive_DMA ......................................................... 834
53.2.17
HAL_USART_TransmitReceive_DMA ........................................... 834
53.2.18
HAL_USART_DMAPause .............................................................. 834
53.2.19
HAL_USART_DMAResume ........................................................... 835
53.2.20
HAL_USART_DMAStop ................................................................. 835
53.2.21
HAL_USART_IRQHandler ............................................................. 835
53.2.22
HAL_USART_TxCpltCallback ........................................................ 835
53.2.23
HAL_USART_TxHalfCpltCallback .................................................. 835
53.2.24
HAL_USART_RxCpltCallback ........................................................ 836
53.2.25
HAL_USART_RxHalfCpltCallback ................................................. 836
53.2.26
HAL_USART_TxRxCpltCallback .................................................... 836
53.2.27
HAL_USART_ErrorCallback .......................................................... 836
53.2.28
HAL_USART_GetState .................................................................. 836
53.2.29
HAL_USART_GetError................................................................... 837
USART Firmware driver defines.................................................... 837
53.3.1
54
HAL USART Extension Driver .................................................... 844
54.1
USARTEx Firmware driver defines ............................................... 844
54.1.1
55
USART............................................................................................ 837
USARTEx ....................................................................................... 844
HAL WWDG Generic Driver ........................................................ 848
55.1
55.2
WWDG Firmware driver registers structures ................................. 848
55.1.1
WWDG_InitTypeDef ....................................................................... 848
55.1.2
WWDG_HandleTypeDef ................................................................ 848
WWDG Firmware driver API description ....................................... 849
DOCID026526 Rev 2
41/861
Contents
55.3
55.2.1
UM1786
WWDG specific features ................................................................ 849
55.2.2
How to use this driver ..................................................................... 849
55.2.3
Initialization and de-initialization functions ..................................... 850
55.2.4
Peripheral State functions .............................................................. 850
55.2.5
HAL_WWDG_Init............................................................................ 850
55.2.6
HAL_WWDG_DeInit ....................................................................... 850
55.2.7
HAL_WWDG_MspInit ..................................................................... 850
55.2.8
HAL_WWDG_MspDeInit ................................................................ 851
55.2.9
HAL_WWDG_WakeupCallback ..................................................... 851
55.2.10
HAL_WWDG_Start ......................................................................... 851
55.2.11
HAL_WWDG_Start_IT.................................................................... 851
55.2.12
HAL_WWDG_Refresh .................................................................... 852
55.2.13
HAL_WWDG_IRQHandler ............................................................. 852
55.2.14
HAL_WWDG_WakeupCallback ..................................................... 852
55.2.15
HAL_WWDG_GetState .................................................................. 853
WWDG Firmware driver defines.................................................... 853
55.3.1
WWDG............................................................................................ 853
56
FAQs............................................................................................. 856
57
Revision history .......................................................................... 860
42/861
DOCID026526 Rev 2
UM1786
List of tables
List of tables
Table 1: Acronyms and definitions ............................................................................................................ 45
Table 2: HAL drivers files .......................................................................................................................... 47
Table 3: User-application files .................................................................................................................. 48
Table 4: APis classification ....................................................................................................................... 52
Table 5: List of devices supported by HAL drivers ................................................................................... 54
Table 6: HAL API naming rules ................................................................................................................ 57
Table 7: Macros handling interrupts and specific clock configurations .................................................... 58
Table 8: Callback functions ....................................................................................................................... 59
Table 9: HAL generic APIs ....................................................................................................................... 60
Table 10: HAL extension APIs .................................................................................................................. 61
Table 11: Define statements used for HAL configuration ......................................................................... 65
Table 12: Description of GPIO_InitTypeDef structure .............................................................................. 67
Table 13: Description of EXTI configuration macros ................................................................................ 69
Table 14: MSP functions ........................................................................................................................... 74
Table 15: Timeout values ......................................................................................................................... 78
Table 16: COMP Inputs for STM32F303xB/STM32F303xC/STM32F303xE devices ............................ 188
Table 17: COMP outputs for STM32F303xB/STM32F303xC/STM32F303xE devices .......................... 188
Table 18: Redirection of COMP outputs to embedded timers for STM32F303xB/STM32F303xC devices
................................................................................................................................................................ 189
Table 19: Redirection of COMP outputs to embedded timers for STM32F303xE devices .................... 189
Table 20: COMP outputs blanking sources for the STM32F303xB/STM32F303xC/STM32F303xE
devicesutputs for STM32F303xB/STM32F303xC/STM32F303xE devices ............................................ 190
Table 21: Pre-emption priority and subpriority vs Priority Grouping configuration ................................. 201
Table 22: IRDA frame formats ................................................................................................................ 432
Table 23: OPAMPs inverting/non-inverting inputs for STM32F3 devices .............................................. 475
Table 24: OPAMP outputs for STM32F3 devices ................................................................................... 475
Table 25: Number of wait states (WS) according to system clock (SYSCLK) frequency ....................... 526
Table 26: USART frame formats (1 M bit) .............................................................................................. 645
Table 27: USART frame formats (2 M bits) ............................................................................................ 645
Table 28: Maximum SPI frequency vs data size .................................................................................... 684
Table 29: UART frame formats (1 M bit) ................................................................................................. 800
Table 30: UART frame formats (2 M bits) ............................................................................................... 800
Table 29: UARTEx frame formats (1 M bit) ............................................................................................ 822
Table 30: UARTEx frame formats (2 M bits)........................................................................................... 822
Table 31: USART frame formats (1 M bit) .............................................................................................. 830
Table 32: USART frame formats (2 M bits) ............................................................................................ 830
Table 33: Document revision history ...................................................................................................... 860
DOCID026526 Rev 2
43/861
List of figures
UM1786
List of figures
Figure 1: Example of project template ...................................................................................................... 49
Figure 2: Adding device-specific functions ............................................................................................... 62
Figure 3: Adding family-specific functions ................................................................................................ 62
Figure 4: Adding new peripherals ............................................................................................................. 63
Figure 5: Updating existing APIs .............................................................................................................. 63
Figure 6: File inclusion model ................................................................................................................... 64
Figure 7: HAL driver model ....................................................................................................................... 72
44/861
DOCID026526 Rev 2
UM1786
1
Acronyms and definitions
Acronyms and definitions
Table 1: Acronyms and definitions
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 2
45/861
Acronyms and definitions
46/861
UM1786
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 2
UM1786
2
Overview of HAL drivers
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
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 2
47/861
Overview of HAL drivers
UM1786
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 :

48/861
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 2
UM1786
Overview of HAL drivers
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
DOCID026526 Rev 2
49/861
Overview of HAL drivers
2.2
UM1786
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:


50/861
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 2
UM1786
Overview of HAL drivers
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)
2.3
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.
DOCID026526 Rev 2
51/861
Overview of HAL drivers
UM1786
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
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.
52/861
DOCID026526 Rev 2
UM1786
2.4
Overview of HAL drivers
Devices supported by HAL drivers
DOCID026526 Rev 2
53/861
Overview of HAL drivers
UM1786
54/861
IP/Module
STM32F301x6/x8
STM32F302x6/x8
STM32F302xB/xC
STM32F302xE
STM32F303x6/x8
STM32F303xC
STM32F303xE
STM32F373xB/xC
STM32F334x6/xST
M32F373xB/C8
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
DOCID026526 Rev 2
IP/Module
STM32F302x6/x8
STM32F302xB/xC
STM32F302xE
STM32F303x6/x8
STM32F303xC
STM32F303xE
STM32F373xB/xC
STM32F334x6/xST
M32F373xB/C8
STM32F318xx
STM32F328xx
STM32F358xx
STM32F378xx
STM32F398xx
Overview of HAL drivers
STM32F301x6/x8
UM1786
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
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
DOCID026526 Rev 2
55/861
56/861
IP/Module
STM32F302x6/x8
STM32F302xB/xC
STM32F302xE
STM32F303x6/x8
STM32F303xC
STM32F303xE
STM32F373xB/xC
STM32F334x6/xST
M32F373xB/C8
STM32F318xx
STM32F328xx
STM32F358xx
STM32F378xx
STM32F398xx
UM1786
STM32F301x6/x8
Overview of HAL drivers
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
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 2
UM1786
Overview of HAL drivers
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
HAL_PPP_ MODULE
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










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 2
57/861
Overview of HAL drivers



2.5.2
UM1786
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
58/861
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 2
UM1786
Overview of HAL drivers



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
Example
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
Ex: HAL_USART_ErrorCallback
Called by peripheral or DMA interrupt handler when an error
occurs
DOCID026526 Rev 2
59/861
Overview of HAL drivers
2.6
UM1786
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
60/861
DOCID026526 Rev 2
UM1786
Overview of HAL drivers
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
2.7.2
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
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().
DOCID026526 Rev 2
61/861
Overview of HAL drivers
UM1786
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
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
62/861
DOCID026526 Rev 2
UM1786
Overview of HAL drivers
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 */
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.
DOCID026526 Rev 2
63/861
Overview of HAL drivers
UM1786
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;

64/861
HAL Locked: The HAL lock is used by all HAL APIs to prevent accessing by accident
shared resources.
DOCID026526 Rev 2
UM1786
Overview of HAL drivers
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)
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)
PREFETCH_ENABLE
Enables prefetch feature
TRUE
HSE_STARTUP_TIMEOUT
DOCID026526 Rev 2
65/861
Overview of HAL drivers
UM1786
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:



2.11.2
__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.
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.
66/861
DOCID026526 Rev 2
UM1786
Overview of HAL drivers
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
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_LOW
GPIO_SPEED_MEDIUM
GPIO_SPEED_HIGH
DOCID026526 Rev 2
67/861
Overview of HAL drivers
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_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_FAST;
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:







68/861
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 2
UM1786
Overview of HAL drivers

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
PPP_EXTI_LINE_FUNCTION
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 */
__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()
DOCID026526 Rev 2
69/861
Overview of HAL drivers
UM1786
Macros
Description
__HAL_PPP_EXTI_GET_FLAG
Gets a given EXTI line interrupt flag pending bit status.
Example:
__HAL_PWR_PVD_EXTI_GET_FLAG()
__HAL_PPP_EXTI_CLEAR_FLAG
Clears a given EXTI line interrupt flag pending bit.
Example;
__HAL_PWR_PVD_EXTI_CLEAR_FLAG()
__HAL_PPP_EXTI_GENERATE_SWIT
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:


70/861
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()
DOCID026526 Rev 2
UM1786
c.
d.
e.
Overview of HAL drivers
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.
Use HAL_DMA_IRQHandler() called under DMA_IRQHandler() Interrupt
subroutine
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.
DOCID026526 Rev 2
71/861
Overview of HAL drivers
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.
72/861
DOCID026526 Rev 2
UM1786
Overview of HAL drivers
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();
}
}
DOCID026526 Rev 2
73/861
Overview of HAL drivers
2.12.2.3
UM1786
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.
74/861
DOCID026526 Rev 2
UM1786
2.12.3
Overview of HAL drivers
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.
DOCID026526 Rev 2
75/861
Overview of HAL drivers
An example of use is illustrated below:
UM1786
main.c file:
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;
76/861
DOCID026526 Rev 2
UM1786
Overview of HAL drivers
The initialization is done as follows (UART example):
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 = 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 ;
DOCID026526 Rev 2
77/861
Overview of HAL drivers
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)
{
78/861
DOCID026526 Rev 2
UM1786
Overview of HAL drivers
if(HAL_GetTick() >= timeout)
{
/* Process unlocked */
__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;
DOCID026526 Rev 2
79/861
Overview of HAL drivers
UM1786
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 */
}
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 */
80/861
DOCID026526 Rev 2
UM1786
Overview of HAL drivers
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)
{
}
}
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.
DOCID026526 Rev 2
81/861
HAL System Driver
UM1786
3
HAL System Driver
3.1
HAL Firmware driver API description
The following section lists the various functions of the HAL library.
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:








3.1.3
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.
HAL_Init()
HAL_DeInit()
HAL_MspInit()
HAL_MspDeInit()
HAL_InitTick()
HAL Control functions
This section provides functions allowing to:


82/861
Provide a tick value in millisecond
Provide a blocking delay in millisecond
DOCID026526 Rev 2
UM1786
HAL System Driver






















3.1.4
Suspend the time base source interrupt
Resume the time base source interrupt
Get the HAL API driver version
Get the device identifier
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
HAL_IncTick()
HAL_GetTick()
HAL_Delay()
HAL_SuspendTick()
HAL_ResumeTick()
HAL_GetHalVersion()
HAL_GetREVID()
HAL_GetDEVID()
HAL_EnableDBGSleepMode()
HAL_DisableDBGSleepMode()
HAL_EnableDBGStopMode()
HAL_DisableDBGStopMode()
HAL_EnableDBGStandbyMode()
HAL_DisableDBGStandbyMode()
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.


3.1.5
HAL_DeInit
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 2
83/861
HAL System Driver
3.1.6
3.1.7
3.1.8
UM1786
HAL_MspInit
Function Name
void HAL_MspInit (void )
Function Description
Initializes the MSP.
Return values

HAL_MspDeInit
Function Name
void HAL_MspDeInit (void )
Function Description
DeInitializes the MSP.
Return values

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.

84/861
None
HAL_InitTick

3.1.9
None
DOCID026526 Rev 2
UM1786
3.1.10
3.1.11
3.1.12
HAL System Driver
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_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.
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.

3.1.13
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.
DOCID026526 Rev 2
85/861
HAL System Driver
3.1.14
3.1.15
3.1.16
3.1.17
3.1.18
3.1.19
86/861
UM1786
The function is declared as __Weak to be overwritten in case
of other implementations in user file.
HAL_GetHalVersion
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)
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_EnableDBGSleepMode
Function Name
void HAL_EnableDBGSleepMode (void )
Function Description
Enable the Debug Module during SLEEP mode.
Return values

None
HAL_DisableDBGSleepMode
Function Name
void HAL_DisableDBGSleepMode (void )
Function Description
Disable the Debug Module during SLEEP mode.
Return values

None
HAL_EnableDBGStopMode
Function Name
void HAL_EnableDBGStopMode (void )
Function Description
Enable the Debug Module during STOP mode.
Return values

None
DOCID026526 Rev 2
UM1786
3.1.20
3.1.21
3.1.22
3.2
HAL System Driver
HAL_DisableDBGStopMode
Function Name
void HAL_DisableDBGStopMode (void )
Function Description
Disable the Debug Module during STOP mode.
Return values

None
HAL_EnableDBGStandbyMode
Function Name
void HAL_EnableDBGStandbyMode (void )
Function Description
Enable the Debug Module during STANDBY mode.
Return values

None
HAL_DisableDBGStandbyMode
Function Name
void HAL_DisableDBGStandbyMode (void )
Function Description
Disable the Debug Module during STANDBY mode.
Return values

None
HAL Firmware driver defines
The following section lists the various define and macros of the module.
3.2.1
HAL
HAL
HAL ADC Trigger Remapping
HAL_REMAPADCTRIGGER_ADC12_EXT2
Input trigger of ADC12 regular channel
EXT2 0: No remap (TIM1_CC3) 1: Remap
(TIM20_TRGO)
HAL_REMAPADCTRIGGER_ADC12_EXT3
Input trigger of ADC12 regular channel
EXT3 0: No remap (TIM2_CC2) 1: Remap
(TIM20_TRGO2)
HAL_REMAPADCTRIGGER_ADC12_EXT5
Input trigger of ADC12 regular channel
EXT5 0: No remap (TIM4_CC4) 1: Remap
(TIM20_CC1)
HAL_REMAPADCTRIGGER_ADC12_EXT13
Input trigger of ADC12 regular channel
EXT13 0: No remap (TIM6_TRGO) 1:
Remap (TIM20_CC2)
HAL_REMAPADCTRIGGER_ADC12_EXT15
Input trigger of ADC12 regular channel
EXT15 0: No remap (TIM3_CC4) 1:
Remap (TIM20_CC3)
HAL_REMAPADCTRIGGER_ADC12_JEXT3
Input trigger of ADC12 injected channel
JEXT3 0: No remap (TIM2_CC1) 1:
DOCID026526 Rev 2
87/861
HAL System Driver
UM1786
Remap (TIM20_TRGO)
HAL_REMAPADCTRIGGER_ADC12_JEXT6
Input trigger of ADC12 injected channel
JEXT6 0: No remap (EXTI line 15) 1:
Remap (TIM20_TRGO2)
HAL_REMAPADCTRIGGER_ADC12_JEXT13
Input trigger of ADC12 injected channel
JEXT13 0: No remap (TIM3_CC1) 1:
Remap (TIM20_CC4)
HAL_REMAPADCTRIGGER_ADC34_EXT5
Input trigger of ADC34 regular channel
EXT5 0: No remap (EXTI line 2) 1:
Remap (TIM20_TRGO)
HAL_REMAPADCTRIGGER_ADC34_EXT6
Input trigger of ADC34 regular channel
EXT6 0: No remap (TIM4_CC1) 1: Remap
(TIM20_TRGO2)
HAL_REMAPADCTRIGGER_ADC34_EXT15
Input trigger of ADC34 regular channel
EXT15 0: No remap (TIM2_CC1) 1:
Remap (TIM20_CC1)
HAL_REMAPADCTRIGGER_ADC34_JEXT5
Input trigger of ADC34 injected channel
JEXT5 0: No remap (TIM4_CC3) 1:
Remap (TIM20_TRGO)
HAL_REMAPADCTRIGGER_ADC34_JEXT11
Input trigger of ADC34 injected channel
JEXT11 0: No remap (TIM1_CC3) 1:
Remap (TIM20_TRGO2)
HAL_REMAPADCTRIGGER_ADC34_JEXT14
Input trigger of ADC34 injected channel
JEXT14 0: No remap (TIM7_TRGO) 1:
Remap (TIM20_CC2)
IS_HAL_REMAPADCTRIGGER
CRC aliases for Exported Functions
HAL_CRC_Input_Data_Reverse
HAL_CRC_Output_Data_Reverse
HAL DMA Remapping
88/861
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
DOCID026526 Rev 2
UM1786
HAL System Driver
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
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_HAL_REMAPDMA
HAL I2C Fast Mode Plus
HAL_SYSCFG_FASTMODEPLUS_I2C1
I2C1 fast mode Plus driving capability
activation 0: FM+ mode is not enabled
on I2C1 pins selected through AF
selection bits 1: FM+ mode is enabled
on I2C1 pins selected through AF
selection bits
HAL_SYSCFG_FASTMODEPLUS_I2C2
I2C2 fast mode Plus driving capability
activation 0: FM+ mode is not enabled
on I2C2 pins selected through AF
selection bits 1: FM+ mode is enabled
on I2C2 pins selected through AF
selection bits
HAL_SYSCFG_FASTMODEPLUS_I2C3
I2C3 fast mode Plus driving capability
activation 0: FM+ mode is not enabled
on I2C3 pins selected through AF
selection bits 1: FM+ mode is enabled
on I2C3 pins selected through AF
selection bits
HAL_SYSCFG_FASTMODEPLUS_I2C_PB6
Fast Mode Plus (FM+) driving capability
activation on the pad 0: PB6 pin
operates in standard mode 1: I2C FM+
mode enabled on PB6 pin, and the
Speed control is bypassed
HAL_SYSCFG_FASTMODEPLUS_I2C_PB7
Fast Mode Plus (FM+) driving capability
activation on the pad 0: PB7 pin
operates in standard mode 1: I2C FM+
mode enabled on PB7 pin, and the
Speed control is bypassed
HAL_SYSCFG_FASTMODEPLUS_I2C_PB8
Fast Mode Plus (FM+) driving capability
activation on the pad 0: PB8 pin
operates in standard mode 1: I2C FM+
DOCID026526 Rev 2
89/861
HAL System Driver
UM1786
mode enabled on PB8 pin, and the
Speed control is bypassed
HAL_SYSCFG_FASTMODEPLUS_I2C_PB9
Fast Mode Plus (FM+) driving capability
activation on the pad 0: PB9 pin
operates in standard mode 1: I2C FM+
mode enabled on PB9 pin, and the
Speed control is bypassed
IS_HAL_SYSCFG_FASTMODEPLUS_CONFIG
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
HAL_SYSCFG_WP_PAGE8
ICODE SRAM Write protection page 8
HAL_SYSCFG_WP_PAGE9
ICODE SRAM Write protection page 9
HAL_SYSCFG_WP_PAGE10
ICODE SRAM Write protection page 10
HAL_SYSCFG_WP_PAGE11
ICODE SRAM Write protection page 11
HAL_SYSCFG_WP_PAGE12
ICODE SRAM Write protection page 12
HAL_SYSCFG_WP_PAGE13
ICODE SRAM Write protection page 13
HAL_SYSCFG_WP_PAGE14
ICODE SRAM Write protection page 14
HAL_SYSCFG_WP_PAGE15
ICODE SRAM Write protection page 15
IS_HAL_SYSCFG_WP_PAGE
Constants
__STM32F3xx_HAL_VERSION_MAIN
[31:24] main version
__STM32F3xx_HAL_VERSION_SUB1
[23:16] sub1 version
__STM32F3xx_HAL_VERSION_SUB2
[15:8] sub2 version
__STM32F3xx_HAL_VERSION_RC
[7:0] release candidate
__STM32F3xx_HAL_VERSION
IDCODE_DEVID_MASK
HAL SYSCFG Interrupts
90/861
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 2
UM1786
HAL_SYSCFG_IT_FPU_IDC
HAL System Driver
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
DOCID026526 Rev 2
91/861
HAL ADC Generic Driver
UM1786
4
HAL ADC Generic Driver
4.1
ADC Firmware driver registers structures
4.1.1
__ADC_HandleTypeDef
__ADC_HandleTypeDef is defined in the stm32f3xx_hal_adc.h
Data Fields







ADC_TypeDef * Instance
ADC_InitTypeDef Init
__IO uint32_t NbrOfConversionRank
DMA_HandleTypeDef * DMA_Handle
HAL_LockTypeDef Lock
__IO HAL_ADC_StateTypeDef State
__IO uint32_t ErrorCode
Field Documentation







4.2
ADC_TypeDef* __ADC_HandleTypeDef::Instance
Register base address
ADC_InitTypeDef __ADC_HandleTypeDef::Init
ADC required parameters
__IO uint32_t __ADC_HandleTypeDef::NbrOfConversionRank
ADC conversion rank counter
DMA_HandleTypeDef* __ADC_HandleTypeDef::DMA_Handle
Pointer DMA Handler
HAL_LockTypeDef __ADC_HandleTypeDef::Lock
ADC locking object
__IO HAL_ADC_StateTypeDef __ADC_HandleTypeDef::State
ADC communication state
__IO uint32_t __ADC_HandleTypeDef::ErrorCode
ADC Error code
ADC Firmware driver API description
The following section lists the various functions of the ADC library.
4.2.1
ADC peripheral features
1.
2.
3.
4.
92/861
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 automatic conversion of channel 0 to channel 'n'.
DOCID026526 Rev 2
UM1786
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
4.2.2
HAL ADC Generic Driver
Data alignment with in-built data coherency.
Channel-wise programmable sampling time.
ADC conversion of regular or injected groups.
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.
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)
DOCID026526 Rev 2
93/861
HAL ADC Generic Driver
UM1786

2.
3.
4.
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC (optional, if
ADC conversion from asynchronous clock)

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.
94/861
Configure the ADC parameters (resolution, data alignment, ...) and regular group
parameters (conversion trigger, sequencer, ..., of regular group) 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().
DOCID026526 Rev 2
UM1786
5.
HAL ADC Generic Driver
Optionally, for devices with several ADC instances: configure the multimode
parameters using function HAL_ADCEx_MultiModeConfigChannel().
Execution of ADC conversions
1.
2.
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) and start conversions using function
HAL_ADC_Start()

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 2
95/861
HAL ADC Generic Driver
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.
96/861
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)
DOCID026526 Rev 2
UM1786
HAL ADC Generic Driver

2.
3.
4.
4.2.3
PeriphClkInit.Adc34ClockSelection = RCC_ADC34PLLCLK_OFF (optional,
if configured before)

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:






4.2.4
Initialize and configure the ADC.
De-initialize the ADC.
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.
HAL_ADC_Start()
HAL_ADC_Stop()
HAL_ADC_PollForConversion()
HAL_ADC_PollForEvent()
HAL_ADC_Start_IT()
DOCID026526 Rev 2
97/861
HAL ADC Generic Driver









4.2.5
UM1786
HAL_ADC_Stop_IT()
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:




4.2.6
Configure channels on regular group
Configure the analog watchdog
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.




4.2.7
Check the ADC state
Check the ADC error code
HAL_ADC_GetState()
HAL_ADC_GetError()
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
"ADC_InitTypeDef".

98/861
DOCID026526 Rev 2
UM1786
HAL ADC Generic Driver


4.2.8
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().

4.2.9
4.2.10
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_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
Function Name
void HAL_ADC_MspDeInit (ADC_HandleTypeDef * hadc)
DOCID026526 Rev 2
99/861
HAL ADC Generic Driver
Function Description
4.2.11
4.2.12
UM1786
DeInitializes the ADC MSP.
Parameters

hadc: ADC handle
Return values

None
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).

4.2.13
100/861
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.
DOCID026526 Rev 2
UM1786
HAL ADC Generic Driver
Return values
4.2.14
4.2.16
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.
Parameters


Return values
4.2.15


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

DOCID026526 Rev 2
101/861
HAL ADC Generic Driver
UM1786
slave).
4.2.17
4.2.18
HAL_ADC_Start_DMA
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.
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.

4.2.19
4.2.20
102/861
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.
DOCID026526 Rev 2
UM1786
4.2.21
4.2.22
4.2.23
4.2.24
HAL ADC Generic Driver
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)
Function Description
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
Notes

In case of several analog watchdog enabled, if needed to
know which one triggered and on which ADCx, Test Analog
Watchdog flags ADC_FLAG_AWD1/2/3 into function
HAL_ADC_LevelOutOfWindowCallback(). For example: "if
(__HAL_ADC_GET_FLAG(&hadc1, ADC_FLAG_AWD1) !=
RESET)" "if (__HAL_ADC_GET_FLAG(&hadc1,
ADC_FLAG_AWD2) != RESET)" "if
(__HAL_ADC_GET_FLAG(&hadc1, ADC_FLAG_AWD3) !=
RESET)"
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)
DOCID026526 Rev 2
103/861
HAL ADC Generic Driver
Parameters
Return values
4.2.25
UM1786

hadc: ADC handle

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".

4.2.26
104/861
HAL_ADC_AnalogWDGConfig
Function Name
HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig
(ADC_HandleTypeDef * hadc, ADC_AnalogWDGConfTypeDef *
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".
DOCID026526 Rev 2
UM1786
4.2.27
4.2.28
4.3
HAL ADC Generic Driver
HAL_ADC_GetState
Function Name
HAL_ADC_StateTypeDef HAL_ADC_GetState
(ADC_HandleTypeDef * hadc)
Function Description
return the ADC state
Parameters

hadc: ADC handle
Return values

HAL state
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
ADC Firmware driver defines
The following section lists the various define and macros of the module.
4.3.1
ADC
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:
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:
DOCID026526 Rev 2
105/861
HAL ADC Generic Driver
UM1786

None:
ADC Injected Conversion Number Verification
IS_ADC_INJECTED_NB_CONV
ADC Multimode Bits
ADC_CCR_MULTI
Multi ADC mode selection
ADC_CCR_MULTI_0
MULTI bit 0
ADC_CCR_MULTI_1
MULTI bit 1
ADC_CCR_MULTI_2
MULTI bit 2
ADC_CCR_MULTI_3
MULTI bit 3
ADC_CCR_MULTI_4
MULTI bit 4
ADC_CCR_DELAY
Delay between 2 sampling phases
ADC_CCR_DELAY_0
DELAY bit 0
ADC_CCR_DELAY_1
DELAY bit 1
ADC_CCR_DELAY_2
DELAY bit 2
ADC_CCR_DELAY_3
DELAY bit 3
ADC_CCR_DMACFG
DMA configuration for multi-ADC mode
ADC_CCR_MDMA
DMA mode for multi-ADC mode
ADC_CCR_MDMA_0
MDMA bit 0
ADC_CCR_MDMA_1
MDMA bit 1
ADC_CCR_CKMODE
ADC clock mode
ADC_CCR_CKMODE_0
CKMODE bit 0
ADC_CCR_CKMODE_1
CKMODE bit 1
ADC_CCR_VREFEN
VREFINT enable
ADC_CCR_TSEN
Temperature sensor enable
ADC_CCR_VBATEN
VBAT enable
ADC Private Constants
ADC_FLAG_ALL
ADC_FLAG_POSTCONV_ALL
ADC Regular Discontinuous Mode NumberVerification
IS_ADC_REGULAR_DISCONT_NUMBER
ADC Regular Conversion Number Verification
IS_ADC_REGULAR_NB_CONV
ADC Trigger Remapping Enable
__HAL_REMAPADCTRIGGER_ENABLE
Description:

ADC trigger remapping enable/disable
macros.
Parameters:
106/861
DOCID026526 Rev 2
UM1786
HAL ADC Generic Driver

__ADCTRIGGER_REMAP__: This
parameter can be a value of
__HAL_REMAPADCTRIGGER_DISABLE
DOCID026526 Rev 2
107/861
HAL ADC Extension Driver
UM1786
5
HAL ADC Extension Driver
5.1
ADCEx Firmware driver registers structures
5.1.1
ADC_InitTypeDef
ADC_InitTypeDef is defined in the stm32f3xx_hal_adc_ex.h
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




108/861
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
DOCID026526 Rev 2
UM1786








HAL ADC Extension Driver
converted, the one defined in rank 1). Parameters 'NbrOfConversion' and
'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: new conversion start 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 2
109/861
HAL ADC Extension Driver
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).
5.1.2
ADC_ChannelConfTypeDef
ADC_ChannelConfTypeDef is defined in the stm32f3xx_hal_adc_ex.h
Data Fields






uint32_t Channel
uint32_t Rank
uint32_t SamplingTime
uint32_t SingleDiff
uint32_t OffsetNumber
uint32_t Offset
Field Documentation



110/861
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
DOCID026526 Rev 2
UM1786



5.1.3
HAL ADC Extension Driver
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_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
ADC_InjectionConfTypeDef is defined in the stm32f3xx_hal_adc_ex.h
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
DOCID026526 Rev 2
111/861
HAL ADC Extension Driver

UM1786
uint32_t ExternalTrigInjecConvEdge
Field Documentation







112/861
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
DOCID026526 Rev 2
UM1786





HAL ADC Extension Driver
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
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 2
113/861
HAL ADC Extension Driver
5.1.4
UM1786
ADC_AnalogWDGConfTypeDef
ADC_AnalogWDGConfTypeDef is defined in the stm32f3xx_hal_adc_ex.h
Data Fields






uint32_t WatchdogNumber
uint32_t WatchdogMode
uint32_t Channel
uint32_t ITMode
uint32_t HighThreshold
uint32_t LowThreshold
Field Documentation






114/861
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.
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.
DOCID026526 Rev 2
UM1786
5.1.5
HAL ADC Extension Driver
ADC_MultiModeTypeDef
ADC_MultiModeTypeDef is defined in the stm32f3xx_hal_adc_ex.h
Data Fields



uint32_t Mode
uint32_t DMAAccessMode
uint32_t TwoSamplingDelay
Field Documentation



5.2
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
ADCEx Firmware driver API description
The following section lists the various functions of the ADCEx library.
5.2.1
Initialization and de-initialization functions
This section provides functions allowing to:




5.2.2
Initialize and configure the ADC.
De-initialize the ADC.
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.
DOCID026526 Rev 2
115/861
HAL ADC Extension Driver










































5.2.3
UM1786
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.
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()
HAL_ADCEx_MultiModeGetValue()
HAL_ADCEx_InjectedGetValue()
HAL_ADCEx_InjectedConvCpltCallback()
HAL_ADCEx_InjectedQueueOverflowCallback()
Peripheral Control functions
This section provides functions allowing to:





116/861
Configure channels on regular group
Configure channels on injected group
Configure multimode
Configure the analog watchdog
HAL_ADC_ConfigChannel()
DOCID026526 Rev 2
UM1786
HAL ADC Extension Driver



5.2.4
HAL_ADCEx_InjectedConfigChannel()
HAL_ADC_AnalogWDGConfig()
HAL_ADCEx_MultiModeConfigChannel()
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
"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.



5.2.5
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
DOCID026526 Rev 2
117/861
HAL ADC Extension Driver

5.2.6
5.2.7
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).

5.2.8
118/861
UM1786
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_PollForConversion
DOCID026526 Rev 2
UM1786
5.2.9
Function Name
HAL ADC Extension Driver
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.
Parameters


Return values
5.2.10
5.2.11

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
DOCID026526 Rev 2
119/861
HAL ADC Extension Driver

5.2.12
5.2.13
HAL_ADC_Start_DMA
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.
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.

5.2.14
120/861
UM1786
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_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.
DOCID026526 Rev 2
UM1786
5.2.15
5.2.16
5.2.17
5.2.18
HAL ADC Extension Driver
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_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:
ADC_SINGLE_ENDED: Channel in mode input single ended
ADC_DIFFERENTIAL_ENDED: Channel in mode input
differential ended
Return values

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


hadc: ADC handle
SingleDiff: Selection of single-ended or differential input This
DOCID026526 Rev 2
121/861
HAL ADC Extension Driver

Return values
5.2.19
5.2.20

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
Function Name
HAL_StatusTypeDef HAL_ADCEx_InjectedStop
(ADC_HandleTypeDef * hadc)
Function Description
Stop conversion of injected channels.
Parameters

hadc: ADC handle
Return values

None
Notes

If ADC must be disabled and if conversion is on going on
regular group, function HAL_ADC_Stop must be used to stop
both injected and regular groups, and disable the ADC.
In case of auto-injection mode, 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).

HAL_ADCEx_InjectedPollForConversion
Function Name
122/861
HAL state
HAL_ADCEx_InjectedStart

5.2.21
UM1786
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_StatusTypeDef HAL_ADCEx_InjectedPollForConversion
(ADC_HandleTypeDef * hadc, uint32_t Timeout)
DOCID026526 Rev 2
UM1786
Function Description
5.2.22
5.2.23
HAL ADC Extension Driver
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 conversion of injected channels, disable interruption of endof-conversion.
Parameters

hadc: ADC handle
Return values

None
Notes

If ADC must be disabled and if conversion is on going on
regular group, function HAL_ADC_Stop must be used to stop
both injected and regular groups, and disable the ADC.
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.


5.2.24
5.2.25
HAL_ADCEx_MultiModeStart_DMA
Function Name
HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA
(ADC_HandleTypeDef * hadc, uint32_t * pData, uint32_t
Length)
Function Description
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)
DOCID026526 Rev 2
123/861
HAL ADC Extension Driver
Function Description
UM1786
Stop ADC conversion of regular group (and injected channels in
case of auto_injection mode), disable ADC DMA transfer, disable
ADC peripheral.
Parameters

hadc: ADC handle of ADC master (handle of ADC slave must
not be used)
Return values

None
Notes

Multimode is kept enabled after this function. To disable
multimode (set with HAL_ADCEx_MultiModeConfigChannel()
), ADC must be reinitialized using HAL_ADC_Init() or
HAL_ADC_ReInit().
In case of DMA configured in circular mode, function
HAL_ADC_Stop_DMA must be called after this function with
handle of ADC slave, to properly disable the DMA channel.

5.2.26
5.2.27
5.2.28
124/861
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.
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

None
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
DOCID026526 Rev 2
UM1786
HAL ADC Extension Driver
Return values
5.2.29
5.2.30

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_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".

5.2.31
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.
DOCID026526 Rev 2
125/861
HAL ADC Extension Driver
Parameters
UM1786


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:
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.



5.2.32
126/861
HAL_ADC_AnalogWDGConfig
Function Name
HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig
(ADC_HandleTypeDef * hadc, ADC_AnalogWDGConfTypeDef *
AnalogWDGConfig)
Function Description
Configures the analog watchdog.
Parameters


hadc: ADC handle
AnalogWDGConfig: Structure of ADC analog watchdog
configuration
DOCID026526 Rev 2
UM1786
5.2.33
HAL ADC Extension Driver
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_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() ).

5.3
ADCEx Firmware driver defines
The following section lists the various define and macros of the module.
5.3.1
ADCEx
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
DOCID026526 Rev 2
127/861
HAL ADC Extension Driver
ADC_ANALOGWATCHDOG_1
UM1786
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
ADC_CHANNEL_VOPAMP2
ADC_CHANNEL_VOPAMP3
ADC_CHANNEL_VOPAMP4
ADC_CHANNEL_VREFINT
ADC Extended Clock Prescaler
128/861
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
DOCID026526 Rev 2
UM1786
HAL ADC Extension Driver
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
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
DOCID026526 Rev 2
129/861
HAL ADC Extension Driver
ADC_EOC_SINGLE_SEQ_CONV
UM1786
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,
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
ADC_AWD_EVENT
ADCEx Exported Macros
__HAL_ADC_ENABLE
Description:

Enable the ADC peripheral.
Parameters:

__HANDLE__: ADC handle
Return value:

__HAL_ADC_DISABLE
None:
Description:

Disable the ADC peripheral.
Parameters:

__HANDLE__: ADC handle
Return value:

__HAL_ADC_ENABLE_IT
None:
Description:

Enable the ADC end of conversion
interrupt.
Parameters:


130/861
__HANDLE__: ADC handle
__INTERRUPT__: ADC Interrupt This
parameter can be any combination of the
following values:
DOCID026526 Rev 2
UM1786
HAL ADC Extension Driver











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:

__HAL_ADC_DISABLE_IT
None:
Description:

Disable 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
DOCID026526 Rev 2
131/861
HAL ADC Extension Driver






UM1786
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:

__HAL_ADC_GET_IT_SOURCE
None:
Description:

Checks if the specified ADC interrupt
source is enabled or disabled.
Parameters:


132/861
__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)
DOCID026526 Rev 2
UM1786
HAL ADC Extension Driver



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)
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:
DOCID026526 Rev 2
133/861
HAL ADC Extension Driver
UM1786

Clear the ADC's pending flags.
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_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
134/861
DOCID026526 Rev 2
UM1786
HAL ADC Extension Driver
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
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
ADC_EXTERNALTRIGINJECCONV_T20_CC4
External trigger of injected group for
ADC1&ADC2 only, specific to device
STM303xE, using Timer20 with ADC
trigger input remap. Remap trigger
using macro
ADC_EXTERNALTRIGINJECCONV_T20_CC2
External trigger of injected group for
ADC1&ADC2 only, specific to device
STM303xE, using Timer20 with ADC
trigger input remap. Remap trigger
using macro
ADC_EXTERNALTRIGINJECCONV_T20_TRGO
External trigger of regular group for
ADC1&ADC2, ADC3&ADC4, specific
to device STM303xE, using Timer20
DOCID026526 Rev 2
135/861
HAL ADC Extension Driver
UM1786
with ADC trigger input remap. For
ADC1&ADC2: Remap trigger using
macro
ADC_EXTERNALTRIGINJECCONV_T20_TRGO2
External trigger of regular group for
ADC1&ADC2, ADC3&ADC4, specific
to device STM303xE, using Timer20
with ADC trigger input remap. For
ADC1&ADC2: Remap trigger using
macro
ADC Extended External trigger selection for regular group
ADC_EXTERNALTRIGCONV_T1_CC1
ADC_EXTERNALTRIGCONV_T1_CC2
ADC_EXTERNALTRIGCONV_T2_CC2
ADC_EXTERNALTRIGCONV_T3_CC4
ADC_EXTERNALTRIGCONV_T4_CC4
ADC_EXTERNALTRIGCONV_T6_TRGO
ADC_EXTERNALTRIGCONV_EXT_IT11
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
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_EXTERNALTRIGCONV_T20_MASK
136/861
ADC_EXTERNALTRIGCONV_T20_CC2
External trigger of regular group for
ADC1&ADC2 only, specific to device
STM303xE, using Timer20 with ADC trigger
input remap. Remap trigger using macro
ADC_EXTERNALTRIGCONV_T20_CC3
External trigger of regular group for
DOCID026526 Rev 2
UM1786
HAL ADC Extension Driver
ADC1&ADC2 only, specific to device
STM303xE, using Timer20 with ADC trigger
input remap. Remap trigger using macro
ADC_EXTERNALTRIGCONV_T20_CC1
External trigger of regular group for
ADC1&ADC2, ADC3&ADC4, specific to
device STM303xE, sing Timer20 with ADC
trigger input remap. For ADC1&ADC2:
Remap trigger using macro
ADC_EXTERNALTRIGCONV_T20_TRGO
External trigger of regular group for
ADC1&ADC2, ADC3&ADC4, specific to
device STM303xE, sing Timer20 with ADC
trigger input remap. For ADC1&ADC2:
Remap trigger using macro
ADC_EXTERNALTRIGCONV_T20_TRGO2
External trigger of regular group for
ADC1&ADC2, ADC3&ADC4, specific to
device STM303xE, sing Timer20 with ADC
trigger input remap. For ADC1&ADC2:
Remap trigger using macro
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 External Trigger Source of Injected Group (Internal)
ADC1_2_EXTERNALTRIGINJEC_T1_TRGO
ADC1_2_EXTERNALTRIGINJEC_T1_CC4
DOCID026526 Rev 2
137/861
HAL ADC Extension Driver
ADC1_2_EXTERNALTRIGINJEC_T2_TRGO
ADC1_2_EXTERNALTRIGINJEC_T2_CC1
ADC1_2_EXTERNALTRIGINJEC_T3_CC4
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_T20_TRGO
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 External trigger selection for regular group (Used Internally)
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
138/861
DOCID026526 Rev 2
UM1786
UM1786
HAL ADC Extension Driver
ADC1_2_EXTERNALTRIG_T4_CC4
ADC1_2_EXTERNALTRIG_EXT_IT11
ADC1_2_EXTERNALTRIG_T8_TRGO
ADC1_2_EXTERNALTRIG_T8_TRGO2
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)
DOCID026526 Rev 2
139/861
HAL ADC Extension Driver
ADC_IT_AWD2
UM1786
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
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 Private Constants
ADC_CALIBRATION_TIMEOUT
ADC_ENABLE_TIMEOUT
ADC_DISABLE_TIMEOUT
ADC_STOP_CONVERSION_TIMEOUT
ADC_CONVERSION_TIME_MAX_CPU_CYCLES
ADC_STAB_DELAY_US
ADC_TEMPSENSOR_DELAY_US
ADCEx Private Private Macros
ADC_ENABLING_CONDITIONS
Description:

Verification of hardware
constraints before ADC can be
enabled.
Parameters:

__HANDLE__: ADC handle
Return value:

SET: (ADC can be enabled) or
RESET (ADC cannot be
enabled)
Description:
ADC_IS_ENABLED

Verification of ADC state:
enabled or disabled.
Parameters:
140/861
DOCID026526 Rev 2
UM1786
HAL ADC Extension Driver

__HANDLE__: ADC handle
Return value:

ADC_IS_SOFTWARE_START_REGULAR
SET: (ADC enabled) or RESET
(ADC disabled)
Description:

Test if conversion trigger of
regular group is software start or
external trigger.
Parameters:

__HANDLE__: ADC handle
Return value:

ADC_IS_SOFTWARE_START_INJECTED
SET: (software start) or RESET
(external trigger)
Description:

Test if conversion trigger of
injected group is software start
or external trigger.
Parameters:

__HANDLE__: ADC handle
Return value:

ADC_IS_CONVERSION_ONGOING_REGULAR_I
NJECTED
SET: (software start) or RESET
(external trigger)
Description:

Check if no conversion on going
on regular and/or injected
groups.
Parameters:

__HANDLE__: ADC handle
Return value:

ADC_IS_CONVERSION_ONGOING_REGULAR
SET: (conversion is on going) or
RESET (no conversion is on
going)
Description:

Check if no conversion on going
on regular group.
Parameters:

__HANDLE__: ADC handle
Return value:

DOCID026526 Rev 2
SET: (conversion is on going) or
RESET (no conversion is on
going)
141/861
HAL ADC Extension Driver
ADC_IS_CONVERSION_ONGOING_INJECTED
UM1786
Description:

Check if no conversion on going
on injected group.
Parameters:

__HANDLE__: ADC handle
Return value:

SET: (conversion is on going) or
RESET (no conversion is on
going)
Description:
ADC_GET_RESOLUTION

Returns resolution bits in
CFGR1 register: RES[1:0].
Parameters:

__HANDLE__: ADC handle
Return value:

ADC_CLEAR_ERRORCODE
None:
Description:

Clear ADC error code (set it to
error code: "no error")
Parameters:

__HANDLE__: ADC handle
Return value:

None:
Description:
ADC_SMPR1

Set the ADC's sample time for
Channels numbers between 0
and 9.
Parameters:


_SAMPLETIME_: Sample time
parameter.
_CHANNELNB_: Channel
number.
Return value:

None:
Description:
ADC_SMPR2

Set the ADC's sample time for
Channels numbers between 10
and 18.
Parameters:

142/861
DOCID026526 Rev 2
_SAMPLETIME_: Sample time
parameter.
UM1786
HAL ADC Extension Driver

_CHANNELNB_: Channel
number.
Return value:

None:
Description:
ADC_SQR1_RK

Set the selected regular Channel
rank for rank between 1 and 4.
Parameters:


_CHANNELNB_: Channel
number.
_RANKNB_: Rank number.
Return value:

None:
Description:
ADC_SQR2_RK

Set the selected regular Channel
rank for rank between 5 and 9.
Parameters:


_CHANNELNB_: Channel
number.
_RANKNB_: Rank number.
Return value:

None:
Description:
ADC_SQR3_RK

Set the selected regular Channel
rank for rank between 10 and
14.
Parameters:


_CHANNELNB_: Channel
number.
_RANKNB_: Rank number.
Return value:

None:
Description:
ADC_SQR4_RK

Set the selected regular Channel
rank for rank between 15 and
16.
Parameters:


_CHANNELNB_: Channel
number.
_RANKNB_: Rank number.
Return value:
DOCID026526 Rev 2
143/861
HAL ADC Extension Driver
UM1786

None:
Description:
ADC_JSQR_RK

Set the selected injected
Channel rank.
Parameters:


_CHANNELNB_: Channel
number.
_RANKNB_: Rank number.
Return value:

ADC_CFGR_AWD1CH_SHIFT
None:
Description:

Set the Analog Watchdog 1
channel.
Parameters:

_CHANNEL_: channel to be
monitored by Analog Watchdog
1.
Return value:

None:
Description:
ADC_CFGR_AWD23CR

Configure the channel number
into Analog Watchdog 2 or 3.
Parameters:

_CHANNEL_: ADC Channel
Return value:

ADC_CFGR_INJECT_AUTO_CONVERSION
None:
Description:

Enable automatic conversion of
injected group.
Parameters:

_INJECT_AUTO_CONVERSIO
N_: Injected automatic
conversion.
Return value:

ADC_CFGR_INJECT_CONTEXT_QUEUE
None:
Description:

Enable ADC injected context
queue.
Parameters:

144/861
DOCID026526 Rev 2
_INJECT_CONTEXT_QUEUE_
UM1786
HAL ADC Extension Driver
MODE_: Injected context queue
mode.
Return value:

ADC_CFGR_INJECT_DISCCONTINUOUS
None:
Description:

Enable ADC discontinuous
conversion mode for injected
group.
Parameters:

_INJECT_DISCONTINUOUS_M
ODE_: Injected discontinuous
mode.
Return value:

ADC_CFGR_REG_DISCCONTINUOUS
None:
Description:

Enable ADC discontinuous
conversion mode for regular
group.
Parameters:

_REG_DISCONTINUOUS_MOD
E_: Regular discontinuous
mode.
Return value:

ADC_CFGR_DISCONTINUOUS_NUM
None:
Description:

Configures the number of
discontinuous conversions for
regular group.
Parameters:

_NBR_DISCONTINUOUS_CON
V_: Number of discontinuous
conversions.
Return value:

None:
Description:
ADC_CFGR_AUTOWAIT

Enable the ADC auto delay
mode.
Parameters:

_AUTOWAIT_: Auto delay bit
enable or disable.
Return value:
DOCID026526 Rev 2
145/861
HAL ADC Extension Driver
UM1786

ADC_CFGR_CONTINUOUS
None:
Description:

Enable ADC continuous
conversion mode.
Parameters:

_CONTINUOUS_MODE_:
Continuous mode.
Return value:

None:
Description:
ADC_CFGR_OVERRUN

Enable ADC overrun mode.
Parameters:

_OVERRUN_MODE_: Overrun
mode.
Return value:

ADC_CFGR_DMACONTREQ
Overrun: bit setting to be
programmed into CFGR register
Description:

Enable the ADC DMA
continuous request.
Parameters:

_DMACONTREQ_MODE_:
DMA continuous request mode.
Return value:

None:
Description:
ADC_CFGR_EXTSEL_SET

For devices with 3 ADCs or
more: Defines the external
trigger source for regular group
according to ADC into common
group ADC1&ADC2 or
ADC3&ADC4 (some triggers
with same source have different
value to be programmed into
ADC EXTSEL bits of CFGR
register).
Parameters:


__HANDLE__: ADC handle
__EXT_TRIG_CONV__:
External trigger selected for
regular group.
Return value:
146/861
DOCID026526 Rev 2
UM1786
HAL ADC Extension Driver

ADC_JSQR_JEXTSEL_SET
External: trigger to be
programmed into EXTSEL bits
of CFGR register
Description:

For devices with 3 ADCs or
more: Defines the external
trigger source for injected group
according to ADC into common
group ADC1&ADC2 or
ADC3&ADC4 (some triggers
with same source have different
value to be programmed into
ADC JEXTSEL bits of JSQR
register).
Parameters:


__HANDLE__: ADC handle
__EXT_TRIG_INJECTCONV__:
External trigger selected for
injected group
Return value:

External: trigger to be
programmed into JEXTSEL bits
of JSQR register
Description:
ADC_OFR_CHANNEL

Configure the channel number
into offset OFRx register.
Parameters:

_CHANNEL_: ADC Channel
Return value:

None:
Description:
ADC_DIFSEL_CHANNEL

Configure the channel number
into differential mode selection
register.
Parameters:

_CHANNEL_: ADC Channel
Return value:

None:
Description:
ADC_CALFACT_DIFF_SET

Calibration factor in differential
mode to be set into calibration
register.
Parameters:
DOCID026526 Rev 2
147/861
HAL ADC Extension Driver
UM1786

_Calibration_Factor_:
Calibration factor value
Return value:

None:
Description:
ADC_CALFACT_DIFF_GET

Calibration factor in differential
mode to be retrieved from
calibration register.
Parameters:

_Calibration_Factor_:
Calibration factor value
Return value:

ADC_TRX_HIGHTHRESHOLD
None:
Description:

Configure the analog watchdog
high threshold into registers
TR1, TR2 or TR3.
Parameters:

_Threshold_: Threshold value
Return value:

ADC_CCR_MULTI_DMACONTREQ
None:
Description:

Enable the ADC DMA
continuous request for ADC
multimode.
Parameters:

_DMAContReq_MODE_: DMA
continuous request mode.
Return value:

ADC_DISABLING_CONDITIONS
None:
Description:

Verification of hardware
constraints before ADC can be
disabled.
Parameters:

__HANDLE__: ADC handle
Return value:

148/861
DOCID026526 Rev 2
SET: (ADC can be disabled) or
RESET (ADC cannot be
disabled)
UM1786
ADC_OFFSET_SHIFT_RESOLUTION
HAL ADC Extension Driver
Description:

Shift the offset in function of the
selected ADC resolution.
Parameters:


__HANDLE__: ADC handle
_Offset_: Value to be shifted
Return value:

ADC_AWD1THRESHOLD_SHIFT_RESOLUTION
None:
Description:

Shift the AWD1 threshold in
function of the selected ADC
resolution.
Parameters:


__HANDLE__: ADC handle
_Threshold_: Value to be shifted
Return value:

ADC_AWD23THRESHOLD_SHIFT_RESOLUTIO
N
None:
Description:

Shift the AWD2 and AWD3
threshold in function of the
selected ADC resolution.
Parameters:


__HANDLE__: ADC handle
_Threshold_: Value to be shifted
Return value:

ADC_COMMON_REGISTER
None:
Description:

Defines if the selected ADC is
within ADC common register
ADC1_2 or ADC3_4 if available
(ADC2, ADC3, ADC4 availability
depends on STM32 product)
Parameters:

__HANDLE__: ADC handle
Return value:

ADC_COMMON_CCR_MULTI
Description:

DOCID026526 Rev 2
Common: control register
ADC1_2 or ADC3_4
Selection of ADC common
register CCR bits
MULTI[4:0]corresponding to the
selected ADC (applicable for
149/861
HAL ADC Extension Driver
UM1786
devices with several ADCs)
Parameters:

__HANDLE__: ADC handle
Return value:

ADC_NONMULTIMODE_OR_MULTIMODEMAST
ER
None:
Description:

Verification of condition for ADC
start conversion: ADC must be
in non-multimode, or multimode
with handle of ADC master
(applicable for devices with
several ADCs)
Parameters:

__HANDLE__: ADC handle
Return value:

ADC_COMMON_ADC_OTHER
None:
Description:

Set handle of the other ADC
sharing the same common
register ADC1_2 or ADC3_4 if
available (ADC2, ADC3, ADC4
availability depends on STM32
product)
Parameters:


__HANDLE__: ADC handle
__HANDLE_OTHER_ADC__:
other ADC handle
Return value:

None:
Description:
ADC_MULTI_SLAVE

Set handle of the ADC slave
associated to the ADC master if
available (ADC2, ADC3, ADC4
availability depends on STM32
product)
Parameters:


__HANDLE_MASTER__: ADC
master handle
__HANDLE_SLAVE__: ADC
slave handle
Return value:

150/861
DOCID026526 Rev 2
None:
UM1786
HAL ADC Extension Driver
IS_ADC_RESOLUTION
IS_ADC_RESOLUTION_8_6_BITS
IS_ADC_DATA_ALIGN
IS_ADC_SCAN_MODE
IS_ADC_EOC_SELECTION
IS_ADC_OVERRUN
IS_ADC_CHANNEL
IS_ADC_DIFF_CHANNEL
IS_ADC_SAMPLE_TIME
IS_ADC_SINGLE_DIFFERENTIAL
IS_ADC_OFFSET_NUMBER
IS_ADC_REGULAR_RANK
IS_ADC_EXTTRIG_EDGE
IS_ADC_EXTTRIG
IS_ADC_EXTTRIGINJEC_EDGE
IS_ADC_EXTTRIGINJEC
IS_ADC_INJECTED_RANK
IS_ADC_MODE
IS_ADC_DMA_ACCESS_MODE
IS_ADC_SAMPLING_DELAY
IS_ADC_ANALOG_WATCHDOG_NUMBER
IS_ADC_ANALOG_WATCHDOG_MODE
IS_ADC_CONVERSION_GROUP
IS_ADC_EVENT_TYPE
IS_ADC_IT
IS_ADC_FLAG
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
DOCID026526 Rev 2
151/861
HAL ADC Extension Driver
ADC_REGULAR_RANK_8
UM1786
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_RESOLUTION12B
ADC 12-bit resolution
ADC_RESOLUTION10B
ADC 10-bit resolution
ADC_RESOLUTION8B
ADC 8-bit resolution
ADC_RESOLUTION6B
ADC 6-bit resolution
ADC Extended Sampling Times
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
152/861
DOCID026526 Rev 2
UM1786
HAL CAN Generic Driver
6
HAL CAN Generic Driver
6.1
CAN Firmware driver registers structures
6.1.1
CAN_InitTypeDef
CAN_InitTypeDef is defined in the stm32f3xx_hal_can.h
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








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.
DOCID026526 Rev 2
153/861
HAL CAN Generic Driver



6.1.2
UM1786
uint32_t CAN_InitTypeDef::NART
Enable or disable the non-automatic retransmission mode. This parameter can be set
to ENABLE or DISABLE.
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
CAN_FilterConfTypeDef is defined in the stm32f3xx_hal_can.h
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






154/861
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.
DOCID026526 Rev 2
UM1786
HAL CAN Generic Driver




6.1.3
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
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 This parameter must be a number between Min_Data
= 0 and Max_Data = 28.
CanTxMsgTypeDef
CanTxMsgTypeDef is defined in the stm32f3xx_hal_can.h
Data Fields






uint32_t StdId
uint32_t ExtId
uint32_t IDE
uint32_t RTR
uint32_t DLC
uint32_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.
uint32_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
CanRxMsgTypeDef is defined in the stm32f3xx_hal_can.h
Data Fields
DOCID026526 Rev 2
155/861
HAL CAN Generic Driver








UM1786
uint32_t StdId
uint32_t ExtId
uint32_t IDE
uint32_t RTR
uint32_t DLC
uint32_t Data
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.
uint32_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
CAN_HandleTypeDef is defined in the stm32f3xx_hal_can.h
Data Fields







CAN_TypeDef * Instance
CAN_InitTypeDef Init
CanTxMsgTypeDef * pTxMsg
CanRxMsgTypeDef * pRxMsg
HAL_LockTypeDef Lock
__IO HAL_CAN_StateTypeDef State
__IO HAL_CAN_ErrorTypeDef ErrorCode
Field Documentation
156/861
DOCID026526 Rev 2
UM1786
HAL CAN Generic Driver







6.2
CAN_TypeDef* CAN_HandleTypeDef::Instance
Register base address
CAN_InitTypeDef CAN_HandleTypeDef::Init
CAN required parameters
CanTxMsgTypeDef* CAN_HandleTypeDef::pTxMsg
Pointer to transmit structure
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 HAL_CAN_ErrorTypeDef CAN_HandleTypeDef::ErrorCode
CAN Error code
CAN Firmware driver API description
The following section lists the various functions of the CAN library.
6.2.1
How to use this driver
1.
2.
3.
4.
5.
Enable the CAN controller interface clock using __CAN_CLK_ENABLE();
CAN pins configuration

Enable the clock for the CAN GPIOs using the following function:
__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
DOCID026526 Rev 2
157/861
HAL CAN Generic Driver

UM1786
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.





__HAL_CAN_ENABLE_IT: Enable the specified CAN interrupts
__HAL_CAN_DISABLE_IT: Disable the specified CAN interrupts
__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:







6.2.3
Initialize and configure the CAN.
De-initialize the CAN.
HAL_CAN_Init()
HAL_CAN_ConfigFilter()
HAL_CAN_DeInit()
HAL_CAN_MspInit()
HAL_CAN_MspDeInit()
IO operation functions
This section provides functions allowing to:














6.2.4
158/861
Transmit a CAN frame message.
Receive a CAN frame message.
Enter CAN peripheral in sleep mode.
Wake up the CAN peripheral from sleep mode.
HAL_CAN_Transmit()
HAL_CAN_Transmit_IT()
HAL_CAN_Receive()
HAL_CAN_Receive_IT()
HAL_CAN_Sleep()
HAL_CAN_WakeUp()
HAL_CAN_IRQHandler()
HAL_CAN_TxCpltCallback()
HAL_CAN_RxCpltCallback()
HAL_CAN_ErrorCallback()
Peripheral State and Error functions
DOCID026526 Rev 2
UM1786
HAL CAN Generic Driver
This subsection provides functions allowing to :




6.2.5
6.2.6
Check the CAN state.
Check CAN Errors detected during interrupt process
HAL_CAN_GetState()
HAL_CAN_GetError()
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
parameters in the CAN_FilterInitStruct.
Parameters

Return values
6.2.7
6.2.8

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.
DOCID026526 Rev 2
159/861
HAL CAN Generic Driver
Parameters
Return values
6.2.9
6.2.10
6.2.12

None
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


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
HAL_StatusTypeDef HAL_CAN_Transmit_IT
(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
160/861
hcan: pointer to a CAN_HandleTypeDef structure that
contains the configuration information for the specified CAN.
HAL_CAN_MspDeInit
Return values
6.2.11
UM1786



hcan: pointer to a CAN_HandleTypeDef structure that
contains the configuration information for the specified CAN.
FIFONumber: FIFO number.
Timeout: Timeout duration.

HAL status
DOCID026526 Rev 2
UM1786
HAL CAN Generic Driver

6.2.13
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
6.2.14
6.2.15
6.2.16
None

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.
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
DOCID026526 Rev 2
161/861
HAL CAN Generic Driver
6.2.17
6.2.18
6.2.19
6.2.20
6.2.21
162/861
UM1786
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_GetState
Function Name
HAL_CAN_StateTypeDef HAL_CAN_GetState
(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
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.
DOCID026526 Rev 2
UM1786
HAL CAN Generic Driver
Return values
6.3

CAN Error Code
CAN Firmware driver defines
The following section lists the various define and macros of the module.
6.3.1
CAN
CAN
CAN Clock Prescaler
IS_CAN_PRESCALER
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 2
163/861
HAL CAN Generic Driver
UM1786

CAN_FLAG_MASK
The: number of pending message.
Description:

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:

The: new state of __FLAG__ (TRUE or
FALSE).
__HAL_CAN_GET_FLAG
164/861
DOCID026526 Rev 2
UM1786
HAL CAN Generic Driver
__HAL_CAN_CLEAR_FLAG
Description:

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:
DOCID026526 Rev 2
165/861
HAL CAN Generic Driver
UM1786


__HANDLE__: specifies the CAN Handle.
__INTERRUPT__: specifies the CAN
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
Description:

166/861
None:
Enable or disables the DBG Freeze for
CAN.
DOCID026526 Rev 2
UM1786
HAL CAN Generic Driver
Parameters:


__HANDLE__: specifies the CAN Handle.
__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
IS_CAN_FILTER_FIFO
CAN_FilterFIFO0
CAN_FilterFIFO1
CAN Filter Mode
CAN_FILTERMODE_IDMASK
Identifier mask mode
CAN_FILTERMODE_IDLIST
Identifier list mode
IS_CAN_FILTER_MODE
CAN Filter Number
IS_CAN_FILTER_NUMBER
CAN Filter Scale
CAN_FILTERSCALE_16BIT
Two 16-bit filters
CAN_FILTERSCALE_32BIT
One 32-bit filter
IS_CAN_FILTER_SCALE
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
DOCID026526 Rev 2
167/861
HAL CAN Generic Driver
CAN_FLAG_FF1
UM1786
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
IS_CAN_GET_FLAG
IS_CAN_CLEAR_FLAG
CAN Identifier Type
CAN_ID_STD
Standard Id
CAN_ID_EXT
Extended Id
IS_CAN_IDTYPE
CAN initialization Status
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_IT_RQCP0
CAN_IT_RQCP1
CAN_IT_RQCP2
IS_CAN_IT
168/861
DOCID026526 Rev 2
UM1786
HAL CAN Generic Driver
IS_CAN_CLEAR_IT
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
IS_CAN_MODE
CAN Private Constants
HAL_CAN_DEFAULT_TIMEOUT
CAN Receive FIFO Number
CAN_FIFO0
CAN FIFO 0 used to receive
CAN_FIFO1
CAN FIFO 1 used to receive
IS_CAN_FIFO
CAN Remote Transmission Request
CAN_RTR_DATA
Data frame
CAN_RTR_REMOTE
Remote frame
IS_CAN_RTR
CAN Start Bank Filter For Slave CAN
IS_CAN_BANKNUMBER
CAN Synchronization Jump Width
CAN_SJW_1TQ
1 time quantum
CAN_SJW_2TQ
2 time quantum
CAN_SJW_3TQ
3 time quantum
CAN_SJW_4TQ
4 time quantum
IS_CAN_SJW
CAN Timeouts
INAK_TIMEOUT
SLAK_TIMEOUT
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
DOCID026526 Rev 2
169/861
HAL CAN Generic Driver
CAN_BS1_4TQ
4 time quantum
UM1786
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
IS_CAN_BS1
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
IS_CAN_BS2
CAN Transmit Constants
CAN_TXSTATUS_FAILED
CAN transmission failed
CAN_TXSTATUS_OK
CAN transmission succeeded
CAN_TXSTATUS_PENDING
CAN transmission pending
CAN_TXSTATUS_NOMAILBOX
CAN cell did not provide CAN_TxStatus_NoMailBox
CAN Tx
IS_CAN_TRANSMITMAILBOX
IS_CAN_STDID
IS_CAN_EXTID
IS_CAN_DLC
170/861
DOCID026526 Rev 2
UM1786
HAL CEC Generic Driver
7
HAL CEC Generic Driver
7.1
CEC Firmware driver registers structures
7.1.1
CEC_InitTypeDef
CEC_InitTypeDef is defined in the stm32f3xx_hal_cec.h
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






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 : it is either CEC_STANDARD_TOLERANCE or
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
DOCID026526 Rev 2
171/861
HAL CEC Generic Driver
UM1786
BRESTP=CEC_RX_STOP_ON_BRE and
BREGEN=CEC_BRE_ERRORBIT_NO_GENERATION. b) LBPE detection: error-bit
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
7.1.2
CEC_HandleTypeDef
CEC_HandleTypeDef is defined in the stm32f3xx_hal_cec.h
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









172/861
CEC_TypeDef* CEC_HandleTypeDef::Instance
CEC_InitTypeDef CEC_HandleTypeDef::Init
uint8_t* CEC_HandleTypeDef::pTxBuffPtr
uint16_t CEC_HandleTypeDef::TxXferCount
uint8_t* CEC_HandleTypeDef::pRxBuffPtr
uint16_t CEC_HandleTypeDef::RxXferSize
uint32_t CEC_HandleTypeDef::ErrorCode
HAL_LockTypeDef CEC_HandleTypeDef::Lock
HAL_CEC_StateTypeDef CEC_HandleTypeDef::State
DOCID026526 Rev 2
UM1786
7.2
HAL CEC Generic Driver
CEC Firmware driver API description
The following section lists the various functions of the CEC library.
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





7.2.3
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
HAL_CEC_Init()
HAL_CEC_DeInit()
HAL_CEC_MspInit()
HAL_CEC_MspDeInit()
IO operation function
DOCID026526 Rev 2
173/861
HAL CEC Generic Driver








7.2.4
UM1786
HAL_CEC_Transmit()
HAL_CEC_Receive()
HAL_CEC_Transmit_IT()
HAL_CEC_Receive_IT()
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.



7.2.5
7.2.6
7.2.7
7.2.8
174/861
HAL_CEC_GetState() API can be helpful to check in run-time the state of the CEC
peripheral.
HAL_CEC_GetState()
HAL_CEC_GetError()
HAL_CEC_Init
Function Name
HAL_StatusTypeDef HAL_CEC_Init (CEC_HandleTypeDef *
hcec)
Function Description
Initializes 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
DeInitializes 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
DOCID026526 Rev 2
UM1786
7.2.9
Function Name
HAL CEC Generic Driver
void HAL_CEC_MspDeInit (CEC_HandleTypeDef * hcec)
Function Description
CEC MSP DeInit.
Parameters

hcec: CEC handle
Return values

None
HAL_CEC_Transmit
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




Return values
7.2.10
7.2.11

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).
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. Note that 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
Return values

HAL status
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
DOCID026526 Rev 2
175/861
HAL CEC Generic Driver
Return values
7.2.12
7.2.13
7.2.14
7.2.15
176/861
UM1786


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).

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. Note that 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
Return values

HAL status
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
DOCID026526 Rev 2
UM1786
7.2.16
7.2.17
7.2.18
7.3
HAL CEC Generic Driver
HAL_CEC_ErrorCallback
Function Name
void HAL_CEC_ErrorCallback (CEC_HandleTypeDef * hcec)
Function Description
CEC error callbacks.
Parameters

hcec: CEC handle
Return values

None
HAL_CEC_GetState
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
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
CEC Firmware driver defines
The following section lists the various define and macros of the module.
7.3.1
CEC
CEC
all RX or TX errors flags in CEC ISR register
CEC_ISR_ALL_ERROR
Error Bit Generation if Bit Rise Error reported
CEC_BRE_ERRORBIT_NO_GENERATION
CEC_BRE_ERRORBIT_GENERATION
IS_CEC_BREERRORBITGEN
Reception Stop on Error
CEC_NO_RX_STOP_ON_BRE
CEC_RX_STOP_ON_BRE
IS_CEC_BRERXSTOP
DOCID026526 Rev 2
177/861
HAL CEC Generic Driver
Error Bit Generation on Broadcast message
UM1786
CEC_BROADCASTERROR_ERRORBIT_GENERATION
CEC_BROADCASTERROR_NO_ERRORBIT_GENERATION
IS_CEC_BROADCASTERROR_NO_ERRORBIT_GENERATION
CEC Exported Macros
__HAL_CEC_RESET_HANDLE_STATE
Description:

Reset CEC handle state.
Parameters:

__HANDLE__: CEC handle.
Return value:

None:
Description:
__HAL_CEC_GET_IT

Checks whether or not the
specified CEC interrupt flag is
set.
Parameters:


178/861
DOCID026526 Rev 2
__HANDLE__: specifies the
CEC Handle.
__INTERRUPT__: specifies
the interrupt to check. This
parameter can be one of the
following values:

CEC_ISR_RXBR : RxByte Received

CEC_ISR_RXEND : End
of Reception

CEC_ISR_RXOVR : Rx
Overrun

CEC_ISR_BRE : Rx Bit
Rising Error

CEC_ISR_SBPE : Rx
Short Bit Period Error

CEC_ISR_LBPE : Rx
Long Bit Period Error

CEC_ISR_RXACKE : Rx
Missing Acknowledge

CEC_ISR_ARBLST :
Arbitration lost

CEC_ISR_TXBR : Tx-Byte
Request

CEC_ISR_TXEND : End
of Transmission

CEC_ISR_TXUDR : Txbuffer Underrun

CEC_ISR_TXERR : Tx
Error

CEC_ISR_TXACKE : Tx
UM1786
HAL CEC Generic Driver
Missing Acknowledge
Return value:

__HAL_CEC_CLEAR_FLAG
ITStatus:
Description:

Clears the interrupt or status
flag when raised (write at 1)
Parameters:


__HANDLE__: specifies the
CEC Handle.
__FLAG__: specifies the
interrupt/status flag to clear.
This parameter can be one of
the following values:

CEC_ISR_RXBR : RxByte Received

CEC_ISR_RXEND : End
of Reception

CEC_ISR_RXOVR : Rx
Overrun

CEC_ISR_BRE : Rx Bit
Rising Error

CEC_ISR_SBPE : Rx
Short Bit Period Error

CEC_ISR_LBPE : Rx
Long Bit Period Error

CEC_ISR_RXACKE : Rx
Missing Acknowledge

CEC_ISR_ARBLST :
Arbitration lost

CEC_ISR_TXBR : Tx-Byte
Request

CEC_ISR_TXEND : End
of Transmission

CEC_ISR_TXUDR : Txbuffer Underrun

CEC_ISR_TXERR : Tx
Error

CEC_ISR_TXACKE : Tx
Missing Acknowledge
Return value:

none:
Description:
__HAL_CEC_ENABLE_IT

Enables the specified CEC
interrupt.
Parameters:


DOCID026526 Rev 2
__HANDLE__: specifies the
CEC Handle.
__INTERRUPT__: specifies
179/861
HAL CEC Generic Driver
UM1786
the CEC interrupt to enable.
This parameter can be one of
the following values:

CEC_IER_RXBRIE : RxByte Received IT Enable

CEC_IER_RXENDIE :
End Of Reception IT
Enable

CEC_IER_RXOVRIE : RxOverrun IT Enable

CEC_IER_BREIE : Rx Bit
Rising Error IT Enable

CEC_IER_SBPEIE : Rx
Short Bit period Error IT
Enable

CEC_IER_LBPEIE : Rx
Long Bit period Error IT
Enable

CEC_IER_RXACKEIE :
Rx Missing Acknowledge
IT Enable

CEC_IER_ARBLSTIE :
Arbitration Lost IT Enable

CEC_IER_TXBRIE : Tx
Byte Request IT Enable

CEC_IER_TXENDIE : End
of Transmission IT Enable

CEC_IER_TXUDRIE : TxBuffer Underrun IT Enable

CEC_IER_TXERRIE : TxError IT Enable

CEC_IER_TXACKEIE : Tx
Missing Acknowledge IT
Enable
Return value:

none:
Description:
__HAL_CEC_DISABLE_IT

Disables the specified CEC
interrupt.
Parameters:


180/861
DOCID026526 Rev 2
__HANDLE__: specifies the
CEC Handle.
__INTERRUPT__: specifies
the CEC interrupt to disable.
This parameter can be one of
the following values:

CEC_IER_RXBRIE : RxByte Received IT Enable

CEC_IER_RXENDIE :
End Of Reception IT
Enable
UM1786
HAL CEC Generic Driver











CEC_IER_RXOVRIE : RxOverrun IT Enable
CEC_IER_BREIE : Rx Bit
Rising Error IT Enable
CEC_IER_SBPEIE : Rx
Short Bit period Error IT
Enable
CEC_IER_LBPEIE : Rx
Long Bit period Error IT
Enable
CEC_IER_RXACKEIE :
Rx Missing Acknowledge
IT Enable
CEC_IER_ARBLSTIE :
Arbitration Lost IT Enable
CEC_IER_TXBRIE : Tx
Byte Request IT Enable
CEC_IER_TXENDIE : End
of Transmission IT Enable
CEC_IER_TXUDRIE : TxBuffer Underrun IT Enable
CEC_IER_TXERRIE : TxError IT Enable
CEC_IER_TXACKEIE : Tx
Missing Acknowledge IT
Enable
Return value:

__HAL_CEC_GET_IT_SOURCE
none:
Description:

Checks whether or not the
specified CEC interrupt is
enabled.
Parameters:


DOCID026526 Rev 2
__HANDLE__: specifies the
CEC Handle.
__INTERRUPT__: specifies
the CEC interrupt to check.
This parameter can be one of
the following values:

CEC_IER_RXBRIE : RxByte Received IT Enable

CEC_IER_RXENDIE :
End Of Reception IT
Enable

CEC_IER_RXOVRIE : RxOverrun IT Enable

CEC_IER_BREIE : Rx Bit
Rising Error IT Enable

CEC_IER_SBPEIE : Rx
Short Bit period Error IT
Enable
181/861
HAL CEC Generic Driver
UM1786








CEC_IER_LBPEIE : Rx
Long Bit period Error IT
Enable
CEC_IER_RXACKEIE :
Rx Missing Acknowledge
IT Enable
CEC_IER_ARBLSTIE :
Arbitration Lost IT Enable
CEC_IER_TXBRIE : Tx
Byte Request IT Enable
CEC_IER_TXENDIE : End
of Transmission IT Enable
CEC_IER_TXUDRIE : TxBuffer Underrun IT Enable
CEC_IER_TXERRIE : TxError IT Enable
CEC_IER_TXACKEIE : Tx
Missing Acknowledge IT
Enable
Return value:

FlagStatus:
Description:
__HAL_CEC_ENABLE

Enables the CEC device.
Parameters:

__HANDLE__: specifies the
CEC Handle.
Return value:

none:
Description:
__HAL_CEC_DISABLE

Disables 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
182/861
DOCID026526 Rev 2
none:
Description:
UM1786
HAL CEC Generic Driver

Set Transmission End flag.
Parameters:

__HANDLE__: specifies the
CEC Handle.
Return value:

__HAL_CEC_GET_TRANSMISSION_START_FLA
G
none: If the CEC message
consists of only one byte,
TXEOM must be set before of
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:

FlagStatus:
Description:
__HAL_CEC_CLEAR_OAR

Clear OAR register.
Parameters:

__HANDLE__: specifies the
CEC Handle.
Return value:

none:
Description:
__HAL_CEC_SET_OAR

Set OAR register (without
resetting previously set
address in case of multiaddress mode) To reset OAR,
Parameters:


DOCID026526 Rev 2
__HANDLE__: specifies the
CEC Handle.
__ADDRESS__: Own Address
value (CEC logical address is
identified by bit position)
183/861
HAL CEC Generic Driver
UM1786
Return value:

none:
Description:
IS_CEC_OAR_ADDRESS

Check CEC device Own
Address Register (OAR)
setting.
Parameters:

__ADDRESS__: CEC own
address.
Return value:

Test: result (TRUE or FALSE).
Description:
IS_CEC_ADDRESS

Check CEC initiator or
destination logical address
setting.
Parameters:

__ADDRESS__: CEC initiator
or logical address.
Return value:

Test: result (TRUE or FALSE).
Description:
IS_CEC_MSGSIZE

Check CEC message size.
Parameters:

__SIZE__: CEC message size.
Return value:

all RX errors interrupts enabling flag
CEC_IER_RX_ALL_ERR
all TX errors interrupts enabling flag
CEC_IER_TX_ALL_ERR
Initiator logical address position in message header
CEC_INITIATOR_LSB_POS
Error Bit Generation if Long Bit Period Error reported
CEC_LBPE_ERRORBIT_NO_GENERATION
CEC_LBPE_ERRORBIT_GENERATION
IS_CEC_LBPEERRORBITGEN
Listening mode option
CEC_REDUCED_LISTENING_MODE
184/861
DOCID026526 Rev 2
Test: result (TRUE or FALSE).
UM1786
HAL CEC Generic Driver
CEC_FULL_LISTENING_MODE
IS_CEC_LISTENING_MODE
Device Own Address position in CEC CFGR register
CEC_CFGR_OAR_LSB_POS
CEC Private Constants
CEC_CFGR_FIELDS
Signal Free Time start option
CEC_SFT_START_ON_TXSOM
CEC_SFT_START_ON_TX_RX_END
IS_CEC_SFTOP
Signal Free Time setting parameter
CEC_DEFAULT_SFT
CEC_0_5_BITPERIOD_SFT
CEC_1_5_BITPERIOD_SFT
CEC_2_5_BITPERIOD_SFT
CEC_3_5_BITPERIOD_SFT
CEC_4_5_BITPERIOD_SFT
CEC_5_5_BITPERIOD_SFT
CEC_6_5_BITPERIOD_SFT
IS_CEC_SIGNALFREETIME
Receiver Tolerance
CEC_STANDARD_TOLERANCE
CEC_EXTENDED_TOLERANCE
IS_CEC_TOLERANCE
DOCID026526 Rev 2
185/861
HAL COMP Generic Driver
UM1786
8
HAL COMP Generic Driver
8.1
COMP Firmware driver registers structures
8.1.1
COMP_InitTypeDef
COMP_InitTypeDef is defined in the stm32f3xx_hal_comp.h
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








186/861
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/xC and
STM32F378xx devices
uint32_t COMP_InitTypeDef::Mode
Selects the operating comsumption 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 2
UM1786
HAL COMP Generic Driver

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
COMP_HandleTypeDef is defined in the stm32f3xx_hal_comp.h
Data Fields




COMP_TypeDef * Instance
COMP_InitTypeDef Init
HAL_LockTypeDef Lock
__IO HAL_COMP_StateTypeDef State
Field Documentation




8.2
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
COMP Firmware driver API description
The following section lists the various functions of the COMP library.
8.2.1
COMP Peripheral features
The STM32F3xx device family integrates up to 7 analog comparators COMP1,
COMP2...COMP7:
1.
2.
3.
The non inverting input and inverting input can be set to GPIO pins as shown in Table
16: "COMP Inputs for STM32F303xB/STM32F303xC/STM32F303xE devices". COMP
Inputs below for STM32F303xB/STM32F303xC as example. For other 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 (refer to Table 17: "COMP outputs for
STM32F303xB/STM32F303xC/STM32F303xE devices" ). COMP Outputs below for
STM32F303xB/STM32F303xC as example. For other 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...) (refer
to Table 18: "Redirection of COMP outputs to embedded timers for
STM32F303xB/STM32F303xC devices" and Table 19: "Redirection of COMP outputs
to embedded timers for STM32F303xE devices"). COMP Outputs redirection to
embedded timers below for STM32F303xB/STM32F303xC as example. For other
DOCID026526 Rev 2
187/861
HAL COMP Generic Driver
UM1786
STM32F3xx devices please refer to the COMP peripheral section in corresponding
Reference Manual.
4.
The comparators COMP1 and COMP2, COMP3 and COMP4, COMP5 and COMP6
can be combined in window mode and only COMP1, COMP3 and COMP5 non
inverting input can be used as non-inverting input.
5.
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

COMP7 is internally connected to EXTI Line 33 From the corresponding IRQ
handler, the right interrupt source can be retrieved with the macro
__HAL_COMP_EXTI_GET_FLAG(). Possible values are:

COMP_EXTI_LINE_COMP1_EVENT

COMP_EXTI_LINE_COMP2_EVENT

COMP_EXTI_LINE_COMP3_EVENT

COMP_EXTI_LINE_COMP4_EVENT

COMP_EXTI_LINE_COMP5_EVENT

COMP_EXTI_LINE_COMP6_EVENT

COMP_EXTI_LINE_COMP7_EVENT
Table 16: COMP Inputs for STM32F303xB/STM32F303xC/STM32F303xE devices
COMP1
COMP2
COMP3
COMP4
COMP5
COMP6
COMP7
Inverting
inputs
1/4
VREFINT
1/2
VREFINT
3/4
VREFINT
VREFINT
DAC1 OUT
(PA4)
DAC2 OUT
(PA5)
I/O1
I/O2
OK
OK
OK
OK
OK
OK
PA0
---
OK
OK
OK
OK
OK
OK
PA2
---
OK
OK
OK
OK
OK
OK
PD15
PB12
OK
OK
OK
OK
OK
OK
PE8
PB2
OK
OK
OK
OK
OK
OK
PD13
PB10
OK
OK
OK
OK
OK
OK
PD10
PB15
OK
OK
OK
OK
OK
OK
PC0
---
Noninverting
inputs
I/O1
I/O2
PA1
---
PA7
PA3
PB14
PD14
PB0
PE7
PD12
PB13
PD11
PAB11
PA0
PC1
Table 17: COMP outputs for STM32F303xB/STM32F303xC/STM32F303xE devices
188/861
COMP1
COMP2
COMP3
COMP4
COMP5
COMP6
COMP7
PA0
PA2
PB1
PC8
PC7
PA10
PC2
PF4
PA7
---
PA8
PA9
PC6
---
PA6
PA12
---
---
---
---
---
PA11
PB9
---
---
---
---
---
PB8
---
---
---
---
---
---
DOCID026526 Rev 2
UM1786
HAL COMP Generic Driver
Table 18: Redirection of COMP outputs to embedded timers for STM32F303xB/STM32F303xC
devices
COMP1
COMP2
COMP3
COMP4
COMP5
COMP6
COMP7
TIM1 BKIN
TIM1 BKIN
TIM1 BKIN
TIM1 BKIN
TIM1 BKIN
TIM1 BKIN
TIM1 BKIN
TIM1
BKIN2
TIM1
BKIN2
TIM1
BKIN2
TIM1
BKIN2
TIM1
BKIN2
TIM1
BKIN2
TIM1
BKIN2
TIM8 BKIN
TIM8 BKIN
TIM8 BKIN
TIM8 BKIN
TIM8 BKIN
TIM8 BKIN
TIM8 BKIN
TIM8
BKIN2
TIM8
BKIN2
TIM8
BKIN2
TIM8
BKIN2
TIM8
BKIN2
TIM8
BKIN2
TIM8
BKIN2
TIM1
BKIN2 +
TIM8
BKIN2
TIM1
BKIN2 +
TIM8
BKIN2
TIM1
BKIN2 +
TIM8
BKIN2
TIM1
BKIN2 +
TIM8
BKIN2
TIM1
BKIN2 +
TIM8
BKIN2
TIM1
BKIN2 +
TIM8
BKIN2
TIM1
BKIN2 +
TIM8
BKIN2
TIM1
OCREFCL
R
TIM1
OCREFCL
R
TIM1
OCREFCL
R
TIM8
OCREFCL
R
TIM8
OCREFCL
R
TIM8
OCREFCL
R
TIM1
OCREFCL
R
TIM1 I2C1
TIM1 I2C1
TIM2
OCREFCL
R
TIM3 I2C3
TIM2 I2C1
TIM2 I2C2
TIM8
OCREFCL
R
TIM2 I2C4
TIM2 I2C4
TIM3 I2C2
TIM3
OCREFCL
R
TIM3
OCREFCL
R
TIM2
OCREFCL
R
TIM2 I2C3
TIM2
OCREFCL
R
TIM2
OCREFCL
R
TIM4 I2C1
TIM4 I2C2
TIM4 I2C3
TIM16
OCREFCL
R
TIM1 I2C2
TIM3 I2C1
TIM3 I2C1
TIM15 I2C1
TIM15
OCREFCL
R
TIM16
BKIN
TIM16 I2C1
TIM17
OCREFCL
R
TIM3
OCREFCL
R
TIM3
OCREFCL
R
TIM15
BKIN
TIM15 I2C2
TIM17 I2C1
TIM4 I2C4
TIM17
BKIN
Table 19: Redirection of COMP outputs to embedded timers for STM32F303xE devices
COMP1
COMP2
COMP3
COMP4
COMP5
COMP6
COMP7
TIM1 BKIN
TIM1 BKIN
TIM1 BKIN
TIM1
(1)
BKIN
TIM1 BKIN
TIM1 BKIN
TIM1
(1)
BKIN
TIM1
BKIN2
TIM1
BKIN2
TIM1
BKIN2
TIM1
BKIN2
TIM1
BKIN2
TIM1
BKIN2
TIM1
BKIN2
TIM8 BKIN
TIM8 BKIN
TIM8 BKIN
TIM8
(1)
BKIN
TIM8 BKIN
TIM8 BKIN
TIM8
(1)
BKIN
TIM8
BKIN2
TIM8
BKIN2
TIM8
BKIN2
TIM8
BKIN2
TIM8
BKIN2
TIM8
BKIN2
TIM8
BKIN2
TIM1
BKIN2 +
TIM8
BKIN2
TIM1
BKIN2 +
TIM8
BKIN2
TIM1
BKIN2 +
TIM8
BKIN2
TIM1
BKIN2 +
TIM8
BKIN2
TIM1
BKIN2 +
TIM8
BKIN2
TIM1
BKIN2 +
TIM8
BKIN2
TIM1
BKIN2 +
TIM8
BKIN2
DOCID026526 Rev 2
189/861
HAL COMP Generic Driver
UM1786
COMP1
COMP2
COMP3
COMP4
COMP5
COMP6
COMP7
TIM1
OCREFCL
R
TIM1
OCREFCL
R
TIM1
OCREFCL
R
TIM8
OCREFCL
R
TIM8
OCREFCL
R
TIM8
OCREFCL
R
TIM1
OCREFCL
R
TIM1 I2C1
TIM1 I2C1
TIM2
OCREFCL
R
TIM3 I2C3
TIM2 I2C1
TIM2 I2C2
TIM8
OCREFCL
R
TIM2 I2C4
TIM2 I2C4
TIM3 I2C2
TIM3
OCREFCL
R
TIM3
OCREFCL
R
TIM2
OCREFCL
R
TIM2 I2C3
TIM2
OCREFCL
R
TIM2
OCREFCL
R
TIM4 I2C1
TIM4 I2C2
TIM4 I2C3
TIM16
OCREFCL
R
TIM1 I2C2
TIM3 I2C1
TIM3 I2C1
TIM15 I2C1
TIM15
OCREFCL
R
TIM16
BKIN
TIM16 I2C1
TIM17
OCREFCL
R
TIM3
OCREFCL
R
TIM3
OCREFCL
R
TIM15
BKIN
TIM15 I2C2
TIM17 I2C1
TIM4 I2C4
TIM17
BKIN
TIM20
BKIN
TIM20
BKIN
TIM20
BKIN
TIM20
(1)
BKIN
TIM20
BKIN
TIM20
BKIN
TIM20
(1)
BKIN
TIM20
BKIN2
TIM20
BKIN2
TIM20
BKIN2
TIM20
BKIN2
TIM20
BKIN2
TIM1
BKIN2 +
TIM8
BKIN2 +
TIM20
BKIN2
TIM1
BKIN2 +
TIM8
BKIN2 +
TIM20
BKIN2
TIM1
BKIN2 +
TIM8
BKIN2 +
TIM20
BKIN2
TIM1
BKIN2 +
TIM8
BKIN2 +
TIM20
BKIN2
TIM1
BKIN2 +
TIM8
BKIN2 +
TIM20
BKIN2
TIM20
BKIN2
TIM1
BKIN2 +
TIM8
BKIN2 +
TIM20
BKIN2
TIM1
BKIN2 +
TIM8
BKIN2 +
TIM20
BKIN2
Notes:
(1)
This connection consists in connecting both GPIO and COMP outputs to TIM1/8/20 BRK input through an OR
gate, instead of connecting the GPIO to TIM1/8/20 BRK input and the COMP output to TIM1/8/20 BRK_ACTH
input. The objective is to add a 3-bit digital filter on the COMP output.
Table 20: COMP outputs blanking sources for the STM32F303xB/STM32F303xC/STM32F303xE
devicesutputs for STM32F303xB/STM32F303xC/STM32F303xE devices
8.2.2
COMP1
COMP2
COMP3
COMP4
COMP5
COMP6
COMP7
TIM1 OC5
TIM1 OC5
TIM1 OC5
TIM3 OC4
---
TIM8 OC5
TIM1 OC5
TIM2 OC3
TIM2 OC3
---
TIM8 OC5
TIM3 OC3
TIM2 OC4
TIM8 OC5
TIM3 OC3
TIM3 OC3
TIM2 OC4
TIM15 OC1
TIM8 OC5
TIM15 OC2
TIM15 OC2
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.
190/861
Fill in the HAL_COMP_MspInit() to

Configure the comparator input in analog mode using HAL_GPIO_Init()
DOCID026526 Rev 2
UM1786
HAL COMP Generic Driver

2.
3.
4.
8.2.3
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 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_EnableIRQ() function.
Configure the comparator using HAL_COMP_Init() function:

Select the inverting input

Select the non-inverting input

Select the output polarity

Select the output redirection

Select the hysteresis level

Select the power mode

Select the event/interrupt mode
Enable the comparator using HAL_COMP_Start() function or HAL_COMP_Start_IT()
function for interrupt mode
Read the comparator output level with HAL_COMP_GetOutputLevel()
Initialization and Configuration functions
This section provides functions to initialize and de-initialize comparators




8.2.4
HAL_COMP_Init()
HAL_COMP_DeInit()
HAL_COMP_MspInit()
HAL_COMP_MspDeInit()
IO operation functions
This subsection provides a set of functions allowing to manage the COMP data transfers.





8.2.5
HAL_COMP_Start()
HAL_COMP_Stop()
HAL_COMP_Start_IT()
HAL_COMP_Stop_IT()
HAL_COMP_IRQHandler()
Peripheral Control functions
This subsection provides a set of functions allowing to control the COMP data transfers.



8.2.6
HAL_COMP_Lock()
HAL_COMP_GetOutputLevel()
HAL_COMP_TriggerCallback()
Peripheral State functions
This subsection permit to get in run-time the status of the peripheral and the data flow.

HAL_COMP_GetState()
DOCID026526 Rev 2
191/861
HAL COMP Generic Driver
8.2.7
8.2.8
8.2.9
8.2.10
8.2.11
192/861
UM1786
HAL_COMP_Init
Function Name
HAL_StatusTypeDef HAL_COMP_Init (COMP_HandleTypeDef
* hcomp)
Function Description
Initializes the COMP according to the specified parameters in the
COMP_InitTypeDef and create the associated handle.
Parameters

hcomp: COMP handle
Return values

HAL status
Notes

If the selected comparator is locked, initialization can't be
performed. To unlock the configuration, perform a system
reset.
HAL_COMP_DeInit
Function Name
HAL_StatusTypeDef HAL_COMP_DeInit
(COMP_HandleTypeDef * hcomp)
Function Description
DeInitializes the COMP peripheral.
Parameters

hcomp: COMP handle
Return values

HAL status
Notes

Deinitialization can't be performed if the COMP configuration
is locked. To unlock the configuration, perform a system
reset.
HAL_COMP_MspInit
Function Name
void HAL_COMP_MspInit (COMP_HandleTypeDef * hcomp)
Function Description
Initializes the COMP MSP.
Parameters

hcomp: COMP handle
Return values

None
HAL_COMP_MspDeInit
Function Name
void HAL_COMP_MspDeInit (COMP_HandleTypeDef * hcomp)
Function Description
DeInitializes COMP MSP.
Parameters

hcomp: COMP handle
Return values

None
HAL_COMP_Start
DOCID026526 Rev 2
UM1786
8.2.12
8.2.13
8.2.14
8.2.15
Function Name
HAL COMP Generic Driver
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
Enables the interrupt and starts the comparator.
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
Disable the interrupt and Stop the comparator.
Parameters

hcomp: COMP handle
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
DOCID026526 Rev 2
193/861
HAL COMP Generic Driver
8.2.16
8.2.17
8.2.18
8.2.19
8.3
UM1786
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
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_TriggerCallback
Function Name
void HAL_COMP_TriggerCallback (COMP_HandleTypeDef *
hcomp)
Function Description
Comparator callback.
Parameters

hcomp: COMP handle
Return values

None
HAL_COMP_GetState
Function Name
HAL_COMP_StateTypeDef HAL_COMP_GetState
(COMP_HandleTypeDef * hcomp)
Function Description
Return the COMP state.
Parameters

hcomp: COMP handle
Return values

HAL state
COMP Firmware driver defines
The following section lists the various define and macros of the module.
8.3.1
COMP
COMP
COMP Exported Constants
COMP_LOCK_DISABLE
COMP_LOCK_ENABLE
COMP_STATE_BIT_LOCK
194/861
DOCID026526 Rev 2
UM1786
HAL COMP Generic Driver
COMP Exported Macros
__HAL_COMP_RESET_HANDLE_STATE
Description:

Reset COMP handle state.
Parameters:

__HANDLE__: COMP handle.
Return value:

None:
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
IS_COMP_OUTPUTPOL
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
COMP_TRIGGERMODE_IT_RISING_FALLING
External Interrupt Mode with
Rising/Falling edge trigger detection
IS_COMP_TRIGGERMODE
DOCID026526 Rev 2
195/861
HAL COMP Extension Driver
UM1786
9
HAL COMP Extension Driver
9.1
COMPEx Firmware driver defines
The following section lists the various define and macros of the module.
9.1.1
COMPEx
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
comparator
COMP_BLANKINGSRCE_TIM2OC3
TIM2 OC5 selected as blanking source for
comparator
COMP_BLANKINGSRCE_TIM3OC3
TIM2 OC3 selected as blanking source for
comparator
COMP_BLANKINGSRCE_TIM2OC4
TIM2 OC4 selected as blanking source for
comparator
COMP_BLANKINGSRCE_TIM8OC5
TIM8 OC5 selected as blanking source for
comparator
COMP_BLANKINGSRCE_TIM3OC4
TIM3 OC4 selected as blanking source for
comparator
COMP_BLANKINGSRCE_TIM15OC1
TIM15 OC1 selected as blanking source for
comparator
COMP_BLANKINGSRCE_TIM15OC2
TIM15 OC2 selected as blanking source for
comparator
IS_COMP_BLANKINGSRCE
IS_COMP_BLANKINGSRCE_INSTANCE
COMP_CSR_COMPxBLANKING_MASK
COMP_CSR_COMPxBLANKING mask
COMP Extended Exported Constants
COMP_CSR_RESET_VALUE
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 Extended EXTI Line Event
(STM32F303xE/STM32F398xx/STM32F303xC/STM32F358xx Product devices)
196/861
COMP_EXTI_LINE_MASK
Mask on possible line values
COMP_EXTI_LINE_REG_MASK
Mask on possible register values
COMP_EXTI_LINE_COMP1_EVENT
External interrupt line 21 Connected to COMP1
DOCID026526 Rev 2
UM1786
COMP_EXTI_LINE_COMP2_EVENT
HAL COMP Extension Driver
External interrupt line 22 Connected to COMP2
COMP_EXTI_LINE_COMP3_EVENT
External interrupt line 29 Connected to COMP3
COMP_EXTI_LINE_COMP4_EVENT
External interrupt line 30 Connected to COMP4
COMP_EXTI_LINE_COMP5_EVENT
External interrupt line 31 Connected to COMP5
COMP_EXTI_LINE_COMP6_EVENT
External interrupt line 32 Connected to COMP6
COMP_EXTI_LINE_COMP7_EVENT
External interrupt line 33 Connected to COMP7
COMP Extended Hysteresis
COMP_HYSTERESIS_NONE
No hysteresis
IS_COMP_HYSTERESIS
Not available: check always true
COMP_CSR_COMPxHYST_MASK
Mask empty: feature not available
COMP Extended InvertingInput
(STM32F302xE/STM32F303xE/STM32F398xx/STM32F302xC/STM32F303xC/STM32F35
8xx Product devices)
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)
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
IS_COMP_INVERTINGINPUT
COMP Extended Mode
IS_COMP_MODE
< Power mode not available Not available: check
always true
COMP_CSR_COMPxMODE_MASK
Mask empty: feature not available
COMP Extended NonInvertingInput (STM32F302xE/STM32F303xE/STM32F398xx
Product devices)
DOCID026526 Rev 2
197/861
HAL COMP Extension Driver
COMP_NONINVERTINGINPUT_IO1
COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSE
D
UM1786
IO1 (PA1 for COMP1, PA7 for
COMP2, PB14 for COMP3, PB0
for COMP4, PD12 for COMP5,
PD11 for COMP6, PA0 for
COMP7) connected to
comparator non inverting input
DAC ouput connected to
comparator COMP1 non
inverting input
IS_COMP_NONINVERTINGINPUT
IS_COMP_NONINVERTINGINPUT_INSTANCE
COMP_CSR_COMPxNONINSEL_MASK
COMP_CSR_COMPxNONINSE
L mask
COMP Extended Output (STM32F303xE/STM32F398xx Product devices)
198/861
COMP_OUTPUT_NONE
COMP output isn't connected
to other peripherals
COMP_OUTPUT_TIM1BKIN
COMP output connected to
TIM1 Break Input (BKIN)
COMP_OUTPUT_TIM1BKIN2
COMP output connected to
TIM1 Break Input 2 (BKIN2)
COMP_OUTPUT_TIM8BKIN
COMP output connected to
TIM8 Break Input (BKIN)
COMP_OUTPUT_TIM8BKIN2
COMP output connected to
TIM8 Break Input 2 (BKIN2)
COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2
COMP output connected to
TIM1 Break Input 2 and TIM8
Break Input 2
COMP_OUTPUT_TIM20BKIN
COMP output connected to
TIM20 Break Input (BKIN)
COMP_OUTPUT_TIM20BKIN2
COMP output connected to
TIM20 Break Input 2 (BKIN2)
COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2_TIM20BKIN2
COMP output connected to
TIM1 Break Input 2, TIM8
Break Input 2 and TIM20 Break
Input 2
COMP_OUTPUT_TIM1OCREFCLR
COMP output connected to
TIM1 OCREF Clear
COMP_OUTPUT_TIM1IC1
COMP output connected to
TIM1 Input Capture 1
COMP_OUTPUT_TIM2IC4
COMP output connected to
TIM2 Input Capture 4
COMP_OUTPUT_TIM2OCREFCLR
COMP output connected to
TIM2 OCREF Clear
COMP_OUTPUT_TIM3IC1
COMP output connected to
TIM3 Input Capture 1
DOCID026526 Rev 2
UM1786
COMP_OUTPUT_TIM3OCREFCLR
HAL COMP Extension Driver
COMP output connected to
TIM3 OCREF Clear
COMP_OUTPUT_TIM20OCREFCLR
COMP output connected to
TIM20 OCREF Clear
COMP_OUTPUT_TIM4IC1
COMP output connected to
TIM4 Input Capture 1
COMP_OUTPUT_TIM3IC2
COMP output connected to
TIM3 Input Capture 2
COMP_OUTPUT_TIM15IC1
COMP output connected to
TIM15 Input Capture 1
COMP_OUTPUT_TIM15BKIN
COMP output connected to
TIM15 Break Input (BKIN)
COMP_OUTPUT_TIM3IC3
COMP output connected to
TIM3 Input Capture 3
COMP_OUTPUT_TIM8OCREFCLR
COMP output connected to
TIM8 OCREF Clear
COMP_OUTPUT_TIM15IC2
COMP output connected to
TIM15 Input Capture 2
COMP_OUTPUT_TIM4IC2
COMP output connected to
TIM4 Input Capture 2
COMP_OUTPUT_TIM15OCREFCLR
COMP output connected to
TIM15 OCREF Clear
COMP_OUTPUT_TIM2IC1
COMP output connected to
TIM2 Input Capture 1
COMP_OUTPUT_TIM17IC1
COMP output connected to
TIM17 Input Capture 1
COMP_OUTPUT_TIM4IC3
COMP output connected to
TIM4 Input Capture 3
COMP_OUTPUT_TIM16BKIN
COMP output connected to
TIM16 Break Input (BKIN)
COMP_OUTPUT_TIM2IC2
COMP output connected to
TIM2 Input Capture 2
COMP_OUTPUT_COMP6TIM2OCREFCLR
COMP output connected to
TIM2 OCREF Clear
COMP_OUTPUT_TIM16OCREFCLR
COMP output connected to
TIM16 OCREF Clear
COMP_OUTPUT_TIM16IC1
COMP output connected to
TIM16 Input Capture 1
COMP_OUTPUT_TIM4IC4
COMP output connected to
TIM4 Input Capture 4
COMP_OUTPUT_TIM2IC3
COMP output connected to
TIM2 Input Capture 3
COMP_OUTPUT_TIM1IC2
COMP output connected to
TIM1 Input Capture 2
DOCID026526 Rev 2
199/861
HAL COMP Extension Driver
COMP_OUTPUT_TIM17OCREFCLR
UM1786
COMP output connected to
TIM16 OCREF Clear
COMP_OUTPUT_TIM17BKIN
COMP output connected to
TIM16 Break Input (BKIN)
IS_COMP_OUTPUT
COMP Extended WindowMode (STM32F302xE/STM32F303xE/STM32F398xx Product
devices)
COMP_WINDOWMODE_DISABLED
Window mode disabled
COMP_WINDOWMODE_ENABLED
Window mode enabled: non inverting input of
comparator X (x=2,4,6) is connected to the non
inverting input of comparator X-1
IS_COMP_WINDOWMODE
COMP_CSR_COMPxWNDWEN_MASK
200/861
COMP_CSR_COMPxWNDWEN mask
DOCID026526 Rev 2
UM1786
HAL CORTEX Generic Driver
10
HAL CORTEX Generic Driver
10.1
CORTEX Firmware driver API description
The following section lists the various functions of the CORTEX library.
10.1.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 Table 21: "Pre-emption priority and subpriority vs Priority
Grouping configuration". @brief CORTEX_NVIC_Priority_Table. 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)
Table 21: Pre-emption priority and subpriority vs Priority Grouping configuration
NVIC_PriorityGroup
NVIC_PRIORITYGROUP_0
NVIC_PRIORITYGROUP_1
NVIC_PRIORITYGROUP_2
NVIC_PRIORITYGROUP_3
NVIC_IRQChannelPreemptionPriority
0
0-1
0-3
0-7
DOCID026526 Rev 2
NVIC_IRQChannelSubPriority
Description
0-15
0 bit for
pre-emption
priority
4 bits for
subpriority
0-7
1 bit for
pre-emption
priority
3 bits for
subpriority
0-3
2 bits for
pre-emption
priority
2 bits for
subpriority
0-1
3 bits for
pre-emption
priority
1 bit for
subpriority
201/861
HAL CORTEX Generic Driver
NVIC_PriorityGroup
UM1786
NVIC_IRQChannelPreemptionPriority
NVIC_PRIORITYGROUP_4
NVIC_IRQChannelSubPriority
Description
0
4 bits for
pre-emption
priority
0 bit for
subpriority
0-15
How to configure Systick using CORTEX HAL driver
Setup SysTick Timer for time base




10.1.2
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)

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






10.1.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) functionalities.

202/861
HAL_NVIC_GetPriorityGrouping()
DOCID026526 Rev 2
UM1786
HAL CORTEX Generic Driver








10.1.4
10.1.5
HAL_NVIC_GetPriority()
HAL_NVIC_SetPendingIRQ()
HAL_NVIC_GetPendingIRQ()
HAL_NVIC_ClearPendingIRQ()
HAL_NVIC_GetActive()
HAL_SYSTICK_CLKSourceConfig()
HAL_SYSTICK_IRQHandler()
HAL_SYSTICK_Callback()
HAL_NVIC_SetPriorityGrouping
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 preemption priority 3 bits for subpriority
NVIC_PRIORITYGROUP_2: 2 bits for pre-emption priority 2
bits for subpriority NVIC_PRIORITYGROUP_3: 3 bits for preemption priority 1 bits for subpriority
NVIC_PRIORITYGROUP_4: 4 bits for pre-emption priority 0
bits for subpriority
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
DOCID026526 Rev 2
203/861
HAL CORTEX Generic Driver
10.1.6
10.1.7
10.1.8
10.1.9
10.1.10
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
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_NVIC_GetPriorityGrouping
Function Name
204/861
UM1786
uint32_t HAL_NVIC_GetPriorityGrouping (void )
DOCID026526 Rev 2
UM1786
10.1.11
Function Description
HAL CORTEX Generic Driver
Gets the priority grouping field from the NVIC Interrupt Controller.
Return values

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




Return values
10.1.12
10.1.13
Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field)

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 preemption priority 3 bits for subpriority
NVIC_PRIORITYGROUP_2: 2 bits for pre-emption priority 2
bits for subpriority NVIC_PRIORITYGROUP_3: 3 bits for preemption 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).
None
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_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
DOCID026526 Rev 2
205/861
HAL CORTEX Generic Driver
Return values
10.1.14
10.1.15
10.1.16
10.1.17

status - 0 Interrupt status is not pending. 1 Interrupt status is
pending.
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)
Function Description
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
206/861
UM1786
enumerator of IRQn_Type enumeration (For the complete
STM32 Devices IRQ Channels list, please refer to the
appropriate CMSIS device file (stm32f3xxxx.h))
void HAL_SYSTICK_IRQHandler (void )
DOCID026526 Rev 2
UM1786
10.1.18
10.2
Function Description
HAL CORTEX Generic Driver
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
CORTEX Firmware driver defines
The following section lists the various define and macros of the module.
10.2.1
CORTEX
CORTEX
CORTEX Exported Macros
__HAL_CORTEX_SYSTICKCLK_CON
FIG
Description:

Configures the SysTick clock source.
Parameters:

__CLKSRC__: 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 value:

None:
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
IS_NVIC_PRIORITY_GROUP
IS_NVIC_PREEMPTION_PRIORITY
IS_NVIC_SUB_PRIORITY
CORTEX SysTick clock source
SYSTICK_CLKSOURCE_HCLK_DIV8
DOCID026526 Rev 2
207/861
HAL CORTEX Generic Driver
SYSTICK_CLKSOURCE_HCLK
IS_SYSTICK_CLK_SOURCE
208/861
DOCID026526 Rev 2
UM1786
UM1786
HAL CRC Generic Driver
11
HAL CRC Generic Driver
11.1
CRC Firmware driver registers structures
11.1.1
CRC_InitTypeDef
CRC_InitTypeDef is defined in the stm32f3xx_hal_crc.h
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






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. 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 2
209/861
HAL CRC Generic Driver
UM1786
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_DISABLED no CRC inversion, or
CRC_OUTPUTDATA_INVERSION_ENABLED CRC 0x11223344 is converted into
0x22CC4488
11.1.2
CRC_HandleTypeDef
CRC_HandleTypeDef is defined in the stm32f3xx_hal_crc.h
Data Fields





CRC_TypeDef * Instance
CRC_InitTypeDef Init
HAL_LockTypeDef Lock
__IO HAL_CRC_StateTypeDef State
uint32_t InputDataFormat
Field Documentation





11.2
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-bits 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
CRC Firmware driver API description
The following section lists the various functions of the CRC library.
11.2.1
How to use this driver
1.
2.
210/861
Enable CRC AHB clock using __CRC_CLK_ENABLE();
Initialize CRC calculator
DOCID026526 Rev 2
UM1786
HAL CRC Generic Driver
3.
4.
11.2.2

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
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 Configuration functions
This section provides functions allowing to:








11.2.3
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
DeInitialize CRC MSP
HAL_CRC_Init()
HAL_CRC_DeInit()
HAL_CRC_MspInit()
HAL_CRC_MspDeInit()
Peripheral Control functions
This section provides functions allowing to:




11.2.4
Compute the 7, 8, 16 or 32-bit CRC value of an 8, 16 or 32-bit data buffer using
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.
HAL_CRC_Accumulate()
HAL_CRC_Calculate()
Peripheral State functions
This subsection permits to get in run-time the status of the peripheral and the data flow.

11.2.5
HAL_CRC_GetState()
HAL_CRC_Init
Function Name
HAL_StatusTypeDef HAL_CRC_Init (CRC_HandleTypeDef *
hcrc)
Function Description
Initializes the CRC according to the specified parameters in the
CRC_InitTypeDef and creates the associated handle.
Parameters

hcrc: CRC handle
Return values

HAL status
DOCID026526 Rev 2
211/861
HAL CRC Generic Driver
11.2.6
11.2.7
11.2.8
11.2.9
UM1786
HAL_CRC_DeInit
Function Name
HAL_StatusTypeDef HAL_CRC_DeInit (CRC_HandleTypeDef *
hcrc)
Function Description
DeInitializes 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
DeInitializes 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



Return values
11.2.10
uint32_t CRC (returned value LSBs for CRC shorter than 32
bits)
HAL_CRC_Calculate
Function Name
212/861

hcrc: CRC handle
pBuffer: pointer to the input data buffer, exact input data
format is provided by hcrc->InputDataFormat.
BufferLength: input data buffer length
uint32_t HAL_CRC_Calculate (CRC_HandleTypeDef * hcrc,
uint32_t pBuffer, uint32_t BufferLength)
DOCID026526 Rev 2
UM1786
Function Description
Parameters
HAL CRC Generic Driver
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.



Return values
11.2.11
11.3

hcrc: CRC handle
pBuffer: pointer to the input data buffer, exact input data
format is provided by hcrc->InputDataFormat.
BufferLength: input data buffer length
uint32_t CRC (returned value LSBs for CRC shorter than 32
bits)
HAL_CRC_GetState
Function Name
HAL_CRC_StateTypeDef HAL_CRC_GetState
(CRC_HandleTypeDef * hcrc)
Function Description
Returns the CRC state.
Parameters

hcrc: CRC handle
Return values

HAL state
CRC Firmware driver defines
The following section lists the various define and macros of the module.
11.3.1
CRC
CRC
Default CRC computation initialization value
DEFAULT_CRC_INITVALUE
Indicates whether or not default init value is used
DEFAULT_INIT_VALUE_ENABLE
DEFAULT_INIT_VALUE_DISABLE
IS_DEFAULT_INIT_VALUE
Indicates whether or not default polynomial is used
DEFAULT_POLYNOMIAL_ENABLE
DEFAULT_POLYNOMIAL_DISABLE
IS_DEFAULT_POLYNOMIAL
Default CRC generating polynomial
DEFAULT_CRC32_POLY
CRC Exported Macros
__HAL_CRC_RESET_HANDLE_STATE
Description:

Reset CRC handle state.
Parameters:

DOCID026526 Rev 2
__HANDLE__: CRC handle.
213/861
HAL CRC Generic Driver
UM1786
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.:
Input Buffer Format
CRC_INPUTDATA_FORMAT_UNDEFINED
CRC_INPUTDATA_FORMAT_BYTES
CRC_INPUTDATA_FORMAT_HALFWORDS
CRC_INPUTDATA_FORMAT_WORDS
IS_CRC_INPUTDATA_FORMAT
Polynomial sizes to configure the IP
CRC_POLYLENGTH_32B
CRC_POLYLENGTH_16B
CRC_POLYLENGTH_8B
CRC_POLYLENGTH_7B
IS_CRC_POL_LENGTH
CRC polynomial possible sizes actual definitions
HAL_CRC_LENGTH_32B
HAL_CRC_LENGTH_16B
HAL_CRC_LENGTH_8B
HAL_CRC_LENGTH_7B
214/861
DOCID026526 Rev 2
UM1786
HAL CRC Extension Driver
12
HAL CRC Extension Driver
12.1
CRCEx Firmware driver API description
The following section lists the various functions of the CRCEx library.
12.1.1
Product specific features
12.1.2
How to use this driver




12.1.3
Enable CRC AHB clock using __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
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
HAL_CRCEx_Polynomial_Set
Function Name
HAL_StatusTypeDef HAL_CRCEx_Polynomial_Set
(CRC_HandleTypeDef * hcrc, uint32_t Pol, uint32_t
PolyLength)
Function Description
Initializes the CRC polynomial if different from default one.
Parameters



Return values
12.1.4

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
DOCID026526 Rev 2
215/861
HAL CRC Extension Driver
Function Name
12.1.5
12.2
UM1786
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: Bytewise bit reversal
CRC_INPUTDATA_INVERSION_HALFWORD: HalfWordwise bit reversal CRC_INPUTDATA_INVERSION_WORD:
Word-wise bit reversal
Return values

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_DISABLED: no CRC
inversion (default value)
CRC_OUTPUTDATA_INVERSION_ENABLED: bit-level
inversion (e.g for a 8-bit CRC: 0xB5 becomes 0xAD)
Return values

HAL status
CRCEx Firmware driver defines
The following section lists the various define and macros of the module.
12.2.1
CRCEx
CRCEx
CRC Extended Exported Macros
__HAL_CRC_OUTPUTREVERSAL_ENABLE
Description:

Set CRC output reversal.
Parameters:

__HANDLE__: CRC handle
Return value:

__HAL_CRC_OUTPUTREVERSAL_DISABLE
Description:

216/861
None.:
DOCID026526 Rev 2
Unset CRC output reversal.
UM1786
HAL CRC Extension Driver
Parameters:

__HANDLE__: CRC handle
Return value:

__HAL_CRC_POLYNOMIAL_CONFIG
None.:
Description:

Set CRC non-default polynomial.
Parameters:


__HANDLE__: CRC handle
__POLYNOMIAL__: 7, 8, 16 or 32-bit
polynomial
Return value:

None.:
CRC Extended Input Data Inversion Modes
CRC_INPUTDATA_INVERSION_NONE
CRC_INPUTDATA_INVERSION_BYTE
CRC_INPUTDATA_INVERSION_HALFWORD
CRC_INPUTDATA_INVERSION_WORD
IS_CRC_INPUTDATA_INVERSION_MODE
CRC Extended Output Data Inversion Modes
CRC_OUTPUTDATA_INVERSION_DISABLED
CRC_OUTPUTDATA_INVERSION_ENABLED
IS_CRC_OUTPUTDATA_INVERSION_MODE
DOCID026526 Rev 2
217/861
HAL DAC Generic Driver
UM1786
13
HAL DAC Generic Driver
13.1
DAC Firmware driver registers structures
13.1.1
DAC_ChannelConfTypeDef
DAC_ChannelConfTypeDef is defined in the stm32f3xx_hal_dac.h
Data Fields


uint32_t DAC_Trigger
uint32_t DAC_OutputBuffer
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
__DAC_HandleTypeDef
__DAC_HandleTypeDef is defined in the stm32f3xx_hal_dac.h
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






218/861
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
DMA_HandleTypeDef* __DAC_HandleTypeDef::DMA_Handle2
Pointer DMA handler for channel 2
__IO uint32_t __DAC_HandleTypeDef::ErrorCode
DAC Error code
DOCID026526 Rev 2
UM1786
13.2
HAL DAC Generic Driver
DAC Firmware driver API description
The following section lists the various functions of the DAC library.
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_Pin9) using DAC_Trigger_Ext_IT9. The
used pin (GPIOx_Pin9) 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;
Refer to the device datasheet for more details about output impedance value with
and without output buffer.
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:
DOCID026526 Rev 2
219/861
HAL DAC Generic Driver
1.
8-bit right alignment using DAC_ALIGN_8B_R
2.
12-bit left alignment using DAC_ALIGN_12B_L
3.
12-bit right alignment using DAC_ALIGN_12B_R
UM1786
DAC data value to voltage correspondence
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()
DMA1 requests are mapped as following:
1.
2.
3.
13.2.2
DAC1 channel1: mapped either on - DMA1 channel3 - or DMA2 channel3 (for
STM32F3 devices having 2 DMA) which must be already configured
DAC1 channel2: (for STM32F3 devices having 2 channels on DAC1) mapped either
on - DMA1 channel4 - or DMA2 channel4 (for STM32F3 devices having 2 DMA) which
must be already configured
DAC2 channel1: mapped either on (for STM32F3 devices having 2 DAC) - DMA1
channel4 - or DMA2 channel4 (for STM32F3 devices having 2 DMA) which must be
already configured
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



Start the DAC peripheral using HAL_DAC_Start()
To read the DAC last data output value value, use the HAL_DAC_GetValue()
function.
Stop the DAC peripheral using HAL_DAC_Stop()
DMA mode IO operation


220/861
Start the DAC peripheral using HAL_DAC_Start_DMA(), at this stage the user specify
the length of data to be transfered at each end of conversion
At The end of data transfer HAL_DAC_ConvCpltCallbackCh1()or
HAL_DAC_ConvCpltCallbackCh2() function is executed and user can add his own
code by customization of function pointer HAL_DAC_ConvCpltCallbackCh1 or
HAL_DAC_ConvCpltCallbackCh2
DOCID026526 Rev 2
UM1786
HAL DAC Generic Driver


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
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:






13.2.4
Initialize and configure the DAC.
De-initialize the DAC.
HAL_DAC_Init()
HAL_DAC_DeInit()
HAL_DAC_MspInit()
HAL_DAC_MspDeInit()
IO operation functions
This section provides functions allowing to:

















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.
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_IRQHandler()
DOCID026526 Rev 2
221/861
HAL DAC Generic Driver
13.2.5
UM1786
Peripheral Control functions
This section provides functions allowing to:








13.2.6
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.
HAL_DAC_ConfigChannel()
HAL_DAC_SetValue()
HAL_DACEx_DualSetValue()
DAC Peripheral State and Error functions
This subsection provides functions allowing to




13.2.7
13.2.8
13.2.9
Check the DAC state.
Check the DAC Errors.
HAL_DAC_GetState()
HAL_DAC_GetError()
HAL_DAC_Init
Function Name
HAL_StatusTypeDef HAL_DAC_Init (DAC_HandleTypeDef *
hdac)
Function Description
Initializes the DAC peripheral according to the specified
parameters in the DAC_InitStruct.
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
Deinitializes 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
222/861
void HAL_DAC_MspInit (DAC_HandleTypeDef * hdac)
DOCID026526 Rev 2
UM1786
13.2.10
13.2.11
HAL DAC Generic Driver
Function Description
Initializes 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
DeInitializes 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
13.2.12

HAL status
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
13.2.13
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: DAC1_CHANNEL_1: DAC1
Channel1 selected DAC1_CHANNEL_2: DAC1 Channel2
selected DAC2_CHANNEL_1: DAC2 Channel1 selected

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: DAC1_CHANNEL_1: DAC1
Channel1 selected DAC1_CHANNEL_2: DAC1 Channel2
selected DAC2_CHANNEL_1: DAC2 Channel1 selected
HAL status
HAL_DAC_Stop_DMA
Function Name
HAL_StatusTypeDef HAL_DAC_Stop_DMA
DOCID026526 Rev 2
223/861
HAL DAC Generic Driver
UM1786
(DAC_HandleTypeDef * hdac, uint32_t channel)
Function Description
Disables DAC and stop conversion of channel.
Parameters


Return values
13.2.14

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
13.2.16
13.2.17
224/861
HAL status
HAL_DAC_GetValue

13.2.15
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: DAC1_CHANNEL_1: DAC1
Channel1 selected DAC1_CHANNEL_2: DAC1 Channel2
selected DAC2_CHANNEL_1: DAC2 Channel1 selected

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: DAC1_CHANNEL_1: DAC1
Channel1 selected DAC1_CHANNEL_2: DAC1 Channel2
selected DAC2_CHANNEL_1: DAC2 Channel1 selected
The selected DAC channel data output value.
HAL_DACEx_DualGetValue
Function Name
uint32_t HAL_DACEx_DualGetValue (DAC_HandleTypeDef *
hdac)
Function Description
Returns 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_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
HAL_DAC_ConvHalfCpltCallbackCh1
DOCID026526 Rev 2
UM1786
Function Name
13.2.18
13.2.19
13.2.20
HAL DAC Generic Driver
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_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





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
DOCID026526 Rev 2
225/861
HAL DAC Generic Driver
Return values
13.2.21
13.2.22
UM1786
DAC_Align_12b_L: 12bit left data alignment selected
DAC_Align_12b_R: 12bit right data alignment selected

HAL_DAC_IRQHandler
Function Name
void HAL_DAC_IRQHandler (DAC_HandleTypeDef * hdac)
Function Description
Handles DAC interrupt request.
Parameters

hdac: pointer to a DAC_HandleTypeDef structure that
contains the configuration information for the specified DAC.
Return values

None
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
13.2.23
HAL status

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: DAC1_CHANNEL_1: DAC1
Channel1 selected DAC1_CHANNEL_2: DAC1 Channel2
selected DAC2_CHANNEL_1: DAC2 Channel1 selected
HAL status
HAL_DAC_SetValue
Function Name
HAL_StatusTypeDef HAL_DAC_SetValue
(DAC_HandleTypeDef * hdac, uint32_t channel, uint32_t
alignment, uint32_t data)
Function Description
13.2.24
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


226/861
hdac: pointer to a DAC_HandleTypeDef structure that
contains the configuration information for the specified DAC.
alignment: Specifies the data alignment for dual channel
DOCID026526 Rev 2
UM1786


13.2.25
13.2.26
13.3
HAL DAC Generic Driver
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_DAC_GetState
Function Name
HAL_DAC_StateTypeDef HAL_DAC_GetState
(DAC_HandleTypeDef * hdac)
Function Description
return the DAC 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
uint32_t HAL_DAC_GetError (DAC_HandleTypeDef * hdac)
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
DAC Firmware driver defines
The following section lists the various define and macros of the module.
13.3.1
DAC
DAC
DAC data
IS_DAC_DATA
DAC data alignement
DAC_ALIGN_12B_R
DAC_ALIGN_12B_L
DAC_ALIGN_8B_R
IS_DAC_ALIGN
DOCID026526 Rev 2
227/861
HAL DAC Generic Driver
DAC Error Code
UM1786
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__: DAC handle.
Return value:

None:
__HAL_DAC_ENABLE
__HAL_DAC_DISABLE
__HAL_DHR12R1_ALIGNEMENT
__HAL_DHR12R2_ALIGNEMENT
__HAL_DHR12RD_ALIGNEMENT
__HAL_DAC_ENABLE_IT
__HAL_DAC_DISABLE_IT
__HAL_DAC_GET_FLAG
__HAL_DAC_CLEAR_FLAG
DAC flags definition
DAC_FLAG_DMAUDR1
DAC_FLAG_DMAUDR2
IS_DAC_FLAG
DAC interrupts definition
DAC_IT_DMAUDR1
DAC_IT_DMAUDR2
IS_DAC_IT
DAC lfsrunmask triangleamplitude
228/861
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
DOCID026526 Rev 2
UM1786
DAC_LFSRUNMASK_BITS4_0
HAL DAC Generic Driver
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
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
IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE
DAC output buffer
DAC_OUTPUTBUFFER_ENABLE
DAC_OUTPUTBUFFER_DISABLE
IS_DAC_OUTPUT_BUFFER_STATE
DAC wave generation
DAC_WAVEGENERATION_NONE
DOCID026526 Rev 2
229/861
HAL DAC Generic Driver
DAC_WAVEGENERATION_NOISE
DAC_WAVEGENERATION_TRIANGLE
IS_DAC_GENERATE_WAVE
DAC_WAVE_NOISE
DAC_WAVE_TRIANGLE
IS_DAC_WAVE
230/861
DOCID026526 Rev 2
UM1786
UM1786
HAL DAC Extension Driver
14
HAL DAC Extension Driver
14.1
DACEx Firmware driver API description
The following section lists the various functions of the DACEx library.
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:




14.1.3
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)
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)
HAL_DAC_Start()
HAL_DAC_Start_DMA()
HAL_DAC_GetValue()
HAL_DACEx_DualGetValue()
HAL_DAC_IRQHandler()
HAL_DACEx_TriangleWaveGenerate()
HAL_DACEx_NoiseWaveGenerate()
HAL_DACEx_ConvCpltCallbackCh2()
HAL_DACEx_ConvHalfCpltCallbackCh2()
HAL_DACEx_ErrorCallbackCh2()
HAL_DACEx_DMAUnderrunCallbackCh2()
DOCID026526 Rev 2
231/861
HAL DAC Extension Driver
14.1.4
UM1786
HAL_DAC_SetValue
Function Name
HAL_StatusTypeDef HAL_DAC_SetValue
(DAC_HandleTypeDef * hdac, uint32_t channel, uint32_t
alignment, uint32_t data)
Function Description
14.1.5
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




14.1.6
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_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
14.1.7

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: DAC1_CHANNEL_1: DAC1
Channel1 selected DAC1_CHANNEL_2: DAC1 Channel2
selected DAC2_CHANNEL_1: DAC2 Channel1 selected
HAL status
HAL_DAC_Start_DMA
Function Name
232/861
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.
HAL_StatusTypeDef HAL_DAC_Start_DMA
(DAC_HandleTypeDef * hdac, uint32_t channel, uint32_t *
DOCID026526 Rev 2
UM1786
HAL DAC Extension Driver
pData, uint32_t Length, uint32_t alignment)
Function Description
Enables DAC and starts conversion of channel.
Parameters





Return values
14.1.8

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
14.1.10
HAL status
HAL_DAC_GetValue

14.1.9
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

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: DAC1_CHANNEL_1: DAC1
Channel1 selected DAC1_CHANNEL_2: DAC1 Channel2
selected DAC2_CHANNEL_1: DAC2 Channel1 selected
The selected DAC channel data output value.
HAL_DACEx_DualGetValue
Function Name
uint32_t HAL_DACEx_DualGetValue (DAC_HandleTypeDef *
hdac)
Function Description
Returns 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_DAC_IRQHandler
Function Name
void HAL_DAC_IRQHandler (DAC_HandleTypeDef * hdac)
Function Description
Handles DAC interrupt request.
DOCID026526 Rev 2
233/861
HAL DAC Extension Driver
Parameters

hdac: pointer to a DAC_HandleTypeDef structure that
contains the configuration information for the specified DAC.
Return values

None
14.1.11
UM1786
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



14.1.12
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


234/861
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 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
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
DOCID026526 Rev 2
UM1786

Return values
14.1.13
14.1.14

HAL DAC Extension Driver
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
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.
DOCID026526 Rev 2
235/861
HAL DAC Extension Driver
Return values
14.1.15
14.1.16
14.2
UM1786

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.
Return values

None
DACEx Firmware driver defines
The following section lists the various define and macros of the module.
14.2.1
DACEx
DACEx
DAC Extended Channel selection
DAC_CHANNEL_1
DAC Channel 1
DAC_CHANNEL_2
DAC Channel 2
DAC1_CHANNEL_1
DAC1 Channel 1
DAC1_CHANNEL_2
DAC1 Channel 2
IS_DAC_CHANNEL
DAC Extended trigger selection
236/861
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
DOCID026526 Rev 2
UM1786
HAL DAC Extension Driver
TIM6 TRGO selected as external conversion trigger for
DAC channel
DAC_TRIGGER_T6_TRGO
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
DOCID026526 Rev 2
237/861
HAL DMA Generic Driver
UM1786
15
HAL DMA Generic Driver
15.1
DMA Firmware driver registers structures
15.1.1
DMA_InitTypeDef
DMA_InitTypeDef is defined in the stm32f3xx_hal_dma.h
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
__DMA_HandleTypeDef is defined in the stm32f3xx_hal_dma.h
238/861
DOCID026526 Rev 2
UM1786
HAL DMA Generic Driver
Data Fields









DMA_Channel_TypeDef * Instance
DMA_InitTypeDef Init
HAL_LockTypeDef Lock
HAL_DMA_StateTypeDef State
void * Parent
void(* XferCpltCallback
void(* XferHalfCpltCallback
void(* XferErrorCallback
__IO uint32_t ErrorCode
Field Documentation









15.2
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
__IO uint32_t __DMA_HandleTypeDef::ErrorCode
DMA Error code
DMA Firmware driver API description
The following section lists the various functions of the DMA library.
15.2.1
How to use this driver
1.
2.
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.
DOCID026526 Rev 2
239/861
HAL DMA Generic Driver
UM1786
3.
Use HAL_DMA_GetState() function to return the DMA state and
HAL_DMA_GetError() in case of error detection.
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.
240/861
DOCID026526 Rev 2
UM1786
HAL DMA Generic Driver


15.2.3
HAL_DMA_Init()
HAL_DMA_DeInit()
IO operation functions
This section provides functions allowing to:










15.2.4
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
HAL_DMA_Start()
HAL_DMA_Start_IT()
HAL_DMA_Abort()
HAL_DMA_PollForTransfer()
HAL_DMA_IRQHandler()
State and Errors functions
This subsection provides functions allowing to




15.2.5
15.2.6
Check the DMA state
Get error code
HAL_DMA_GetState()
HAL_DMA_GetError()
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
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.
DOCID026526 Rev 2
241/861
HAL DMA Generic Driver
Return values
15.2.7
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
15.2.8

HAL status
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
242/861
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_DMA_Start_IT



15.2.9
HAL status

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
DOCID026526 Rev 2
UM1786
15.2.10
HAL DMA Generic Driver
only after the transfer of this single data is finished.
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
15.2.11
15.2.12
15.2.13


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
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 2
243/861
HAL DMA Generic Driver
15.3
UM1786
DMA Firmware driver defines
The following section lists the various define and macros of the module.
15.3.1
DMA
DMA
DMA Data buffer size
IS_DMA_BUFFER_SIZE
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
IS_DMA_DIRECTION
DMA Error Code
HAL_DMA_ERROR_NONE
No error
HAL_DMA_ERROR_TE
Transfer error
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
Description:

244/861
None.:
Enables the specified DMA Channel
DOCID026526 Rev 2
UM1786
HAL DMA Generic Driver
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:

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 has occurred or not.
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
DOCID026526 Rev 2
245/861
HAL DMA Generic Driver
UM1786
Return value:

The: state of DMA_IT (SET or RESET).
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
DMA_IT_HT
DMA_IT_TE
DMA Memory data size
246/861
DOCID026526 Rev 2
UM1786
DMA_MDATAALIGN_BYTE
HAL DMA Generic Driver
Memory data alignment : Byte
DMA_MDATAALIGN_HALFWORD
Memory data alignment : HalfWord
DMA_MDATAALIGN_WORD
Memory data alignment : Word
IS_DMA_MEMORY_DATA_SIZE
DMA Memory incremented mode
DMA_MINC_ENABLE
Memory increment mode Enable
DMA_MINC_DISABLE
Memory increment mode Disable
IS_DMA_MEMORY_INC_STATE
DMA mode
DMA_NORMAL
Normal Mode
DMA_CIRCULAR
Circular Mode
IS_DMA_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
IS_DMA_PERIPHERAL_DATA_SIZE
DMA Peripheral incremented mode
DMA_PINC_ENABLE
Peripheral increment mode Enable
DMA_PINC_DISABLE
Peripheral increment mode Disable
IS_DMA_PERIPHERAL_INC_STATE
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
IS_DMA_PRIORITY
DMA Private Constants
HAL_TIMEOUT_DMA_ABORT
DMA Remap Enable
__HAL_REMAPDMA_CHANNEL_ENABLE
Description:

DMA remapping enable/disable
macros.
Parameters:

__DMA_REMAP__: This parameter
can be a value of
__HAL_REMAPDMA_CHANNEL_DISABLE
DOCID026526 Rev 2
247/861
HAL DMA Extension Driver
UM1786
16
HAL DMA Extension Driver
16.1
DMAEx Firmware driver defines
The following section lists the various define and macros of the module.
16.1.1
DMAEx
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_FLAG
The: specified transfer error flag index.
Description:

Get the DMA Channel pending flags.
Parameters:


248/861
__HANDLE__: DMA handle
__FLAG__: Get the specified flag. This
parameter can be any combination of the
following values:

DMA_FLAG_TCx: Transfer complete
flag
DOCID026526 Rev 2
UM1786
HAL DMA Extension Driver


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:

None:
DOCID026526 Rev 2
249/861
HAL FLASH Generic Driver
UM1786
17
HAL FLASH Generic Driver
17.1
FLASH Firmware driver registers structures
17.1.1
FLASH_EraseInitTypeDef
FLASH_EraseInitTypeDef is defined in the stm32f3xx_hal_flash.h
Data Fields



uint32_t TypeErase
uint32_t PageAddress
uint32_t NbPages
Field Documentation



17.1.2
uint32_t FLASH_EraseInitTypeDef::TypeErase
TypeErase: Mass erase or page erase. This parameter can be a value of
FLASH_Type_Erase
uint32_t FLASH_EraseInitTypeDef::PageAddress
PageAdress: Initial FLASH page address to erase when mass erase is disabled This
parameter must be a value of FLASHEx_Address
uint32_t FLASH_EraseInitTypeDef::NbPages
NbPages: Number of pagess to be erased. This parameter must be a value between
1 and (max number of pages - value of initial page)
FLASH_OBProgramInitTypeDef
FLASH_OBProgramInitTypeDef is defined in the stm32f3xx_hal_flash.h
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


250/861
uint32_t FLASH_OBProgramInitTypeDef::OptionType
OptionType: Option byte to be configured. This parameter can be a value of
FLASH_OB_Type
uint32_t FLASH_OBProgramInitTypeDef::WRPState
WRPState: Write protection activation or deactivation. This parameter can be a value
of FLASH_OB_WRP_State
DOCID026526 Rev 2
UM1786
HAL FLASH Generic Driver





17.1.3
uint32_t FLASH_OBProgramInitTypeDef::WRPPage
WRPSector: specifies the page(s) to be write protected This parameter can be a
value of FLASHEx_OB_Write_Protection
uint8_t FLASH_OBProgramInitTypeDef::RDPLevel
RDPLevel: Set the read protection level.. This parameter can be a value of
FLASH_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 FLASH_OB_IWatchdog,
FLASH_OB_nRST_STOP, FLASH_OB_nRST_STDBY, FLASH_OB_BOOT1,
FLASH_OB_VDDA_Analog_Monitoring, FLASH_OB_SRAM_Parity_Enable and
FLASH_OB_SDADC12_VDD_MONITOR
uint32_t FLASH_OBProgramInitTypeDef::DATAAddress
DATAAddress: Address of the option byte DATA to be prgrammed This parameter
can be a value of FLASH_OB_Data_Address
uint8_t FLASH_OBProgramInitTypeDef::DATAData
DATAData: Data to be stored in the option byte DATA This parameter can have any
value
FLASH_ProcessTypeDef
FLASH_ProcessTypeDef is defined in the stm32f3xx_hal_flash.h
Data Fields






__IO FLASH_ProcedureTypeDef ProcedureOnGoing
__IO uint32_t DataRemaining
__IO uint32_t Address
__IO uint64_t Data
HAL_LockTypeDef Lock
__IO FLASH_ErrorTypeDef ErrorCode
Field Documentation






17.2
__IO FLASH_ProcedureTypeDef FLASH_ProcessTypeDef::ProcedureOnGoing
__IO uint32_t FLASH_ProcessTypeDef::DataRemaining
__IO uint32_t FLASH_ProcessTypeDef::Address
__IO uint64_t FLASH_ProcessTypeDef::Data
HAL_LockTypeDef FLASH_ProcessTypeDef::Lock
__IO FLASH_ErrorTypeDef FLASH_ProcessTypeDef::ErrorCode
FLASH Firmware driver API description
The following section lists the various functions of the FLASH library.
17.2.1
FLASH peripheral features
DOCID026526 Rev 2
251/861
HAL FLASH Generic Driver
UM1786
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:
1.
2.
3.
4.
17.2.2
Flash memory read operations
Flash memory program/erase operations
Read / write protections
Prefetch on I-Code
How to use this driver
This driver provides functions and macros to configure and program the FLASH memory of
all STM32F3xx devices. These functions are split in 3 groups:
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 and word
Option Bytes Programming functions: this group includes all needed functions to
manage the Option Bytes:

Lock and Unlock the Option Bytes

Erase Option Bytes

Set/Reset the write protection

Set the Read protection Level

Program the user Option Bytes

Program the data Option Bytes

Launch the Option Bytes loader
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 the latency
Enable/Disable the prefetch buffer
Enable/Disable the half cycle access
Enable/Disable the FLASH interrupts
Monitor the FLASH flags status
IO operation functions
This subsection provides a set of functions allowing to manage the FLASH program
operations (write/erase).


252/861
HAL_FLASH_Program()
HAL_FLASH_Program_IT()
DOCID026526 Rev 2
UM1786
HAL FLASH Generic Driver



17.2.4
HAL_FLASH_IRQHandler()
HAL_FLASH_EndOfOperationCallback()
HAL_FLASH_OperationErrorCallback()
Peripheral Control functions
This subsection provides a set of functions allowing to control the FLASH memory
operations.





17.2.5
HAL_FLASH_Unlock()
HAL_FLASH_Lock()
HAL_FLASH_OB_Unlock()
HAL_FLASH_OB_Lock()
HAL_FLASH_OB_Launch()
Peripheral State functions
This subsection permit to get in run-time the status of the FLASH peripheral.

17.2.6
HAL_FLASH_GetError()
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.

17.2.7
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
DOCID026526 Rev 2
253/861
HAL FLASH Generic Driver


UM1786
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.

17.2.8
17.2.9
17.2.10
254/861
HAL_FLASH_IRQHandler
Function Name
void HAL_FLASH_IRQHandler (void )
Function Description
This function handles FLASH interrupt request.
Return values

None
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
expectedPages Erase: Address of the page which has been
erasedProgram: 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
expectedPages Erase: Address of the page which returned
an errorProgram: Address which was selected for data
program
Return values

none
DOCID026526 Rev 2
UM1786
17.2.11
17.2.12
17.2.13
17.2.14
17.2.15
17.2.16
HAL FLASH Generic Driver
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
Function Name
HAL_StatusTypeDef HAL_FLASH_OB_Unlock (void )
Function Description
Unlock the FLASH Option Control Registers access.
Return values

HAL Status
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
HAL_FLASH_GetError
Function Name
FLASH_ErrorTypeDef HAL_FLASH_GetError (void )
Function Description
Get the specific FLASH error flag.
Return values

FLASH_ErrorCode The returned value can be:
FLASH_ERROR_PG: FLASH Programming error flag
FLASH_ERROR_WRP: FLASH Write protected error flag
DOCID026526 Rev 2
255/861
HAL FLASH Generic Driver
17.3
UM1786
FLASH Firmware driver defines
The following section lists the various define and macros of the module.
17.3.1
FLASH
FLASH
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
IS_FLASH_CLEAR_FLAG
IS_FLASH_GET_FLAG
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 Interrupt
__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:

256/861
__INTERRUPT__: FLASH interrupt This parameter
can be any combination of the following values:
DOCID026526 Rev 2
UM1786
HAL FLASH Generic Driver


FLASH_IT_EOP: End of FLASH Operation
Interrupt
FLASH_IT_ERR: Error Interrupt
Return value:

none:
Description:
__HAL_FLASH_GET_FLAG

Get the specified FLASH flag status.
Parameters:

__FLAG__: specifies the FLASH flag to check. This
parameter can be one 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

FLASH_FLAG_BSY : FLASH Busy 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
IS_FLASH_IT
FLASH Latency
FLASH_LATENCY_0
FLASH Zero Latency cycle
FLASH_LATENCY_1
FLASH One Latency cycle
FLASH_LATENCY_2
FLASH Two Latency cycles
IS_FLASH_LATENCY
DOCID026526 Rev 2
257/861
HAL FLASH Generic Driver
__HAL_FLASH_SET_LATENCY
UM1786
Description:

Set the FLASH Latency.
Parameters:

__LATENCY__: FLASH Latency The value of this
parameter depend on device used within the same
series
Return value:

None:
FLASH Option Byte BOOT1
OB_BOOT1_RESET
BOOT1 Reset
OB_BOOT1_SET
BOOT1 Set
IS_OB_BOOT1
FLASH Option Byte Data Address
IS_OB_DATA_ADDRESS
FLASH Option Byte IWatchdog
OB_IWDG_SW
Software IWDG selected
OB_IWDG_HW
Hardware IWDG selected
IS_OB_IWDG_SOURCE
FLASH Option Byte nRST STDBY
OB_STDBY_NO_RST
No reset generated when entering in STANDBY
OB_STDBY_RST
Reset generated when entering in STANDBY
IS_OB_STDBY_SOURCE
FLASH Option Byte nRST STOP
OB_STOP_NO_RST
No reset generated when entering in STOP
OB_STOP_RST
Reset generated when entering in STOP
IS_OB_STOP_SOURCE
FLASH 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
IS_OB_RDP_LEVEL
FLASH Option Byte SDADC12 VDD MONITOR
OB_SDADC12_VDD_MONITOR_SET
SDADC12_VDD power supply supervisor set
OB_SDADC12_VDD_MONITOR_RESET
SDADC12_VDD power supply supervisor reset
IS_OB_SDADC12_VDD_MONITOR
FLASH Option Byte SRAM Parity Enable
258/861
DOCID026526 Rev 2
UM1786
HAL FLASH Generic Driver
OB_SRAM_PARITY_SET
SRAM parity enable set
OB_SRAM_PARITY_RESET
SRAM parity enable reset
IS_OB_SRAM_PARITY
FLASH 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
IS_OPTIONBYTE
FLASH 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
IS_OB_VDDA_ANALOG
FLASH WRP State
WRPSTATE_DISABLE
Disable the write protection of the desired pages
WRPSTATE_ENABLE
Enable the write protection of the desired pagess
IS_WRPSTATE
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:

None:
FLASH Private Define
HAL_FLASH_TIMEOUT_VALUE
FLASH Timeout definition
HAL_FLASH_TIMEOUT_VALUE
FLASH Type Erase
TYPEERASE_PAGES
Pages erase only
TYPEERASE_MASSERASE
Flash mass erase activation
IS_TYPEERASE
FLASH Type Program
DOCID026526 Rev 2
259/861
HAL FLASH Generic Driver
TYPEPROGRAM_HALFWORD
UM1786
Program a half-word (16-bit) at a specified address.
TYPEPROGRAM_WORD
Program a word (32-bit) at a specified address.
TYPEPROGRAM_DOUBLEWORD
Program a double word (64-bit) at a specified
address
IS_TYPEPROGRAM
260/861
DOCID026526 Rev 2
UM1786
HAL FLASH Extension Driver
18
HAL FLASH Extension Driver
18.1
FLASHEx Firmware driver API description
The following section lists the various functions of the FLASHEx library.
18.1.1
IO operation functions


18.1.2
HAL_FLASHEx_Erase()
HAL_FLASHEx_Erase_IT()
Peripheral Control functions
This subsection provides a set of functions allowing to control the FLASH memory
operations.



18.1.3
18.1.4
HAL_FLASHEx_OBErase()
HAL_FLASHEx_OBProgram()
HAL_FLASHEx_OBGetConfig()
HAL_FLASHEx_Erase
Function Name
HAL_StatusTypeDef HAL_FLASHEx_Erase
(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

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
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
sectors with interrupt enabled.
Parameters

pEraseInit: pointer to an FLASH_EraseInitTypeDef structure
DOCID026526 Rev 2
261/861
HAL FLASH Extension Driver
18.1.5
18.1.6
18.1.7
262/861
UM1786
that contains the configuration information for the erasing.
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
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
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
DOCID026526 Rev 2
UM1786
18.2
HAL FLASH Extension Driver
FLASHEx Firmware driver defines
The following section lists the various define and macros of the module.
18.2.1
FLASHEx
FLASHEx
FLASH Extended Address
IS_FLASH_PROGRAM_ADDRESS
FLASH Extended Exported Constants
FLASH_SIZE_DATA_REGISTER
FLASH_PAGE_SIZE
FLASH Extended Nb Pages
IS_FLASH_NB_PAGES
FLASH Extended Option Bytes 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
OB_WRP_PAGES32TO33
OB_WRP_PAGES34TO35
OB_WRP_PAGES36TO37
OB_WRP_PAGES38TO39
OB_WRP_PAGES40TO41
OB_WRP_PAGES42TO43
OB_WRP_PAGES44TO45
OB_WRP_PAGES46TO47
DOCID026526 Rev 2
263/861
HAL FLASH Extension Driver
OB_WRP_PAGES48TO49
UM1786
OB_WRP_PAGES50TO51
OB_WRP_PAGES52TO53
OB_WRP_PAGES54TO55
OB_WRP_PAGES56TO57
OB_WRP_PAGES58TO59
OB_WRP_PAGES60TO61
OB_WRP_PAGES62TO255
OB_WRP_PAGES0TO15MASK
OB_WRP_PAGES16TO31MASK
OB_WRP_PAGES32TO47MASK
OB_WRP_PAGES48TO255MASK
OB_WRP_ALLPAGES
Write protection of all pages
IS_OB_WRP
FLASH Extended Private Define
HAL_FLASH_TIMEOUT_VALUE
264/861
DOCID026526 Rev 2
UM1786
HAL GPIO Generic Driver
19
HAL GPIO Generic Driver
19.1
GPIO Firmware driver registers structures
19.1.1
GPIO_InitTypeDef
GPIO_InitTypeDef is defined in the stm32f3xx_hal_gpio.h
Data Fields





uint32_t Pin
uint32_t Mode
uint32_t Pull
uint32_t Speed
uint32_t Alternate
Field Documentation





19.2
uint32_t GPIO_InitTypeDef::Pin
Specifies the GPIO pins to be configured. This parameter can be any value of
GPIO_pins_define
uint32_t GPIO_InitTypeDef::Mode
Specifies the operating mode for the selected pins. This parameter can be a value of
GPIO_mode_define
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_define
uint32_t GPIO_InitTypeDef::Speed
Specifies the speed for the selected pins. This parameter can be a value of
GPIO_speed_define
uint32_t GPIO_InitTypeDef::Alternate
Peripheral to be connected to the selected pins This parameter can be a value of
GPIOEx_Alternate_function_selection
GPIO Firmware driver API description
The following section lists the various functions of the GPIO library.
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
DOCID026526 Rev 2
265/861
HAL GPIO Generic Driver
UM1786
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.
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 s 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.
19.2.2
How to use this driver
1.
2.
3.
4.
5.
6.
7.
8.
266/861
Enable the GPIO AHB clock using the following function : __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, the speed is
configurable: Low, Medium and High.

If alternate mode is selected, 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().
HAL_GPIO_DeInit allows to set register values to their reset value. It's also
recommended to use it to unconfigure pin which was used as an external interrupt or
in event mode. That's the only way to reset corresponding bit in EXTI & SYSCFG
registers.
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).
DOCID026526 Rev 2
UM1786
HAL GPIO Generic Driver
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.
10. The HSE oscillator pins OSC_IN/OSC_OUT can be used as general purpose Px0
and Px1, respectively, when the HSE oscillator is off. The HSE has priority over the
GPIO function.
9.
19.2.3
Initialization and de-initialization functions


19.2.4
IO operation functions






19.2.5
HAL_GPIO_Init()
HAL_GPIO_DeInit()
HAL_GPIO_ReadPin()
HAL_GPIO_WritePin()
HAL_GPIO_TogglePin()
HAL_GPIO_LockPin()
HAL_GPIO_EXTI_IRQHandler()
HAL_GPIO_EXTI_Callback()
HAL_GPIO_Init
Function Name
void HAL_GPIO_Init (GPIO_TypeDef * GPIOx,
GPIO_InitTypeDef * GPIO_Init)
Function Description
Initializes the GPIOx peripheral according to the specified
parameters in the GPIO_Init.
Parameters

Return values
19.2.6

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-initializes 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
DOCID026526 Rev 2
267/861
HAL GPIO Generic Driver
19.2.7
HAL_GPIO_ReadPin
Function Name
GPIO_PinState HAL_GPIO_ReadPin (GPIO_TypeDef * GPIOx,
uint16_t GPIO_Pin)
Function Description
Reads the specified input port pin.
Parameters

Return values
19.2.8
UM1786

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.
HAL_GPIO_WritePin
Function Name
void HAL_GPIO_WritePin (GPIO_TypeDef * GPIOx, uint16_t
GPIO_Pin, GPIO_PinState PinState)
Function Description
Sets or clears 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 register to allow atomic
read/modify accesses. In this way, there is no risk of an IRQ
occurring between the read and the modify access.

19.2.9
HAL_GPIO_TogglePin
Function Name
void HAL_GPIO_TogglePin (GPIO_TypeDef * GPIOx, uint16_t
GPIO_Pin)
Function Description
Toggles the specified GPIO pin.
Parameters

Return values
19.2.10

None
HAL_GPIO_LockPin
Function Name
268/861

GPIOx: where x can be (A..F) to select the GPIO peripheral
for STM32F3 family
GPIO_Pin: specifies the pins to be toggled.
HAL_StatusTypeDef HAL_GPIO_LockPin (GPIO_TypeDef *
GPIOx, uint16_t GPIO_Pin)
DOCID026526 Rev 2
UM1786
HAL GPIO Generic Driver
Function Description
Locks GPIO Pins configuration registers.
Parameters


GPIOx: where x can be (A..F) to select the GPIO peripheral
for STM32F3 family
GPIO_Pin: specifies the port bit 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.

19.2.11
19.2.12
19.3
HAL_GPIO_EXTI_IRQHandler
Function Name
void HAL_GPIO_EXTI_IRQHandler (uint16_t GPIO_Pin)
Function Description
This function handles EXTI interrupt request.
Parameters

GPIO_Pin: Specifies the pins connected 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 callbacks.
Parameters

GPIO_Pin: Specifies the pins connected EXTI line
Return values

None
GPIO Firmware driver defines
The following section lists the various define and macros of the module.
19.3.1
GPIO
GPIO
GPIO Exported Macros
__HAL_GPIO_EXTI_GET_FLAG
Description:

Checks 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:
DOCID026526 Rev 2
269/861
HAL GPIO Generic Driver
UM1786

__HAL_GPIO_EXTI_CLEAR_FLAG
The: new state of __EXTI_LINE__ (SET or
RESET).
Description:

Clears 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:

Checks whether the specified EXTI line is
asserted or not.
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:

Clears 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:

Generates 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 define
GPIO_MODE_INPUT
270/861
Input Floating Mode
DOCID026526 Rev 2
UM1786
HAL GPIO Generic Driver
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
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
IS_GPIO_MODE
GPIO pins define
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
IS_GPIO_PIN
GPIO pin actions
DOCID026526 Rev 2
271/861
HAL GPIO Generic Driver
IS_GPIO_PIN_ACTION
UM1786
GPIO Private Defines
GET_GPIO_SOURCE
GPIO_MODE
EXTI_MODE
GPIO_MODE_IT
GPIO_MODE_EVT
RISING_EDGE
FALLING_EDGE
GPIO_OUTPUT_TYPE
GPIO_NUMBER
GPIO pull define
GPIO_NOPULL
No Pull-up or Pull-down activation
GPIO_PULLUP
Pull-up activation
GPIO_PULLDOWN
Pull-down activation
IS_GPIO_PULL
GPIO speed define
GPIO_SPEED_LOW
Low speed
GPIO_SPEED_MEDIUM
Medium speed
GPIO_SPEED_HIGH
High speed
IS_GPIO_SPEED
272/861
DOCID026526 Rev 2
UM1786
HAL GPIO Extension Driver
20
HAL GPIO Extension Driver
20.1
GPIOEx Firmware driver defines
The following section lists the various define and macros of the module.
20.1.1
GPIOEx
GPIOEx
GPIO Extended 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_AF2_I2C3
GPIO_AF2_TIM20
GPIO_AF3_TSC
GPIO_AF3_TIM8
GPIO_AF3_COMP7
GPIO_AF3_TIM15
GPIO_AF3_I2C3
GPIO_AF3_TIM20
GPIO_AF4_TIM1
GPIO_AF4_TIM8
GPIO_AF4_TIM16
DOCID026526 Rev 2
273/861
HAL GPIO Extension Driver
GPIO_AF4_TIM17
UM1786
GPIO_AF4_I2C1
GPIO_AF4_I2C2
GPIO_AF5_SPI1
GPIO_AF5_SPI2
GPIO_AF5_SPI3
GPIO_AF5_I2S
GPIO_AF5_I2S2ext
GPIO_AF5_TIM8
GPIO_AF5_IR
GPIO_AF5_UART4
GPIO_AF5_UART5
GPIO_AF5_SPI4
GPIO_AF6_SPI2
GPIO_AF6_SPI3
GPIO_AF6_I2S3ext
GPIO_AF6_TIM1
GPIO_AF6_TIM8
GPIO_AF6_IR
GPIO_AF6_TIM20
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_AF8_I2C3
GPIO_AF9_CAN
GPIO_AF9_TIM1
274/861
DOCID026526 Rev 2
UM1786
HAL GPIO Extension Driver
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
GPIO_AF12_TIM1
GPIO_AF12_FMC
GPIO_AF12_SDIO
GPIO_AF14_USB
GPIO_AF15_EVENTOUT
IS_GPIO_AF
DOCID026526 Rev 2
275/861
HAL HRTIM Generic Driver
UM1786
21
HAL HRTIM Generic Driver
21.1
HRTIM Firmware driver registers structures
21.1.1
HRTIM_InitTypeDef
HRTIM_InitTypeDef is defined in the stm32f3xx_hal_hrtim.h
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
HRTIM_TimerParamTypeDef is defined in the stm32f3xx_hal_hrtim.h
Data Fields




276/861
uint32_t CaptureTrigger1
uint32_t CaptureTrigger2
uint32_t InterruptRequests
uint32_t DMARequests
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver



uint32_t DMASrcAddress
uint32_t DMADstAddress
uint32_t DMASize
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
__HRTIM_HandleTypeDef is defined in the stm32f3xx_hal_hrtim.h
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


HRTIM_TypeDef* __HRTIM_HandleTypeDef::Instance
Register base address
HRTIM_InitTypeDef __HRTIM_HandleTypeDef::Init
HRTIM required parameters
DOCID026526 Rev 2
277/861
HAL HRTIM Generic Driver









21.1.4
UM1786
HRTIM_TimerParamTypeDef
__HRTIM_HandleTypeDef::TimerParam[MAX_HRTIM_TIMER]
HRTIM timers - including the master - parameters
HAL_LockTypeDef __HRTIM_HandleTypeDef::Lock
Locking object
__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
HRTIM_TimeBaseCfgTypeDef is defined in the stm32f3xx_hal_hrtim.h
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
HRTIM_SimpleOCChannelCfgTypeDef is defined in the stm32f3xx_hal_hrtim.h
278/861
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver
Data Fields




uint32_t Mode
uint32_t Pulse
uint32_t Polarity
uint32_t IdleLevel
Field Documentation




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
HRTIM_SimplePWMChannelCfgTypeDef is defined in the stm32f3xx_hal_hrtim.h
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
HRTIM_SimpleCaptureChannelCfgTypeDef is defined in the stm32f3xx_hal_hrtim.h
Data Fields

uint32_t Event
DOCID026526 Rev 2
279/861
HAL HRTIM Generic Driver



UM1786
uint32_t EventPolarity
uint32_t EventSensitivity
uint32_t EventFilter
Field Documentation




21.1.8
uint32_t HRTIM_SimpleCaptureChannelCfgTypeDef::Event
Specifies the external event triggering the capture. This parameter can be any 'EEVx'
value of HRTIM_External_Event_Channels
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
HRTIM_SimpleOnePulseChannelCfgTypeDef is defined in the stm32f3xx_hal_hrtim.h
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





280/861
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
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver


21.1.9
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
HRTIM_TimerCfgTypeDef is defined in the stm32f3xx_hal_hrtim.h
Data Fields





















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




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
DOCID026526 Rev 2
281/861
HAL HRTIM Generic Driver















282/861
UM1786
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
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
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver


21.1.10
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
HRTIM_CompareCfgTypeDef is defined in the stm32f3xx_hal_hrtim.h
Data Fields



uint32_t CompareValue
uint32_t AutoDelayedMode
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
HRTIM_CaptureCfgTypeDef is defined in the stm32f3xx_hal_hrtim.h
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
HRTIM_OutputCfgTypeDef is defined in the stm32f3xx_hal_hrtim.h
DOCID026526 Rev 2
283/861
HAL HRTIM Generic Driver
Data Fields








UM1786
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








21.1.13
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
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
HRTIM_TimerEventFilteringCfgTypeDef is defined in the stm32f3xx_hal_hrtim.h
Data Fields


uint32_t Filter
uint32_t Latch
Field Documentation
284/861
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver


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
HRTIM_DeadTimeCfgTypeDef is defined in the stm32f3xx_hal_hrtim.h
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
Field Documentation









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
DOCID026526 Rev 2
285/861
HAL HRTIM Generic Driver
21.1.15
UM1786
HRTIM_ChopperModeCfgTypeDef
HRTIM_ChopperModeCfgTypeDef is defined in the stm32f3xx_hal_hrtim.h
Data Fields



uint32_t CarrierFreq
uint32_t DutyCycle
uint32_t StartPulse
Field Documentation



21.1.16
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
HRTIM_EventCfgTypeDef
HRTIM_EventCfgTypeDef is defined in the stm32f3xx_hal_hrtim.h
Data Fields





uint32_t Source
uint32_t Polarity
uint32_t Sensitivity
uint32_t Filter
uint32_t FastMode
Field Documentation




286/861
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
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver

21.1.17
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
HRTIM_FaultCfgTypeDef is defined in the stm32f3xx_hal_hrtim.h
Data Fields




uint32_t Source
uint32_t Polarity
uint32_t Filter
uint32_t Lock
Field Documentation




21.1.18
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
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
HRTIM_BurstModeCfgTypeDef is defined in the stm32f3xx_hal_hrtim.h
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

uint32_t HRTIM_BurstModeCfgTypeDef::Mode
Specifies the burst mode operating mode. This parameter can be a value of
HRTIM_Burst_Mode_Operating_Mode
DOCID026526 Rev 2
287/861
HAL HRTIM Generic Driver






21.1.19
UM1786
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
HRTIM_ADCTriggerCfgTypeDef is defined in the stm32f3xx_hal_hrtim.h
Data Fields


uint32_t UpdateSource
uint32_t Trigger
Field Documentation


21.2
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
HRTIM Firmware driver API description
The following section lists the various functions of the HRTIM library.
21.2.1
Simple mode v.s. waveform mode
The HRTIM HAL API is split into 2 categories:
1.
288/861
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
DOCID026526 Rev 2
UM1786
2.
21.2.2
HAL HRTIM Generic Driver
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.
2.
3.
4.
5.
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:
__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())

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
DOCID026526 Rev 2
289/861
HAL HRTIM Generic Driver
UM1786
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
6.
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
If the HRTIM timer operates in simple mode
1.
290/861
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().
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver

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.
2.
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()).

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
DOCID026526 Rev 2
291/861
HAL HRTIM Generic Driver
UM1786
force the output level by software to have the outputs in a complementary state
as soon as the RUN mode is entered.
3.
Enable or Disable waveform timer output(s)

HAL_HRTIM_WaveformOutputStart(),HAL_HRTIM_WaveformOutputStop().
4.
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(),
5.
Burst mode controller enabling:

HAL_HRTIM_BurstModeCtl(): activates or de-activates the burst mode controller.
6.
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.
7.
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.

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).
8.
Some functions can be used any time to retrieve actual HRTIM status

HAL_HRTIM_GetState(): returns actual HRTIM instance HAL state.
21.2.3
Initialization and Time Base Configuration functions
This section provides functions allowing to:





292/861
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)
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver










21.2.4
Check that the high resolution unit is ready (DLL calibration done)
Configure the time base unit of a HRTIM timer
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:












21.2.5
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.
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 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
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()
DOCID026526 Rev 2
293/861
HAL HRTIM Generic Driver
21.2.6
UM1786
Simple PWM output functions
This section provides functions allowing to:














21.2.7
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
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:














21.2.8
Configure simple input capture channel
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.
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:


294/861
Configure one pulse channel
Start one pulse generation
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver








21.2.9
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.
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:














21.2.10
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
HAL_HRTIM_BurstModeConfig()
HAL_HRTIM_EventConfig()
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
DOCID026526 Rev 2
295/861
HAL HRTIM Generic Driver



































21.2.11
UM1786
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
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()
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:












296/861
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
HAL_HRTIM_GetState()
HAL_HRTIM_GetCapturedValue()
HAL_HRTIM_WaveformGetOutputLevel()
HAL_HRTIM_WaveformGetOutputState()
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver




21.2.12
21.2.13
21.2.14
21.2.15
21.2.16
HAL_HRTIM_GetDelayedProtectionStatus()
HAL_HRTIM_GetBurstStatus()
HAL_HRTIM_GetCurrentPushPullStatus()
HAL_HRTIM_GetIdlePushPullStatus()
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
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_DLLCalibrationStart
Function Name
HAL_StatusTypeDef HAL_HRTIM_DLLCalibrationStart
(HRTIM_HandleTypeDef * hhrtim, uint32_t CalibrationRate)
Function Description
Starts the DLL calibration.
DOCID026526 Rev 2
297/861
HAL HRTIM Generic Driver
Parameters
21.2.17
UM1786


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 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.

21.2.18
298/861
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
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver
Return values
21.2.19

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



21.2.20
21.2.21
HAL status
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_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.
DOCID026526 Rev 2
299/861
HAL HRTIM Generic Driver
Parameters
Return values
21.2.22
21.2.23
21.2.24
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

HAL status
HAL_HRTIM_SimpleBaseStart_IT
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
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
300/861
UM1786


HAL_StatusTypeDef HAL_HRTIM_SimpleBaseStart_DMA
(HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver
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





21.2.25
21.2.26
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
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_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
DOCID026526 Rev 2
301/861
HAL HRTIM Generic Driver
UM1786

21.2.27
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
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.
Parameters



Return values
21.2.28
302/861
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

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
DOCID026526 Rev 2
UM1786
Function Name
HAL HRTIM Generic Driver
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
21.2.29

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_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
DOCID026526 Rev 2
303/861
HAL HRTIM Generic Driver
Return values
Notes
21.2.30
UM1786

HAL status

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



Return values
21.2.31

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



304/861
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
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
DOCID026526 Rev 2
UM1786



21.2.32
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
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
21.2.33
HAL HRTIM Generic Driver
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

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
DOCID026526 Rev 2
305/861
HAL HRTIM Generic Driver
Function Name
UM1786
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




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).

21.2.34
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



306/861
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
pSimplePWMChannelCfg: pointer to the simple PWM output
configuration structure
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
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver
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
21.2.35

HAL_HRTIM_SimplePWMStop
Function Name
HAL_StatusTypeDef HAL_HRTIM_SimplePWMStop
(HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t
PWMChannel)
Function Description
Stops the PWM output signal generation on the designed timer
output.
Parameters



Return values
21.2.36
HAL status

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


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
DOCID026526 Rev 2
307/861
HAL HRTIM Generic Driver

Return values
21.2.37

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
308/861
HAL status
HAL_HRTIM_SimplePWMStop_IT

21.2.38
UM1786
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_StatusTypeDef HAL_HRTIM_SimplePWMStart_DMA
(HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t
PWMChannel, uint32_t SrcAddr, uint32_t DestAddr, uint32_t
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver
Length)
Function Description
Starts the PWM output signal generation on the designed timer
output (The compare DMA request is enabled).
Parameters






Return values
21.2.39

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
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



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 2
309/861
HAL HRTIM Generic Driver
UM1786
HRTIM_OUTPUT_TE2: Timer E - Output 2
Return values
21.2.40

HAL_HRTIM_SimpleCaptureChannelConfig
Function Name
HAL_StatusTypeDef
HAL_HRTIM_SimpleCaptureChannelConfig
(HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t
CaptureChannel, HRTIM_SimpleCaptureChannelCfgTypeDef *
pSimpleCaptureChannelCfg)
Function Description
Configures a simple capture.
Parameters




21.2.41
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



Return values
310/861
HAL status

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
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver
Notes
21.2.42

HAL_HRTIM_SimpleCaptureStop
Function Name
HAL_StatusTypeDef HAL_HRTIM_SimpleCaptureStop
(HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t
CaptureChannel)
Function Description
Disables a simple capture on the designed capture unit.
Parameters



Return values
21.2.43

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
21.2.44
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.

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
Function Name
HAL_StatusTypeDef HAL_HRTIM_SimpleCaptureStop_IT
(HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t
CaptureChannel)
DOCID026526 Rev 2
311/861
HAL HRTIM Generic Driver
Function Description
Parameters
UM1786
Disables a simple capture on the designed capture unit (Capture
interrupt is disabled).



Return values
21.2.45

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
312/861
HAL status
HAL_HRTIM_SimpleCaptureStart_DMA

21.2.46
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

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
DOCID026526 Rev 2
UM1786

Return values
21.2.47

HAL HRTIM Generic Driver
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_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




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
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

DOCID026526 Rev 2
313/861
HAL HRTIM Generic Driver
UM1786
related configuration data provided in the first call.
21.2.48
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
21.2.49

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



314/861
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
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 2
UM1786
HAL HRTIM Generic Driver
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
21.2.50

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
21.2.51
HAL status

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
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
HRTIM_TIMERINDEX_TIMER_E for timer E
OnePulseChannel: Timer output This parameter can be one
DOCID026526 Rev 2
315/861
HAL HRTIM Generic Driver
Return values
21.2.52
21.2.53
UM1786
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_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



316/861
HAL status
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
Return values

HAL status
Notes

This function must be called before starting the timer
DOCID026526 Rev 2
UM1786
21.2.54
21.2.55
HAL HRTIM Generic Driver
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



21.2.56
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
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 HRTIM_FAULTPRESCALER_DIV4:
fFLTS=fHRTIM / 4 HRTIM_FAULTPRESCALER_DIV8:
fFLTS=fHRTIM / 8
DOCID026526 Rev 2
317/861
HAL HRTIM Generic Driver
Return values
Notes
21.2.57
UM1786

HAL status

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
21.2.58

318/861
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



21.2.59
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
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,
HRTIM_TimerCfgTypeDef * pTimerCfg)
Function Description
Configures the general behavior of a timer operating in waveform
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver
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

21.2.60
HAL_HRTIM_TimerEventFilteringConfig
Function Name
HAL_StatusTypeDef HAL_HRTIM_TimerEventFilteringConfig
(HRTIM_HandleTypeDef * hhrtim, uint32_t TimerIdx, uint32_t
Event, HRTIM_TimerEventFilteringCfgTypeDef *
pTimerEventFilteringCfg)
Function Description
Configures the event filtering capabilities of a timer (blanking,
windowing)
Parameters




21.2.61
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
DOCID026526 Rev 2
319/861
HAL HRTIM Generic Driver
Function Name
UM1786
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



21.2.62
Return values

HAL status
Notes

This function must be called before starting the timer
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



21.2.63
320/861
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
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


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 2
UM1786

21.2.64
HAL HRTIM Generic Driver
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 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_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



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
DOCID026526 Rev 2
321/861
HAL HRTIM Generic Driver

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
This function must be called before starting the timer

21.2.65
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




21.2.66
322/861
UM1786
HRTIM_COMPAREUNIT_3: Compare unit 3
HRTIM_COMPAREUNIT_4: Compare unit 4
pCompareCfg: pointer to the compare unit configuration
structure
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
DOCID026526 Rev 2
UM1786


21.2.67
HAL HRTIM Generic Driver
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
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
DOCID026526 Rev 2
323/861
HAL HRTIM Generic Driver
UM1786
registers is automatically reset by hardware
21.2.68
21.2.69
21.2.70
324/861
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_WaveformCounterStart
DOCID026526 Rev 2
UM1786
Function Name
21.2.71
21.2.72
HAL HRTIM Generic Driver
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
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.
DOCID026526 Rev 2
325/861
HAL HRTIM Generic Driver
UM1786
Interrupts to enable are selected through
HAL_HRTIM_WaveformTimerConfig function.
21.2.73
HAL_HRTIM_WaveformCounterStop_IT
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
disabled
All enabled timer related interrupts are disabled.

21.2.74
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)

21.2.75
326/861
HAL_HRTIM_WaveformCounterStop_DMA
DOCID026526 Rev 2
UM1786
Function Name
HAL HRTIM Generic Driver
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.

21.2.76
21.2.77
21.2.78
HAL_HRTIM_BurstModeCtl
Function Name
HAL_StatusTypeDef HAL_HRTIM_BurstModeCtl
(HRTIM_HandleTypeDef * hhrtim, uint32_t Enable)
Function Description
Enables or disables the HRTIM burst mode controller.
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)
DOCID026526 Rev 2
327/861
HAL HRTIM Generic Driver
Function Description
Parameters
UM1786
Triggers a software capture on the designed capture unit.



21.2.79
21.2.80
328/861
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
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
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver
Notes
21.2.81

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



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.
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

21.2.82
The 'software reset' bits in the HRTIM conrol register 2 are
automatically reset by hardware
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
DOCID026526 Rev 2
329/861
HAL HRTIM Generic Driver
21.2.83
21.2.84
21.2.85
UM1786
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
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
21.2.86
330/861

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
DOCID026526 Rev 2
UM1786
Function Name
HAL HRTIM Generic Driver
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



21.2.87
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
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



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
DOCID026526 Rev 2
331/861
HAL HRTIM Generic Driver
UM1786
HRTIM_OUTPUT_TE2: Timer E - Output 2
Return values
21.2.88

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



Return values
21.2.89
21.2.90
332/861
Output state

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_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).
DOCID026526 Rev 2
UM1786
21.2.91
21.2.92
21.2.93
HAL HRTIM Generic Driver
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
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.
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
DOCID026526 Rev 2
333/861
HAL HRTIM Generic Driver
21.2.94
21.2.95
21.2.96
21.2.97
21.2.98
334/861
UM1786
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
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
DOCID026526 Rev 2
UM1786
21.2.99
HAL HRTIM Generic Driver
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
21.2.100 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
21.2.101 HAL_HRTIM_SynchronizationEventCallback
Function Name
void HAL_HRTIM_SynchronizationEventCallback
(HRTIM_HandleTypeDef * hhrtim)
Function Description
Callback function invoked when a synchronization input event is
received.
Parameters

hhrtim: pointer to HAL HRTIM handle
Return values

None
21.2.102 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
DOCID026526 Rev 2
335/861
HAL HRTIM Generic Driver
UM1786
21.2.103 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
21.2.104 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
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
21.2.105 HAL_HRTIM_Compare2EventCallback
336/861
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
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver
Return values

None
21.2.106 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
21.2.107 HAL_HRTIM_Compare4EventCallback
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: 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
21.2.108 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
DOCID026526 Rev 2
337/861
HAL HRTIM Generic Driver
UM1786
HRTIM_TIMERINDEX_TIMER_E for timer E
Return values

None
21.2.109 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
21.2.110 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: 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
21.2.111 HAL_HRTIM_CounterResetCallback
338/861
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
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver
HRTIM_TIMERINDEX_TIMER_E for timer E
Return values

None
21.2.112 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
21.2.113 HAL_HRTIM_Output1ResetCallback
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
HRTIM_TIMERINDEX_TIMER_D for timer D
HRTIM_TIMERINDEX_TIMER_E for timer E
Return values

None
21.2.114 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
DOCID026526 Rev 2
339/861
HAL HRTIM Generic Driver
UM1786
21.2.115 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
21.2.116 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
HRTIM_TIMERINDEX_TIMER_E for timer E
Return values

None
21.2.117 HAL_HRTIM_ErrorCallback
21.3
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
HRTIM Firmware driver defines
The following section lists the various define and macros of the module.
21.3.1
HRTIM
HRTIM
340/861
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver
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
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
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
DOCID026526 Rev 2
341/861
HAL HRTIM Generic Driver
UM1786
4
342/861
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
HRTIM_ADCTRIGGEREVENT24_EVENT_10
ADC Trigger on external 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
DOCID026526 Rev 2
UM1786
HRTIM_ADCTRIGGEREVENT24_TIMERB_PERIOD
HAL HRTIM Generic Driver
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
HRTIM_ADCTRIGGERUPDATE_MASTER
Master timer
HRTIM_ADCTRIGGERUPDATE_TIMER_A
Timer A
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
DOCID026526 Rev 2
343/861
HAL HRTIM Generic Driver
HRTIM_BURSTDMA_PER
UM1786
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
344/861
HRTIM_BURSTMODECLOCKSOURCE_MASTER
Master timer counter reset/rollover is used as clock source for
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]),
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver
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
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
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
DOCID026526 Rev 2
345/861
HAL HRTIM Generic Driver
HRTIM_BURSTMODESTATUS_NORMAL
HRTIM_BURSTMODESTATUS_ONGOING
UM1786
Normal operation
Burst operation on-going
HRTIM Burst Mode Trigger
346/861
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
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)
DOCID026526 Rev 2
UM1786
HRTIM_BURSTMODETRIGGER_EVENT_ONCHIP
HAL HRTIM Generic Driver
On-chip Event
HRTIM Capture Unit
HRTIM_CAPTUREUNIT_1
Capture unit 1 identifier
HRTIM_CAPTUREUNIT_2
Capture unit 2 identifier
HRTIM Capture Unit Trigger
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
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
DOCID026526 Rev 2
347/861
HAL HRTIM Generic Driver
UM1786
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
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
348/861
tSTPW = tHRTIM x 16
DOCID026526 Rev 2
UM1786
HRTIM_CHOPPER_PULSEWIDTH_32
HAL HRTIM Generic Driver
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
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
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
DOCID026526 Rev 2
349/861
HAL HRTIM Generic Driver
HRTIM_COMPAREUNIT_2
Compare unit 2 identifier
UM1786
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
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
350/861
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver
Deadtime falling value and sign is
writeable
HRTIM_TIMDEADTIME_FALLINGLOCK_WRITE
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
HRTIM_TIMDEADTIME_RISINGLOCK_WRITE
Deadtime rising value and sign is
writeable
HRTIM_TIMDEADTIME_RISINGLOCK_READONLY
Deadtime rising value and sign is
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)
DOCID026526 Rev 2
351/861
HAL HRTIM Generic Driver
HRTIM_CALIBRATIONRATE_114
HRTIM_CALIBRATIONRATE_14
UM1786
Periodic DLL calibration: T = 16384 * tHRTIM (114
ms)
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:

None:
Description:
__HAL_HRTIM_ENABLE

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

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:
352/861
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver


__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:


__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:

None:
DOCID026526 Rev 2
353/861
HAL HRTIM Generic Driver
__HAL_HRTIM_DISABLE_IT
UM1786
__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:

Enables or disables the specified HRTIM
Timerx interrupts.
Parameters:



354/861
__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
DOCID026526 Rev 2
UM1786









HAL HRTIM Generic Driver
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:


__HANDLE__: specifies the HRTIM
Handle.
__INTERRUPT__: specifies the interrupt
source to check. 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 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:
DOCID026526 Rev 2
355/861
HAL HRTIM Generic Driver
UM1786

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:



356/861
__HANDLE__: specifies the HRTIM
Handle.
__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
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver














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
The: new state of __INTERRUPT__ (TRUE
or FALSE).
Description:

Clears the specified HRTIM common
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
DOCID026526 Rev 2
357/861
HAL HRTIM Generic Driver
UM1786

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:

__HAL_HRTIM_TIMER_CLEAR_IT
None:
Description:

Clears the specified HRTIM Timerx
pending flag.
Parameters:



358/861
__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
DOCID026526 Rev 2
UM1786










HAL HRTIM Generic Driver
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:


__HANDLE__: specifies the HRTIM
Handle.
__DMA__: specifies the DMA request to
enable or disable. This parameter can be
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
DOCID026526 Rev 2
359/861
HAL HRTIM Generic Driver
UM1786

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
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
360/861
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver
__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:


__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_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.
DOCID026526 Rev 2
361/861
HAL HRTIM Generic Driver
UM1786
Return value:

None:
Description:
__HAL_HRTIM_GetPeriod

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_SetClockPrescaler
timer: Period Register
Description:

Sets the HRTIM timer clock prescaler value
on runtime.
Parameters:



362/861
__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
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)
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver


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_GetClockPrescaler
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:




__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
__COMPARE__: specifies the Compare
new value.
Return value:

__HAL_HRTIM_GetCompare
None:
Description:

Gets the HRTIM timer Compare Register
DOCID026526 Rev 2
363/861
HAL HRTIM Generic Driver
UM1786
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
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
364/861
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
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver
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
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
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
DOCID026526 Rev 2
365/861
HAL HRTIM Generic Driver
HRTIM_FAULT_1
Fault channel 1 identifier
UM1786
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
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
366/861
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver
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
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
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
DOCID026526 Rev 2
The programmed Idle state is
367/861
HAL HRTIM Generic Driver
UM1786
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
HRTIM_OUTPUTPOLARITY_HIGH
Output is acitve HIGH
HRTIM_OUTPUTPOLARITY_LOW
Output is active LOW
HRTIM Output Reset Source
368/861
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
DOCID026526 Rev 2
UM1786
HRTIM_OUTPUTRESET_TIMCMP4
HAL HRTIM Generic Driver
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
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
DOCID026526 Rev 2
369/861
HAL HRTIM Generic Driver
HRTIM_OUTPUTRESET_EEV_8
UM1786
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
370/861
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
HRTIM_OUTPUTSET_MASTERCMP3
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
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver
External event 1 forces the output to its active
state
HRTIM_OUTPUTSET_EEV_1
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
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
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
DOCID026526 Rev 2
371/861
HAL HRTIM Generic Driver
UM1786
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 Private Define
HRTIM_FLTR_FLTxEN
HRTIM_TIMCR_TIMUPDATETRIGGER
HRTIM Private Macros
IS_HRTIM_TIMERINDEX
IS_HRTIM_TIMING_UNIT
IS_HRTIM_TIMERID
IS_HRTIM_COMPAREUNIT
IS_HRTIM_CAPTUREUNIT
IS_HRTIM_OUTPUT
IS_HRTIM_TIMER_OUTPUT
IS_HRTIM_EVENT
IS_HRTIM_FAULT
IS_HRTIM_PRESCALERRATIO
IS_HRTIM_MODE
IS_HRTIM_MODE_ONEPULSE
IS_HRTIM_HALFMODE
IS_HRTIM_SYNCSTART
IS_HRTIM_SYNCRESET
IS_HHRTIM_DACSYNC
IS_HRTIM_PRELOAD
IS_HRTIM_UPDATEGATING_MASTER
IS_HRTIM_UPDATEGATING_TIM
IS_HRTIM_TIMERBURSTMODE
IS_HRTIM_UPDATEONREPETITION
IS_HRTIM_TIMPUSHPULLMODE
IS_HRTIM_TIMFAULTENABLE
IS_HRTIM_TIMFAULTLOCK
372/861
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver
IS_HRTIM_TIMDEADTIMEINSERTION
IS_HRTIM_TIMDELAYEDPROTECTION
IS_HRTIM_TIMUPDATETRIGGER
IS_HRTIM_TIMRESETTRIGGER
IS_HRTIM_TIMUPDATEONRESET
IS_HRTIM_AUTODELAYEDMODE
IS_HRTIM_COMPAREUNIT_AUTODELAYEDMODE
IS_HRTIM_OUTPUTPOLARITY
IS_HRTIM_OUTPUTSET
IS_HRTIM_OUTPUTRESET
IS_HRTIM_OUTPUTIDLEMODE
IS_HRTIM_OUTPUTIDLELEVEL
IS_HRTIM_OUTPUTFAULTLEVEL
IS_HRTIM_OUTPUTCHOPPERMODE
IS_HRTIM_OUTPUTBURSTMODEENTRY
IS_HRTIM_TIMER_CAPTURETRIGGER
IS_HRTIM_TIMEVENTFILTER
IS_HRTIM_TIMEVENTLATCH
IS_HRTIM_TIMDEADTIME_PRESCALERRATIO
IS_HRTIM_TIMDEADTIME_RISINGSIGN
IS_HRTIM_TIMDEADTIME_RISINGLOCK
IS_HRTIM_TIMDEADTIME_RISINGSIGNLOCK
IS_HRTIM_TIMDEADTIME_FALLINGSIGN
IS_HRTIM_TIMDEADTIME_FALLINGLOCK
IS_HRTIM_TIMDEADTIME_FALLINGSIGNLOCK
IS_HRTIM_CHOPPER_PRESCALERRATIO
IS_HRTIM_CHOPPER_DUTYCYCLE
IS_HRTIM_CHOPPER_PULSEWIDTH
IS_HRTIM_SYNCINPUTSOURCE
IS_HRTIM_SYNCOUTPUTSOURCE
IS_HRTIM_SYNCOUTPUTPOLARITY
IS_HRTIM_EVENTSRC
IS_HRTIM_EVENTPOLARITY
IS_HRTIM_EVENTSENSITIVITY
IS_HRTIM_EVENTFASTMODE
IS_HRTIM_EVENTFILTER
DOCID026526 Rev 2
373/861
HAL HRTIM Generic Driver
IS_HRTIM_EVENTPRESCALER
UM1786
IS_HRTIM_FAULTSOURCE
IS_HRTIM_FAULTPOLARITY
IS_HRTIM_FAULTFILTER
IS_HRTIM_FAULTLOCK
IS_HRTIM_FAULTPRESCALER
IS_HRTIM_BURSTMODE
IS_HRTIM_BURSTMODECLOCKSOURCE
IS_HRTIM_HRTIM_BURSTMODEPRESCALER
IS_HRTIM_BURSTMODEPRELOAD
IS_HRTIM_BURSTMODETRIGGER
IS_HRTIM_ADCTRIGGERUPDATE
IS_HRTIM_CALIBRATIONRATE
IS_HRTIM_TIMER_BURSTDMA
IS_HRTIM_BURSTMODECTL
IS_HRTIM_TIMERUPDATE
IS_HRTIM_TIMERRESET
IS_HRTIM_IT
IS_HRTIM_MASTER_IT
IS_HRTIM_TIM_IT
IS_HRTIM_MASTER_DMA
IS_HRTIM_TIM_DMA
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
374/861
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver
HRTIM Software Timer Reset
HRTIM_TIMERRESET_MASTER
Resets the master timer counter
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
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
DOCID026526 Rev 2
375/861
HAL HRTIM Generic Driver
UM1786
clock cycles length for the
synchronization
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
376/861
HRTIM_TIMDELAYEDPROTECTION_DISABLED
No action
HRTIM_TIMDELAYEDPROTECTION_DELAYEDOUT1_EEV68
Output 1 delayed Idle
on external Event 6 or
8
HRTIM_TIMDELAYEDPROTECTION_DELAYEDOUT2_EEV68
Output 2 delayed Idle
on external Event 6 or
8
HRTIM_TIMDELAYEDPROTECTION_DELAYEDBOTH_EEV68
Output 1 and output 2
delayed Idle on
external Event 6 or 8
HRTIM_TIMDELAYEDPROTECTION_BALANCED_EEV68
Balanced Idle on
external Event 6 or 8
HRTIM_TIMDELAYEDPROTECTION_DELAYEDOUT1_DEEV79
Output 1 delayed Idle
on external Event 7 or
9
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver
HRTIM_TIMDELAYEDPROTECTION_DELAYEDOUT2_DEEV79 Output 2 delayed Idle
on external Event 7 or
9
HRTIM_TIMDELAYEDPROTECTION_DELAYEDBOTH_EEV79
Output 1 and output2
delayed Idle on
external Event 7 or 9
HRTIM_TIMDELAYEDPROTECTION_BALANCED_EEV79
Balanced Idle on
external Event 7 or 9
HRTIM Timer External Event Filter
HRTIM_TIMEVENTFILTER_NONE
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
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
DOCID026526 Rev 2
377/861
HAL HRTIM Generic Driver
UM1786
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
378/861
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
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver
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
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
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
DOCID026526 Rev 2
379/861
HAL HRTIM Generic Driver
UM1786
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
380/861
HRTIM_TIMUPDATETRIGGER_NONE
Register update is disabled
HRTIM_TIMUPDATETRIGGER_MASTER
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
DOCID026526 Rev 2
UM1786
HAL HRTIM Generic Driver
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
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
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
DOCID026526 Rev 2
381/861
HAL HRTIM Generic Driver
HRTIM_TIM_FLAG_CMP3
Timer compare 3 interrupt flag
UM1786
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
382/861
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
of HRTIM update enable input 1
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 2
UM1786
HAL I2C Generic Driver
22
HAL I2C Generic Driver
22.1
I2C Firmware driver registers structures
22.1.1
I2C_InitTypeDef
I2C_InitTypeDef is defined in the stm32f3xx_hal_i2c.h
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
I2C_HandleTypeDef is defined in the stm32f3xx_hal_i2c.h
DOCID026526 Rev 2
383/861
HAL I2C Generic Driver
UM1786
Data Fields










I2C_TypeDef * Instance
I2C_InitTypeDef Init
uint8_t * pBuffPtr
uint16_t XferSize
__IO uint16_t XferCount
DMA_HandleTypeDef * hdmatx
DMA_HandleTypeDef * hdmarx
HAL_LockTypeDef Lock
__IO HAL_I2C_StateTypeDef State
__IO HAL_I2C_ErrorTypeDef ErrorCode
Field Documentation










22.2
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.
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_ErrorTypeDef I2C_HandleTypeDef::ErrorCode
I2C Error code.
I2C Firmware driver API description
The following section lists the various functions of the I2C library.
22.2.1
How to use this driver
The I2C HAL driver can be used as follows:
1.
2.
384/861
Declare a I2C_HandleTypeDef handle structure, for example: I2C_HandleTypeDef
hi2c;
Initialize the I2C low level resources by implement the HAL_I2C_MspInit() API:

Enable the I2Cx interface clock

I2C pins configuration

Enable the clock for the I2C GPIOs
DOCID026526 Rev 2
UM1786
HAL I2C Generic Driver
3.
4.
5.
6.

Configure I2C pins as alternate function open-drain

NVIC configuration if you need to use interrupt process

Configure the I2Cx interrupt priority

Enable the NVIC I2C IRQ Channel

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 Adressing 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() API:

These APIs configures also the low level Hardware (GPIO, CLOCK,
CORTEX...etc) by calling the customed 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 modes of operations 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()
Interrupt mode IO operation



Transmit in master mode an amount of data in no-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 no-blocking mode using
HAL_I2C_Master_Receive_IT()
DOCID026526 Rev 2
385/861
HAL I2C Generic Driver






UM1786
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 no-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 no-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()
Interrupt mode IO MEM operation





Write an amount of data in no-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 no-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







386/861
Transmit in master mode an amount of data in no-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 no-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 no-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 no-blocking mode (DMA) using
HAL_I2C_Slave_Receive_DMA()
DOCID026526 Rev 2
UM1786
HAL I2C Generic Driver


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()
DMA mode IO MEM operation





Write an amount of data in no-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()
Read an amount of data in no-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_GET_FLAG: Checks whether the specified I2C flag is set or not.
__HAL_I2C_CLEAR_FLAG: Clears the specified I2C pending flag.
__HAL_I2C_ENABLE_IT: Enables the specified I2C interrupt.
__HAL_I2C_DISABLE_IT: Disables 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 de-initialiaze 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
DOCID026526 Rev 2
387/861
HAL I2C Generic Driver





22.2.3
UM1786

Nostretch mode
Call the function HAL_I2C_DeInit() to restore the default configuration of the selected
I2Cx periperal.
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.
1.
2.
3.
4.
5.



388/861
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 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 No_Blocking mode:

HAL_I2C_MemTxCpltCallback()

HAL_I2C_MemRxCpltCallback()

HAL_I2C_MasterTxCpltCallback()

HAL_I2C_MasterRxCpltCallback()

HAL_I2C_SlaveTxCpltCallback()

HAL_I2C_SlaveRxCpltCallback()

HAL_I2C_ErrorCallback()
HAL_I2C_Master_Transmit()
HAL_I2C_Master_Receive()
HAL_I2C_Slave_Transmit()
DOCID026526 Rev 2
UM1786
HAL I2C Generic Driver

























22.2.4
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()
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_EV_IRQHandler()
HAL_I2C_ER_IRQHandler()
HAL_I2C_MasterTxCpltCallback()
HAL_I2C_MasterRxCpltCallback()
HAL_I2C_SlaveTxCpltCallback()
HAL_I2C_SlaveRxCpltCallback()
HAL_I2C_MemTxCpltCallback()
HAL_I2C_MemRxCpltCallback()
HAL_I2C_ErrorCallback()
Peripheral State and Errors functions
This subsection permit to get in run-time the status of the peripheral and the data flow.


22.2.5
22.2.6
HAL_I2C_GetState()
HAL_I2C_GetError()
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 create 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
DeInitializes the I2C peripheral.
DOCID026526 Rev 2
389/861
HAL I2C Generic Driver
Parameters
Return values
22.2.7
22.2.8
22.2.9
390/861
hi2c: Pointer to a I2C_HandleTypeDef structure that contains
the configuration information for the specified I2C.

HAL status
HAL_I2C_MspInit
Function Name
void HAL_I2C_MspInit (I2C_HandleTypeDef * hi2c)
Function Description
I2C MSP Init.
Parameters

hi2c: Pointer to a I2C_HandleTypeDef structure that contains
the configuration information for the specified I2C.
Return values

None
HAL_I2C_MspDeInit
Function Name
void HAL_I2C_MspDeInit (I2C_HandleTypeDef * hi2c)
Function Description
I2C MSP DeInit.
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
22.2.10
UM1786





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

hi2c: Pointer to a I2C_HandleTypeDef structure that contains
the configuration information for the specified I2C.
DOCID026526 Rev 2
UM1786
HAL I2C Generic Driver
Return values
22.2.11

HAL status
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




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_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
22.2.13
DevAddress: Target device address
pData: Pointer to data buffer
Size: Amount of data to be sent
Timeout: Timeout duration
HAL_I2C_Slave_Transmit
Return values
22.2.12







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_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 no-blocking 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
DOCID026526 Rev 2
391/861
HAL I2C Generic Driver
Return values
22.2.14
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 no-blocking mode
with Interrupt.
Parameters

HAL status
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 no-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

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 no-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

HAL status
HAL_I2C_Master_Transmit_DMA
Function Name
392/861

Function Name
Return values
22.2.17



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_I2C_Slave_Transmit_IT
Return values
22.2.16
HAL status
HAL_I2C_Master_Receive_IT
Return values
22.2.15
UM1786

HAL_StatusTypeDef HAL_I2C_Master_Transmit_DMA
DOCID026526 Rev 2
UM1786
HAL I2C Generic Driver
(I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint8_t *
pData, uint16_t Size)
Function Description
Transmit in master mode an amount of data in no-blocking mode
with DMA.
Parameters

Return values
22.2.18
HAL status
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 no-blocking mode
with DMA.
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

HAL status
HAL_I2C_Slave_Transmit_DMA
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 no-blocking mode
with DMA.
Parameters

Return values
22.2.20

HAL_I2C_Master_Receive_DMA
Return values
22.2.19



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


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_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 no-blocking mode
with DMA.
Parameters

hi2c: Pointer to a I2C_HandleTypeDef structure that contains
DOCID026526 Rev 2
393/861
HAL I2C Generic Driver
Return values
22.2.21
HAL status
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







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
Timeout: Timeout duration

HAL status
HAL_I2C_Mem_Write_IT
Function Name
394/861

Function Name
Return values
22.2.23


HAL_I2C_Mem_Write
Return values
22.2.22
UM1786
the configuration information for the specified I2C.
pData: Pointer to data buffer
Size: Amount of data to be sent
HAL_StatusTypeDef HAL_I2C_Mem_Write_IT
(I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint16_t
MemAddress, uint16_t MemAddSize, uint8_t * pData, uint16_t
DOCID026526 Rev 2
UM1786
HAL I2C Generic Driver
Size)
Function Description
Write an amount of data in no-blocking mode with Interrupt to a
specific memory address.
Parameters

Return values
22.2.24

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 no-blocking mode with Interrupt from a
specific memory address.
Parameters

Return values
22.2.25





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





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_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 no-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
DOCID026526 Rev 2
395/861
HAL I2C Generic Driver
22.2.26
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 no-blocking mode with DMA from a
specific memory address.
Parameters

Return values
22.2.27
22.2.28
22.2.29





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

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_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
396/861
UM1786
void HAL_I2C_ER_IRQHandler (I2C_HandleTypeDef * hi2c)
DOCID026526 Rev 2
UM1786
22.2.30
22.2.31
22.2.32
22.2.33
Function Description
HAL I2C Generic Driver
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
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
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
DOCID026526 Rev 2
397/861
HAL I2C Generic Driver
22.2.34
22.2.35
22.2.36
22.2.37
22.2.38
398/861
UM1786
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
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_GetState
Function Name
HAL_I2C_StateTypeDef HAL_I2C_GetState
(I2C_HandleTypeDef * hi2c)
Function Description
Returns the I2C state.
Parameters

hi2c: I2C handle
Return values

HAL state
HAL_I2C_GetError
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
DOCID026526 Rev 2
UM1786
HAL I2C Generic Driver
the configuration information for the specified I2C.
Return values
22.3

I2C Error Code
I2C Firmware driver defines
The following section lists the various define and macros of the module.
22.3.1
I2C
I2C
I2C addressing mode
I2C_ADDRESSINGMODE_7BIT
I2C_ADDRESSINGMODE_10BIT
IS_I2C_ADDRESSING_MODE
I2C dual addressing mode
I2C_DUALADDRESS_DISABLED
I2C_DUALADDRESS_ENABLED
IS_I2C_DUAL_ADDRESS
I2C Exported Macros
__HAL_I2C_RESET_HANDLE_STATE
Description:

Reset I2C handle state.
Parameters:

__HANDLE__: I2C handle.
Return value:

__HAL_I2C_ENABLE_IT
None:
Description:

Enable the specified I2C interrupts.
Parameters:


__HANDLE__: specifies the I2C Handle.
This parameter can be I2Cx where x: 1, 2,
or 3 to select the I2C peripheral.
__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

I2C_IT_RXI: RX interrupt enable
DOCID026526 Rev 2
399/861
HAL I2C Generic Driver
UM1786

I2C_IT_TXI: TX interrupt enable
Return value:

None:
Description:
__HAL_I2C_DISABLE_IT

Disable the specified I2C interrupts.
Parameters:


__HANDLE__: specifies the I2C Handle.
This parameter can be I2Cx where x: 1, 2,
or 3 to select the I2C peripheral.
__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 if the specified I2C interrupt source is
enabled or disabled.
Parameters:


__HANDLE__: specifies the I2C Handle.
This parameter can be I2Cx where x: 1, 2,
or 3 to select the I2C peripheral.
__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:
400/861
DOCID026526 Rev 2
UM1786
HAL I2C Generic Driver

__HAL_I2C_GET_FLAG
The: new state of __INTERRUPT__ (TRUE
or FALSE).
Description:

Check whether the specified I2C flag is set
or not.
Parameters:


__HANDLE__: specifies the I2C Handle.
This parameter can be I2Cx where x: 1, 2,
or 3 to select the I2C peripheral.
__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__ (TRUE or
FALSE).
Description:

Clears the I2C pending flags which are
cleared by writing 1 in a specific bit.
Parameters:

__HANDLE__: specifies the I2C Handle.
This parameter can be I2Cx where x: 1, 2,
or 3 to select the I2C peripheral.
DOCID026526 Rev 2
401/861
HAL I2C Generic Driver
UM1786

__FLAG__: specifies the flag to clear. This
parameter can be any combination of the
following values:

I2C_FLAG_ADDR: Address matched
(slave mode)

I2C_FLAG_AF: Acknowledge failure
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:

None:
__HAL_I2C_RESET_CR2
__HAL_I2C_MEM_ADD_MSB
__HAL_I2C_MEM_ADD_LSB
__HAL_I2C_GENERATE_START
IS_I2C_OWN_ADDRESS1
IS_I2C_OWN_ADDRESS2
I2C Flag definition
I2C_FLAG_TXE
I2C_FLAG_TXIS
I2C_FLAG_RXNE
402/861
DOCID026526 Rev 2
UM1786
HAL I2C Generic Driver
I2C_FLAG_ADDR
I2C_FLAG_AF
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_DISABLED
I2C_GENERALCALL_ENABLED
IS_I2C_GENERAL_CALL
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
IS_I2C_MEMADD_SIZE
I2C nostretch mode
I2C_NOSTRETCH_DISABLED
I2C_NOSTRETCH_ENABLED
IS_I2C_NO_STRETCH
I2C own address2 masks
I2C_OA2_NOMASK
I2C_OA2_MASK01
DOCID026526 Rev 2
403/861
HAL I2C Generic Driver
I2C_OA2_MASK02
UM1786
I2C_OA2_MASK03
I2C_OA2_MASK04
I2C_OA2_MASK05
I2C_OA2_MASK06
I2C_OA2_MASK07
IS_I2C_OWN_ADDRESS2_MASK
I2C Private Define
TIMING_CLEAR_MASK
I2C_TIMEOUT_ADDR
I2C_TIMEOUT_BUSY
I2C_TIMEOUT_DIR
I2C_TIMEOUT_RXNE
I2C_TIMEOUT_STOPF
I2C_TIMEOUT_TC
I2C_TIMEOUT_TCR
I2C_TIMEOUT_TXIS
I2C_TIMEOUT_FLAG
I2C ReloadEndMode definition
I2C_RELOAD_MODE
I2C_AUTOEND_MODE
I2C_SOFTEND_MODE
IS_TRANSFER_MODE
I2C StartStopMode definition
I2C_NO_STARTSTOP
I2C_GENERATE_STOP
I2C_GENERATE_START_READ
I2C_GENERATE_START_WRITE
IS_TRANSFER_REQUEST
404/861
DOCID026526 Rev 2
UM1786
HAL I2C Extension Driver
23
HAL I2C Extension Driver
23.1
I2CEx Firmware driver API description
The following section lists the various functions of the I2CEx library.
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.
23.1.3
Configure I2C Analog noise filter using the function
HAL_I2CEx_AnalogFilter_Config()
Configure I2C Digital noise filter using the function HAL_I2CEx_DigitalFilter_Config()
Configure the enabling or disabling of I2C Wake Up Mode using these functions :

HAL_I2CEx_EnableWakeUp()

HAL_I2CEx_DisableWakeUp()
Extended features functions
This section provides functions allowing to:






23.1.4
Configure Noise Filters
Configure Wake Up Feature
HAL_I2CEx_AnalogFilter_Config()
HAL_I2CEx_DigitalFilter_Config()
HAL_I2CEx_EnableWakeUp()
HAL_I2CEx_DisableWakeUp()
HAL_I2CEx_AnalogFilter_Config
Function Name
HAL_StatusTypeDef HAL_I2CEx_AnalogFilter_Config
(I2C_HandleTypeDef * hi2c, uint32_t AnalogFilter)
Function Description
Configure I2C Analog noise filter.
Parameters

Return values

hi2c: pointer to a I2C_HandleTypeDef structure that contains
the configuration information for the specified I2Cx peripheral.
AnalogFilter: new state of the Analog filter.

HAL status
DOCID026526 Rev 2
405/861
HAL I2C Extension Driver
23.1.5
HAL_I2CEx_DigitalFilter_Config
Function Name
HAL_StatusTypeDef HAL_I2CEx_DigitalFilter_Config
(I2C_HandleTypeDef * hi2c, uint32_t DigitalFilter)
Function Description
Configure I2C Digital noise filter.
Parameters

Return values
23.1.6
23.1.7
23.2
UM1786

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
I2CEx Firmware driver defines
The following section lists the various define and macros of the module.
23.2.1
I2CEx
I2CEx
I2C Extended Analog Filter
I2C_ANALOGFILTER_ENABLED
I2C_ANALOGFILTER_DISABLED
IS_I2C_ANALOG_FILTER
I2C Extended Digital Filter
IS_I2C_DIGITAL_FILTER
406/861
DOCID026526 Rev 2
UM1786
HAL I2S Generic Driver
24
HAL I2S Generic Driver
24.1
I2S Firmware driver registers structures
24.1.1
I2S_InitTypeDef
I2S_InitTypeDef is defined in the stm32f3xx_hal_i2s.h
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
I2S_HandleTypeDef is defined in the stm32f3xx_hal_i2s.h
Data Fields
DOCID026526 Rev 2
407/861
HAL I2S Generic Driver













UM1786
SPI_TypeDef * Instance
I2S_InitTypeDef Init
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 HAL_I2S_ErrorTypeDef ErrorCode
Field Documentation













24.2
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 HAL_I2S_ErrorTypeDef I2S_HandleTypeDef::ErrorCode
I2S Error code
I2S Firmware driver API description
The following section lists the various functions of the I2S library.
24.2.1
408/861
How to use this driver
DOCID026526 Rev 2
UM1786
HAL I2S Generic Driver
The I2S HAL driver can be used as follows:
1.
2.
3.
4.
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:

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
DOCID026526 Rev 2
409/861
HAL I2S Generic Driver
UM1786
DMA mode IO operation










Send an amount of data in non blocking mode (DMA) using
HAL_I2S_Transmit_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
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:


410/861
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
DOCID026526 Rev 2
UM1786
HAL I2S Generic Driver





24.2.3
Call the function HAL_I2S_DeInit() to restore the default configuration of the selected
I2Sx periperal.
HAL_I2S_Init()
HAL_I2S_DeInit()
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.














24.2.4
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()
HAL_I2S_Transmit()
HAL_I2S_Receive()
HAL_I2S_Transmit_IT()
HAL_I2S_Receive_IT()
HAL_I2S_Transmit_DMA()
HAL_I2S_Receive_DMA()
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.

HAL_I2S_GetState()
DOCID026526 Rev 2
411/861
HAL I2S Generic Driver




24.2.5
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
24.2.6
24.2.7
24.2.8
412/861
UM1786
HAL_I2S_GetError()
HAL_I2S_DMAPause()
HAL_I2S_DMAResume()
HAL_I2S_DMAStop()

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
DOCID026526 Rev 2
UM1786
24.2.9
HAL I2S Generic Driver
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.
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).

24.2.10
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.


24.2.11
HAL_I2S_Transmit_IT
DOCID026526 Rev 2
413/861
HAL I2S Generic Driver
Function Name
UM1786
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



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:
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).

24.2.12
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.


24.2.13
414/861
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.
DOCID026526 Rev 2
UM1786
HAL I2S Generic Driver
Parameters



hi2s: pointer to a I2S_HandleTypeDef structure that contains
the configuration information for I2S module
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).

24.2.14
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).

24.2.15
24.2.16
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

HAL status
HAL_I2S_TxHalfCpltCallback
DOCID026526 Rev 2
415/861
HAL I2S Generic Driver
Function Name
24.2.17
24.2.18
24.2.19
24.2.20
416/861
UM1786
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
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
DOCID026526 Rev 2
UM1786
24.2.21
24.2.22
24.2.23
24.2.24
24.2.25
HAL I2S Generic Driver
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_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
HAL_I2S_ErrorTypeDef 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
HAL_I2S_DMAPause
Function Name
HAL_StatusTypeDef HAL_I2S_DMAPause
(I2S_HandleTypeDef * hi2s)
Function Description
Pauses the audio stream playing from the Media.
DOCID026526 Rev 2
417/861
HAL I2S Generic Driver
Parameters
Return values
24.2.26
24.2.27
24.3
UM1786

hi2s: : I2S handle

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
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
I2S Firmware driver defines
The following section lists the various define and macros of the module.
24.3.1
I2S
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
418/861
DOCID026526 Rev 2
UM1786
HAL I2S Generic Driver
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 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.
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
DOCID026526 Rev 2
419/861
HAL I2S Generic Driver
UM1786

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:

The: new state of __IT__ (TRUE or FALSE).
Description:
__HAL_I2S_GET_FLAG

Checks whether the specified I2S 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_I2S_CLEAR_OVRFLAG
The: new state of __FLAG__ (TRUE or
FALSE).
Description:

Clears the I2S OVR pending flag.
Parameters:
420/861
DOCID026526 Rev 2
UM1786
HAL I2S Generic Driver

__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
I2S_MODE_SLAVE_TX
I2S_MODE_SLAVE_RX
I2S_MODE_MASTER_TX
I2S_MODE_MASTER_RX
IS_I2S_MODE
I2S Standard
DOCID026526 Rev 2
421/861
HAL I2S Generic Driver
I2S_STANDARD_PHILIPS
UM1786
I2S_STANDARD_MSB
I2S_STANDARD_LSB
I2S_STANDARD_PCM_SHORT
I2S_STANDARD_PCM_LONG
IS_I2S_STANDARD
422/861
DOCID026526 Rev 2
UM1786
HAL I2S Extension Driver
25
HAL I2S Extension Driver
25.1
I2SEx Firmware driver API description
The following section lists the various functions of the I2SEx library.
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 (refer to
the I2S full duplex block diagram available in the device reference manual).
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()
DOCID026526 Rev 2
423/861
HAL I2S Extension Driver








25.1.3
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
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.



25.1.4
424/861
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()
HAL_I2SEx_TransmitReceive()
HAL_I2SEx_TransmitReceive_IT()
HAL_I2SEx_TransmitReceive_DMA()
HAL_I2SEx_TransmitReceive
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:
DOCID026526 Rev 2
UM1786
HAL I2S Extension Driver

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).

25.1.5
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).

25.1.6
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
DOCID026526 Rev 2
425/861
HAL I2S Extension Driver
Notes
UM1786


25.2
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).
I2SEx Firmware driver defines
The following section lists the various define and macros of the module.
25.2.1
I2SEx
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:

426/861
Checks if the specified I2SExt interrupt source
DOCID026526 Rev 2
UM1786
HAL I2S Extension Driver
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_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:
DOCID026526 Rev 2
427/861
HAL I2S Extension Driver
UM1786

__HANDLE__: specifies the I2S Handle.
Return value:

428/861
None:
DOCID026526 Rev 2
UM1786
HAL IRDA Generic Driver
26
HAL IRDA Generic Driver
26.1
IRDA Firmware driver registers structures
26.1.1
IRDA_InitTypeDef
IRDA_InitTypeDef is defined in the stm32f3xx_hal_irda.h
Data Fields






uint32_t BaudRate
uint32_t WordLength
uint16_t Parity
uint16_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
uint16_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).
uint16_t IRDA_InitTypeDef::Mode
Specifies whether the Receive or Transmit mode is enabled or disabled. This
parameter can be a value of IRDA_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
IRDA_HandleTypeDef is defined in the stm32f3xx_hal_irda.h
Data Fields

USART_TypeDef * Instance
DOCID026526 Rev 2
429/861
HAL IRDA Generic Driver













UM1786
IRDA_InitTypeDef Init
uint8_t * pTxBuffPtr
uint16_t TxXferSize
uint16_t TxXferCount
uint8_t * pRxBuffPtr
uint16_t RxXferSize
uint16_t RxXferCount
uint16_t Mask
DMA_HandleTypeDef * hdmatx
DMA_HandleTypeDef * hdmarx
HAL_LockTypeDef Lock
HAL_IRDA_StateTypeDef State
HAL_IRDA_ErrorTypeDef ErrorCode
Field Documentation














26.2
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
HAL_IRDA_StateTypeDef IRDA_HandleTypeDef::State
IRDA communication state
HAL_IRDA_ErrorTypeDef IRDA_HandleTypeDef::ErrorCode
IRDA Error code
IRDA Firmware driver API description
The following section lists the various functions of the IRDA library.
26.2.1
430/861
How to use this driver
DOCID026526 Rev 2
UM1786
HAL IRDA Generic Driver
The IRDA HAL driver can be used as follows:
1.
2.
3.
4.
5.
Declare a IRDA_HandleTypeDef handle structure.
Initialize the IRDA low level resources by implementing the HAL_IRDA_MspInit() API
in setting the associated USART or UART in IRDA mode:
a.
Enable the USARTx/UARTx interface clock.
b.
USARTx/UARTx pins configuration:

Enable the clock for the USARTx/UARTx GPIOs.

Configure these USARTx/UARTx pins as alternate function pull-up.
c.
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 IRDA IRQ handle.
d.
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 initilalized 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 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 customed HAL_IRDA_MspInit() API. 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.
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
DMA mode IO operation
DOCID026526 Rev 2
431/861
HAL IRDA Generic Driver





UM1786
Send an amount of data in non blocking mode (DMA) using
HAL_IRDA_Transmit_DMA()
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 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
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: If the parity is enabled, then the MSB bit of the data written in the data
register is transmitted but is changed by the parity bit. Depending on the frame
length defined by the M bit (8-bits or 9-bits) or by the M1 and M0 bits (7-bit, 8-bit
or 9-bit), the possible IRDA frame formats are as listed in Table 22: "IRDA frame
formats" .

Power mode

Prescaler setting

Receiver/transmitter modes
Table 22: IRDA frame formats
432/861
M bit
PCE bit
IRDA frame
0
0
| SB | 8-bit data | STB |
0
1
| SB | 7-bit data | PB | STB |
1
0
| SB | 9-bit data | STB |
1
1
| SB | 8-bit data | PB | STB |
M1, M0 bits
PCE bit
IRDA frame
DOCID026526 Rev 2
UM1786
HAL IRDA Generic Driver
M bit
PCE bit
IRDA frame
10
0
| SB | 7-bit data | STB |
10
1
SB | 6-bit data | PB | STB |
The HAL_IRDA_Init() function follows IRDA configuration procedures (details for the
procedures are available in reference manual).




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.

Non 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 respectivelly 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 API's are :

HAL_IRDA_Transmit()

HAL_IRDA_Receive()
Non-Blocking mode API's with Interrupt are :

HAL_IRDA_Transmit_IT()

HAL_IRDA_Receive_IT()

HAL_IRDA_IRQHandler()

IRDA_Transmit_IT()

IRDA_Receive_IT()
Non-Blocking mode functions with DMA are :

HAL_IRDA_Transmit_DMA()

HAL_IRDA_Receive_DMA()
A set of Transfer Complete Callbacks are provided in No_Blocking mode:

HAL_IRDA_TxCpltCallback()

HAL_IRDA_RxCpltCallback()

HAL_IRDA_ErrorCallback()
HAL_IRDA_Transmit()
HAL_IRDA_Receive()
HAL_IRDA_Transmit_IT()
HAL_IRDA_Receive_IT()
HAL_IRDA_Transmit_DMA()
DOCID026526 Rev 2
433/861
HAL IRDA Generic Driver





26.2.4
UM1786
HAL_IRDA_Receive_DMA()
HAL_IRDA_IRQHandler()
HAL_IRDA_TxCpltCallback()
HAL_IRDA_RxCpltCallback()
HAL_IRDA_ErrorCallback()
Peripheral State and Error functions
This subsection provides a set of functions allowing to control the IRDA.




26.2.5
26.2.6
26.2.7
26.2.8
HAL_IRDA_GetState() API can be helpful to check in run-time the state of the IRDA
peripheral.
IRDA_SetConfig() API is used to configure the IRDA communications parameters.
HAL_IRDA_GetState()
HAL_IRDA_GetError()
HAL_IRDA_Init
Function Name
HAL_StatusTypeDef HAL_IRDA_Init (IRDA_HandleTypeDef *
hirda)
Function Description
Initializes the IRDA mode according to the specified parameters in
the IRDA_InitTypeDef and creates the associated handle .
Parameters

hirda: IRDA handle
Return values

HAL status
HAL_IRDA_DeInit
Function Name
HAL_StatusTypeDef HAL_IRDA_DeInit (IRDA_HandleTypeDef
* hirda)
Function Description
DeInitializes the IRDA peripheral.
Parameters

hirda: IRDA handle
Return values

HAL status
HAL_IRDA_MspInit
Function Name
void HAL_IRDA_MspInit (IRDA_HandleTypeDef * hirda)
Function Description
IRDA MSP Init.
Parameters

hirda: IRDA handle
Return values

None
HAL_IRDA_MspDeInit
Function Name
434/861
void HAL_IRDA_MspDeInit (IRDA_HandleTypeDef * hirda)
DOCID026526 Rev 2
UM1786
26.2.9
26.2.10
26.2.11
26.2.12
HAL IRDA Generic Driver
Function Description
IRDA MSP DeInit.
Parameters

hirda: IRDA handle
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




hirda: IRDA handle
pData: pointer to data buffer
Size: amount of data to be sent
Timeout: Duration of the timeout
Return values

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




hirda: IRDA handle
pData: pointer to data buffer
Size: amount of data to be received
Timeout: Duration of the timeout
Return values

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: IRDA handle
pData: pointer to data buffer
Size: amount of data to be sent
Return values

HAL status
HAL_IRDA_Receive_IT
Function Name
HAL_StatusTypeDef HAL_IRDA_Receive_IT
(IRDA_HandleTypeDef * hirda, uint8_t * pData, uint16_t Size)
DOCID026526 Rev 2
435/861
HAL IRDA Generic Driver
Function Description
26.2.13
26.2.14
26.2.15
26.2.16
436/861
UM1786
Receive an amount of data in interrupt mode.
Parameters



hirda: IRDA handle
pData: pointer to data buffer
Size: amount of data to be received
Return values

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



hirda: IRDA handle
pData: pointer to data buffer
Size: amount of data to be sent
Return values

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: IRDA handle
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
contain the parity bit (MSB position)
HAL_IRDA_IRQHandler
Function Name
void HAL_IRDA_IRQHandler (IRDA_HandleTypeDef * hirda)
Function Description
This function handles IRDA interrupt request.
Parameters

hirda: IRDA handle
Return values

None
HAL_IRDA_TxCpltCallback
Function Name
void HAL_IRDA_TxCpltCallback (IRDA_HandleTypeDef *
hirda)
Function Description
Tx Transfer completed callback.
DOCID026526 Rev 2
UM1786
26.2.17
26.2.18
26.2.19
26.2.20
26.3
HAL IRDA Generic Driver
Parameters

hirda: irda handle
Return values

None
HAL_IRDA_RxCpltCallback
Function Name
void HAL_IRDA_RxCpltCallback (IRDA_HandleTypeDef *
hirda)
Function Description
Rx Transfer completed callback.
Parameters

hirda: irda handle
Return values

None
HAL_IRDA_ErrorCallback
Function Name
void HAL_IRDA_ErrorCallback (IRDA_HandleTypeDef * hirda)
Function Description
IRDA error callback.
Parameters

hirda: IRDA handle
Return values

None
HAL_IRDA_GetState
Function Name
HAL_IRDA_StateTypeDef HAL_IRDA_GetState
(IRDA_HandleTypeDef * hirda)
Function Description
return the IRDA state
Parameters

hirda: irda handle
Return values

HAL state
HAL_IRDA_GetError
Function Name
uint32_t HAL_IRDA_GetError (IRDA_HandleTypeDef * hirda)
Function Description
Return the IRDA error code.
Parameters

hirda: pointer to a IRDA_HandleTypeDef structure that
contains the configuration information for the specified IRDA.
Return values

IRDA Error Code
IRDA Firmware driver defines
The following section lists the various define and macros of the module.
26.3.1
IRDA
IRDA
DOCID026526 Rev 2
437/861
HAL IRDA Generic Driver
IRDA DMA Rx
UM1786
IRDA_DMA_RX_DISABLE
IRDA_DMA_RX_ENABLE
IS_IRDA_DMA_RX
IRDA DMA Tx
IRDA_DMA_TX_DISABLE
IRDA_DMA_TX_ENABLE
IS_IRDA_DMA_TX
IRDA Exported Macros
__HAL_IRDA_RESET_HANDLE_STA
TE
Description:

Reset IRDA handle state.
Parameters:

__HANDLE__: IRDA handle.
Return value:

__HAL_IRDA_GET_FLAG
None:
Description:

Checks whether the specified IRDA flag is
set or not.
Parameters:


438/861
__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
ackowledge flag

IRDA_FLAG_TEACK: Transmit enable
ackowledge 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
DOCID026526 Rev 2
UM1786
HAL IRDA Generic Driver


IRDA_FLAG_FE: Framing Error flag
IRDA_FLAG_PE: Parity Error flag
Return value:

__HAL_IRDA_ENABLE_IT
The: new state of __FLAG__ (TRUE or
FALSE).
Description:

Enables 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:

Disables 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
DOCID026526 Rev 2
439/861
HAL IRDA Generic Driver
UM1786
error, noise error, overrun error)
Return value:

None:
Description:
__HAL_IRDA_GET_IT

Checks 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:

Checks whether the specified IRDA interrupt
source is enabled.
Parameters:


440/861
__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
DOCID026526 Rev 2
UM1786
HAL IRDA Generic Driver



IRDA_IT_NE: Noise Error interrupt
IRDA_IT_FE: Framing Error interrupt
IRDA_IT_PE: Parity Error interrupt
Return value:

__HAL_IRDA_CLEAR_IT
The: new state of __IT__ (TRUE or FALSE).
Description:

Clears 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: AutoBaud Rate Request

IRDA_RXDATA_FLUSH_REQUEST:
Receive Data flush Request

IRDA_TXDATA_FLUSH_REQUEST:
Transmit data flush Request
Return value:

None:
DOCID026526 Rev 2
441/861
HAL IRDA Generic Driver
__HAL_IRDA_ENABLE
UM1786
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:

IS_IRDA_BAUDRATE
None:
Description:

Ensure that IRDA Baud rate is less or equal
to maximum value.
Parameters:

__BAUDRATE__: specifies the IRDA
Baudrate set by the user.
Return value:

IS_IRDA_PRESCALER
True: or False
Description:

Ensure that IRDA prescaler value is strictly
larger than 0.
Parameters:

__PRESCALER__: specifies the IRDA
prescaler value set by the user.
Return value:

True: or False
IRDA Flags
IRDA_FLAG_REACK
IRDA_FLAG_TEACK
IRDA_FLAG_BUSY
442/861
DOCID026526 Rev 2
UM1786
HAL IRDA Generic Driver
IRDA_FLAG_ABRF
IRDA_FLAG_ABRE
IRDA_FLAG_TXE
IRDA_FLAG_TC
IRDA_FLAG_RXNE
IRDA_FLAG_ORE
IRDA_FLAG_NE
IRDA_FLAG_FE
IRDA_FLAG_PE
IRDA interruptions flag mask
IRDA_IT_MASK
IRDA Interrupts Definition
IRDA_IT_PE
IRDA_IT_TXE
IRDA_IT_TC
IRDA_IT_RXNE
IRDA_IT_IDLE
IRDA_IT_ERR
IRDA_IT_ORE
IRDA_IT_NE
IRDA_IT_FE
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_POWERMODE_LOWPOWER
IS_IRDA_POWERMODE
IRDA Mode
IRDA_MODE_DISABLE
IRDA_MODE_ENABLE
IS_IRDA_MODE
IRDA One Bit Sampling
DOCID026526 Rev 2
443/861
HAL IRDA Generic Driver
IRDA_ONE_BIT_SAMPLE_DISABLED
IRDA_ONE_BIT_SAMPLE_ENABLED
IS_IRDA_ONEBIT_SAMPLE
IRDA Parity
IRDA_PARITY_NONE
IRDA_PARITY_EVEN
IRDA_PARITY_ODD
IS_IRDA_PARITY
IRDA Private Constants
TEACK_REACK_TIMEOUT
IRDA_TXDMA_TIMEOUTVALUE
IRDA_TIMEOUT_VALUE
IRDA_CR1_FIELDS
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
IS_IRDA_REQUEST_PARAMETER
IRDA State
IRDA_STATE_DISABLE
IRDA_STATE_ENABLE
IS_IRDA_STATE
IRDA Transfer Mode
IRDA_MODE_RX
IRDA_MODE_TX
IRDA_MODE_TX_RX
IS_IRDA_TX_RX_MODE
444/861
DOCID026526 Rev 2
UM1786
UM1786
HAL IRDA Extension Driver
27
HAL IRDA Extension Driver
27.1
IRDAEx Firmware driver defines
The following section lists the various define and macros of the module.
27.1.1
IRDAEx
IRDAEx
IRDA Extended Exported Macros
__HAL_IRDA_GETCLOCKSOURCE
Description:

Reports the IRDA clock source.
Parameters:


__HANDLE__: specifies the IRDA Handle
__CLOCKSOURCE__: output variable
Return value:

__HAL_IRDA_MASK_COMPUTATION
IRDA: clocking source, written in
__CLOCKSOURCE__.
Description:

Computes the mask to apply to retrieve the
received data according to the word length
and to the parity bits activation.
Parameters:

__HANDLE__: specifies the IRDA Handle
Return value:

none:
IRDA Extended Word Length
IRDA_WORDLENGTH_7B
IRDA_WORDLENGTH_8B
IRDA_WORDLENGTH_9B
IS_IRDA_WORD_LENGTH
DOCID026526 Rev 2
445/861
HAL IWDG Generic Driver
UM1786
28
HAL IWDG Generic Driver
28.1
IWDG Firmware driver registers structures
28.1.1
IWDG_InitTypeDef
IWDG_InitTypeDef is defined in the stm32f3xx_hal_iwdg.h
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
IWDG_HandleTypeDef is defined in the stm32f3xx_hal_iwdg.h
Data Fields




IWDG_TypeDef * Instance
IWDG_InitTypeDef Init
HAL_LockTypeDef Lock
__IO HAL_IWDG_StateTypeDef State
Field Documentation




446/861
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 2
UM1786
28.2
HAL IWDG Generic Driver
IWDG Firmware driver API description
The following section lists the various functions of the IWDG library.
28.2.1
IWDG specific features







28.2.2
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. STM32F30x devices provide the capability to
measure the LSI frequency (LSI clock connected internally to TIM16 CH1 input
capture). The measured value can be used to have an IWDG timeout with an
acceptable accuracy. For more information, please refer to the STM32F3xx Reference
manual.
How to use this driver
1.
2.
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.
DOCID026526 Rev 2
447/861
HAL IWDG Generic Driver
UM1786
IWDG HAL driver macros list
Below the list of most used macros in IWDG HAL driver.





28.2.3
__HAL_IWDG_START: Enable the IWDG peripheral
__HAL_IWDG_RELOAD_COUNTER: Reloads IWDG counter with value defined in
the reload register
__HAL_IWDG_ENABLE_WRITE_ACCESS : Enable write access to IWDG_PR and
IWDG_RLR registers
__HAL_IWDG_DISABLE_WRITE_ACCESS : Disable write access to IWDG_PR and
IWDG_RLR registers
__HAL_IWDG_GET_FLAG: Get the selected IWDG's flag status
Initialization functions
This section provides functions allowing to:






28.2.4
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 IWDG MSP
HAL_IWDG_Init()
HAL_IWDG_MspInit()
IO operation functions
This section provides functions allowing to:




28.2.5
Start the IWDG.
Refresh the IWDG.
HAL_IWDG_Start()
HAL_IWDG_Refresh()
Peripheral State functions
This subsection permits to get in run-time the status of the peripheral and the data flow.

28.2.6
448/861
HAL_IWDG_GetState()
HAL_IWDG_Init
Function Name
HAL_StatusTypeDef HAL_IWDG_Init (IWDG_HandleTypeDef *
hiwdg)
Function Description
Initializes the IWDG according to the specified parameters in the
IWDG_InitTypeDef and creates 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
DOCID026526 Rev 2
UM1786
28.2.7
28.2.8
28.2.9
28.2.10
28.3
HAL IWDG Generic Driver
HAL_IWDG_MspInit
Function Name
void HAL_IWDG_MspInit (IWDG_HandleTypeDef * hiwdg)
Function Description
Initializes the IWDG MSP.
Parameters

hiwdg: pointer to a IWDG_HandleTypeDef structure that
contains the configuration information for the specified IWDG
module.
Return values

None
HAL_IWDG_Start
Function Name
HAL_StatusTypeDef HAL_IWDG_Start (IWDG_HandleTypeDef
* hiwdg)
Function Description
Starts 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
Refreshes 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
Returns the IWDG state.
Parameters

hiwdg: pointer to a IWDG_HandleTypeDef structure that
contains the configuration information for the specified IWDG
module.
Return values

HAL state
IWDG Firmware driver defines
The following section lists the various define and macros of the module.
DOCID026526 Rev 2
449/861
HAL IWDG Generic Driver
28.3.1
UM1786
IWDG
IWDG
IWDG CounterWindow Value
IS_IWDG_WINDOW
IWDG Exported Macros
__HAL_IWDG_RESET_HANDLE_STATE
Description:

Reset IWDG handle state.
Parameters:

__HANDLE__: IWDG handle.
Return value:

None:
Description:
__HAL_IWDG_START

Enables the IWDG peripheral.
Parameters:

__HANDLE__: IWDG handle
Return value:

__HAL_IWDG_RELOAD_COUNTER
None:
Description:

Reloads IWDG counter with value
defined in the reload register (write
access to IWDG_PR and IWDG_RLR
registers disabled).
Parameters:

__HANDLE__: IWDG handle
Return value:

__HAL_IWDG_ENABLE_WRITE_ACCESS
None:
Description:

Enable write access to IWDG_PR,
IWDG_RLR and IWDG_WINR
registers.
Parameters:

__HANDLE__: IWDG handle
Return value:

__HAL_IWDG_DISABLE_WRITE_ACCESS
Description:

450/861
None:
DOCID026526 Rev 2
Disable write access to IWDG_PR,
IWDG_RLR and IWDG_WINR
registers.
UM1786
HAL IWDG Generic Driver
Parameters:

__HANDLE__: IWDG handle
Return value:

None:
Description:
__HAL_IWDG_GET_FLAG

Gets the selected IWDG's 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 Flag definition
IWDG_FLAG_PVU
Watchdog counter prescaler value update Flag
IWDG_FLAG_RVU
Watchdog counter reload value update Flag
IWDG_FLAG_WVU
Watchdog counter window value update Flag
IS_IWDG_FLAG
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
IS_IWDG_PRESCALER
IWDG Private Defines
HAL_IWDG_DEFAULT_TIMEOUT
IWDG Registers BitMask
KR_KEY_RELOAD
IWDG Reload Counter Enable
KR_KEY_ENABLE
IWDG Peripheral Enable
DOCID026526 Rev 2
451/861
HAL IWDG Generic Driver
KR_KEY_EWA
IWDG KR Write Access Enable
UM1786
KR_KEY_DWA
IWDG KR Write Access Disable
IS_IWDG_KR
IWDG Reload Value
IS_IWDG_RELOAD
IWDG Window option
IWDG_WINDOW_DISABLE
452/861
DOCID026526 Rev 2
UM1786
HAL NAND Generic Driver
29
HAL NAND Generic Driver
29.1
NAND Firmware driver registers structures
29.1.1
NAND_IDTypeDef
NAND_IDTypeDef is defined in the stm32f3xx_hal_nand.h
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
NAND_AddressTypedef is defined in the stm32f3xx_hal_nand.h
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
NAND_InfoTypeDef is defined in the stm32f3xx_hal_nand.h
Data Fields
DOCID026526 Rev 2
453/861
HAL NAND Generic Driver





UM1786
uint32_t PageSize
uint32_t SpareAreaSize
uint32_t BlockSize
uint32_t BlockNbr
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
NAND_HandleTypeDef is defined in the stm32f3xx_hal_nand.h
Data Fields





FMC_NAND_TypeDef * Instance
FMC_NAND_InitTypeDef Init
HAL_LockTypeDef Lock
__IO HAL_NAND_StateTypeDef State
NAND_InfoTypeDef Info
Field Documentation





29.2
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
NAND Firmware driver API description
The following section lists the various functions of the NAND library.
454/861
DOCID026526 Rev 2
UM1786
29.2.1
HAL NAND Generic Driver
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/FSMC 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.
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






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


HAL_NAND_Read_ID()
HAL_NAND_Reset()
DOCID026526 Rev 2
455/861
HAL NAND Generic Driver







29.2.4
UM1786
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()
NAND Control functions
This subsection provides a set of functions allowing to control dynamically the NAND
interface.



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.


29.2.6
HAL_NAND_GetState()
HAL_NAND_Read_Status()
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
29.2.7
456/861
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
DOCID026526 Rev 2
UM1786
29.2.8
29.2.9
29.2.10
29.2.11
29.2.12
HAL NAND Generic Driver
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.
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

hnand: pointer to a NAND_HandleTypeDef structure that
contains the configuration information for NAND module.
DOCID026526 Rev 2
457/861
HAL NAND Generic Driver
Return values
29.2.13
29.2.14
HAL status
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
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




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




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
458/861

Function Name
Return values
29.2.16
pNAND_ID: NAND ID structure
HAL_NAND_Reset
Return values
29.2.15
UM1786

HAL_StatusTypeDef HAL_NAND_Read_SpareArea
(NAND_HandleTypeDef * hnand, NAND_AddressTypedef *
DOCID026526 Rev 2
UM1786
HAL NAND Generic Driver
pAddress, uint8_t * pBuffer, uint32_t NumSpareAreaToRead)
Function Description
Read Spare area(s) from NAND memory.
Parameters

Return values
29.2.17
HAL status
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
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
29.2.19

HAL_NAND_Write_SpareArea
Return values
29.2.18



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

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
DOCID026526 Rev 2
459/861
HAL NAND Generic Driver
29.2.20
UM1786
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
29.2.21
29.2.22
29.2.23
The new status of the increment address operation. It can be:
NAND_VALID_ADDRESS: When the new address is valid
addressNAND_INVALID_ADDRESS: When the new address
is invalid address
HAL_NAND_ECC_Enable
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
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
460/861

hnand: pointer to a NAND_HandleTypeDef structure that
contains the configuration information for NAND module.
pAddress: pointer to NAND address structure


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
DOCID026526 Rev 2
UM1786
29.2.24
29.2.25
29.3
HAL NAND Generic Driver
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
NAND Firmware driver defines
The following section lists the various define and macros of the module.
29.3.1
NAND
NAND
NAND Exported Constants
NAND_DEVICE1
NAND_DEVICE2
NAND_WRITE_TIMEOUT
CMD_AREA
ADDR_AREA
NAND_CMD_AREA_A
NAND_CMD_AREA_B
NAND_CMD_AREA_C
NAND_VALID_ADDRESS
NAND_INVALID_ADDRESS
NAND_TIMEOUT_ERROR
NAND_BUSY
NAND_ERROR
NAND_READY
NAND Exported Macros
DOCID026526 Rev 2
461/861
HAL NAND Generic Driver
__HAL_NAND_RESET_HANDLE_STATE
UM1786
Description:

Reset NAND handle state.
Parameters:

__HANDLE__: specifies the NAND
handle.
Return value:

ARRAY_ADDRESS
None:
Description:

NAND memory address computation.
Parameters:


__ADDRESS__: NAND memory address.
__HANDLE__: NAND handle.
Return value:

ADDR_1st_CYCLE
NAND: Raw address value
Description:

NAND memory address cycling.
Parameters:

__ADDRESS__: NAND memory address.
Return value:

NAND: address cycling value.
ADDR_2nd_CYCLE
ADDR_3rd_CYCLE
ADDR_4th_CYCLE
462/861
DOCID026526 Rev 2
UM1786
HAL NOR Generic Driver
30
HAL NOR Generic Driver
30.1
NOR Firmware driver registers structures
30.1.1
NOR_IDTypeDef
NOR_IDTypeDef is defined in the stm32f3xx_hal_nor.h
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
NOR_CFITypeDef is defined in the stm32f3xx_hal_nor.h
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 2
463/861
HAL NOR Generic Driver
30.1.3
UM1786
NOR_HandleTypeDef
NOR_HandleTypeDef is defined in the stm32f3xx_hal_nor.h
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





30.2
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
NOR Firmware driver API description
The following section lists the various functions of the NOR library.
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:







464/861
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 2
UM1786
HAL NOR Generic Driver
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





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









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.


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.


HAL_NOR_GetState()
HAL_NOR_GetStatus()
DOCID026526 Rev 2
465/861
HAL NOR Generic Driver
30.2.6
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
30.2.7
30.2.8
30.2.9
30.2.10


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
Function Name
466/861
UM1786
void HAL_NOR_MspWait (NOR_HandleTypeDef * hnor,
DOCID026526 Rev 2
UM1786
HAL NOR Generic Driver
uint32_t Timeout)
Function Description
NOR MSP Wait fro Ready/Busy signal.
Parameters

Return values
30.2.11
30.2.13
None
Function Name
HAL_StatusTypeDef HAL_NOR_Read_ID
(NOR_HandleTypeDef * hnor, NOR_IDTypeDef * pNOR_ID)
Function Description
Read NOR flash IDs.
Parameters


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
30.2.14

HAL_NOR_Read_ID
Return values
30.2.12

hnor: pointer to a NOR_HandleTypeDef structure that
contains the configuration information for NOR module.
Timeout: Maximum timeout value


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)
DOCID026526 Rev 2
467/861
HAL NOR Generic Driver
Function Description
Parameters
Return values
30.2.15
UM1786
Program data to NOR memory.



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
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
30.2.16
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).


30.2.17
HAL_NOR_Erase_Block
Function Name
468/861
HAL_StatusTypeDef HAL_NOR_Erase_Block
(NOR_HandleTypeDef * hnor, uint32_t BlockAddress, uint32_t
Address)
DOCID026526 Rev 2
UM1786
Function Description
HAL NOR Generic Driver
Erase the specified block of the NOR memory.
Parameters

Return values
30.2.18
30.2.21
HAL status
Function Name
HAL_StatusTypeDef HAL_NOR_Erase_Chip
(NOR_HandleTypeDef * hnor, uint32_t Address)
Function Description
Erase the entire NOR chip.
Parameters


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
30.2.20

HAL_NOR_Erase_Chip
Return values
30.2.19


hnor: pointer to a NOR_HandleTypeDef structure that
contains the configuration information for NOR module.
BlockAddress: Block to erase address
Address: Device address

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.
DOCID026526 Rev 2
469/861
HAL NOR Generic Driver
Parameters
Return values
30.2.22
30.2.23
UM1786

hnor: pointer to a NOR_HandleTypeDef structure that
contains the configuration information for NOR module.

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
NOR_StatusTypedef HAL_NOR_GetStatus
(NOR_HandleTypeDef * hnor, uint32_t Address, uint32_t
Timeout)
Function Description
Returns the NOR operation status.
Parameters



Return values
30.3

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: NOR_SUCCESS,
NOR_ERROR or NOR_TIMEOUT
NOR Firmware driver defines
The following section lists the various define and macros of the module.
30.3.1
NOR
NOR
NOR Exported Constants
MC_ADDRESS
DEVICE_CODE1_ADDR
DEVICE_CODE2_ADDR
DEVICE_CODE3_ADDR
CFI1_ADDRESS
CFI2_ADDRESS
CFI3_ADDRESS
CFI4_ADDRESS
470/861
DOCID026526 Rev 2
UM1786
HAL NOR Generic Driver
NOR_TMEOUT
NOR_MEMORY_8B
NOR_MEMORY_16B
NOR_MEMORY_ADRESS1
NOR_MEMORY_ADRESS2
NOR_MEMORY_ADRESS3
NOR_MEMORY_ADRESS4
NOR Exported Macros
__HAL_NOR_RESET_HANDLE_STATE
Description:

Reset NOR handle state.
Parameters:

__HANDLE__: NOR handle
Return value:

__NOR_ADDR_SHIFT
None:
Description:

NOR memory address shifting.
Parameters:



__NOR_ADDRESS: NOR base address
__NOR_MEMORY_WIDTH_: NOR
memory width
__ADDRESS__: NOR memory address
Return value:

__NOR_WRITE
NOR: shifted address value
Description:

NOR memory write data to specified
address.
Parameters:


__ADDRESS__: NOR memory address
__DATA__: Data to write
Return value:

None:
DOCID026526 Rev 2
471/861
HAL OPAMP Generic Driver
UM1786
31
HAL OPAMP Generic Driver
31.1
OPAMP Firmware driver registers structures
31.1.1
OPAMP_InitTypeDef
OPAMP_InitTypeDef is defined in the stm32f3xx_hal_opamp.h
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






472/861
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 modes In 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_ENABLE In 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 2
UM1786





31.1.2
HAL OPAMP Generic Driver
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
OPAMP_HandleTypeDef is defined in the stm32f3xx_hal_opamp.h
Data Fields





OPAMP_TypeDef * Instance
OPAMP_InitTypeDef Init
HAL_StatusTypeDef Status
HAL_LockTypeDef Lock
__IO HAL_OPAMP_StateTypeDef State
Field Documentation





31.2
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
OPAMP Firmware driver API description
The following section lists the various functions of the OPAMP library.
DOCID026526 Rev 2
473/861
HAL OPAMP Generic Driver
31.2.1
UM1786
OPAMP Peripheral Features
The device integrates up to 4 operational amplifiers OPAMP1, OPAMP2, OPAMP3 and
OPAMP4:
1.
2.
3.
4.
5.
6.
7.
8.
474/861
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.
The OPAMPs non inverting input (both default and secondary) can be selected
among the list shown in Table 23: "OPAMPs inverting/non-inverting inputs for
STM32F3 devices" .
The OPAMPs non inverting input (both default and secondary) can be selected
among the list shown in Table 24: "OPAMP outputs for STM32F3 devices".
DOCID026526 Rev 2
UM1786
HAL OPAMP Generic Driver
Table 23: OPAMPs inverting/non-inverting inputs for STM32F3 devices
Inverting inputs
HAL parameter name
OPAMP1
OPAMP2
OPAMP3
OPAMP4
Non connected
VM0
VM1
X
PC5
PA3
X
PC5
PA5
X
PB10
PB2
X
PB10
PD8
VP0
VP1
VP2
VP3
PA1
PA7
PA3
PA5
PA7
PD14
PB0
PB14
PB0
PB13
PA1
PA5
PB13
PD11
PA4
PB11
(1)
Non-inverting inputs
Notes:
(1)
NA in follower mode.
Table 24: OPAMP outputs for STM32F3 devices
Output
31.2.2
OPAMP1
OPAMP2
OPAMP3
OPAMP4
PA2
PA6
PB1
PB12
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.
2.
3.
4.
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.
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.
DOCID026526 Rev 2
475/861
HAL OPAMP Generic Driver
UM1786
5.
Lock the opamp in running mode using HAL_OPAMP_Lock() function. From then The
configuration can only be modified after HW reset.
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:




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.



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.

31.2.6
HAL_OPAMP_Lock()
Peripheral State functions
This subsection permit to get in run-time the status of the peripheral and the data flow.


31.2.7
476/861
HAL_OPAMP_GetState()
HAL_OPAMP_GetTrimOffset()
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
DOCID026526 Rev 2
UM1786
HAL OPAMP Generic Driver
Notes
31.2.8
31.2.9
31.2.10
31.2.11
31.2.12

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
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
DOCID026526 Rev 2
477/861
HAL OPAMP Generic Driver
Function Name
31.2.13
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
31.2.14
31.2.15
31.2.16
478/861
UM1786
HAL_StatusTypeDef HAL_OPAMP_Stop
(OPAMP_HandleTypeDef * hopamp)
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
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
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)
DOCID026526 Rev 2
UM1786
HAL OPAMP Generic Driver
Return values
31.3

Trimming value (P or N): range: 0->31 or
OPAMP_FACTORYTRIMMING_DUMMY if trimming value is
not available
OPAMP Firmware driver defines
The following section lists the various define and macros of the module.
31.3.1
OPAMP
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
IOPAMP_INVERTINGINPUT_VM0
inverting input connected to VM0
IOPAMP_INVERTINGINPUT_VM1
inverting input connected to VM1
IS_OPAMP_INVERTING_INPUT
OPAMP Inverting Input Secondary
OPAMP_SEC_INVERTINGINPUT_VM0
VM0 (PC5 for OPAMP1 and OPAMP2, PB10 for
OPAMP3 and OPAMP4) connected to OPAMPx
inverting input
OPAMP_SEC_INVERTINGINPUT_VM1
VM1 (PA3 for OPAMP1, PA5 for OPAMP2, PB2
for OPAMP3, PD8 for OPAMP4) connected to
OPAMPx inverting input
IS_OPAMP_SEC_INVERTINGINPUT
DOCID026526 Rev 2
479/861
HAL OPAMP Generic Driver
OPAMP Mode
UM1786
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_VP0
VP0 (PA1 for OPAMP1, PA7 for OPAMP2, PB0
for OPAMP3, PB13 for OPAMP4) connected to
OPAMPx non inverting input
OPAMP_NONINVERTINGINPUT_VP1
VP1 (PA7 for OPAMP1, PD14 for OPAMP2,
PB13 for OPAMP3, PD11 for OPAMP4)
connected to OPAMPx non inverting input
OPAMP_NONINVERTINGINPUT_VP2
VP2 (PA3 for OPAMP1, PB0 for OPAMP2, PA1
for OPAMP3, PA4 for OPAMP4) connected to
OPAMPx non inverting input
OPAMP_NONINVERTINGINPUT_VP3
vp3 (PA5 for OPAMP1, PB14 for OPAMP2, PA5
for OPAMP3, PB11 for OPAMP4) connected to
OPAMPx non inverting input
IS_OPAMP_NONINVERTING_INPUT
OPAMP Non Inverting Input Secondary
OPAMP_SEC_NONINVERTINGINPUT_VP0
VP0 (PA1 for OPAMP1, PA7 for OPAMP2,
PB0 for OPAMP3, PB13 for OPAMP4)
connected to OPAMPx non inverting input
OPAMP_SEC_NONINVERTINGINPUT_VP1
VP1 (PA7 for OPAMP1, PD14 for
OPAMP2, PB13 for OPAMP3, PD11 for
OPAMP4) connected to OPAMPx non
inverting input
OPAMP_SEC_NONINVERTINGINPUT_VP2
VP2 (PA3 for OPAMP1, PB0 for OPAMP2,
PA1 for OPAMP3, PA4 for OPAMP4)
connected to OPAMPx non inverting input
OPAMP_SEC_NONINVERTINGINPUT_VP3
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
OPAMP_PGACONNECT_NO
In PGA mode, the non inverting input is not connected
OPAMP_PGACONNECT_VM0
In PGA mode, the non inverting input is connected to
VM0
OPAMP_PGACONNECT_VM1
In PGA mode, the non inverting input is connected to
VM1
IS_OPAMP_PGACONNECT
OPAMP Pga Gain
480/861
DOCID026526 Rev 2
UM1786
HAL OPAMP Generic Driver
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 Private Define
OPAMP_CSR_RESET_VALUE
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 2
481/861
HAL OPAMP Extension Driver
UM1786
32
HAL OPAMP Extension Driver
32.1
OPAMPEx Firmware driver API description
The following section lists the various functions of the OPAMPEx library.
32.1.1
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: handle
hopamp2: handle
hopamp3: handle
hopamp4: handle
Return values

HAL status
Notes

Updated offset trimming values (PMOS & NMOS), user
trimming is enabled
Calibration runs about 25 ms.

32.2
OPAMPEx Firmware driver defines
The following section lists the various define and macros of the module.
32.2.1
OPAMPEx
OPAMPEx
482/861
DOCID026526 Rev 2
UM1786
HAL PCCARD Generic Driver
33
HAL PCCARD Generic Driver
33.1
PCCARD Firmware driver registers structures
33.1.1
PCCARD_HandleTypeDef
PCCARD_HandleTypeDef is defined in the stm32f3xx_hal_pccard.h
Data Fields




FMC_PCCARD_TypeDef * Instance
FMC_PCCARD_InitTypeDef Init
__IO HAL_PCCARD_StateTypeDef State
HAL_LockTypeDef Lock
Field Documentation




33.2
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
PCCARD Firmware driver API description
The following section lists the various functions of the PCCARD library.
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_CF_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_CF_Read_Sector()/HAL_CF_Write_Sector(), to read/write sector.
Perform PCCARD/compact flash Reset chip operation using the function
HAL_CF_Reset().
Perform PCCARD/compact flash erase sector operation using the function
HAL_CF_Erase_Sector().
DOCID026526 Rev 2
483/861
HAL PCCARD Generic Driver


UM1786
Read the PCCARD/compact flash status operation using the function
HAL_CF_ReadStatus().
You can monitor the PCCARD/compact flash device HAL state by calling the function
HAL_PCCARD_GetState()
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




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







33.2.4
HAL_CF_Read_ID()
HAL_CF_Read_Sector()
HAL_CF_Write_Sector()
HAL_CF_Erase_Sector()
HAL_CF_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.



33.2.5
484/861
HAL_PCCARD_GetState()
HAL_CF_GetStatus()
HAL_CF_ReadStatus()
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

hpccard: pointer to a PCCARD_HandleTypeDef structure
that contains the configuration information for PCCARD
DOCID026526 Rev 2
UM1786
Return values
33.2.6
33.2.7
33.2.8
33.2.9



HAL PCCARD Generic Driver
module.
ComSpaceTiming: Common space timing structure
AttSpaceTiming: Attribute space timing structure
IOSpaceTiming: IO space timing structure

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_CF_Read_ID
Function Name
HAL_StatusTypeDef HAL_CF_Read_ID
(PCCARD_HandleTypeDef * hpccard, uint8_t
CompactFlash_ID, uint8_t * pStatus)
Function Description
Read Compact Flash's ID.
DOCID026526 Rev 2
485/861
HAL PCCARD Generic Driver
Parameters
Return values
33.2.10

HAL status
Function Name
HAL_StatusTypeDef HAL_CF_Read_Sector
(PCCARD_HandleTypeDef * hpccard, uint16_t * pBuffer,
uint16_t SectorAddress, uint8_t * pStatus)
Function Description
Read sector from PCCARD memory.
Parameters




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_CF_Write_Sector
Function Name
HAL_StatusTypeDef HAL_CF_Write_Sector
(PCCARD_HandleTypeDef * hpccard, uint16_t * pBuffer,
uint16_t SectorAddress, uint8_t * pStatus)
Function Description
Write sector to PCCARD memory.
Parameters

Return values
33.2.12


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_CF_Read_Sector
Return values
33.2.11
UM1786




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_CF_Erase_Sector
Function Name
HAL_StatusTypeDef HAL_CF_Erase_Sector
(PCCARD_HandleTypeDef * hpccard, uint16_t SectorAddress,
uint8_t * pStatus)
Function Description
Erase sector from PCCARD memory.
Parameters


486/861
hpccard: pointer to a PCCARD_HandleTypeDef structure
that contains the configuration information for PCCARD
module.
SectorAddress: Sector address to erase
DOCID026526 Rev 2
UM1786
HAL PCCARD Generic Driver
Return values
33.2.13
33.2.14
33.2.15
33.2.16

pStatus: pointer to CF status

HAL status
HAL_CF_Reset
Function Name
HAL_StatusTypeDef HAL_CF_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
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.
DOCID026526 Rev 2
487/861
HAL PCCARD Generic Driver
Return values
33.2.17
33.2.18
33.3
UM1786

HAL state
HAL_CF_GetStatus
Function Name
CF_StatusTypedef HAL_CF_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 errorCompactFlash_READY:
when memory is ready for the next operation
HAL_CF_ReadStatus
Function Name
CF_StatusTypedef HAL_CF_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
busyCompactFlash_READY: when memory is ready for the
next operationCompactFlash_ERROR: when the previous
operation gererates error
PCCARD Firmware driver defines
The following section lists the various define and macros of the module.
33.3.1
PCCARD
PCCARD
PCCARD Compact Flash ATA Commands
CF_READ_SECTOR_CMD
CF_WRITE_SECTOR_CMD
CF_ERASE_SECTOR_CMD
CF_IDENTIFY_CMD
PCCARD Compact Flash ATA Registers
CF_DATA
488/861
Data register
DOCID026526 Rev 2
UM1786
HAL PCCARD Generic Driver
CF_SECTOR_COUNT
Sector Count register
CF_SECTOR_NUMBER
Sector Number register
CF_CYLINDER_LOW
Cylinder low register
CF_CYLINDER_HIGH
Cylinder high register
CF_CARD_HEAD
Card/Head register
CF_STATUS_CMD
Status(read)/Command(write) register
CF_STATUS_CMD_ALTERNATE
Alternate Status(read)/Command(write) register
CF_COMMON_DATA_AREA
Start of data area (for Common access only!)
PCCARD Compact Flash Characteristics
CF_DEVICE_ADDRESS
CF_ATTRIBUTE_SPACE_ADDRESS
Attribute space size to @0x9BFF FFFF
CF_COMMON_SPACE_ADDRESS
Common space size to @0x93FF FFFF
CF_IO_SPACE_ADDRESS
IO space size to @0x9FFF FFFF
CF_IO_SPACE_PRIMARY_ADDR
IO space size to @0x9FFF FFFF
PCCARD_Compact_Flash_Sector_Size
CF_SECTOR_SIZE
PCCARD Compact Flash Status
CF_TIMEOUT_ERROR
CF_BUSY
CF_PROGR
CF_READY
PCCARD Exported Macros
__HAL_PCCARD_RESET_HANDLE_STATE
Description:

Reset PCCARD handle state.
Parameters:

__HANDLE__: specifies the PCCARD
handle.
Return value:

DOCID026526 Rev 2
None:
489/861
HAL PCD Generic Driver
UM1786
34
HAL PCD Generic Driver
34.1
PCD Firmware driver registers structures
34.1.1
PCD_InitTypeDef
PCD_InitTypeDef is defined in the stm32f3xx_hal_pcd.h
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
PCD_EPTypeDef is defined in the stm32f3xx_hal_pcd.h
Data Fields
490/861
DOCID026526 Rev 2
UM1786
HAL PCD Generic Driver












uint8_t num
uint8_t is_in
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
PCD_HandleTypeDef is defined in the stm32f3xx_hal_pcd.h
DOCID026526 Rev 2
491/861
HAL PCD Generic Driver
Data Fields









UM1786
PCD_TypeDef * Instance
PCD_InitTypeDef Init
__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









34.2
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[8]
IN endpoint parameters
PCD_EPTypeDef PCD_HandleTypeDef::OUT_ep[8]
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
PCD Firmware driver API description
The following section lists the various functions of the PCD library.
34.2.1
How to use this driver
The PCD HAL driver can be used as follows:
1.
2.
3.
4.
5.
492/861
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

__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:
DOCID026526 Rev 2
UM1786
HAL PCD Generic Driver
6.
34.2.2
a.
hpcd.pData = pdev;
Enable HCD transmission and reception:
a.
HAL_PCD_Start();
Initialization and de-initialization functions
This section provides functions allowing to:




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.














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.













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_ActiveRemoteWakeup()
HAL_PCD_DeActiveRemoteWakeup()
DOCID026526 Rev 2
493/861
HAL PCD Generic Driver
34.2.5
UM1786
Peripheral State functions
This subsection permit to get in run-time the status of the peripheral and the data flow.

34.2.6
34.2.7
34.2.8
34.2.9
34.2.10
HAL_PCD_GetState()
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
494/861
HAL_StatusTypeDef HAL_PCD_Start (PCD_HandleTypeDef *
DOCID026526 Rev 2
UM1786
HAL PCD Generic Driver
hpcd)
34.2.11
34.2.12
34.2.13
34.2.14
Function Description
Start The USB OTG Device.
Parameters

hpcd: PCD handle
Return values

HAL status
HAL_PCD_Stop
Function Name
HAL_StatusTypeDef HAL_PCD_Stop (PCD_HandleTypeDef *
hpcd)
Function Description
Stop The USB OTG 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
DOCID026526 Rev 2
495/861
HAL PCD Generic Driver
34.2.15
34.2.16
34.2.17
34.2.18
34.2.19
496/861
UM1786
HAL_PCD_SetupStageCallback
Function Name
void HAL_PCD_SetupStageCallback (PCD_HandleTypeDef *
hpcd)
Function Description
Setup stage callback.
Parameters

hpcd: ppp handle
Return values

None
HAL_PCD_SOFCallback
Function Name
void HAL_PCD_SOFCallback (PCD_HandleTypeDef * hpcd)
Function Description
USB Start Of Frame callbacks.
Parameters

hpcd: PCD handle
Return values

None
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
DOCID026526 Rev 2
UM1786
34.2.20
34.2.21
34.2.22
34.2.23
34.2.24
HAL PCD Generic Driver
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)
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: ppp handle
Return values

None
HAL_PCD_DevConnect
Function Name
HAL_StatusTypeDef HAL_PCD_DevConnect
(PCD_HandleTypeDef * hpcd)
Function Description
Connect the USB device.
DOCID026526 Rev 2
497/861
HAL PCD Generic Driver
Parameters
Return values
34.2.25
34.2.26
34.2.27
34.2.28
498/861
UM1786

hpcd: PCD handle

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
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
ep_mps: endpoint max packert size
ep_type: endpoint type
Return values

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
DOCID026526 Rev 2
UM1786
34.2.29
34.2.30
34.2.31
34.2.32
HAL PCD Generic Driver
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_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
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_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
DOCID026526 Rev 2
499/861
HAL PCD Generic Driver
34.2.33
34.2.34
34.2.35
34.2.36
34.2.37
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_ActiveRemoteWakeup
Function Name
HAL_StatusTypeDef HAL_PCD_ActiveRemoteWakeup
(PCD_HandleTypeDef * hpcd)
Function Description
HAL_PCD_ActiveRemoteWakeup : active remote wakeup
signalling.
Parameters

hpcd: PCD handle
Return values

status
HAL_PCD_DeActiveRemoteWakeup
Function Name
HAL_StatusTypeDef HAL_PCD_DeActiveRemoteWakeup
(PCD_HandleTypeDef * hpcd)
Function Description
HAL_PCD_DeActiveRemoteWakeup : de-active remote wakeup
signalling.
Parameters

hpcd: PCD handle
Return values

status
HAL_PCD_GetState
Function Name
500/861
UM1786
PCD_StateTypeDef HAL_PCD_GetState (PCD_HandleTypeDef
* hpcd)
DOCID026526 Rev 2
UM1786
34.2.38
34.2.39
34.3
HAL PCD Generic Driver
Function Description
Return the PCD state.
Parameters

hpcd: PCD handle
Return values

HAL state
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
PCD Firmware driver defines
The following section lists the various define and macros of the module.
34.3.1
PCD
PCD
PCD Core PHY
PCD_PHY_EMBEDDED
PCD Core Speed
PCD_SPEED_HIGH
PCD_SPEED_FULL
PCD_ENDP_Type
PCD_ENDP0
PCD_ENDP1
DOCID026526 Rev 2
501/861
HAL PCD Generic Driver
PCD_ENDP2
UM1786
PCD_ENDP3
PCD_ENDP4
PCD_ENDP5
PCD_ENDP6
PCD_ENDP7
PCD_SNG_BUF
PCD_DBL_BUF
IS_PCD_ALL_INSTANCE
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
__HAL_USB_EXTI_ENABLE_IT
__HAL_USB_EXTI_DISABLE_IT
__HAL_USB_EXTI_GENERATE_SWIT
__HAL_USB_EXTI_GET_FLAG
__HAL_USB_EXTI_CLEAR_FLAG
__HAL_USB_EXTI_SET_RISING_EDGE_TRIGGER
__HAL_USB_EXTI_SET_FALLING_EDGE_TRIGGER
__HAL_USB_EXTI_SET_FALLINGRISING_TRIGGER
PCD Private Define
BTABLE_ADDRESS
PCD Private Macros
502/861
DOCID026526 Rev 2
UM1786
HAL PCD Generic Driver
PCD_SET_ENDPOINT
PCD_GET_ENDPOINT
PCD_SET_EPTYPE
Description:

sets the type in the endpoint register(bits
EP_TYPE[1:0])
Parameters:



USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
wType: Endpoint Type.
Return value:

PCD_GET_EPTYPE
None:
Description:

gets the type in the endpoint register(bits
EP_TYPE[1:0])
Parameters:


USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
Return value:

PCD_FreeUserBuffer
Endpoint: Type
Description:

free buffer used from the application realizing
it to the line toggles bit SW_BUF in the double
buffered endpoint register
Parameters:



USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
bDir: Direction
Return value:

PCD_GET_DB_DIR
None:
Description:

gets direction of the double buffered endpoint
Parameters:


USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
Return value:

EP_DBUF_OUT: if the endpoint counter not
yet programmed.
DOCID026526 Rev 2
503/861
HAL PCD Generic Driver
PCD_SET_EP_TX_STATUS
UM1786
Description:

sets the status for tx transfer (bits
STAT_TX[1:0]).
Parameters:



USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
wState: new state
Return value:

PCD_SET_EP_RX_STATUS
None:
Description:

sets the status for rx transfer (bits
STAT_TX[1:0])
Parameters:



USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
wState: new state
Return value:

PCD_SET_EP_TXRX_STATUS
None:
Description:

sets the status for rx & tx (bits STAT_TX[1:0]
& STAT_RX[1:0])
Parameters:




USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
wStaterx: new state.
wStatetx: new state.
Return value:

PCD_GET_EP_TX_STATUS
None:
Description:

gets the status for tx/rx transfer (bits
STAT_TX[1:0] /STAT_RX[1:0])
Parameters:


USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
Return value:

status:
PCD_GET_EP_RX_STATUS
504/861
DOCID026526 Rev 2
UM1786
HAL PCD Generic Driver
Description:
PCD_SET_EP_TX_VALID

sets directly the VALID tx/rx-status into the
endpoint register
Parameters:


USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
Return value:

None:
PCD_SET_EP_RX_VALID
PCD_GET_EP_TX_STALL_STATUS
Description:

checks stall condition in an endpoint.
Parameters:


USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
Return value:

TRUE: = endpoint in stall condition.
PCD_GET_EP_RX_STALL_STATUS
Description:
PCD_SET_EP_KIND

set & clear EP_KIND bit.
Parameters:


USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
Return value:

None:
PCD_CLEAR_EP_KIND
Description:
PCD_SET_OUT_STATUS

Sets/clears directly STATUS_OUT bit in the
endpoint register.
Parameters:


USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
Return value:

None:
PCD_CLEAR_OUT_STATUS
PCD_SET_EP_DBUF
Description:
DOCID026526 Rev 2
505/861
HAL PCD Generic Driver
UM1786

Sets/clears directly EP_KIND bit in the
endpoint register.
Parameters:


USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
Return value:

None:
PCD_CLEAR_EP_DBUF
PCD_CLEAR_RX_EP_CTR
Description:

Clears bit CTR_RX / CTR_TX in the endpoint
register.
Parameters:


USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
Return value:

None:
PCD_CLEAR_TX_EP_CTR
PCD_RX_DTOG
Description:

Toggles DTOG_RX / DTOG_TX bit in the
endpoint register.
Parameters:


USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
Return value:

None:
PCD_TX_DTOG
PCD_CLEAR_RX_DTOG
Description:

Clears DTOG_RX / DTOG_TX bit in the
endpoint register.
Parameters:


USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
Return value:

None:
PCD_CLEAR_TX_DTOG
PCD_SET_EP_ADDRESS
506/861
Description:
DOCID026526 Rev 2
UM1786
HAL PCD Generic Driver

Sets address in an endpoint register.
Parameters:



USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
bAddr: Address.
Return value:

None:
PCD_GET_EP_ADDRESS
PCD_SET_EP_TX_ADDRESS
Description:

sets address of the tx/rx buffer.
Parameters:



USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
wAddr: address to be set (must be word
aligned).
Return value:

None:
PCD_SET_EP_RX_ADDRESS
PCD_GET_EP_TX_ADDRESS
Description:

Gets address of the tx/rx buffer.
Parameters:


USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
Return value:

address: of the buffer.
PCD_GET_EP_RX_ADDRESS
Description:
PCD_CALC_BLK32

Sets counter of rx buffer with no.
Parameters:



dwReg: Register
wCount: Counter.
wNBlocks: no. of Blocks.
Return value:

None:
PCD_CALC_BLK2
PCD_SET_EP_CNT_RX_REG
DOCID026526 Rev 2
507/861
HAL PCD Generic Driver
PCD_SET_EP_RX_DBUF0_CNT
UM1786
Description:
PCD_SET_EP_TX_CNT

sets counter for the tx/rx buffer.
Parameters:



USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
wCount: Counter value.
Return value:

None:
Description:
PCD_GET_EP_TX_CNT

gets counter of the tx buffer.
Parameters:


USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
Return value:

Counter: value
PCD_GET_EP_RX_CNT
PCD_SET_EP_DBUF0_ADDR
Description:

Sets buffer 0/1 address in a double buffer
endpoint.
Parameters:



USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
wBuf0Addr: buffer 0 address.
Return value:

Counter: value
PCD_SET_EP_DBUF1_ADDR
PCD_SET_EP_DBUF_ADDR
Description:

Sets addresses in a double buffer endpoint.
Parameters:




USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
wBuf0Addr: buffer 0 address.
wBuf1Addr: = buffer 1 address.
Return value:

508/861
None:
DOCID026526 Rev 2
UM1786
HAL PCD Generic Driver
PCD_GET_EP_DBUF0_ADDR
Description:

Gets buffer 0/1 address of a double buffer
endpoint.
Parameters:


USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
Return value:

None:
PCD_GET_EP_DBUF1_ADDR
PCD_SET_EP_DBUF0_CNT
Description:

Gets buffer 0/1 address of a double buffer
endpoint.
Parameters:




USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
bDir: endpoint dir EP_DBUF_OUT = OUT
EP_DBUF_IN = IN
wCount: Counter value
Return value:

None:
PCD_SET_EP_DBUF1_CNT
PCD_SET_EP_DBUF_CNT
PCD_GET_EP_DBUF0_CNT
Description:

Gets buffer 0/1 rx/tx counter for double
buffering.
Parameters:


USBx: USB peripheral instance register
address.
bEpNum: Endpoint Number.
Return value:

None:
PCD_GET_EP_DBUF1_CNT
DOCID026526 Rev 2
509/861
HAL PCD Extension Driver
UM1786
35
HAL PCD Extension Driver
35.1
PCDEx Firmware driver API description
The following section lists the various functions of the PCDEx library.
35.1.1
Peripheral extended features methods


35.1.2
HAL_PCDEx_PMAConfig()
HAL_PCDEx_SetConnectionState()
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
35.1.3
35.2

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
__weak 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
PCDEx Firmware driver defines
The following section lists the various define and macros of the module.
35.2.1
PCDEx
PCDEx
510/861
DOCID026526 Rev 2
UM1786
HAL PCD Extension Driver
PCD Extended Exported Macros
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 2
511/861
HAL PWR Generic Driver
UM1786
36
HAL PWR Generic Driver
36.1
PWR Firmware driver API description
The following section lists the various functions of the PWR library.
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
__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 an 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:



512/861
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).
DOCID026526 Rev 2
UM1786
HAL PWR Generic Driver
Sleep mode


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.

Low Power regulator ON.

PWR_STOPENTRY_WFI: enter STOP mode with WFI instruction

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.
DOCID026526 Rev 2
513/861
HAL PWR Generic Driver
UM1786









36.1.3
36.1.4
36.1.5
514/861
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.

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.
HAL_PWR_EnableWakeUpPin()
HAL_PWR_DisableWakeUpPin()
HAL_PWR_EnterSLEEPMode()
HAL_PWR_EnterSTOPMode()
HAL_PWR_EnterSTANDBYMode()
HAL_PWR_EnableBkUpAccess()
HAL_PWR_DisableBkUpAccess()
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
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
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:
DOCID026526 Rev 2
UM1786
HAL PWR Generic Driver
PWR_WAKEUP_PIN1, PWR_WAKEUP_PIN2,
PWR_WAKEUP_PIN3
Return values
36.1.6
36.1.7

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_EnterSLEEPMode
Function Name
void HAL_PWR_EnterSLEEPMode (uint32_t Regulator, uint8_t
SLEEPEntry)
Function Description
Enters Sleep mode.
Parameters


36.1.8
None
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.
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
DOCID026526 Rev 2
515/861
HAL PWR Generic Driver
UM1786

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
reduced.


36.1.9
36.1.10
36.1.11
516/861
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_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
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
Backup Domain Access should be kept enabled.
DOCID026526 Rev 2
UM1786
36.2
HAL PWR Generic Driver
PWR Firmware driver defines
The following section lists the various define and macros of the module.
36.2.1
PWR
PWR
PWR Alias Exported Constants
PWR_OFFSET
CR_OFFSET
DBP_BitNumber
CR_DBP_BB
PVDE_BitNumber
CR_PVDE_BB
CSR_OFFSET
EWUP1_BitNumber
CSR_EWUP1_BB
EWUP2_BitNumber
CSR_EWUP2_BB
EWUP3_BitNumber
CSR_EWUP3_BB
PWR Exported Macro
__HAL_PWR_GET_FLAG
Description:

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
DOCID026526 Rev 2
517/861
HAL PWR Generic Driver
UM1786
ready.
Return value:

__HAL_PWR_CLEAR_FLAG
The: new state of __FLAG__ (TRUE or FALSE).
Description:

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
PWR_FLAG_SB
PWR_FLAG_PVDO
PWR_FLAG_VREFINTRDY
IS_PWR_GET_FLAG
PWR Regulator state in STOP mode
PWR_MAINREGULATOR_ON
PWR_LOWPOWERREGULATOR_ON
IS_PWR_REGULATOR
PWR SLEEP mode entry
PWR_SLEEPENTRY_WFI
PWR_SLEEPENTRY_WFE
IS_PWR_SLEEP_ENTRY
PWR STOP mode entry
PWR_STOPENTRY_WFI
PWR_STOPENTRY_WFE
IS_PWR_STOP_ENTRY
PWR WakeUp Pins
PWR_WAKEUP_PIN1
PWR_WAKEUP_PIN2
PWR_WAKEUP_PIN3
IS_PWR_WAKEUP_PIN
518/861
DOCID026526 Rev 2
UM1786
HAL PWR Extension Driver
37
HAL PWR Extension Driver
37.1
PWREx Firmware driver registers structures
37.1.1
PWR_PVDTypeDef
PWR_PVDTypeDef is defined in the stm32f3xx_hal_pwr_ex.h
Data Fields


uint32_t PVDLevel
uint32_t Mode
Field Documentation


37.2
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
PWREx Firmware driver API description
The following section lists the various functions of the PWREx library.
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_PVD_EXTI_ENABLE_IT() macro
The PVD is stopped in Standby mode. PVD is not available on STM32F3x8 Product
Line
Voltage regulator

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
DOCID026526 Rev 2
519/861
HAL PWR Extension Driver
UM1786
regulator is bypassed and the microcontroller must be powered from a nominal VDD =
1.8V +/-8% voltage.

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_PVD_EXTI_ENABLE_IT() macro

The PVD is stopped in Standby mode.
SDADC power configuration






37.2.2
37.2.3
37.2.4
520/861
On STM32F373xC/STM32F378xx devices, there are up to 3 SDADC instances that
can be enabled/disabled. This is done by calling the following functions:
void HAL_PWREx_EnableSDADCAnalog(uint32_t Analogx);
void HAL_PWREx_DisableSDADCAnalog(uint32_t Analogx);
HAL_PWR_PVDConfig()
HAL_PWR_EnablePVD()
HAL_PWR_DisablePVD()
HAL_PWR_PVD_IRQHandler()
HAL_PWR_PVDCallback()
HAL_PWR_PVDConfig
Function Name
void HAL_PWR_PVDConfig (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
DOCID026526 Rev 2
UM1786
37.2.5
37.2.6
37.3
HAL PWR Extension Driver
HAL_PWR_PVD_IRQHandler
Function Name
void HAL_PWR_PVD_IRQHandler (void )
Function Description
This function handles the PWR PVD interrupt request.
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
PWREx Firmware driver defines
The following section lists the various define and macros of the module.
37.3.1
PWREx
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
Description:

DOCID026526 Rev 2
None.:
Enable event on PVD
521/861
HAL PWR Extension Driver
UM1786
Exti Line 16.
Return value:

__HAL_PWR_PVD_EXTI_DISABLE_EVENT
None.:
Description:

Disable event on PVD
Exti Line 16.
Return value:

__HAL_PWR_PVD_EXTI_CLEAR_EGDE_TRIGGER
None.:
Description:

PVD EXTI line
configuration: clear
falling edge and rising
edge trigger.
Return value:

__HAL_PWR_PVD_EXTI_SET_FALLING_EGDE_TRIGGER
None.:
Description:

PVD EXTI line
configuration: set
falling edge trigger.
Return value:

__HAL_PWR_PVD_EXTI_SET_RISING_EDGE_TRIGGER
None.:
Description:

PVD EXTI line
configuration: set
rising edge trigger.
Return value:

__HAL_PWR_PVD_EXTI_GET_FLAG
None.:
Description:

Check whether the
specified PVD EXTI
interrupt flag is set or
not.
Return value:

__HAL_PWR_PVD_EXTI_CLEAR_FLAG
EXTI: PVD Line
Status.
Description:

Clear the PVD EXTI
flag.
Return value:

PWR Extended Private Constants
522/861
DOCID026526 Rev 2
None.:
UM1786
HAL PWR Extension Driver
PVD_MODE_IT
PVD_MODE_EVT
PVD_RISING_EDGE
PVD_FALLING_EDGE
PWR Extended PVD detection level
PWR_PVDLEVEL_0
PWR_PVDLEVEL_1
PWR_PVDLEVEL_2
PWR_PVDLEVEL_3
PWR_PVDLEVEL_4
PWR_PVDLEVEL_5
PWR_PVDLEVEL_6
PWR_PVDLEVEL_7
IS_PWR_PVD_LEVEL
PWR Extended PVD Mode
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
IS_PWR_PVD_MODE
DOCID026526 Rev 2
523/861
HAL RCC Generic Driver
UM1786
38
HAL RCC Generic Driver
38.1
RCC Firmware driver registers structures
38.1.1
RCC_ClkInitTypeDef
RCC_ClkInitTypeDef is defined in the stm32f3xx_hal_rcc.h
Data Fields





uint32_t ClockType
uint32_t SYSCLKSource
uint32_t AHBCLKDivider
uint32_t APB1CLKDivider
uint32_t APB2CLKDivider
Field Documentation





38.2
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
RCC Firmware driver API description
The following section lists the various functions of the RCC library.
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 disabled, and all peripherals are off except internal
SRAM, Flash and JTAG.



524/861
There is no prescaler on High speed (AHB) and Low speed (APB) busses; all
peripherals mapped on these busses are running at HSI speed.
The clock for all peripherals is switched off, except the SRAM and FLASH.
All GPIOs are in input floating state, except the JTAG pins which are assigned to be
used for debug purpose.
DOCID026526 Rev 2
UM1786
HAL RCC Generic Driver
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 busses prescalers
Enable the clock for the peripheral(s) to be used
Configure the clock source(s) for peripherals which clocks are not derived from the
System clock (RTC, ADC, I2C, I2S, TIM, USB FS)
Initialization and de-initialization functions
This section provide functions allowing to configure the internal/external oscillators (HSE,
HSI, LSE, LSI, PLL, CSS and MCO) and the System busses 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 clockis 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 busses clocks configuration
1.
2.
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 busses. You can use "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.
DOCID026526 Rev 2
525/861
HAL RCC Generic Driver
UM1786

3.
4.
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 (see Table 25: "Number of wait states (WS) according to
system clock (SYSCLK) frequency").
After reset, the System clock source is the HSI (8 MHz) with 0 WS and prefetch is
disabled.
Table 25: Number of wait states (WS) according to system clock (SYSCLK) frequency



38.2.3
Latency
SYSCLK clock frequency (MHz)
0WS (1CPU cycle)
0 ≤ SYSCLK ≤ 24
1WS (2CPU cycles)
24 < HCLK ≤ 48
2 WS (3CPU cycles)
48 < HCLK ≤ 72
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.











38.2.4
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_CCSCallback()
HAL_RCC_DeInit
Function Name
void HAL_RCC_DeInit (void )
Function Description
Resets the RCC clock configuration to the default reset state.
Return values

None
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, MCO
OFFAll interrupts disabled
This function doesn't modify the configuration of the
Peripheral clocksLSI, LSE and RTC clocks

526/861
DOCID026526 Rev 2
UM1786
38.2.5
38.2.6
HAL RCC Generic Driver
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.
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 busses 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 This parameter can be one of the
following values: FLASH_LATENCY_0: FLASH 0 Latency
cycle FLASH_LATENCY_1: FLASH 1 Latency cycle
FLASH_LATENCY_2: FLASH 2 Latency cycle
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 startup 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 startup 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.


38.2.7
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(such as PA8).
DOCID026526 Rev 2
527/861
HAL RCC Generic Driver
Parameters
UM1786

RCC_MCOx: specifies the output direction for the clock
source. This parameter can be one of the following values:
RCC_MCO: Clock source to output on MCO pin(such as
PA8).
RCC_MCOSource: specifies the clock source to output. This
parameter can be one of the following values:
RCC_MCOSOURCE_LSI: LSI clock selected as MCO source
RCC_MCOSOURCE_HSI: HSI clock selected as MCO
source RCC_MCOSOURCE_LSE: LSE clock selected as
MCO source RCC_MCOSOURCE_HSE: HSE clock selected
as MCO source RCC_MCOSOURCE_PLLCLK_DIV2: main
PLL clock divided by 2 selected as MCO source
RCC_MCOSOURCE_SYSCLK: System clock (SYSCLK)
selected as MCO source
RCC_MCODiv: specifies the MCOx prescaler. This
parameter can be one of the following values:
RCC_MCO_NODIV: no division applied to MCO clock


38.2.8
38.2.9
38.2.10
528/861
Return values

None
Notes

MCO pin (such as PA8) 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
Function Name
void HAL_RCC_DisableCSS (void )
Function Description
Disables the Clock Security System.
Return values

None
HAL_RCC_GetSysClockFreq
Function Name
uint32_t HAL_RCC_GetSysClockFreq (void )
Function Description
Returns the SYSCLK frequency.
Return values

SYSCLK frequency
DOCID026526 Rev 2
UM1786
HAL RCC Generic Driver
Notes









38.2.11
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

38.2.12
38.2.13
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 a value 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.h file
(default value 8 MHz).
(**) HSE_VALUE is a constant defined in stm32f3xx.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 baudrate 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_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
based on this function will be incorrect.
HAL_RCC_GetPCLK2Freq
DOCID026526 Rev 2
529/861
HAL RCC Generic Driver
Function Name
38.2.14
38.2.15
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
38.2.16
38.2.17
530/861
UM1786
uint32_t HAL_RCC_GetPCLK2Freq (void )

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_CCSCallback
Function Name
void HAL_RCC_CCSCallback (void )
Function Description
RCC Clock Security System interrupt callback.
Return values

None
DOCID026526 Rev 2
UM1786
38.3
HAL RCC Generic Driver
RCC Firmware driver defines
The following section lists the various define and macros of the module.
38.3.1
RCC
RCC
RCC AHB Clock Enable Disable
__GPIOA_CLK_ENABLE
__GPIOB_CLK_ENABLE
__GPIOC_CLK_ENABLE
__GPIOD_CLK_ENABLE
__GPIOF_CLK_ENABLE
__CRC_CLK_ENABLE
__DMA1_CLK_ENABLE
__SRAM_CLK_ENABLE
__FLITF_CLK_ENABLE
__TSC_CLK_ENABLE
__GPIOA_CLK_DISABLE
__GPIOB_CLK_DISABLE
__GPIOC_CLK_DISABLE
__GPIOD_CLK_DISABLE
__GPIOF_CLK_DISABLE
__CRC_CLK_DISABLE
__DMA1_CLK_DISABLE
__SRAM_CLK_DISABLE
__FLITF_CLK_DISABLE
__TSC_CLK_DISABLE
RCC AHB Clock Source
RCC_SYSCLK_DIV1
RCC_SYSCLK_DIV2
RCC_SYSCLK_DIV4
RCC_SYSCLK_DIV8
RCC_SYSCLK_DIV16
RCC_SYSCLK_DIV64
RCC_SYSCLK_DIV128
RCC_SYSCLK_DIV256
RCC_SYSCLK_DIV512
IS_RCC_SYSCLK_DIV
DOCID026526 Rev 2
531/861
HAL RCC Generic Driver
RCC AHB Force Release Reset
__AHB_FORCE_RESET
__GPIOA_FORCE_RESET
__GPIOB_FORCE_RESET
__GPIOC_FORCE_RESET
__GPIOD_FORCE_RESET
__GPIOF_FORCE_RESET
__TSC_FORCE_RESET
__AHB_RELEASE_RESET
__GPIOA_RELEASE_RESET
__GPIOB_RELEASE_RESET
__GPIOC_RELEASE_RESET
__GPIOD_RELEASE_RESET
__GPIOF_RELEASE_RESET
__TSC_RELEASE_RESET
RCC APB1 APB2 Clock Source
RCC_HCLK_DIV1
RCC_HCLK_DIV2
RCC_HCLK_DIV4
RCC_HCLK_DIV8
RCC_HCLK_DIV16
IS_RCC_HCLK_DIV
RCC APB1 Clock Enable Disable
__TIM2_CLK_ENABLE
__TIM6_CLK_ENABLE
__WWDG_CLK_ENABLE
__USART2_CLK_ENABLE
__USART3_CLK_ENABLE
__I2C1_CLK_ENABLE
__PWR_CLK_ENABLE
__DAC1_CLK_ENABLE
__TIM2_CLK_DISABLE
__TIM6_CLK_DISABLE
__WWDG_CLK_DISABLE
__USART2_CLK_DISABLE
__USART3_CLK_DISABLE
532/861
DOCID026526 Rev 2
UM1786
UM1786
HAL RCC Generic Driver
__I2C1_CLK_DISABLE
__PWR_CLK_DISABLE
__DAC1_CLK_DISABLE
RCC APB1 Force Release Reset
__APB1_FORCE_RESET
__TIM2_FORCE_RESET
__TIM6_FORCE_RESET
__WWDG_FORCE_RESET
__USART2_FORCE_RESET
__USART3_FORCE_RESET
__I2C1_FORCE_RESET
__PWR_FORCE_RESET
__DAC1_FORCE_RESET
__APB1_RELEASE_RESET
__TIM2_RELEASE_RESET
__TIM6_RELEASE_RESET
__WWDG_RELEASE_RESET
__USART2_RELEASE_RESET
__USART3_RELEASE_RESET
__I2C1_RELEASE_RESET
__PWR_RELEASE_RESET
__DAC1_RELEASE_RESET
RCC APB2 Clock Enable Disable
__SYSCFG_CLK_ENABLE
__TIM15_CLK_ENABLE
__TIM16_CLK_ENABLE
__TIM17_CLK_ENABLE
__USART1_CLK_ENABLE
__SYSCFG_CLK_DISABLE
__TIM15_CLK_DISABLE
__TIM16_CLK_DISABLE
__TIM17_CLK_DISABLE
__USART1_CLK_DISABLE
RCC APB2 Force Release Reset
__APB2_FORCE_RESET
__SYSCFG_FORCE_RESET
DOCID026526 Rev 2
533/861
HAL RCC Generic Driver
__TIM15_FORCE_RESET
UM1786
__TIM16_FORCE_RESET
__TIM17_FORCE_RESET
__USART1_FORCE_RESET
__APB2_RELEASE_RESET
__SYSCFG_RELEASE_RESET
__TIM15_RELEASE_RESET
__TIM16_RELEASE_RESET
__TIM17_RELEASE_RESET
__USART1_RELEASE_RESET
RCC BitAddress AliasRegion
RCC_OFFSET
RCC_CR_OFFSET
HSION_BitNumber
CR_HSION_BB
HSEON_BitNumber
CR_HSEON_BB
CSSON_BitNumber
CR_CSSON_BB
PLLON_BitNumber
CR_PLLON_BB
RCC_CFGR_OFFSET
PLLSRC_BitNumber
CFGR_PLLSRC_BB
RCC_CIR_OFFSET
RCC_BDCR_OFFSET
LSEON_BitNumber
BDCR_LSEON_BB
RTCEN_BitNumber
BDCR_RTCEN_BB
BDRST_BitNumber
BDCR_BDRST_BB
RCC_CSR_OFFSET
LSION_BitNumber
CSR_LSION_BB
RMVF_BitNumber
534/861
DOCID026526 Rev 2
UM1786
HAL RCC Generic Driver
CSR_RMVF_BB
CR_BYTE2_ADDRESS
CIR_BYTE1_ADDRESS
CIR_BYTE2_ADDRESS
CSR_BYTE1_ADDRESS
BDCR_BYTE0_ADDRESS
RCC Flag
CR_REG_INDEX
BDCR_REG_INDEX
CSR_REG_INDEX
RCC_FLAG_HSIRDY
RCC_FLAG_HSERDY
RCC_FLAG_PLLRDY
RCC_FLAG_LSERDY
RCC_FLAG_LSIRDY
RCC_FLAG_RMV
RCC_FLAG_OBLRST
RCC_FLAG_PINRST
RCC_FLAG_PORRST
RCC_FLAG_SFTRST
RCC_FLAG_IWDGRST
RCC_FLAG_WWDGRST
RCC_FLAG_LPWRRST
RCC Flags Interrupts Management
__HAL_RCC_ENABLE_IT
Description:

Enable RCC interrupt (Perform Byte access
to RCC_CIR[12:8] bits to enable the
selected interrupts.).
Parameters:

__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
enable

RCC_IT_LSERDY: LSE ready interrupt
enable

RCC_IT_HSIRDY: HSI ready interrupt
enable

RCC_IT_HSERDY: HSE ready
interrupt enable
DOCID026526 Rev 2
535/861
HAL RCC Generic Driver
UM1786

__HAL_RCC_DISABLE_IT
RCC_IT_PLLRDY: PLL ready interrupt
enable
Description:

Disable RCC interrupt (Perform Byte access
to RCC_CIR[12:8] bits to disable the
selected interrupts.).
Parameters:

__HAL_RCC_CLEAR_IT
__INTERRUPT__: specifies the RCC
interrupt sources to be disabled. This
parameter can be any combination of the
following values:

RCC_IT_LSIRDYIE: LSI ready interrupt
enable

RCC_IT_LSERDYIE: LSE ready
interrupt enable

RCC_IT_HSIRDYIE: HSI ready
interrupt enable

RCC_IT_HSERDYIE: HSE ready
interrupt enable

RCC_IT_PLLRDYIE: PLL ready
interrupt enable
Description:

Clear the RCC's interrupt pending bits (
Perform Byte access to RCC_CIR[23:16]
bits to clear the selected interrupt pending
bits.
Parameters:

__HAL_RCC_GET_IT
__IT__: specifies the interrupt pending bit to
clear. This parameter can be any
combination of the following values:

RCC_IT_LSIRDYC: LSI ready interrupt
clear

RCC_IT_LSERDYC: LSE ready
interrupt clear

RCC_IT_HSIRDYC: HSI ready interrupt
clear

RCC_IT_HSERDYC: HSE ready
interrupt clear

RCC_IT_PLLRDYC: PLL ready
interrupt clear

RCC_IT_CSSC: Clock Security System
interrupt clear
Description:

Check the RCC's interrupt has occurred or
not.
Parameters:

536/861
__IT__: specifies the RCC interrupt source
to check. This parameter can be one of the
DOCID026526 Rev 2
UM1786
HAL RCC Generic Driver
following values:

RCC_IT_LSIRDYF: LSI ready interrupt
flag

RCC_IT_LSERDYF: LSE ready
interrupt flag

RCC_IT_HSIRDYF: HSI ready interrupt
flag

RCC_IT_HSERDYF: HSE ready
interrupt flag

RCC_IT_PLLRDYF: PLL ready
interrupt flag

RCC_IT_CSSF: Clock Security System
interrupt flag
Return value:

The: new state of __IT__ (TRUE or FALSE).
__HAL_RCC_CLEAR_RESET_FLAGS
Description:
RCC_FLAG_MASK

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: 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).
__HAL_RCC_GET_FLAG
RCC Force Release Backup
DOCID026526 Rev 2
537/861
HAL RCC Generic Driver
__HAL_RCC_BACKUPRESET_FORCE
UM1786
__HAL_RCC_BACKUPRESET_RELEASE
RCC Get Clock source
__HAL_RCC_GET_SYSCLK_SOU
RCE
Description:

Macro to get the clock source used as system
clock.
Return value:

__HAL_RCC_GET_PLL_OSCSOU
RCE
The: clock source used as system clock. The
returned value can be one of the following
value:

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
Description:

Macro to get the oscillator used as PLL clock
source.
Return value:

The: oscillator used as PLL clock source. The
returned value can be one of the following:

RCC_PLLSOURCE_HSI: HSI oscillator is
used as PLL clock source.

RCC_PLLSOURCE_HSE: HSE oscillator is
used as PLL clock source.
RCC HSE Config
RCC_HSE_OFF
RCC_HSE_ON
RCC_HSE_BYPASS
IS_RCC_HSE
RCC HSE Configuration
__HAL_RCC_HSE_CONFIG
Description:

Macro to configure the External High Speed oscillator
(HSE).
Parameters:

538/861
__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
DOCID026526 Rev 2
UM1786
HAL RCC Generic Driver
RCC HSI Config
RCC_HSI_OFF
RCC_HSI_ON
IS_RCC_HSI
RCC_HSICALIBRATION_DEFAULT
IS_RCC_CALIBRATION_VALUE
RCC HSI Configuration
__HAL_RCC_HSI_ENABLE
__HAL_RCC_HSI_DISABLE
__HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST
Description:

Macro to adjust the Internal
High Speed oscillator (HSI)
calibration value.
Parameters:

__HSICalibrationValue__:
specifies the calibration
trimming value. This parameter
must be a number between 0
and 0x1F.
RCC I2C1 Clock Source
RCC_I2C1CLKSOURCE_HSI
RCC_I2C1CLKSOURCE_SYSCLK
IS_RCC_I2C1CLKSOURCE
RCC I2Cx Clock Config
__HAL_RCC_I2C1_CONFIG
Description:

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:
DOCID026526 Rev 2
539/861
HAL RCC Generic Driver
UM1786
System Clock selected as I2C1 clock
RCC Interrupt
RCC_IT_LSIRDY
RCC_IT_LSERDY
RCC_IT_HSIRDY
RCC_IT_HSERDY
RCC_IT_PLLRDY
RCC_IT_CSS
RCC_LSE_Config
RCC_LSE_OFF
RCC_LSE_ON
RCC_LSE_BYPASS
IS_RCC_LSE
RCC 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,
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
RCC LSI Config
RCC_LSI_OFF
RCC_LSI_ON
IS_RCC_LSI
RCC LSI Configuration
__HAL_RCC_LSI_ENABLE
__HAL_RCC_LSI_DISABLE
RCC MCOx Index
RCC_MCO
IS_RCC_MCO
RCC Oscillator Type
RCC_OSCILLATORTYPE_NONE
RCC_OSCILLATORTYPE_HSE
540/861
DOCID026526 Rev 2
UM1786
HAL RCC Generic Driver
RCC_OSCILLATORTYPE_HSI
RCC_OSCILLATORTYPE_LSE
RCC_OSCILLATORTYPE_LSI
IS_RCC_OSCILLATORTYPE
RCC PLL Config
RCC_PLL_NONE
RCC_PLL_OFF
RCC_PLL_ON
IS_RCC_PLL
RCC PLL Configuration
__HAL_RCC_PLL_ENABLE
__HAL_RCC_PLL_DISABLE
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
IS_RCC_PLL_MUL
RCC Private Define
HSE_TIMEOUT_VALUE
HSI_TIMEOUT_VALUE
LSI_TIMEOUT_VALUE
PLL_TIMEOUT_VALUE
CLOCKSWITCH_TIMEOUT_VALUE
RCC Private Macros
DOCID026526 Rev 2
541/861
HAL RCC Generic Driver
__MCO_CLK_ENABLE
UM1786
MCO_GPIO_PORT
MCO_PIN
RCC RTC Clock Configuration
__HAL_RCC_RTC_ENABLE
__HAL_RCC_RTC_DISABLE
__HAL_RCC_RTC_CONFIG
Description:

Macro to configure the RTC clock (RTCCLK).
Parameters:

__HAL_RCC_GET_RTC_SOURC
E
__RTCCLKSource__: specifies the RTC clock
source. This parameter can be one of the
following values:

RCC_RTCCLKSOURCE_NONE: 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
Description:

Macro to get the RTC clock source.
Return value:

The: clock source can be one of the following
values:

RCC_RTCCLKSOURCE_NONE: 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 selected as RTC
clock
RCC RTC Clock Source
RCC_RTCCLKSOURCE_NONE
RCC_RTCCLKSOURCE_LSE
RCC_RTCCLKSOURCE_LSI
RCC_RTCCLKSOURCE_HSE_DIV32
IS_RCC_RTCCLKSOURCE
RCC System Clock Source
RCC_SYSCLKSOURCE_HSI
RCC_SYSCLKSOURCE_HSE
542/861
DOCID026526 Rev 2
UM1786
HAL RCC Generic Driver
RCC_SYSCLKSOURCE_PLLCLK
IS_RCC_SYSCLKSOURCE
RCC System Clock Source Status
RCC_SYSCLKSOURCE_STATUS_HSI
RCC_SYSCLKSOURCE_STATUS_HSE
RCC_SYSCLKSOURCE_STATUS_PLLCLK
IS_RCC_SYSCLKSOURCE_STATUS
RCC System Clock Type
RCC_CLOCKTYPE_SYSCLK
RCC_CLOCKTYPE_HCLK
RCC_CLOCKTYPE_PCLK1
RCC_CLOCKTYPE_PCLK2
IS_RCC_CLOCKTYPE
RCC Timeout
LSE_TIMEOUT_VALUE
DBP_TIMEOUT_VALUE
RCC USART2 Clock Source
RCC_USART2CLKSOURCE_PCLK1
RCC_USART2CLKSOURCE_SYSCLK
RCC_USART2CLKSOURCE_LSE
RCC_USART2CLKSOURCE_HSI
IS_RCC_USART2CLKSOURCE
RCC USART3 Clock Source
RCC_USART3CLKSOURCE_PCLK1
RCC_USART3CLKSOURCE_SYSCLK
RCC_USART3CLKSOURCE_LSE
RCC_USART3CLKSOURCE_HSI
IS_RCC_USART3CLKSOURCE
RCC USARTx Clock Config
__HAL_RCC_USART1_CONFIG
Description:

Macro to configure the USART1 clock
(USART1CLK).
Parameters:

__USART1CLKSource__: specifies the
USART1 clock source. This parameter can be
one of the following values:

RCC_USART1CLKSOURCE_PCLK2 or
RCC_USART1CLKSOURCE_PCLK1:
PCLK2 or PCLK1 selected as USART1
DOCID026526 Rev 2
543/861
HAL RCC Generic Driver



__HAL_RCC_GET_USART1_SOUR
CE
UM1786
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 or
RCC_USART1CLKSOURCE_PCLK1:
PCLK2 or PCLK1 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:

Macro to get the USART2 clock source.
Return value:

544/861
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
DOCID026526 Rev 2
UM1786
HAL RCC Generic Driver

__HAL_RCC_USART3_CONFIG
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:

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 2
545/861
HAL RCC Extension Driver
UM1786
39
HAL RCC Extension Driver
39.1
RCCEx Firmware driver registers structures
39.1.1
RCC_PLLInitTypeDef
RCC_PLLInitTypeDef is defined in the stm32f3xx_hal_rcc_ex.h
Data Fields




uint32_t PLLState
uint32_t PLLSource
uint32_t PLLMUL
uint32_t PREDIV
Field Documentation




39.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
RCCEx_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
uint32_t RCC_PLLInitTypeDef::PREDIV
PREDIV: Predivision factor for PLL VCO input clock This parameter must be a value
of RCCEx_PLL_Prediv_Factor
RCC_OscInitTypeDef
RCC_OscInitTypeDef is defined in the stm32f3xx_hal_rcc_ex.h
Data Fields







uint32_t OscillatorType
uint32_t HSEState
uint32_t LSEState
uint32_t HSIState
uint32_t HSICalibrationValue
uint32_t LSIState
RCC_PLLInitTypeDef PLL
Field Documentation

546/861
uint32_t RCC_OscInitTypeDef::OscillatorType
The oscillators to be configured. This parameter can be a value of
RCC_Oscillator_Type
DOCID026526 Rev 2
UM1786
HAL RCC Extension Driver






39.1.3
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::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 calibration trimming value. 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_PeriphCLKInitTypeDef
RCC_PeriphCLKInitTypeDef is defined in the stm32f3xx_hal_rcc_ex.h
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 I2c3ClockSelection
uint32_t Adc12ClockSelection
uint32_t Adc34ClockSelection
uint32_t I2sClockSelection
uint32_t Tim1ClockSelection
uint32_t Tim2ClockSelection
uint32_t Tim34ClockSelection
uint32_t Tim8ClockSelection
uint32_t Tim15ClockSelection
uint32_t Tim16ClockSelection
uint32_t Tim17ClockSelection
uint32_t Tim20ClockSelection
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
DOCID026526 Rev 2
547/861
HAL RCC Extension Driver




















39.2
UM1786
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
uint32_t RCC_PeriphCLKInitTypeDef::I2c2ClockSelection
I2C2 clock source This parameter can be a value of RCCEx_I2C2_Clock_Source
uint32_t RCC_PeriphCLKInitTypeDef::I2c3ClockSelection
I2C3 clock source This parameter can be a value of RCCEx_I2C3_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::Tim2ClockSelection
TIM2 clock source This parameter can be a value of RCCEx_TIM2_Clock_Source
uint32_t RCC_PeriphCLKInitTypeDef::Tim34ClockSelection
TIM3 & TIM4 clock source This parameter can be a value of
RCCEx_TIM34_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::Tim15ClockSelection
TIM15 clock source This parameter can be a value of RCCEx_TIM15_Clock_Source
uint32_t RCC_PeriphCLKInitTypeDef::Tim16ClockSelection
TIM16 clock source This parameter can be a value of RCCEx_TIM16_Clock_Source
uint32_t RCC_PeriphCLKInitTypeDef::Tim17ClockSelection
TIM17 clock source This parameter can be a value of RCCEx_TIM17_Clock_Source
uint32_t RCC_PeriphCLKInitTypeDef::Tim20ClockSelection
TIM20 clock source This parameter can be a value of RCCEx_TIM20_Clock_Source
uint32_t RCC_PeriphCLKInitTypeDef::USBClockSelection
USB clock source This parameter can be a value of RCCEx_USB_Clock_Source
RCCEx Firmware driver API description
The following section lists the various functions of the RCCEx library.
548/861
DOCID026526 Rev 2
UM1786
39.2.1
HAL RCC Extension Driver
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) and RCC_BDCR register are set to their reset
values.





39.2.2
39.2.3
HAL_RCCEx_PeriphCLKConfig()
HAL_RCCEx_GetPeriphCLKConfig()
HAL_RCC_OscConfig()
HAL_RCC_GetOscConfig()
HAL_RCC_GetSysClockFreq()
HAL_RCCEx_PeriphCLKConfig
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,
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
DOCID026526 Rev 2
549/861
HAL RCC Extension Driver
39.2.4
39.2.5
39.2.6
UM1786
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.
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_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 a value 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.h file
(default value 8 MHz).
(**) HSE_VALUE is a constant defined in stm32f3xx.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.






550/861
DOCID026526 Rev 2
UM1786
HAL RCC Extension Driver


39.3
This function can be used by the user application to compute
the baudrate 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.
RCCEx Firmware driver defines
The following section lists the various define and macros of the module.
39.3.1
RCCEx
RCCEx
RCC Extended ADC12 Clock Source
RCC_ADC12PLLCLK_OFF
RCC_ADC12PLLCLK_DIV1
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
IS_RCC_ADC12PLLCLK_DIV
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
DOCID026526 Rev 2
551/861
HAL RCC Extension Driver
RCC_ADC34PLLCLK_DIV128
UM1786
RCC_ADC34PLLCLK_DIV256
IS_RCC_ADC34PLLCLK_DIV
RCC Extended ADCx Clock Config
__HAL_RCC_ADC12_CONFIG
Description:

Macro to configure the ADC1 & ADC2 clock
(ADC12CLK).
Parameters:

552/861
__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
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
DOCID026526 Rev 2
UM1786
HAL RCC Extension Driver
__HAL_RCC_GET_ADC12_SOURCE
Description:

Macro to get the ADC1 & ADC2 clock.
Return value:

__HAL_RCC_ADC34_CONFIG
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

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:

__ADC34CLKSource__: specifies the ADC3
& ADC4 clock source. This parameter can be
one of the following values:
DOCID026526 Rev 2
553/861
HAL RCC Extension Driver
UM1786













__HAL_RCC_GET_ADC34_SOURCE
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 &
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:

554/861
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
DOCID026526 Rev 2
UM1786










HAL RCC Extension Driver
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 &
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
__DMA2_CLK_ENABLE
__GPIOE_CLK_ENABLE
__ADC12_CLK_ENABLE
__ADC1_CLK_ENABLE
__ADC2_CLK_ENABLE
__DMA2_CLK_DISABLE
__GPIOE_CLK_DISABLE
__ADC12_CLK_DISABLE
__ADC1_CLK_DISABLE
__ADC2_CLK_DISABLE
__ADC34_CLK_ENABLE
__ADC34_CLK_DISABLE
__FMC_CLK_ENABLE
__GPIOG_CLK_ENABLE
DOCID026526 Rev 2
555/861
HAL RCC Extension Driver
__GPIOH_CLK_ENABLE
UM1786
__FMC_CLK_DISABLE
__GPIOG_CLK_DISABLE
__GPIOH_CLK_DISABLE
RCC Extended AHB Force Release Reset
__GPIOE_FORCE_RESET
__ADC12_FORCE_RESET
__ADC1_FORCE_RESET
__ADC2_FORCE_RESET
__GPIOE_RELEASE_RESET
__ADC12_RELEASE_RESET
__ADC1_RELEASE_RESET
__ADC2_RELEASE_RESET
__ADC34_FORCE_RESET
__ADC34_RELEASE_RESET
__FMC_FORCE_RESET
__GPIOG_FORCE_RESET
__GPIOH_FORCE_RESET
__FMC_RELEASE_RESET
__GPIOG_RELEASE_RESET
__GPIOH_RELEASE_RESET
RCC Extended APB1 Clock Enable Disable
__TIM3_CLK_ENABLE
__TIM4_CLK_ENABLE
__SPI2_CLK_ENABLE
__SPI3_CLK_ENABLE
__UART4_CLK_ENABLE
__UART5_CLK_ENABLE
__I2C2_CLK_ENABLE
__TIM3_CLK_DISABLE
__TIM4_CLK_DISABLE
__SPI2_CLK_DISABLE
__SPI3_CLK_DISABLE
__UART4_CLK_DISABLE
__UART5_CLK_DISABLE
__I2C2_CLK_DISABLE
556/861
DOCID026526 Rev 2
UM1786
HAL RCC Extension Driver
__TIM7_CLK_ENABLE
__TIM7_CLK_DISABLE
__USB_CLK_ENABLE
__USB_CLK_DISABLE
__CAN_CLK_ENABLE
__CAN_CLK_DISABLE
__I2C3_CLK_ENABLE
__I2C3_CLK_DISABLE
RCC Extended APB1 Force Release Reset
__TIM3_FORCE_RESET
__TIM4_FORCE_RESET
__SPI2_FORCE_RESET
__SPI3_FORCE_RESET
__UART4_FORCE_RESET
__UART5_FORCE_RESET
__I2C2_FORCE_RESET
__TIM3_RELEASE_RESET
__TIM4_RELEASE_RESET
__SPI2_RELEASE_RESET
__SPI3_RELEASE_RESET
__UART4_RELEASE_RESET
__UART5_RELEASE_RESET
__I2C2_RELEASE_RESET
__TIM7_FORCE_RESET
__TIM7_RELEASE_RESET
__USB_FORCE_RESET
__USB_RELEASE_RESET
__CAN_FORCE_RESET
__CAN_RELEASE_RESET
__I2C3_FORCE_RESET
__I2C3_RELEASE_RESET
RCC Extended APB2 Clock Enable Disable
__SPI1_CLK_ENABLE
__SPI1_CLK_DISABLE
__TIM8_CLK_ENABLE
__TIM8_CLK_DISABLE
DOCID026526 Rev 2
557/861
HAL RCC Extension Driver
__TIM1_CLK_ENABLE
UM1786
__TIM1_CLK_DISABLE
__SPI4_CLK_ENABLE
__SPI4_CLK_DISABLE
__TIM20_CLK_ENABLE
__TIM20_CLK_DISABLE
RCC Extended APB2 Force Release Reset
__SPI1_FORCE_RESET
__SPI1_RELEASE_RESET
__TIM8_FORCE_RESET
__TIM8_RELEASE_RESET
__TIM1_FORCE_RESET
__TIM1_RELEASE_RESET
__SPI4_FORCE_RESET
__SPI4_RELEASE_RESET
__TIM20_FORCE_RESET
__TIM20_RELEASE_RESET
RCC Extended I2C2 Clock Source
RCC_I2C2CLKSOURCE_HSI
RCC_I2C2CLKSOURCE_SYSCLK
IS_RCC_I2C2CLKSOURCE
RCC Extended I2C3 Clock Source
RCC_I2C3CLKSOURCE_HSI
RCC_I2C3CLKSOURCE_SYSCLK
IS_RCC_I2C3CLKSOURCE
RCC Extended I2Cx Clock Config
__HAL_RCC_I2C2_CONFIG
Description:

Macro to configure the I2C2 clock (I2C2CLK).
Parameters:

__HAL_RCC_GET_I2C2_SOURCE
Description:

558/861
__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
Macro to get the I2C2 clock source.
DOCID026526 Rev 2
UM1786
HAL RCC Extension Driver
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
Description:
__HAL_RCC_I2C3_CONFIG

Macro to configure the I2C3 clock (I2C3CLK).
Parameters:

__I2C3CLKSource__: specifies the I2C3 clock
source. This parameter can be one of the
following values:

RCC_I2C3CLKSOURCE_HSI: HSI
selected as I2C3 clock

RCC_I2C3CLKSOURCE_SYSCLK:
System Clock selected as I2C3 clock
Description:
__HAL_RCC_GET_I2C3_SOURCE

Macro to get the I2C3 clock source.
Return value:

The: clock source can be one of the following
values:

RCC_I2C3CLKSOURCE_HSI: HSI
selected as I2C3 clock

RCC_I2C3CLKSOURCE_SYSCLK:
System Clock selected as I2C3 clock
RCC Extended I2Sx Clock Config
Description:
__HAL_RCC_I2S_CONFIG

Macro to configure the I2S clock source
(I2SCLK).
Parameters:

__HAL_RCC_GET_I2S_SOURCE
__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
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
DOCID026526 Rev 2
559/861
HAL RCC Extension Driver

UM1786
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
RCC_I2SCLKSOURCE_EXT
IS_RCC_I2SCLKSOURCE
RCC Extended MCOx Clock Config
__HAL_RCC_MCO_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_MCOSOURCE_HSI: HSI selected as MCO
clock

RCC_MCOSOURCE_HSE: HSE selected as
MCO clock

RCC_MCOSOURCE_LSI: LSI selected as MCO
clock

RCC_MCOSOURCE_LSE: LSE selected as
MCO clock

RCC_MCOSOURCE_PLLCLK_DIV2: PLLCLK
Divided by 2 selected as MCO clock

RCC_MCOSOURCE_SYSCLK: System Clock
selected as MCO clock
__MCODiv__: specifies the MCO clock prescaler.
This parameter can be one of the following values:

RCC_MCO_NODIV: No division applied on MCO
clock source
RCC Extended MCOx Clock Prescaler
RCC_MCO_DIV1
RCC_MCO_DIV2
RCC_MCO_DIV4
RCC_MCO_DIV8
RCC_MCO_DIV16
RCC_MCO_DIV32
RCC_MCO_DIV64
RCC_MCO_DIV128
IS_RCC_MCODIV
RCC Extended MCO Clock Source
RCC_MCOSOURCE_NONE
560/861
DOCID026526 Rev 2
UM1786
HAL RCC Extension Driver
RCC_MCOSOURCE_LSI
RCC_MCOSOURCE_LSE
RCC_MCOSOURCE_SYSCLK
RCC_MCOSOURCE_HSI
RCC_MCOSOURCE_HSE
RCC_MCOSOURCE_PLLCLK_DIV1
RCC_MCOSOURCE_PLLCLK_DIV2
IS_RCC_MCOSOURCE
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_PERIPHCLK_I2C3
RCC_PERIPHCLK_TIM2
RCC_PERIPHCLK_TIM34
RCC_PERIPHCLK_TIM15
RCC_PERIPHCLK_TIM16
RCC_PERIPHCLK_TIM17
RCC_PERIPHCLK_TIM20
IS_RCC_PERIPHCLK
RCC Extended PLL Clock Source
RCC_PLLSOURCE_HSI
RCC_PLLSOURCE_HSE
IS_RCC_PLLSOURCE
RCC Extended PLL Configuration
DOCID026526 Rev 2
561/861
HAL RCC Extension Driver
__HAL_RCC_PLL_CONFIG
UM1786
Description:

Macro to configure the PLL clock source, multiplication
and division factors.
Parameters:



__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
__PREDIV__: specifies the predivider factor for PLL
VCO input clock This parameter must be a number
between RCC_PREDIV_DIV1 and
RCC_PREDIV_DIV16.
__PLLMUL__: specifies the multiplication factor for PLL
VCO input clock This parameter must be a number
between RCC_PLL_MUL2 and RCC_PLL_MUL16.
RCC Extended PLL Prediv Factor
RCC_PREDIV_DIV1
RCC_PREDIV_DIV2
RCC_PREDIV_DIV3
RCC_PREDIV_DIV4
RCC_PREDIV_DIV5
RCC_PREDIV_DIV6
RCC_PREDIV_DIV7
RCC_PREDIV_DIV8
RCC_PREDIV_DIV9
RCC_PREDIV_DIV10
RCC_PREDIV_DIV11
RCC_PREDIV_DIV12
RCC_PREDIV_DIV13
RCC_PREDIV_DIV14
RCC_PREDIV_DIV15
RCC_PREDIV_DIV16
IS_RCC_PREDIV
RCC Extended Private Define
HSE_TIMEOUT_VALUE
HSI_TIMEOUT_VALUE
LSI_TIMEOUT_VALUE
PLL_TIMEOUT_VALUE
562/861
DOCID026526 Rev 2
UM1786
HAL RCC Extension Driver
CLOCKSWITCH_TIMEOUT_VALUE
RCC Extended TIM15 Clock Source
RCC_TIM15CLK_HCLK
RCC_TIM15CLK_PLLCLK
IS_RCC_TIM15CLKSOURCE
RCC Extended TIM16 Clock Source
RCC_TIM16CLK_HCLK
RCC_TIM16CLK_PLLCLK
IS_RCC_TIM16CLKSOURCE
RCC Extended TIM17 Clock Source
RCC_TIM17CLK_HCLK
RCC_TIM17CLK_PLLCLK
IS_RCC_TIM17CLKSOURCE
RCC Extended TIM1 Clock Source
RCC_TIM1CLK_HCLK
RCC_TIM1CLK_PLLCLK
IS_RCC_TIM1CLKSOURCE
RCC Extended TIM20 Clock Source
RCC_TIM20CLK_HCLK
RCC_TIM20CLK_PLLCLK
IS_RCC_TIM20CLKSOURCE
RCC Extended TIM2 Clock Source
RCC_TIM2CLK_HCLK
RCC_TIM2CLK_PLLCLK
IS_RCC_TIM2CLKSOURCE
RCC Extended TIM3 & TIM4 Clock Source
RCC_TIM34CLK_HCLK
RCC_TIM34CLK_PLLCLK
IS_RCC_TIM3CLKSOURCE
RCC Extended TIM8 Clock Source
RCC_TIM8CLK_HCLK
RCC_TIM8CLK_PLLCLK
IS_RCC_TIM8CLKSOURCE
RCC Extended TIMx Clock Config
__HAL_RCC_TIM1_CONFIG
Description:

Macro to configure the TIM1 clock (TIM1CLK).
DOCID026526 Rev 2
563/861
HAL RCC Extension Driver
UM1786
Parameters:

__HAL_RCC_GET_TIM1_SOURCE
__TIM1CLKSource__: specifies the TIM1
clock source. This parameter can be one of
the following values:

RCC_TIM1CLKSOURCE_HCLK: HCLK
selected as TIM1 clock

RCC_TIM1CLKSOURCE_PLL: 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_TIM1CLKSOURCE_HCLK: HCLK
selected as TIM1 clock

RCC_TIM1CLKSOURCE_PLL: 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_TIM8CLKSOURCE_HCLK: HCLK
selected as TIM8 clock

RCC_TIM8CLKSOURCE_PLL: PLL
Clock selected as TIM8 clock
Description:

Macro to get the TIM8 clock (TIM8CLK).
Return value:

__HAL_RCC_TIM2_CONFIG
The: clock source can be one of the following
values:

RCC_TIM8CLKSOURCE_HCLK: HCLK
selected as TIM8 clock

RCC_TIM8CLKSOURCE_PLL: PLL
Clock selected as TIM8 clock
Description:

Macro to configure the TIM2 clock (TIM2CLK).
Parameters:

564/861
__TIM2CLKSource__: specifies the TIM2
clock source. This parameter can be one of
the following values:

RCC_TIM2CLK_HCLK: HCLK selected
as TIM2 clock

RCC_TIM2CLK_PLL: PLL Clock selected
DOCID026526 Rev 2
UM1786
HAL RCC Extension Driver
as TIM2 clock
__HAL_RCC_GET_TIM2_SOURCE
Description:

Macro to get the TIM2 clock (TIM2CLK).
Return value:

__HAL_RCC_TIM34_CONFIG
The: clock source can be one of the following
values:

RCC_TIM2CLK_HCLK: HCLK selected
as TIM2 clock

RCC_TIM2CLK_PLL: PLL Clock selected
as TIM2 clock
Description:

Macro to configure the TIM3 & TIM4 clock
(TIM34CLK).
Parameters:

__HAL_RCC_GET_TIM34_SOURCE
__TIM34CLKSource__: specifies the TIM3 &
TIM4 clock source. This parameter can be
one of the following values:

RCC_TIM34CLK_HCLK: HCLK selected
as TIM3 & TIM4 clock

RCC_TIM34CLK_PLL: PLL Clock
selected as TIM3 & TIM4 clock
Description:

Macro to get the TIM3 & TIM4 clock
(TIM34CLK).
Return value:

__HAL_RCC_TIM15_CONFIG
The: clock source can be one of the following
values:

RCC_TIM34CLK_HCLK: HCLK selected
as TIM3 & TIM4 clock

RCC_TIM34CLK_PLL: PLL Clock
selected as TIM3 & TIM4 clock
Description:

Macro to configure the TIM15 clock
(TIM15CLK).
Parameters:

__HAL_RCC_GET_TIM15_SOURCE
__TIM15CLKSource__: specifies the TIM15
clock source. This parameter can be one of
the following values:

RCC_TIM15CLK_HCLK: HCLK selected
as TIM15 clock

RCC_TIM15CLK_PLL: PLL Clock
selected as TIM15 clock
Description:

Macro to get the TIM15 clock (TIM15CLK).
DOCID026526 Rev 2
565/861
HAL RCC Extension Driver
UM1786
Return value:

__HAL_RCC_TIM16_CONFIG
The: clock source can be one of the following
values:

RCC_TIM15CLK_HCLK: HCLK selected
as TIM15 clock

RCC_TIM15CLK_PLL: PLL Clock
selected as TIM15 clock
Description:

Macro to configure the TIM16 clock
(TIM16CLK).
Parameters:

__HAL_RCC_GET_TIM16_SOURCE
__TIM16CLKSource__: specifies the TIM16
clock source. This parameter can be one of
the following values:

RCC_TIM16CLK_HCLK: HCLK selected
as TIM16 clock

RCC_TIM16CLK_PLL: PLL Clock
selected as TIM16 clock
Description:

Macro to get the TIM16 clock (TIM16CLK).
Return value:

__HAL_RCC_TIM17_CONFIG
The: clock source can be one of the following
values:

RCC_TIM16CLK_HCLK: HCLK selected
as TIM16 clock

RCC_TIM16CLK_PLL: PLL Clock
selected as TIM16 clock
Description:

Macro to configure the TIM17 clock
(TIM17CLK).
Parameters:

__HAL_RCC_GET_TIM17_SOURCE
__TIM17CLKSource__: specifies the TIM17
clock source. This parameter can be one of
the following values:

RCC_TIM17CLK_HCLK: HCLK selected
as TIM17 clock

RCC_TIM17CLK_PLL: PLL Clock
selected as TIM17 clock
Description:

Macro to get the TIM17 clock (TIM17CLK).
Return value:

566/861
The: clock source can be one of the following
values:

RCC_TIM17CLK_HCLK: HCLK selected
as TIM17 clock

RCC_TIM17CLK_PLL: PLL Clock
DOCID026526 Rev 2
UM1786
HAL RCC Extension Driver
selected as TIM17 clock
__HAL_RCC_TIM20_CONFIG
Description:

Macro to configure the TIM20 clock
(TIM20CLK).
Parameters:

__HAL_RCC_GET_TIM20_SOURCE
__TIM20CLKSource__: specifies the TIM20
clock source. This parameter can be one of
the following values:

RCC_TIM20CLK_HCLK: HCLK selected
as TIM20 clock

RCC_TIM20CLK_PLL: PLL Clock
selected as TIM20 clock
Description:

Macro to get the TIM20 clock (TIM20CLK).
Return value:

The: clock source can be one of the following
values:

RCC_TIM20CLK_HCLK: HCLK selected
as TIM20 clock

RCC_TIM20CLK_PLL: PLL Clock
selected as TIM20 clock
RCC Extended UART4 Clock Source
RCC_UART4CLKSOURCE_PCLK1
RCC_UART4CLKSOURCE_SYSCLK
RCC_UART4CLKSOURCE_LSE
RCC_UART4CLKSOURCE_HSI
IS_RCC_UART4CLKSOURCE
RCC Extended UART5 Clock Source
RCC_UART5CLKSOURCE_PCLK1
RCC_UART5CLKSOURCE_SYSCLK
RCC_UART5CLKSOURCE_LSE
RCC_UART5CLKSOURCE_HSI
IS_RCC_UART5CLKSOURCE
RCC Extended UARTx Clock Config
__HAL_RCC_UART4_CONFIG
Description:

Macro to configure the UART4 clock
(UART4CLK).
Parameters:

__UART4CLKSource__: specifies the UART4
clock source. This parameter can be one of
the following values:

RCC_UART4CLKSOURCE_PCLK1:
DOCID026526 Rev 2
567/861
HAL RCC Extension Driver



__HAL_RCC_GET_UART4_SOURC
E
UM1786
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:

__HAL_RCC_UART5_CONFIG
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:
System Clock selected as UART4 clock

RCC_UART4CLKSOURCE_LSE: LSE
selected as UART4 clock
Description:

Macro to configure the UART5 clock
(UART5CLK).
Parameters:

__HAL_RCC_GET_UART5_SOURC
E
__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:

Macro to get the UART5 clock source.
Return value:

568/861
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
DOCID026526 Rev 2
UM1786
HAL RCC Extension Driver
RCC Extended USART1 Clock Source
RCC_USART1CLKSOURCE_PCLK2
RCC_USART1CLKSOURCE_SYSCLK
RCC_USART1CLKSOURCE_LSE
RCC_USART1CLKSOURCE_HSI
IS_RCC_USART1CLKSOURCE
RCC Extended USBx Clock Config
__HAL_RCC_USB_CONFIG
Description:

Macro to configure the USB clock (USBCLK).
Parameters:

__HAL_RCC_GET_USB_SOURCE
__USBCLKSource__: specifies the USB clock
source. This parameter can be one of the
following values:

RCC_USBPLLCLK_DIV1: PLL Clock
divided by 1 selected as USB clock

RCC_USBPLLCLK_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_USBPLLCLK_DIV1: PLL Clock
divided by 1 selected as USB clock

RCC_USBPLLCLK_DIV1_5: PLL Clock
divided by 1.5 selected as USB clock
RCC Extended USB Clock Source
RCC_USBPLLCLK_DIV1
RCC_USBPLLCLK_DIV1_5
IS_RCC_USBCLKSOURCE
DOCID026526 Rev 2
569/861
HAL RTC Generic Driver
UM1786
40
HAL RTC Generic Driver
40.1
RTC Firmware driver registers structures
40.1.1
RTC_InitTypeDef
RTC_InitTypeDef is defined in the stm32f3xx_hal_rtc.h
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
RTC_TimeTypeDef is defined in the stm32f3xx_hal_rtc.h
Data Fields





570/861
uint8_t Hours
uint8_t Minutes
uint8_t Seconds
uint32_t SubSeconds
uint8_t TimeFormat
DOCID026526 Rev 2
UM1786
HAL RTC Generic Driver


uint32_t DayLightSaving
uint32_t StoreOperation
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
uint32_t RTC_TimeTypeDef::SubSeconds
Specifies the RTC Time SubSeconds. 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::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
RTC_DateTypeDef is defined in the stm32f3xx_hal_rtc.h
Data Fields




uint8_t WeekDay
uint8_t Month
uint8_t Date
uint8_t Year
Field Documentation



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
uint8_t RTC_DateTypeDef::Date
Specifies the RTC Date. This parameter must be a number between Min_Data = 1
and Max_Data = 31
DOCID026526 Rev 2
571/861
HAL RTC Generic Driver

40.1.4
UM1786
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
RTC_AlarmTypeDef is defined in the stm32f3xx_hal_rtc.h
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
RTC_HandleTypeDef is defined in the stm32f3xx_hal_rtc.h
Data Fields




RTC_TypeDef * Instance
RTC_InitTypeDef Init
HAL_LockTypeDef Lock
__IO HAL_RTCStateTypeDef State
Field Documentation
572/861
DOCID026526 Rev 2
UM1786
HAL RTC Generic Driver




40.2
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
RTC Firmware driver API description
The following section lists the various functions of the RTC library.
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:
DOCID026526 Rev 2
573/861
HAL RTC Generic Driver
UM1786
1.
Enable the Power Controller (PWR) APB1 interface clock using the
__PWR_CLK_ENABLE() function.
2.
Enable access to RTC domain using the HAL_PWR_EnableBkUpAccess() function.
3.
Select the RTC clock source using the __HAL_RCC_RTC_CONFIG() function.
4.
Enable RTC Clock using the __HAL_RCC_RTC_ENABLE() function.
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

574/861
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
DOCID026526 Rev 2
UM1786
HAL RTC Generic Driver
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


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 provide functions allowing to initialize and configure the RTC Prescaler
(Synchronous and Asynchronous), RTC Hour format, disable RTC registers Write
protection, enter and exit the RTC initialization mode, RTC registers synchronization check
and reference clock detection enable.
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 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).
HAL_RTC_Init()
HAL_RTC_DeInit()
HAL_RTC_MspInit()
HAL_RTC_MspDeInit()
DOCID026526 Rev 2
575/861
HAL RTC Generic Driver
40.2.7
UM1786
RTC Time and Date functions
This section provide functions allowing to configure Time and Date features




40.2.8
HAL_RTC_SetTime()
HAL_RTC_GetTime()
HAL_RTC_SetDate()
HAL_RTC_GetDate()
RTC Alarm functions
This section provide functions allowing to configure Alarm feature







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()
Peripheral Control functions
This subsection provides functions allowing to


40.2.10
Wait for RTC Time and Date Synchronization
HAL_RTC_WaitForSynchro()
Peripheral State functions
This subsection provides functions allowing to


40.2.11
40.2.12
Get RTC state
HAL_RTC_GetState()
HAL_RTC_Init
Function Name
HAL_StatusTypeDef HAL_RTC_Init (RTC_HandleTypeDef *
hrtc)
Function Description
Initializes the RTC peripheral.
Parameters

hrtc: RTC handle
Return values

HAL status
HAL_RTC_DeInit
Function Name
576/861
HAL_StatusTypeDef HAL_RTC_DeInit (RTC_HandleTypeDef *
hrtc)
DOCID026526 Rev 2
UM1786
40.2.13
40.2.14
40.2.15
40.2.16
HAL RTC Generic Driver
Function Description
DeInitializes 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
Initializes the RTC MSP.
Parameters

hrtc: RTC handle
Return values

None
HAL_RTC_MspDeInit
Function Name
void HAL_RTC_MspDeInit (RTC_HandleTypeDef * hrtc)
Function Description
DeInitializes the RTC MSP.
Parameters

hrtc: RTC handle
Return values

None
HAL_RTC_SetTime
Function Name
HAL_StatusTypeDef HAL_RTC_SetTime (RTC_HandleTypeDef
* hrtc, RTC_TimeTypeDef * sTime, uint32_t Format)
Function Description
Sets 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: FORMAT_BIN:
Binary data format 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
Gets 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: FORMAT_BIN:
DOCID026526 Rev 2
577/861
HAL RTC Generic Driver
UM1786
Binary data format FORMAT_BCD: BCD data format
40.2.17
40.2.18
40.2.19
578/861
Return values

HAL status
Notes

Call HAL_RTC_GetDate() after HAL_RTC_GetTime() to
unlock the values in the higher-order calendar shadow
registers.
HAL_RTC_SetDate
Function Name
HAL_StatusTypeDef HAL_RTC_SetDate (RTC_HandleTypeDef
* hrtc, RTC_DateTypeDef * sDate, uint32_t Format)
Function Description
Sets 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: FORMAT_BIN:
Binary data format FORMAT_BCD: BCD data format
Return values

HAL status
HAL_RTC_GetDate
Function Name
HAL_StatusTypeDef HAL_RTC_GetDate (RTC_HandleTypeDef
* hrtc, RTC_DateTypeDef * sDate, uint32_t Format)
Function Description
Gets 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: FORMAT_BIN :
Binary data format 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
Sets the specified RTC Alarm.
Parameters



hrtc: RTC handle
sAlarm: P