DM 00122015
DM 00122015
DM 00122015
User manual
Description of STM32F0xx HAL drivers
Introduction
TM
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 STM32CubeF0 for
STM32F0 series)
The STM32Cube HAL, an STM32 abstraction layer embedded software, ensuring maximized
portability across STM32 portfolio
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:
November 2014
DocID026525 Rev 1
1/692
www.st.com
Contents
UM1785
Contents
1
2.2
2/692
2.1.1
2.1.2
2.2.2
2.2.3
2.3
2.4
2.5
2.5.2
2.5.3
2.6
2.7
2.7.2
2.8
2.9
2.10
HAL configuration............................................................................ 53
2.11
2.12
2.11.1
Clock ................................................................................................. 54
2.11.2
GPIOs ............................................................................................... 55
2.11.3
2.11.4
PWR ................................................................................................. 57
2.11.5
EXTI .................................................................................................. 57
2.11.6
DMA .................................................................................................. 58
2.12.2
2.12.3
2.12.4
UM1785
Contents
3.1
3.2
3.1.2
3.1.3
3.1.4
HAL_Init ............................................................................................ 71
3.1.5
HAL_DeInit ....................................................................................... 71
3.1.6
HAL_MspInit ..................................................................................... 72
3.1.7
HAL_MspDeInit ................................................................................ 72
3.1.8
HAL_InitTick ..................................................................................... 72
3.1.9
HAL_IncTick ..................................................................................... 73
3.1.10
HAL_GetTick .................................................................................... 73
3.1.11
HAL_SuspendTick ............................................................................ 73
3.1.12
HAL_ResumeTick............................................................................. 74
3.1.13
HAL_Delay ....................................................................................... 74
3.1.14
HAL_GetHalVersion ......................................................................... 75
3.1.15
HAL_GetREVID ................................................................................ 75
3.1.16
HAL_GetDEVID ................................................................................ 75
3.1.17
HAL_EnableDBGStopMode ............................................................. 75
3.1.18
HAL_DisableDBGStopMode ............................................................ 76
3.1.19
HAL_EnableDBGStandbyMode ....................................................... 76
3.1.20
HAL_DisableDBGStandbyMode ...................................................... 76
HAL ................................................................................................... 77
4.2
ADC_InitTypeDef .............................................................................. 81
4.1.2
ADC_ChannelConfTypeDef ............................................................. 82
4.1.3
ADC_AnalogWDGConfTypeDef ....................................................... 83
4.1.4
ADC_HandleTypeDef ....................................................................... 84
4.2.2
4.2.3
4.2.4
4.2.5
4.2.6
4.2.7
HAL_ADC_Init .................................................................................. 87
4.2.8
HAL_ADC_DeInit .............................................................................. 87
DocID026525 Rev 1
3/692
Contents
4.3
4.2.9
UM1785
HAL_ADC_MspInit ........................................................................... 88
4.2.10
HAL_ADC_MspDeInit ....................................................................... 88
4.2.11
HAL_ADC_Start ............................................................................... 88
4.2.12
HAL_ADC_Stop ................................................................................ 89
4.2.13
HAL_ADC_PollForConversion ......................................................... 89
4.2.14
HAL_ADC_PollForEvent .................................................................. 89
4.2.15
HAL_ADC_Start_IT .......................................................................... 90
4.2.16
HAL_ADC_Stop_IT .......................................................................... 90
4.2.17
HAL_ADC_Start_DMA ..................................................................... 90
4.2.18
HAL_ADC_Stop_DMA...................................................................... 91
4.2.19
HAL_ADC_GetValue ........................................................................ 91
4.2.20
HAL_ADC_IRQHandler .................................................................... 92
4.2.21
HAL_ADC_ConvCpltCallback .......................................................... 92
4.2.22
HAL_ADC_ConvHalfCpltCallback .................................................... 92
4.2.23
HAL_ADC_LevelOutOfWindowCallback .......................................... 93
4.2.24
HAL_ADC_ErrorCallback ................................................................. 93
4.2.25
HAL_ADC_ConfigChannel ............................................................... 93
4.2.26
HAL_ADC_AnalogWDGConfig ........................................................ 94
4.2.27
HAL_ADC_GetState ......................................................................... 94
4.2.28
HAL_ADC_GetError ......................................................................... 95
5.2
5.1.2
5.1.3
5.1.4
6.2
4/692
ADC .................................................................................................. 95
6.1.2
6.1.3
CanTxMsgTypeDef......................................................................... 110
6.1.4
6.1.5
UM1785
Contents
6.3
6.2.1
6.2.2
6.2.3
6.2.4
6.2.5
6.2.6
HAL_CAN_ConfigFilter................................................................... 114
6.2.7
6.2.8
6.2.9
6.2.10
6.2.11
6.2.12
6.2.13
6.2.14
6.2.15
6.2.16
6.2.17
6.2.18
6.2.19
6.2.20
6.2.21
7.2
7.1.2
7.2.2
7.2.3
7.2.4
7.2.5
7.2.6
7.2.7
7.2.8
7.2.9
7.2.10
5/692
Contents
7.3
7.2.11
UM1785
HAL_CEC_Transmit_IT .................................................................. 134
7.2.12
7.2.13
7.2.14
7.2.15
7.2.16
7.2.17
7.2.18
8.2
8.3
8.1.2
8.2.2
8.2.3
8.2.4
8.2.5
8.2.6
8.2.7
8.2.8
8.2.9
8.2.10
HAL_COMP_MspDeInit.................................................................. 150
8.2.11
8.2.12
8.2.13
8.2.14
8.2.15
8.2.16
8.2.17
8.2.18
8.2.19
HAL_COMP_GetState.................................................................... 153
6/692
UM1785
Contents
9.2
9.1.1
9.1.2
9.1.3
9.1.4
9.1.5
9.1.6
HAL_NVIC_DisableIRQ.................................................................. 161
9.1.7
HAL_NVIC_SystemReset............................................................... 161
9.1.8
9.1.9
9.1.10
9.1.11
9.1.12
9.1.13
9.1.14
9.1.15
10
10.2
10.1.2
10.2.2
10.2.3
10.2.4
10.2.5
10.2.6
10.2.7
10.2.8
HAL_CRC_MspDeInit..................................................................... 169
10.2.9
10.3
11
7/692
Contents
11.2
11.1.1
UM1785
Product specific features ................................................................ 173
11.1.2
11.1.3
11.1.4
11.1.5
11.1.6
HAL_CRCEx_Output_Data_Reverse............................................. 174
11.1.7
12
12.2
12.1.2
12.2.2
12.2.3
12.2.4
12.2.5
12.2.6
12.2.7
12.2.8
12.2.9
DocID026525 Rev 1
UM1785
Contents
12.3
13
13.1.2
13.1.3
13.1.4
13.1.5
13.1.6
13.1.7
13.1.8
13.1.9
13.2
14
14.2
14.1.2
__DMA_HandleTypeDef................................................................. 202
14.2.2
14.2.3
14.2.4
14.2.5
14.2.6
14.2.7
14.2.8
9/692
Contents
14.2.9
UM1785
HAL_DMA_Abort ............................................................................ 206
14.3
15
16
DMAEx............................................................................................ 213
16.2
16.1.2
16.1.3
16.2.2
16.2.3
16.2.4
16.2.5
16.2.6
16.2.7
16.2.8
16.2.9
16.3
17
10/692
UM1785
Contents
17.2
17.1.2
17.1.3
17.1.4
17.1.5
17.1.6
17.1.7
17.1.8
17.1.9
18
18.2
18.2.2
18.2.3
18.2.4
18.2.5
18.2.6
18.2.7
18.2.8
18.2.9
18.3
19
20
20.2
20.1.2
11/692
Contents
20.2.2
UM1785
Initialization and Configuration functions ........................................ 252
20.2.3
20.2.4
20.2.5
20.2.6
20.2.7
20.2.8
20.2.9
20.3
12/692
UM1785
21
Contents
21.2
21.1.2
21.1.3
21.1.4
21.1.5
21.1.6
21.1.7
22
22.2
22.1.2
22.2.2
22.2.3
22.2.4
22.2.5
22.2.6
22.2.7
HAL_I2S_MspInit............................................................................ 281
22.2.8
22.2.9
DocID026525 Rev 1
13/692
Contents
UM1785
22.2.22 HAL_I2S_RxCpltCallback .............................................................. 287
22.2.23 HAL_I2S_ErrorCallback ................................................................. 288
22.2.24 HAL_I2S_GetState ......................................................................... 288
22.2.25 HAL_I2S_GetError ......................................................................... 288
22.3
23
23.2
23.1.2
23.2.2
23.2.3
23.2.4
23.2.5
23.2.6
HAL_IRDA_DeInit........................................................................... 298
23.2.7
23.2.8
23.2.9
23.3
24
25
14/692
UM1785
Contents
25.1
25.2
25.1.2
25.2.2
25.2.3
25.2.4
25.2.5
25.2.6
25.2.7
25.2.8
25.2.9
25.3
26
26.2
26.1.2
26.1.3
26.2.2
26.2.3
26.2.4
26.2.5
26.2.6
26.2.7
26.2.8
26.2.9
DocID026525 Rev 1
15/692
Contents
UM1785
26.2.16 HAL_PCD_SOFCallback ................................................................ 326
26.2.17 HAL_PCD_ResetCallback .............................................................. 326
26.2.18 HAL_PCD_SuspendCallback ......................................................... 326
26.2.19 HAL_PCD_ResumeCallback .......................................................... 327
26.2.20 HAL_PCD_ISOOUTIncompleteCallback........................................ 327
26.2.21 HAL_PCD_ISOINIncompleteCallback............................................ 327
26.2.22 HAL_PCD_ConnectCallback .......................................................... 328
26.2.23 HAL_PCD_DisconnectCallback ..................................................... 328
26.2.24 HAL_PCD_DevConnect ................................................................. 328
26.2.25 HAL_PCD_DevDisconnect ............................................................. 329
26.2.26 HAL_PCD_SetAddress .................................................................. 329
26.2.27 HAL_PCD_EP_Open ..................................................................... 329
26.2.28 HAL_PCD_EP_Close ..................................................................... 330
26.2.29 HAL_PCD_EP_Receive ................................................................. 330
26.2.30 HAL_PCD_EP_GetRxCount .......................................................... 331
26.2.31 HAL_PCD_EP_Transmit ................................................................ 331
26.2.32 HAL_PCD_EP_SetStall .................................................................. 331
26.2.33 HAL_PCD_EP_ClrStall................................................................... 332
26.2.34 HAL_PCD_EP_Flush ..................................................................... 332
26.2.35 HAL_PCD_ActiveRemoteWakeup ................................................. 332
26.2.36 HAL_PCD_DeActiveRemoteWakeup............................................. 333
26.2.37 HAL_PCD_GetState ....................................................................... 333
26.3
27
28
27.1.2
16/692
28.1.2
28.1.3
28.1.4
HAL_PWR_DisableBkUpAccess.................................................... 346
28.1.5
28.1.6
28.1.7
28.1.8
UM1785
Contents
28.1.9
28.2
29
29.2
29.2.2
29.2.3
HAL_PWR_EnablePVD.................................................................. 354
29.2.4
29.2.5
29.2.6
29.2.7
29.2.8
29.2.9
29.3
30
30.2
30.1.2
30.1.3
30.2.2
30.2.3
30.2.4
30.2.5
30.2.6
17/692
Contents
30.2.7
UM1785
HAL_RCC_ClockConfig ................................................................. 365
30.2.8
30.2.9
30.3
31
31.2
31.1.2
31.1.3
31.2.2
31.2.3
31.2.4
31.2.5
31.2.6
31.2.7
31.2.8
HAL_RCCEx_CRSConfig............................................................... 392
31.2.9
31.3
32
18/692
32.1.2
RTC_TimeTypeDef......................................................................... 405
32.1.3
32.1.4
UM1785
Contents
32.1.5
32.2
32.2.2
32.2.3
32.2.4
32.2.5
32.2.6
32.2.7
32.2.8
32.2.9
32.3
33
33.2
33.2.2
33.2.3
19/692
Contents
33.2.4
UM1785
Extension Peripheral Control functions .......................................... 428
33.2.5
33.2.6
33.2.7
33.2.8
HAL_RTCEx_GetTimeStamp......................................................... 430
33.2.9
33.3
34
20/692
UM1785
Contents
34.2
34.1.1
34.1.2
SMARTCARD_AdvFeatureInitTypeDef.......................................... 452
34.1.3
34.2.2
34.2.3
34.2.4
34.2.5
34.2.6
34.2.7
34.2.8
34.2.9
HAL_SMARTCARD_Transmit........................................................ 459
34.3
35
35.2
35.1.2
35.1.3
35.1.4
35.1.5
36
21/692
Contents
36.2
36.1.1
UM1785
SMBUS_InitTypeDef ...................................................................... 477
36.1.2
36.2.2
36.2.3
36.2.4
36.2.5
36.2.6
36.2.7
HAL_SMBUS_MspDeInit................................................................ 481
36.2.8
36.2.9
36.3
37
37.2
22/692
37.1.2
UM1785
Contents
37.2.1
37.2.2
37.2.3
37.2.4
37.2.5
37.2.6
37.2.7
37.2.8
HAL_SPI_MspDeInit....................................................................... 503
37.2.9
37.3
38
38.1.2
TIM_OC_InitTypeDef...................................................................... 519
DocID026525 Rev 1
23/692
Contents
38.2
38.1.3
UM1785
TIM_OnePulse_InitTypeDef ........................................................... 520
38.1.4
38.1.5
38.1.6
38.1.7
38.1.8
38.1.9
38.2.2
38.2.3
38.2.4
38.2.5
38.2.6
38.2.7
38.2.8
38.2.9
DocID026525 Rev 1
UM1785
Contents
38.2.32 HAL_TIM_OC_Stop_DMA ............................................................. 536
38.2.33 HAL_TIM_PWM_Init ....................................................................... 536
38.2.34 HAL_TIM_PWM_DeInit .................................................................. 537
38.2.35 HAL_TIM_PWM_MspInit ................................................................ 537
38.2.36 HAL_TIM_PWM_MspDeInit ........................................................... 537
38.2.37 HAL_TIM_PWM_Start .................................................................... 538
38.2.38 HAL_TIM_PWM_Stop .................................................................... 538
38.2.39 HAL_TIM_PWM_Start_IT ............................................................... 538
38.2.40 HAL_TIM_PWM_Stop_IT ............................................................... 539
38.2.41 HAL_TIM_PWM_Start_DMA .......................................................... 539
38.2.42 HAL_TIM_PWM_Stop_DMA .......................................................... 540
38.2.43 HAL_TIM_IC_Init ............................................................................ 540
38.2.44 HAL_TIM_IC_DeInit ....................................................................... 541
38.2.45 HAL_TIM_IC_MspInit ..................................................................... 541
38.2.46 HAL_TIM_IC_MspDeInit................................................................. 541
38.2.47 HAL_TIM_IC_Start ......................................................................... 542
38.2.48 HAL_TIM_IC_Stop ......................................................................... 542
38.2.49 HAL_TIM_IC_Start_IT .................................................................... 543
38.2.50 HAL_TIM_IC_Stop_IT .................................................................... 543
38.2.51 HAL_TIM_IC_Start_DMA ............................................................... 543
38.2.52 HAL_TIM_IC_Stop_DMA ............................................................... 544
38.2.53 HAL_TIM_OnePulse_Init ................................................................ 544
38.2.54 HAL_TIM_OnePulse_DeInit ........................................................... 545
38.2.55 HAL_TIM_OnePulse_MspInit ......................................................... 545
38.2.56 HAL_TIM_OnePulse_MspDeInit .................................................... 546
38.2.57 HAL_TIM_OnePulse_Start ............................................................. 546
38.2.58 HAL_TIM_OnePulse_Stop ............................................................. 546
38.2.59 HAL_TIM_OnePulse_Start_IT ........................................................ 547
38.2.60 HAL_TIM_OnePulse_Stop_IT ........................................................ 547
38.2.61 HAL_TIM_Encoder_Init .................................................................. 548
38.2.62 HAL_TIM_Encoder_DeInit ............................................................. 548
38.2.63 HAL_TIM_Encoder_MspInit ........................................................... 548
38.2.64 HAL_TIM_Encoder_MspDeInit ....................................................... 549
38.2.65 HAL_TIM_Encoder_Start ............................................................... 549
38.2.66 HAL_TIM_Encoder_Stop ............................................................... 549
38.2.67 HAL_TIM_Encoder_Start_IT .......................................................... 550
38.2.68 HAL_TIM_Encoder_Stop_IT .......................................................... 550
38.2.69 HAL_TIM_Encoder_Start_DMA ..................................................... 551
DocID026525 Rev 1
25/692
Contents
UM1785
38.2.70 HAL_TIM_Encoder_Stop_DMA ..................................................... 551
38.2.71 HAL_TIM_IRQHandler ................................................................... 551
38.2.72 HAL_TIM_OC_ConfigChannel ....................................................... 552
38.2.73 HAL_TIM_IC_ConfigChannel ......................................................... 552
38.2.74 HAL_TIM_PWM_ConfigChannel .................................................... 553
38.2.75 HAL_TIM_OnePulse_ConfigChannel............................................. 553
38.2.76 HAL_TIM_DMABurst_WriteStart .................................................... 554
38.2.77 HAL_TIM_DMABurst_WriteStop .................................................... 555
38.2.78 HAL_TIM_DMABurst_ReadStart .................................................... 555
38.2.79 HAL_TIM_DMABurst_ReadStop .................................................... 556
38.2.80 HAL_TIM_GenerateEvent .............................................................. 557
38.2.81 HAL_TIM_ConfigOCrefClear .......................................................... 557
38.2.82 HAL_TIM_ConfigClockSource ....................................................... 558
38.2.83 HAL_TIM_ConfigTI1Input ............................................................... 558
38.2.84 HAL_TIM_SlaveConfigSynchronization ......................................... 559
38.2.85 HAL_TIM_SlaveConfigSynchronization_IT .................................... 559
38.2.86 HAL_TIM_ReadCapturedValue ...................................................... 560
38.2.87 HAL_TIM_PeriodElapsedCallback ................................................. 560
38.2.88 HAL_TIM_OC_DelayElapsedCallback ........................................... 560
38.2.89 HAL_TIM_IC_CaptureCallback ...................................................... 561
38.2.90 HAL_TIM_PWM_PulseFinishedCallback ....................................... 561
38.2.91 HAL_TIM_TriggerCallback ............................................................. 561
38.2.92 HAL_TIM_ErrorCallback................................................................. 562
38.2.93 HAL_TIM_Base_GetState .............................................................. 562
38.2.94 HAL_TIM_OC_GetState ................................................................. 562
38.2.95 HAL_TIM_PWM_GetState ............................................................. 563
38.2.96 HAL_TIM_IC_GetState................................................................... 563
38.2.97 HAL_TIM_OnePulse_GetState ...................................................... 563
38.2.98 HAL_TIM_Encoder_GetState ......................................................... 564
38.3
39
39.2
39.1.2
39.1.3
26/692
TIM.................................................................................................. 564
UM1785
Contents
39.2.2
39.2.3
39.2.4
39.2.5
39.2.6
39.2.7
39.2.8
39.2.9
DocID026525 Rev 1
27/692
Contents
UM1785
39.2.40 HAL_TIMEx_CommutationCallback ............................................... 597
39.2.41 HAL_TIMEx_BreakCallback ........................................................... 598
39.2.42 HAL_TIMEx_DMACommutationCplt .............................................. 598
39.2.43 HAL_TIMEx_HallSensor_GetState ................................................ 598
39.3
40
40.2
40.1.2
TSC_IOConfigTypeDef................................................................... 600
40.1.3
40.2.2
40.2.3
40.2.4
40.2.5
40.2.6
40.2.7
40.2.8
40.2.9
40.3
41
28/692
TSC................................................................................................. 609
UM1785
Contents
41.2
41.1.1
41.1.2
41.1.3
41.1.4
41.2.2
41.2.3
41.2.4
41.2.5
41.2.6
41.2.7
41.2.8
41.2.9
41.3
29/692
Contents
42
UM1785
42.1.2
42.1.3
42.1.4
HAL_RS485Ex_Init......................................................................... 649
42.1.5
42.1.6
42.1.7
42.1.8
42.1.9
42.2
43
43.2
43.1.2
43.2.2
43.2.3
43.2.4
43.2.5
43.2.6
43.2.7
43.2.8
43.2.9
DocID026525 Rev 1
UM1785
Contents
43.2.18 HAL_USART_TransmitReceive_DMA ........................................... 665
43.2.19 HAL_USART_DMAPause .............................................................. 666
43.2.20 HAL_USART_DMAResume ........................................................... 666
43.2.21 HAL_USART_DMAStop ................................................................. 667
43.2.22 HAL_USART_IRQHandler ............................................................. 667
43.2.23 HAL_USART_TxCpltCallback ........................................................ 667
43.2.24 HAL_USART_TxHalfCpltCallback .................................................. 668
43.2.25 HAL_USART_RxCpltCallback ........................................................ 668
43.2.26 HAL_USART_RxHalfCpltCallback ................................................. 668
43.2.27 HAL_USART_TxRxCpltCallback .................................................... 669
43.2.28 HAL_USART_ErrorCallback .......................................................... 669
43.2.29 HAL_USART_GetState .................................................................. 669
43.2.30 HAL_USART_GetError................................................................... 670
43.3
44
45
USART............................................................................................ 670
45.2
45.1.2
45.2.2
45.2.3
45.2.4
45.2.5
45.2.6
HAL_WWDG_Init............................................................................ 680
45.2.7
45.2.8
45.2.9
DocID026525 Rev 1
31/692
Contents
UM1785
45.2.15 HAL_WWDG_WakeupCallback ..................................................... 684
45.2.16 HAL_WWDG_GetState .................................................................. 684
45.3
WWDG............................................................................................ 684
46
FAQs............................................................................................. 687
47
32/692
DocID026525 Rev 1
UM1785
List of tables
List of tables
Table 1: Acronyms and definitions ............................................................................................................ 35
Table 2: HAL drivers files .......................................................................................................................... 37
Table 3: User-application files .................................................................................................................. 38
Table 4: APis classification ....................................................................................................................... 43
Table 5: List of devices supported by HAL drivers ................................................................................... 43
Table 6: HAL API naming rules ................................................................................................................ 45
Table 7: Macros handling interrupts and specific clock configurations .................................................... 46
Table 8: Callback functions ....................................................................................................................... 47
Table 9: HAL generic APIs ....................................................................................................................... 48
Table 10: HAL extension APIs .................................................................................................................. 49
Table 11: Define statements used for HAL configuration ......................................................................... 53
Table 12: Description of GPIO_InitTypeDef structure .............................................................................. 55
Table 13: Description of EXTI configuration macros ................................................................................ 57
Table 14: MSP functions ........................................................................................................................... 62
Table 15: Timeout values ......................................................................................................................... 66
Table 16: COMP Inputs for STM32F05xx, STM32F07x and STM32F09x devices ................................ 147
Table 17: COMP outputs for STM32F05xx, STM32F07x and STM32F09x devices .............................. 147
Table 18: Redirection of COMP outputs to embedded timers for STM32F05xx, STM32F07x and
STM32F09x devices ............................................................................................................................... 148
Table 19: IRDA frame formats ................................................................................................................ 296
Table 20: Number of wait states (WS) according to system clock (SYSCLK) frequency....................... 364
Table 21: USART frame formats ............................................................................................................ 456
Table 22: Maximum SPI frequency vs data size .................................................................................... 499
Table 23: UART frame formats ............................................................................................................... 623
Table 24: USART frame formats ............................................................................................................ 659
Table 25: Document revision history ...................................................................................................... 691
DocID026525 Rev 1
33/692
List of figures
UM1785
List of figures
Figure 1: Example of project template ...................................................................................................... 40
Figure 2: Adding device-specific functions ............................................................................................... 50
Figure 3: Adding family-specific functions ................................................................................................ 50
Figure 4: Adding new peripherals ............................................................................................................. 51
Figure 5: Updating existing APIs .............................................................................................................. 51
Figure 6: File inclusion model ................................................................................................................... 52
Figure 7: HAL driver model ....................................................................................................................... 60
34/692
DocID026525 Rev 1
UM1785
Definition
ADC
Analog-to-digital converter
ANSI
API
BSP
COMP
Comparator
CMSIS
CPU
CRYP
CRC
DAC
DMA
EXTI
FLASH
Flash memory
GPIO
HAL
I2C
Inter-integrated circuit
I2S
Inter-integrated sound
IRDA
IWDG
Independent watchdog
LCD
MSP
NVIC
PCD
PWR
Power controller
RCC
RNG
RTC
Real-time clock
SD
SRAM
SMARTCARD
SPI
SysTick
Secure Digital
SRAM external memory
Smartcard IC
Serial Peripheral interface
System tick timer
TIM
TSC
DocID026525 Rev 1
35/692
UM1785
Acronym
36/692
Definition
UART
USART
WWDG
Window watchdog
USB
PPP
DocID026525 Rev 1
UM1785
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:
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
2.1.1
Description
stm32f0xx_hal_ppp.c
stm32f0xx_hal_ppp.h
DocID026525 Rev 1
37/692
UM1785
File
Description
stm32f0xx_hal_ppp_ex.c
stm32f0xx_hal_ppp_ex.h
stm32f0xx_hal.c
stm32f0xx_hal.h
stm32f0xx_hal_msp_template.c
stm32f0xx_hal_conf_template.h
stm32f0xx_hal_def.h
2.1.2
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_stm32f0xx.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 :
38/692
startup_stm32f0xx.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.
stm32f0xx_flash.icf
(optional)
Linker file for EWARM toolchain allowing mainly to adapt the stack/heap
size to fit the application requirements.
stm32f0xx_hal_msp.c
This file contains the MSP initialization and de-initialization (main routine
and callbacks) of the peripheral used in the user application.
stm32f0xx_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.
DocID026525 Rev 1
UM1785
stm32f0xx_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 stm32f0xx_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 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
DocID026525 Rev 1
39/692
UM1785
Figure 1: Example of project template
2.2
2.2.1
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.
40/692
DocID026525 Rev 1
UM1785
1) The multi-instance feature implies that all the APIs used in the application are
re-entrant and avoid using global variables because subroutines can fail to be reentrant if they rely on a global variable to remain unchanged but that variable is
modified when the subroutine is recursively invoked. For this reason, the following
rules are respected:
Re-entrant code does not hold any static (or global) non-constant data: reentrant functions can work with global data. For example, a re-entrant
interrupt service routine can grab a piece of hardware status to work with
(e.g. serial port read buffer) which is not only global, but volatile. Still, typical
use of static variables and global data is not advised, in the sense that only
atomic read-modify-write instructions should be used in these variables. It
should not be possible for an interrupt or signal to occur during the execution
of such an instruction.
Reentrant code does not modify its own code.
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.
DocID026525 Rev 1
41/692
UM1785
2.2.3
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.
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).
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.
42/692
DocID026525 Rev 1
UM1785
Extension file
X
(1)
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.
2.4
IP/Module
STM32F030x6
STM32F030x8
STM32F070x6
STM32F070x8
STM32F030xC
STM32F031x6
STM32F051x8
STM32F071xB
STM32F091xC
STM32F042x6
STM32F072xB
STM32F048xx
STM32F058xx
STM32F078xx
STM32F098xx
stm32f0xx_hal.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_adc.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_adc_ex.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_can.c
No
No
No
No
No
No
No
No
Yes
Yes
Yes
Yes
No
Yes
Yes
stm32f0xx_hal_cec.c
No
No
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_comp.c
No
No
No
No
No
No
Yes
Yes
Yes
No
Yes
No
Yes
Yes
Yes
stm32f0xx_hal_cortex.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_crc.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_crc_ex.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_dac.c
No
No
No
No
No
No
Yes
Yes
Yes
No
Yes
No
Yes
Yes
Yes
stm32f0xx_hal_dac_ex.c
No
No
No
No
No
No
Yes
Yes
Yes
No
Yes
No
Yes
Yes
Yes
stm32f0xx_hal_dma.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_flash.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
DocID026525 Rev 1
43/692
IP/Module
STM32F030x8
STM32F070x6
STM32F070x8
STM32F030xC
STM32F031x6
STM32F051x8
STM32F071xB
STM32F091xC
STM32F042x6
STM32F072xB
STM32F048xx
STM32F058xx
STM32F078xx
STM32F098xx
UM1785
STM32F030x6
stm32f0xx_hal_flash_ex.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_gpio.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_i2c.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_i2c_ex.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_i2s.c
No
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_irda.c
No
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_iwdg.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_msp_template.c
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
stm32f0xx_hal_pcd.c
No
No
Yes
Yes
No
No
No
No
No
Yes
Yes
Yes
No
Yes
No
stm32f0xx_hal_pcd_ex.c
No
No
Yes
Yes
No
No
No
No
No
Yes
Yes
Yes
No
Yes
No
stm32f0xx_hal_pwr.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_pwr_ex.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
No
stm32f0xx_hal_rcc.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_rcc_ex.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_rtc.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_rtc_ex.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_smartcard.c
No
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_smartcard_ex.c
No
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_smbus.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_spi.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_tim.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_tim_ex.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_tsc.c
No
No
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_uart.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_uart_ex.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_usart.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
stm32f0xx_hal_wwdg.c
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
44/692
DocID026525 Rev 1
UM1785
2.5
2.5.1
File names
Generic
Family specific
Device specific
stm32f0xx_hal_ppp (c/h)
stm32f0xx_hal_ppp_ex (c/h)
Module
name
HAL_PPP_ MODULE
Function
name
HAL_PPP_Function
HAL_PPP_FeatureFunction_M
ODE
HAL_PPPEx_Function
HAL_PPPEx_FeatureFunction_
MODE
HAL_PPPEx_Function
HAL_PPPEx_FeatureFunction_MO
DE
Handle
name
PPP_HandleTypedef
NA
NA
Init
structure
name
PPP_InitTypeDef
NA
PPP_InitTypeDef
Enum
name
HAL_PPP_StructnameTypeDef
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 STM32F0xx 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: stm32f030x6.h,
stm32f030x8.h, stm32f031x6.h, stm32f038xx.h, stm32f042x6.h, stm32f048xx.h,
stm32f051x8.h, stm32f058xx.h, stm32f071xB.h, stm32f072xB.h, stm32f078xx.h,
stm32f091xC.h and stm32f098xx.h. The platform is selected by enabling the
compilation switch in the compilation toolchain directive or in the stm32f0xx.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()).
DocID026525 Rev 1
45/692
2.5.2
UM1785
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
For the shared and system peripherals, no handle or instance object is used. This rule
applies to the following peripherals:
GPIO
SYSTICK
NVIC
RCC
FLASH.
Example: The HAL_GPIO_Init() requires only the GPIO address and its configuration
parameters.
HAL_StatusTypeDef HAL_GPIO_Init (GPIO_TypeDef* GPIOx, GPIO_InitTypeDef *Init)
{
/*GPIO Initialization body */
}
The macros that handle interrupts and specific clock configurations are defined in
each peripheral/module driver. These macros are exported in the peripheral driver
header files so that they can be used by the extension file. The list of these macros is
defined below: This list is not exhaustive and other macros related to peripheral
features can be added, so that they can be used in the user application.
Table 7: Macros handling interrupts and specific clock configurations
Macros
__HAL_PPP_ENABLE_IT(__HANDLE__, __INTERRUPT__)
__HAL_PPP_DISABLE_IT(__HANDLE__, __INTERRUPT__)
46/692
Description
__HAL_PPP_ENABLE(__HANDLE__)
Enables a peripheral
__HAL_PPP_DISABLE(__HANDLE__)
Disables a peripheral
DocID026525 Rev 1
UM1785
NVIC and SYSTICK are two ARM Cortex core features. The APIs related to these
features are located in the stm32f0xx_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;
}
2.5.3
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:
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
DocID026525 Rev 1
47/692
2.6
UM1785
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
Description
HAL_ADC_Init()
HAL_ADC_DeInit()
HAL_ADC_Start ()
HAL_ADC_Stop ()
HAL_ADC_PollForConversion()
HAL_ADC_Start_IT()
HAL_ADC_Stop_IT()
Initialization
group
IO operation
group
HAL_ADC_IRQHandler()
48/692
DocID026525 Rev 1
UM1785
Description
HAL_ADC_ConvCpltCallback()
HAL_ADC_ErrorCallback()
HAL_ADC_ConfigChannel()
HAL_ADC_AnalogWDGConfig
HAL_ADC_GetState()
HAL_ADC_GetError()
Control group
State and
Errors group
2.7
2.7.1
HAL_ADCEx_CalibrationStart()
2.7.2
HAL_ADCEx_Calibration_GetValue()
HAL_ADCEx_Calibration_SetValue()
DocID026525 Rev 1
49/692
UM1785
Figure 2: Adding device-specific functions
Example: stm32f0xx_hal_rcc_ex.c/h
#if defined(STM32F042x6) || defined(STM32F048xx) || \
defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
defined(STM32F091xC) || defined(STM32F098xx)
void HAL_RCCEx_CRSConfig(RCC_CRSInitTypeDef *pInit);
void HAL_RCCEx_CRSSoftwareSynchronizationGenerate(void);
void HAL_RCCEx_CRSGetSynchronizationInfo(RCC_CRSSynchroInfoTypeDef *pSynchroInfo);
RCC_CRSStatusTypeDef HAL_RCCEx_CRSWaitSynchronization(uint32_t Timeout);
#endif /* STM32F042x6 || STM32F048xx || */
/* STM32F071xB || STM32F072xB || STM32F078xx || */
/* STM32F091xC || STM32F098xx */
50/692
DocID026525 Rev 1
UM1785
Example: stm32f0xx_hal_lcd.c/h
2.8
51/692
UM1785
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 stm32f0xx_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 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;
52/692
DocID026525 Rev 1
UM1785
HAL Locked The HAL lock is used by all HAL APIs to prevent accessing by accident
shared resources.
typedef enum
{
HAL_UNLOCKED = 0x00, /*!<Resources unlocked */
HAL_LOCKED = 0x01 /*!< Resources locked */
} HAL_LockTypeDef;In addition to common resources, the stm32f0xx_hal_def.h file
calls the stm32f0xx.h file in CMSIS library to get the data structures and the
address mapping for all peripherals:
#ifndef NULL
#define NULL (void *) 0
#endif
#define HAL_MAX_DELAY 0xFFFFFFFF
2.10
HAL configuration
The configuration file, stm32f0xx_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
HSE_VALUE
HSE_STARTUP_TIMEOUT
HSI_VALUE
HSI_STARTUP_TIMEOUT
LSE_VALUE
HSI14_VALUE
Description
Defines the value of the external oscillator (HSE)
expressed in Hz. The user must adjust this define
statement when using a different crystal value.
Timeout for HSE start up, expressed in ms
Defines the value of the internal oscillator (HSI)
expressed in Hz.
Timeout for HSI start up, expressed in ms
Default
Value
8 000 000
(Hz)
5000
16 000 000
(Hz)
5000
32768 (Hz)
14 000 000
(Hz)
DocID026525 Rev 1
53/692
UM1785
Configuration item
Description
Default
Value
HSI48_VALUE
48 000 000
(Hz)
LSI_VALUE
40 000 (Hz)
VDD_VALUE
VDD value
3300 (mV)
USE_RTOS
FALSE (for
future use)
PREFETCH_ENABLE
TRUE
2.11
2.11.1
Clock
Two main functions can be used to configure the system clock:
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
stm32f0xx_hal_rcc_ex.c: HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef
*PeriphClkInit).
Additional RCC HAL driver functions are available:
54/692
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
DocID026525 Rev 1
UM1785
2.11.2
GPIOs
GPIO HAL APIs are the following:
HAL_GPIO_Init() / HAL_GPIO_DeInit()
HAL_GPIO_ReadPin() / HAL_GPIO_WritePin()
HAL_GPIO_TogglePin ().
In addition to standard GPIO modes (input, output, analog), pin mode can be configured as
EXTI with interrupt or event generation.
When selecting EXTI mode with interrupt generation, the user must call
HAL_GPIO_EXTI_IRQHandler() from stm32f0xx_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
GPIO mode
DocID026525 Rev 1
55/692
UM1785
Structure
field
Pull
Speed
Alternate
Description
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
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.
Refer to the Alternate function mapping table in the datasheets
for the detailed description of the system and peripheral I/O
alternate functions.
GPIO_InitStructure.Mode = GPIO_MODE_IT_FALLING;
GPIO_InitStructure.Pull = GPIO_NOPULL;
GPIO_InitStructure.Pin = GPIO_PIN_0;
HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
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
56/692
HAL_NVIC_SetPriority()
DocID026525 Rev 1
UM1785
2.11.4
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()
HAL_SYSTICK_Callback()
PWR
The PWR HAL driver handles power management. The features shared between all
STM32 Series are listed below:
2.11.5
HAL_PWR_PVDConfig()
HAL_PWR_EnablePVD() / HAL_PWR_DisablePVD()
HAL_PWR_PVD_IRQHandler()
HAL_PWR_PVDCallback()
Wakeup pin configuration
HAL_PWR_EnableWakeUpPin() / HAL_PWR_DisableWakeUpPin()
Low power mode entry
HAL_PWR_EnterSLEEPMode()
HAL_PWR_EnterSTOPMode()
HAL_PWR_EnterSTANDBYMode()
Backup domain configuration
HAL_PWR_EnableBkUpAccess()/ HAL_PWR_DisableBkUpAccess()
EXTI
The EXTI is not considered as a standalone peripheral but rather as a service used by
other peripheral. As a result there are no EXTI APIs but each peripheral HAL driver
implements the associated EXTI configuration and EXTI function are implemented as
macros in its header file.
The first 16 EXTI lines connected to the GPIOs are managed within the GPIO driver. The
GPIO_InitTypeDef structure allows configuring an I/O as external interrupt or external
event.
The EXTI lines connected internally to the PVD, RTC, USB, and COMP are configured
within the HAL drivers of these peripheral through the macros given in the table below. The
EXTI internal connections depend on the targeted STM32 microcontroller (refer to the
product datasheet for more details):
Table 13: Description of EXTI configuration macros
Macros
Description
Defines the EXTI line connected to the internal peripheral.
Example:
#define PWR_EXTI_LINE_PVD ((uint32_t)0x00010000) /*!<External
interrupt line 16 Connected to the PVD EXTI Line */
PPP_EXTI_LINE_FUNCTION
__HAL_PPP_EXTI_ENABLE_IT
DocID026525 Rev 1
57/692
UM1785
Macros
Description
__HAL_PPP_EXTI_DISABLE_IT
__HAL_PPP_EXTI_GET_FLAG
__HAL_PPP_EXTI_CLEAR_FLAG
__HAL_PPP_EXTI_GENERATE_SWIT
__HAL_PPP_EXTI_ENABLE_EVENT
__HAL_PPP_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
stm32f0xx_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).
58/692
UM1785
Additional functions and macros are available to ensure efficient DMA management:
The most used DMA HAL driver macros are the following:
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.
DocID026525 Rev 1
59/692
UM1785
2.12
2.12.1
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.
2.12.2
HAL initialization
2.12.2.1
60/692
UM1785
2.12.2.2
Set Systick timer to generate an interrupt each 1ms (based on HSI clock) with the
lowest priority
2.12.2.3
DocID026525 Rev 1
61/692
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 stm32f0xx_hal_msp.c file in the user
folders. An stm32f0xx_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.
stm32f0xx_hal_msp.c file contains the following functions:
Table 14: MSP functions
Routine
Description
void HAL_MspInit()
void HAL_MspDeInit()
void HAL_PPP_MspInit()
void HAL_PPP_MspDeInit()
2.12.3
62/692
Polling mode
Interrupt mode
DocID026525 Rev 1
UM1785
2.12.3.1
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:
To use a process in interrupt mode, HAL_PPP_Process_IT() is called in the user file and
HAL_PPP_IRQHandler in stm32f0xx_it.c.
The HAL_PPP_ProcessCpltCallback() function is declared as weak function in the driver.
This means that the user can declare it again in the application. The function in the driver is
not modified.
An example of use is illustrated below:
main.c file:
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;
DocID026525 Rev 1
63/692
UM1785
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)
{
}
stm32f0xx_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:
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 stm32f0xx_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;
64/692
DocID026525 Rev 1
UM1785
stm32f0xx_it.c file:
extern UART_HandleTypeDef UartHandle;
void DMAx_IRQHandler(void)
{
HAL_DMA_IRQHandler(&UartHandle.DMA_Handle_tx);
}
2.12.4
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)
DocID026525 Rev 1
65/692
UM1785
Description
(1)
Timeout in ms
Infinite poll till process is successful
Notes:
(1)
However, in some cases, a fixed timeout is used for system peripherals or internal HAL
driver processes. In these cases, the timeout has the same meaning and is used in the
same way, except when it is defined locally in the drivers and cannot be modified or
introduced as an argument in the user application.
Example of fixed timeout:
#define LOCAL_PROCESS_TIMEOUT 100
HAL_StatusTypeDef HAL_PPP_Process(PPP_HandleTypeDef)
{
()
timeout = HAL_GetTick() + LOCAL_PROCESS_TIMEOUT;
()
while(ProcessOngoing)
{
()
if(HAL_GetTick() >= timeout)
{
/* Process unlocked */
__HAL_UNLOCK(hppp);
hppp->State= HAL_PPP_STATE_TIMEOUT;
return HAL_PPP_STATE_TIMEOUT;
}
}
()
}
The following example shows how to use the timeout inside the polling functions:
HAL_PPP_StateTypeDef HAL_PPP_Poll (PPP_HandleTypeDef *hppp, uint32_t Timeout)
{
()
timeout = HAL_GetTick() + Timeout;
()
while(ProcessOngoing)
{
()
if(Timeout != HAL_MAX_DELAY)
{
if(HAL_GetTick() >= timeout)
{
/* Process unlocked */
__HAL_UNLOCK(hppp);
hppp->State= HAL_PPP_STATE_TIMEOUT;
return hppp->State;
}
}
()
}
66/692
DocID026525 Rev 1
UM1785
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).
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.
Timeout error: the following statement is used when a timeout error occurs:
In all peripheral handles, a HAL_PPP_ErrorTypeDef is defined and used to store the last
error code.
typedef struct
{
PPP_TypeDef * Instance; /* PPP registers base address */
PPP_InitTypeDef Init; /* PPP initialization parameters */
HAL_LockTypeDef Lock; /* PPP locking object */
__IO HAL_PPP_StateTypeDef State; /* PPP state */
__IO HAL_PPP_ErrorTypeDef ErrorCode; /* PPP Error code */
()
/* PPP specific parameters */
}
PPP_HandleTypeDef;
The error state and the peripheral global state are always updated before returning an
error:
PPP->State = HAL_PPP_READY; /* Set the peripheral ready */
PP->ErrorCode = HAL_ERRORCODE ; /* Set the error code */
_HAL_UNLOCK(PPP) ; /* Unlock the PPP resources */
return HAL_ERROR; /*return with HAL error */
67/692
UM1785
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 stm32f0xx_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))
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) */
68/692
DocID026525 Rev 1
UM1785
DocID026525 Rev 1
69/692
UM1785
3.1
3.1.1
3.1.2
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.
70/692
UM1785
3.1.4
HAL_Init
Function Name
Function Description
Return values
HAL status
Notes
3.1.5
HAL_DeInit
Function Name
Function Description
This function de-Initializes common part of the HAL and stops the
source of time base.
Return values
HAL status
DocID026525 Rev 1
71/692
3.1.6
3.1.7
3.1.8
UM1785
HAL_MspInit
Function Name
Function Description
Return values
None.
Notes
None.
HAL_MspDeInit
Function Name
Function Description
Return values
None.
Notes
None.
HAL_InitTick
Function Name
Function Description
Parameters
Return values
HAL status
Notes
72/692
DocID026525 Rev 1
UM1785
3.1.9
HAL_IncTick
Function Name
Function Description
Return values
None.
Notes
3.1.10
3.1.11
HAL_GetTick
Function Name
Function Description
Return values
tick value
Notes
HAL_SuspendTick
Function Name
Function Description
DocID026525 Rev 1
73/692
UM1785
None.
3.1.12
3.1.13
HAL_ResumeTick
Function Name
Function Description
Return values
None.
Notes
HAL_Delay
Function Name
Function Description
Parameters
Return values
None.
Notes
74/692
DocID026525 Rev 1
UM1785
3.1.14
3.1.15
3.1.16
3.1.17
HAL_GetHalVersion
Function Name
Function Description
Return values
Notes
None.
HAL_GetREVID
Function Name
Function Description
Return values
Notes
None.
HAL_GetDEVID
Function Name
Function Description
Return values
Device identifier
Notes
None.
HAL_EnableDBGStopMode
Function Name
Function Description
DocID026525 Rev 1
75/692
3.1.18
3.1.19
3.1.20
76/692
UM1785
None.
None.
HAL_DisableDBGStopMode
Function Name
Function Description
Return values
None.
Notes
None.
HAL_EnableDBGStandbyMode
Function Name
Function Description
Return values
None.
Notes
None.
HAL_DisableDBGStandbyMode
Function Name
Function Description
Return values
None.
Notes
None.
DocID026525 Rev 1
UM1785
3.2
3.2.1
HAL
HAL
HAL FastModePlus I2C
IS_HAL_SYSCFG_FASTMODEPLUS_CONFIG
HAL Fast mode plus driving cap
__HAL_SYSCFG_FASTMODEPLUS_ENABLE
__HAL_SYSCFG_FASTMODEPLUS_DISABLE
HAL IRDA Enveloppe Selection
HAL_SYSCFG_IRDA_ENV_SEL_TIM16
HAL_SYSCFG_IRDA_ENV_SEL_USART1
HAL_SYSCFG_IRDA_ENV_SEL_USART4
IS_HAL_SYSCFG_IRDA_ENV_SEL
HAL ISR Wrapper
HAL_SYSCFG_ITLINE0
HAL_SYSCFG_ITLINE1
HAL_SYSCFG_ITLINE2
HAL_SYSCFG_ITLINE3
HAL_SYSCFG_ITLINE4
HAL_SYSCFG_ITLINE5
HAL_SYSCFG_ITLINE6
HAL_SYSCFG_ITLINE7
HAL_SYSCFG_ITLINE8
HAL_SYSCFG_ITLINE9
HAL_SYSCFG_ITLINE10
HAL_SYSCFG_ITLINE11
HAL_SYSCFG_ITLINE12
HAL_SYSCFG_ITLINE13
HAL_SYSCFG_ITLINE14
HAL_SYSCFG_ITLINE15
HAL_SYSCFG_ITLINE16
HAL_SYSCFG_ITLINE17
HAL_SYSCFG_ITLINE18
HAL_SYSCFG_ITLINE19
HAL_SYSCFG_ITLINE20
HAL_SYSCFG_ITLINE21
DocID026525 Rev 1
77/692
UM1785
HAL_SYSCFG_ITLINE23
HAL_SYSCFG_ITLINE24
HAL_SYSCFG_ITLINE25
HAL_SYSCFG_ITLINE26
HAL_SYSCFG_ITLINE27
HAL_SYSCFG_ITLINE28
HAL_SYSCFG_ITLINE29
HAL_SYSCFG_ITLINE30
HAL_SYSCFG_ITLINE31
HAL_ITLINE_EWDG
HAL_ITLINE_PVDOUT
HAL_ITLINE_VDDIO2
HAL_ITLINE_RTC_WAKEUP
HAL_ITLINE_RTC_TSTAMP
HAL_ITLINE_RTC_ALRA
HAL_ITLINE_FLASH_ITF
HAL_ITLINE_CRS
HAL_ITLINE_CLK_CTRL
HAL_ITLINE_EXTI0
HAL_ITLINE_EXTI1
HAL_ITLINE_EXTI2
HAL_ITLINE_EXTI3
HAL_ITLINE_EXTI4
HAL_ITLINE_EXTI5
HAL_ITLINE_EXTI6
HAL_ITLINE_EXTI7
HAL_ITLINE_EXTI8
HAL_ITLINE_EXTI9
HAL_ITLINE_EXTI10
HAL_ITLINE_EXTI11
HAL_ITLINE_EXTI12
HAL_ITLINE_EXTI13
HAL_ITLINE_EXTI14
HAL_ITLINE_EXTI15
HAL_ITLINE_TSC_EOA
78/692
DocID026525 Rev 1
UM1785
HAL_ITLINE_USART2
DocID026525 Rev 1
79/692
UM1785
HAL_ITLINE_USART4
HAL_ITLINE_USART5
HAL_ITLINE_USART6
HAL_ITLINE_USART7
HAL_ITLINE_USART8
HAL_ITLINE_CAN
HAL_ITLINE_CEC
HAL ISR wrapper check
__HAL_GET_PENDING_IT
Constants
__STM32F0xx_HAL_VERSION_MAIN
__STM32F0xx_HAL_VERSION_SUB1
__STM32F0xx_HAL_VERSION_SUB2
__STM32F0xx_HAL_VERSION_RC
__STM32F0xx_HAL_VERSION
IDCODE_DEVID_MASK
HAL SYSCFG IRDA modulation envelope selection
__HAL_SYSCFG_IRDA_ENV_SELECTION
__HAL_SYSCFG_GET_IRDA_ENV_SELECTION
80/692
DocID026525 Rev 1
UM1785
4.1
4.1.1
ADC_InitTypeDef
ADC_InitTypeDef is defined in the stm32f0xx_hal_adc.h
Data Fields
uint32_t ClockPrescaler
uint32_t Resolution
uint32_t DataAlign
uint32_t ScanConvMode
uint32_t EOCSelection
uint32_t LowPowerAutoWait
uint32_t LowPowerAutoPowerOff
uint32_t ContinuousConvMode
uint32_t DiscontinuousConvMode
uint32_t ExternalTrigConv
uint32_t ExternalTrigConvEdge
uint32_t DMAContinuousRequests
uint32_t Overrun
Field Documentation
81/692
4.1.2
ADC_ChannelConfTypeDef
ADC_ChannelConfTypeDef is defined in the stm32f0xx_hal_adc.h
Data Fields
82/692
uint32_t Channel
uint32_t Rank
uint32_t SamplingTime
DocID026525 Rev 1
UM1785
4.1.3
ADC_AnalogWDGConfTypeDef
ADC_AnalogWDGConfTypeDef is defined in the stm32f0xx_hal_adc.h
Data Fields
uint32_t WatchdogMode
uint32_t Channel
uint32_t ITMode
uint32_t HighThreshold
uint32_t LowThreshold
Field Documentation
83/692
4.1.4
ADC_HandleTypeDef
ADC_HandleTypeDef is defined in the stm32f0xx_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
4.2.1
1.
2.
DocID026525 Rev 1
UM1785
4.2.2
1.
2.
3.
4.
Two possible clock sources: synchronous clock derived from APB clock or
asynchronous clock derived from ADC dedicated HSI RC oscillator 14MHz.
Enable the clock for the ADC GPIOs using the following function:
__GPIOx_CLK_ENABLE();
4.2.3
To enable the DMA mode for regular group, use the HAL_ADC_Start_DMA() function.
To enable the generation of DMA requests continuously at the end of the last DMA
transfer, use the HAL_ADC_Init() function.
85/692
4.2.4
UM1785
HAL_ADC_DeInit()
HAL_ADC_MspInit()
HAL_ADC_MspDeInit()
IO operation functions
This section provides functions allowing to:
4.2.5
4.2.6
86/692
DocID026525 Rev 1
UM1785
4.2.7
HAL_ADC_Init
Function Name
Function Description
Parameters
Return values
HAL status
Notes
4.2.8
HAL_ADC_DeInit
Function Name
Function Description
Parameters
Return values
HAL status
Notes
DocID026525 Rev 1
87/692
UM1785
common group is still running.
4.2.9
4.2.10
4.2.11
88/692
HAL_ADC_MspInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_ADC_MspDeInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_ADC_Start
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
UM1785
4.2.12
4.2.13
4.2.14
HAL_ADC_Stop
Function Name
Function Description
Parameters
Return values
HAL status.
Notes
None.
HAL_ADC_PollForConversion
Function Name
HAL_StatusTypeDef HAL_ADC_PollForConversion (
ADC_HandleTypeDef * hadc, uint32_t Timeout)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_ADC_PollForEvent
Function Name
HAL_StatusTypeDef HAL_ADC_PollForEvent (
ADC_HandleTypeDef * hadc, uint32_t EventType, uint32_t
Timeout)
Function Description
Parameters
89/692
4.2.15
4.2.16
4.2.17
Return values
HAL status
Notes
None.
HAL_ADC_Start_IT
Function Name
HAL_StatusTypeDef HAL_ADC_Start_IT (
ADC_HandleTypeDef * hadc)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_ADC_Stop_IT
Function Name
HAL_StatusTypeDef HAL_ADC_Stop_IT (
ADC_HandleTypeDef * hadc)
Function Description
Stop ADC conversion of regular group, disable interruption of endof-conversion, disable ADC peripheral.
Parameters
Return values
HAL status.
Notes
None.
HAL_ADC_Start_DMA
Function Name
90/692
UM1785
HAL_StatusTypeDef HAL_ADC_Start_DMA (
ADC_HandleTypeDef * hadc, uint32_t * pData, uint32_t
DocID026525 Rev 1
UM1785
4.2.18
4.2.19
Function Description
Parameters
Return values
None.
Notes
None.
HAL_ADC_Stop_DMA
Function Name
HAL_StatusTypeDef HAL_ADC_Stop_DMA (
ADC_HandleTypeDef * hadc)
Function Description
Parameters
Return values
HAL status.
Notes
None.
HAL_ADC_GetValue
Function Name
Function Description
Parameters
Return values
Converted value
Notes
None.
DocID026525 Rev 1
91/692
4.2.20
4.2.21
4.2.22
92/692
UM1785
HAL_ADC_IRQHandler
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_ADC_ConvCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_ADC_ConvHalfCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
UM1785
4.2.23
4.2.24
4.2.25
HAL_ADC_LevelOutOfWindowCallback
Function Name
void HAL_ADC_LevelOutOfWindowCallback (
ADC_HandleTypeDef * hadc)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_ADC_ErrorCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_ADC_ConfigChannel
Function Name
HAL_StatusTypeDef HAL_ADC_ConfigChannel (
ADC_HandleTypeDef * hadc, ADC_ChannelConfTypeDef *
sConfig)
Function Description
Parameters
Return values
HAL status
Notes
93/692
4.2.26
4.2.27
94/692
UM1785
datasheet for timings values, parameters TS_vrefint, TS_vbat,
TS_temp (values rough order: 5us to 17us). These internal
paths can be be disabled using function HAL_ADC_DeInit().
Possibility to update parameters on the fly: This function
initializes channel into regular group, following calls to this
function can be used to reconfigure some parameters of
structure "ADC_ChannelConfTypeDef" on the fly, without
reseting the ADC. The setting of these parameters is
conditioned to ADC state. For parameters constraints, see
comments of structure "ADC_ChannelConfTypeDef".
HAL_ADC_AnalogWDGConfig
Function Name
HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig (
ADC_HandleTypeDef * hadc, ADC_AnalogWDGConfTypeDef *
AnalogWDGConfig)
Function Description
Parameters
Return values
HAL status
Notes
HAL_ADC_GetState
Function Name
HAL_ADC_StateTypeDef HAL_ADC_GetState (
ADC_HandleTypeDef * hadc)
Function Description
Parameters
Return values
HAL state
DocID026525 Rev 1
UM1785
4.2.28
None.
HAL_ADC_GetError
Function Name
Function Description
Parameters
Return values
Notes
None.
4.3
4.3.1
ADC
ADC
ADC analog watchdog mode
ADC_ANALOGWATCHDOG_NONE
ADC_ANALOGWATCHDOG_SINGLE_REG
ADC_ANALOGWATCHDOG_ALL_REG
IS_ADC_ANALOG_WATCHDOG_MODE
ADC channels
ADC_CHANNEL_0
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
DocID026525 Rev 1
95/692
UM1785
ADC_CHANNEL_12
ADC_CHANNEL_13
ADC_CHANNEL_14
ADC_CHANNEL_15
ADC_CHANNEL_16
ADC_CHANNEL_17
ADC_CHANNEL_18
ADC_CHANNEL_TEMPSENSOR
ADC_CHANNEL_VREFINT
ADC_CHANNEL_VBAT
IS_ADC_CHANNEL
ADC ClockPrescaler
ADC_CLOCK_ASYNC
ADC_CLOCK_SYNC_PCLK_DIV2
ADC_CLOCK_SYNC_PCLK_DIV4
ADC_CLOCKPRESCALER_PCLK_DIV2
ADC_CLOCKPRESCALER_PCLK_DIV4
IS_ADC_CLOCKPRESCALER
ADC Data_align
ADC_DATAALIGN_RIGHT
ADC_DATAALIGN_LEFT
IS_ADC_DATA_ALIGN
ADC EOCSelection
EOC_SINGLE_CONV
EOC_SEQ_CONV
EOC_SINGLE_SEQ_CONV
IS_ADC_EOC_SELECTION
ADC Error Code
HAL_ADC_ERROR_NONE
No error
HAL_ADC_ERROR_INTERNAL
HAL_ADC_ERROR_OVR
Overrun error
HAL_ADC_ERROR_DMA
DocID026525 Rev 1
UM1785
OVR_EVENT
IS_ADC_EVENT_TYPE
ADC Exported Macros
__HAL_ADC_RESET_HANDLE_STATE
Description:
Parameters:
__HANDLE__: ADC
handle
Return value:
None:
Description:
__HAL_ADC_IS_ENABLED
Parameters:
__HANDLE__: ADC
handle
Return value:
__HAL_ADC_IS_SOFTWARE_START_REGULAR
Description:
Parameters:
__HANDLE__: ADC
handle
Return value:
__HAL_ADC_IS_CONVERSION_ONGOING_REGULAR
Description:
Check if no conversion on
going on regular group.
Parameters:
__HANDLE__: ADC
handle
Return value:
DocID026525 Rev 1
SET: (conversion is on
going) or RESET (no
97/692
UM1785
conversion is on going)
__HAL_ADC_GET_RESOLUTION
Description:
Parameters:
__HANDLE__: ADC
handle
Return value:
__HAL_ADC_GET_SAMPLINGTIME
None:
Description:
Parameters:
__HANDLE__: ADC
handle
Return value:
__HAL_ADC_GET_IT_SOURCE
None:
Description:
Parameters:
__HANDLE__: ADC
handle
__INTERRUPT__: ADC
interrupt source to check
Return value:
Description:
__HAL_ADC_ENABLE_IT
Parameters:
__HANDLE__: ADC
handle
__INTERRUPT__: ADC
Interrupt
Return value:
Description:
__HAL_ADC_DISABLE_IT
98/692
None:
DocID026525 Rev 1
UM1785
Parameters:
__HANDLE__: ADC
handle
__INTERRUPT__: ADC
Interrupt
Return value:
None:
Description:
__HAL_ADC_GET_FLAG
Parameters:
__HANDLE__: ADC
handle
__FLAG__: ADC flag
Return value:
None:
Description:
__HAL_ADC_CLEAR_FLAG
Parameters:
__HANDLE__: ADC
handle
__FLAG__: ADC flag
Return value:
__HAL_ADC_CLEAR_ERRORCODE
None:
Description:
Parameters:
__HANDLE__: ADC
handle
Return value:
__HAL_ADC_CHSELR_CHANNEL
None:
Description:
Parameters:
DocID026525 Rev 1
_CHANNEL_: ADC
99/692
UM1785
Channel
Return value:
None:
Description:
Parameters:
_CHANNEL_: channel to be
monitored by Analog Watchdog
1.
Return value:
__HAL_ADC_CFGR1_REG_DISCCONTINUOUS
None:
Description:
Parameters:
_REG_DISCONTINUOUS_MO
DE_: Regulat discontinuous
mode.
Return value:
__HAL_ADC_CFGR1_AUTOOFF
None:
Description:
Parameters:
Return value:
__HAL_ADC_CFGR1_AUTOWAIT
None:
Description:
Parameters:
Return value:
__HAL_ADC_CFGR1_CONTINUOUS
Description:
100/692
DocID026525 Rev 1
None:
UM1785
_CONTINUOUS_MODE_:
Continuous mode.
Return value:
__HAL_ADC_CFGR1_OVERRUN
None:
Description:
Parameters:
_OVERRUN_MODE_: Overrun
mode.
Return value:
__HAL_ADC_CFGR1_SCANDIR
Description:
Parameters:
_SCAN_MODE_: Scan
conversion mode.
Return value:
__HAL_ADC_CFGR1_DMACONTREQ
None:
Description:
Parameters:
_DMACONTREQ_MODE_:
DMA continuous request mode.
Return value:
__HAL_ADC_OFR_CHANNEL
None:
Description:
Parameters:
Return value:
DocID026525 Rev 1
None:
101/692
UM1785
Description:
Parameters:
Return value:
None:
Description:
__HAL_ADC_ENABLE
Parameters:
Return value:
__HAL_ADC_ENABLING_CONDITIONS
None:
Description:
Verification of hardware
constraints before ADC can be
enabled.
Parameters:
Return value:
Description:
__HAL_ADC_DISABLE
Parameters:
Return value:
__HAL_ADC_DISABLING_CONDITIONS
None:
Description:
Verification of hardware
constraints before ADC can be
disabled.
Parameters:
Return value:
102/692
DocID026525 Rev 1
UM1785
__HAL_ADC_AWD1THRESHOLD_SHIFT_RESOL
UTION
Parameters:
Return value:
None:
ADC_FLAG_OVR
ADC_FLAG_EOS
ADC_FLAG_EOC
ADC_FLAG_EOSMP
ADC_FLAG_RDY
ADC_FLAG_ALL
ADC_FLAG_POSTCONV_ALL
ADC Internal HAL driver Ext trig src Regular
ADC1_2_EXTERNALTRIG_T1_TRGO
ADC1_2_EXTERNALTRIG_T1_CC4
ADC1_2_EXTERNALTRIG_T2_TRGO
ADC1_2_EXTERNALTRIG_T3_TRGO
DocID026525 Rev 1
103/692
UM1785
ADC_IT_OVR
ADC_IT_EOS
ADC_IT_EOC
ADC_IT_EOSMP
ADC_IT_RDY
ADC Overrun
OVR_DATA_OVERWRITTEN
OVR_DATA_PRESERVED
IS_ADC_OVERRUN
ADC Private Constants
ADC_ENABLE_TIMEOUT
ADC_DISABLE_TIMEOUT
ADC_STOP_CONVERSION_TIMEOUT
ADC_TEMPSENSOR_DELAY_CPU_CYCLES
ADC_STAB_DELAY_CPU_CYCLES
ADC range verification
IS_ADC_RANGE
ADC rank
ADC_RANK_CHANNEL_NUMBER
ADC_RANK_NONE
IS_ADC_RANK
ADC regular rank verification
IS_ADC_REGULAR_RANK
ADC Resolution
ADC_RESOLUTION12b
ADC_RESOLUTION10b
ADC_RESOLUTION8b
ADC_RESOLUTION6b
IS_ADC_RESOLUTION
ADC sampling times
ADC_SAMPLETIME_1CYCLE_5
104/692
DocID026525 Rev 1
UM1785
ADC_SAMPLETIME_7CYCLES_5
ADC_SAMPLETIME_13CYCLES_5
ADC_SAMPLETIME_28CYCLES_5
ADC_SAMPLETIME_41CYCLES_5
ADC_SAMPLETIME_55CYCLES_5
ADC_SAMPLETIME_71CYCLES_5
ADC_SAMPLETIME_239CYCLES_5
IS_ADC_SAMPLE_TIME
ADC Scan mode
ADC_SCAN_DIRECTION_FORWARD
ADC_SCAN_DIRECTION_BACKWARD
ADC_SCAN_ENABLE
IS_ADC_SCAN_MODE
DocID026525 Rev 1
105/692
UM1785
5.1
5.1.1
1.
2.
5.1.2
1.
2.
3.
106/692
Enable the ADC interface As prerequisite, into HAL_ADC_MspInit(), ADC clock must
be configured at RCC top level: clock source and clock prescaler. Two possible clock
sources: synchronous clock derived from APB clock or asynchronous clock derived
from ADC dedicated HSI RC oscillator 14MHz. Example: __ADC1_CLK_ENABLE();
(mandatory) HI14 enable or let under control of ADC: (optional) RCC_OscInitTypeDef
RCC_OscInitStructure; RCC_OscInitStructure.OscillatorType =
RCC_OSCILLATORTYPE_HSI14; RCC_OscInitStructure.HSI14CalibrationValue =
RCC_HSI14CALIBRATION_DEFAULT; RCC_OscInitStructure.HSI14State =
RCC_HSI14_ADC_CONTROL; RCC_OscInitStructure.PLL... (optional if used for
system clock) HAL_RCC_OscConfig(&RCC_OscInitStructure); Parameter
"HSI14State" must be set either: - to "...HSI14State = RCC_HSI14_ADC_CONTROL"
to let the ADC control the HSI14 oscillator enable/disable (if not used to supply the
main system clock): feature used if ADC mode LowPowerAutoPowerOff is enabled. to "...HSI14State = RCC_HSI14_ON" to maintain the HSI14 oscillator always enabled:
can be used to supply the main system clock.
ADC pins configuration
Enable the clock for the ADC GPIOs using the following function:
__GPIOx_CLK_ENABLE();
UM1785
4.
To configure the ADC regular channels group features, use HAL_ADC_Init() and
HAL_ADC_ConfigChannel() functions.
To activate the continuous mode, use the HAL_ADC_Init() function.
To read the ADC converted values, use the HAL_ADC_GetValue() function.
5.1.3
To enable the DMA mode for regular channels group, use the
HAL_ADC_Start_DMA() function.
To enable the generation of DMA requests continuously at the end of the last DMA
transfer, use the HAL_ADC_Init() function.
IO operation functions
This section provides functions allowing to:
5.1.4
HAL_ADCEx_Calibration_Start
Function Name
HAL_StatusTypeDef HAL_ADCEx_Calibration_Start (
ADC_HandleTypeDef * hadc)
Function Description
Parameters
Return values
HAL status
Notes
5.2
5.2.1
ADCEx
ADCEx
ADCEx Private Constants
DocID026525 Rev 1
107/692
UM1785
ADC_CALIBRATION_TIMEOUT
108/692
DocID026525 Rev 1
UM1785
6.1
6.1.1
CAN_InitTypeDef
CAN_InitTypeDef is defined in the stm32f0xx_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
6.1.2
CAN_FilterConfTypeDef
CAN_FilterConfTypeDef is defined in the stm32f0xx_hal_can.h
DocID026525 Rev 1
109/692
UM1785
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
6.1.3
CanTxMsgTypeDef
CanTxMsgTypeDef is defined in the stm32f0xx_hal_can.h
Data Fields
110/692
uint32_t StdId
uint32_t ExtId
uint32_t IDE
uint32_t RTR
DocID026525 Rev 1
UM1785
uint32_t DLC
uint32_t Data
Field Documentation
6.1.4
CanRxMsgTypeDef
CanRxMsgTypeDef is defined in the stm32f0xx_hal_can.h
Data Fields
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
111/692
6.1.5
UM1785
CAN_HandleTypeDef
CAN_HandleTypeDef is defined in the stm32f0xx_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
6.2
6.2.1
1.
2.
3.
4.
5.
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.
112/692
DocID026525 Rev 1
UM1785
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
6.2.2
6.2.3
IO operation functions
This section provides functions allowing to:
113/692
6.2.4
UM1785
6.2.5
6.2.6
114/692
HAL_CAN_Init
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_CAN_ConfigFilter
Function Name
HAL_StatusTypeDef HAL_CAN_ConfigFilter (
CAN_HandleTypeDef * hcan, CAN_FilterConfTypeDef *
sFilterConfig)
Function Description
DocID026525 Rev 1
UM1785
6.2.7
6.2.8
6.2.9
Return values
None.
Notes
None.
HAL_CAN_DeInit
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_CAN_MspInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_CAN_MspDeInit
DocID026525 Rev 1
115/692
6.2.10
6.2.11
116/692
UM1785
void HAL_CAN_MspDeInit ( CAN_HandleTypeDef * hcan)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_CAN_Transmit
Function Name
HAL_StatusTypeDef HAL_CAN_Transmit (
CAN_HandleTypeDef * hcan, uint32_t Timeout)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_CAN_Transmit_IT
Function Name
HAL_StatusTypeDef HAL_CAN_Transmit_IT (
CAN_HandleTypeDef * hcan)
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
UM1785
6.2.12
6.2.13
6.2.14
HAL_CAN_Receive
Function Name
HAL_StatusTypeDef HAL_CAN_Receive (
CAN_HandleTypeDef * hcan, uint8_t FIFONumber, uint32_t
Timeout)
Function Description
Parameters
Return values
HAL.
Notes
None.
HAL_CAN_Receive_IT
Function Name
HAL_StatusTypeDef HAL_CAN_Receive_IT (
CAN_HandleTypeDef * hcan, uint8_t FIFONumber)
Function Description
Parameters
Return values
HAL.
Notes
None.
HAL_CAN_Sleep
Function Name
Function Description
Parameters
DocID026525 Rev 1
117/692
6.2.15
6.2.16
6.2.17
118/692
UM1785
HAL status.
None.
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
Return values
HAL status.
Notes
None.
HAL_CAN_IRQHandler
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_CAN_TxCpltCallback
Function Name
Function Description
UM1785
6.2.18
6.2.19
6.2.20
Return values
None.
Notes
None.
HAL_CAN_RxCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_CAN_ErrorCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_CAN_GetState
Function Name
HAL_CAN_StateTypeDef HAL_CAN_GetState (
CAN_HandleTypeDef * hcan)
DocID026525 Rev 1
119/692
6.2.21
UM1785
return the CAN state
Parameters
Return values
HAL state
Notes
None.
HAL_CAN_GetError
Function Name
Function Description
Parameters
Return values
Notes
None.
6.3
6.3.1
CAN
CAN
CAN clock prescaler
IS_CAN_PRESCALER
CAN Exported Macros
__HAL_CAN_RESET_HANDLE_STATE
Description:
Parameters:
Return value:
__HAL_CAN_ENABLE_IT
None:
Description:
Parameters:
120/692
DocID026525 Rev 1
UM1785
Return value:
None:
Description:
__HAL_CAN_DISABLE_IT
Parameters:
Return value:
__HAL_CAN_MSG_PENDING
None:
Description:
Parameters:
Return value:
CAN_FLAG_MASK
Description:
Parameters:
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
DocID026525 Rev 1
121/692
UM1785
Return value:
__HAL_CAN_GET_FLAG
__HAL_CAN_CLEAR_FLAG
Description:
Parameters:
122/692
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
DocID026525 Rev 1
UM1785
Return value:
__HAL_CAN_GET_IT_SOURCE
Description:
Parameters:
Return value:
__HAL_CAN_TRANSMIT_STATUS
Description:
Parameters:
Return value:
__HAL_CAN_FIFO_RELEASE
Description:
DocID026525 Rev 1
123/692
UM1785
Parameters:
Return value:
__HAL_CAN_CANCEL_TRANSMIT
None:
Description:
Parameters:
Return value:
__HAL_CAN_DBG_FREEZE
None:
Description:
Parameters:
Return value:
None:
CAN_FILTER_FIFO1
IS_CAN_FILTER_FIFO
CAN_FilterFIFO0
CAN_FilterFIFO1
CAN filter mode
CAN_FILTERMODE_IDMASK
CAN_FILTERMODE_IDLIST
IS_CAN_FILTER_MODE
CAN filter number
IS_CAN_FILTER_NUMBER
124/692
DocID026525 Rev 1
UM1785
CAN_FILTERSCALE_32BIT
IS_CAN_FILTER_SCALE
CAN flags
CAN_FLAG_RQCP0
CAN_FLAG_RQCP1
CAN_FLAG_RQCP2
CAN_FLAG_TXOK0
CAN_FLAG_TXOK1
CAN_FLAG_TXOK2
CAN_FLAG_TME0
CAN_FLAG_TME1
CAN_FLAG_TME2
CAN_FLAG_FF0
CAN_FLAG_FOV0
CAN_FLAG_FF1
CAN_FLAG_FOV1
CAN_FLAG_WKU
Wake up flag
CAN_FLAG_SLAK
CAN_FLAG_SLAKI
CAN_FLAG_EWG
CAN_FLAG_EPV
CAN_FLAG_BOF
Bus-Off flag
Standard Id
CAN_ID_EXT
Extended Id
IS_CAN_IDTYPE
CAN InitStatus
CAN_INITSTATUS_FAILED
CAN_INITSTATUS_SUCCESS
CAN initialization OK
CAN interrupts
CAN_IT_TME
CAN_IT_FMP0
CAN_IT_FF0
CAN_IT_FOV0
DocID026525 Rev 1
125/692
UM1785
FIFO 1 message pending interrupt
CAN_IT_FF1
CAN_IT_FOV1
CAN_IT_WKU
Wake-up interrupt
CAN_IT_SLK
CAN_IT_EWG
CAN_IT_EPV
CAN_IT_BOF
Bus-off interrupt
CAN_IT_LEC
CAN_IT_ERR
Error Interrupt
CAN_IT_RQCP0
CAN_IT_RQCP1
CAN_IT_RQCP2
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
IS_CAN_MODE
CAN Private Constants
HAL_CAN_DEFAULT_TIMEOUT
CAN receive FIFO number constants
CAN_FIFO0
CAN_FIFO1
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 synchronisation jump width
126/692
DocID026525 Rev 1
UM1785
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
CAN_BS1_4TQ
4 time quantum
CAN_BS1_5TQ
5 time quantum
CAN_BS1_6TQ
6 time quantum
CAN_BS1_7TQ
7 time quantum
CAN_BS1_8TQ
8 time quantum
CAN_BS1_9TQ
9 time quantum
CAN_BS1_10TQ
10 time quantum
CAN_BS1_11TQ
11 time quantum
CAN_BS1_12TQ
12 time quantum
CAN_BS1_13TQ
13 time quantum
CAN_BS1_14TQ
14 time quantum
CAN_BS1_15TQ
15 time quantum
CAN_BS1_16TQ
16 time quantum
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
DocID026525 Rev 1
127/692
UM1785
CAN transmission failed
CAN_TXSTATUS_OK
CAN_TXSTATUS_PENDING
CAN_TXSTATUS_NOMAILBOX
CAN Tx
IS_CAN_TRANSMITMAILBOX
IS_CAN_STDID
IS_CAN_EXTID
IS_CAN_DLC
128/692
DocID026525 Rev 1
UM1785
7.1
7.1.1
CEC_InitTypeDef
CEC_InitTypeDef is defined in the stm32f0xx_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
129/692
uint8_t CEC_InitTypeDef::InitiatorAddress
7.1.2
CEC_HandleTypeDef
CEC_HandleTypeDef is defined in the stm32f0xx_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
7.2
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
130/692
DocID026525 Rev 1
UM1785
7.2.1
3.
4.
7.2.2
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.
7.2.3
SignalFreeTime
Tolerance
ListenMode
HAL_CEC_Init()
HAL_CEC_DeInit()
HAL_CEC_MspInit()
HAL_CEC_MspDeInit()
IO operation function
HAL_CEC_Transmit()
HAL_CEC_Receive()
HAL_CEC_Transmit_IT()
HAL_CEC_Receive_IT()
HAL_CEC_IRQHandler()
DocID026525 Rev 1
131/692
7.2.4
UM1785
HAL_CEC_TxCpltCallback()
HAL_CEC_RxCpltCallback()
HAL_CEC_ErrorCallback()
7.2.5
7.2.6
7.2.7
132/692
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
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_CEC_DeInit
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_CEC_MspInit
DocID026525 Rev 1
UM1785
7.2.8
7.2.9
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_CEC_MspDeInit
Function Name
Function Description
Parameters
Return values
None.
Notes
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
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
133/692
7.2.10
7.2.11
7.2.12
134/692
UM1785
HAL_CEC_Receive
Function Name
HAL_StatusTypeDef HAL_CEC_Receive (
CEC_HandleTypeDef * hcec, uint8_t * pData, uint32_t
Timeout)
Function Description
Parameters
Return values
HAL status
Notes
None.
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
Parameters
Return values
HAL status
Notes
None.
HAL_CEC_Receive_IT
DocID026525 Rev 1
UM1785
7.2.13
7.2.14
HAL_StatusTypeDef HAL_CEC_Receive_IT (
CEC_HandleTypeDef * hcec, uint8_t * pData)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_CEC_IRQHandler
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_CEC_TxCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
135/692
7.2.15
7.2.16
7.2.17
136/692
UM1785
HAL_CEC_RxCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_CEC_ErrorCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_CEC_GetState
Function Name
HAL_CEC_StateTypeDef HAL_CEC_GetState (
CEC_HandleTypeDef * hcec)
Function Description
Parameters
Return values
HAL state
Notes
None.
DocID026525 Rev 1
UM1785
7.2.18
HAL_CEC_GetError
Function Name
Function Description
Parameters
Return values
Notes
None.
7.3
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
Error Bit Generation on Broadcast message
CEC_BROADCASTERROR_ERRORBIT_GENERATION
CEC_BROADCASTERROR_NO_ERRORBIT_GENERATION
IS_CEC_BROADCASTERROR_NO_ERRORBIT_GENERATION
CEC Exported Macros
__HAL_CEC_RESET_HANDLE_STATE
Description:
Parameters:
Return value:
DocID026525 Rev 1
137/692
UM1785
None:
Description:
__HAL_CEC_GET_IT
Parameters:
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_TXERR : Tx
Error
CEC_ISR_TXACKE : Tx
Missing Acknowledge
Return value:
ITStatus:
Description:
__HAL_CEC_CLEAR_FLAG
Parameters:
138/692
DocID026525 Rev 1
UM1785
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_TXERR : Tx
Error
CEC_ISR_TXACKE : Tx
Missing Acknowledge
Return value:
none:
Description:
__HAL_CEC_ENABLE_IT
Parameters:
DocID026525 Rev 1
CEC_IER_RXENDIE :
End Of Reception IT
Enable
CEC_IER_BREIE : Rx Bit
Rising Error IT Enable
CEC_IER_SBPEIE : Rx
Short Bit period Error IT
Enable
139/692
UM1785
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
Parameters:
140/692
DocID026525 Rev 1
CEC_IER_RXENDIE :
End Of Reception 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
UM1785
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:
Parameters:
DocID026525 Rev 1
CEC_IER_RXENDIE :
End Of Reception 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_TXERRIE : Tx141/692
UM1785
Error IT Enable
CEC_IER_TXACKEIE : Tx
Missing Acknowledge IT
Enable
Return value:
FlagStatus:
Description:
__HAL_CEC_ENABLE
Parameters:
Return value:
none:
Description:
__HAL_CEC_DISABLE
Parameters:
Return value:
__HAL_CEC_FIRST_BYTE_TX_SET
none:
Description:
Parameters:
Return value:
__HAL_CEC_LAST_BYTE_TX_SET
none:
Description:
Parameters:
Return value:
__HAL_CEC_GET_TRANSMISSION_START_FLA
G
142/692
DocID026525 Rev 1
Description:
UM1785
Return value:
__HAL_CEC_GET_TRANSMISSION_END_FLAG
FlagStatus:
Description:
Parameters:
Return value:
FlagStatus:
Description:
__HAL_CEC_CLEAR_OAR
Parameters:
Return value:
none:
Description:
__HAL_CEC_SET_OAR
Parameters:
Return value:
none:
Description:
IS_CEC_OAR_ADDRESS
Parameters:
Return value:
DocID026525 Rev 1
143/692
UM1785
Description:
IS_CEC_ADDRESS
Parameters:
Return value:
Description:
IS_CEC_MSGSIZE
Parameters:
Return value:
144/692
DocID026525 Rev 1
UM1785
DocID026525 Rev 1
145/692
UM1785
8.1
8.1.1
COMP_InitTypeDef
COMP_InitTypeDef is defined in the stm32f0xx_hal_comp.h
Data Fields
uint32_t InvertingInput
uint32_t NonInvertingInput
uint32_t Output
uint32_t OutputPol
uint32_t Hysteresis
uint32_t Mode
uint32_t WindowMode
uint32_t TriggerMode
Field Documentation
8.1.2
COMP_HandleTypeDef
COMP_HandleTypeDef is defined in the stm32f0xx_hal_comp.h
Data Fields
COMP_TypeDef * Instance
COMP_InitTypeDef Init
HAL_LockTypeDef Lock
__IO HAL_COMP_StateTypeDef State
Field Documentation
146/692
DocID026525 Rev 1
UM1785
8.2
8.2.1
The non inverting input and inverting input can be set to GPIO pins as shown in
table1. COMP Inputs below.
The COMP output is available using HAL_COMP_GetOutputLevel() and can be set
on GPIO pins. Refer to table 2. COMP Outputs below.
The COMP output can be redirected to embedded timers (TIM1, TIM2 and TIM3)
Refer to table 3. COMP Outputs redirection to embedded timers below.
The comparators COMP1 and COMP2 can be combined in window mode.
The comparators have interrupt capability with wake-up from Sleep and Stop modes
(through the EXTI controller):
COMP_EXTI_LINE_COMP1_EVENT
COMP_EXTI_LINE_COMP2_EVENT
Table 16: COMP Inputs for STM32F05xx, STM32F07x and STM32F09x devices
Inverting inputs
1/4 VREFINT
1/2 VREFINT
3/4 VREFINT
VREFINT
DAC1 OUT (PA4)
DAC2 OUT (PA5)
I/O1
Non-inverting inputs
COMP1
COMP2
OK
OK
OK
OK
OK
OK
PA0
OK
OK
OK
OK
OK
OK
PA2
PA1
PA3
Table 17: COMP outputs for STM32F05xx, STM32F07x and STM32F09x devices
COMP1
COMP2
PA0
PA2
PA6
PA7
PA11
PA12
DocID026525 Rev 1
147/692
UM1785
Table 18: Redirection of COMP outputs to embedded timers for STM32F05xx, STM32F07x and
STM32F09x devices
8.2.2
COMP1
COMP2
TIM1 BKIN
TIM1 BKIN
TIM1 OCREFCLR
TIM1 OCREFCLR
TIM1 IC1
TIM1 IC1
TIM2 IC4
TIM2 IC4
TIM2 OCREFCLR
TIM2 OCREFCLR
TIM3 IC1
TIM3 IC3
TIM3 OCREFCLR
TIM3 OCREFCLR
2.
3.
4.
8.2.3
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:
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.
148/692
DocID026525 Rev 1
UM1785
8.2.5
HAL_COMP_Start()
HAL_COMP_Stop()
HAL_COMP_Start_IT()
HAL_COMP_Stop_IT()
HAL_COMP_IRQHandler()
8.2.6
HAL_COMP_Lock()
HAL_COMP_GetOutputLevel()
HAL_COMP_TriggerCallback()
8.2.7
8.2.8
HAL_COMP_GetState()
HAL_COMP_Init
Function Name
Function Description
Parameters
Return values
HAL status
Notes
HAL_COMP_DeInit
Function Name
HAL_StatusTypeDef HAL_COMP_DeInit (
COMP_HandleTypeDef * hcomp)
Function Description
Parameters
Return values
HAL status
DocID026525 Rev 1
149/692
8.2.9
8.2.10
8.2.11
150/692
UM1785
HAL_COMP_MspInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_COMP_MspDeInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_COMP_Start
Function Name
HAL_StatusTypeDef HAL_COMP_Start (
COMP_HandleTypeDef * hcomp)
Function Description
Parameters
DocID026525 Rev 1
UM1785
8.2.12
8.2.13
8.2.14
HAL status
Notes
None.
HAL_COMP_Stop
Function Name
HAL_StatusTypeDef HAL_COMP_Stop (
COMP_HandleTypeDef * hcomp)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_COMP_Start_IT
Function Name
HAL_StatusTypeDef HAL_COMP_Start_IT (
COMP_HandleTypeDef * hcomp)
Function Description
Parameters
Return values
HAL status.
Notes
None.
HAL_COMP_Stop_IT
Function Name
HAL_StatusTypeDef HAL_COMP_Stop_IT (
COMP_HandleTypeDef * hcomp)
Function Description
Parameters
DocID026525 Rev 1
151/692
8.2.15
8.2.16
8.2.17
152/692
UM1785
HAL status
None.
HAL_COMP_IRQHandler
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_COMP_Lock
Function Name
HAL_StatusTypeDef HAL_COMP_Lock (
COMP_HandleTypeDef * hcomp)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_COMP_GetOutputLevel
Function Name
Function Description
Notes
None.
DocID026525 Rev 1
UM1785
8.2.18
8.2.19
HAL_COMP_TriggerCallback
Function Name
Function Description
Comparator callback.
Parameters
Return values
None.
Notes
None.
HAL_COMP_GetState
Function Name
HAL_COMP_StateTypeDef HAL_COMP_GetState (
COMP_HandleTypeDef * hcomp)
Function Description
Parameters
Return values
HAL state
Notes
None.
8.3
8.3.1
COMP
COMP
COMP Exported Macros
__HAL_COMP_RESET_HANDLE_STATE
Description:
Parameters:
DocID026525 Rev 1
153/692
UM1785
Return value:
__HAL_COMP_EXTI_GET_FLAG
None:
Description:
Parameters:
Return value:
__HAL_COMP_EXTI_CLEAR_FLAG
Description:
Parameters:
Return value:
__HAL_COMP_EXTI_ENABLE_IT
None.:
Description:
Parameters:
Return value:
__HAL_COMP_EXTI_DISABLE_IT
None.:
Description:
Parameters:
Return value:
__HAL_COMP_EXTI_RISING_IT_ENABLE
None.:
Description:
Parameters:
154/692
DocID026525 Rev 1
UM1785
Return value:
__HAL_COMP_EXTI_RISING_IT_DISABLE
None.:
Description:
Parameters:
Return value:
__HAL_COMP_EXTI_FALLING_IT_ENABLE
None.:
Description:
Parameters:
Return value:
__HAL_COMP_EXTI_FALLING_IT_DISABLE
None.:
Description:
Parameters:
Return value:
__HAL_COMP_GET_EXTI_LINE
None.:
Description:
Parameters:
Return value:
value: of
COMP ExtiLineEvent
DocID026525 Rev 1
155/692
UM1785
External interrupt line 21 Connected to COMP1
External interrupt line 22 Connected to COMP2
COMP Hysteresis
COMP_HYSTERESIS_NONE
No hysteresis
COMP_HYSTERESIS_LOW
COMP_HYSTERESIS_MEDIUM
COMP_HYSTERESIS_HIGH
IS_COMP_HYSTERESIS
COMP InvertingInput
COMP_INVERTINGINPUT_1_4VREFINT
COMP_INVERTINGINPUT_1_2VREFINT
COMP_INVERTINGINPUT_3_4VREFINT
COMP_INVERTINGINPUT_VREFINT
COMP_INVERTINGINPUT_DAC1
COMP_INVERTINGINPUT_DAC1SWITCHCLOSED
COMP_INVERTINGINPUT_DAC2
COMP_INVERTINGINPUT_IO1
IS_COMP_INVERTINGINPUT
COMP Lock
COMP_LOCK_DISABLE
COMP_LOCK_ENABLE
COMP_STATE_BIT_LOCK
COMP Mode
COMP_MODE_HIGHSPEED
High Speed
COMP_MODE_MEDIUMSPEED
Medium Speed
COMP_MODE_LOWPOWER
COMP_MODE_ULTRALOWPOWER
IS_COMP_MODE
COMP NonInvertingInput
COMP_NONINVERTINGINPUT_IO1
156/692
DocID026525 Rev 1
UM1785
IS_COMP_NONINVERTINGINPUT
COMP Output
COMP_OUTPUT_NONE
COMP_OUTPUT_TIM1BKIN
COMP_OUTPUT_TIM1IC1
COMP_OUTPUT_TIM1OCREFCLR
COMP_OUTPUT_TIM2IC4
COMP_OUTPUT_TIM2OCREFCLR
COMP_OUTPUT_TIM3IC1
COMP_OUTPUT_TIM3OCREFCLR
IS_COMP_OUTPUT
COMP OutputLevel
COMP_OUTPUTLEVEL_LOW
COMP_OUTPUTLEVEL_HIGH
COMP OutputPolarity
COMP_OUTPUTPOL_NONINVERTED
COMP_OUTPUTPOL_INVERTED
IS_COMP_OUTPUTPOL
COMP Private Constants
COMP_CSR_RESET_VALUE
COMP_CSR_RESET_PARAMETERS_MASK
COMP_CSR_UPDATE_PARAMETERS_MASK
COMP_CSR_COMPxNONINSEL_MASK
COMP_CSR_COMP1_SHIFT
COMP_CSR_COMP2_SHIFT
COMP TriggerMode
COMP_TRIGGERMODE_NONE
COMP_TRIGGERMODE_IT_RISING
COMP_TRIGGERMODE_IT_FALLING
COMP_TRIGGERMODE_IT_RISING_FALLING
DocID026525 Rev 1
157/692
UM1785
COMP WindowMode
COMP_WINDOWMODE_DISABLED
COMP_WINDOWMODE_ENABLED
IS_COMP_WINDOWMODE
158/692
DocID026525 Rev 1
UM1785
9.1
9.1.1
2.
3.
Enable and Configure the priority of the selected IRQ Channels. The priority can be
0..3. Lower priority values gives higher priority. Priority Order: Lowest priority.
Lowest hardware priority (IRQn position).
Configure the priority of the selected IRQ Channels using HAL_NVIC_SetPriority()
Enable the selected IRQ Channels using HAL_NVIC_EnableIRQ()
9.1.2
Configures the SysTick Reload register with value passed as function parameter.
Configures the SysTick Counter clock source to be Core Clock Source (HCLK).
DocID026525 Rev 1
159/692
9.1.3
HAL_NVIC_SetPriority()
HAL_NVIC_EnableIRQ()
HAL_NVIC_DisableIRQ()
HAL_NVIC_SystemReset()
HAL_SYSTICK_Config()
9.1.4
HAL_NVIC_GetPriority()
HAL_NVIC_SetPendingIRQ()
HAL_NVIC_GetPendingIRQ()
HAL_NVIC_ClearPendingIRQ()
HAL_SYSTICK_CLKSourceConfig()
HAL_SYSTICK_IRQHandler()
HAL_SYSTICK_Callback()
HAL_NVIC_SetPriority
Function Name
Function Description
Parameters
9.1.5
160/692
Return values
None.
Notes
None.
HAL_NVIC_EnableIRQ
DocID026525 Rev 1
UM1785
9.1.6
9.1.7
Function Name
Function Description
Parameters
Return values
None.
Notes
HAL_NVIC_DisableIRQ
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_NVIC_SystemReset
Function Name
Function Description
Return values
None.
Notes
None.
DocID026525 Rev 1
161/692
9.1.8
9.1.9
9.1.10
162/692
UM1785
HAL_SYSTICK_Config
Function Name
Function Description
Initializes the System Timer and its interrupt, and starts the
System Tick Timer.
Parameters
Return values
1 Function failed.
Notes
None.
HAL_NVIC_GetPriority
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_NVIC_SetPendingIRQ
Function Name
Function Description
Parameters
Return values
None.
DocID026525 Rev 1
UM1785
9.1.11
9.1.12
9.1.13
None.
HAL_NVIC_GetPendingIRQ
Function Name
Function Description
Parameters
Return values
Notes
None.
HAL_NVIC_ClearPendingIRQ
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SYSTICK_CLKSourceConfig
Function Name
163/692
9.1.14
9.1.15
UM1785
Configures the SysTick clock source.
Parameters
Return values
None.
Notes
None.
HAL_SYSTICK_IRQHandler
Function Name
Function Description
Return values
None.
Notes
None.
HAL_SYSTICK_Callback
Function Name
Function Description
SYSTICK callback.
Return values
None.
Notes
None.
9.2
9.2.1
CORTEX
CORTEX
CORTEX Exported Macro
164/692
DocID026525 Rev 1
UM1785
Description:
Parameters:
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 Priority
IS_NVIC_PREEMPTION_PRIORITY
CORTEX SysTick clock source
SYSTICK_CLKSOURCE_HCLK_DIV8
SYSTICK_CLKSOURCE_HCLK
IS_SYSTICK_CLK_SOURCE
DocID026525 Rev 1
165/692
UM1785
10
10.1
10.1.1
CRC_InitTypeDef
CRC_InitTypeDef is defined in the stm32f0xx_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
166/692
DocID026525 Rev 1
UM1785
10.1.2
CRC_HandleTypeDef
CRC_HandleTypeDef is defined in the stm32f0xx_hal_crc.h
Data Fields
CRC_TypeDef * Instance
CRC_InitTypeDef Init
HAL_LockTypeDef Lock
__IO HAL_CRC_StateTypeDef State
uint32_t InputDataFormat
Field Documentation
10.2
10.2.1
1.
2.
3.
DocID026525 Rev 1
167/692
10.2.2
10.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()
10.2.4
10.2.5
168/692
HAL_CRC_GetState()
HAL_CRC_Init
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
UM1785
10.2.6
10.2.7
10.2.8
HAL_CRC_DeInit
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_CRC_MspInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_CRC_MspDeInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
169/692
10.2.9
UM1785
HAL_CRC_Accumulate
Function Name
Function Description
Parameters
10.2.10
Return values
Notes
None.
HAL_CRC_Calculate
Function Name
Function Description
Parameters
10.2.11
Return values
Notes
None.
HAL_CRC_GetState
Function Name
170/692
HAL_CRC_StateTypeDef HAL_CRC_GetState (
DocID026525 Rev 1
UM1785
Parameters
Return values
HAL state
Notes
None.
10.3
10.3.1
CRC
CRC
Aliases for inter STM32 series compatibility
HAL_CRC_Input_Data_Reverse
HAL_CRC_Output_Data_Reverse
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:
Parameters:
Return value:
__HAL_CRC_DR_RESET
None:
Description:
DocID026525 Rev 1
171/692
UM1785
Parameters:
Return value:
__HAL_CRC_INITIALCRCVALUE_CONFIG
None.:
Description:
Parameters:
Return value:
172/692
DocID026525 Rev 1
None.:
UM1785
11
11.1
11.1.1
11.1.2
11.1.3
Extended initialization
Set or not user-defined generating polynomial other than default one
11.1.4
11.1.5
HAL_CRCEx_Init
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_CRCEx_Input_Data_Reverse
DocID026525 Rev 1
173/692
11.1.6
11.1.7
174/692
UM1785
Function Name
HAL_StatusTypeDef HAL_CRCEx_Input_Data_Reverse (
CRC_HandleTypeDef * hcrc, uint32_t InputReverseMode)
Function Description
Parameters
CRC_INPUTDATA_INVERSION_HALFWORD
HalfWord-wise bit reversal
Return values
HAL status
Notes
None.
HAL_CRCEx_Output_Data_Reverse
Function Name
HAL_StatusTypeDef HAL_CRCEx_Output_Data_Reverse (
CRC_HandleTypeDef * hcrc, uint32_t OutputReverseMode)
Function Description
Parameters
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
Notes
None.
HAL_CRCEx_Polynomial_Set
DocID026525 Rev 1
UM1785
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
11.2
11.2.1
CRCEx
CRCEx
CRCEx Exported Macros
__HAL_CRC_OUTPUTREVERSAL_ENABLE
Description:
Parameters:
Return value:
__HAL_CRC_OUTPUTREVERSAL_DISABLE
None.:
Description:
Parameters:
Return value:
DocID026525 Rev 1
None.:
175/692
UM1785
Description:
Parameters:
Return value:
176/692
DocID026525 Rev 1
None.:
UM1785
12
12.1
12.1.1
DAC_HandleTypeDef
DAC_HandleTypeDef is defined in the stm32f0xx_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
12.1.2
DAC_ChannelConfTypeDef
DAC_ChannelConfTypeDef is defined in the stm32f0xx_hal_dac.h
Data Fields
uint32_t DAC_Trigger
uint32_t DAC_OutputBuffer
Field Documentation
12.2
DocID026525 Rev 1
177/692
12.2.1
UM1785
DAC Channels
STM32F0 devices integrates no, one or two 12-bit Digital Analog Converters. STM32F05x
devices have one converter (channel1) STM32F07x & STM32F09x devices have two
converters (i.e. channel1 & channel2) When 2 converters are present (i.e. channel1 &
channel2) they can be used independently or simultaneously (dual mode):
1.
2.
DAC Triggers
Digital to Analog conversion can be non-triggered using DAC_Trigger_None and
DAC_OUT1/DAC_OUT2 is available once writing to DHRx register.
Digital to Analog conversion can be triggered by:
1.
2.
3.
Noise wave
Triangle wave
DocID026525 Rev 1
UM1785
DMA requests
A DMA1 request can be generated when an external trigger (but not a software trigger)
occurs if DMA1 requests are enabled using HAL_DAC_Start_DMA()
DMA1 requests are mapped as following:
1.
2.
12.2.2
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
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
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()
179/692
UM1785
12.2.3
12.2.4
IO operation functions
This section provides functions allowing to:
12.2.5
Start conversion.
Stop conversion.
Start conversion and enable DMA transfer.
Stop conversion and disable DMA transfer.
Get result of conversion.
HAL_DAC_Start()
HAL_DAC_Stop()
HAL_DAC_Start_DMA()
HAL_DAC_Stop_DMA()
HAL_DAC_ConvCpltCallbackCh1()
HAL_DAC_ConvHalfCpltCallbackCh1()
HAL_DAC_ErrorCallbackCh1()
HAL_DAC_DMAUnderrunCallbackCh1()
12.2.6
Configure channels.
Set the specified data holding register value for DAC channel.
HAL_DAC_ConfigChannel()
HAL_DAC_SetValue()
HAL_DAC_GetValue()
180/692
UM1785
12.2.7
12.2.8
12.2.9
HAL_DAC_Init
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_DAC_DeInit
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_DAC_MspInit
Function Name
Function Description
Parameters
DocID026525 Rev 1
181/692
12.2.10
12.2.11
UM1785
contains the configuration information for the specified DAC.
Return values
None.
Notes
None.
HAL_DAC_MspDeInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_DAC_Start
Function Name
Function Description
Parameters
12.2.12
182/692
Return values
HAL status
Notes
None.
HAL_DAC_Stop
DocID026525 Rev 1
UM1785
Function Name
Function Description
Parameters
12.2.13
Return values
HAL status
Notes
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
Parameters
12.2.14
Return values
HAL status
Notes
None.
HAL_DAC_Stop_DMA
DocID026525 Rev 1
183/692
UM1785
Function Name
HAL_StatusTypeDef HAL_DAC_Stop_DMA (
DAC_HandleTypeDef * hdac, uint32_t Channel)
Function Description
Parameters
12.2.15
12.2.16
184/692
Return values
HAL status
Notes
None.
HAL_DAC_ConvCpltCallbackCh1
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_DAC_ConvHalfCpltCallbackCh1
Function Name
void HAL_DAC_ConvHalfCpltCallbackCh1 (
DAC_HandleTypeDef * hdac)
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
UM1785
12.2.17
12.2.18
12.2.19
HAL_DAC_ErrorCallbackCh1
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_DAC_DMAUnderrunCallbackCh1
Function Name
void HAL_DAC_DMAUnderrunCallbackCh1 (
DAC_HandleTypeDef * hdac)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_DAC_ConfigChannel
Function Name
HAL_StatusTypeDef HAL_DAC_ConfigChannel (
DAC_HandleTypeDef * hdac, DAC_ChannelConfTypeDef *
sConfig, uint32_t Channel)
Function Description
Parameters
185/692
12.2.20
UM1785
Return values
HAL status
Notes
None.
HAL_DAC_SetValue
Function Name
HAL_StatusTypeDef HAL_DAC_SetValue (
DAC_HandleTypeDef * hdac, uint32_t Channel, uint32_t
Alignment, uint32_t Data)
Function Description
Set the specified data holding register value for DAC channel.
Parameters
12.2.21
186/692
Return values
HAL status
Notes
None.
HAL_DAC_GetValue
Function Name
Function Description
Returns the last data output value of the selected DAC channel.
DocID026525 Rev 1
UM1785
12.2.22
12.2.23
12.2.24
Return values
Notes
None.
HAL_DAC_GetState
Function Name
HAL_DAC_StateTypeDef HAL_DAC_GetState (
DAC_HandleTypeDef * hdac)
Function Description
Parameters
Return values
HAL state
Notes
None.
HAL_DAC_GetError
Function Name
Function Description
Parameters
Return values
Notes
None.
HAL_DAC_IRQHandler
DocID026525 Rev 1
187/692
UM1785
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
12.3
12.3.1
DAC
DAC
DAC Channel selection
DAC_CHANNEL_1
DAC_CHANNEL_2
IS_DAC_CHANNEL
DAC data
IS_DAC_DATA
DAC data alignement
DAC_ALIGN_12B_R
DAC_ALIGN_12B_L
DAC_ALIGN_8B_R
IS_DAC_ALIGN
DAC Error Code
HAL_DAC_ERROR_NONE
No error
HAL_DAC_ERROR_DMAUNDERRUNCH1
HAL_DAC_ERROR_DMAUNDERRUNCH2
HAL_DAC_ERROR_DMA
DMA error
Description:
Parameters:
Return value:
188/692
DocID026525 Rev 1
UM1785
None:
Description:
__HAL_DAC_ENABLE
Parameters:
Return value:
None:
Description:
__HAL_DAC_DISABLE
Parameters:
Return value:
__HAL_DHR12R1_ALIGNEMENT
None:
Description:
Parameters:
Return value:
__HAL_DHR12R2_ALIGNEMENT
None:
Description:
Parameters:
Return value:
__HAL_DHR12RD_ALIGNEMENT
None:
Description:
Parameters:
Return value:
None:
DocID026525 Rev 1
189/692
UM1785
Description:
Parameters:
Return value:
None:
Description:
__HAL_DAC_DISABLE_IT
Parameters:
Return value:
None:
Description:
__HAL_DAC_GET_FLAG
Parameters:
Return value:
None:
Description:
__HAL_DAC_CLEAR_FLAG
Parameters:
Return value:
None:
DocID026525 Rev 1
UM1785
DAC_TRIGGER_T2_TRGO
DAC_TRIGGER_T3_TRGO
DAC_TRIGGER_T6_TRGO
DAC_TRIGGER_T7_TRGO
DAC_TRIGGER_T15_TRGO
DAC_TRIGGER_EXT_IT9
DAC_TRIGGER_SOFTWARE
IS_DAC_TRIGGER
DocID026525 Rev 1
191/692
UM1785
13
13.1
13.1.1
13.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.
13.1.3
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_ConfigChannel()
HAL_DAC_GetValue()
HAL_DAC_Start()
HAL_DAC_Start_DMA()
HAL_DAC_IRQHandler()
HAL_DACEx_DualGetValue()
HAL_DACEx_TriangleWaveGenerate()
HAL_DACEx_NoiseWaveGenerate()
HAL_DACEx_DualSetValue()
HAL_DACEx_ConvCpltCallbackCh2()
HAL_DACEx_ConvHalfCpltCallbackCh2()
HAL_DACEx_ErrorCallbackCh2()
HAL_DACEx_DMAUnderrunCallbackCh2()
DAC_DMAConvCpltCh2()
DAC_DMAHalfConvCpltCh2()
DAC_DMAErrorCh2()
HAL_DAC_ConfigChannel
Function Name
192/692
HAL_StatusTypeDef HAL_DAC_ConfigChannel (
DAC_HandleTypeDef * hdac, DAC_ChannelConfTypeDef *
DocID026525 Rev 1
UM1785
Parameters
13.1.4
Return values
HAL status
Notes
None.
HAL_DAC_GetValue
Function Name
Function Description
Returns the last data output value of the selected DAC channel.
Parameters
13.1.5
Return values
Notes
None.
HAL_DAC_Start
Function Name
Function Description
Parameters
193/692
UM1785
13.1.6
Return values
HAL status
Notes
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
Parameters
13.1.7
194/692
Return values
HAL status
Notes
None.
HAL_DAC_IRQHandler
Function Name
Function Description
Parameters
Return values
None.
DocID026525 Rev 1
UM1785
13.1.8
13.1.9
None.
HAL_DACEx_DualGetValue
Function Name
Function Description
Returns the last data output value of the selected DAC channel.
Parameters
Return values
Notes
None.
HAL_DACEx_TriangleWaveGenerate
Function Name
HAL_StatusTypeDef HAL_DACEx_TriangleWaveGenerate (
DAC_HandleTypeDef * hdac, uint32_t Channel, uint32_t
Amplitude)
Function Description
Parameters
195/692
UM1785
13.1.10
Return values
HAL status
Notes
None.
HAL_DACEx_NoiseWaveGenerate
Function Name
HAL_StatusTypeDef HAL_DACEx_NoiseWaveGenerate (
DAC_HandleTypeDef * hdac, uint32_t Channel, uint32_t
Amplitude)
Function Description
Parameters
196/692
UM1785
13.1.11
Return values
HAL status
Notes
None.
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
13.1.12
Return values
HAL status
Notes
HAL_DACEx_ConvCpltCallbackCh2
Function Name
void HAL_DACEx_ConvCpltCallbackCh2 (
DAC_HandleTypeDef * hdac)
DocID026525 Rev 1
197/692
13.1.13
13.1.14
13.1.15
198/692
UM1785
Conversion complete callback in non blocking mode for Channel2.
Parameters
Return values
None.
Notes
None.
HAL_DACEx_ConvHalfCpltCallbackCh2
Function Name
void HAL_DACEx_ConvHalfCpltCallbackCh2 (
DAC_HandleTypeDef * hdac)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_DACEx_ErrorCallbackCh2
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_DACEx_DMAUnderrunCallbackCh2
DocID026525 Rev 1
UM1785
13.1.16
13.1.17
void HAL_DACEx_DMAUnderrunCallbackCh2 (
DAC_HandleTypeDef * hdac)
Function Description
Parameters
Return values
None.
Notes
None.
DAC_DMAConvCpltCh2
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
DAC_DMAHalfConvCpltCh2
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
199/692
13.1.18
UM1785
DAC_DMAErrorCh2
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
13.2
13.2.1
DACEx
DACEx
DACEx lfsrunmask triangleamplitude
200/692
DAC_LFSRUNMASK_BIT0
DAC_LFSRUNMASK_BITS1_0
DAC_LFSRUNMASK_BITS2_0
DAC_LFSRUNMASK_BITS3_0
DAC_LFSRUNMASK_BITS4_0
DAC_LFSRUNMASK_BITS5_0
DAC_LFSRUNMASK_BITS6_0
DAC_LFSRUNMASK_BITS7_0
DAC_LFSRUNMASK_BITS8_0
DAC_LFSRUNMASK_BITS9_0
DAC_LFSRUNMASK_BITS10_0
DAC_LFSRUNMASK_BITS11_0
DocID026525 Rev 1
UM1785
DAC_TRIANGLEAMPLITUDE_3
DAC_TRIANGLEAMPLITUDE_7
DAC_TRIANGLEAMPLITUDE_15
DAC_TRIANGLEAMPLITUDE_31
DAC_TRIANGLEAMPLITUDE_63
DAC_TRIANGLEAMPLITUDE_127
DAC_TRIANGLEAMPLITUDE_255
DAC_TRIANGLEAMPLITUDE_511
DAC_TRIANGLEAMPLITUDE_1023
DAC_TRIANGLEAMPLITUDE_2047
DAC_TRIANGLEAMPLITUDE_4095
IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE
DACEx wave generation
DAC_WAVEGENERATION_NONE
DAC_WAVEGENERATION_NOISE
DAC_WAVEGENERATION_TRIANGLE
IS_DAC_GENERATE_WAVE
DACEx wave generation bis
DAC_WAVE_NOISE
DAC_WAVE_TRIANGLE
IS_DAC_WAVE
DocID026525 Rev 1
201/692
UM1785
14
14.1
14.1.1
DMA_InitTypeDef
DMA_InitTypeDef is defined in the stm32f0xx_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
14.1.2
__DMA_HandleTypeDef
__DMA_HandleTypeDef is defined in the stm32f0xx_hal_dma.h
Data Fields
202/692
DMA_Channel_TypeDef * Instance
DMA_InitTypeDef Init
HAL_LockTypeDef Lock
HAL_DMA_StateTypeDef State
void * Parent
void(* XferCpltCallback
DocID026525 Rev 1
UM1785
void(* XferHalfCpltCallback
void(* XferErrorCallback
__IO uint32_t ErrorCode
Field Documentation
14.2
14.2.1
1.
2.
3.
4.
Enable and configure the peripheral to be connected to the DMA Channel (except for
internal SRAM / FLASH memories: no initialization is necessary) please refer to
Reference manual for connection between peripherals and DMA requests .
For a given Channel, program the required configuration through the following
parameters: Transfer Direction, Source and Destination data formats, Circular or
Normal mode, Channel Priority level, Source and Destination Increment mode, using
HAL_DMA_Init() function.
Use HAL_DMA_GetState() function to return the DMA state and
HAL_DMA_GetError() in case of error detection.
Use HAL_DMA_Abort() function to abort the current transfer In Memory-to-Memory
transfer mode, Circular mode is not allowed.
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.
203/692
UM1785
14.2.2
14.2.3
HAL_DMA_Init()
HAL_DMA_DeInit()
IO operation functions
This section provides functions allowing to:
204/692
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()
DocID026525 Rev 1
UM1785
14.2.4
14.2.5
14.2.6
14.2.7
HAL_DMA_Init
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_DMA_DeInit
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_DMA_Start
DocID026525 Rev 1
205/692
UM1785
HAL_StatusTypeDef HAL_DMA_Start ( DMA_HandleTypeDef *
hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t
DataLength)
Function Description
Parameters
14.2.8
Return values
HAL status
Notes
None.
HAL_DMA_Start_IT
Function Name
HAL_StatusTypeDef HAL_DMA_Start_IT (
DMA_HandleTypeDef * hdma, uint32_t SrcAddress, uint32_t
DstAddress, uint32_t DataLength)
Function Description
Parameters
14.2.9
206/692
Return values
HAL status
Notes
None.
HAL_DMA_Abort
Function Name
Function Description
DocID026525 Rev 1
UM1785
14.2.10
14.2.11
Return values
HAL status
Notes
After disabling a DMA Channel, a check for wait until the DMA
Channel is effectively disabled is added. If a Channel is
disabled while a data transfer is ongoing, the current data will
be transferred and the Channel will be effectively disabled
only after the transfer of this single data is finished.
HAL_DMA_PollForTransfer
Function Name
HAL_StatusTypeDef HAL_DMA_PollForTransfer (
DMA_HandleTypeDef * hdma, uint32_t CompleteLevel,
uint32_t Timeout)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_DMA_IRQHandler
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
207/692
14.2.12
14.2.13
UM1785
HAL_DMA_GetState
Function Name
HAL_DMA_StateTypeDef HAL_DMA_GetState (
DMA_HandleTypeDef * hdma)
Function Description
Parameters
Return values
HAL state
Notes
None.
HAL_DMA_GetError
Function Name
Function Description
Parameters
Return values
Notes
None.
14.3
14.3.1
DMA
DMA
DMA Data buffer size
IS_DMA_BUFFER_SIZE
DMA Data transfer direction
DMA_PERIPH_TO_MEMORY
208/692
DocID026525 Rev 1
UM1785
DMA_MEMORY_TO_MEMORY
IS_DMA_DIRECTION
DMA Error Code
HAL_DMA_ERROR_NONE
No error
HAL_DMA_ERROR_TE
Transfer error
HAL_DMA_ERROR_TIMEOUT
Timeout error
Description:
Parameters:
Return value:
__HAL_DMA_ENABLE
None:
Description:
Parameters:
Return value:
__HAL_DMA_DISABLE
None.:
Description:
Parameters:
Return value:
__HAL_DMA_ENABLE_IT
None.:
Description:
Parameters:
DocID026525 Rev 1
209/692
UM1785
mask
Return value:
None:
Description:
__HAL_DMA_DISABLE_IT
Parameters:
Return value:
__HAL_DMA_GET_IT_SOURCE
None:
Description:
Parameters:
Return value:
210/692
DocID026525 Rev 1
UM1785
DMA_MDATAALIGN_HALFWORD
DMA_MDATAALIGN_WORD
IS_DMA_MEMORY_DATA_SIZE
DMA Memory incremented mode
DMA_MINC_ENABLE
DMA_MINC_DISABLE
IS_DMA_MEMORY_INC_STATE
DMA mode
DocID026525 Rev 1
211/692
UM1785
Normal Mode
Circular Mode
IS_DMA_MODE
DMA Peripheral data size
DMA_PDATAALIGN_BYTE
DMA_PDATAALIGN_HALFWORD
DMA_PDATAALIGN_WORD
IS_DMA_PERIPHERAL_DATA_SIZE
DMA Peripheral incremented mode
DMA_PINC_ENABLE
DMA_PINC_DISABLE
IS_DMA_PERIPHERAL_INC_STATE
DMA Priority level
DMA_PRIORITY_LOW
DMA_PRIORITY_MEDIUM
DMA_PRIORITY_HIGH
DMA_PRIORITY_VERY_HIGH
IS_DMA_PRIORITY
DMA Private Constants
HAL_TIMEOUT_DMA_ABORT
212/692
DocID026525 Rev 1
UM1785
15
15.1
15.1.1
DMAEx
DMAEx
DMAEx Exported Constants
DMA1_CHANNEL1_RMP
DMA1_CHANNEL2_RMP
DMA1_CHANNEL3_RMP
DMA1_CHANNEL4_RMP
DMA1_CHANNEL5_RMP
DMA1_CHANNEL6_RMP
DMA1_CHANNEL7_RMP
DMA2_CHANNEL1_RMP
DMA2_CHANNEL2_RMP
DMA2_CHANNEL3_RMP
DMA2_CHANNEL4_RMP
DMA2_CHANNEL5_RMP
HAL_DMA1_CH1_DEFAULT
HAL_DMA1_CH1_ADC
HAL_DMA1_CH1_TIM17_CH1
HAL_DMA1_CH1_TIM17_UP
HAL_DMA1_CH1_USART1_RX
HAL_DMA1_CH1_USART2_RX
HAL_DMA1_CH1_USART3_RX
HAL_DMA1_CH1_USART4_RX
HAL_DMA1_CH1_USART5_RX
HAL_DMA1_CH1_USART6_RX
HAL_DMA1_CH1_USART7_RX
HAL_DMA1_CH1_USART8_RX
HAL_DMA1_CH2_DEFAULT
HAL_DMA1_CH2_ADC
HAL_DMA1_CH2_I2C1_TX
HAL_DMA1_CH2_SPI1_RX
HAL_DMA1_CH2_TIM1_CH1
DocID026525 Rev 1
213/692
214/692
UM1785
Remap TIM17 channel 1 on DMA1 channel 2
HAL_DMA1_CH2_TIM17_UP
HAL_DMA1_CH2_USART1_TX
HAL_DMA1_CH2_USART2_TX
HAL_DMA1_CH2_USART3_TX
HAL_DMA1_CH2_USART4_TX
HAL_DMA1_CH2_USART5_TX
HAL_DMA1_CH2_USART6_TX
HAL_DMA1_CH2_USART7_TX
HAL_DMA1_CH2_USART8_TX
HAL_DMA1_CH3_DEFAULT
HAL_DMA1_CH3_TIM6_UP
HAL_DMA1_CH3_DAC_CH1
HAL_DMA1_CH3_I2C1_RX
HAL_DMA1_CH3_SPI1_TX
HAL_DMA1_CH3_TIM1_CH2
HAL_DMA1_CH3_TIM2_CH2
HAL_DMA1_CH3_TIM16_CH1
HAL_DMA1_CH3_TIM16_UP
HAL_DMA1_CH3_USART1_RX
HAL_DMA1_CH3_USART2_RX
HAL_DMA1_CH3_USART3_RX
HAL_DMA1_CH3_USART4_RX
HAL_DMA1_CH3_USART5_RX
HAL_DMA1_CH3_USART6_RX
HAL_DMA1_CH3_USART7_RX
HAL_DMA1_CH3_USART8_RX
HAL_DMA1_CH4_DEFAULT
HAL_DMA1_CH4_TIM7_UP
HAL_DMA1_CH4_DAC_CH2
HAL_DMA1_CH4_I2C2_TX
HAL_DMA1_CH4_SPI2_RX
HAL_DMA1_CH4_TIM2_CH4
HAL_DMA1_CH4_TIM3_CH1
HAL_DMA1_CH4_TIM3_TRIG
HAL_DMA1_CH4_TIM16_CH1
DocID026525 Rev 1
UM1785
HAL_DMA1_CH4_TIM16_UP
HAL_DMA1_CH4_USART1_TX
HAL_DMA1_CH4_USART2_TX
HAL_DMA1_CH4_USART3_TX
HAL_DMA1_CH4_USART4_TX
HAL_DMA1_CH4_USART5_TX
HAL_DMA1_CH4_USART6_TX
HAL_DMA1_CH4_USART7_TX
HAL_DMA1_CH4_USART8_TX
HAL_DMA1_CH5_DEFAULT
HAL_DMA1_CH5_I2C2_RX
HAL_DMA1_CH5_SPI2_TX
HAL_DMA1_CH5_TIM1_CH3
HAL_DMA1_CH5_USART1_RX
HAL_DMA1_CH5_USART2_RX
HAL_DMA1_CH5_USART3_RX
HAL_DMA1_CH5_USART4_RX
HAL_DMA1_CH5_USART5_RX
HAL_DMA1_CH5_USART6_RX
HAL_DMA1_CH5_USART7_RX
HAL_DMA1_CH5_USART8_RX
HAL_DMA1_CH6_DEFAULT
HAL_DMA1_CH6_I2C1_TX
HAL_DMA1_CH6_SPI2_RX
HAL_DMA1_CH6_TIM1_CH1
HAL_DMA1_CH6_TIM1_CH2
HAL_DMA1_CH6_TIM1_CH3
HAL_DMA1_CH6_TIM3_CH1
HAL_DMA1_CH6_TIM3_TRIG
HAL_DMA1_CH6_TIM16_CH1
HAL_DMA1_CH6_TIM16_UP
HAL_DMA1_CH6_USART1_RX
HAL_DMA1_CH6_USART2_RX
HAL_DMA1_CH6_USART3_RX
HAL_DMA1_CH6_USART4_RX
HAL_DMA1_CH6_USART5_RX
DocID026525 Rev 1
215/692
HAL_DMA1_CH6_USART7_RX
HAL_DMA1_CH6_USART8_RX
HAL_DMA1_CH7_DEFAULT
HAL_DMA1_CH7_I2C1_RX
HAL_DMA1_CH7_SPI2_TX
HAL_DMA1_CH7_TIM2_CH2
HAL_DMA1_CH7_TIM2_CH4
HAL_DMA1_CH7_TIM17_CH1
HAL_DMA1_CH7_TIM17_UP
HAL_DMA1_CH7_USART1_TX
HAL_DMA1_CH7_USART2_TX
HAL_DMA1_CH7_USART3_TX
HAL_DMA1_CH7_USART4_TX
HAL_DMA1_CH7_USART5_TX
HAL_DMA1_CH7_USART6_TX
HAL_DMA1_CH7_USART7_TX
HAL_DMA1_CH7_USART8_TX
HAL_DMA2_CH1_DEFAULT
HAL_DMA2_CH1_I2C2_TX
HAL_DMA2_CH1_USART1_TX
HAL_DMA2_CH1_USART2_TX
HAL_DMA2_CH1_USART3_TX
HAL_DMA2_CH1_USART4_TX
HAL_DMA2_CH1_USART5_TX
HAL_DMA2_CH1_USART6_TX
HAL_DMA2_CH1_USART7_TX
HAL_DMA2_CH1_USART8_TX
HAL_DMA2_CH2_DEFAULT
HAL_DMA2_CH2_I2C2_RX
HAL_DMA2_CH2_USART1_RX
HAL_DMA2_CH2_USART2_RX
HAL_DMA2_CH2_USART3_RX
HAL_DMA2_CH2_USART4_RX
HAL_DMA2_CH2_USART5_RX
HAL_DMA2_CH2_USART6_RX
216/692
UM1785
DocID026525 Rev 1
UM1785
HAL_DMA2_CH2_USART7_RX
HAL_DMA2_CH2_USART8_RX
HAL_DMA2_CH3_DEFAULT
HAL_DMA2_CH3_TIM6_UP
HAL_DMA2_CH3_DAC_CH1
HAL_DMA2_CH3_SPI1_RX
HAL_DMA2_CH3_USART1_RX
HAL_DMA2_CH3_USART2_RX
HAL_DMA2_CH3_USART3_RX
HAL_DMA2_CH3_USART4_RX
HAL_DMA2_CH3_USART5_RX
HAL_DMA2_CH3_USART6_RX
HAL_DMA2_CH3_USART7_RX
HAL_DMA2_CH3_USART8_RX
HAL_DMA2_CH4_DEFAULT
HAL_DMA2_CH4_TIM7_UP
HAL_DMA2_CH4_DAC_CH2
HAL_DMA2_CH4_SPI1_TX
HAL_DMA2_CH4_USART1_TX
HAL_DMA2_CH4_USART2_TX
HAL_DMA2_CH4_USART3_TX
HAL_DMA2_CH4_USART4_TX
HAL_DMA2_CH4_USART5_TX
HAL_DMA2_CH4_USART6_TX
HAL_DMA2_CH4_USART7_TX
HAL_DMA2_CH4_USART8_TX
HAL_DMA2_CH5_DEFAULT
HAL_DMA2_CH5_ADC
HAL_DMA2_CH5_USART1_TX
HAL_DMA2_CH5_USART2_TX
HAL_DMA2_CH5_USART3_TX
HAL_DMA2_CH5_USART4_TX
HAL_DMA2_CH5_USART5_TX
HAL_DMA2_CH5_USART6_TX
HAL_DMA2_CH5_USART7_TX
HAL_DMA2_CH5_USART8_TX
DocID026525 Rev 1
217/692
UM1785
IS_HAL_DMA2_REMAP
DMAEx Exported Macros
__HAL_DMA_GET_TC_FLAG_INDEX
Description:
Parameters:
Return value:
__HAL_DMA_GET_HT_FLAG_INDEX
Description:
Parameters:
Return value:
__HAL_DMA_GET_TE_FLAG_INDEX
Description:
Parameters:
Return value:
__HAL_DMA_GET_FLAG
Description:
Parameters:
Return value:
218/692
DocID026525 Rev 1
UM1785
Description:
Parameters:
Return value:
None:
__HAL_DMA1_REMAP
__HAL_DMA2_REMAP
DocID026525 Rev 1
219/692
UM1785
16
16.1
16.1.1
FLASH_EraseInitTypeDef
FLASH_EraseInitTypeDef is defined in the stm32f0xx_hal_flash.h
Data Fields
uint32_t TypeErase
uint32_t PageAddress
uint32_t NbPages
Field Documentation
16.1.2
FLASH_OBProgramInitTypeDef
FLASH_OBProgramInitTypeDef is defined in the stm32f0xx_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
220/692
DocID026525 Rev 1
UM1785
16.1.3
FLASH_ProcessTypeDef
FLASH_ProcessTypeDef is defined in the stm32f0xx_hal_flash.h
Data Fields
Field Documentation
16.2
16.2.1
221/692
16.2.2
UM1785
2.
3.
FLASH Memory I/O Programming functions: this group includes all needed functions
to erase and program the main memory:
In addition to these function, this driver includes a set of macros allowing to handle the
following operations:
16.2.3
IO operation functions
This subsection provides a set of functions allowing to manage the FLASH program
operations (write/erase).
16.2.4
HAL_FLASH_Program()
HAL_FLASH_Program_IT()
HAL_FLASH_IRQHandler()
HAL_FLASH_EndOfOperationCallback()
HAL_FLASH_OperationErrorCallback()
222/692
HAL_FLASH_Unlock()
HAL_FLASH_Lock()
DocID026525 Rev 1
UM1785
16.2.5
HAL_FLASH_OB_Unlock()
HAL_FLASH_OB_Lock()
HAL_FLASH_OB_Launch()
16.2.6
HAL_FLASH_GetError()
HAL_FLASH_Program
Function Name
Function Description
Parameters
Return values
Notes
16.2.7
HAL_FLASH_Program_IT
Function Name
Function Description
Parameters
223/692
UM1785
Return values
Notes
16.2.8
16.2.9
224/692
HAL_FLASH_IRQHandler
Function Name
Function Description
Return values
None.
Notes
None.
HAL_FLASH_EndOfOperationCallback
Function Name
Function Description
Parameters
Return values
none
Notes
None.
DocID026525 Rev 1
UM1785
16.2.10
16.2.11
16.2.12
HAL_FLASH_OperationErrorCallback
Function Name
Function Description
Parameters
Return values
none
Notes
None.
HAL_FLASH_Unlock
Function Name
Function Description
Return values
HAL Status
Notes
None.
HAL_FLASH_Lock
Function Name
Function Description
Return values
HAL Status
Notes
None.
DocID026525 Rev 1
225/692
16.2.13
16.2.14
16.2.15
16.2.16
226/692
UM1785
HAL_FLASH_OB_Unlock
Function Name
Function Description
Return values
HAL Status
Notes
None.
HAL_FLASH_OB_Lock
Function Name
Function Description
Return values
HAL Status
Notes
None.
HAL_FLASH_OB_Launch
Function Name
Function Description
Return values
HAL status
Notes
None.
HAL_FLASH_GetError
Function Name
Function Description
DocID026525 Rev 1
UM1785
Notes
None.
16.3
16.3.1
FLASH
FLASH
FLASH Flag definition
FLASH_FLAG_BSY
FLASH_FLAG_PGERR
FLASH_FLAG_WRPERR
FLASH_FLAG_EOP
FLASH Interrupt
Description:
__HAL_FLASH_ENABLE_IT
Parameters:
Return value:
__HAL_FLASH_DISABLE_IT
none:
Description:
Parameters:
Return value:
__HAL_FLASH_GET_FLAG
none:
Description:
DocID026525 Rev 1
227/692
UM1785
Parameters:
Return value:
__HAL_FLASH_CLEAR_FLAG
Description:
Parameters:
Return value:
none:
FLASH_IT_ERR
FLASH Latency
FLASH_LATENCY_0
FLASH_LATENCY_1
IS_FLASH_LATENCY
__HAL_FLASH_SET_LATENCY
Description:
Parameters:
Return value:
None:
FLASH OB BOOT1
228/692
DocID026525 Rev 1
UM1785
BOOT1 Reset
OB_BOOT1_SET
BOOT1 Set
IS_OB_BOOT1
FLASH OB Data Address
IS_OB_DATA_ADDRESS
FLASH OB nRST STDBY
OB_STDBY_NO_RST
OB_STDBY_RST
IS_OB_STDBY_SOURCE
FLASH OB nRST STOP
OB_STOP_NO_RST
OB_STOP_RST
IS_OB_STOP_SOURCE
FLASH OB RAM Parity Check Enable
OB_RAM_PARITY_CHECK_SET
OB_RAM_PARITY_CHECK_RESET
IS_OB_SRAM_PARITY
FLASH OB Read Protection
OB_RDP_LEVEL_0
OB_RDP_LEVEL_1
OB_RDP_LEVEL_2
IS_OB_RDP_LEVEL
FLASH Option Bytes Type
OPTIONBYTE_WRP
OPTIONBYTE_RDP
OPTIONBYTE_USER
OPTIONBYTE_DATA
IS_OPTIONBYTE
FLASH OB VDDA Analog Monitoring
OB_VDDA_ANALOG_ON
OB_VDDA_ANALOG_OFF
IS_OB_VDDA_ANALOG
FLASH OB Watchdog
OB_WDG_SW
OB_WDG_HW
IS_OB_WDG_SOURCE
DocID026525 Rev 1
229/692
UM1785
WRPSTATE_DISABLE
WRPSTATE_ENABLE
IS_WRPSTATE
FLASH Prefetch
__HAL_FLASH_PREFETCH_BUFFER_ENABLE
Description:
Return value:
__HAL_FLASH_PREFETCH_BUFFER_DISABLE
None:
Description:
Return value:
None:
TYPEERASE_MASSERASE
IS_TYPEERASE
FLASH Type Program
TYPEPROGRAM_HALFWORD
TYPEPROGRAM_WORD
TYPEPROGRAM_DOUBLEWORD
IS_TYPEPROGRAM
230/692
DocID026525 Rev 1
UM1785
17
17.1
17.1.1
17.1.2
17.1.3
IO operation functions
17.1.4
HAL_FLASHEx_Erase()
HAL_FLASHEx_Erase_IT()
17.1.5
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
Parameters
DocID026525 Rev 1
231/692
17.1.6
17.1.7
232/692
UM1785
HAL_FLASHEx_Erase_IT
Function Name
HAL_StatusTypeDef HAL_FLASHEx_Erase_IT (
FLASH_EraseInitTypeDef * pEraseInit)
Function Description
Parameters
Return values
Notes
HAL_FLASHEx_OBErase
Function Name
Function Description
Return values
HAL status
Notes
DocID026525 Rev 1
UM1785
17.1.8
17.1.9
HAL_FLASHEx_OBProgram
Function Name
HAL_StatusTypeDef HAL_FLASHEx_OBProgram (
FLASH_OBProgramInitTypeDef * pOBInit)
Function Description
Parameters
Return values
Notes
HAL_FLASHEx_OBGetConfig
Function Name
void HAL_FLASHEx_OBGetConfig (
FLASH_OBProgramInitTypeDef * pOBInit)
Function Description
Parameters
Return values
None.
Notes
None.
17.2
17.2.1
FLASHEx
FLASHEx
FLASHEx Address
IS_FLASH_PROGRAM_ADDRESS
FLASHEx Nb Pages
DocID026525 Rev 1
233/692
UM1785
FLASHEx OB BOOT0
OB_BOOT0_RESET
BOOT0 Reset
OB_BOOT0_SET
BOOT0 Set
IS_OB_BOOT0
FLASHEx OB BOOT SEL
OB_BOOT_SEL_RESET
BOOT_SEL Reset
OB_BOOT_SEL_SET
BOOT_SEL Set
IS_OB_BOOT_SEL
FLASHEx OB Write Protection
OB_WRP_PAGES0TO1
OB_WRP_PAGES2TO3
OB_WRP_PAGES4TO5
OB_WRP_PAGES6TO7
OB_WRP_PAGES8TO9
OB_WRP_PAGES10TO11
OB_WRP_PAGES12TO13
OB_WRP_PAGES14TO15
OB_WRP_PAGES16TO17
OB_WRP_PAGES18TO19
OB_WRP_PAGES20TO21
OB_WRP_PAGES22TO23
OB_WRP_PAGES24TO25
OB_WRP_PAGES26TO27
OB_WRP_PAGES28TO29
OB_WRP_PAGES30TO31
OB_WRP_PAGES32TO33
OB_WRP_PAGES34TO35
OB_WRP_PAGES36TO37
OB_WRP_PAGES38TO39
OB_WRP_PAGES40TO41
OB_WRP_PAGES42TO43
OB_WRP_PAGES44TO45
OB_WRP_PAGES46TO47
OB_WRP_PAGES48TO49
OB_WRP_PAGES50TO51
234/692
DocID026525 Rev 1
UM1785
IS_OB_WRP
FLASHEx Page Size
FLASH_PAGE_SIZE
FLASHEx Private Constants
HAL_FLASH_TIMEOUT_VALUE
DocID026525 Rev 1
235/692
UM1785
18
18.1
18.1.1
GPIO_InitTypeDef
GPIO_InitTypeDef is defined in the stm32f0xx_hal_gpio.h
Data Fields
uint32_t Pin
uint32_t Mode
uint32_t Pull
uint32_t Speed
uint32_t Alternate
Field Documentation
18.2
18.2.1
Input mode
Analog mode
Output mode
Alternate function mode
External interrupt/event lines
During and just after reset, the alternate functions and external interrupt lines are not
active and the I/O ports are configured in input floating mode.
All GPIO pins have weak internal pull-up and pull-down resistors, which can be activated
or not.
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.
236/692
DocID026525 Rev 1
UM1785
18.2.2
1.
2.
Enable the GPIO AHB clock using the following function : __GPIOx_CLK_ENABLE().
Configure the GPIO pin(s) using HAL_GPIO_Init().
18.2.3
DocID026525 Rev 1
237/692
18.2.4
IO operation functions
18.2.5
UM1785
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
Function Description
Parameters
Parameters
Return values
None.
Notes
18.2.6
238/692
HAL_GPIO_DeInit
Function Name
Function Description
Parameters
Parameters
DocID026525 Rev 1
UM1785
None.
Notes
18.2.7
HAL_GPIO_ReadPin
Function Name
Function Description
Parameters
Parameters
Return values
Notes
18.2.8
HAL_GPIO_WritePin
Function Name
Function Description
Parameters
Parameters
Return values
None.
DocID026525 Rev 1
239/692
UM1785
18.2.9
HAL_GPIO_TogglePin
Function Name
Function Description
Parameters
Parameters
Return values
None.
Notes
18.2.10
HAL_GPIO_LockPin
Function Name
Function Description
Parameters
Parameters
Return values
None.
Notes
240/692
DocID026525 Rev 1
UM1785
18.2.11
18.2.12
HAL_GPIO_EXTI_IRQHandler
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_GPIO_EXTI_Callback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
18.3
18.3.1
GPIO
GPIO
GPIO Exported Macros
__HAL_GPIO_EXTI_GET_FLAG
Description:
DocID026525 Rev 1
241/692
UM1785
Parameters:
Return value:
__HAL_GPIO_EXTI_CLEAR_FLAG
Description:
Parameters:
Return value:
__HAL_GPIO_EXTI_GET_IT
None:
Description:
Parameters:
Return value:
__HAL_GPIO_EXTI_CLEAR_IT
Description:
Parameters:
Return value:
__HAL_GPIO_EXTI_GENERATE_SWIT
None:
Description:
Parameters:
242/692
DocID026525 Rev 1
UM1785
Return value:
None:
GPIO mode
GPIO_MODE_INPUT
GPIO_MODE_OUTPUT_PP
GPIO_MODE_OUTPUT_OD
GPIO_MODE_AF_PP
GPIO_MODE_AF_OD
GPIO_MODE_ANALOG
Analog Mode
GPIO_MODE_IT_RISING
GPIO_MODE_IT_FALLING
GPIO_MODE_IT_RISING_FALLING
GPIO_MODE_EVT_RISING
GPIO_MODE_EVT_FALLING
GPIO_MODE_EVT_RISING_FALLING
IS_GPIO_MODE
GPIO pins
GPIO_PIN_0
GPIO_PIN_1
GPIO_PIN_2
GPIO_PIN_3
GPIO_PIN_4
GPIO_PIN_5
GPIO_PIN_6
GPIO_PIN_7
GPIO_PIN_8
GPIO_PIN_9
GPIO_PIN_10
GPIO_PIN_11
GPIO_PIN_12
DocID026525 Rev 1
243/692
UM1785
GPIO_PIN_14
GPIO_PIN_15
GPIO_PIN_All
GPIO_PIN_MASK
IS_GPIO_PIN
GPIO pin actions
IS_GPIO_PIN_ACTION
GPIO Private Define
GPIO_MODE
EXTI_MODE
GPIO_MODE_IT
GPIO_MODE_EVT
RISING_EDGE
FALLING_EDGE
GPIO_OUTPUT_TYPE
GPIO_NUMBER
GPIO pull
GPIO_NOPULL
GPIO_PULLUP
Pull-up activation
GPIO_PULLDOWN
Pull-down activation
IS_GPIO_PULL
GPIO speed
GPIO_SPEED_LOW
Low speed
GPIO_SPEED_MEDIUM
Medium speed
GPIO_SPEED_HIGH
High speed
IS_GPIO_SPEED
244/692
DocID026525 Rev 1
UM1785
19
19.1
19.1.1
GPIOEx
GPIOEx
GPIOEx Alternate function selection
GPIO_AF0_EVENTOUT
GPIO_AF0_SWDIO
GPIO_AF0_SWCLK
GPIO_AF0_MCO
GPIO_AF0_CEC
GPIO_AF0_CRS
GPIO_AF0_IR
GPIO_AF0_SPI1
GPIO_AF0_SPI2
GPIO_AF0_TIM1
GPIO_AF0_TIM3
GPIO_AF0_TIM14
GPIO_AF0_TIM15
GPIO_AF0_TIM16
GPIO_AF0_TIM17
GPIO_AF0_TSC
GPIO_AF0_USART1
GPIO_AF0_USART2
GPIO_AF0_USART3
GPIO_AF0_USART4
GPIO_AF0_USART8
GPIO_AF0_CAN
GPIO_AF1_TIM3
GPIO_AF1_TIM15
GPIO_AF1_USART1
GPIO_AF1_USART2
GPIO_AF1_USART3
GPIO_AF1_USART4
GPIO_AF1_USART5
245/692
GPIO_AF1_USART7
GPIO_AF1_USART8
GPIO_AF1_IR
GPIO_AF1_CEC
GPIO_AF1_EVENTOUT
GPIO_AF1_I2C1
GPIO_AF1_I2C2
GPIO_AF1_TSC
GPIO_AF1_SPI1
GPIO_AF1_SPI2
GPIO_AF2_TIM1
GPIO_AF2_TIM2
GPIO_AF2_TIM16
GPIO_AF2_TIM17
GPIO_AF2_EVENTOUT
GPIO_AF2_USART5
GPIO_AF2_USART6
GPIO_AF2_USART7
GPIO_AF2_USART8
GPIO_AF3_EVENTOUT
GPIO_AF3_TSC
GPIO_AF3_TIM15
GPIO_AF3_I2C1
GPIO_AF4_TIM14
GPIO_AF4_USART4
GPIO_AF4_USART3
GPIO_AF4_CRS
GPIO_AF4_CAN
GPIO_AF4_I2C1
GPIO_AF4_USART5
GPIO_AF5_TIM15
GPIO_AF5_TIM16
GPIO_AF5_TIM17
GPIO_AF5_SPI2
GPIO_AF5_I2C2
246/692
UM1785
DocID026525 Rev 1
UM1785
GPIO_AF5_MCO
GPIO_AF5_USART6
GPIO_AF6_EVENTOUT
GPIO_AF7_COMP1
GPIO_AF7_COMP2
IS_GPIO_AF
GPIOEx_Get Port Index
GET_GPIO_INDEX
DocID026525 Rev 1
247/692
UM1785
20
20.1
20.1.1
I2C_InitTypeDef
I2C_InitTypeDef is defined in the stm32f0xx_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
20.1.2
I2C_HandleTypeDef
I2C_HandleTypeDef is defined in the stm32f0xx_hal_i2c.h
Data Fields
248/692
I2C_TypeDef * Instance
I2C_InitTypeDef Init
uint8_t * pBuffPtr
uint16_t XferSize
__IO uint16_t XferCount
DMA_HandleTypeDef * hdmatx
DMA_HandleTypeDef * hdmarx
DocID026525 Rev 1
UM1785
HAL_LockTypeDef Lock
__IO HAL_I2C_StateTypeDef State
__IO HAL_I2C_ErrorTypeDef ErrorCode
Field Documentation
20.2
20.2.1
3.
4.
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:
DocID026525 Rev 1
249/692
UM1785
5.
6.
These API s 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 :
250/692
DocID026525 Rev 1
UM1785
Transmit in master mode an amount of data in non blocking mode (DMA) using
HAL_I2C_Master_Transmit_DMA()
At transmission end of transfer HAL_I2C_MasterTxCpltCallback is executed and user
can add his own code by customization of function pointer
HAL_I2C_MasterTxCpltCallback
Receive in master mode an amount of data in non blocking mode (DMA) using
HAL_I2C_Master_Receive_DMA()
At reception end of transfer HAL_I2C_MasterRxCpltCallback is executed and user
can add his own code by customization of function pointer
HAL_I2C_MasterRxCpltCallback
Transmit in slave mode an amount of data in non blocking mode (DMA) using
HAL_I2C_Slave_Transmit_DMA()
At transmission end of transfer HAL_I2C_SlaveTxCpltCallback is executed and user
can add his own code by customization of function pointer
HAL_I2C_SlaveTxCpltCallback
Receive in slave mode an amount of data in non blocking mode (DMA) using
HAL_I2C_Slave_Receive_DMA()
At reception end of transfer HAL_I2C_SlaveRxCpltCallback is executed and user can
add his own code by customization of function pointer HAL_I2C_SlaveRxCpltCallback
In case of transfer Error, HAL_I2C_ErrorCallback() function is executed and user can
add his own code by customization of function pointer HAL_I2C_ErrorCallback
Write an amount of data in no-blocking mode with DMA to a specific memory address
using HAL_I2C_Mem_Write_DMA()
At MEM 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 MEM 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
DocID026525 Rev 1
251/692
UM1785
20.2.2
20.2.3
Clock Timing
Own Address 1
Own Address 2
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.
252/692
UM1785
3.
4.
5.
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()
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()
DocID026525 Rev 1
253/692
20.2.4
UM1785
HAL_I2C_SlaveRxCpltCallback()
HAL_I2C_MemTxCpltCallback()
HAL_I2C_MemRxCpltCallback()
HAL_I2C_ErrorCallback()
20.2.5
20.2.6
20.2.7
254/692
HAL_I2C_GetState()
HAL_I2C_GetError()
HAL_I2C_Init
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_I2C_DeInit
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_I2C_MspInit
DocID026525 Rev 1
UM1785
20.2.8
20.2.9
Function Description
Parameters
Return values
None.
Notes
None.
HAL_I2C_MspDeInit
Function Name
Function Description
Parameters
Return values
None.
Notes
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
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
255/692
20.2.10
20.2.11
20.2.12
256/692
UM1785
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
Parameters
Return values
HAL status
Notes
None.
HAL_I2C_Slave_Transmit
Function Name
HAL_StatusTypeDef HAL_I2C_Slave_Transmit (
I2C_HandleTypeDef * hi2c, uint8_t * pData, uint16_t Size,
uint32_t Timeout)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_I2C_Slave_Receive
DocID026525 Rev 1
UM1785
20.2.13
20.2.14
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
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
Parameters
Return values
HAL status
Notes
None.
HAL_I2C_Master_Receive_IT
Function Name
HAL_StatusTypeDef HAL_I2C_Master_Receive_IT (
I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint8_t *
pData, uint16_t Size)
Function Description
Parameters
257/692
20.2.15
20.2.16
258/692
UM1785
contains the configuration information for the specified I2C.
DevAddress : Target device address
pData : Pointer to data buffer
Size : Amount of data to be sent
Return values
HAL status
Notes
None.
HAL_I2C_Slave_Transmit_IT
Function Name
HAL_StatusTypeDef HAL_I2C_Slave_Transmit_IT (
I2C_HandleTypeDef * hi2c, uint8_t * pData, uint16_t Size)
Function Description
Parameters
Return values
HAL status
Notes
None.
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
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
UM1785
20.2.17
20.2.18
20.2.19
HAL_I2C_Master_Transmit_DMA
Function Name
HAL_StatusTypeDef HAL_I2C_Master_Transmit_DMA (
I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint8_t *
pData, uint16_t Size)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_I2C_Master_Receive_DMA
Function Name
HAL_StatusTypeDef HAL_I2C_Master_Receive_DMA (
I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint8_t *
pData, uint16_t Size)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_I2C_Slave_Transmit_DMA
DocID026525 Rev 1
259/692
20.2.20
20.2.21
UM1785
HAL_StatusTypeDef HAL_I2C_Slave_Transmit_DMA (
I2C_HandleTypeDef * hi2c, uint8_t * pData, uint16_t Size)
Function Description
Parameters
Return values
HAL status
Notes
None.
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
Parameters
Return values
HAL status
Notes
None.
HAL_I2C_Mem_Write
Function Name
HAL_StatusTypeDef HAL_I2C_Mem_Write (
I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint16_t
MemAddress, uint16_t MemAddSize, uint8_t * pData, uint16_t
Size, uint32_t Timeout)
Function Description
Parameters
260/692
UM1785
20.2.22
20.2.23
Return values
HAL status
Notes
None.
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
Parameters
Return values
HAL status
Notes
None.
HAL_I2C_Mem_Write_IT
Function Name
HAL_StatusTypeDef HAL_I2C_Mem_Write_IT (
I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint16_t
MemAddress, uint16_t MemAddSize, uint8_t * pData, uint16_t
Size)
Function Description
Parameters
261/692
20.2.24
20.2.25
262/692
UM1785
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
Return values
HAL status
Notes
None.
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
Parameters
Return values
HAL status
Notes
None.
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
Parameters
UM1785
20.2.26
20.2.27
Return values
HAL status
Notes
None.
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
Parameters
Return values
HAL status
Notes
None.
HAL_I2C_IsDeviceReady
Function Name
HAL_StatusTypeDef HAL_I2C_IsDeviceReady (
I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint32_t
Trials, uint32_t Timeout)
Function Description
Parameters
263/692
20.2.28
20.2.29
20.2.30
Return values
HAL status
Notes
HAL_I2C_EV_IRQHandler
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_I2C_ER_IRQHandler
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_I2C_MasterTxCpltCallback
Function Name
264/692
UM1785
DocID026525 Rev 1
UM1785
20.2.31
20.2.32
20.2.33
Parameters
Return values
None.
Notes
None.
HAL_I2C_MasterRxCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_I2C_SlaveTxCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_I2C_SlaveRxCpltCallback
DocID026525 Rev 1
265/692
20.2.34
20.2.35
266/692
UM1785
void HAL_I2C_SlaveRxCpltCallback ( I2C_HandleTypeDef *
hi2c)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_I2C_MemTxCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_I2C_MemRxCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
UM1785
20.2.36
20.2.37
20.2.38
HAL_I2C_ErrorCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_I2C_GetState
Function Name
HAL_I2C_StateTypeDef HAL_I2C_GetState (
I2C_HandleTypeDef * hi2c)
Function Description
Parameters
Return values
HAL state
Notes
None.
HAL_I2C_GetError
Function Name
Function Description
Parameters
Return values
Notes
None.
DocID026525 Rev 1
267/692
UM1785
20.3
20.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:
Parameters:
Return value:
__HAL_I2C_ENABLE_IT
None:
Description:
Parameters:
Return value:
268/692
None:
DocID026525 Rev 1
UM1785
Description:
Parameters:
Return value:
__HAL_I2C_GET_FLAG
Description:
Parameters:
DocID026525 Rev 1
269/692
UM1785
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:
Description:
__HAL_I2C_CLEAR_FLAG
Parameters:
I2C_FLAG_OVR: Overrun/Underrun
Return value:
None:
__HAL_I2C_ENABLE
__HAL_I2C_DISABLE
__HAL_I2C_RESET_CR2
__HAL_I2C_MEM_ADD_MSB
__HAL_I2C_MEM_ADD_LSB
270/692
DocID026525 Rev 1
UM1785
271/692
272/692
DocID026525 Rev 1
UM1785
UM1785
21
21.1
21.1.1
21.1.2
21.1.3
HAL_I2CEx_EnableWakeUp()
HAL_I2CEx_DisableWakeUp()
21.1.4
HAL_I2CEx_AnalogFilter_Config
Function Name
HAL_StatusTypeDef HAL_I2CEx_AnalogFilter_Config (
I2C_HandleTypeDef * hi2c, uint32_t AnalogFilter)
Function Description
Parameters
Return values
HAL status
DocID026525 Rev 1
273/692
21.1.5
UM1785
HAL_I2CEx_DigitalFilter_Config
Function Name
HAL_StatusTypeDef HAL_I2CEx_DigitalFilter_Config (
I2C_HandleTypeDef * hi2c, uint32_t DigitalFilter)
Function Description
Parameters
21.1.6
21.1.7
Return values
HAL status
Notes
None.
HAL_I2CEx_EnableWakeUp
Function Name
HAL_StatusTypeDef HAL_I2CEx_EnableWakeUp (
I2C_HandleTypeDef * hi2c)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_I2CEx_DisableWakeUp
Function Name
274/692
None.
HAL_StatusTypeDef HAL_I2CEx_DisableWakeUp (
DocID026525 Rev 1
UM1785
Parameters
Return values
HAL status
Notes
None.
21.2
21.2.1
I2CEx
I2CEx
I2CEx Analog Filter
I2C_ANALOGFILTER_ENABLED
I2C_ANALOGFILTER_DISABLED
IS_I2C_ANALOG_FILTER
I2CEx Digital Filter
IS_I2C_DIGITAL_FILTER
DocID026525 Rev 1
275/692
UM1785
22
22.1
22.1.1
I2S_InitTypeDef
I2S_InitTypeDef is defined in the stm32f0xx_hal_i2s.h
Data Fields
uint32_t Mode
uint32_t Standard
uint32_t DataFormat
uint32_t MCLKOutput
uint32_t AudioFreq
uint32_t CPOL
Field Documentation
22.1.2
I2S_HandleTypeDef
I2S_HandleTypeDef is defined in the stm32f0xx_hal_i2s.h
Data Fields
276/692
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
DocID026525 Rev 1
UM1785
22.2
SPI_TypeDef* I2S_HandleTypeDef::Instance
I2S_InitTypeDef I2S_HandleTypeDef::Init
uint16_t* I2S_HandleTypeDef::pTxBuffPtr
__IO uint16_t I2S_HandleTypeDef::TxXferSize
__IO uint16_t I2S_HandleTypeDef::TxXferCount
uint16_t* I2S_HandleTypeDef::pRxBuffPtr
__IO uint16_t I2S_HandleTypeDef::RxXferSize
__IO uint16_t I2S_HandleTypeDef::RxXferCount
DMA_HandleTypeDef* I2S_HandleTypeDef::hdmatx
DMA_HandleTypeDef* I2S_HandleTypeDef::hdmarx
__IO HAL_LockTypeDef I2S_HandleTypeDef::Lock
__IO HAL_I2S_StateTypeDef I2S_HandleTypeDef::State
__IO HAL_I2S_ErrorTypeDef I2S_HandleTypeDef::ErrorCode
22.2.1
3.
Configure the declared DMA handle structure with the required Tx/Rx
parameters.
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: External clock source is configured after
setting correctly the define constant EXTERNAL_CLOCK_VALUE in the
stm32f0xx_hal_conf.h file.
DocID026525 Rev 1
277/692
UM1785
278/692
UM1785
22.2.2
22.2.3
Mode
Standard
Data Format
MCLK Output
Audio frequency
Polarity
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.
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()
DocID026525 Rev 1
279/692
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_DMAPause()
HAL_I2S_DMAResume()
HAL_I2S_DMAStop()
HAL_I2S_IRQHandler()
HAL_I2S_TxHalfCpltCallback()
HAL_I2S_TxCpltCallback()
HAL_I2S_RxHalfCpltCallback()
HAL_I2S_RxCpltCallback()
HAL_I2S_ErrorCallback()
22.2.4
UM1785
22.2.5
22.2.6
HAL_I2S_GetState()
HAL_I2S_GetError()
HAL_I2S_Init
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_I2S_DeInit
Function Name
280/692
DocID026525 Rev 1
UM1785
22.2.7
22.2.8
22.2.9
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_I2S_MspInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_I2S_MspDeInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_I2S_Transmit
DocID026525 Rev 1
281/692
UM1785
HAL_StatusTypeDef HAL_I2S_Transmit ( I2S_HandleTypeDef
* hi2s, uint16_t * pData, uint16_t Size, uint32_t Timeout)
Function Description
Parameters
Parameters
Return values
HAL status
Notes
22.2.10
HAL_I2S_Receive
Function Name
Function Description
Parameters
Parameters
Return values
HAL status
Notes
282/692
DocID026525 Rev 1
UM1785
22.2.11
HAL_I2S_Transmit_IT
Function Name
HAL_StatusTypeDef HAL_I2S_Transmit_IT (
I2S_HandleTypeDef * hi2s, uint16_t * pData, uint16_t Size)
Function Description
Parameters
Return values
HAL status
Notes
22.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
Parameters
Return values
HAL status
Notes
283/692
UM1785
22.2.13
HAL_I2S_Transmit_DMA
Function Name
HAL_StatusTypeDef HAL_I2S_Transmit_DMA (
I2S_HandleTypeDef * hi2s, uint16_t * pData, uint16_t Size)
Function Description
Parameters
Return values
HAL status
Notes
22.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
Parameters
284/692
DocID026525 Rev 1
UM1785
HAL status
Notes
22.2.15
22.2.16
HAL_I2S_DMAPause
Function Name
HAL_StatusTypeDef HAL_I2S_DMAPause (
I2S_HandleTypeDef * hi2s)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_I2S_DMAResume
Function Name
HAL_StatusTypeDef HAL_I2S_DMAResume (
I2S_HandleTypeDef * hi2s)
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
285/692
22.2.17
22.2.18
22.2.19
286/692
UM1785
HAL_I2S_DMAStop
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_I2S_IRQHandler
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_I2S_TxHalfCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
UM1785
22.2.20
22.2.21
22.2.22
HAL_I2S_TxCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_I2S_RxHalfCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_I2S_RxCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
287/692
22.2.23
22.2.24
22.2.25
288/692
UM1785
HAL_I2S_ErrorCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_I2S_GetState
Function Name
HAL_I2S_StateTypeDef HAL_I2S_GetState (
I2S_HandleTypeDef * hi2s)
Function Description
Parameters
Return values
HAL state
Notes
None.
HAL_I2S_GetError
Function Name
HAL_I2S_ErrorTypeDef HAL_I2S_GetError (
I2S_HandleTypeDef * hi2s)
Function Description
Parameters
Return values
Notes
None.
DocID026525 Rev 1
UM1785
22.3
22.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
I2S_CPOL_HIGH
IS_I2S_CPOL
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:
Parameters:
Return value:
__HAL_I2S_ENABLE
None:
Description:
DocID026525 Rev 1
289/692
UM1785
peripheral (in I2S mode).
Parameters:
Return value:
None:
__HAL_I2S_DISABLE
Description:
__HAL_I2S_ENABLE_IT
Parameters:
Return value:
None:
__HAL_I2S_DISABLE_IT
__HAL_I2S_GET_IT_SOURCE
Description:
Parameters:
Return value:
__HAL_I2S_GET_FLAG
Description:
Parameters:
290/692
DocID026525 Rev 1
UM1785
Return value:
__HAL_I2S_CLEAR_OVRFLAG
Description:
Parameters:
Return value:
__HAL_I2S_CLEAR_UDRFLAG
None:
Description:
Parameters:
Return value:
None:
291/692
292/692
DocID026525 Rev 1
UM1785
UM1785
23
23.1
23.1.1
IRDA_InitTypeDef
IRDA_InitTypeDef is defined in the stm32f0xx_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
23.1.2
IRDA_HandleTypeDef
IRDA_HandleTypeDef is defined in the stm32f0xx_hal_irda.h
Data Fields
USART_TypeDef * Instance
IRDA_InitTypeDef Init
uint8_t * pTxBuffPtr
uint16_t TxXferSize
uint16_t TxXferCount
uint8_t * pRxBuffPtr
uint16_t RxXferSize
uint16_t RxXferCount
DocID026525 Rev 1
293/692
UM1785
uint16_t Mask
DMA_HandleTypeDef * hdmatx
DMA_HandleTypeDef * hdmarx
HAL_LockTypeDef Lock
HAL_IRDA_StateTypeDef State
HAL_IRDA_ErrorTypeDef ErrorCode
Field Documentation
23.2
USART_TypeDef* IRDA_HandleTypeDef::Instance
IRDA_InitTypeDef IRDA_HandleTypeDef::Init
uint8_t* IRDA_HandleTypeDef::pTxBuffPtr
uint16_t IRDA_HandleTypeDef::TxXferSize
uint16_t IRDA_HandleTypeDef::TxXferCount
uint8_t* IRDA_HandleTypeDef::pRxBuffPtr
uint16_t IRDA_HandleTypeDef::RxXferSize
uint16_t IRDA_HandleTypeDef::RxXferCount
uint16_t IRDA_HandleTypeDef::Mask
DMA_HandleTypeDef* IRDA_HandleTypeDef::hdmatx
DMA_HandleTypeDef* IRDA_HandleTypeDef::hdmarx
HAL_LockTypeDef IRDA_HandleTypeDef::Lock
HAL_IRDA_StateTypeDef IRDA_HandleTypeDef::State
HAL_IRDA_ErrorTypeDef IRDA_HandleTypeDef::ErrorCode
23.2.1
294/692
Configure the declared DMA handle structure with the required Tx/Rx
parameters.
Associate the initilalized DMA handle to the IRDA DMA Tx/Rx handle.
DocID026525 Rev 1
UM1785
3.
4.
5.
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 :
DocID026525 Rev 1
295/692
UM1785
You can refer to the IRDA HAL driver header file for more useful macros
23.2.2
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 the following table
Power mode
Prescaler setting
Receiver/transmitter modes
Table 19: IRDA frame formats
M bit
PCE bit
IRDA frame
M1, M0 bits
PCE bit
IRDA frame
10
10
The HAL_IRDA_Init() function follows IRDA configuration procedures (details for the
procedures are available in reference manual).
23.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.
296/692
DocID026525 Rev 1
UM1785
2.
3.
4.
5.
23.2.4
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 Non 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()
HAL_IRDA_Receive_DMA()
HAL_IRDA_IRQHandler()
HAL_IRDA_TxCpltCallback()
HAL_IRDA_RxCpltCallback()
HAL_IRDA_ErrorCallback()
23.2.5
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
DocID026525 Rev 1
297/692
UM1785
hirda)
23.2.6
23.2.7
23.2.8
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_IRDA_DeInit
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_IRDA_MspInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_IRDA_MspDeInit
Function Name
298/692
UM1785
23.2.9
23.2.10
Parameters
Return values
None.
Notes
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
Parameters
Return values
HAL status
Notes
None.
HAL_IRDA_Receive
Function Name
HAL_StatusTypeDef HAL_IRDA_Receive (
IRDA_HandleTypeDef * hirda, uint8_t * pData, uint16_t Size,
uint32_t Timeout)
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
299/692
23.2.11
23.2.12
23.2.13
300/692
UM1785
HAL_IRDA_Transmit_IT
Function Name
HAL_StatusTypeDef HAL_IRDA_Transmit_IT (
IRDA_HandleTypeDef * hirda, uint8_t * pData, uint16_t Size)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_IRDA_Receive_IT
Function Name
HAL_StatusTypeDef HAL_IRDA_Receive_IT (
IRDA_HandleTypeDef * hirda, uint8_t * pData, uint16_t Size)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_IRDA_Transmit_DMA
Function Name
HAL_StatusTypeDef HAL_IRDA_Transmit_DMA (
IRDA_HandleTypeDef * hirda, uint8_t * pData, uint16_t Size)
Function Description
Parameters
Return values
HAL status
DocID026525 Rev 1
UM1785
23.2.14
23.2.15
23.2.16
None.
HAL_IRDA_Receive_DMA
Function Name
HAL_StatusTypeDef HAL_IRDA_Receive_DMA (
IRDA_HandleTypeDef * hirda, uint8_t * pData, uint16_t Size)
Function Description
Parameters
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
Function Description
Parameters
Return values
None.
Notes
None.
HAL_IRDA_TxCpltCallback
Function Name
Function Description
Parameters
301/692
23.2.17
23.2.18
23.2.19
302/692
UM1785
None.
None.
HAL_IRDA_RxCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_IRDA_ErrorCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_IRDA_GetState
Function Name
HAL_IRDA_StateTypeDef HAL_IRDA_GetState (
IRDA_HandleTypeDef * hirda)
Function Description
Parameters
DocID026525 Rev 1
UM1785
23.2.20
HAL state
Notes
None.
HAL_IRDA_GetError
Function Name
Function Description
Parameters
Return values
Notes
None.
23.3
23.3.1
IRDA
IRDA
IRDA DMA Rx
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:
Parameters:
Return value:
None:
DocID026525 Rev 1
303/692
UM1785
Description:
Parameters:
IRDA_FLAG_TC: Transmission
Complete flag
Return value:
__HAL_IRDA_ENABLE_IT
Description:
Parameters:
304/692
DocID026525 Rev 1
UM1785
Return value:
__HAL_IRDA_DISABLE_IT
None:
Description:
Parameters:
Return value:
__HAL_IRDA_GET_IT
None:
Description:
Parameters:
DocID026525 Rev 1
305/692
UM1785
Return value:
__HAL_IRDA_GET_IT_SOURCE
Description:
Parameters:
Return value:
__HAL_IRDA_CLEAR_IT
Description:
Parameters:
306/692
DocID026525 Rev 1
UM1785
Return value:
__HAL_IRDA_SEND_REQ
None:
Description:
Parameters:
IRDA_RXDATA_FLUSH_REQUEST:
Receive Data flush Request
IRDA_TXDATA_FLUSH_REQUEST:
Transmit data flush Request
Return value:
__HAL_IRDA_ENABLE
None:
Description:
Parameters:
Return value:
__HAL_IRDA_DISABLE
None:
Description:
Parameters:
DocID026525 Rev 1
307/692
UM1785
Return value:
None:
Description:
IS_IRDA_BAUDRATE
Parameters:
Return value:
True: or False
Description:
IS_IRDA_PRESCALER
Parameters:
Return value:
True: or False
IRDA Flags
IRDA_FLAG_REACK
IRDA_FLAG_TEACK
IRDA_FLAG_BUSY
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 Interrupt Definition
IRDA_IT_PE
IRDA_IT_TXE
IRDA_IT_TC
308/692
DocID026525 Rev 1
UM1785
IRDA_CLEAR_FEF
IRDA_CLEAR_NEF
IRDA_CLEAR_OREF
IRDA_CLEAR_TCF
DocID026525 Rev 1
309/692
UM1785
IRDA_TXDATA_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
310/692
DocID026525 Rev 1
UM1785
24
24.1
24.1.1
IRDAEx
IRDAEx
IRDAEx Exported Macros
__HAL_IRDA_GETCLOCKSOURCE
Description:
Parameters:
Return value:
__HAL_IRDA_MASK_COMPUTATION
Description:
Parameters:
Return value:
none:
DocID026525 Rev 1
311/692
UM1785
25
25.1
25.1.1
IWDG_InitTypeDef
IWDG_InitTypeDef is defined in the stm32f0xx_hal_iwdg.h
Data Fields
uint32_t Prescaler
uint32_t Reload
uint32_t Window
Field Documentation
25.1.2
IWDG_HandleTypeDef
IWDG_HandleTypeDef is defined in the stm32f0xx_hal_iwdg.h
Data Fields
IWDG_TypeDef * Instance
IWDG_InitTypeDef Init
HAL_LockTypeDef Lock
__IO HAL_IWDG_StateTypeDef State
Field Documentation
25.2
25.2.1
312/692
DocID026525 Rev 1
UM1785
25.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. STM32F0x 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 STM32F0x Reference manual.
1.
2.
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.
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:
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.
DocID026525 Rev 1
313/692
25.2.3
UM1785
Initialization functions
This section provides functions allowing to:
25.2.4
IO operation functions
This section provides functions allowing to:
25.2.5
25.2.6
314/692
HAL_IWDG_GetState()
HAL_IWDG_Init
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
UM1785
25.2.7
25.2.8
25.2.9
HAL_IWDG_MspInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_IWDG_Start
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_IWDG_Refresh
Function Name
HAL_StatusTypeDef HAL_IWDG_Refresh (
IWDG_HandleTypeDef * hiwdg)
Function Description
Parameters
Return values
HAL status
DocID026525 Rev 1
315/692
25.2.10
UM1785
None.
HAL_IWDG_GetState
Function Name
HAL_IWDG_StateTypeDef HAL_IWDG_GetState (
IWDG_HandleTypeDef * hiwdg)
Function Description
Parameters
Return values
HAL state
Notes
None.
25.3
25.3.1
IWDG
IWDG
IWDG CounterWindow Value
IS_IWDG_WINDOW
IWDG Exported Macros
__HAL_IWDG_RESET_HANDLE_STATE
Description:
Parameters:
Return value:
__HAL_IWDG_START
None:
Description:
Parameters:
Return value:
316/692
DocID026525 Rev 1
None:
UM1785
Description:
Parameters:
Return value:
__HAL_IWDG_ENABLE_WRITE_ACCESS
None:
Description:
Parameters:
Return value:
__HAL_IWDG_DISABLE_WRITE_ACCESS
None:
Description:
Parameters:
Return value:
__HAL_IWDG_GET_FLAG
None:
Description:
Parameters:
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:
317/692
UM1785
Watchdog counter prescaler value update Flag
IWDG_FLAG_RVU
IWDG_FLAG_WVU
IWDG Prescaler
IWDG_PRESCALER_4
IWDG_PRESCALER_8
IWDG_PRESCALER_16
IWDG_PRESCALER_32
IWDG_PRESCALER_64
IWDG_PRESCALER_128
IWDG_PRESCALER_256
IS_IWDG_PRESCALER
IWDG Private Defines
HAL_IWDG_DEFAULT_TIMEOUT
IWDG Registers BitMask
KR_KEY_RELOAD
KR_KEY_ENABLE
KR_KEY_EWA
KR_KEY_DWA
IS_IWDG_KR
IWDG Reload Value
IS_IWDG_RELOAD
IWDG Window option
IWDG_WINDOW_DISABLE
318/692
DocID026525 Rev 1
UM1785
26
26.1
26.1.1
PCD_InitTypeDef
PCD_InitTypeDef is defined in the stm32f0xx_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
26.1.2
PCD_EPTypeDef
PCD_EPTypeDef is defined in the stm32f0xx_hal_pcd.h
Data Fields
uint8_t num
uint8_t is_in
uint8_t is_stall
uint8_t type
uint16_t pmaadress
uint16_t pmaaddr0
uint16_t pmaaddr1
DocID026525 Rev 1
319/692
UM1785
uint8_t doublebuffer
uint32_t maxpacket
uint8_t * xfer_buff
uint32_t xfer_len
uint32_t xfer_count
Field Documentation
26.1.3
PCD_HandleTypeDef
PCD_HandleTypeDef is defined in the stm32f0xx_hal_pcd.h
Data Fields
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
320/692
UM1785
26.2
26.2.1
5.
6.
26.2.2
__USB_CLK_ENABLE);
b.
Initialize the related GPIO clocks
c.
Configure PCD pin-out
d.
Configure PCD NVIC interrupt
Associate the Upper USB device stack to the HAL PCD Driver:
a.
hpcd.pData = pdev;
Enable HCD transmission and reception:
a.
HAL_PCD_Start();
26.2.2.1
HAL_PCD_Init()
HAL_PCD_DeInit()
HAL_PCD_MspInit()
HAL_PCD_MspDeInit()
HAL_PCD_Init
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
321/692
26.2.3
UM1785
IO operation functions
This subsection provides a set of functions allowing to manage the PCD data transfers.
26.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()
26.2.5
HAL_PCD_DevConnect()
HAL_PCD_DevDisconnect()
HAL_PCD_SetAddress()
HAL_PCD_EP_Open()
HAL_PCD_EP_Close()
HAL_PCD_EP_Receive()
HAL_PCD_EP_GetRxCount()
HAL_PCD_EP_Transmit()
HAL_PCD_EP_SetStall()
HAL_PCD_EP_ClrStall()
HAL_PCD_EP_Flush()
HAL_PCD_ActiveRemoteWakeup()
HAL_PCD_DeActiveRemoteWakeup()
26.2.6
322/692
HAL_PCD_GetState()
HAL_PCD_Init
DocID026525 Rev 1
UM1785
Function Name
26.2.7
26.2.8
26.2.9
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_PCD_DeInit
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_PCD_MspInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_PCD_MspDeInit
DocID026525 Rev 1
323/692
26.2.10
26.2.11
26.2.12
Function Description
Parameters
Return values
None.
Notes
None.
HAL_PCD_Start
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_PCD_Stop
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_PCD_IRQHandler
Function Name
324/692
UM1785
void HAL_PCD_MspDeInit ( PCD_HandleTypeDef * hpcd)
UM1785
26.2.13
26.2.14
26.2.15
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_PCD_DataOutStageCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_PCD_DataInStageCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_PCD_SetupStageCallback
DocID026525 Rev 1
325/692
26.2.16
26.2.17
26.2.18
Function Description
Parameters
Return values
None.
Notes
None.
HAL_PCD_SOFCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_PCD_ResetCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_PCD_SuspendCallback
Function Name
326/692
UM1785
void HAL_PCD_SetupStageCallback ( PCD_HandleTypeDef *
hpcd)
UM1785
26.2.19
26.2.20
26.2.21
Parameters
Return values
None.
Notes
None.
HAL_PCD_ResumeCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_PCD_ISOOUTIncompleteCallback
Function Name
void HAL_PCD_ISOOUTIncompleteCallback (
PCD_HandleTypeDef * hpcd, uint8_t epnum)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_PCD_ISOINIncompleteCallback
Function Name
void HAL_PCD_ISOINIncompleteCallback (
DocID026525 Rev 1
327/692
UM1785
PCD_HandleTypeDef * hpcd, uint8_t epnum)
26.2.22
26.2.23
26.2.24
328/692
Function Description
Parameters
Return values
None.
Notes
None.
HAL_PCD_ConnectCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_PCD_DisconnectCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_PCD_DevConnect
DocID026525 Rev 1
UM1785
26.2.25
26.2.26
26.2.27
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_PCD_DevDisconnect
Function Name
HAL_StatusTypeDef HAL_PCD_DevDisconnect (
PCD_HandleTypeDef * hpcd)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_PCD_SetAddress
Function Name
HAL_StatusTypeDef HAL_PCD_SetAddress (
PCD_HandleTypeDef * hpcd, uint8_t address)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_PCD_EP_Open
DocID026525 Rev 1
329/692
26.2.28
26.2.29
330/692
UM1785
HAL_StatusTypeDef HAL_PCD_EP_Open (
PCD_HandleTypeDef * hpcd, uint8_t ep_addr, uint16_t
ep_mps, uint8_t ep_type)
Function Description
Parameters
Return values
HAL status
Notes
None.
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
Return values
HAL status
Notes
None.
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
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
UM1785
26.2.30
26.2.31
26.2.32
HAL_PCD_EP_GetRxCount
Function Name
Function Description
Parameters
Return values
Data Size
Notes
None.
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
Parameters
Return values
HAL status
Notes
None.
HAL_PCD_EP_SetStall
Function Name
HAL_StatusTypeDef HAL_PCD_EP_SetStall (
PCD_HandleTypeDef * hpcd, uint8_t ep_addr)
Function Description
331/692
26.2.33
26.2.34
26.2.35
Return values
HAL status
Notes
None.
HAL_PCD_EP_ClrStall
Function Name
HAL_StatusTypeDef HAL_PCD_EP_ClrStall (
PCD_HandleTypeDef * hpcd, uint8_t ep_addr)
Function Description
Parameters
Return values
HAL status
Notes
None.
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
Return values
HAL status
Notes
None.
HAL_PCD_ActiveRemoteWakeup
Function Name
332/692
UM1785
HAL_StatusTypeDef HAL_PCD_ActiveRemoteWakeup (
DocID026525 Rev 1
UM1785
26.2.36
26.2.37
Function Description
Parameters
Return values
status
Notes
None.
HAL_PCD_DeActiveRemoteWakeup
Function Name
HAL_StatusTypeDef HAL_PCD_DeActiveRemoteWakeup (
PCD_HandleTypeDef * hpcd)
Function Description
Parameters
Return values
status
Notes
None.
HAL_PCD_GetState
Function Name
Function Description
Parameters
Return values
HAL state
Notes
None.
DocID026525 Rev 1
333/692
UM1785
26.3
26.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
PCD_ENDP2
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
334/692
DocID026525 Rev 1
UM1785
__HAL_USB_EXTI_ENABLE_IT
__HAL_USB_EXTI_DISABLE_IT
__HAL_USB_EXTI_GENERATE_SWIT
PCD Private Define
BTABLE_ADDRESS
PCD Private Macros
PCD_SET_ENDPOINT
PCD_GET_ENDPOINT
PCD_SET_EPTYPE
Description:
Parameters:
Return value:
PCD_GET_EPTYPE
None:
Description:
Parameters:
Return value:
PCD_FreeUserBuffer
Endpoint: Type
Description:
Parameters:
Return value:
DocID026525 Rev 1
335/692
UM1785
None:
Description:
PCD_GET_DB_DIR
Parameters:
Return value:
Description:
PCD_SET_EP_TX_STATUS
Parameters:
Return value:
PCD_SET_EP_RX_STATUS
None:
Description:
Parameters:
Return value:
PCD_SET_EP_TXRX_STATUS
None:
Description:
Parameters:
Return value:
336/692
None:
DocID026525 Rev 1
UM1785
Description:
Parameters:
Return value:
status:
PCD_GET_EP_RX_STATUS
Description:
PCD_SET_EP_TX_VALID
Parameters:
Return value:
None:
PCD_SET_EP_RX_VALID
PCD_GET_EP_TX_STALL_STATUS
Description:
Parameters:
Return value:
PCD_GET_EP_RX_STALL_STATUS
PCD_SET_EP_KIND
Description:
Parameters:
Return value:
None:
PCD_CLEAR_EP_KIND
PCD_SET_OUT_STATUS
Description:
DocID026525 Rev 1
337/692
UM1785
Parameters:
Return value:
None:
PCD_CLEAR_OUT_STATUS
PCD_SET_EP_DBUF
Description:
Parameters:
Return value:
None:
PCD_CLEAR_EP_DBUF
PCD_CLEAR_RX_EP_CTR
Description:
Parameters:
Return value:
None:
PCD_CLEAR_TX_EP_CTR
PCD_RX_DTOG
Description:
Parameters:
Return value:
None:
PCD_TX_DTOG
PCD_CLEAR_RX_DTOG
338/692
Description:
DocID026525 Rev 1
UM1785
Parameters:
Return value:
None:
PCD_CLEAR_TX_DTOG
Description:
PCD_SET_EP_ADDRESS
Parameters:
Return value:
None:
Description:
PCD_GET_EP_ADDRESS
Parameters:
Return value:
None:
PCD_EP_TX_ADDRESS
PCD_EP_TX_CNT
PCD_EP_RX_ADDRESS
PCD_EP_RX_CNT
PCD_SET_EP_TX_ADDRESS
Description:
Parameters:
Return value:
None:
DocID026525 Rev 1
339/692
UM1785
Description:
Parameters:
Return value:
PCD_GET_EP_RX_ADDRESS
Description:
PCD_CALC_BLK32
Parameters:
dwReg: Register
wCount: Counter.
wNBlocks: no. of Blocks.
Return value:
None:
PCD_CALC_BLK2
PCD_SET_EP_CNT_RX_REG
PCD_SET_EP_RX_DBUF0_CNT
PCD_SET_EP_TX_CNT
Description:
Parameters:
Return value:
None:
PCD_SET_EP_RX_CNT
PCD_GET_EP_TX_CNT
Description:
Parameters:
Return value:
340/692
Counter: value
DocID026525 Rev 1
UM1785
Description:
Parameters:
Return value:
Counter: value
PCD_SET_EP_DBUF1_ADDR
PCD_SET_EP_DBUF_ADDR
Description:
Parameters:
Return value:
PCD_GET_EP_DBUF0_ADDR
None:
Description:
Parameters:
Return value:
None:
PCD_GET_EP_DBUF1_ADDR
PCD_SET_EP_DBUF0_CNT
Description:
Parameters:
DocID026525 Rev 1
341/692
UM1785
Return value:
None:
PCD_SET_EP_DBUF1_CNT
PCD_SET_EP_DBUF_CNT
PCD_GET_EP_DBUF0_CNT
Description:
Parameters:
Return value:
None:
PCD_GET_EP_DBUF1_CNT
342/692
DocID026525 Rev 1
UM1785
27
27.1
27.1.1
27.1.2
HAL_PCDEx_PMAConfig()
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
Parameters
Return values
: status
Notes
None.
DocID026525 Rev 1
343/692
UM1785
28
28.1
28.1.1
28.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.
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 two WakeUp pins, and up to eight Wakeup pins on STM32F07x &
STM32F09x devices.
Sleep mode
344/692
UM1785
Exit:
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.
Standby mode
The Standby mode allows to achieve the lowest power consumption. It is based on the
Cortex-M0 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 and Standby circuitry. The voltage regulator is OFF.
Entry:
WKUP pin rising edge, RTC alarm (Alarm A), RTC wakeup, tamper event, timestamp event, external reset in NRST pin, IWDG reset.
To wake up from the Stop mode with an RTC alarm event, it is necessary to
configure the RTC to generate the RTC alarm using the
HAL_RTC_SetAlarm_IT() function.
To wake up from the Stop mode with an RTC Tamper or time stamp event, it is
necessary to configure the RTC to detect the tamper or time stamp event using
the HAL_RTC_SetTimeStamp_IT() or HAL_RTC_SetTamper_IT() functions.
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
DocID026525 Rev 1
345/692
UM1785
28.1.3
28.1.4
346/692
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.
HAL_PWR_EnableBkUpAccess
Function Name
Function Description
Return values
None.
Notes
HAL_PWR_DisableBkUpAccess
Function Name
Function Description
Return values
None.
Notes
DocID026525 Rev 1
UM1785
28.1.5
28.1.6
28.1.7
HAL_PWR_EnableWakeUpPin
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_PWR_DisableWakeUpPin
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_PWR_EnterSLEEPMode
Function Name
Function Description
Parameters
347/692
UM1785
28.1.8
Return values
None.
Notes
In Sleep mode, all I/O pins keep the same state as in Run
mode.
HAL_PWR_EnterSTOPMode
Function Name
Function Description
Parameters
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.
28.1.9
348/692
HAL_PWR_EnterSTANDBYMode
DocID026525 Rev 1
UM1785
28.1.10
28.1.11
Function Name
Function Description
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. STM32F0x8
devices, the Stop mode is available, but it is aningless to
distinguish between voltage regulator in Low power mode and
voltage regulator in Run mode because the regulator not used
and the core is supplied directly from an external source.
Consequently, the Standby mode is not available on those
devices.
HAL_PWR_EnableSleepOnExit
Function Name
Function Description
Return values
None.
Notes
HAL_PWR_DisableSleepOnExit
Function Name
Function Description
Return values
None.
Notes
DocID026525 Rev 1
349/692
28.1.12
28.1.13
28.1.14
350/692
UM1785
HAL_PWR_EnableSEVOnPend
Function Name
Function Description
Return values
None.
Notes
HAL_PWR_DisableSEVOnPend
Function Name
Function Description
Return values
None.
Notes
HAL_PWR_EnableBkUpAccess
Function Name
Function Description
Return values
None.
Notes
DocID026525 Rev 1
UM1785
28.1.15
HAL_PWR_DisableBkUpAccess
Function Name
Function Description
Return values
None.
Notes
28.2
28.2.1
PWR
PWR
PWR Exported Macro
__HAL_PWR_GET_FLAG
Description:
Parameters:
DocID026525 Rev 1
351/692
UM1785
STM32F030x8 products
Return value:
__HAL_PWR_CLEAR_FLAG
Description:
Parameters:
352/692
DocID026525 Rev 1
UM1785
29
29.1
29.1.1
PWR_PVDTypeDef
PWR_PVDTypeDef is defined in the stm32f0xx_hal_pwr_ex.h
Data Fields
uint32_t PVDLevel
uint32_t Mode
Field Documentation
29.2
29.2.1
PVD configuration
The PVD is used to monitor the VDD power supply by comparing it to a threshold
selected by the PVD Level (PLS[2:0] bits in the PWR_CR).
A PVDO flag is available to indicate if VDD/VDDA is higher or lower than the PVD
threshold. This event is internally connected to the EXTI line16 and can generate an
interrupt if enabled. This is done through HAL_PWR_PVDConfig(),
HAL_PWR_EnablePVD() functions.
The PVD is stopped in Standby mode. PVD is not available on STM32F030x4/x6/x8
353/692
29.2.2
29.2.3
29.2.4
354/692
UM1785
HAL_PWR_PVDCallback()
HAL_PWR_EnableVddio2Monitor()
HAL_PWR_DisableVddio2Monitor()
HAL_PWR_Vddio2Monitor_IRQHandler()
HAL_PWR_Vddio2MonitorCallback()
HAL_PWR_PVDConfig
Function Name
Function Description
Parameters
Return values
None.
Notes
HAL_PWR_EnablePVD
Function Name
Function Description
Return values
None.
Notes
None.
HAL_PWR_DisablePVD
Function Name
Function Description
Return values
None.
Notes
None.
DocID026525 Rev 1
UM1785
29.2.5
29.2.6
29.2.7
HAL_PWR_PVD_IRQHandler
Function Name
Function Description
Return values
None.
Notes
HAL_PWR_PVDCallback
Function Name
Function Description
Return values
None.
Notes
None.
HAL_PWR_EnableVddio2Monitor
Function Name
Function Description
Return values
None.
Notes
DocID026525 Rev 1
355/692
29.2.8
29.2.9
29.2.10
UM1785
HAL_PWR_DisableVddio2Monitor
Function Name
Function Description
Return values
None.
Notes
None.
HAL_PWR_Vddio2Monitor_IRQHandler
Function Name
Function Description
Return values
None.
Notes
HAL_PWR_Vddio2MonitorCallback
Function Name
Function Description
Return values
None.
Notes
None.
29.3
29.3.1
PWREx
PWREx
PWREx Exported Macros
356/692
DocID026525 Rev 1
UM1785
__HAL_PWR_PVD_EXTI_ENABLE_IT
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_ENABLE_EVENT
None.:
Description:
Enable event on
PVD 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:
Return value:
__HAL_PWR_PVD_EXTI_SET_FALLING_EGDE_TRIGGER
None.:
Description:
Return value:
__HAL_PWR_PVD_EXTI_SET_RISING_EDGE_TRIGGER
None.:
Description:
Return value:
DocID026525 Rev 1
357/692
UM1785
__HAL_PWR_PVD_EXTI_GET_FLAG
None.:
Description:
Return value:
__HAL_PWR_PVD_EXTI_CLEAR_FLAG
Description:
Return value:
__HAL_PWR_PVD_EXTI_GENERATE_SWIT
None.:
Description:
Generate a
Software interrupt
on selected EXTI
line.
Return value:
__HAL_PWR_VDDIO2_EXTI_ENABLE_IT
None.:
Description:
Enable interrupt
on Vddio2 Monitor
Exti Line 31.
Return value:
__HAL_PWR_VDDIO2_EXTI_DISABLE_IT
None.:
Description:
Disable interrupt
on Vddio2 Monitor
Exti Line 31.
Return value:
__HAL_PWR_VDDIO2_EXTI_CLEAR_EGDE_TRIGGER
None.:
Description:
Vddio2 Monitor
EXTI line
configuration: clear
falling edge and
rising edge trigger.
Return value:
358/692
DocID026525 Rev 1
None.:
UM1785
Vddio2 Monitor
EXTI line
configuration: set
falling edge
trigger.
Return value:
__HAL_PWR_VDDIO2_EXTI_GET_FLAG
None.:
Description:
Return value:
__HAL_PWR_VDDIO2_EXTI_CLEAR_FLAG
EXTI: VDDIO2
Monitor Line
Status.
Description:
Return value:
__HAL_PWR_VDDIO2_EXTI_GENERATE_SWIT
None.:
Description:
Generate a
Software interrupt
on selected EXTI
line.
Return value:
None.:
PWR_EXTI_LINE_VDDIO2
PWREx Flag
PWR_FLAG_WU
PWR_FLAG_SB
PWR_FLAG_PVDO
PWR_FLAG_VREFINTRDY
PWREx Private Constants
PVD_MODE_IT
DocID026525 Rev 1
359/692
UM1785
PVD_RISING_EDGE
PVD_FALLING_EDGE
PWREx 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
PWREx PVD Mode
PWR_PVD_MODE_NORMAL
PWR_PVD_MODE_IT_RISING
PWR_PVD_MODE_IT_FALLING
PWR_PVD_MODE_IT_RISING_FALLING
PWR_PVD_MODE_EVENT_RISING
PWR_PVD_MODE_EVENT_FALLING
PWR_PVD_MODE_EVENT_RISING_FALLING
IS_PWR_PVD_MODE
PWREx Wakeup Pins
PWR_WAKEUP_PIN1
PWR_WAKEUP_PIN2
PWR_WAKEUP_PIN3
PWR_WAKEUP_PIN4
PWR_WAKEUP_PIN5
PWR_WAKEUP_PIN6
PWR_WAKEUP_PIN7
PWR_WAKEUP_PIN8
IS_PWR_WAKEUP_PIN
360/692
DocID026525 Rev 1
UM1785
30
30.1
30.1.1
RCC_PLLInitTypeDef
RCC_PLLInitTypeDef is defined in the stm32f0xx_hal_rcc.h
Data Fields
uint32_t PLLState
uint32_t PLLSource
uint32_t PREDIV
uint32_t PLLMUL
Field Documentation
30.1.2
RCC_OscInitTypeDef
RCC_OscInitTypeDef is defined in the stm32f0xx_hal_rcc.h
Data Fields
uint32_t OscillatorType
uint32_t HSEState
uint32_t LSEState
uint32_t HSIState
uint32_t HSICalibrationValue
uint32_t HSI14State
uint32_t HSI14CalibrationValue
uint32_t HSI48State
uint32_t LSIState
RCC_PLLInitTypeDef PLL
Field Documentation
361/692
30.1.3
UM1785
RCC_ClkInitTypeDef
RCC_ClkInitTypeDef is defined in the stm32f0xx_hal_rcc.h
Data Fields
uint32_t ClockType
uint32_t SYSCLKSource
uint32_t AHBCLKDivider
uint32_t APB1CLKDivider
Field Documentation
30.2
30.2.1
362/692
DocID026525 Rev 1
UM1785
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.
Once the device started from reset, the user application has to:
30.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, USART, TIM, USB FS, etc..)
RCC Limitations
A delay between an RCC peripheral clock enable and the effective peripheral enabling
should be taken into account in order to manage the peripheral read/write from/to
registeres.
Possible Workarounds:
1.
2.
3.
30.2.3
Enable the peripheral clock sometimes before the peripheral read/write register is
required.
For AHB peripheral, insert two dummy read to the peripheral register.
For APB peripheral, insert a dummy read to the peripheral register.
2.
3.
4.
5.
6.
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.
HSI14 (high-speed internal), 14 MHz factory-trimmed RC used directly to clock the
ADC peripheral.
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, HSI48 or HSE), featuring different output clocks:
The first output is used to generate the high speed system clock (up to 48 MHz)
The second output is used to generate the clock for the USB FS (48 MHz)
DocID026525 Rev 1
363/692
UM1785
7.
8.
The third output may be used to generate the clock for the TIM, I2C and USART
peripherals (up to 48 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-M0
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).
2.
3.
4.
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) clock is 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 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 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.
Latency
0 SYSCLK 24
24 < HCLK 48
30.2.4
HAL_RCC_DeInit()
HAL_RCC_OscConfig()
HAL_RCC_ClockConfig()
364/692
HAL_RCC_MCOConfig()
HAL_RCC_EnableCSS()
HAL_RCC_DisableCSS()
HAL_RCC_GetSysClockFreq()
HAL_RCC_GetHCLKFreq()
HAL_RCC_GetPCLK1Freq()
DocID026525 Rev 1
UM1785
30.2.5
HAL_RCC_GetOscConfig()
HAL_RCC_GetClockConfig()
HAL_RCC_NMI_IRQHandler()
HAL_RCC_CCSCallback()
HAL_RCC_DeInit
Function Name
Function Description
Return values
None.
Notes
30.2.6
30.2.7
HAL_RCC_OscConfig
Function Name
HAL_StatusTypeDef HAL_RCC_OscConfig (
RCC_OscInitTypeDef * RCC_OscInitStruct)
Function Description
Parameters
Return values
HAL status
Notes
HAL_RCC_ClockConfig
Function Name
HAL_StatusTypeDef HAL_RCC_ClockConfig (
RCC_ClkInitTypeDef * RCC_ClkInitStruct, uint32_t FLatency)
DocID026525 Rev 1
365/692
UM1785
Initializes the CPU, AHB and APB busses clocks according to the
specified parameters in the RCC_ClkInitStruct.
Return values
HAL status
Notes
30.2.8
HAL_RCC_MCOConfig
Function Name
Function Description
Parameters
366/692
UM1785
30.2.9
30.2.10
Return values
None.
Notes
HAL_RCC_EnableCSS
Function Name
Function Description
Return values
None.
Notes
HAL_RCC_DisableCSS
Function Name
Function Description
Return values
None.
Notes
None.
DocID026525 Rev 1
367/692
30.2.11
UM1785
HAL_RCC_GetSysClockFreq
Function Name
Function Description
Return values
SYSCLK frequency
Notes
30.2.12
368/692
HAL_RCC_GetHCLKFreq
Function Name
Function Description
Return values
HCLK frequency
Notes
UM1785
30.2.13
30.2.14
30.2.15
HAL_RCC_GetPCLK1Freq
Function Name
Function Description
Return values
PCLK1 frequency
Notes
HAL_RCC_GetOscConfig
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_RCC_GetClockConfig
Function Name
Function Description
369/692
30.2.16
30.2.17
UM1785
Return values
None.
Notes
None.
HAL_RCC_NMI_IRQHandler
Function Name
Function Description
Return values
None.
Notes
HAL_RCC_CCSCallback
Function Name
Function Description
Return values
none
Notes
None.
30.3
30.3.1
RCC
RCC
RCC AHB Clock Enable Disable
__GPIOA_CLK_ENABLE
__GPIOB_CLK_ENABLE
__GPIOC_CLK_ENABLE
370/692
DocID026525 Rev 1
UM1785
DocID026525 Rev 1
371/692
UM1785
__TIM14_CLK_ENABLE
__WWDG_CLK_ENABLE
__I2C1_CLK_ENABLE
__PWR_CLK_ENABLE
__TIM3_CLK_DISABLE
__TIM14_CLK_DISABLE
__WWDG_CLK_DISABLE
__I2C1_CLK_DISABLE
__PWR_CLK_DISABLE
RCC APB1 Clock Source
RCC_HCLK_DIV1
RCC_HCLK_DIV2
RCC_HCLK_DIV4
RCC_HCLK_DIV8
RCC_HCLK_DIV16
IS_RCC_HCLK_DIV
RCC APB1 Force Release Reset
__APB1_FORCE_RESET
__TIM3_FORCE_RESET
__TIM14_FORCE_RESET
__WWDG_FORCE_RESET
__I2C1_FORCE_RESET
__PWR_FORCE_RESET
__APB1_RELEASE_RESET
__TIM3_RELEASE_RESET
__TIM14_RELEASE_RESET
__WWDG_RELEASE_RESET
__I2C1_RELEASE_RESET
__PWR_RELEASE_RESET
RCC APB2 Clock Enable Disable
__SYSCFG_CLK_ENABLE
__ADC1_CLK_ENABLE
__TIM1_CLK_ENABLE
__SPI1_CLK_ENABLE
__TIM16_CLK_ENABLE
372/692
DocID026525 Rev 1
UM1785
DocID026525 Rev 1
373/692
UM1785
RCC_CR2_OFFSET
RCC_CR_BYTE2_ADDRESS
RCC_CIR_BYTE1_ADDRESS
RCC_CIR_BYTE2_ADDRESS
RCC_CSR_BYTE1_ADDRESS
RCC_BDCR_BYTE0_ADDRESS
RCC_CFGR_PLLMUL_BITNUMBER
RCC_CFGR2_PREDIV_BITNUMBER
RCC Calibration values
IS_RCC_CALIBRATION_VALUE
RCC Flag
CR_REG_INDEX
CR2_REG_INDEX
BDCR_REG_INDEX
CSR_REG_INDEX
RCC_CR_HSIRDY_BitNumber
RCC_CR_HSERDY_BitNumber
RCC_CR_PLLRDY_BitNumber
RCC_FLAG_HSIRDY
RCC_FLAG_HSERDY
RCC_FLAG_PLLRDY
RCC_CR2_HSI14RDY_BitNumber
RCC_FLAG_HSI14RDY
RCC_BDCR_LSERDY_BitNumber
RCC_FLAG_LSERDY
RCC_CSR_LSIRDY_BitNumber
RCC_CSR_V18PWRRSTF_BitNumber
RCC_CSR_RMVF_BitNumber
RCC_CSR_OBLRSTF_BitNumber
RCC_CSR_PINRSTF_BitNumber
RCC_CSR_PORRSTF_BitNumber
RCC_CSR_SFTRSTF_BitNumber
RCC_CSR_IWDGRSTF_BitNumber
RCC_CSR_WWDGRSTF_BitNumber
RCC_CSR_LPWRRSTF_BitNumber
374/692
DocID026525 Rev 1
UM1785
Description:
Parameters:
__HAL_RCC_DISABLE_IT
Description:
Parameters:
DocID026525 Rev 1
375/692
__HAL_RCC_CLEAR_IT
UM1785
enable
RCC_IT_LSERDY: LSE ready interrupt
enable
RCC_IT_HSIRDY: HSI ready interrupt
enable
RCC_IT_HSERDY: HSE ready
interrupt enable
RCC_IT_PLLRDY: PLL ready interrupt
enable
RCC_IT_HSI14RDY: HSI14 ready
interrupt enable
RCC_IT_HSI48RDY: HSI48 ready
interrupt enable (only applicable to
STM32F0X2 USB devices)
Description:
Parameters:
__HAL_RCC_GET_IT
Description:
Parameters:
376/692
DocID026525 Rev 1
UM1785
Return value:
__HAL_RCC_CLEAR_RESET_FLAGS
RCC_FLAG_MASK
Description:
Parameters:
RCC_FLAG_HSI14RDY: HSI14
oscillator clock ready
RCC_FLAG_HSI48RDY: HSI48
oscillator clock ready (only applicable to
STM32F0X2 USB devices)
RCC_FLAG_PORRST: POR/PDR
reset
RCC_FLAG_IWDGRST: Independent
Watchdog reset
RCC_FLAG_WWDGRST: Window
Watchdog reset
Return value:
DocID026525 Rev 1
377/692
UM1785
__HAL_RCC_GET_FLAG
RCC Force Release Backup
__HAL_RCC_BACKUPRESET_FORCE
__HAL_RCC_BACKUPRESET_RELEASE
RCC Get Clock source
__HAL_RCC_GET_SYSCLK_SOU
RCE
Description:
Return value:
__HAL_RCC_GET_PLL_OSCSOU
RCE
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:
Return value:
Description:
Parameters:
378/692
DocID026525 Rev 1
UM1785
__HAL_RCC_HSE_PREDIV_CONFIG
Description:
Parameters:
Description:
Parameters:
__HSI14CalibrationValue__:
specifies the calibration trimming
value (default is
RCC_HSI14CALIBRATION_DE
FAULT). This parameter must be
a number between 0 and 0x1F.
__HAL_RCC_HSI14_CALIBRATIONVALUE_ADJ
UST
RCC HSI Config
RCC_HSI_OFF
RCC_HSI_ON
DocID026525 Rev 1
379/692
UM1785
RCC_HSICALIBRATION_DEFAULT
RCC HSI Configuration
__HAL_RCC_HSI_ENABLE
__HAL_RCC_HSI_DISABLE
Description:
RCC_CR_HSITRIM_BitNumber
Parameters:
__HSICalibrationValue__:
specifies the calibration
trimming value (default is
RCC_HSICALIBRATION_DEFA
ULT). This parameter must be a
number between 0 and 0x1F.
__HAL_RCC_HSI_CALIBRATIONVALUE_ADJUS
T
RCC I2C1 Clock Source
RCC_I2C1CLKSOURCE_HSI
RCC_I2C1CLKSOURCE_SYSCLK
IS_RCC_I2C1CLKSOURCE
RCC I2Cx Clock Config
__HAL_RCC_I2C1_CONFIG
Description:
Parameters:
__HAL_RCC_GET_I2C1_SOURCE
RCC_I2C1CLKSOURCE_HSI: HSI
selected as I2C1 clock
RCC_I2C1CLKSOURCE_SYSCLK:
System Clock selected as I2C1 clock
Description:
Return value:
RCC_I2C1CLKSOURCE_HSI: HSI
selected as I2C1 clock
RCC_I2C1CLKSOURCE_SYSCLK:
System Clock selected as I2C1 clock
RCC Interrupt
380/692
DocID026525 Rev 1
UM1785
Description:
Parameters:
DocID026525 Rev 1
381/692
UM1785
RCC_MCOSOURCE_HSI
RCC_MCOSOURCE_HSE
RCC_MCOSOURCE_PLLCLK_DIV2
RCC_MCOSOURCE_HSI14
RCC Oscillator Type
RCC_OSCILLATORTYPE_NONE
RCC_OSCILLATORTYPE_HSE
RCC_OSCILLATORTYPE_HSI
RCC_OSCILLATORTYPE_LSE
RCC_OSCILLATORTYPE_LSI
RCC_OSCILLATORTYPE_HSI14
RCC_OSCILLATORTYPE_HSI48
IS_RCC_OSCILLATORTYPE
RCC PLL Clock Source
RCC_PLLSOURCE_HSE
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
__HAL_RCC_PLL_CONFIG
Description:
Parameters:
382/692
DocID026525 Rev 1
UM1785
383/692
UM1785
RCC_CFGR_HPRE_BITNUMBER
RCC_CFGR_PPRE_BITNUMBER
RCC Private Macros
__MCO_CLK_ENABLE
MCO_GPIO_PORT
MCO_PIN
RCC RTC Clock Configuration
__HAL_RCC_RTC_ENABLE
__HAL_RCC_RTC_DISABLE
Description:
__HAL_RCC_RTC_CONFIG
Parameters:
__HAL_RCC_GET_RTC_SOURC
E
RCC_RTCCLKSOURCE_NONE: No clock
selected as RTC clock
RCC_RTCCLKSOURCE_LSE: LSE
selected as RTC clock
RCC_RTCCLKSOURCE_HSE_DIV32:
HSE clock divided by 32
Description:
Return value:
RCC_RTCCLKSOURCE_NONE: No clock
selected as RTC clock
RCC_RTCCLKSOURCE_LSE: LSE
selected as RTC clock
RCC_RTCCLKSOURCE_HSE_DIV32:
HSE clock divided by 32 selected as RTC
clock
DocID026525 Rev 1
UM1785
Description:
Parameters:
DocID026525 Rev 1
385/692
UM1785
USART1 clock source. This parameter can be
one of the following values:
RCC_USART1CLKSOURCE_PCLK1:
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
__HAL_RCC_GET_USART1_SOUR
CE
Description:
Return value:
386/692
RCC_USART1CLKSOURCE_PCLK1:
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
DocID026525 Rev 1
UM1785
31
31.1
31.1.1
RCC_PeriphCLKInitTypeDef
RCC_PeriphCLKInitTypeDef is defined in the stm32f0xx_hal_rcc_ex.h
Data Fields
uint32_t PeriphClockSelection
uint32_t RTCClockSelection
uint32_t Usart1ClockSelection
uint32_t Usart2ClockSelection
uint32_t Usart3ClockSelection
uint32_t I2c1ClockSelection
uint32_t CecClockSelection
Field Documentation
31.1.2
RCC_CRSInitTypeDef
RCC_CRSInitTypeDef is defined in the stm32f0xx_hal_rcc_ex.h
Data Fields
uint32_t Prescaler
uint32_t Source
uint32_t Polarity
uint32_t ReloadValue
uint32_t ErrorLimitValue
uint32_t HSI48CalibrationValue
Field Documentation
DocID026525 Rev 1
387/692
31.1.3
UM1785
RCC_CRSSynchroInfoTypeDef
RCC_CRSSynchroInfoTypeDef is defined in the stm32f0xx_hal_rcc_ex.h
Data Fields
uint32_t ReloadValue
uint32_t HSI48CalibrationValue
uint32_t FreqErrorCapture
uint32_t FreqErrorDirection
Field Documentation
31.2
31.2.1
388/692
DocID026525 Rev 1
UM1785
31.2.2
31.2.3
31.2.4
HAL_RCC_OscConfig()
HAL_RCC_ClockConfig()
HAL_RCC_GetSysClockFreq()
HAL_RCCEx_PeriphCLKConfig()
HAL_RCCEx_GetPeriphCLKConfig()
HAL_RCCEx_CRSConfig()
HAL_RCCEx_CRSSoftwareSynchronizationGenerate()
HAL_RCCEx_CRSGetSynchronizationInfo()
HAL_RCCEx_CRSWaitSynchronization()
HAL_RCC_OscConfig
Function Name
HAL_StatusTypeDef HAL_RCC_OscConfig (
RCC_OscInitTypeDef * RCC_OscInitStruct)
Function Description
Parameters
Return values
HAL status
Notes
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.
DocID026525 Rev 1
389/692
UM1785
Return values
HAL status
Notes
31.2.5
HAL_RCC_GetSysClockFreq
Function Name
Function Description
Return values
SYSCLK frequency
Notes
390/692
DocID026525 Rev 1
UM1785
31.2.6
31.2.7
HAL_RCCEx_PeriphCLKConfig
Function Name
HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig (
RCC_PeriphCLKInitTypeDef * PeriphClkInit)
Function Description
Parameters
Return values
None.
Notes
HAL_RCCEx_GetPeriphCLKConfig
Function Name
void HAL_RCCEx_GetPeriphCLKConfig (
RCC_PeriphCLKInitTypeDef * PeriphClkInit)
Function Description
Parameters
391/692
UM1785
USB).
31.2.8
31.2.9
31.2.10
392/692
Return values
None.
Notes
None.
HAL_RCCEx_CRSConfig
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_RCCEx_CRSSoftwareSynchronizationGenerate
Function Name
void HAL_RCCEx_CRSSoftwareSynchronizationGenerate (
void )
Function Description
Return values
None.
Notes
None.
HAL_RCCEx_CRSGetSynchronizationInfo
Function Name
void HAL_RCCEx_CRSGetSynchronizationInfo (
RCC_CRSSynchroInfoTypeDef * pSynchroInfo)
Function Description
Parameters
DocID026525 Rev 1
UM1785
31.2.11
None.
Notes
None.
HAL_RCCEx_CRSWaitSynchronization
Function Name
RCC_CRSStatusTypeDef
HAL_RCCEx_CRSWaitSynchronization ( uint32_t Timeout)
Function Description
Parameters
Return values
RCC_CRS_TIMEOUT
RCC_CRS_SYNCOK
RCC_CRS_SYNCWARM
RCC_CRS_SYNCERR
RCC_CRS_SYNCMISS
RCC_CRS_TRIMOV
Notes
31.3
31.3.1
RCCEx
RCCEx
RCCEx CEC Clock Source
RCC_CECCLKSOURCE_HSI
RCC_CECCLKSOURCE_LSE
IS_RCC_CECCLKSOURCE
RCCEx CRS ErrorLimitDefault
RCC_CRS_ERRORLIMIT_DEFAULT
IS_RCC_CRS_ERRORLIMIT
RCCEx CRS Extended Features
DocID026525 Rev 1
393/692
UM1785
Description:
Return value:
__HAL_RCC_CRS_DISABLE_FREQ_ERROR_COUNTER
None:
Description:
Return value:
__HAL_RCC_CRS_ENABLE_AUTOMATIC_CALIB
None:
Description:
Return value:
__HAL_RCC_CRS_DISABLE_AUTOMATIC_CALIB
None:
Description:
Return value:
__HAL_RCC_CRS_CALCULATE_RELOADVALUE
None:
Description:
Macro to calculate
reload value to be set in
CRS register according
to target and sync
frequencies.
Parameters:
_FTARGET_: Target
frequency (value in Hz)
_FSYNC_:
Synchronization signal
frequency (value in Hz)
Return value:
DocID026525 Rev 1
None:
UM1785
RCC_CRS_FLAG_SYNCERR
SYNC error
RCC_CRS_FLAG_SYNCMISS
SYNC missed
RCC_CRS_FREQERRORDIR_DOWN
IS_RCC_CRS_FREQERRORDIR
RCCEx CRS HSI48CalibrationDefault
RCC_CRS_HSI48CALIBRATION_DEFAULT
IS_RCC_CRS_HSI48CALIBRATION
RCCEx CRS Interrupt Sources
RCC_CRS_IT_SYNCOK
SYNC event OK
RCC_CRS_IT_SYNCWARN
SYNC warning
RCC_CRS_IT_ERR
error
RCC_CRS_IT_ESYNC
Expected SYNC
RCC_CRS_IT_TRIMOVF
RCC_CRS_IT_SYNCERR
SYNC error
RCC_CRS_IT_SYNCMISS
SYNC missed
IS_RCC_CRS_RELOADVALUE
RCCEx CRS SynchroDivider
RCC_CRS_SYNC_DIV1
RCC_CRS_SYNC_DIV2
RCC_CRS_SYNC_DIV4
RCC_CRS_SYNC_DIV8
RCC_CRS_SYNC_DIV16
RCC_CRS_SYNC_DIV32
395/692
UM1785
Synchro Signal divided by 64
RCC_CRS_SYNC_DIV128
IS_RCC_CRS_SYNC_DIV
RCCEx CRS SynchroPolarity
RCC_CRS_SYNC_POLARITY_RISING
RCC_CRS_SYNC_POLARITY_FALLING
IS_RCC_CRS_SYNC_POLARITY
RCCEx CRS SynchroSource
RCC_CRS_SYNC_SOURCE_GPIO
RCC_CRS_SYNC_SOURCE_LSE
RCC_CRS_SYNC_SOURCE_USB
IS_RCC_CRS_SYNC_SOURCE
RCCEx Force Release Peripheral Reset
__GPIOD_FORCE_RESET
__GPIOD_RELEASE_RESET
__GPIOE_FORCE_RESET
__GPIOE_RELEASE_RESET
__TSC_FORCE_RESET
__TSC_RELEASE_RESET
__USART2_FORCE_RESET
__SPI2_FORCE_RESET
__USART2_RELEASE_RESET
__SPI2_RELEASE_RESET
__TIM2_FORCE_RESET
__TIM2_RELEASE_RESET
__TIM6_FORCE_RESET
__I2C2_FORCE_RESET
__TIM6_RELEASE_RESET
__I2C2_RELEASE_RESET
__DAC1_FORCE_RESET
__DAC1_RELEASE_RESET
__CEC_FORCE_RESET
__CEC_RELEASE_RESET
__TIM7_FORCE_RESET
__USART3_FORCE_RESET
__USART4_FORCE_RESET
396/692
DocID026525 Rev 1
UM1785
Description:
Return value:
Description:
Parameters:
DocID026525 Rev 1
397/692
UM1785
following values:
RCC_CRS_IT_SYNCOK
RCC_CRS_IT_SYNCWARN
RCC_CRS_IT_ERR
RCC_CRS_IT_ESYNC
Return value:
__HAL_RCC_CRS_DISABLE_IT
None:
Description:
Parameters:
RCC_CRS_IT_SYNCOK
RCC_CRS_IT_SYNCWARN
RCC_CRS_IT_ERR
RCC_CRS_IT_ESYNC
Return value:
__HAL_RCC_CRS_GET_IT_SOURCE
None:
Description:
Parameters:
RCC_CRS_IT_SYNCOK
RCC_CRS_IT_SYNCWARN
RCC_CRS_IT_ERR
RCC_CRS_IT_ESYNC
Return value:
RCC_CRS_IT_ERROR_MASK
Description:
Parameters:
398/692
RCC_CRS_IT_SYNCOK
RCC_CRS_IT_SYNCWARN
RCC_CRS_IT_ERR
RCC_CRS_IT_ESYNC
DocID026525 Rev 1
UM1785
RCC_CRS_IT_TRIMOVF
RCC_CRS_IT_SYNCERR
RCC_CRS_IT_SYNCMISS
__HAL_RCC_CRS_CLEAR_IT
__HAL_RCC_CRS_GET_FLAG
Description:
Parameters:
RCC_CRS_FLAG_SYNCOK
RCC_CRS_FLAG_SYNCWARN
RCC_CRS_FLAG_ERR
RCC_CRS_FLAG_ESYNC
RCC_CRS_FLAG_TRIMOVF
RCC_CRS_FLAG_SYNCERR
RCC_CRS_FLAG_SYNCMISS
Return value:
RCC_CRS_FLAG_ERROR_MASK
Description:
Parameters:
RCC_CRS_FLAG_SYNCOK
RCC_CRS_FLAG_SYNCWARN
RCC_CRS_FLAG_ERR
RCC_CRS_FLAG_ESYNC
RCC_CRS_FLAG_TRIMOVF
RCC_CRS_FLAG_SYNCERR
RCC_CRS_FLAG_SYNCMISS
Return value:
None:
__HAL_RCC_CRS_CLEAR_FLAG
RCCEx MCOx Clock Prescaler
RCC_MCO_DIV1
RCC_MCO_DIV2
RCC_MCO_DIV4
RCC_MCO_DIV8
RCC_MCO_DIV16
DocID026525 Rev 1
399/692
UM1785
RCC_MCO_DIV64
RCC_MCO_DIV128
IS_RCC_MCODIV
RCCEx MCO Clock Source
RCC_MCOSOURCE_HSI48
RCC_MCOSOURCE_PLLCLK_NODIV
IS_RCC_MCOSOURCE
RCC_IT_HSI48
RCC_CR2_HSI48RDY_BitNumber
RCC_FLAG_HSI48RDY
RCCEx_Peripheral_Clock_Enable_Disable
__GPIOD_CLK_ENABLE
__GPIOD_CLK_DISABLE
__GPIOE_CLK_ENABLE
__GPIOE_CLK_DISABLE
__TSC_CLK_ENABLE
__TSC_CLK_DISABLE
__DMA2_CLK_ENABLE
__DMA2_CLK_DISABLE
__USART2_CLK_ENABLE
__SPI2_CLK_ENABLE
__USART2_CLK_DISABLE
__SPI2_CLK_DISABLE
__TIM2_CLK_ENABLE
__TIM2_CLK_DISABLE
__TIM6_CLK_ENABLE
__I2C2_CLK_ENABLE
__TIM6_CLK_DISABLE
__I2C2_CLK_DISABLE
__DAC1_CLK_ENABLE
__DAC1_CLK_DISABLE
__CEC_CLK_ENABLE
__CEC_CLK_DISABLE
__TIM7_CLK_ENABLE
__USART3_CLK_ENABLE
400/692
DocID026525 Rev 1
UM1785
Description:
Parameters:
__HAL_RCC_GET_CEC_SOURCE
RCC_CECCLKSOURCE_HSI: HSI
selected as CEC clock
RCC_CECCLKSOURCE_LSE: LSE
selected as CEC clock
Description:
Return value:
__HAL_RCC_MCO_CONFIG
RCC_CECCLKSOURCE_HSI: HSI
selected as CEC clock
RCC_CECCLKSOURCE_LSE: LSE
selected as CEC clock
Description:
DocID026525 Rev 1
401/692
UM1785
Parameters:
__HAL_RCC_USART2_CONFIG
RCC_MCOSOURCE_HSE: HSE
selected as MCO clock
RCC_MCOSOURCE_PLLCLK_NODIV:
PLLCLK 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
RCC_MCOSOURCE_HSI14: HSI14
selected as MCO clock
RCC_MCOSOURCE_HSI48: HSI48
selected as MCO clock
__MCODiv__: specifies the MCO clock
prescaler. This parameter can be one of the
following values:
Description:
Parameters:
402/692
RCC_USART2CLKSOURCE_PCLK1:
PCLK1 selected as USART2 clock
RCC_USART2CLKSOURCE_HSI: HSI
DocID026525 Rev 1
UM1785
__HAL_RCC_GET_USART2_SOUR
CE
Description:
Return value:
__HAL_RCC_USART3_CONFIG
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:
Parameters:
__HAL_RCC_GET_USART3_SOUR
CE
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:
Return value:
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
403/692
404/692
DocID026525 Rev 1
UM1785
UM1785
32
32.1
32.1.1
RTC_InitTypeDef
RTC_InitTypeDef is defined in the stm32f0xx_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
32.1.2
RTC_TimeTypeDef
RTC_TimeTypeDef is defined in the stm32f0xx_hal_rtc.h
Data Fields
uint8_t Hours
uint8_t Minutes
uint8_t Seconds
uint32_t SubSeconds
uint8_t TimeFormat
uint32_t DayLightSaving
uint32_t StoreOperation
Field Documentation
DocID026525 Rev 1
405/692
32.1.3
UM1785
RTC_DateTypeDef
RTC_DateTypeDef is defined in the stm32f0xx_hal_rtc.h
Data Fields
uint8_t WeekDay
uint8_t Month
uint8_t Date
uint8_t Year
Field Documentation
32.1.4
RTC_AlarmTypeDef
RTC_AlarmTypeDef is defined in the stm32f0xx_hal_rtc.h
Data Fields
406/692
RTC_TimeTypeDef AlarmTime
uint32_t AlarmMask
uint32_t AlarmSubSecondMask
uint32_t AlarmDateWeekDaySel
uint8_t AlarmDateWeekDay
uint32_t Alarm
DocID026525 Rev 1
UM1785
32.1.5
RTC_HandleTypeDef
RTC_HandleTypeDef is defined in the stm32f0xx_hal_rtc.h
Data Fields
RTC_TypeDef * Instance
RTC_InitTypeDef Init
HAL_LockTypeDef Lock
__IO HAL_RTCStateTypeDef State
Field Documentation
32.2
32.2.1
407/692
UM1785
When the backup domain is supplied by VDD (analog switch connected to VDD), the
following functions are available:
1.
2.
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.
32.2.2
32.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.
32.2.4
Enable the Power Controller (PWR) APB1 interface clock using the
__PWR_CLK_ENABLE() function.
Enable access to RTC domain using the HAL_PWR_EnableBkUpAccess() function.
Select the RTC clock source using the __HAL_RCC_RTC_CONFIG() function.
Enable RTC Clock using the __HAL_RCC_RTC_ENABLE() function.
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.
408/692
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.
DocID026525 Rev 1
UM1785
Alarm configuration
32.2.5
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.
32.2.6
2.
3.
4.
32.2.7
The RTC Prescaler is programmed to generate the RTC 1Hz time base. It is split into
2 programmable prescalers to minimize power consumption.
DocID026525 Rev 1
409/692
32.2.8
UM1785
HAL_RTC_SetTime()
HAL_RTC_GetTime()
HAL_RTC_SetDate()
HAL_RTC_GetDate()
32.2.9
HAL_RTC_SetAlarm()
HAL_RTC_SetAlarm_IT()
HAL_RTC_DeactivateAlarm()
HAL_RTC_GetAlarm()
HAL_RTC_AlarmIRQHandler()
HAL_RTC_AlarmAEventCallback()
HAL_RTC_PollForAlarmAEvent()
32.2.10
32.2.11
410/692
HAL_RTC_Init
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
UM1785
32.2.12
32.2.13
32.2.14
HAL_RTC_DeInit
Function Name
Function Description
Parameters
Return values
HAL status
Notes
HAL_RTC_MspInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_RTC_MspDeInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
411/692
32.2.15
32.2.16
32.2.17
412/692
UM1785
HAL_RTC_SetTime
Function Name
HAL_StatusTypeDef HAL_RTC_SetTime (
RTC_HandleTypeDef * hrtc, RTC_TimeTypeDef * sTime,
uint32_t Format)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_RTC_GetTime
Function Name
HAL_StatusTypeDef HAL_RTC_GetTime (
RTC_HandleTypeDef * hrtc, RTC_TimeTypeDef * sTime,
uint32_t Format)
Function Description
Parameters
Return values
HAL status
Notes
HAL_RTC_SetDate
DocID026525 Rev 1
UM1785
32.2.18
32.2.19
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_RTC_GetDate
Function Name
HAL_StatusTypeDef HAL_RTC_GetDate (
RTC_HandleTypeDef * hrtc, RTC_DateTypeDef * sDate,
uint32_t Format)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_RTC_SetAlarm
Function Name
HAL_StatusTypeDef HAL_RTC_SetAlarm (
RTC_HandleTypeDef * hrtc, RTC_AlarmTypeDef * sAlarm,
uint32_t Format)
Function Description
Parameters
413/692
32.2.20
UM1785
Return values
HAL status
Notes
None.
HAL_RTC_SetAlarm_IT
Function Name
HAL_StatusTypeDef HAL_RTC_SetAlarm_IT (
RTC_HandleTypeDef * hrtc, RTC_AlarmTypeDef * sAlarm,
uint32_t Format)
Function Description
Parameters
Return values
HAL status
Notes
32.2.21
414/692
HAL_RTC_DeactivateAlarm
Function Name
HAL_StatusTypeDef HAL_RTC_DeactivateAlarm (
RTC_HandleTypeDef * hrtc, uint32_t Alarm)
Function Description
Parameters
ALARM_A AlarmA
DocID026525 Rev 1
UM1785
32.2.22
HAL status
Notes
None.
HAL_RTC_GetAlarm
Function Name
HAL_StatusTypeDef HAL_RTC_GetAlarm (
RTC_HandleTypeDef * hrtc, RTC_AlarmTypeDef * sAlarm,
uint32_t Alarm, uint32_t Format)
Function Description
Parameters
32.2.23
ALARM_A AlarmA
Format : Specifies the format of the entered parameters.
This parameter can be one of the following values:
Return values
HAL status
Notes
None.
HAL_RTC_AlarmIRQHandler
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
415/692
32.2.24
32.2.25
32.2.26
UM1785
HAL_RTC_AlarmAEventCallback
Function Name
Function Description
Alarm A callback.
Parameters
Return values
None.
Notes
None.
HAL_RTC_PollForAlarmAEvent
Function Name
HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent (
RTC_HandleTypeDef * hrtc, uint32_t Timeout)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_RTC_WaitForSynchro
Function Name
HAL_StatusTypeDef HAL_RTC_WaitForSynchro (
RTC_HandleTypeDef * hrtc)
Function Description
Waits until the RTC Time and Date registers (RTC_TR and
RTC_DR) are synchronized with RTC APB clock.
Parameters
Return values
HAL status
Notes
416/692
DocID026525 Rev 1
UM1785
32.2.27
HAL_RTC_GetState
Function Name
HAL_RTCStateTypeDef HAL_RTC_GetState (
RTC_HandleTypeDef * hrtc)
Function Description
Parameters
Return values
HAL state
Notes
None.
32.3
32.3.1
RTC
RTC
RTC AlarmDateWeekDay Definitions
RTC_ALARMDATEWEEKDAYSEL_DATE
RTC_ALARMDATEWEEKDAYSEL_WEEKDAY
IS_RTC_ALARM_DATE_WEEKDAY_SEL
RTC AlarmMask Definitions
RTC_ALARMMASK_NONE
RTC_ALARMMASK_DATEWEEKDAY
RTC_ALARMMASK_HOURS
RTC_ALARMMASK_MINUTES
RTC_ALARMMASK_SECONDS
RTC_ALARMMASK_ALL
IS_ALARM_MASK
RTC Alarms Definitions
DocID026525 Rev 1
417/692
UM1785
IS_ALARM
RTC Alarm Definitions
IS_RTC_ALARM_DATE_WEEKDAY_DATE
IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY
RTC Alarm Sub Seconds Masks Definitions
RTC_ALARMSUBSECONDMASK_ALL
RTC_ALARMSUBSECONDMASK_SS14_1
RTC_ALARMSUBSECONDMASK_SS14_2
RTC_ALARMSUBSECONDMASK_SS14_3
RTC_ALARMSUBSECONDMASK_SS14_4
RTC_ALARMSUBSECONDMASK_SS14_5
RTC_ALARMSUBSECONDMASK_SS14_6
RTC_ALARMSUBSECONDMASK_SS14_7
RTC_ALARMSUBSECONDMASK_SS14_8
RTC_ALARMSUBSECONDMASK_SS14_9
RTC_ALARMSUBSECONDMASK_SS14_10
RTC_ALARMSUBSECONDMASK_SS14_11
RTC_ALARMSUBSECONDMASK_SS14_12
RTC_ALARMSUBSECONDMASK_SS14_13
RTC_ALARMSUBSECONDMASK_SS14
RTC_ALARMSUBSECONDMASK_None
IS_RTC_ALARM_SUB_SECOND_MASK
RTC Alarm Sub Seconds Value
IS_RTC_ALARM_SUB_SECOND_VALUE
RTC AM PM Definitions
418/692
DocID026525 Rev 1
UM1785
Description:
Parameters:
Return value:
__HAL_RTC_WRITEPROTECTION_
DISABLE
None:
Description:
Parameters:
Return value:
__HAL_RTC_WRITEPROTECTION_
ENABLE
None:
Description:
Parameters:
Return value:
__HAL_RTC_ALARMA_ENABLE
None:
Description:
Parameters:
Return value:
None:
DocID026525 Rev 1
419/692
UM1785
Description:
Parameters:
Return value:
__HAL_RTC_ALARM_ENABLE_IT
None:
Description:
Parameters:
Return value:
__HAL_RTC_ALARM_DISABLE_IT
None:
Description:
Parameters:
Return value:
__HAL_RTC_ALARM_GET_IT
None:
Description:
Parameters:
Return value:
__HAL_RTC_ALARM_GET_FLAG
Description:
420/692
None:
DocID026525 Rev 1
UM1785
RTC_FLAG_ALRAF
RTC_FLAG_ALRAWF
Return value:
__HAL_RTC_ALARM_CLEAR_FLAG
None:
Description:
Parameters:
RTC_FLAG_ALRAF
Return value:
None:
RTC_EXTI_LINE_ALARM_EVENT
RTC_EXTI_LINE_TAMPER_TIMEST
AMP_EVENT
RTC_EXTI_LINE_WAKEUPTIMER_E
VENT
__HAL_RTC_EXTI_ENABLE_IT
Description:
Parameters:
RTC_EXTI_LINE_ALARM_EVENT
RTC_EXTI_LINE_TAMPER_TIMESTA
MP_EVENT
RTC_EXTI_LINE_WAKEUPTIMER_EV
ENT
Return value:
None:
__HAL_RTC_ENABLE_IT
__HAL_RTC_EXTI_DISABLE_IT
Description:
Parameters:
DocID026525 Rev 1
421/692
UM1785
RTC_EXTI_LINE_ALARM_EVENT
RTC_EXTI_LINE_TAMPER_TIMESTA
MP_EVENT
RTC_EXTI_LINE_WAKEUPTIMER_EV
ENT
Return value:
None:
__HAL_RTC_DISABLE_IT
__HAL_RTC_EXTI_GENERATE_SWI
T
Description:
Parameters:
RTC_EXTI_LINE_ALARM_EVENT
RTC_EXTI_LINE_TAMPER_TIMESTA
MP_EVENT
RTC_EXTI_LINE_WAKEUPTIMER_EV
ENT
Return value:
__HAL_RTC_EXTI_CLEAR_FLAG
None:
Description:
Parameters:
RTC_EXTI_LINE_ALARM_EVENT
RTC_EXTI_LINE_TAMPER_TIMESTA
MP_EVENT
RTC_EXTI_LINE_WAKEUPTIMER_EV
ENT
Return value:
None:
__HAL_RTC_CLEAR_FLAG
RTC Flags Definitions
RTC_FLAG_RECALPF
RTC_FLAG_TAMP3F
RTC_FLAG_TAMP2F
422/692
DocID026525 Rev 1
UM1785
DocID026525 Rev 1
423/692
UM1785
RTC_MONTH_APRIL
RTC_MONTH_MAY
RTC_MONTH_JUNE
RTC_MONTH_JULY
RTC_MONTH_AUGUST
RTC_MONTH_SEPTEMBER
RTC_MONTH_OCTOBER
RTC_MONTH_NOVEMBER
RTC_MONTH_DECEMBER
IS_RTC_MONTH
IS_RTC_DATE
RTC Output Polarity Definitions
RTC_OUTPUT_POLARITY_HIGH
RTC_OUTPUT_POLARITY_LOW
IS_RTC_OUTPUT_POL
RTC Output Type ALARM OUT
RTC_OUTPUT_TYPE_OPENDRAIN
RTC_OUTPUT_TYPE_PUSHPULL
IS_RTC_OUTPUT_TYPE
RTC StoreOperation Definitions
RTC_STOREOPERATION_RESET
RTC_STOREOPERATION_SET
IS_RTC_STORE_OPERATION
RTC Synchronous Predivider
IS_RTC_SYNCH_PREDIV
RTC Time Definitions
IS_RTC_HOUR12
IS_RTC_HOUR24
IS_RTC_MINUTES
IS_RTC_SECONDS
RTC WeekDay Definitions
RTC_WEEKDAY_MONDAY
RTC_WEEKDAY_TUESDAY
RTC_WEEKDAY_WEDNESDAY
RTC_WEEKDAY_THURSDAY
424/692
DocID026525 Rev 1
UM1785
DocID026525 Rev 1
425/692
UM1785
33
33.1
33.1.1
RTC_TamperTypeDef
RTC_TamperTypeDef is defined in the stm32f0xx_hal_rtc_ex.h
Data Fields
uint32_t Tamper
uint32_t Trigger
uint32_t Filter
uint32_t SamplingFrequency
uint32_t PrechargeDuration
uint32_t TamperPullUp
uint32_t TimeStampOnTamperDetection
Field Documentation
33.2
33.2.1
426/692
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.
DocID026525 Rev 1
UM1785
TimeStamp configuration
Configure the RTC_AF trigger and enables the RTC TimeStamp using the
HAL_RTCEx_SetTimeStamp() function. You can also configure the RTC TimeStamp
with interrupt mode using the HAL_RTCEx_SetTimeStamp_IT() function.
To read the RTC TimeStamp Time and Date register, use the
HAL_RTCEx_GetTimeStamp() function.
Tamper configuration
Enable the RTC Tamper and Configure the Tamper filter count, trigger Edge or Level
according to the Tamper filter (if equal to 0 Edge else Level) value, sampling
frequency, precharge or discharge and Pull-UP using the HAL_RTCEx_SetTamper()
function. You can configure RTC Tamper with interrupt mode using
HAL_RTCEx_SetTamper_IT() function.
33.2.2
HAL_RTCEx_SetTimeStamp()
HAL_RTCEx_SetTimeStamp_IT()
HAL_RTCEx_DeactivateTimeStamp()
HAL_RTCEx_GetTimeStamp()
HAL_RTCEx_SetTamper()
HAL_RTCEx_SetTamper_IT()
HAL_RTCEx_DeactivateTamper()
HAL_RTCEx_TamperTimeStampIRQHandler()
HAL_RTCEx_TimeStampEventCallback()
HAL_RTCEx_Tamper1EventCallback()
HAL_RTCEx_Tamper2EventCallback()
HAL_RTCEx_Tamper3EventCallback()
HAL_RTCEx_PollForTimeStampEvent()
HAL_RTCEx_PollForTamper1Event()
HAL_RTCEx_PollForTamper2Event()
HAL_RTCEx_PollForTamper3Event()
DocID026525 Rev 1
427/692
33.2.3
UM1785
33.2.4
HAL_RTCEx_SetWakeUpTimer()
HAL_RTCEx_SetWakeUpTimer_IT()
HAL_RTCEx_DeactivateWakeUpTimer()
HAL_RTCEx_GetWakeUpTimer()
HAL_RTCEx_WakeUpTimerIRQHandler()
HAL_RTCEx_WakeUpTimerEventCallback()
HAL_RTCEx_PollForWakeUpTimerEvent()
33.2.5
428/692
HAL_RTCEx_SetTimeStamp
Function Name
HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp (
RTC_HandleTypeDef * hrtc, uint32_t TimeStampEdge,
uint32_t RTC_TimeStampPin)
Function Description
Sets TimeStamp.
Parameters
UM1785
33.2.6
Return values
HAL status
Notes
HAL_RTCEx_SetTimeStamp_IT
Function Name
HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT (
RTC_HandleTypeDef * hrtc, uint32_t TimeStampEdge,
uint32_t RTC_TimeStampPin)
Function Description
Parameters
Parameters
33.2.7
Return values
HAL status
Notes
HAL_RTCEx_DeactivateTimeStamp
DocID026525 Rev 1
429/692
33.2.8
33.2.9
430/692
UM1785
HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp (
RTC_HandleTypeDef * hrtc)
Function Description
Deactivates TimeStamp.
Parameters
Return values
HAL status
Notes
None.
HAL_RTCEx_GetTimeStamp
Function Name
HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp (
RTC_HandleTypeDef * hrtc, RTC_TimeTypeDef *
sTimeStamp, RTC_DateTypeDef * sTimeStampDate, uint32_t
Format)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_RTCEx_SetTamper
Function Name
HAL_StatusTypeDef HAL_RTCEx_SetTamper (
RTC_HandleTypeDef * hrtc, RTC_TamperTypeDef * sTamper)
Function Description
Sets Tamper.
Parameters
Return values
HAL status
Notes
DocID026525 Rev 1
UM1785
33.2.10
33.2.11
33.2.12
HAL_RTCEx_SetTamper_IT
Function Name
HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT (
RTC_HandleTypeDef * hrtc, RTC_TamperTypeDef * sTamper)
Function Description
Parameters
Return values
HAL status
Notes
HAL_RTCEx_DeactivateTamper
Function Name
HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper (
RTC_HandleTypeDef * hrtc, uint32_t Tamper)
Function Description
Deactivates Tamper.
Parameters
Return values
HAL status
Notes
None.
HAL_RTCEx_TamperTimeStampIRQHandler
Function Name
void HAL_RTCEx_TamperTimeStampIRQHandler (
RTC_HandleTypeDef * hrtc)
DocID026525 Rev 1
431/692
33.2.13
33.2.14
33.2.15
Parameters
Return values
None.
Notes
None.
HAL_RTCEx_TimeStampEventCallback
Function Name
void HAL_RTCEx_TimeStampEventCallback (
RTC_HandleTypeDef * hrtc)
Function Description
TimeStamp callback.
Parameters
Return values
None.
Notes
None.
HAL_RTCEx_Tamper1EventCallback
Function Name
void HAL_RTCEx_Tamper1EventCallback (
RTC_HandleTypeDef * hrtc)
Function Description
Tamper 1 callback.
Parameters
Return values
None.
Notes
None.
HAL_RTCEx_Tamper2EventCallback
Function Name
432/692
UM1785
This function handles TimeStamp interrupt request.
void HAL_RTCEx_Tamper2EventCallback (
RTC_HandleTypeDef * hrtc)
DocID026525 Rev 1
UM1785
33.2.16
33.2.17
33.2.18
Tamper 2 callback.
Parameters
Return values
None.
Notes
None.
HAL_RTCEx_Tamper3EventCallback
Function Name
void HAL_RTCEx_Tamper3EventCallback (
RTC_HandleTypeDef * hrtc)
Function Description
Tamper 3 callback.
Parameters
Return values
None.
Notes
None.
HAL_RTCEx_PollForTimeStampEvent
Function Name
HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent (
RTC_HandleTypeDef * hrtc, uint32_t Timeout)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_RTCEx_PollForTamper1Event
Function Name
HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event (
DocID026525 Rev 1
433/692
UM1785
RTC_HandleTypeDef * hrtc, uint32_t Timeout)
33.2.19
33.2.20
33.2.21
434/692
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_RTCEx_PollForTamper2Event
Function Name
HAL_StatusTypeDef HAL_RTCEx_PollForTamper2Event (
RTC_HandleTypeDef * hrtc, uint32_t Timeout)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_RTCEx_PollForTamper3Event
Function Name
HAL_StatusTypeDef HAL_RTCEx_PollForTamper3Event (
RTC_HandleTypeDef * hrtc, uint32_t Timeout)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_RTCEx_SetWakeUpTimer
DocID026525 Rev 1
UM1785
33.2.22
33.2.23
HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer (
RTC_HandleTypeDef * hrtc, uint32_t WakeUpCounter,
uint32_t WakeUpClock)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_RTCEx_SetWakeUpTimer_IT
Function Name
HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT (
RTC_HandleTypeDef * hrtc, uint32_t WakeUpCounter,
uint32_t WakeUpClock)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_RTCEx_DeactivateWakeUpTimer
Function Name
uint32_t HAL_RTCEx_DeactivateWakeUpTimer (
RTC_HandleTypeDef * hrtc)
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
435/692
33.2.24
33.2.25
33.2.26
436/692
UM1785
HAL_RTCEx_GetWakeUpTimer
Function Name
uint32_t HAL_RTCEx_GetWakeUpTimer (
RTC_HandleTypeDef * hrtc)
Function Description
Parameters
Return values
Counter value
Notes
None.
HAL_RTCEx_WakeUpTimerIRQHandler
Function Name
void HAL_RTCEx_WakeUpTimerIRQHandler (
RTC_HandleTypeDef * hrtc)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_RTCEx_WakeUpTimerEventCallback
Function Name
void HAL_RTCEx_WakeUpTimerEventCallback (
RTC_HandleTypeDef * hrtc)
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
UM1785
33.2.27
33.2.28
HAL_RTCEx_PollForWakeUpTimerEvent
Function Name
HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent
( RTC_HandleTypeDef * hrtc, uint32_t Timeout)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_RTCEx_BKUPWrite
Function Name
Function Description
Parameters
33.2.29
Return values
None.
Notes
None.
HAL_RTCEx_BKUPRead
Function Name
Function Description
Parameters
437/692
33.2.30
UM1785
parameter can be: RTC_BKP_DRx where x can be from 0 to
4 to specify the register.
Return values
Read value
Notes
None.
HAL_RTCEx_SetSmoothCalib
Function Name
HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib (
RTC_HandleTypeDef * hrtc, uint32_t SmoothCalibPeriod,
uint32_t SmoothCalibPlusPulses, uint32_t
SmouthCalibMinusPulsesValue)
Function Description
Parameters
33.2.31
438/692
RTC_SMOOTHCALIB_PLUSPULSES_RESET No
RTCCLK pulses are added.
SmouthCalibMinusPulsesValue : Select the value of
CALM[8:0] bits. This parameter can be one any value from 0
to 0x000001FF.
Return values
HAL status
Notes
HAL_RTCEx_SetSynchroShift
DocID026525 Rev 1
UM1785
Function Name
Function Description
Parameters
33.2.32
33.2.33
RTC_SHIFTADD1S_RESET No effect.
ShiftSubFS : Select the number of Second Fractions to
substitute. This parameter can be one any value from 0 to
0x7FFF.
Return values
HAL status
Notes
HAL_RTCEx_SetCalibrationOutPut
Function Name
HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut (
RTC_HandleTypeDef * hrtc, uint32_t CalibOutput)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_RTCEx_DeactivateCalibrationOutPut
Function Name
HAL_StatusTypeDef
DocID026525 Rev 1
439/692
UM1785
HAL_RTCEx_DeactivateCalibrationOutPut (
RTC_HandleTypeDef * hrtc)
33.2.34
33.2.35
33.2.36
440/692
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_RTCEx_SetRefClock
Function Name
HAL_StatusTypeDef HAL_RTCEx_SetRefClock (
RTC_HandleTypeDef * hrtc)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_RTCEx_DeactivateRefClock
Function Name
HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock (
RTC_HandleTypeDef * hrtc)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_RTCEx_EnableBypassShadow
DocID026525 Rev 1
UM1785
33.2.37
Function Name
Function Description
Parameters
Return values
HAL status
Notes
HAL_RTCEx_DisableBypassShadow
Function Name
HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow (
RTC_HandleTypeDef * hrtc)
Function Description
Parameters
Return values
HAL status
Notes
33.3
33.3.1
RTCEx
RTCEx
RTCEx Add 1 Second Parameter Definition
RTC_SHIFTADD1S_RESET
RTC_SHIFTADD1S_SET
IS_RTC_SHIFT_ADD1S
RTCEx Backup Registers Definition
RTC_BKP_DR0
RTC_BKP_DR1
RTC_BKP_DR2
RTC_BKP_DR3
RTC_BKP_DR4
DocID026525 Rev 1
441/692
UM1785
Description:
Parameters:
Return value:
__HAL_RTC_TIMESTAMP_ENABLE
None:
Description:
Parameters:
Return value:
__HAL_RTC_WAKEUPTIMER_DISABLE
None:
Description:
Parameters:
Return value:
__HAL_RTC_TIMESTAMP_DISABLE
None:
Description:
Parameters:
Return value:
__HAL_RTC_CALIBRATION_OUTPUT_ENABLE
442/692
DocID026525 Rev 1
None:
Description:
UM1785
Parameters:
Return value:
__HAL_RTC_CALIBRATION_OUTPUT_DISABLE
None:
Description:
Parameters:
Return value:
__HAL_RTC_CLOCKREF_DETECTION_ENABLE
None:
Description:
Parameters:
Return value:
__HAL_RTC_CLOCKREF_DETECTION_DISABLE
None:
Description:
Parameters:
Return value:
__HAL_RTC_TIMESTAMP_ENABLE_IT
None:
Description:
Parameters:
DocID026525 Rev 1
UM1785
RTC_IT_TS: TimeStamp
interrupt
Return value:
__HAL_RTC_WAKEUPTIMER_ENABLE_IT
None:
Description:
Parameters:
RTC_IT_WUT:
WakeUpTimer A interrupt
Return value:
__HAL_RTC_TIMESTAMP_DISABLE_IT
None:
Description:
Parameters:
RTC_IT_TS: TimeStamp
interrupt
Return value:
__HAL_RTC_WAKEUPTIMER_DISABLE_IT
None:
Description:
Parameters:
444/692
DocID026525 Rev 1
UM1785
RTC_IT_WUT:
WakeUpTimer A interrupt
Return value:
__HAL_RTC_TAMPER_GET_IT
None:
Description:
Parameters:
RTC_IT_TAMP1
Return value:
__HAL_RTC_WAKEUPTIMER_GET_IT
None:
Description:
Parameters:
RTC_IT_WUT:
WakeUpTimer A interrupt
Return value:
__HAL_RTC_TIMESTAMP_GET_IT
None:
Description:
Parameters:
DocID026525 Rev 1
RTC_IT_TS: TimeStamp
445/692
UM1785
interrupt
Return value:
__HAL_RTC_TIMESTAMP_GET_FLAG
None:
Description:
Parameters:
RTC_FLAG_TSF
RTC_FLAG_TSOVF
Return value:
__HAL_RTC_WAKEUPTIMER_GET_FLAG
None:
Description:
Parameters:
RTC_FLAG_WUTF
RTC_FLAG_WUTWF
Return value:
__HAL_RTC_TAMPER_GET_FLAG
None:
Description:
Parameters:
RTC_FLAG_TAMP1F
Return value:
446/692
DocID026525 Rev 1
None:
UM1785
__HAL_RTC_SHIFT_GET_FLAG
Parameters:
RTC_FLAG_SHPF
Return value:
__HAL_RTC_TIMESTAMP_CLEAR_FLAG
None:
Description:
Parameters:
RTC_FLAG_TSF
Return value:
__HAL_RTC_TAMPER_CLEAR_FLAG
None:
Description:
Parameters:
RTC_FLAG_TAMP1F
Return value:
__HAL_RTC_WAKEUPTIMER_CLEAR_FLAG
None:
Description:
Parameters:
DocID026525 Rev 1
UM1785
RTC_FLAG_WUTF
Return value:
None:
RTC_SMOOTHCALIB_PERIOD_16SEC
RTC_SMOOTHCALIB_PERIOD_8SEC
IS_RTC_SMOOTH_CALIB_PERIOD
RTCEx Smooth calib Plus pulses Definition
RTC_SMOOTHCALIB_PLUSPULSES_SET
RTC_SMOOTHCALIB_PLUSPULSES_RESET
IS_RTC_SMOOTH_CALIB_PLUS
RTCEx Substract Fraction Of Second Value
IS_RTC_SHIFT_SUBFS
RTCEx Tamper Filter Definition
448/692
RTC_TAMPERFILTER_DISABLE
RTC_TAMPERFILTER_2SAMPLE
RTC_TAMPERFILTER_4SAMPLE
RTC_TAMPERFILTER_8SAMPLE
DocID026525 Rev 1
UM1785
RTC_TAMPERPRECHARGEDURATION_2RTCCLK
RTC_TAMPERPRECHARGEDURATION_4RTCCLK
RTC_TAMPERPRECHARGEDURATION_8RTCCLK
IS_TAMPER_PRECHARGE_DURATION
RTCEx Tamper Pull UP Definition
RTC_TAMPER_PULLUP_ENABLE
RTC_TAMPER_PULLUP_DISABLE
IS_TAMPER_PULLUP_STATE
RTCEx Tamper Sampling Frequencies Definition
RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV32768
RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV16384
RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV8192
RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV4096
RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV2048
RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV1024
DocID026525 Rev 1
449/692
RTC_TAMPERSAMPLINGFREQ_RTCCLK_DIV256
UM1785
Each of the tamper inputs are
sampled with a frequency =
RTCCLK / 512
Each of the tamper inputs are
sampled with a frequency =
RTCCLK / 256
IS_TAMPER_SAMPLING_FREQ
RTCEx Tamper TimeStampOnTamperDetection Definition
RTC_TIMESTAMPONTAMPERDETECTION_ENABLE
TimeStamp on Tamper
Detection event saved
RTC_TIMESTAMPONTAMPERDETECTION_DISABLE
TimeStamp on Tamper
Detection event is not saved
IS_TAMPER_TIMESTAMPONTAMPER_DETECTION
RTCEx Tamper Trigger Definition
RTC_TAMPERTRIGGER_RISINGEDGE
RTC_TAMPERTRIGGER_FALLINGEDGE
RTC_TAMPERTRIGGER_LOWLEVEL
RTC_TAMPERTRIGGER_HIGHLEVEL
IS_TAMPER_TRIGGER
RTCEx TimeStamp Pin Selection
RTC_TIMESTAMPPIN_PC13
IS_RTC_TIMESTAMP_PIN
RTCEx Time Stamp Edges definition
RTC_TIMESTAMPEDGE_RISING
RTC_TIMESTAMPEDGE_FALLING
IS_TIMESTAMP_EDGE
RTCEx Wakeup Timer Definition
RTC_WAKEUPCLOCK_RTCCLK_DIV16
RTC_WAKEUPCLOCK_RTCCLK_DIV8
RTC_WAKEUPCLOCK_RTCCLK_DIV4
RTC_WAKEUPCLOCK_RTCCLK_DIV2
RTC_WAKEUPCLOCK_CK_SPRE_16BITS
RTC_WAKEUPCLOCK_CK_SPRE_17BITS
IS_WAKEUP_CLOCK
IS_WAKEUP_COUNTER
450/692
DocID026525 Rev 1
UM1785
34
34.1
34.1.1
SMARTCARD_InitTypeDef
SMARTCARD_InitTypeDef is defined in the stm32f0xx_hal_smartcard.h
Data Fields
uint32_t BaudRate
uint32_t WordLength
uint32_t StopBits
uint16_t Parity
uint16_t Mode
uint16_t CLKPolarity
uint16_t CLKPhase
uint16_t CLKLastBit
uint16_t OneBitSampling
uint8_t Prescaler
uint8_t GuardTime
uint16_t NACKEnable
uint32_t TimeOutEnable
uint32_t TimeOutValue
uint8_t BlockLength
uint8_t AutoRetryCount
Field Documentation
451/692
34.1.2
UM1785
SMARTCARD_AdvFeatureInitTypeDef
SMARTCARD_AdvFeatureInitTypeDef is defined in the stm32f0xx_hal_smartcard.h
Data Fields
uint32_t AdvFeatureInit
uint32_t TxPinLevelInvert
uint32_t RxPinLevelInvert
uint32_t DataInvert
uint32_t Swap
uint32_t OverrunDisable
uint32_t DMADisableonRxError
uint32_t MSBFirst
Field Documentation
452/692
DocID026525 Rev 1
UM1785
34.1.3
SMARTCARD_HandleTypeDef
SMARTCARD_HandleTypeDef is defined in the stm32f0xx_hal_smartcard.h
Data Fields
USART_TypeDef * Instance
SMARTCARD_InitTypeDef Init
SMARTCARD_AdvFeatureInitTypeDef AdvancedInit
uint8_t * pTxBuffPtr
uint16_t TxXferSize
uint16_t TxXferCount
uint8_t * pRxBuffPtr
uint16_t RxXferSize
uint16_t RxXferCount
DMA_HandleTypeDef * hdmatx
DMA_HandleTypeDef * hdmarx
HAL_LockTypeDef Lock
HAL_SMARTCARD_StateTypeDef State
HAL_SMARTCARD_ErrorTypeDef ErrorCode
Field Documentation
USART_TypeDef* SMARTCARD_HandleTypeDef::Instance
SMARTCARD_InitTypeDef SMARTCARD_HandleTypeDef::Init
SMARTCARD_AdvFeatureInitTypeDef
SMARTCARD_HandleTypeDef::AdvancedInit
uint8_t* SMARTCARD_HandleTypeDef::pTxBuffPtr
uint16_t SMARTCARD_HandleTypeDef::TxXferSize
uint16_t SMARTCARD_HandleTypeDef::TxXferCount
uint8_t* SMARTCARD_HandleTypeDef::pRxBuffPtr
uint16_t SMARTCARD_HandleTypeDef::RxXferSize
uint16_t SMARTCARD_HandleTypeDef::RxXferCount
DMA_HandleTypeDef* SMARTCARD_HandleTypeDef::hdmatx
DMA_HandleTypeDef* SMARTCARD_HandleTypeDef::hdmarx
HAL_LockTypeDef SMARTCARD_HandleTypeDef::Lock
HAL_SMARTCARD_StateTypeDef SMARTCARD_HandleTypeDef::State
HAL_SMARTCARD_ErrorTypeDef SMARTCARD_HandleTypeDef::ErrorCode
DocID026525 Rev 1
453/692
34.2
UM1785
34.2.1
3.
4.
5.
6.
Configure the declared DMA handle structure with the required Tx/Rx
parameters.
Configure the priority and enable the NVIC for the transfer complete
interrupt on the DMA Tx/Rx channel.
Program the Baud Rate, Parity, Mode(Receiver/Transmitter), clock enabling/disabling
and accordingly, the clock parameters (parity, phase, last bit), prescaler value, guard
time and NACK on transmission error enabling or disabling in the hsmartcard Init
structure.
If required, program SMARTCARD advanced features (TX/RX pins swap, TimeOut,
auto-retry counter,...) in the hsmartcard AdvancedInit structure.
Initialize the SMARTCARD associated USART registers by calling the
HAL_SMARTCARD_Init() API:
This API configures also the low level Hardware GPIO, CLOCK, CORTEX...etc)
by calling the customed HAL_SMARTCARD_MspInit() API. The specific
SMARTCARD interrupts (Transmission complete interrupt, RXNE interrupt and
Error Interrupts) will be managed using the macros
__HAL_SMARTCARD_ENABLE_IT() and __HAL_SMARTCARD_DISABLE_IT()
inside the transmit and receive process.
Three operation modes are available within this driver :
454/692
DocID026525 Rev 1
UM1785
34.2.2
DocID026525 Rev 1
455/692
Baud Rate
Parity: parity should be enabled, Frame Length is fixed to 8 bits plus parity: the
USART frame format is given in the tables below.
Receiver/transmitter modes
Synchronous mode (and if enabled, phase, polarity and last bit parameters)
Prescaler value
Block length
Auto-retry counter
Table 21: USART frame formats
M bit
PCE bit
USART frame
or
M1, M0 bits
PCE bit
USART frame
01
34.2.3
HAL_SMARTCARD_Init()
HAL_SMARTCARD_DeInit()
HAL_SMARTCARD_MspInit()
HAL_SMARTCARD_MspDeInit()
IO operation functions
This subsection provides a set of functions allowing to manage the SMARTCARD data
transfers.
456/692
DocID026525 Rev 1
UM1785
2.
3.
4.
5.
34.2.4
HAL_SMARTCARD_Transmit()
HAL_SMARTCARD_Receive()
Non Blocking mode API s with Interrupt are :
HAL_SMARTCARD_Transmit_IT()
HAL_SMARTCARD_Receive_IT()
HAL_SMARTCARD_IRQHandler()
Non Blocking mode functions with DMA are :
HAL_SMARTCARD_Transmit_DMA()
HAL_SMARTCARD_Receive_DMA()
A set of Transfer Complete Callbacks are provided in non Blocking mode:
HAL_SMARTCARD_TxCpltCallback()
HAL_SMARTCARD_RxCpltCallback()
HAL_SMARTCARD_ErrorCallback()
HAL_SMARTCARD_Transmit()
HAL_SMARTCARD_Receive()
HAL_SMARTCARD_Transmit_IT()
HAL_SMARTCARD_Receive_IT()
HAL_SMARTCARD_Transmit_DMA()
HAL_SMARTCARD_Receive_DMA()
HAL_SMARTCARD_IRQHandler()
HAL_SMARTCARD_TxCpltCallback()
HAL_SMARTCARD_RxCpltCallback()
HAL_SMARTCARD_ErrorCallback()
457/692
34.2.5
34.2.6
34.2.7
458/692
UM1785
HAL_SMARTCARD_Init
Function Name
HAL_StatusTypeDef HAL_SMARTCARD_Init (
SMARTCARD_HandleTypeDef * hsmartcard)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_SMARTCARD_DeInit
Function Name
HAL_StatusTypeDef HAL_SMARTCARD_DeInit (
SMARTCARD_HandleTypeDef * hsmartcard)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_SMARTCARD_MspInit
Function Name
void HAL_SMARTCARD_MspInit (
SMARTCARD_HandleTypeDef * hsmartcard)
Function Description
DocID026525 Rev 1
UM1785
34.2.8
34.2.9
34.2.10
Return values
None.
Notes
None.
HAL_SMARTCARD_MspDeInit
Function Name
void HAL_SMARTCARD_MspDeInit (
SMARTCARD_HandleTypeDef * hsmartcard)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SMARTCARD_Transmit
Function Name
HAL_StatusTypeDef HAL_SMARTCARD_Transmit (
SMARTCARD_HandleTypeDef * hsmartcard, uint8_t * pData,
uint16_t Size, uint32_t Timeout)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_SMARTCARD_Receive
DocID026525 Rev 1
459/692
34.2.11
34.2.12
460/692
UM1785
HAL_StatusTypeDef HAL_SMARTCARD_Receive (
SMARTCARD_HandleTypeDef * hsmartcard, uint8_t * pData,
uint16_t Size, uint32_t Timeout)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_SMARTCARD_Transmit_IT
Function Name
HAL_StatusTypeDef HAL_SMARTCARD_Transmit_IT (
SMARTCARD_HandleTypeDef * hsmartcard, uint8_t * pData,
uint16_t Size)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_SMARTCARD_Receive_IT
Function Name
HAL_StatusTypeDef HAL_SMARTCARD_Receive_IT (
SMARTCARD_HandleTypeDef * hsmartcard, uint8_t * pData,
uint16_t Size)
Function Description
Parameters
Return values
HAL status
DocID026525 Rev 1
UM1785
34.2.13
34.2.14
34.2.15
None.
HAL_SMARTCARD_Transmit_DMA
Function Name
HAL_StatusTypeDef HAL_SMARTCARD_Transmit_DMA (
SMARTCARD_HandleTypeDef * hsmartcard, uint8_t * pData,
uint16_t Size)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_SMARTCARD_Receive_DMA
Function Name
HAL_StatusTypeDef HAL_SMARTCARD_Receive_DMA (
SMARTCARD_HandleTypeDef * hsmartcard, uint8_t * pData,
uint16_t Size)
Function Description
Parameters
Return values
HAL status
Notes
HAL_SMARTCARD_IRQHandler
DocID026525 Rev 1
461/692
34.2.16
34.2.17
34.2.18
462/692
UM1785
void HAL_SMARTCARD_IRQHandler (
SMARTCARD_HandleTypeDef * hsmartcard)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SMARTCARD_TxCpltCallback
Function Name
void HAL_SMARTCARD_TxCpltCallback (
SMARTCARD_HandleTypeDef * hsmartcard)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SMARTCARD_RxCpltCallback
Function Name
void HAL_SMARTCARD_RxCpltCallback (
SMARTCARD_HandleTypeDef * hsmartcard)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SMARTCARD_ErrorCallback
DocID026525 Rev 1
UM1785
34.2.19
34.2.20
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SMARTCARD_GetState
Function Name
HAL_SMARTCARD_StateTypeDef
HAL_SMARTCARD_GetState ( SMARTCARD_HandleTypeDef *
hsmartcard)
Function Description
Parameters
Return values
HAL state
Notes
None.
HAL_SMARTCARD_GetError
Function Name
uint32_t HAL_SMARTCARD_GetError (
SMARTCARD_HandleTypeDef * hsmartcard)
Function Description
Parameters
Return values
Notes
None.
DocID026525 Rev 1
463/692
UM1785
34.3
34.3.1
SMARTCARD
SMARTCARD
SMARTCARD advanced feature initialization type
SMARTCARD_ADVFEATURE_NO_INIT
SMARTCARD_ADVFEATURE_TXINVERT_INIT
SMARTCARD_ADVFEATURE_RXINVERT_INIT
SMARTCARD_ADVFEATURE_DATAINVERT_INIT
SMARTCARD_ADVFEATURE_SWAP_INIT
SMARTCARD_ADVFEATURE_RXOVERRUNDISABLE_INIT
SMARTCARD_ADVFEATURE_DMADISABLEONERROR_INIT
SMARTCARD_ADVFEATURE_MSBFIRST_INIT
IS_SMARTCARD_ADVFEATURE_INIT
SMARTCARD Clock Phase
SMARTCARD_PHASE_1EDGE
SMARTCARD_PHASE_2EDGE
IS_SMARTCARD_PHASE
SMARTCARD Clock Polarity
SMARTCARD_POLARITY_LOW
SMARTCARD_POLARITY_HIGH
IS_SMARTCARD_POLARITY
SMARTCARD auto retry counter LSB position in CR3 register
SMARTCARD_CR3_SCARCNT_LSB_POS
SMARTCARD advanced feature Binary Data inversion
SMARTCARD_ADVFEATURE_DATAINV_DISABLE
SMARTCARD_ADVFEATURE_DATAINV_ENABLE
IS_SMARTCARD_ADVFEATURE_DATAINV
SMARTCARD advanced feature DMA Disable on Rx Error
SMARTCARD_ADVFEATURE_DMA_ENABLEONRXERROR
SMARTCARD_ADVFEATURE_DMA_DISABLEONRXERROR
IS_SMARTCARD_ADVFEATURE_DMAONRXERROR
SMARTCARD Exported Macros
__HAL_SMARTCARD_RESET_HANDL
E_STATE
Description:
Parameters:
464/692
DocID026525 Rev 1
UM1785
__HAL_SMARTCARD_GET_FLAG
None:
Description:
Parameters:
SMARTCARD_FLAG_REACK:
Receive enable ackowledge flag
SMARTCARD_FLAG_TEACK:
Transmit enable ackowledge flag
SMARTCARD_FLAG_BUSY: Busy
flag
SMARTCARD_FLAG_EOBF: End of
block flag
SMARTCARD_FLAG_RTOF:
Receiver timeout flag
SMARTCARD_FLAG_TXE: Transmit
data register empty flag
SMARTCARD_FLAG_TC:
Transmission Complete flag
SMARTCARD_FLAG_RXNE: Receive
data register not empty flag
SMARTCARD_FLAG_ORE: OverRun
Error flag
SMARTCARD_FLAG_FE: Framing
Error flag
Return value:
__HAL_SMARTCARD_ENABLE_IT
Description:
Parameters:
DocID026525 Rev 1
465/692
UM1785
parameter can be one of the following
values:
SMARTCARD_IT_EOBF: End Of
Block interrupt
SMARTCARD_IT_RTOF: Receive
TimeOut interrupt
SMARTCARD_IT_TC: Transmission
complete interrupt
SMARTCARD_IT_RXNE: Receive
Data register not empty interrupt
SMARTCARD_IT_ERR: Error
interrupt(Frame error, noise error,
overrun error)
Return value:
__HAL_SMARTCARD_DISABLE_IT
None:
Description:
Parameters:
SMARTCARD_IT_EOBF: End Of
Block interrupt
SMARTCARD_IT_RTOF: Receive
TimeOut interrupt
SMARTCARD_IT_TC: Transmission
complete interrupt
SMARTCARD_IT_RXNE: Receive
Data register not empty interrupt
SMARTCARD_IT_ERR: Error
interrupt(Frame error, noise error,
overrun error)
Return value:
__HAL_SMARTCARD_GET_IT
Description:
466/692
None:
DocID026525 Rev 1
UM1785
SMARTCARD_IT_EOBF: End Of
Block interrupt
SMARTCARD_IT_RTOF: Receive
TimeOut interrupt
SMARTCARD_IT_TC: Transmission
complete interrupt
SMARTCARD_IT_RXNE: Receive
Data register not empty interrupt
SMARTCARD_IT_ORE: OverRun
Error interrupt
Return value:
__HAL_SMARTCARD_GET_IT_SOUR
CE
Description:
Parameters:
SMARTCARD_IT_EOBF: End Of
Block interrupt
SMARTCARD_IT_RTOF: Receive
TimeOut interrupt
SMARTCARD_IT_TC: Transmission
complete interrupt
SMARTCARD_IT_RXNE: Receive
DocID026525 Rev 1
467/692
UM1785
Data register not empty interrupt
SMARTCARD_IT_ORE: OverRun
Error interrupt
SMARTCARD_IT_NE: Noise Error
interrupt
SMARTCARD_IT_FE: Framing Error
interrupt
SMARTCARD_IT_PE: Parity Error
interrupt
Return value:
__HAL_SMARTCARD_CLEAR_IT
Description:
Parameters:
USART_CLEAR_OREF: OverRun
Error Clear Flag
USART_CLEAR_TCF: Transmission
Complete Clear Flag
USART_CLEAR_RTOF: Receiver
Time Out Clear Flag
Return value:
__HAL_SMARTCARD_SEND_REQ
None:
Description:
Parameters:
468/692
DocID026525 Rev 1
UM1785
SMARTCARD_RXDATA_FLUSH_RE
QUEST: Receive Data flush Request
SMARTCARD_TXDATA_FLUSH_RE
QUEST: Transmit data flush Request
Return value:
__HAL_SMARTCARD_ENABLE
None:
Description:
Parameters:
Return value:
__HAL_SMARTCARD_DISABLE
None:
Description:
Parameters:
Return value:
IS_SMARTCARD_BAUDRATE
None:
Description:
Parameters:
Return value:
IS_SMARTCARD_BLOCKLENGTH
Description:
Parameters:
Return value:
DocID026525 Rev 1
469/692
UM1785
IS_SMARTCARD_TIMEOUT_VALUE
Description:
Parameters:
Return value:
IS_SMARTCARD_AUTORETRY_COU
NT
Description:
Parameters:
Return value:
Description:
Parameters:
Return value:
SMARTCARD Flags
SMARTCARD_FLAG_REACK
SMARTCARD_FLAG_TEACK
SMARTCARD_FLAG_BUSY
SMARTCARD_FLAG_EOBF
SMARTCARD_FLAG_RTOF
SMARTCARD_FLAG_TXE
SMARTCARD_FLAG_TC
SMARTCARD_FLAG_RXNE
SMARTCARD_FLAG_ORE
SMARTCARD_FLAG_NE
470/692
DocID026525 Rev 1
UM1785
SMARTCARD_CLEAR_FEF
SMARTCARD_CLEAR_NEF
SMARTCARD_CLEAR_OREF
SMARTCARD_CLEAR_TCF
SMARTCARD_CLEAR_RTOF
SMARTCARD_CLEAR_EOBF
DocID026525 Rev 1
471/692
SMARTCARD_TXDATA_FLUSH_REQUEST
IS_SMARTCARD_REQUEST_PARAMETER
SMARTCARD block length LSB position in RTOR register
SMARTCARD_RTOR_BLEN_LSB_POS
SMARTCARD advanced feature RX pin active level inversion
SMARTCARD_ADVFEATURE_RXINV_DISABLE
SMARTCARD_ADVFEATURE_RXINV_ENABLE
IS_SMARTCARD_ADVFEATURE_RXINV
SMARTCARD advanced feature RX TX pins swap
472/692
DocID026525 Rev 1
UM1785
UM1785
DocID026525 Rev 1
473/692
UM1785
35
35.1
35.1.1
35.1.2
35.1.3
HAL_SMARTCARDEx_BlockLength_Config
Function Name
void HAL_SMARTCARDEx_BlockLength_Config (
SMARTCARD_HandleTypeDef * hsmartcard, uint8_t
BlockLength)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SMARTCARDEx_TimeOut_Config
Function Name
474/692
void HAL_SMARTCARDEx_TimeOut_Config (
SMARTCARD_HandleTypeDef * hsmartcard, uint32_t
DocID026525 Rev 1
UM1785
35.1.4
35.1.5
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SMARTCARDEx_EnableReceiverTimeOut
Function Name
HAL_StatusTypeDef
HAL_SMARTCARDEx_EnableReceiverTimeOut (
SMARTCARD_HandleTypeDef * hsmartcard)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_SMARTCARDEx_DisableReceiverTimeOut
Function Name
HAL_StatusTypeDef
HAL_SMARTCARDEx_DisableReceiverTimeOut (
SMARTCARD_HandleTypeDef * hsmartcard)
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
475/692
UM1785
35.2
35.2.1
SMARTCARDEx
SMARTCARDEx
476/692
DocID026525 Rev 1
UM1785
36
36.1
36.1.1
SMBUS_InitTypeDef
SMBUS_InitTypeDef is defined in the stm32f0xx_hal_smbus.h
Data Fields
uint32_t Timing
uint32_t AnalogFilter
uint32_t OwnAddress1
uint32_t AddressingMode
uint32_t DualAddressMode
uint32_t OwnAddress2
uint32_t OwnAddress2Masks
uint32_t GeneralCallMode
uint32_t NoStretchMode
uint32_t PacketErrorCheckMode
uint32_t PeripheralMode
uint32_t SMBusTimeout
Field Documentation
DocID026525 Rev 1
477/692
36.1.2
UM1785
SMBUS_HandleTypeDef
SMBUS_HandleTypeDef is defined in the stm32f0xx_hal_smbus.h
Data Fields
I2C_TypeDef * Instance
SMBUS_InitTypeDef Init
uint8_t * pBuffPtr
uint16_t XferSize
__IO uint16_t XferCount
__IO uint32_t XferOptions
__IO HAL_SMBUS_StateTypeDef PreviousState
HAL_LockTypeDef Lock
__IO HAL_SMBUS_StateTypeDef State
__IO HAL_SMBUS_ErrorTypeDef ErrorCode
Field Documentation
36.2
36.2.1
478/692
UM1785
36.2.2
Call the function HAL_SMBUS_Init() to configure the selected device with the
selected configuration:
Clock Timing
Bus Timeout
Own Address 1
Own Address 2
Nostretch mode
Peripheral mode
Call the function HAL_SMBUS_DeInit() to restore the default configuration of the
selected SMBUSx periperal.
HAL_SMBUS_Init()
HAL_SMBUS_DeInit()
HAL_SMBUS_MspInit()
HAL_SMBUS_MspDeInit()
IO operation functions
This subsection provides a set of functions allowing to manage the SMBUS data transfers.
1.
2.
3.
4.
HAL_SMBUS_IsDeviceReady()
There is only one mode of transfer:
HAL_SMBUS_Master_Transmit_IT()
HAL_SMBUS_Master_Receive_IT()
HAL_SMBUS_Slave_Transmit_IT()
HAL_SMBUS_Slave_Receive_IT()
HAL_SMBUS_DisableListen_IT()
HAL_SMBUS_EnableAlert_IT()
HAL_SMBUS_DisableAlert_IT()
A set of Transfer Complete Callbacks are provided in No_Blocking mode:
HAL_SMBUS_MasterTxCpltCallback()
HAL_SMBUS_MasterRxCpltCallback()
HAL_SMBUS_SlaveTxCpltCallback()
HAL_SMBUS_SlaveRxCpltCallback()
HAL_SMBUS_SlaveListenCpltCallback() or alias
HAL_SMBUS_ListenCpltCallback()
HAL_SMBUS_ErrorCallback()
HAL_SMBUS_Master_Transmit_IT()
HAL_SMBUS_Master_Receive_IT()
HAL_SMBUS_Master_Abort_IT()
HAL_SMBUS_Slave_Transmit_IT()
DocID026525 Rev 1
479/692
36.2.3
UM1785
HAL_SMBUS_Slave_Receive_IT()
HAL_SMBUS_Slave_Listen_IT()
HAL_SMBUS_DisableListen_IT()
HAL_SMBUS_EnableAlert_IT()
HAL_SMBUS_DisableAlert_IT()
HAL_SMBUS_IsDeviceReady()
HAL_SMBUS_EV_IRQHandler()
HAL_SMBUS_ER_IRQHandler()
HAL_SMBUS_MasterTxCpltCallback()
HAL_SMBUS_MasterRxCpltCallback()
HAL_SMBUS_SlaveTxCpltCallback()
HAL_SMBUS_SlaveRxCpltCallback()
HAL_SMBUS_SlaveAddrCallback()
HAL_SMBUS_SlaveListenCpltCallback()
HAL_SMBUS_ErrorCallback()
36.2.4
36.2.5
480/692
HAL_SMBUS_GetState()
HAL_SMBUS_GetError()
HAL_SMBUS_Init
Function Name
HAL_StatusTypeDef HAL_SMBUS_Init (
SMBUS_HandleTypeDef * hsmbus)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_SMBUS_DeInit
Function Name
HAL_StatusTypeDef HAL_SMBUS_DeInit (
SMBUS_HandleTypeDef * hsmbus)
Function Description
DocID026525 Rev 1
UM1785
36.2.6
36.2.7
36.2.8
Return values
HAL status
Notes
None.
HAL_SMBUS_MspInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SMBUS_MspDeInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SMBUS_Master_Transmit_IT
DocID026525 Rev 1
481/692
UM1785
Function Name
HAL_StatusTypeDef HAL_SMBUS_Master_Transmit_IT (
SMBUS_HandleTypeDef * hsmbus, uint16_t DevAddress,
uint8_t * pData, uint16_t Size, uint32_t XferOptions)
Function Description
Transmit in master/host SMBUS mode an amount of data in noblocking mode with Interrupt.
Parameters
36.2.9
Return values
HAL status
Notes
None.
HAL_SMBUS_Master_Receive_IT
Function Name
HAL_StatusTypeDef HAL_SMBUS_Master_Receive_IT (
SMBUS_HandleTypeDef * hsmbus, uint16_t DevAddress,
uint8_t * pData, uint16_t Size, uint32_t XferOptions)
Function Description
Receive in master/host SMBUS mode an amount of data in noblocking mode with Interrupt.
Parameters
36.2.10
482/692
Return values
HAL status
Notes
None.
HAL_SMBUS_Master_Abort_IT
DocID026525 Rev 1
UM1785
36.2.11
HAL_StatusTypeDef HAL_SMBUS_Master_Abort_IT (
SMBUS_HandleTypeDef * hsmbus, uint16_t DevAddress)
Function Description
Parameters
Return values
HAL status
Notes
HAL_SMBUS_Slave_Transmit_IT
Function Name
HAL_StatusTypeDef HAL_SMBUS_Slave_Transmit_IT (
SMBUS_HandleTypeDef * hsmbus, uint8_t * pData, uint16_t
Size, uint32_t XferOptions)
Function Description
Transmit in slave/device SMBUS mode an amount of data in noblocking mode with Interrupt.
Parameters
36.2.12
Return values
HAL status
Notes
None.
HAL_SMBUS_Slave_Receive_IT
Function Name
HAL_StatusTypeDef HAL_SMBUS_Slave_Receive_IT (
SMBUS_HandleTypeDef * hsmbus, uint8_t * pData, uint16_t
Size, uint32_t XferOptions)
Function Description
483/692
UM1785
blocking mode with Interrupt.
Parameters
36.2.13
36.2.14
484/692
Return values
HAL status
Notes
None.
HAL_SMBUS_Slave_Listen_IT
Function Name
HAL_StatusTypeDef HAL_SMBUS_Slave_Listen_IT (
SMBUS_HandleTypeDef * hsmbus)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_SMBUS_DisableListen_IT
Function Name
HAL_StatusTypeDef HAL_SMBUS_DisableListen_IT (
SMBUS_HandleTypeDef * hsmbus)
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
UM1785
36.2.15
36.2.16
36.2.17
HAL_SMBUS_EnableAlert_IT
Function Name
HAL_StatusTypeDef HAL_SMBUS_EnableAlert_IT (
SMBUS_HandleTypeDef * hsmbus)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_SMBUS_DisableAlert_IT
Function Name
HAL_StatusTypeDef HAL_SMBUS_DisableAlert_IT (
SMBUS_HandleTypeDef * hsmbus)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_SMBUS_IsDeviceReady
Function Name
HAL_StatusTypeDef HAL_SMBUS_IsDeviceReady (
SMBUS_HandleTypeDef * hsmbus, uint16_t DevAddress,
uint32_t Trials, uint32_t Timeout)
Function Description
Parameters
485/692
36.2.18
36.2.19
36.2.20
486/692
UM1785
Return values
HAL status
Notes
HAL_SMBUS_EV_IRQHandler
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SMBUS_ER_IRQHandler
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SMBUS_MasterTxCpltCallback
DocID026525 Rev 1
UM1785
36.2.21
36.2.22
void HAL_SMBUS_MasterTxCpltCallback (
SMBUS_HandleTypeDef * hsmbus)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SMBUS_MasterRxCpltCallback
Function Name
void HAL_SMBUS_MasterRxCpltCallback (
SMBUS_HandleTypeDef * hsmbus)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SMBUS_SlaveTxCpltCallback
Function Name
void HAL_SMBUS_SlaveTxCpltCallback (
SMBUS_HandleTypeDef * hsmbus)
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
487/692
36.2.23
36.2.24
UM1785
HAL_SMBUS_SlaveRxCpltCallback
Function Name
void HAL_SMBUS_SlaveRxCpltCallback (
SMBUS_HandleTypeDef * hsmbus)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SMBUS_SlaveAddrCallback
Function Name
void HAL_SMBUS_SlaveAddrCallback (
SMBUS_HandleTypeDef * hsmbus, uint8_t TransferDirection,
uint16_t AddrMatchCode)
Function Description
Parameters
Return values
None.
Notes
None.
36.2.25
488/692
HAL_SMBUS_SlaveListenCpltCallback
Function Name
void HAL_SMBUS_SlaveListenCpltCallback (
SMBUS_HandleTypeDef * hsmbus)
Function Description
UM1785
36.2.26
36.2.27
36.2.28
Return values
None.
Notes
None.
HAL_SMBUS_ErrorCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SMBUS_GetState
Function Name
HAL_SMBUS_StateTypeDef HAL_SMBUS_GetState (
SMBUS_HandleTypeDef * hsmbus)
Function Description
Parameters
Return values
HAL state
Notes
None.
HAL_SMBUS_GetError
DocID026525 Rev 1
489/692
UM1785
uint32_t HAL_SMBUS_GetError ( SMBUS_HandleTypeDef *
hsmbus)
Function Description
Parameters
Return values
Notes
None.
36.3
36.3.1
SMBUS
SMBUS
SMBUS addressing mode
SMBUS_ADDRESSINGMODE_7BIT
SMBUS_ADDRESSINGMODE_10BIT
IS_SMBUS_ADDRESSING_MODE
SMBUS Analog Filter
SMBUS_ANALOGFILTER_ENABLED
SMBUS_ANALOGFILTER_DISABLED
IS_SMBUS_ANALOG_FILTER
SMBUS dual addressing mode
SMBUS_DUALADDRESS_DISABLED
SMBUS_DUALADDRESS_ENABLED
IS_SMBUS_DUAL_ADDRESS
Input and Output operation functions
HAL_SMBUS_EnableListen_IT
HAL_SMBUS_AddrCallback
HAL_SMBUS_ListenCpltCallback
SMBUS Exported Macros
__HAL_SMBUS_RESET_HANDLE_STATE
Description:
Parameters:
Return value:
490/692
DocID026525 Rev 1
UM1785
__HAL_SMBUS_ENABLE_IT
None:
Description:
Parameters:
SMBUS_IT_TCI: Transfer
complete interrupt enable
SMBUS_IT_STOPI: STOP
detection interrupt enable
SMBUS_IT_NACKI: NACK
received interrupt enable
SMBUS_IT_ADDRI: Address
match interrupt enable
SMBUS_IT_RXI: RX interrupt
enable
SMBUS_IT_TXI: TX interrupt
enable
Return value:
None:
__HAL_SMBUS_DISABLE_IT
__HAL_SMBUS_GET_IT_SOURCE
Description:
Parameters:
DocID026525 Rev 1
SMBUS_IT_TCI: Transfer
complete interrupt enable
SMBUS_IT_STOPI: STOP
detection interrupt enable
SMBUS_IT_NACKI: NACK
491/692
UM1785
received interrupt enable
SMBUS_IT_ADDRI: Address
match interrupt enable
SMBUS_IT_RXI: RX interrupt
enable
SMBUS_IT_TXI: TX interrupt
enable
Return value:
SMBUS_FLAG_MASK
Description:
Parameters:
492/692
DocID026525 Rev 1
SMBUS_FLAG_TXE: Transmit
data register empty
SMBUS_FLAG_TXIS: Transmit
interrupt status
SMBUS_FLAG_RXNE: Receive
data register not empty
SMBUS_FLAG_ADDR: Address
matched (slave mode)
SMBUS_FLAG_AF: NACK
received flag
SMBUS_FLAG_STOPF: STOP
detection flag
SMBUS_FLAG_TC: Transfer
complete (master mode)
SMBUS_FLAG_TCR: Transfer
complete reload
SMBUS_FLAG_ARLO: Arbitration
lost
SMBUS_FLAG_OVR:
Overrun/Underrun
SMBUS_FLAG_PECERR: PEC
error in reception
SMBUS_FLAG_TIMEOUT:
Timeout or Tlow detection flag
SMBUS_FLAG_ALERT: SMBus
alert
SMBUS_FLAG_DIR: Transfer
direction (slave mode)
UM1785
__HAL_SMBUS_GET_FLAG
__HAL_SMBUS_CLEAR_FLAG
Description:
Parameters:
SMBUS_FLAG_ADDR: Address
matched (slave mode)
SMBUS_FLAG_AF: NACK
received flag
SMBUS_FLAG_STOPF: STOP
detection flag
SMBUS_FLAG_ARLO: Arbitration
lost
SMBUS_FLAG_OVR:
Overrun/Underrun
SMBUS_FLAG_PECERR: PEC
error in reception
SMBUS_FLAG_TIMEOUT:
Timeout or Tlow detection flag
SMBUS_FLAG_ALERT: SMBus
alert
Return value:
None:
__HAL_SMBUS_ENABLE
__HAL_SMBUS_DISABLE
__HAL_SMBUS_RESET_CR1
__HAL_SMBUS_RESET_CR2
__HAL_SMBUS_GENERATE_START
__HAL_SMBUS_GET_ADDR_MATCH
__HAL_SMBUS_GET_DIR
__HAL_SMBUS_GET_STOP_MODE
__HAL_SMBUS_GET_PEC_MODE
__HAL_SMBUS_GET_ALERT_ENABLED
DocID026525 Rev 1
493/692
DocID026525 Rev 1
UM1785
UM1785
495/692
UM1785
SMBUS_RELOAD_MODE
SMBUS_AUTOEND_MODE
SMBUS_SENDPEC_MODE
IS_SMBUS_TRANSFER_MODE
SMBUS StartStopMode definition
SMBUS_NO_STARTSTOP
SMBUS_GENERATE_STOP
SMBUS_GENERATE_START_READ
SMBUS_GENERATE_START_WRITE
IS_SMBUS_TRANSFER_REQUEST
SMBUS XferOptions definition
SMBUS_FIRST_FRAME
SMBUS_NEXT_FRAME
SMBUS_FIRST_AND_LAST_FRAME_NO_PEC
SMBUS_LAST_FRAME_NO_PEC
SMBUS_FIRST_AND_LAST_FRAME_WITH_PEC
SMBUS_LAST_FRAME_WITH_PEC
IS_SMBUS_TRANSFER_OPTIONS_REQUEST
496/692
DocID026525 Rev 1
UM1785
37
37.1
37.1.1
SPI_InitTypeDef
SPI_InitTypeDef is defined in the stm32f0xx_hal_spi.h
Data Fields
uint32_t Mode
uint32_t Direction
uint32_t DataSize
uint32_t CLKPolarity
uint32_t CLKPhase
uint32_t NSS
uint32_t BaudRatePrescaler
uint32_t FirstBit
uint32_t TIMode
uint32_t CRCCalculation
uint32_t CRCPolynomial
uint32_t CRCLength
uint32_t NSSPMode
Field Documentation
DocID026525 Rev 1
497/692
37.1.2
UM1785
__SPI_HandleTypeDef
__SPI_HandleTypeDef is defined in the stm32f0xx_hal_spi.h
Data Fields
SPI_TypeDef * Instance
SPI_InitTypeDef Init
uint8_t * pTxBuffPtr
uint16_t TxXferSize
uint16_t TxXferCount
uint8_t * pRxBuffPtr
uint16_t RxXferSize
uint16_t RxXferCount
uint32_t CRCSize
void(* RxISR
void(* TxISR
DMA_HandleTypeDef * hdmatx
DMA_HandleTypeDef * hdmarx
HAL_LockTypeDef Lock
HAL_SPI_StateTypeDef State
HAL_SPI_ErrorTypeDef ErrorCode
Field Documentation
498/692
SPI_TypeDef* __SPI_HandleTypeDef::Instance
SPI_InitTypeDef __SPI_HandleTypeDef::Init
uint8_t* __SPI_HandleTypeDef::pTxBuffPtr
uint16_t __SPI_HandleTypeDef::TxXferSize
uint16_t __SPI_HandleTypeDef::TxXferCount
uint8_t* __SPI_HandleTypeDef::pRxBuffPtr
uint16_t __SPI_HandleTypeDef::RxXferSize
uint16_t __SPI_HandleTypeDef::RxXferCount
uint32_t __SPI_HandleTypeDef::CRCSize
void(* __SPI_HandleTypeDef::RxISR)(struct __SPI_HandleTypeDef *hspi)
void(* __SPI_HandleTypeDef::TxISR)(struct __SPI_HandleTypeDef *hspi)
DMA_HandleTypeDef* __SPI_HandleTypeDef::hdmatx
DMA_HandleTypeDef* __SPI_HandleTypeDef::hdmarx
HAL_LockTypeDef __SPI_HandleTypeDef::Lock
HAL_SPI_StateTypeDef __SPI_HandleTypeDef::State
HAL_SPI_ErrorTypeDef __SPI_HandleTypeDef::ErrorCode
DocID026525 Rev 1
UM1785
37.2
37.2.1
3.
4.
Configure the priority and enable the NVIC for the transfer complete
interrupt on the DMA Tx or Rx channel
Program the Mode, BidirectionalMode , Data size, Baudrate Prescaler, NSS
management, Clock polarity and phase, FirstBit and CRC configuration in the hspi Init
structure.
Initialize the SPI registers by calling the HAL_SPI_Init() API:
These APIs configures also the low level Hardware GPIO, CLOCK,
CORTEX...etc) by calling the customed HAL_SPI_MspInit(&hspi) API.
Using the HAL it is not possible to reach all supported SPI frequency with the differents
SPI Modes, the following table resume the max SPI frequency reached with 8- or 16-bit
data size:
Table 22: Maximum SPI frequency vs data size
Process
Tx/Rx
Rx
Tx
Transfer mode
2 lines, fullduplex
1 line, Rx only
1 line
Polling
fCPU/32
fCPU/32
NA
NA
NA
NA
Interrupt
fCPU/32
fCPU/32
NA
NA
NA
NA
DMA
fCPU/32
fCPU/16
NA
NA
NA
NA
Polling
fCPU/32
fCPU/16
fCPU/16
fCPU/16
fCPU/16
fCPU/16
Interrupt
fCPU/16
fCPU/16
fCPU/16
fCPU/16
fCPU/16
fCPU/16
DMA
fCPU/4
fCPU/8
fCPU/4
fCPU/4
fCPU/8
fCPU/16
Polling
fCPU/16
fCPU/16
NA
NA
fCPU/16
fCPU/16
Interrupt
fCPU/32
fCPU/16
NA
NA
fCPU/16
fCPU/16
DMA
fCPU/2
fCPU/16
NA
NA
fCPU/8
fCPU/16
DocID026525 Rev 1
499/692
UM1785
@note The max SPI frequency depend on SPI data size (4bits, 5bits,..., 8bits,...15bits,
16bits), SPI mode(2 Lines fullduplex, 2 lines RxOnly, 1 line TX/RX) and Process mode
(Polling, IT, DMA).
@note
1.
2.
3.
37.2.2
37.2.3
Mode
Direction
Data Size
NSS Management
BaudRate Prescaler
FirstBit
TIMode
CRC Calculation
IO operation functions
The SPI supports master and slave mode :
1.
500/692
UM1785
2.
3.
4.
5.
37.2.4
HAL_SPI_IRQHandler()
Non Blocking mode functions with DMA are :
HAL_SPI_TxCpltCallback()
HAL_SPI_RxCpltCallback()
HAL_SPI_ErrorCallback()
HAL_SPI_TxRxCpltCallback()
HAL_SPI_Transmit()
HAL_SPI_Receive()
HAL_SPI_TransmitReceive()
HAL_SPI_Transmit_IT()
HAL_SPI_Receive_IT()
HAL_SPI_TransmitReceive_IT()
HAL_SPI_Transmit_DMA()
HAL_SPI_Receive_DMA()
HAL_SPI_TransmitReceive_DMA()
HAL_SPI_DMAPause()
HAL_SPI_DMAResume()
HAL_SPI_DMAStop()
HAL_SPI_IRQHandler()
HAL_SPI_FlushRxFifo()
HAL_SPI_TxCpltCallback()
HAL_SPI_RxCpltCallback()
HAL_SPI_TxRxCpltCallback()
HAL_SPI_TxHalfCpltCallback()
HAL_SPI_RxHalfCpltCallback()
HAL_SPI_TxRxHalfCpltCallback()
HAL_SPI_ErrorCallback()
HAL_SPI_GetState() API can be helpful to check in run-time the state of the SPI
peripheral.
HAL_SPI_GetError() check in run-time Errors occurring during communication
DocID026525 Rev 1
501/692
37.2.5
37.2.6
37.2.7
502/692
UM1785
HAL_SPI_GetState()
HAL_SPI_GetError()
HAL_SPI_Init
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_SPI_DeInit
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_SPI_MspInit
Function Name
Function Description
Parameters
Return values
None.
DocID026525 Rev 1
UM1785
37.2.8
37.2.9
None.
HAL_SPI_MspDeInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SPI_InitExtended
Function Name
HAL_StatusTypeDef HAL_SPI_InitExtended (
SPI_HandleTypeDef * hspi)
Function Description
Notes
37.2.10
None.
HAL_SPI_Transmit
Function Name
Function Description
Parameters
DocID026525 Rev 1
503/692
37.2.11
37.2.12
504/692
UM1785
HAL status
None.
HAL_SPI_Receive
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_SPI_TransmitReceive
Function Name
HAL_StatusTypeDef HAL_SPI_TransmitReceive (
SPI_HandleTypeDef * hspi, uint8_t * pTxData, uint8_t *
pRxData, uint16_t Size, uint32_t Timeout)
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
UM1785
37.2.13
37.2.14
37.2.15
HAL_SPI_Transmit_IT
Function Name
HAL_StatusTypeDef HAL_SPI_Transmit_IT (
SPI_HandleTypeDef * hspi, uint8_t * pData, uint16_t Size)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_SPI_Receive_IT
Function Name
HAL_StatusTypeDef HAL_SPI_Receive_IT (
SPI_HandleTypeDef * hspi, uint8_t * pData, uint16_t Size)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_SPI_TransmitReceive_IT
Function Name
HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT (
SPI_HandleTypeDef * hspi, uint8_t * pTxData, uint8_t *
pRxData, uint16_t Size)
Function Description
Parameters
505/692
37.2.16
37.2.17
506/692
UM1785
Return values
HAL status
Notes
None.
HAL_SPI_Transmit_DMA
Function Name
HAL_StatusTypeDef HAL_SPI_Transmit_DMA (
SPI_HandleTypeDef * hspi, uint8_t * pData, uint16_t Size)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_SPI_Receive_DMA
Function Name
HAL_StatusTypeDef HAL_SPI_Receive_DMA (
SPI_HandleTypeDef * hspi, uint8_t * pData, uint16_t Size)
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
UM1785
37.2.18
37.2.19
37.2.20
HAL_SPI_TransmitReceive_DMA
Function Name
HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA (
SPI_HandleTypeDef * hspi, uint8_t * pTxData, uint8_t *
pRxData, uint16_t Size)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_SPI_DMAPause
Function Name
HAL_StatusTypeDef HAL_SPI_DMAPause (
SPI_HandleTypeDef * hspi)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_SPI_DMAResume
Function Name
HAL_StatusTypeDef HAL_SPI_DMAResume (
SPI_HandleTypeDef * hspi)
Function Description
Parameters
507/692
UM1785
module.
37.2.21
37.2.22
37.2.23
Return values
HAL status
Notes
None.
HAL_SPI_DMAStop
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_SPI_IRQHandler
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SPI_FlushRxFifo
Function Name
508/692
HAL_StatusTypeDef HAL_SPI_FlushRxFifo (
DocID026525 Rev 1
UM1785
37.2.24
37.2.25
37.2.26
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_SPI_TxCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SPI_RxCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SPI_TxRxCpltCallback
DocID026525 Rev 1
509/692
37.2.27
37.2.28
37.2.29
510/692
UM1785
void HAL_SPI_TxRxCpltCallback ( SPI_HandleTypeDef * hspi)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SPI_TxHalfCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SPI_RxHalfCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SPI_TxRxHalfCpltCallback
DocID026525 Rev 1
UM1785
37.2.30
37.2.31
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SPI_ErrorCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_SPI_GetState
Function Name
HAL_SPI_StateTypeDef HAL_SPI_GetState (
SPI_HandleTypeDef * hspi)
Function Description
Parameters
Return values
SPI state
Notes
None.
DocID026525 Rev 1
511/692
37.2.32
UM1785
HAL_SPI_GetError
Function Name
HAL_SPI_ErrorTypeDef HAL_SPI_GetError (
SPI_HandleTypeDef * hspi)
Function Description
Parameters
Return values
Notes
None.
37.3
37.3.1
SPI
SPI
SPI BaudRate Prescaler
SPI_BAUDRATEPRESCALER_2
SPI_BAUDRATEPRESCALER_4
SPI_BAUDRATEPRESCALER_8
SPI_BAUDRATEPRESCALER_16
SPI_BAUDRATEPRESCALER_32
SPI_BAUDRATEPRESCALER_64
SPI_BAUDRATEPRESCALER_128
SPI_BAUDRATEPRESCALER_256
IS_SPI_BAUDRATE_PRESCALER
SPI Clock Phase
SPI_PHASE_1EDGE
SPI_PHASE_2EDGE
IS_SPI_CPHA
SPI Clock Polarity
SPI_POLARITY_LOW
SPI_POLARITY_HIGH
IS_SPI_CPOL
SPI CRC Calculation
SPI_CRCCALCULATION_DISABLED
512/692
DocID026525 Rev 1
UM1785
Description:
Parameters:
Return value:
None:
DocID026525 Rev 1
513/692
UM1785
Description:
Parameters:
Return value:
None:
__HAL_SPI_DISABLE_IT
__HAL_SPI_GET_IT_SOURCE
Description:
Parameters:
Return value:
__HAL_SPI_GET_FLAG
Description:
Parameters:
514/692
DocID026525 Rev 1
UM1785
Return value:
__HAL_SPI_CLEAR_CRCERRFLAG
Description:
Parameters:
Return value:
__HAL_SPI_CLEAR_MODFFLAG
None:
Description:
Parameters:
Return value:
__HAL_SPI_CLEAR_OVRFLAG
None:
Description:
Parameters:
Return value:
__HAL_SPI_CLEAR_FREFLAG
None:
Description:
DocID026525 Rev 1
515/692
UM1785
Parameters:
Return value:
__HAL_SPI_ENABLE
None:
Description:
Parameters:
Return value:
__HAL_SPI_DISABLE
None:
Description:
Parameters:
Return value:
__HAL_SPI_1LINE_TX
None:
Description:
Parameters:
Return value:
__HAL_SPI_1LINE_RX
None:
Description:
Parameters:
Return value:
__HAL_SPI_RESET_CRC
516/692
None:
Description:
DocID026525 Rev 1
UM1785
Parameters:
Return value:
None:
IS_SPI_CRC_POLYNOMIAL
SPI FIFO reception threshold
SPI_RXFIFO_THRESHOLD
SPI_RXFIFO_THRESHOLD_QF
SPI_RXFIFO_THRESHOLD_HF
SPI Flag definition
SPI_FLAG_RXNE
SPI_FLAG_TXE
SPI_FLAG_BSY
SPI_FLAG_CRCERR
SPI_FLAG_MODF
SPI_FLAG_OVR
SPI_FLAG_FRE
SPI_FLAG_FTLVL
SPI_FLAG_FRLVL
SPI Interrupt configuration definition
SPI_IT_TXE
SPI_IT_RXNE
SPI_IT_ERR
SPI mode
SPI_MODE_SLAVE
SPI_MODE_MASTER
IS_SPI_MODE
SPI MSB LSB transmission
SPI_FIRSTBIT_MSB
SPI_FIRSTBIT_LSB
IS_SPI_FIRST_BIT
SPI NSS pulse management
SPI_NSS_PULSE_ENABLED
SPI_NSS_PULSE_DISABLED
DocID026525 Rev 1
517/692
UM1785
518/692
DocID026525 Rev 1
UM1785
38
38.1
38.1.1
TIM_Base_InitTypeDef
TIM_Base_InitTypeDef is defined in the stm32f0xx_hal_tim.h
Data Fields
uint32_t Prescaler
uint32_t CounterMode
uint32_t Period
uint32_t ClockDivision
uint32_t RepetitionCounter
Field Documentation
38.1.2
the number of half PWM period in center-aligned mode This parameter must be a
number between Min_Data = 0x00 and Max_Data = 0xFF.
Note:This parameter is valid only for TIM1 and TIM8.
TIM_OC_InitTypeDef
TIM_OC_InitTypeDef is defined in the stm32f0xx_hal_tim.h
Data Fields
uint32_t OCMode
uint32_t Pulse
uint32_t OCPolarity
uint32_t OCNPolarity
uint32_t OCFastMode
uint32_t OCIdleState
uint32_t OCNIdleState
DocID026525 Rev 1
519/692
38.1.3
UM1785
TIM_OnePulse_InitTypeDef
TIM_OnePulse_InitTypeDef is defined in the stm32f0xx_hal_tim.h
Data Fields
uint32_t OCMode
uint32_t Pulse
uint32_t OCPolarity
uint32_t OCNPolarity
uint32_t OCIdleState
uint32_t OCNIdleState
uint32_t ICPolarity
uint32_t ICSelection
uint32_t ICFilter
Field Documentation
520/692
UM1785
38.1.4
TIM_IC_InitTypeDef
TIM_IC_InitTypeDef is defined in the stm32f0xx_hal_tim.h
Data Fields
uint32_t ICPolarity
uint32_t ICSelection
uint32_t ICPrescaler
uint32_t ICFilter
Field Documentation
38.1.5
TIM_Encoder_InitTypeDef
TIM_Encoder_InitTypeDef is defined in the stm32f0xx_hal_tim.h
Data Fields
uint32_t EncoderMode
uint32_t IC1Polarity
uint32_t IC1Selection
uint32_t IC1Prescaler
uint32_t IC1Filter
uint32_t IC2Polarity
uint32_t IC2Selection
uint32_t IC2Prescaler
uint32_t IC2Filter
Field Documentation
DocID026525 Rev 1
521/692
38.1.6
UM1785
TIM_ClockConfigTypeDef
TIM_ClockConfigTypeDef is defined in the stm32f0xx_hal_tim.h
Data Fields
uint32_t ClockSource
uint32_t ClockPolarity
uint32_t ClockPrescaler
uint32_t ClockFilter
Field Documentation
38.1.7
TIM_ClearInputConfigTypeDef
TIM_ClearInputConfigTypeDef is defined in the stm32f0xx_hal_tim.h
Data Fields
522/692
uint32_t ClearInputState
uint32_t ClearInputSource
uint32_t ClearInputPolarity
uint32_t ClearInputPrescaler
uint32_t ClearInputFilter
DocID026525 Rev 1
UM1785
38.1.8
TIM_SlaveConfigTypeDef
TIM_SlaveConfigTypeDef is defined in the stm32f0xx_hal_tim.h
Data Fields
uint32_t SlaveMode
uint32_t InputTrigger
uint32_t TriggerPolarity
uint32_t TriggerPrescaler
uint32_t TriggerFilter
Field Documentation
38.1.9
TIM_HandleTypeDef
TIM_HandleTypeDef is defined in the stm32f0xx_hal_tim.h
Data Fields
TIM_TypeDef * Instance
TIM_Base_InitTypeDef Init
HAL_TIM_ActiveChannel Channel
DMA_HandleTypeDef * hdma
HAL_LockTypeDef Lock
__IO HAL_TIM_StateTypeDef State
Field Documentation
DocID026525 Rev 1
523/692
38.2
UM1785
38.2.1
38.2.2
1.
2.
3.
4.
524/692
Input Capture
Output Compare
Initialize the TIM low level resources by implementing the following functions
depending from feature used :
Enable the clock for the TIM GPIOs using the following function:
__GPIOx_CLK_ENABLE();
DocID026525 Rev 1
UM1785
5.
6.
38.2.3
38.2.4
525/692
38.2.5
UM1785
38.2.6
526/692
UM1785
38.2.7
38.2.8
527/692
38.2.9
UM1785
HAL_TIM_Encoder_Start_IT()
HAL_TIM_Encoder_Stop_IT()
HAL_TIM_Encoder_Start_DMA()
HAL_TIM_Encoder_Stop_DMA()
38.2.10
HAL_TIM_IRQHandler()
38.2.11
Configure The Input Output channels for OC, PWM, IC or One Pulse mode.
Configure External Clock source.
Configure Complementary channels, break features and dead time.
Configure Master and the Slave synchronization.
Configure the DMA Burst Mode.
HAL_TIM_OC_ConfigChannel()
HAL_TIM_IC_ConfigChannel()
HAL_TIM_PWM_ConfigChannel()
HAL_TIM_OnePulse_ConfigChannel()
HAL_TIM_DMABurst_WriteStart()
HAL_TIM_DMABurst_WriteStop()
HAL_TIM_DMABurst_ReadStart()
HAL_TIM_DMABurst_ReadStop()
HAL_TIM_GenerateEvent()
HAL_TIM_ConfigOCrefClear()
HAL_TIM_ConfigClockSource()
HAL_TIM_ConfigTI1Input()
HAL_TIM_SlaveConfigSynchronization()
HAL_TIM_SlaveConfigSynchronization_IT()
HAL_TIM_ReadCapturedValue()
528/692
UM1785
38.2.12
38.2.13
38.2.14
38.2.15
HAL_TIM_Base_GetState()
HAL_TIM_OC_GetState()
HAL_TIM_PWM_GetState()
HAL_TIM_IC_GetState()
HAL_TIM_OnePulse_GetState()
HAL_TIM_Encoder_GetState()
HAL_TIM_Base_Init
Function Name
HAL_StatusTypeDef HAL_TIM_Base_Init (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_Base_DeInit
Function Name
HAL_StatusTypeDef HAL_TIM_Base_DeInit (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_Base_MspInit
DocID026525 Rev 1
529/692
38.2.16
38.2.17
38.2.18
Function Description
Parameters
Return values
None.
Notes
None.
HAL_TIM_Base_MspDeInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_TIM_Base_Start
Function Name
HAL_StatusTypeDef HAL_TIM_Base_Start (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_Base_Stop
Function Name
530/692
UM1785
void HAL_TIM_Base_MspInit ( TIM_HandleTypeDef * htim)
HAL_StatusTypeDef HAL_TIM_Base_Stop (
TIM_HandleTypeDef * htim)
DocID026525 Rev 1
UM1785
38.2.19
38.2.20
38.2.21
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_Base_Start_IT
Function Name
HAL_StatusTypeDef HAL_TIM_Base_Start_IT (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_Base_Stop_IT
Function Name
HAL_StatusTypeDef HAL_TIM_Base_Stop_IT (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_Base_Start_DMA
Function Name
HAL_StatusTypeDef HAL_TIM_Base_Start_DMA (
TIM_HandleTypeDef * htim, uint32_t * pData, uint16_t Length)
DocID026525 Rev 1
531/692
38.2.22
38.2.23
38.2.24
532/692
UM1785
Starts the TIM Base generation in DMA mode.
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_Base_Stop_DMA
Function Name
HAL_StatusTypeDef HAL_TIM_Base_Stop_DMA (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_OC_Init
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_OC_DeInit
DocID026525 Rev 1
UM1785
38.2.25
38.2.26
38.2.27
HAL_StatusTypeDef HAL_TIM_OC_DeInit (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_OC_MspInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_TIM_OC_MspDeInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_TIM_OC_Start
DocID026525 Rev 1
533/692
38.2.28
38.2.29
534/692
UM1785
HAL_StatusTypeDef HAL_TIM_OC_Start ( TIM_HandleTypeDef
* htim, uint32_t Channel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_OC_Stop
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_OC_Start_IT
Function Name
HAL_StatusTypeDef HAL_TIM_OC_Start_IT (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
DocID026525 Rev 1
UM1785
38.2.30
38.2.31
Return values
HAL status
Notes
None.
HAL_TIM_OC_Stop_IT
Function Name
HAL_StatusTypeDef HAL_TIM_OC_Stop_IT (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_OC_Start_DMA
Function Name
HAL_StatusTypeDef HAL_TIM_OC_Start_DMA (
TIM_HandleTypeDef * htim, uint32_t Channel, uint32_t *
pData, uint16_t Length)
Function Description
Parameters
535/692
UM1785
38.2.32
38.2.33
536/692
Return values
HAL status
Notes
None.
HAL_TIM_OC_Stop_DMA
Function Name
HAL_StatusTypeDef HAL_TIM_OC_Stop_DMA (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_PWM_Init
Function Name
HAL_StatusTypeDef HAL_TIM_PWM_Init (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
UM1785
38.2.34
38.2.35
38.2.36
HAL_TIM_PWM_DeInit
Function Name
HAL_StatusTypeDef HAL_TIM_PWM_DeInit (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_PWM_MspInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_TIM_PWM_MspDeInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
537/692
38.2.37
38.2.38
38.2.39
538/692
UM1785
HAL_TIM_PWM_Start
Function Name
HAL_StatusTypeDef HAL_TIM_PWM_Start (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_PWM_Stop
Function Name
HAL_StatusTypeDef HAL_TIM_PWM_Stop (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_PWM_Start_IT
DocID026525 Rev 1
UM1785
38.2.40
38.2.41
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_PWM_Stop_IT
Function Name
HAL_StatusTypeDef HAL_TIM_PWM_Stop_IT (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_PWM_Start_DMA
Function Name
HAL_StatusTypeDef HAL_TIM_PWM_Start_DMA (
TIM_HandleTypeDef * htim, uint32_t Channel, uint32_t *
pData, uint16_t Length)
Function Description
DocID026525 Rev 1
539/692
UM1785
38.2.42
38.2.43
540/692
Return values
HAL status
Notes
None.
HAL_TIM_PWM_Stop_DMA
Function Name
HAL_StatusTypeDef HAL_TIM_PWM_Stop_DMA (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_IC_Init
Function Name
Function Description
DocID026525 Rev 1
UM1785
38.2.44
38.2.45
38.2.46
Return values
HAL status
Notes
None.
HAL_TIM_IC_DeInit
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_IC_MspInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_TIM_IC_MspDeInit
Function Name
Function Description
Parameters
DocID026525 Rev 1
541/692
38.2.47
38.2.48
542/692
UM1785
None.
None.
HAL_TIM_IC_Start
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_IC_Stop
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
UM1785
38.2.49
38.2.50
38.2.51
HAL_TIM_IC_Start_IT
Function Name
HAL_StatusTypeDef HAL_TIM_IC_Start_IT (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_IC_Stop_IT
Function Name
HAL_StatusTypeDef HAL_TIM_IC_Stop_IT (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_IC_Start_DMA
DocID026525 Rev 1
543/692
UM1785
HAL_StatusTypeDef HAL_TIM_IC_Start_DMA (
TIM_HandleTypeDef * htim, uint32_t Channel, uint32_t *
pData, uint16_t Length)
Function Description
Parameters
38.2.52
38.2.53
Return values
HAL status
Notes
None.
HAL_TIM_IC_Stop_DMA
Function Name
HAL_StatusTypeDef HAL_TIM_IC_Stop_DMA (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_OnePulse_Init
Function Name
544/692
HAL_StatusTypeDef HAL_TIM_OnePulse_Init (
DocID026525 Rev 1
UM1785
38.2.54
38.2.55
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_OnePulse_DeInit
Function Name
HAL_StatusTypeDef HAL_TIM_OnePulse_DeInit (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_OnePulse_MspInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
545/692
38.2.56
38.2.57
38.2.58
546/692
UM1785
HAL_TIM_OnePulse_MspDeInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_TIM_OnePulse_Start
Function Name
HAL_StatusTypeDef HAL_TIM_OnePulse_Start (
TIM_HandleTypeDef * htim, uint32_t OutputChannel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_OnePulse_Stop
Function Name
HAL_StatusTypeDef HAL_TIM_OnePulse_Stop (
TIM_HandleTypeDef * htim, uint32_t OutputChannel)
Function Description
Parameters
UM1785
38.2.59
38.2.60
Return values
HAL status
Notes
None.
HAL_TIM_OnePulse_Start_IT
Function Name
HAL_StatusTypeDef HAL_TIM_OnePulse_Start_IT (
TIM_HandleTypeDef * htim, uint32_t OutputChannel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_OnePulse_Stop_IT
Function Name
HAL_StatusTypeDef HAL_TIM_OnePulse_Stop_IT (
TIM_HandleTypeDef * htim, uint32_t OutputChannel)
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
547/692
38.2.61
38.2.62
38.2.63
548/692
UM1785
HAL_TIM_Encoder_Init
Function Name
HAL_StatusTypeDef HAL_TIM_Encoder_Init (
TIM_HandleTypeDef * htim, TIM_Encoder_InitTypeDef *
sConfig)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_Encoder_DeInit
Function Name
HAL_StatusTypeDef HAL_TIM_Encoder_DeInit (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_Encoder_MspInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
UM1785
38.2.64
38.2.65
38.2.66
HAL_TIM_Encoder_MspDeInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_TIM_Encoder_Start
Function Name
HAL_StatusTypeDef HAL_TIM_Encoder_Start (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_Encoder_Stop
Function Name
HAL_StatusTypeDef HAL_TIM_Encoder_Stop (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
Parameters
549/692
UM1785
38.2.67
38.2.68
550/692
Return values
HAL status
Notes
None.
HAL_TIM_Encoder_Start_IT
Function Name
HAL_StatusTypeDef HAL_TIM_Encoder_Start_IT (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_Encoder_Stop_IT
Function Name
HAL_StatusTypeDef HAL_TIM_Encoder_Stop_IT (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
UM1785
38.2.69
HAL_TIM_Encoder_Start_DMA
Function Name
HAL_StatusTypeDef HAL_TIM_Encoder_Start_DMA (
TIM_HandleTypeDef * htim, uint32_t Channel, uint32_t *
pData1, uint32_t * pData2, uint16_t Length)
Function Description
Parameters
38.2.70
38.2.71
Return values
HAL status
Notes
None.
HAL_TIM_Encoder_Stop_DMA
Function Name
HAL_StatusTypeDef HAL_TIM_Encoder_Stop_DMA (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_IRQHandler
DocID026525 Rev 1
551/692
38.2.72
38.2.73
552/692
UM1785
void HAL_TIM_IRQHandler ( TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_TIM_OC_ConfigChannel
Function Name
HAL_StatusTypeDef HAL_TIM_OC_ConfigChannel (
TIM_HandleTypeDef * htim, TIM_OC_InitTypeDef * sConfig,
uint32_t Channel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_IC_ConfigChannel
Function Name
HAL_StatusTypeDef HAL_TIM_IC_ConfigChannel (
TIM_HandleTypeDef * htim, TIM_IC_InitTypeDef * sConfig,
uint32_t Channel)
Function Description
Parameters
UM1785
38.2.74
38.2.75
Return values
HAL status
Notes
None.
HAL_TIM_PWM_ConfigChannel
Function Name
HAL_StatusTypeDef HAL_TIM_PWM_ConfigChannel (
TIM_HandleTypeDef * htim, TIM_OC_InitTypeDef * sConfig,
uint32_t Channel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_OnePulse_ConfigChannel
Function Name
HAL_StatusTypeDef HAL_TIM_OnePulse_ConfigChannel (
TIM_HandleTypeDef * htim, TIM_OnePulse_InitTypeDef *
sConfig, uint32_t OutputChannel, uint32_t InputChannel)
Function Description
Parameters
553/692
UM1785
38.2.76
Return values
HAL status
Notes
None.
HAL_TIM_DMABurst_WriteStart
Function Name
HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStart (
TIM_HandleTypeDef * htim, uint32_t BurstBaseAddress,
uint32_t BurstRequestSrc, uint32_t * BurstBuffer, uint32_t
BurstLength)
Function Description
Configure the DMA Burst to transfer Data from the memory to the
TIM peripheral.
Parameters
554/692
TIM_DMABase_CR1
TIM_DMABase_CR2
TIM_DMABase_SMCR
TIM_DMABase_DIER
TIM_DMABase_SR
TIM_DMABase_EGR
TIM_DMABase_CCMR1
TIM_DMABase_CCMR2
TIM_DMABase_CCER
TIM_DMABase_CNT
TIM_DMABase_PSC
TIM_DMABase_ARR
TIM_DMABase_RCR
TIM_DMABase_CCR1
TIM_DMABase_CCR2
TIM_DMABase_CCR3
TIM_DMABase_CCR4
TIM_DMABase_BDTR
TIM_DMABase_DCR
BurstRequestSrc : : TIM DMA Request sources This
parameter can be one of the following values:
UM1785
38.2.77
38.2.78
Return values
HAL status
Notes
None.
HAL_TIM_DMABurst_WriteStop
Function Name
HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStop (
TIM_HandleTypeDef * htim, uint32_t BurstRequestSrc)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_DMABurst_ReadStart
Function Name
HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStart (
TIM_HandleTypeDef * htim, uint32_t BurstBaseAddress,
uint32_t BurstRequestSrc, uint32_t * BurstBuffer, uint32_t
BurstLength)
Function Description
Configure the DMA Burst to transfer Data from the TIM peripheral
to the memory.
Parameters
TIM_DMABase_CR1
TIM_DMABase_CR2
DocID026525 Rev 1
555/692
UM1785
38.2.79
556/692
TIM_DMABase_SMCR
TIM_DMABase_DIER
TIM_DMABase_SR
TIM_DMABase_EGR
TIM_DMABase_CCMR1
TIM_DMABase_CCMR2
TIM_DMABase_CCER
TIM_DMABase_CNT
TIM_DMABase_PSC
TIM_DMABase_ARR
TIM_DMABase_RCR
TIM_DMABase_CCR1
TIM_DMABase_CCR2
TIM_DMABase_CCR3
TIM_DMABase_CCR4
TIM_DMABase_BDTR
TIM_DMABase_DCR
BurstRequestSrc : : TIM DMA Request sources This
parameter can be one of the following values:
Return values
HAL status
Notes
None.
HAL_TIM_DMABurst_ReadStop
Function Name
HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStop (
TIM_HandleTypeDef * htim, uint32_t BurstRequestSrc)
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
UM1785
38.2.80
38.2.81
HAL_TIM_GenerateEvent
Function Name
HAL_StatusTypeDef HAL_TIM_GenerateEvent (
TIM_HandleTypeDef * htim, uint32_t EventSource)
Function Description
Parameters
Return values
HAL status
Notes
HAL_TIM_ConfigOCrefClear
Function Name
HAL_StatusTypeDef HAL_TIM_ConfigOCrefClear (
TIM_HandleTypeDef * htim, TIM_ClearInputConfigTypeDef *
sClearInputConfig, uint32_t Channel)
Function Description
Parameters
557/692
UM1785
38.2.82
38.2.83
558/692
Return values
HAL status
Notes
None.
HAL_TIM_ConfigClockSource
Function Name
HAL_StatusTypeDef HAL_TIM_ConfigClockSource (
TIM_HandleTypeDef * htim, TIM_ClockConfigTypeDef *
sClockSourceConfig)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_ConfigTI1Input
Function Name
HAL_StatusTypeDef HAL_TIM_ConfigTI1Input (
TIM_HandleTypeDef * htim, uint32_t TI1_Selection)
Function Description
Parameters
TIM_TI1SELECTION_XORCOMBINATION The
TIMx_CH1, CH2 and CH3 pins are connected to the TI1
input (XOR combination)
DocID026525 Rev 1
UM1785
38.2.84
38.2.85
HAL status
Notes
None.
HAL_TIM_SlaveConfigSynchronization
Function Name
HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchronization (
TIM_HandleTypeDef * htim, TIM_SlaveConfigTypeDef *
sSlaveConfig)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIM_SlaveConfigSynchronization_IT
Function Name
HAL_StatusTypeDef
HAL_TIM_SlaveConfigSynchronization_IT (
TIM_HandleTypeDef * htim, TIM_SlaveConfigTypeDef *
sSlaveConfig)
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
559/692
38.2.86
38.2.87
38.2.88
560/692
UM1785
HAL_TIM_ReadCapturedValue
Function Name
Function Description
Parameters
Return values
Captured value
Notes
None.
HAL_TIM_PeriodElapsedCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_TIM_OC_DelayElapsedCallback
Function Name
void HAL_TIM_OC_DelayElapsedCallback (
TIM_HandleTypeDef * htim)
Function Description
Parameters
UM1785
38.2.89
38.2.90
38.2.91
None.
Notes
None.
HAL_TIM_IC_CaptureCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_TIM_PWM_PulseFinishedCallback
Function Name
void HAL_TIM_PWM_PulseFinishedCallback (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_TIM_TriggerCallback
Function Name
Function Description
Parameters
Return values
None.
DocID026525 Rev 1
561/692
38.2.92
38.2.93
38.2.94
562/692
UM1785
None.
HAL_TIM_ErrorCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_TIM_Base_GetState
Function Name
HAL_TIM_StateTypeDef HAL_TIM_Base_GetState (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
HAL state
Notes
None.
HAL_TIM_OC_GetState
Function Name
HAL_TIM_StateTypeDef HAL_TIM_OC_GetState (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
HAL state
Notes
None.
DocID026525 Rev 1
UM1785
38.2.95
38.2.96
38.2.97
HAL_TIM_PWM_GetState
Function Name
HAL_TIM_StateTypeDef HAL_TIM_PWM_GetState (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
HAL state
Notes
None.
HAL_TIM_IC_GetState
Function Name
HAL_TIM_StateTypeDef HAL_TIM_IC_GetState (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
HAL state
Notes
None.
HAL_TIM_OnePulse_GetState
Function Name
HAL_TIM_StateTypeDef HAL_TIM_OnePulse_GetState (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
HAL state
Notes
None.
DocID026525 Rev 1
563/692
38.2.98
UM1785
HAL_TIM_Encoder_GetState
Function Name
HAL_TIM_StateTypeDef HAL_TIM_Encoder_GetState (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
HAL state
Notes
None.
38.3
38.3.1
TIM
TIM
TIM Automatic Output Enable
TIM_AUTOMATICOUTPUT_ENABLE
TIM_AUTOMATICOUTPUT_DISABLE
IS_TIM_AUTOMATIC_OUTPUT_STATE
TIM Break Input Enable
TIM_BREAK_ENABLE
TIM_BREAK_DISABLE
IS_TIM_BREAK_STATE
TIM Break Input Polarity
TIM_BREAKPOLARITY_LOW
TIM_BREAKPOLARITY_HIGH
IS_TIM_BREAK_POLARITY
TIM Channel
TIM_CHANNEL_1
TIM_CHANNEL_2
TIM_CHANNEL_3
TIM_CHANNEL_4
564/692
DocID026525 Rev 1
UM1785
TIM_CLEARINPUTPOLARITY_NONINVERTED
IS_TIM_CLEARINPUT_POLARITY
TIM Clear Input Prescaler
TIM_CLEARINPUTPRESCALER_DIV1
No prescaler is used
TIM_CLEARINPUTPRESCALER_DIV2
TIM_CLEARINPUTPRESCALER_DIV4
TIM_CLEARINPUTPRESCALER_DIV8
IS_TIM_CLEARINPUT_PRESCALER
TIM ClearInput Source
TIM_CLEARINPUTSOURCE_ETR
TIM_CLEARINPUTSOURCE_NONE
IS_TIM_CLEARINPUT_SOURCE
TIM Clock Division
TIM_CLOCKDIVISION_DIV1
TIM_CLOCKDIVISION_DIV2
TIM_CLOCKDIVISION_DIV4
IS_TIM_CLOCKDIVISION_DIV
TIM Clock Filter
IS_TIM_CLOCKFILTER
IS_TIM_DEADTIME
TIM Clock Polarity
TIM_CLOCKPOLARITY_INVERTED
TIM_CLOCKPOLARITY_NONINVERTED
TIM_CLOCKPOLARITY_RISING
TIM_CLOCKPOLARITY_FALLING
DocID026525 Rev 1
565/692
UM1785
Polarity for TIx clock sources
IS_TIM_CLOCKPOLARITY
TIM Clock Prescaler
TIM_CLOCKPRESCALER_DIV1
No prescaler is used
TIM_CLOCKPRESCALER_DIV2
TIM_CLOCKPRESCALER_DIV4
TIM_CLOCKPRESCALER_DIV8
IS_TIM_CLOCKPRESCALER
TIM Clock Source
TIM_CLOCKSOURCE_ETRMODE2
TIM_CLOCKSOURCE_INTERNAL
TIM_CLOCKSOURCE_ITR0
TIM_CLOCKSOURCE_ITR1
TIM_CLOCKSOURCE_ITR2
TIM_CLOCKSOURCE_ITR3
TIM_CLOCKSOURCE_TI1ED
TIM_CLOCKSOURCE_TI1
TIM_CLOCKSOURCE_TI2
TIM_CLOCKSOURCE_ETRMODE1
IS_TIM_CLOCKSOURCE
TIM Commutation
TIM_COMMUTATION_TRGI
TIM_COMMUTATION_SOFTWARE
TIM Counter Mode
TIM_COUNTERMODE_UP
TIM_COUNTERMODE_DOWN
TIM_COUNTERMODE_CENTERALIGNED1
TIM_COUNTERMODE_CENTERALIGNED2
TIM_COUNTERMODE_CENTERALIGNED3
IS_TIM_COUNTER_MODE
TIM DMA Base address
TIM_DMABase_CR1
TIM_DMABase_CR2
TIM_DMABase_SMCR
566/692
DocID026525 Rev 1
UM1785
DocID026525 Rev 1
567/692
UM1785
IS_TIM_DMA_LENGTH
TIM DMA Handle Index
TIM_DMA_ID_UPDATE
TIM_DMA_ID_CC1
TIM_DMA_ID_CC2
TIM_DMA_ID_CC3
TIM_DMA_ID_CC4
TIM_DMA_ID_COMMUTATION
TIM_DMA_ID_TRIGGER
TIM_ETRPOLARITY_NONINVERTED
No prescaler is used
TIM_ETRPRESCALER_DIV2
TIM_ETRPRESCALER_DIV4
TIM_ETRPRESCALER_DIV8
568/692
DocID026525 Rev 1
UM1785
Description:
Parameters:
Return value:
None:
Description:
__HAL_TIM_ENABLE
Parameters:
Return value:
None:
Description:
__HAL_TIM_MOE_ENABLE
Parameters:
Return value:
None:
Description:
__HAL_TIM_DISABLE
Parameters:
Return value:
__HAL_TIM_MOE_DISABLE
None:
Description:
DocID026525 Rev 1
569/692
UM1785
Parameters:
Return value:
None:
__HAL_TIM_ENABLE_IT
__HAL_TIM_ENABLE_DMA
__HAL_TIM_DISABLE_IT
__HAL_TIM_DISABLE_DMA
__HAL_TIM_GET_FLAG
__HAL_TIM_CLEAR_FLAG
__HAL_TIM_GET_ITSTATUS
__HAL_TIM_CLEAR_IT
__HAL_TIM_DIRECTION_STATUS
__HAL_TIM_PRESCALER
__HAL_TIM_SetICPrescalerValue
__HAL_TIM_ResetICPrescalerValue
__HAL_TIM_SetCompare
Description:
Parameters:
Return value:
__HAL_TIM_GetCompare
None:
Description:
Parameters:
570/692
DocID026525 Rev 1
UM1785
TIM_CHANNEL_1: get
capture/compare 1 register value
TIM_CHANNEL_2: get
capture/compare 2 register value
TIM_CHANNEL_3: get
capture/compare 3 register value
TIM_CHANNEL_4: get
capture/compare 4 register value
Return value:
__HAL_TIM_SetCounter
None:
Description:
Parameters:
Return value:
__HAL_TIM_GetCounter
None:
Description:
Parameters:
Return value:
__HAL_TIM_SetAutoreload
None:
Description:
Parameters:
Return value:
__HAL_TIM_GetAutoreload
None:
Description:
DocID026525 Rev 1
571/692
UM1785
runtime.
Parameters:
Return value:
__HAL_TIM_SetClockDivision
None:
Description:
Parameters:
TIM_CLOCKDIVISION_DIV1
TIM_CLOCKDIVISION_DIV2
TIM_CLOCKDIVISION_DIV4
Return value:
__HAL_TIM_GetClockDivision
None:
Description:
Parameters:
Return value:
__HAL_TIM_SetICPrescaler
None:
Description:
Parameters:
572/692
DocID026525 Rev 1
UM1785
TIM_ICPSC_DIV1: no prescaler
__HAL_TIM_GetICPrescaler
None:
Description:
Parameters:
Return value:
__HAL_TIM_URS_ENABLE
None:
Description:
Parameters:
Return value:
__HAL_TIM_URS_DISABLE
None:
Description:
Parameters:
Return value:
None:
573/692
UM1785
TIM_FLAG_CC1
TIM_FLAG_CC2
TIM_FLAG_CC3
TIM_FLAG_CC4
TIM_FLAG_COM
TIM_FLAG_TRIGGER
TIM_FLAG_BREAK
TIM_FLAG_CC1OF
TIM_FLAG_CC2OF
TIM_FLAG_CC3OF
TIM_FLAG_CC4OF
IS_TIM_FLAG
TIM Input Capture Value
IS_TIM_IC_FILTER
TIM Input Capture Polarity
TIM_ICPOLARITY_RISING
TIM_ICPOLARITY_FALLING
TIM_ICPOLARITY_BOTHEDGE
IS_TIM_IC_POLARITY
TIM Input Capture Prescaler
TIM_ICPSC_DIV1
TIM_ICPSC_DIV2
TIM_ICPSC_DIV4
TIM_ICPSC_DIV8
IS_TIM_IC_PRESCALER
TIM Input Capture Selection
TIM_ICSELECTION_DIRECTTI
TIM_ICSELECTION_INDIRECTTI
TIM_ICSELECTION_TRC
IS_TIM_IC_SELECTION
TIM Input Channel polarity
574/692
TIM_INPUTCHANNELPOLARITY_RISING
TIM_INPUTCHANNELPOLARITY_FALLING
DocID026525 Rev 1
UM1785
TIM_INPUTCHANNELPOLARITY_BOTHEDGE
DocID026525 Rev 1
575/692
UM1785
IS_TIM_OSSI_STATE
TIM Off-state Selection for Run Mode
TIM_OSSR_ENABLE
TIM_OSSR_DISABLE
IS_TIM_OSSR_STATE
TIM Output Compare & PWM modes
TIM_OCMODE_TIMING
TIM_OCMODE_ACTIVE
TIM_OCMODE_INACTIVE
TIM_OCMODE_TOGGLE
TIM_OCMODE_PWM1
TIM_OCMODE_PWM2
TIM_OCMODE_FORCED_ACTIVE
TIM_OCMODE_FORCED_INACTIVE
IS_TIM_PWM_MODE
IS_TIM_OC_MODE
TIM Output Compare Idle State
TIM_OCIDLESTATE_SET
TIM_OCIDLESTATE_RESET
IS_TIM_OCIDLE_STATE
TIM Complementary Output Compare Idle State
TIM_OCNIDLESTATE_SET
TIM_OCNIDLESTATE_RESET
IS_TIM_OCNIDLE_STATE
TIM Complementary Output Compare Polarity
TIM_OCNPOLARITY_HIGH
TIM_OCNPOLARITY_LOW
IS_TIM_OCN_POLARITY
TIM Complementary Output Compare State
TIM_OUTPUTNSTATE_DISABLE
TIM_OUTPUTNSTATE_ENABLE
IS_TIM_OUTPUTN_STATE
TIM Output Compare Polarity
TIM_OCPOLARITY_HIGH
TIM_OCPOLARITY_LOW
576/692
DocID026525 Rev 1
UM1785
TIM_TRIGGERPOLARITY_NONINVERTED
TIM_TRIGGERPOLARITY_RISING
TIM_TRIGGERPOLARITY_FALLING
TIM_TRIGGERPOLARITY_BOTHEDGE
IS_TIM_TRIGGERPOLARITY
TIM Trigger Prescaler
TIM_TRIGGERPRESCALER_DIV1
No prescaler is used
DocID026525 Rev 1
577/692
UM1785
Prescaler for External ETR Trigger: Capture
performed once every 2 events.
TIM_TRIGGERPRESCALER_DIV4
TIM_TRIGGERPRESCALER_DIV8
IS_TIM_TRIGGERPRESCALER
TIM Trigger Selection
TIM_TS_ITR0
TIM_TS_ITR1
TIM_TS_ITR2
TIM_TS_ITR3
TIM_TS_TI1F_ED
TIM_TS_TI1FP1
TIM_TS_TI2FP2
TIM_TS_ETRF
TIM_TS_NONE
IS_TIM_TRIGGER_SELECTION
IS_TIM_INTERNAL_TRIGGER_SELECTION
IS_TIM_INTERNAL_TRIGGEREVENT_SELECTION
578/692
DocID026525 Rev 1
UM1785
39
39.1
39.1.1
TIM_HallSensor_InitTypeDef
TIM_HallSensor_InitTypeDef is defined in the stm32f0xx_hal_tim_ex.h
Data Fields
uint32_t IC1Polarity
uint32_t IC1Prescaler
uint32_t IC1Filter
uint32_t Commutation_Delay
Field Documentation
39.1.2
TIM_MasterConfigTypeDef
TIM_MasterConfigTypeDef is defined in the stm32f0xx_hal_tim_ex.h
Data Fields
uint32_t MasterOutputTrigger
uint32_t MasterSlaveMode
Field Documentation
39.1.3
TIM_BreakDeadTimeConfigTypeDef
TIM_BreakDeadTimeConfigTypeDef is defined in the stm32f0xx_hal_tim_ex.h
Data Fields
uint32_t OffStateRunMode
uint32_t OffStateIDLEMode
DocID026525 Rev 1
579/692
UM1785
uint32_t LockLevel
uint32_t DeadTime
uint32_t BreakState
uint32_t BreakPolarity
uint32_t AutomaticOutput
Field Documentation
39.2
39.2.1
2.
3.
4.
39.2.2
1.
580/692
Output Compare
Initialize the TIM low level resources by implementing the following functions
depending from feature used :
UM1785
2.
3.
4.
5.
39.2.3
Enable the clock for the TIM GPIOs using the following function:
__GPIOx_CLK_ENABLE();
DocID026525 Rev 1
581/692
39.2.4
UM1785
39.2.5
39.2.6
582/692
UM1785
39.2.7
39.2.8
39.2.9
Configure the commutation event in case of use of the Hall sensor interface.
Configure Complementary channels, break features and dead time.
Configure Master synchronization.
Configure timer remapping capabilities.
HAL_TIMEx_ConfigCommutationEvent()
HAL_TIMEx_ConfigCommutationEvent_IT()
HAL_TIMEx_ConfigCommutationEvent_DMA()
HAL_TIMEx_MasterConfigSynchronization()
HAL_TIMEx_ConfigBreakDeadTime()
HAL_TIMEx_RemapConfig()
HAL_TIMEx_HallSensor_Init
Function Name
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init (
TIM_HandleTypeDef * htim, TIM_HallSensor_InitTypeDef *
sConfig)
Function Description
Initializes the TIM Hall Sensor Interface and create the associated
handle.
Parameters
Return values
HAL status
Notes
None.
HAL_TIMEx_HallSensor_DeInit
Function Name
HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
HAL status
DocID026525 Rev 1
583/692
39.2.10
39.2.11
39.2.12
584/692
UM1785
None.
HAL_TIMEx_HallSensor_MspInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_TIMEx_HallSensor_MspDeInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_TIMEx_HallSensor_Start
Function Name
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
HAL status
DocID026525 Rev 1
UM1785
39.2.13
39.2.14
39.2.15
None.
HAL_TIMEx_HallSensor_Stop
Function Name
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIMEx_HallSensor_Start_IT
Function Name
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIMEx_HallSensor_Stop_IT
Function Name
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
HAL status
DocID026525 Rev 1
585/692
39.2.16
39.2.17
39.2.18
586/692
UM1785
None.
HAL_TIMEx_HallSensor_Start_DMA
Function Name
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA (
TIM_HandleTypeDef * htim, uint32_t * pData, uint16_t Length)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIMEx_HallSensor_Stop_DMA
Function Name
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA (
TIM_HandleTypeDef * htim)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIMEx_OCN_Start
Function Name
HAL_StatusTypeDef HAL_TIMEx_OCN_Start (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
DocID026525 Rev 1
UM1785
39.2.19
39.2.20
Parameters
Return values
HAL status
Notes
None.
HAL_TIMEx_OCN_Stop
Function Name
HAL_StatusTypeDef HAL_TIMEx_OCN_Stop (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIMEx_OCN_Start_IT
Function Name
HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
Parameters
587/692
UM1785
be one of the following values:
39.2.21
39.2.22
588/692
Return values
HAL status
Notes
None.
HAL_TIMEx_OCN_Stop_IT
Function Name
HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIMEx_OCN_Start_DMA
Function Name
HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA (
TIM_HandleTypeDef * htim, uint32_t Channel, uint32_t *
pData, uint16_t Length)
Function Description
Parameters
UM1785
39.2.23
39.2.24
Return values
HAL status
Notes
None.
HAL_TIMEx_OCN_Stop_DMA
Function Name
HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIMEx_PWMN_Start
Function Name
HAL_StatusTypeDef HAL_TIMEx_PWMN_Start (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
Parameters
DocID026525 Rev 1
589/692
UM1785
39.2.25
39.2.26
590/692
Return values
HAL status
Notes
None.
HAL_TIMEx_PWMN_Stop
Function Name
HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIMEx_PWMN_Start_IT
Function Name
HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
UM1785
39.2.27
39.2.28
HAL_TIMEx_PWMN_Stop_IT
Function Name
HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIMEx_PWMN_Start_DMA
Function Name
HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA (
TIM_HandleTypeDef * htim, uint32_t Channel, uint32_t *
pData, uint16_t Length)
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
591/692
39.2.29
39.2.30
592/692
UM1785
HAL_TIMEx_PWMN_Stop_DMA
Function Name
HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA (
TIM_HandleTypeDef * htim, uint32_t Channel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIMEx_OnePulseN_Start
Function Name
HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start (
TIM_HandleTypeDef * htim, uint32_t OutputChannel)
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
UM1785
39.2.31
39.2.32
39.2.33
HAL_TIMEx_OnePulseN_Stop
Function Name
HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop (
TIM_HandleTypeDef * htim, uint32_t OutputChannel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIMEx_OnePulseN_Start_IT
Function Name
HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT (
TIM_HandleTypeDef * htim, uint32_t OutputChannel)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIMEx_OnePulseN_Stop_IT
Function Name
HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT (
TIM_HandleTypeDef * htim, uint32_t OutputChannel)
DocID026525 Rev 1
593/692
39.2.34
UM1785
Stops the TIM One Pulse signal generation in interrupt mode on
the complementary channel.
Parameters
Return values
HAL status
Notes
None.
HAL_TIMEx_ConfigCommutationEvent
Function Name
HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent (
TIM_HandleTypeDef * htim, uint32_t InputTrigger, uint32_t
CommutationSource)
Function Description
Parameters
594/692
TIM_COMMUTATION_SOFTWARE Commutation
source is set by software using the COMG bit
Return values
HAL status
Notes
DocID026525 Rev 1
UM1785
39.2.35
HAL_TIMEx_ConfigCommutationEvent_IT
Function Name
HAL_StatusTypeDef
HAL_TIMEx_ConfigCommutationEvent_IT (
TIM_HandleTypeDef * htim, uint32_t InputTrigger, uint32_t
CommutationSource)
Function Description
Parameters
39.2.36
TIM_COMMUTATION_SOFTWARE Commutation
source is set by software using the COMG bit
Return values
HAL status
Notes
HAL_TIMEx_ConfigCommutationEvent_DMA
Function Name
HAL_StatusTypeDef
HAL_TIMEx_ConfigCommutationEvent_DMA (
TIM_HandleTypeDef * htim, uint32_t InputTrigger, uint32_t
CommutationSource)
Function Description
DocID026525 Rev 1
595/692
UM1785
Return values
HAL status
Notes
39.2.37
596/692
TIM_COMMUTATION_SOFTWARE Commutation
source is set by software using the COMG bit
HAL_TIMEx_MasterConfigSynchronization
Function Name
HAL_StatusTypeDef
HAL_TIMEx_MasterConfigSynchronization (
TIM_HandleTypeDef * htim, TIM_MasterConfigTypeDef *
sMasterConfig)
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
UM1785
39.2.38
39.2.39
39.2.40
HAL_TIMEx_ConfigBreakDeadTime
Function Name
HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime (
TIM_HandleTypeDef * htim,
TIM_BreakDeadTimeConfigTypeDef *
sBreakDeadTimeConfig)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIMEx_RemapConfig
Function Name
HAL_StatusTypeDef HAL_TIMEx_RemapConfig (
TIM_HandleTypeDef * htim, uint32_t Remap)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TIMEx_CommutationCallback
DocID026525 Rev 1
597/692
39.2.41
39.2.42
39.2.43
Function Description
Parameters
Return values
None.
Notes
None.
HAL_TIMEx_BreakCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_TIMEx_DMACommutationCplt
Function Name
void HAL_TIMEx_DMACommutationCplt (
DMA_HandleTypeDef * hdma)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_TIMEx_HallSensor_GetState
Function Name
598/692
UM1785
void HAL_TIMEx_CommutationCallback ( TIM_HandleTypeDef
* htim)
HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState (
DocID026525 Rev 1
UM1785
Parameters
Return values
HAL state
Notes
None.
39.3
39.3.1
TIMEx
TIMEx
TIMEx Remap
TIM_TIM14_GPIO
TIM_TIM14_RTC
TIM_TIM14_HSE
TIM_TIM14_MCO
IS_TIM_REMAP
DocID026525 Rev 1
599/692
UM1785
40
40.1
40.1.1
TSC_InitTypeDef
TSC_InitTypeDef is defined in the stm32f0xx_hal_tsc.h
Data Fields
uint32_t CTPulseHighLength
uint32_t CTPulseLowLength
uint32_t SpreadSpectrum
uint32_t SpreadSpectrumDeviation
uint32_t SpreadSpectrumPrescaler
uint32_t PulseGeneratorPrescaler
uint32_t MaxCountValue
uint32_t IODefaultMode
uint32_t SynchroPinPolarity
uint32_t AcquisitionMode
uint32_t MaxCountInterrupt
uint32_t ChannelIOs
uint32_t ShieldIOs
uint32_t SamplingIOs
Field Documentation
40.1.2
TSC_IOConfigTypeDef
TSC_IOConfigTypeDef is defined in the stm32f0xx_hal_tsc.h
Data Fields
600/692
uint32_t ChannelIOs
uint32_t ShieldIOs
uint32_t SamplingIOs
DocID026525 Rev 1
UM1785
40.1.3
TSC_HandleTypeDef
TSC_HandleTypeDef is defined in the stm32f0xx_hal_tsc.h
Data Fields
TSC_TypeDef * Instance
TSC_InitTypeDef Init
__IO HAL_TSC_StateTypeDef State
HAL_LockTypeDef Lock
Field Documentation
40.2
40.2.1
1.
2.
3.
40.2.2
DocID026525 Rev 1
601/692
Enable the clock for the TSC GPIOs using __GPIOx_CLK_ENABLE() macro.
Configure the TSC pins used as sampling IOs in alternate function output OpenDrain mode, and TSC pins used as channel/shield IOs in alternate function
output Push-Pull mode using HAL_GPIO_Init() function.
Configure the alternate function on all the TSC pins using HAL_xxxx() function.
3.
Interrupts configuration
Configure the NVIC (if the interrupt model is used) using HAL_xxx() function.
4.
TSC configuration
Configure all TSC parameters and used TSC IOs using HAL_TSC_Init() function.
Acquisition sequence
40.2.3
40.2.4
40.2.5
State functions
This subsection provides functions allowing to
602/692
UM1785
40.2.6
40.2.7
40.2.8
HAL_TSC_Init
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TSC_DeInit
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TSC_MspInit
Function Name
Function Description
Parameters
603/692
40.2.9
40.2.10
40.2.11
604/692
UM1785
None.
None.
HAL_TSC_MspDeInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_TSC_Start
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TSC_Start_IT
Function Name
Function Description
DocID026525 Rev 1
UM1785
40.2.12
40.2.13
40.2.14
Return values
HAL status.
Notes
None.
HAL_TSC_Stop
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TSC_Stop_IT
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TSC_GroupGetStatus
Function Name
TSC_GroupStatusTypeDef HAL_TSC_GroupGetStatus (
DocID026525 Rev 1
605/692
UM1785
TSC_HandleTypeDef * htsc, uint32_t gx_index)
40.2.15
40.2.16
606/692
Function Description
Parameters
Return values
Group status
Notes
None.
HAL_TSC_GroupGetValue
Function Name
Function Description
Parameters
Return values
Acquisition measure
Notes
None.
HAL_TSC_IOConfig
Function Name
HAL_StatusTypeDef HAL_TSC_IOConfig (
TSC_HandleTypeDef * htsc, TSC_IOConfigTypeDef * config)
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
UM1785
40.2.17
40.2.18
40.2.19
HAL_TSC_IODischarge
Function Name
HAL_StatusTypeDef HAL_TSC_IODischarge (
TSC_HandleTypeDef * htsc, uint32_t choice)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_TSC_GetState
Function Name
HAL_TSC_StateTypeDef HAL_TSC_GetState (
TSC_HandleTypeDef * htsc)
Function Description
Parameters
Return values
HAL state
Notes
None.
HAL_TSC_PollForAcquisition
Function Name
HAL_StatusTypeDef HAL_TSC_PollForAcquisition (
TSC_HandleTypeDef * htsc)
Function Description
Parameters
Return values
HAL state
Notes
607/692
40.2.20
40.2.21
40.2.22
608/692
UM1785
HAL_TSC_IRQHandler
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_TSC_ConvCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_TSC_ErrorCallback
Function Name
Function Description
Parameters
Return values
None.
DocID026525 Rev 1
UM1785
None.
40.3
40.3.1
TSC
TSC
TSC Acquisition mode
TSC_ACQ_MODE_NORMAL
TSC_ACQ_MODE_SYNCHRO
IS_TSC_ACQ_MODE
TSC Charge Transfer Pulse High
TSC_CTPH_1CYCLE
TSC_CTPH_2CYCLES
TSC_CTPH_3CYCLES
TSC_CTPH_4CYCLES
TSC_CTPH_5CYCLES
TSC_CTPH_6CYCLES
TSC_CTPH_7CYCLES
TSC_CTPH_8CYCLES
TSC_CTPH_9CYCLES
TSC_CTPH_10CYCLES
TSC_CTPH_11CYCLES
TSC_CTPH_12CYCLES
TSC_CTPH_13CYCLES
TSC_CTPH_14CYCLES
TSC_CTPH_15CYCLES
TSC_CTPH_16CYCLES
IS_TSC_CTPH
TSC Charge Transfer Pulse Low
TSC_CTPL_1CYCLE
TSC_CTPL_2CYCLES
TSC_CTPL_3CYCLES
TSC_CTPL_4CYCLES
TSC_CTPL_5CYCLES
DocID026525 Rev 1
609/692
UM1785
TSC_CTPL_7CYCLES
TSC_CTPL_8CYCLES
TSC_CTPL_9CYCLES
TSC_CTPL_10CYCLES
TSC_CTPL_11CYCLES
TSC_CTPL_12CYCLES
TSC_CTPL_13CYCLES
TSC_CTPL_14CYCLES
TSC_CTPL_15CYCLES
TSC_CTPL_16CYCLES
IS_TSC_CTPL
TSC Exported Macros
__HAL_TSC_RESET_HANDLE_STATE
Description:
Parameters:
Return value:
__HAL_TSC_ENABLE
None:
Description:
Parameters:
Return value:
__HAL_TSC_DISABLE
None:
Description:
Parameters:
Return value:
__HAL_TSC_START_ACQ
None:
Description:
Start acquisition.
Parameters:
Return value:
610/692
DocID026525 Rev 1
UM1785
None:
Description:
__HAL_TSC_STOP_ACQ
Stop acquisition.
Parameters:
Return value:
__HAL_TSC_SET_IODEF_OUTPPLOW
None:
Description:
Parameters:
Return value:
__HAL_TSC_SET_IODEF_INFLOAT
None:
Description:
Parameters:
Return value:
__HAL_TSC_SET_SYNC_POL_FALL
None:
Description:
Parameters:
Return value:
__HAL_TSC_SET_SYNC_POL_RISE_HIGH
None:
Description:
Parameters:
Return value:
__HAL_TSC_ENABLE_IT
None:
Description:
Parameters:
DocID026525 Rev 1
611/692
UM1785
Return value:
None:
Description:
__HAL_TSC_DISABLE_IT
Parameters:
Return value:
__HAL_TSC_GET_IT_SOURCE
None:
Description:
Parameters:
Return value:
SET: or RESET
Description:
__HAL_TSC_GET_FLAG
Parameters:
Return value:
SET: or RESET
Description:
__HAL_TSC_CLEAR_FLAG
Parameters:
Return value:
__HAL_TSC_ENABLE_HYSTERESIS
None:
Description:
Parameters:
612/692
DocID026525 Rev 1
UM1785
Return value:
__HAL_TSC_DISABLE_HYSTERESIS
None:
Description:
Parameters:
Return value:
__HAL_TSC_OPEN_ANALOG_SWITCH
None:
Description:
Parameters:
Return value:
__HAL_TSC_CLOSE_ANALOG_SWITCH
None:
Description:
Parameters:
Return value:
__HAL_TSC_ENABLE_CHANNEL
None:
Description:
Parameters:
Return value:
__HAL_TSC_DISABLE_CHANNEL
None:
Description:
Parameters:
DocID026525 Rev 1
613/692
UM1785
Return value:
__HAL_TSC_ENABLE_SAMPLING
None:
Description:
Parameters:
Return value:
__HAL_TSC_DISABLE_SAMPLING
None:
Description:
Parameters:
Return value:
__HAL_TSC_ENABLE_GROUP
None:
Description:
Parameters:
Return value:
__HAL_TSC_DISABLE_GROUP
None:
Description:
Parameters:
Return value:
__HAL_TSC_GET_GROUP_STATUS
None:
Description:
Parameters:
Return value:
614/692
DocID026525 Rev 1
SET: or RESET
UM1785
DocID026525 Rev 1
615/692
UM1785
TSC_GROUP3_ALL_IOS
TSC_GROUP4_IO1
TSC_GROUP4_IO2
TSC_GROUP4_IO3
TSC_GROUP4_IO4
TSC_GROUP4_ALL_IOS
TSC_GROUP5_IO1
TSC_GROUP5_IO2
TSC_GROUP5_IO3
TSC_GROUP5_IO4
TSC_GROUP5_ALL_IOS
TSC_GROUP6_IO1
TSC_GROUP6_IO2
TSC_GROUP6_IO3
TSC_GROUP6_IO4
TSC_GROUP6_ALL_IOS
TSC_GROUP7_IO1
TSC_GROUP7_IO2
TSC_GROUP7_IO3
TSC_GROUP7_IO4
TSC_GROUP7_ALL_IOS
TSC_GROUP8_IO1
TSC_GROUP8_IO2
TSC_GROUP8_IO3
TSC_GROUP8_IO4
TSC_GROUP8_ALL_IOS
TSC_ALL_GROUPS_ALL_IOS
TSC interrupts definition
TSC_IT_EOA
TSC_IT_MCE
IS_TSC_MCE_IT
TSC I/O default mode definition
TSC_IODEF_OUT_PP_LOW
TSC_IODEF_IN_FLOAT
IS_TSC_IODEF
TSC I/O mode definition
616/692
DocID026525 Rev 1
UM1785
DocID026525 Rev 1
617/692
UM1785
41
41.1
41.1.1
UART_InitTypeDef
UART_InitTypeDef is defined in the stm32f0xx_hal_uart.h
Data Fields
uint32_t BaudRate
uint32_t WordLength
uint32_t StopBits
uint32_t Parity
uint32_t Mode
uint32_t HwFlowCtl
uint32_t OverSampling
uint32_t OneBitSampling
Field Documentation
618/692
If oversampling is 8, Baud Rate Register[15:4] = ((2 * PCLKx) / ((huart>Init.BaudRate)))[15:4] Baud Rate Register[3] = 0 Baud Rate Register[2:0] = (((2
* PCLKx) / ((huart->Init.BaudRate)))[3:0]) >> 1
uint32_t UART_InitTypeDef::WordLength Specifies the number of data bits
transmitted or received in a frame. This parameter can be a value of
UARTEx_Word_Length
uint32_t UART_InitTypeDef::StopBits Specifies the number of stop bits transmitted.
This parameter can be a value of UART_Stop_Bits
uint32_t UART_InitTypeDef::Parity Specifies the parity mode. This parameter can
be a value of UART_Parity
Note:When parity is enabled, the computed parity is inserted at the MSB position of
the transmitted data (9th bit when the word length is set to 9 data bits; 8th bit when the
word length is set to 8 data bits).
uint32_t UART_InitTypeDef::Mode Specifies whether the Receive or Transmit mode
is enabled or disabled. This parameter can be a value of UART_Mode
uint32_t UART_InitTypeDef::HwFlowCtl Specifies whether the hardware flow
control mode is enabled or disabled. This parameter can be a value of
UART_Hardware_Flow_Control
uint32_t UART_InitTypeDef::OverSampling Specifies whether the Over sampling 8
is enabled or disabled, to achieve higher speed (up to fPCLK/8). This parameter can
be a value of UART_Over_Sampling
uint32_t UART_InitTypeDef::OneBitSampling Specifies whether a single sample or
three samples' majority vote is selected. Selecting the single sample method
increases the receiver tolerance to clock deviations. This parameter can be a value of
UART_OneBit_Sampling.
DocID026525 Rev 1
UM1785
41.1.2
UART_AdvFeatureInitTypeDef
UART_AdvFeatureInitTypeDef is defined in the stm32f0xx_hal_uart.h
Data Fields
uint32_t AdvFeatureInit
uint32_t TxPinLevelInvert
uint32_t RxPinLevelInvert
uint32_t DataInvert
uint32_t Swap
uint32_t OverrunDisable
uint32_t DMADisableonRxError
uint32_t AutoBaudRateEnable
uint32_t AutoBaudRateMode
uint32_t MSBFirst
Field Documentation
41.1.3
UART_WakeUpTypeDef
UART_WakeUpTypeDef is defined in the stm32f0xx_hal_uart.h
Data Fields
uint32_t WakeUpEvent
uint16_t AddressLength
DocID026525 Rev 1
619/692
UM1785
uint8_t Address
Field Documentation
41.1.4
UART_HandleTypeDef
UART_HandleTypeDef is defined in the stm32f0xx_hal_uart.h
Data Fields
USART_TypeDef * Instance
UART_InitTypeDef Init
UART_AdvFeatureInitTypeDef AdvancedInit
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_UART_StateTypeDef State
HAL_UART_ErrorTypeDef ErrorCode
Field Documentation
620/692
USART_TypeDef* UART_HandleTypeDef::Instance
UART_InitTypeDef UART_HandleTypeDef::Init
UART_AdvFeatureInitTypeDef UART_HandleTypeDef::AdvancedInit
uint8_t* UART_HandleTypeDef::pTxBuffPtr
uint16_t UART_HandleTypeDef::TxXferSize
uint16_t UART_HandleTypeDef::TxXferCount
uint8_t* UART_HandleTypeDef::pRxBuffPtr
uint16_t UART_HandleTypeDef::RxXferSize
uint16_t UART_HandleTypeDef::RxXferCount
uint16_t UART_HandleTypeDef::Mask
DMA_HandleTypeDef* UART_HandleTypeDef::hdmatx
DMA_HandleTypeDef* UART_HandleTypeDef::hdmarx
HAL_LockTypeDef UART_HandleTypeDef::Lock
HAL_UART_StateTypeDef UART_HandleTypeDef::State
HAL_UART_ErrorTypeDef UART_HandleTypeDef::ErrorCode
DocID026525 Rev 1
UM1785
41.2
41.2.1
3.
4.
5.
6.
7.
8.
Configure the declared DMA handle structure with the required Tx/Rx
parameters.
Associate the initilalized DMA handle to the UART 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 , Stop Bit, Parity, Hardware flow control and
Mode(Receiver/Transmitter) in the huart Init structure.
If required, program UART advanced features (TX/RX pins swap, auto Baud rate
detection,...) in the huart AdvancedInit structure.
For the UART asynchronous mode, initialize the UART registers by calling the
HAL_UART_Init() API.
For the UART Half duplex mode, initialize the UART registers by calling the
HAL_HalfDuplex_Init() API.
For the UART Multiprocessor mode, initialize the UART registers by calling the
HAL_MultiProcessor_Init() API.
For the UART RS485 Driver Enabled mode, initialize the UART registers by calling
the HAL_RS485Ex_Init() API.
The specific UART interrupts (Transmission complete interrupt, RXNE interrupt
and Error Interrupts) will be managed using the macros
__HAL_UART_ENABLE_IT() and __HAL_UART_DISABLE_IT() inside the
transmit and receive process.
621/692
UM1785
622/692
DocID026525 Rev 1
UM1785
41.2.2
Baud Rate
Word Length
Stop Bit
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), the possible UART frame formats are
as listed in the below table.
Receiver/transmitter modes
PCE bit
UART frame
00
00
01
01
10
10
DocID026525 Rev 1
623/692
41.2.3
HAL_UART_Init()
HAL_HalfDuplex_Init()
HAL_MultiProcessor_Init()
HAL_UART_DeInit()
HAL_UART_MspInit()
HAL_UART_MspDeInit()
IO operation functions
This subsection provides a set of functions allowing to manage the UART asynchronous
and Half duplex data transfers.
1.
2.
3.
4.
5.
HAL_UART_Transmit()
HAL_UART_Receive()
Non Blocking mode APIs with Interrupt are :
HAL_UART_Transmit_IT()
HAL_UART_Receive_IT()
HAL_UART_IRQHandler()
UART_Transmit_IT()
UART_Receive_IT()
Non Blocking mode APIs with DMA are :
HAL_UART_Transmit_DMA()
HAL_UART_Receive_DMA()
HAL_UART_DMAPause()
HAL_UART_DMAResume()
HAL_UART_DMAStop()
A set of Transfer Complete Callbacks are provided in non blocking mode:
HAL_UART_TxHalfCpltCallback()
HAL_UART_TxCpltCallback()
HAL_UART_RxHalfCpltCallback()
HAL_UART_RxCpltCallback()
HAL_UART_ErrorCallback()
In the Half duplex communication, it is forbidden to run the transmit and receive
process in parallel, the UART state HAL_UART_STATE_BUSY_TX_RX can't be
useful.
624/692
DocID026525 Rev 1
UM1785
41.2.4
HAL_UART_Transmit()
HAL_UART_Receive()
HAL_UART_Transmit_IT()
HAL_UART_Receive_IT()
HAL_UART_Transmit_DMA()
HAL_UART_Receive_DMA()
HAL_UART_DMAPause()
HAL_UART_DMAResume()
HAL_UART_DMAStop()
HAL_UART_TxCpltCallback()
HAL_UART_TxHalfCpltCallback()
HAL_UART_RxCpltCallback()
HAL_UART_RxHalfCpltCallback()
HAL_UART_ErrorCallback()
41.2.5
HAL_UART_Init
Function Name
Function Description
Parameters
625/692
41.2.6
41.2.7
UM1785
HAL status
None.
HAL_HalfDuplex_Init
Function Name
HAL_StatusTypeDef HAL_HalfDuplex_Init (
UART_HandleTypeDef * huart)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_MultiProcessor_Init
Function Name
HAL_StatusTypeDef HAL_MultiProcessor_Init (
UART_HandleTypeDef * huart, uint8_t Address, uint32_t
WakeUpMethod)
Function Description
Parameters
UART_WAKEUPMETHOD_IDLELINE WakeUp by an
idle line detection
UART_WAKEUPMETHOD_ADDRESSMARK WakeUp
by an address mark
Return values
HAL status
Notes
If the user resorts to idle line detection wake up, the Address
parameter is useless and ignored by the initialization function.
If the user resorts to address mark wake up, the address
length detection is configured by default to 4 bits only. For the
UART to be able to manage 6-, 7- or 8-bit long addresses
626/692
DocID026525 Rev 1
UM1785
41.2.8
41.2.9
41.2.10
HAL_UART_DeInit
Function Name
HAL_StatusTypeDef HAL_UART_DeInit (
UART_HandleTypeDef * huart)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_UART_MspInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_UART_MspDeInit
Function Name
Function Description
Parameters
Return values
None.
DocID026525 Rev 1
627/692
41.2.11
41.2.12
41.2.13
628/692
UM1785
None.
HAL_UART_Transmit
Function Name
HAL_StatusTypeDef HAL_UART_Transmit (
UART_HandleTypeDef * huart, uint8_t * pData, uint16_t Size,
uint32_t Timeout)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_UART_Receive
Function Name
HAL_StatusTypeDef HAL_UART_Receive (
UART_HandleTypeDef * huart, uint8_t * pData, uint16_t Size,
uint32_t Timeout)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_UART_Transmit_IT
DocID026525 Rev 1
UM1785
41.2.14
41.2.15
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_UART_Receive_IT
Function Name
HAL_StatusTypeDef HAL_UART_Receive_IT (
UART_HandleTypeDef * huart, uint8_t * pData, uint16_t Size)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_UART_Transmit_DMA
Function Name
HAL_StatusTypeDef HAL_UART_Transmit_DMA (
UART_HandleTypeDef * huart, uint8_t * pData, uint16_t Size)
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
629/692
41.2.16
41.2.17
41.2.18
630/692
UM1785
HAL_UART_Receive_DMA
Function Name
HAL_StatusTypeDef HAL_UART_Receive_DMA (
UART_HandleTypeDef * huart, uint8_t * pData, uint16_t Size)
Function Description
Parameters
Return values
HAL status
Notes
HAL_UART_DMAPause
Function Name
HAL_StatusTypeDef HAL_UART_DMAPause (
UART_HandleTypeDef * huart)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_UART_DMAResume
Function Name
HAL_StatusTypeDef HAL_UART_DMAResume (
UART_HandleTypeDef * huart)
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
UM1785
41.2.19
41.2.20
41.2.21
HAL_UART_DMAStop
Function Name
HAL_StatusTypeDef HAL_UART_DMAStop (
UART_HandleTypeDef * huart)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_UART_TxCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_UART_TxHalfCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
631/692
41.2.22
41.2.23
41.2.24
632/692
UM1785
HAL_UART_RxCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_UART_RxHalfCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_UART_ErrorCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
UM1785
41.2.25
41.2.26
41.2.27
HAL_MultiProcessor_EnableMuteMode
Function Name
HAL_StatusTypeDef HAL_MultiProcessor_EnableMuteMode (
UART_HandleTypeDef * huart)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_MultiProcessor_DisableMuteMode
Function Name
HAL_StatusTypeDef HAL_MultiProcessor_DisableMuteMode (
UART_HandleTypeDef * huart)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_MultiProcessor_EnterMuteMode
Function Name
void HAL_MultiProcessor_EnterMuteMode (
UART_HandleTypeDef * huart)
Function Description
633/692
41.2.28
41.2.29
41.2.30
634/692
UM1785
Return values
HAL status
Notes
None.
HAL_HalfDuplex_EnableTransmitter
Function Name
HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter (
UART_HandleTypeDef * huart)
Function Description
Parameters
Return values
HAL.
Notes
None.
HAL_HalfDuplex_EnableReceiver
Function Name
HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver (
UART_HandleTypeDef * huart)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_UART_GetState
Function Name
HAL_UART_StateTypeDef HAL_UART_GetState (
UART_HandleTypeDef * huart)
Function Description
DocID026525 Rev 1
UM1785
41.2.31
Return values
HAL state
Notes
None.
HAL_UART_GetError
Function Name
Function Description
Parameters
Return values
Notes
None.
41.3
41.3.1
UART
UART
UART Advanced Feature Initialization Type
UART_ADVFEATURE_NO_INIT
UART_ADVFEATURE_TXINVERT_INIT
UART_ADVFEATURE_RXINVERT_INIT
UART_ADVFEATURE_DATAINVERT_INIT
UART_ADVFEATURE_SWAP_INIT
UART_ADVFEATURE_RXOVERRUNDISABLE_INIT
UART_ADVFEATURE_DMADISABLEONERROR_INIT
UART_ADVFEATURE_AUTOBAUDRATE_INIT
UART_ADVFEATURE_MSBFIRST_INIT
IS_UART_ADVFEATURE_INIT
UART Advanced Feature Auto BaudRate Enable
UART_ADVFEATURE_AUTOBAUDRATE_DISABLE
DocID026525 Rev 1
635/692
UM1785
IS_UART_ADVFEATURE_AUTOBAUDRATE
UART Driver Enable Assertion Time LSB Position In CR1 Register
UART_CR1_DEAT_ADDRESS_LSB_POS
UART Driver Enable DeAssertion Time LSB Position In CR1 Register
UART_CR1_DEDT_ADDRESS_LSB_POS
UART Address-matching LSB Position In CR2 Register
UART_CR2_ADDRESS_LSB_POS
UART Advanced Feature Binary Data Inversion
UART_ADVFEATURE_DATAINV_DISABLE
UART_ADVFEATURE_DATAINV_ENABLE
IS_UART_ADVFEATURE_DATAINV
UART Advanced Feature DMA Disable On Rx Error
UART_ADVFEATURE_DMA_ENABLEONRXERROR
UART_ADVFEATURE_DMA_DISABLEONRXERROR
IS_UART_ADVFEATURE_DMAONRXERROR
UART DMA Rx
UART_DMA_RX_DISABLE
UART_DMA_RX_ENABLE
IS_UART_DMA_RX
UART DMA Tx
UART_DMA_TX_DISABLE
UART_DMA_TX_ENABLE
IS_UART_DMA_TX
UART DriverEnable Polarity
UART_DE_POLARITY_HIGH
UART_DE_POLARITY_LOW
IS_UART_DE_POLARITY
UART Exported Macros
__HAL_UART_RESET_HANDLE_STA
TE
Description:
Parameters:
Return value:
__HAL_UART_GET_FLAG
Description:
636/692
None:
DocID026525 Rev 1
UM1785
UART_FLAG_TC: Transmission
Complete flag
Return value:
DocID026525 Rev 1
637/692
UM1785
Description:
Parameters:
Return value:
__HAL_UART_DISABLE_IT
None:
Description:
Parameters:
638/692
DocID026525 Rev 1
UM1785
Return value:
__HAL_UART_GET_IT
None:
Description:
Parameters:
DocID026525 Rev 1
639/692
UM1785
Return value:
__HAL_UART_GET_IT_SOURCE
Description:
Parameters:
Return value:
__HAL_UART_CLEAR_IT
Description:
Parameters:
640/692
DocID026525 Rev 1
UM1785
UART_CLEAR_TCF: Transmission
Complete Clear Flag
__HAL_UART_SEND_REQ
None:
Description:
Parameters:
UART_SENDBREAK_REQUEST:
Send Break Request
UART_MUTE_MODE_REQUEST:
Mute Mode Request
UART_RXDATA_FLUSH_REQUEST:
Receive Data flush Request
UART_TXDATA_FLUSH_REQUEST:
DocID026525 Rev 1
641/692
UM1785
Transmit data flush Request (not
available on F030xx devices)
Return value:
__HAL_UART_ENABLE
None:
Description:
Enable UART.
Parameters:
Return value:
__HAL_UART_DISABLE
None:
Description:
Disable UART.
Parameters:
Return value:
None:
642/692
DocID026525 Rev 1
UM1785
DocID026525 Rev 1
643/692
UM1785
Framing Error Clear Flag
UART_CLEAR_NEF
UART_CLEAR_OREF
UART_CLEAR_IDLEF
UART_CLEAR_TCF
UART_CLEAR_LBDF
UART_CLEAR_CTSF
UART_CLEAR_RTOF
UART_CLEAR_EOBF
UART_CLEAR_CMF
UART_CLEAR_WUF
DocID026525 Rev 1
UM1785
__DIV_SAMPLING8
Parameters:
Return value:
Division: result
Description:
__DIV_SAMPLING16
Parameters:
Return value:
Division: result
Description:
IS_UART_BAUDRATE
Parameters:
Return value:
IS_UART_ASSERTIONTIME
Description:
DocID026525 Rev 1
645/692
UM1785
Parameters:
Return value:
IS_UART_DEASSERTIONTIME
Description:
Parameters:
Return value:
UART_SENDBREAK_REQUEST
UART_MUTE_MODE_REQUEST
UART_RXDATA_FLUSH_REQUEST
UART_TXDATA_FLUSH_REQUEST
IS_UART_REQUEST_PARAMETER
UART Advanced Feature RX Pin Active Level Inversion
UART_ADVFEATURE_RXINV_DISABLE
UART_ADVFEATURE_RXINV_ENABLE
IS_UART_ADVFEATURE_RXINV
UART Advanced Feature RX TX Pins Swap
UART_ADVFEATURE_SWAP_DISABLE
UART_ADVFEATURE_SWAP_ENABLE
IS_UART_ADVFEATURE_SWAP
UART State
UART_STATE_DISABLE
UART_STATE_ENABLE
IS_UART_STATE
UART Number of Stop Bits
UART_STOPBITS_1
646/692
DocID026525 Rev 1
UM1785
DocID026525 Rev 1
647/692
UM1785
42
42.1
42.1.1
Baud Rate
Stop Bit
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), the possible UART frame formats are
as listed in the following table: |-----------|-----------|---------------------------------------| |
M1M0 bits | PCE bit | UART frame | |-----------------------|--------------------------------------| | 00 | 0 | | SB | 8-bit data | STB | | |-----------|-----------|--------------------------------------| | 00 | 1 | | SB | 7-bit data | PB | STB | | |-----------|-----------|--------------------------------------| | 01 | 0 | | SB | 9-bit data | STB | | |-----------|-----------|--------------------------------------| | 01 | 1 | | SB | 8-bit data | PB | STB | | +--------------------------------------------------------------+ | 10 | 0 | | SB | 7-bit data | STB | | |-----------|-----------|--------------------------------------| | 10 | 1 | | SB | 6-bit data | PB | STB | | +--------------------------------------------------------------+
Receiver/transmitter modes
The HAL_LIN_Init() and HAL_RS485Ex_Init() APIs follows respectively the LIN and the
UART RS485 mode configuration procedures (details for the procedures are available in
reference manual).
42.1.2
648/692
HAL_RS485Ex_Init()
HAL_LIN_Init()
IO operation function
DocID026525 Rev 1
UM1785
42.1.3
HAL_UART_IRQHandler()
Callback provided in No_Blocking mode:
HAL_UART_WakeupCallback()
HAL_UART_IRQHandler()
HAL_UART_WakeupCallback()
42.1.4
HAL_RS485Ex_Init
Function Name
HAL_StatusTypeDef HAL_RS485Ex_Init (
UART_HandleTypeDef * huart, uint32_t UART_DEPolarity,
uint32_t UART_DEAssertionTime, uint32_t
UART_DEDeassertionTime)
Function Description
Parameters
649/692
42.1.5
42.1.6
650/692
UM1785
the DE (Driver Enable) signal. It is expressed in sample time
units (1/8 or 1/16 bit time, depending on the oversampling
rate).
Return values
HAL status
Notes
None.
HAL_LIN_Init
Function Name
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_UART_IRQHandler
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
UM1785
42.1.7
42.1.8
42.1.9
HAL_UART_WakeupCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_UARTEx_StopModeWakeUpSourceConfig
Function Name
HAL_StatusTypeDef
HAL_UARTEx_StopModeWakeUpSourceConfig (
UART_HandleTypeDef * huart, UART_WakeUpTypeDef
WakeUpSelection)
Function Description
Parameters
UART_WAKEUP_ON_ADDRESS
UART_WAKEUP_ON_STARTBIT
UART_WAKEUP_ON_READDATA_NONEMPTY
Return values
HAL status
Notes
None.
HAL_UARTEx_EnableStopMode
Function Name
HAL_StatusTypeDef HAL_UARTEx_EnableStopMode (
UART_HandleTypeDef * huart)
Function Description
Enable UART Stop Mode The UART is able to wake up the MCU
from Stop mode as long as UART clock is HSI or LSE.
DocID026525 Rev 1
651/692
42.1.10
42.1.11
42.1.12
652/692
UM1785
Return values
HAL status
Notes
None.
HAL_UARTEx_DisableStopMode
Function Name
HAL_StatusTypeDef HAL_UARTEx_DisableStopMode (
UART_HandleTypeDef * huart)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_MultiProcessorEx_AddressLength_Set
Function Name
HAL_StatusTypeDef
HAL_MultiProcessorEx_AddressLength_Set (
UART_HandleTypeDef * huart, uint32_t AddressLength)
Function Description
Notes
None.
HAL_LIN_SendBreak
Function Name
HAL_StatusTypeDef HAL_LIN_SendBreak (
UART_HandleTypeDef * huart)
Function Description
DocID026525 Rev 1
UM1785
Return values
HAL status
Notes
None.
42.2
42.2.1
UARTEx
UARTEx
UARTEx Advanced Feature AutoBaud Rate Mode
UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT
UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE
UART_ADVFEATURE_AUTOBAUDRATE_ON0X7FFRAME
UART_ADVFEATURE_AUTOBAUDRATE_ON0X55FRAME
IS_UART_ADVFEATURE_AUTOBAUDRATEMODE
UARTEx Exported Macros
__HAL_UART_GETCLOCKSOURCE
Description:
Parameters:
Return value:
__HAL_UART_MASK_COMPUTATION
Description:
Parameters:
Return value:
none:
653/692
654/692
DocID026525 Rev 1
UM1785
UM1785
43
43.1
43.1.1
USART_InitTypeDef
USART_InitTypeDef is defined in the stm32f0xx_hal_usart.h
Data Fields
uint32_t BaudRate
uint32_t WordLength
uint32_t StopBits
uint32_t Parity
uint32_t Mode
uint32_t CLKPolarity
uint32_t CLKPhase
uint32_t CLKLastBit
Field Documentation
43.1.2
USART_HandleTypeDef
USART_HandleTypeDef is defined in the stm32f0xx_hal_usart.h
Data Fields
USART_TypeDef * Instance
USART_InitTypeDef Init
DocID026525 Rev 1
655/692
UM1785
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_USART_StateTypeDef State
HAL_USART_ErrorTypeDef ErrorCode
Field Documentation
43.2
43.2.1
656/692
UM1785
Configure the declared DMA handle structure with the required Tx/Rx
parameters.
Associate the initilalized DMA handle to the USART 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 , Stop Bit, Parity, Hardware flow control and
Mode(Receiver/Transmitter) in the husart Init structure.
Initialize the USART registers by calling the HAL_USART_Init() API:
These APIs configures also the low level Hardware GPIO, CLOCK,
CORTEX...etc) by calling the customed HAL_USART_MspInit(&husart) API. The
specific USART interrupts (Transmission complete interrupt, RXNE interrupt and
Error Interrupts) will be managed using the macros
__HAL_USART_ENABLE_IT() and __HAL_USART_DISABLE_IT() inside the
transmit and receive process.
Three operation modes are available within this driver :
c.
3.
4.
5.
DocID026525 Rev 1
657/692
UM1785
43.2.2
658/692
Baud Rate
Word Length
Stop Bit
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 USART frame formats are as listed in the below table.
DocID026525 Rev 1
UM1785
USART polarity
USART phase
USART LastBit
Receiver/transmitter modes
Table 24: USART frame formats
M bit
PCE bit
USART frame
M1, M0 bits
PCE bit
USART frame
10
10
43.2.3
HAL_USART_Init()
HAL_USART_DeInit()
HAL_USART_MspInit()
HAL_USART_MspDeInit()
HAL_USART_CheckIdleState()
IO operation functions
This subsection provides a set of functions allowing to manage the USART synchronous
data transfers.
The USART supports master mode only: it cannot receive or send data related to an input
clock (SCLK is always an output).
1.
2.
3.
659/692
4.
5.
43.2.4
UM1785
HAL_USART_IRQHandler()
Non Blocking mode functions with DMA are :
HAL_USART_DMAPause()
HAL_USART_DMAResume()
HAL_USART_DMAStop()
A set of Transfer Complete Callbacks are provided in non Blocking mode:
HAL_USART_TxCpltCallback()
HAL_USART_RxCpltCallback()
HAL_USART_TxHalfCpltCallback()
HAL_USART_RxHalfCpltCallback()
HAL_USART_ErrorCallback()
HAL_USART_TxRxCpltCallback()
HAL_USART_Transmit()
HAL_USART_Receive()
HAL_USART_TransmitReceive()
HAL_USART_Transmit_IT()
HAL_USART_Receive_IT()
HAL_USART_TransmitReceive_IT()
HAL_USART_Transmit_DMA()
HAL_USART_Receive_DMA()
HAL_USART_TransmitReceive_DMA()
HAL_USART_DMAPause()
HAL_USART_DMAResume()
HAL_USART_DMAStop()
HAL_USART_IRQHandler()
HAL_USART_TxCpltCallback()
HAL_USART_TxHalfCpltCallback()
HAL_USART_RxCpltCallback()
HAL_USART_RxHalfCpltCallback()
HAL_USART_TxRxCpltCallback()
HAL_USART_ErrorCallback()
43.2.5
660/692
HAL_USART_Init
DocID026525 Rev 1
UM1785
Function Name
43.2.6
43.2.7
43.2.8
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_USART_DeInit
Function Name
HAL_StatusTypeDef HAL_USART_DeInit (
USART_HandleTypeDef * husart)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_USART_MspInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_USART_MspDeInit
DocID026525 Rev 1
661/692
43.2.9
UM1785
void HAL_USART_MspDeInit ( USART_HandleTypeDef *
husart)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_USART_CheckIdleState
Function Name
HAL_StatusTypeDef HAL_USART_CheckIdleState (
USART_HandleTypeDef * husart)
Function Description
Notes
43.2.10
43.2.11
662/692
None.
HAL_USART_Transmit
Function Name
HAL_StatusTypeDef HAL_USART_Transmit (
USART_HandleTypeDef * husart, uint8_t * pTxData, uint16_t
Size, uint32_t Timeout)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_USART_Receive
DocID026525 Rev 1
UM1785
Function Name
43.2.12
43.2.13
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_USART_TransmitReceive
Function Name
HAL_StatusTypeDef HAL_USART_TransmitReceive (
USART_HandleTypeDef * husart, uint8_t * pTxData, uint8_t *
pRxData, uint16_t Size, uint32_t Timeout)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_USART_Transmit_IT
Function Name
HAL_StatusTypeDef HAL_USART_Transmit_IT (
USART_HandleTypeDef * husart, uint8_t * pTxData, uint16_t
Size)
Function Description
Parameters
663/692
43.2.14
43.2.15
664/692
UM1785
Return values
HAL status
Notes
None.
HAL_USART_Receive_IT
Function Name
HAL_StatusTypeDef HAL_USART_Receive_IT (
USART_HandleTypeDef * husart, uint8_t * pRxData, uint16_t
Size)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_USART_TransmitReceive_IT
Function Name
HAL_StatusTypeDef HAL_USART_TransmitReceive_IT (
USART_HandleTypeDef * husart, uint8_t * pTxData, uint8_t *
pRxData, uint16_t Size)
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
UM1785
43.2.16
43.2.17
HAL_USART_Transmit_DMA
Function Name
HAL_StatusTypeDef HAL_USART_Transmit_DMA (
USART_HandleTypeDef * husart, uint8_t * pTxData, uint16_t
Size)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_USART_Receive_DMA
Function Name
HAL_StatusTypeDef HAL_USART_Receive_DMA (
USART_HandleTypeDef * husart, uint8_t * pRxData, uint16_t
Size)
Function Description
Parameters
Return values
HAL status
Notes
43.2.18
HAL_USART_TransmitReceive_DMA
Function Name
HAL_StatusTypeDef HAL_USART_TransmitReceive_DMA (
USART_HandleTypeDef * husart, uint8_t * pTxData, uint8_t *
DocID026525 Rev 1
665/692
UM1785
pRxData, uint16_t Size)
43.2.19
43.2.20
666/692
Function Description
Parameters
Return values
HAL status
Notes
HAL_USART_DMAPause
Function Name
HAL_StatusTypeDef HAL_USART_DMAPause (
USART_HandleTypeDef * husart)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_USART_DMAResume
Function Name
HAL_StatusTypeDef HAL_USART_DMAResume (
USART_HandleTypeDef * husart)
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
UM1785
43.2.21
43.2.22
43.2.23
HAL_USART_DMAStop
Function Name
HAL_StatusTypeDef HAL_USART_DMAStop (
USART_HandleTypeDef * husart)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_USART_IRQHandler
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_USART_TxCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
667/692
43.2.24
43.2.25
43.2.26
668/692
UM1785
HAL_USART_TxHalfCpltCallback
Function Name
void HAL_USART_TxHalfCpltCallback (
USART_HandleTypeDef * husart)
Function Description
Parameters
Return values
None.
Notes
None.
HAL_USART_RxCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_USART_RxHalfCpltCallback
Function Name
void HAL_USART_RxHalfCpltCallback (
USART_HandleTypeDef * husart)
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
UM1785
43.2.27
43.2.28
43.2.29
HAL_USART_TxRxCpltCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_USART_ErrorCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_USART_GetState
Function Name
HAL_USART_StateTypeDef HAL_USART_GetState (
USART_HandleTypeDef * husart)
Function Description
Parameters
Return values
HAL state
Notes
None.
DocID026525 Rev 1
669/692
43.2.30
UM1785
HAL_USART_GetError
Function Name
Function Description
Parameters
Return values
Notes
None.
43.3
43.3.1
USART
USART
USART Clock
USART_CLOCK_DISABLED
USART_CLOCK_ENABLED
IS_USART_CLOCK
USART Clock Phase
USART_PHASE_1EDGE
USART_PHASE_2EDGE
IS_USART_PHASE
USART Clock Polarity
USART_POLARITY_LOW
USART_POLARITY_HIGH
IS_USART_POLARITY
USART Exported Macros
__HAL_USART_RESET_HANDLE_ST
ATE
Description:
Parameters:
Return value:
670/692
None:
DocID026525 Rev 1
UM1785
__HAL_USART_GET_FLAG
Parameters:
USART_FLAG_REACK: Receive
enable ackowledge flag
USART_FLAG_TEACK: Transmit
enable ackowledge flag
USART_FLAG_TC: Transmission
Complete flag
Return value:
__HAL_USART_ENABLE_IT
Description:
Parameters:
USART_IT_TC: Transmission
complete interrupt
DocID026525 Rev 1
671/692
UM1785
Return value:
__HAL_USART_DISABLE_IT
None:
Description:
Parameters:
USART_IT_TC: Transmission
complete interrupt
Return value:
__HAL_USART_GET_IT
None:
Description:
Parameters:
USART_IT_TC: Transmission
complete interrupt
Return value:
672/692
DocID026525 Rev 1
UM1785
Description:
Parameters:
USART_IT_TC: Transmission
complete interrupt
Return value:
__HAL_USART_CLEAR_IT
Description:
Parameters:
USART_CLEAR_OREF: OverRun
Error Clear Flag
USART_CLEAR_TCF: Transmission
Complete Clear Flag
Return value:
DocID026525 Rev 1
673/692
UM1785
__HAL_USART_SEND_REQ
None:
Description:
Parameters:
USART_RXDATA_FLUSH_REQUEST
: Receive Data flush Request
USART_TXDATA_FLUSH_REQUEST:
Transmit data flush Request
Return value:
__HAL_USART_ENABLE
None:
Description:
Enable USART.
Parameters:
Return value:
__HAL_USART_DISABLE
None:
Description:
Disable USART.
Parameters:
Return value:
None:
USART Flags
USART_FLAG_REACK
USART_FLAG_TEACK
USART_FLAG_BUSY
USART_FLAG_CTS
USART_FLAG_CTSIF
USART_FLAG_LBDF
USART_FLAG_TXE
USART_FLAG_TC
USART_FLAG_RXNE
674/692
DocID026525 Rev 1
UM1785
USART_CLEAR_FEF
USART_CLEAR_NEF
USART_CLEAR_OREF
USART_CLEAR_IDLEF
USART_CLEAR_TCF
USART_CLEAR_CTSF
DocID026525 Rev 1
675/692
UM1785
USART_PARITY_ODD
IS_USART_PARITY
USART Private Constants
DUMMY_DATA
TEACK_REACK_TIMEOUT
USART_TXDMA_TIMEOUTVALUE
USART_TIMEOUT_VALUE
USART_CR1_FIELDS
USART_CR2_FIELDS
USART Private Macros
IS_USART_BAUDRATE
Description:
Parameters:
Return value:
USART_TXDATA_FLUSH_REQUEST
IS_USART_REQUEST_PARAMETER
USART Number of Stop Bits
USART_STOPBITS_1
USART_STOPBITS_2
USART_STOPBITS_1_5
IS_USART_STOPBITS
676/692
DocID026525 Rev 1
UM1785
44
44.1
44.1.1
USARTEx
USARTEx
USARTEx Exported Macros
__HAL_USART_GETCLOCKSOURCE
Description:
Parameters:
Return value:
__HAL_USART_MASK_COMPUTATION
Description:
Parameters:
Return value:
none:
DocID026525 Rev 1
677/692
UM1785
45
45.1
45.1.1
WWDG_InitTypeDef
WWDG_InitTypeDef is defined in the stm32f0xx_hal_wwdg.h
Data Fields
uint32_t Prescaler
uint32_t Window
uint32_t Counter
Field Documentation
45.1.2
WWDG_HandleTypeDef
WWDG_HandleTypeDef is defined in the stm32f0xx_hal_wwdg.h
Data Fields
WWDG_TypeDef * Instance
WWDG_InitTypeDef Init
HAL_LockTypeDef Lock
__IO HAL_WWDG_StateTypeDef State
Field Documentation
45.2
45.2.1
678/692
DocID026525 Rev 1
UM1785
45.2.2
An MCU reset is also generated if the counter value is refreshed before the counter
has reached the refresh window value. This implies that the counter must be refreshed
in a limited window.
Once enabled the WWDG cannot be disabled except by a system reset.
WWDGRST flag in RCC_CSR register can be used to inform when a WWDG reset
occurs.
The WWDG counter input clock is derived from the APB clock divided by a
programmable prescaler.
WWDG clock (Hz) = PCLK / (4096 * Prescaler)
WWDG timeout (mS) = 1000 * (T[5;0] + 1) / WWDG clock where T[5;0] are the lowest
6 bits of Counter.
WWDG Counter refresh is allowed between the following limits :
45.2.3
DocID026525 Rev 1
679/692
45.2.4
UM1785
IO operation functions
This section provides functions allowing to:
45.2.5
45.2.6
680/692
HAL_WWDG_GetState()
HAL_WWDG_Init
Function Name
HAL_StatusTypeDef HAL_WWDG_Init (
WWDG_HandleTypeDef * hwwdg)
Function Description
Parameters
Return values
HAL status
Notes
None.
DocID026525 Rev 1
UM1785
45.2.7
45.2.8
45.2.9
HAL_WWDG_DeInit
Function Name
HAL_StatusTypeDef HAL_WWDG_DeInit (
WWDG_HandleTypeDef * hwwdg)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_WWDG_MspInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_WWDG_MspDeInit
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
DocID026525 Rev 1
681/692
45.2.10
45.2.11
45.2.12
682/692
UM1785
HAL_WWDG_WakeupCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_WWDG_Start
Function Name
HAL_StatusTypeDef HAL_WWDG_Start (
WWDG_HandleTypeDef * hwwdg)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_WWDG_Start_IT
Function Name
HAL_StatusTypeDef HAL_WWDG_Start_IT (
WWDG_HandleTypeDef * hwwdg)
Function Description
DocID026525 Rev 1
UM1785
45.2.13
45.2.14
Return values
HAL status
Notes
None.
HAL_WWDG_Refresh
Function Name
HAL_StatusTypeDef HAL_WWDG_Refresh (
WWDG_HandleTypeDef * hwwdg, uint32_t Counter)
Function Description
Parameters
Return values
HAL status
Notes
None.
HAL_WWDG_IRQHandler
Function Name
Function Description
Parameters
Return values
None.
Notes
683/692
45.2.15
45.2.16
UM1785
HAL_WWDG_WakeupCallback
Function Name
Function Description
Parameters
Return values
None.
Notes
None.
HAL_WWDG_GetState
Function Name
HAL_WWDG_StateTypeDef HAL_WWDG_GetState (
WWDG_HandleTypeDef * hwwdg)
Function Description
Parameters
Return values
HAL state
Notes
None.
45.3
45.3.1
WWDG
WWDG
WWDG BitAddress AliasRegion
CFR_BASE
WWDG Counter
684/692
DocID026525 Rev 1
UM1785
Description:
Parameters:
Return value:
None:
Description:
__HAL_WWDG_ENABLE
Parameters:
Return value:
None:
Description:
__HAL_WWDG_GET_FLAG
Parameters:
WWDG_FLAG_EWIF: Early
wakeup interrupt flag
Return value:
__HAL_WWDG_CLEAR_FLAG
Description:
Parameters:
WWDG_FLAG_EWIF: Early
wakeup interrupt flag
Return value:
__HAL_WWDG_ENABLE_IT
None:
Description:
DocID026525 Rev 1
UM1785
Parameters:
Return value:
__HAL_WWDG_CLEAR_IT
None:
Description:
Parameters:
WWDG_FLAG_EWIF: Early
wakeup interrupt flag
WWDG_PRESCALER_2
WWDG_PRESCALER_4
WWDG_PRESCALER_8
IS_WWDG_PRESCALER
WWDG Window
IS_WWDG_WINDOW
686/692
DocID026525 Rev 1
UM1785
46
FAQs
FAQs
General subjects
Why should I use the HAL drivers?
There are many advantages in using the HAL drivers:
Ease of use: you can use the HAL drivers to configure and control any peripheral
embedded within your STM32 MCU without prior in-depth knowledge of the product.
HAL drivers provide intuitive and ready-to-use APIs to configure the peripherals and
support polling, interrupt and DMA programming model to accommodate all
application requirements, thus allowing the end-user to build a complete application by
calling a few APIs.
Higher level of abstraction than a standard peripheral library allowing to transparently
manage:
What is the cost of using HAL drivers in term of code size and performance?
Like generic architecture drivers, the HAL drivers may induce firmware overhead.
This is due to the high abstraction level and ready-to-use APIs which allow data transfers,
errors management and offloads the user application from implementation details.
Architecture
How many files should I modify to configure the HAL drivers?
Only one file needs to be modified: stm32f0xx_hal_conf.h. You can modify this file by
disabling unused modules, or adjusting some parameters (i.e. HSE value, System
configuration, )
DocID026525 Rev 1
687/692
FAQs
UM1785
A template is provided in the HAL drivers folders (stm32f0xx_hal_conf_template.c).
The generic APIs (stm32f0xx_hal_ppp.c): It includes the common set of APIs across
all the STM32 product lines
The extension APIs (stm32f0xx_hal_ppp_ex.c): It includes the specific APIs for
specific device part number or family.
When and how should I use callbacks functions (functions declared with the
attribute __weak)?
Use callback functions for the I/O operations used in DMA or interrupt mode. The PPP
process complete callbacks are called to inform the user about process completion in realtime event mode (interrupts).
The Errors callbacks are called when a processing error occurs in DMA or interrupt mode.
These callbacks are customized by the user to add user proprietary code. They can be
declared in the application. Note that the same process completion callbacks are used for
DMA and interrupt mode.
688/692
DocID026525 Rev 1
UM1785
FAQs
Why do I need to configure the SysTick timer to use the HAL drivers?
The SysTick timer is configured to be used to generate variable increments by calling
HAL_IncTick() function in Systick ISR and retrieve the value of this variable by calling
HAL_GetTick() function.
The call HAL_GetTick() function is mandatory when using HAL drivers with Polling
Process or when using HAL_Delay().
Call HAL_Init() function to initialize the system (data cache, NVIC priority,).
Initialize the system clock by calling HAL_RCC_OscConfig() followed by
HAL_RCC_ClockConfig().
Add HAL_IncTick() function under SysTick_Handler() ISR function to enable polling
process when using HAL_Delay() function
Start initializing your peripheral by calling HAL_PPP_Init().
Implement the hardware low level initialization (Peripheral clock, GPIO, DMA,..) by
calling HAL_PPP_MspInit() in stm32f0xx_hal_msp.c
Start your process operation by calling IO operation functions.
689/692
FAQs
UM1785
690/692
DocID026525 Rev 1
UM1785
47
Revision history
Revision history
Table 25: Document revision history
Date
Revision
Changes
21-Nov-2014
Initial release.
DocID026525 Rev 1
691/692
UM1785
STMicroelectronics NV and its subsidiaries (ST) reserve the right to make changes, corrections, enhancements, modifications, and
improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on ST
products before placing orders. ST products are sold pursuant to STs terms and conditions of sale in place at the time of order
acknowledgement.
Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or the
design of Purchasers products.
Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product.
ST and the ST logo are trademarks of ST. All other product or service names are the property of their respective owners.
Information in this document supersedes and replaces information previously supplied in any prior versions of this document.
692/692
DocID026525 Rev 1