Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
cubexHal.pdf
Скачиваний:
110
Добавлен:
10.02.2016
Размер:
16.16 Mб
Скачать

UM1725

HAL WWDG Generic Driver

62.2WWDG Firmware driver API description

62.2.1WWDG specific features

Once enabled the WWDG generates a system reset on expiry of a programmed time period, unless the program refreshes the counter (downcounter) before reaching 0x3F value (i.e. a reset is generated when the counter value rolls over from 0x40 to 0x3F).

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) = PCLK1 / (4096 * Prescaler)

WWDG timeout (mS) = 1000 * Counter / WWDG clock

WWDG Counter refresh is allowed between the following limits :

min time (mS) = 1000 * (Counter _ Window) / WWDG clock

max time (mS) = 1000 * (Counter _ 0x40) / WWDG clock

Min-max timeout value at 50 MHz(PCLK1): 81.9 us / 41.9 ms

62.2.2How to use this driver

Enable WWDG APB1 clock using __HAL_RCC_WWDG_CLK_ENABLE().

Set the WWDG prescaler, refresh window and counter value using

HAL_WWDG_Init() function.

Start the WWDG using HAL_WWDG_Start() function. When the WWDG is enabled the counter value should be configured to a value greater than 0x40 to prevent generating an immediate reset.

Optionally you can enable the Early Wakeup Interrupt (EWI) which is generated when the counter reaches 0x40, and then start the WWDG using HAL_WWDG_Start_IT(). At EWI HAL_WWDG_WakeupCallback is executed and user can add his own code by customization of function pointer HAL_WWDG_WakeupCallback Once enabled, EWI interrupt cannot be disabled except by a system reset.

Then the application program must refresh the WWDG counter at regular intervals during normal operation to prevent an MCU reset, using HAL_WWDG_Refresh() function. This operation must occur only when the counter is lower than the refresh window value already programmed.

WWDG HAL driver macros list

Below the list of most used macros in WWDG HAL driver.

__HAL_WWDG_ENABLE: Enable the WWDG peripheral

__HAL_WWDG_GET_FLAG: Get the selected WWDG's flag status

__HAL_WWDG_CLEAR_FLAG: Clear the WWDG's pending flags

__HAL_WWDG_ENABLE_IT: Enables the WWDG early wake-up interrupt

62.2.3Initialization and de-initialization functions

This section provides functions allowing to:

DOCID025834 Rev 2

887/900

HAL WWDG Generic Driver

UM1725

Initialize the WWDG according to the specified parameters in the WWDG_InitTypeDef and create the associated handle

DeInitialize the WWDG peripheral

Initialize the WWDG MSP

DeInitialize the WWDG MSP

This section contains the following APIs:

HAL_WWDG_Init()

HAL_WWDG_DeInit()

HAL_WWDG_MspInit()

HAL_WWDG_MspDeInit()

HAL_WWDG_WakeupCallback()

62.2.4IO operation functions

This section provides functions allowing to:

Start the WWDG.

Refresh the WWDG.

Handle WWDG interrupt request.

This section contains the following APIs:

HAL_WWDG_Start()

HAL_WWDG_Start_IT()

HAL_WWDG_Refresh()

HAL_WWDG_IRQHandler()

HAL_WWDG_WakeupCallback()

62.2.5Peripheral State functions

This subsection permits to get in run-time the status of the peripheral and the data flow.

This section contains the following APIs:

HAL_WWDG_GetState()

62.2.6HAL_WWDG_Init

Function Name

HAL_StatusTypeDef HAL_WWDG_Init

 

(WWDG_HandleTypeDef * hwwdg)

Function Description

Initializes the WWDG according to the specified parameters in the

 

WWDG_InitTypeDef and creates the associated handle.

Parameters

 

hwwdg: pointer to a WWDG_HandleTypeDef structure that

 

 

contains the configuration information for the specified

 

 

WWDG module.

Return values

 

HAL status

62.2.7HAL_WWDG_DeInit

Function Name

HAL_StatusTypeDef HAL_WWDG_DeInit

 

(WWDG_HandleTypeDef * hwwdg)

Function Description

DeInitializes the WWDG peripheral.

Parameters

hwwdg: pointer to a WWDG_HandleTypeDef structure that

 

contains the configuration information for the specified

888/900

DOCID025834 Rev 2

UM1725

HAL WWDG Generic Driver

 

WWDG module.

Return values

HAL status

62.2.8HAL_WWDG_MspInit

Function Name

void HAL_WWDG_MspInit (WWDG_HandleTypeDef * hwwdg)

Function Description

Initializes the WWDG MSP.

Parameters

 

hwwdg: pointer to a WWDG_HandleTypeDef structure that

 

 

contains the configuration information for the specified

 

 

WWDG module.

Return values

 

None

62.2.9HAL_WWDG_MspDeInit

Function Name

void HAL_WWDG_MspDeInit (WWDG_HandleTypeDef *

 

hwwdg)

Function Description

DeInitializes the WWDG MSP.

Parameters

 

hwwdg: pointer to a WWDG_HandleTypeDef structure that

 

 

contains the configuration information for the specified

 

 

WWDG module.

Return values

 

None

62.2.10HAL_WWDG_WakeupCallback

Function Name

void HAL_WWDG_WakeupCallback (WWDG_HandleTypeDef *

 

hwwdg)

Function Description

Early Wakeup WWDG callback.

Parameters

 

hwwdg: pointer to a WWDG_HandleTypeDef structure that

 

 

contains the configuration information for the specified

 

 

WWDG module.

Return values

 

None

62.2.11HAL_WWDG_Start

Function Name

HAL_StatusTypeDef HAL_WWDG_Start

 

(WWDG_HandleTypeDef * hwwdg)

Function Description

Starts the WWDG.

Parameters

 

hwwdg: pointer to a WWDG_HandleTypeDef structure that

 

 

contains the configuration information for the specified

 

 

WWDG module.

Return values

 

HAL status

62.2.12HAL_WWDG_Start_IT

Function Name

HAL_StatusTypeDef HAL_WWDG_Start_IT

 

 

(WWDG_HandleTypeDef * hwwdg)

 

Function Description

Starts the WWDG with interrupt enabled.

 

 

DOCID025834 Rev 2

889/900

HAL WWDG Generic Driver

 

UM1725

Parameters

 

hwwdg: pointer to a WWDG_HandleTypeDef structure that

 

 

contains the configuration information for the specified

 

 

WWDG module.

Return values

 

HAL status

62.2.13HAL_WWDG_Refresh

Function Name

HAL_StatusTypeDef HAL_WWDG_Refresh

 

(WWDG_HandleTypeDef * hwwdg, uint32_t Counter)

Function Description

Refreshes the WWDG.

Parameters

 

hwwdg: pointer to a WWDG_HandleTypeDef structure that

 

 

contains the configuration information for the specified

 

 

WWDG module.

 

Counter: value of counter to put in WWDG counter

Return values

 

HAL status

62.2.14HAL_WWDG_IRQHandler

Function Name

void HAL_WWDG_IRQHandler (WWDG_HandleTypeDef *

 

hwwdg)

Function Description

Handles WWDG interrupt request.

Parameters

 

hwwdg: pointer to a WWDG_HandleTypeDef structure that

 

 

contains the configuration information for the specified

 

 

WWDG module.

Return values

 

None

Notes

The Early Wakeup Interrupt (EWI) can be used if specific

safety operations or data logging must be performed before the actual reset is generated. The EWI interrupt is enabled using __HAL_WWDG_ENABLE_IT() macro. When the downcounter reaches the value 0x40, and EWI interrupt is generated and the corresponding Interrupt Service Routine (ISR) can be used to trigger specific actions (such as communications or data logging), before resetting the device.

62.2.15HAL_WWDG_WakeupCallback

Function Name

void HAL_WWDG_WakeupCallback (WWDG_HandleTypeDef *

 

hwwdg)

Function Description

Early Wakeup WWDG callback.

Parameters

 

hwwdg: pointer to a WWDG_HandleTypeDef structure that

 

 

contains the configuration information for the specified

 

 

WWDG module.

Return values

 

None

62.2.16HAL_WWDG_GetState

Function Name

HAL_WWDG_StateTypeDef HAL_WWDG_GetState

 

(WWDG_HandleTypeDef * hwwdg)

890/900

DOCID025834 Rev 2

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]