1 |
577 |
jeremybenn |
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
|
2 |
|
|
* File Name : wdg.h
|
3 |
|
|
* Author : MCD Application Team
|
4 |
|
|
* Date First Issued : 25/08/2003
|
5 |
|
|
* Description : This file contains all the functions prototypes for the
|
6 |
|
|
* WDG software library.
|
7 |
|
|
********************************************************************************
|
8 |
|
|
* History:
|
9 |
|
|
* 30/11/2004 : V2.0
|
10 |
|
|
* 14/07/2004 : V1.3
|
11 |
|
|
* 01/01/2004 : V1.2
|
12 |
|
|
*******************************************************************************
|
13 |
|
|
THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
|
14 |
|
|
CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
15 |
|
|
AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
|
16 |
|
|
OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
|
17 |
|
|
OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
|
18 |
|
|
CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
19 |
|
|
*******************************************************************************/
|
20 |
|
|
#ifndef __WDG_H
|
21 |
|
|
#define __WDG_H
|
22 |
|
|
|
23 |
|
|
#include "71x_map.h"
|
24 |
|
|
#include "rccu.h"
|
25 |
|
|
|
26 |
|
|
/*******************************************************************************
|
27 |
|
|
* Function Name : WDG_Enable
|
28 |
|
|
* Description : Enable the Watchdog Mode
|
29 |
|
|
* Input : None
|
30 |
|
|
* Return : None
|
31 |
|
|
*******************************************************************************/
|
32 |
|
|
inline void WDG_Enable ( void )
|
33 |
|
|
{
|
34 |
|
|
WDG->CR |= 0x01;
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
/*******************************************************************************
|
38 |
|
|
* Function Name : WDG_CntRefresh
|
39 |
|
|
* Description : Refresh and update the WDG counter to avoid a system reset.
|
40 |
|
|
* Input : None
|
41 |
|
|
* Return : None
|
42 |
|
|
*******************************************************************************/
|
43 |
|
|
inline void WDG_CntRefresh ( void )
|
44 |
|
|
{
|
45 |
|
|
//write the first value in the key register
|
46 |
|
|
WDG->KR = 0xA55A;
|
47 |
|
|
//write the consecutive value
|
48 |
|
|
WDG->KR = 0x5AA5;
|
49 |
|
|
}
|
50 |
|
|
|
51 |
|
|
/*******************************************************************************
|
52 |
|
|
* Function Name : WDG_PrescalerConfig
|
53 |
|
|
* Description : Set the counter prescaler value.
|
54 |
|
|
* Divide the counter clock by (Prescaler + 1)
|
55 |
|
|
* Input : Prescaler data value (8 bit)
|
56 |
|
|
* Return : None
|
57 |
|
|
*******************************************************************************/
|
58 |
|
|
inline void WDG_PrescalerConfig ( u8 Prescaler )
|
59 |
|
|
{
|
60 |
|
|
WDG->PR = Prescaler;
|
61 |
|
|
}
|
62 |
|
|
|
63 |
|
|
/*******************************************************************************
|
64 |
|
|
* Function Name : WDG_CntReloadUpdate
|
65 |
|
|
* Description : Update the counter pre-load value.
|
66 |
|
|
* Input : Pre-load data value (16 bit)
|
67 |
|
|
* Return : None
|
68 |
|
|
*******************************************************************************/
|
69 |
|
|
inline void WDG_CntReloadUpdate ( u16 PreLoadValue )
|
70 |
|
|
{
|
71 |
|
|
WDG->VR = PreLoadValue;
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
/*******************************************************************************
|
75 |
|
|
* Function Name : WDG_PeriodValueConfig
|
76 |
|
|
* Description : Set the prescaler and counter reload value based on the
|
77 |
|
|
* time needed
|
78 |
|
|
* Input : Amount of time (us) needed, peripheral clock2 value
|
79 |
|
|
* Return : None
|
80 |
|
|
*******************************************************************************/
|
81 |
|
|
void WDG_PeriodValueConfig ( u32 Time );
|
82 |
|
|
|
83 |
|
|
/*******************************************************************************
|
84 |
|
|
* Function Name : WDG_CntOnOffConfig
|
85 |
|
|
* Description : Start or stop the free auto-reload timer to countdown.
|
86 |
|
|
* Input : ENABLE or DISABLE
|
87 |
|
|
* Return : None
|
88 |
|
|
*******************************************************************************/
|
89 |
|
|
inline void WDG_CntOnOffConfig ( FunctionalState NewState )
|
90 |
|
|
{
|
91 |
|
|
if (NewState == ENABLE) WDG->CR |= 0x0002; else WDG->CR &= ~0x0002;
|
92 |
|
|
}
|
93 |
|
|
|
94 |
|
|
/*******************************************************************************
|
95 |
|
|
* Function Name : WDG_ECITConfig
|
96 |
|
|
* Description : Enable or Disable the end of count interrupt
|
97 |
|
|
* Input : ENABLE or DISABLE
|
98 |
|
|
* Return : None
|
99 |
|
|
*******************************************************************************/
|
100 |
|
|
inline void WDG_ECITConfig (FunctionalState NewState)
|
101 |
|
|
{
|
102 |
|
|
if (NewState == ENABLE) WDG->MR |= 0x0001; else WDG->MR &= ~0x0001;
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
/*******************************************************************************
|
106 |
|
|
* Function Name : WDG_ECFlagClear
|
107 |
|
|
* Description : Clear the end of count flag
|
108 |
|
|
* Input : None
|
109 |
|
|
* Return : None
|
110 |
|
|
*******************************************************************************/
|
111 |
|
|
inline void WDG_ECFlagClear ( void )
|
112 |
|
|
{
|
113 |
|
|
WDG->SR = 0x0000;
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
/*******************************************************************************
|
117 |
|
|
* Function Name : WDG_ECStatus
|
118 |
|
|
* Description : Return the end of count status
|
119 |
|
|
* Input : None
|
120 |
|
|
* Return : NewState value
|
121 |
|
|
*******************************************************************************/
|
122 |
|
|
inline u16 WDG_ECStatus ( void )
|
123 |
|
|
{
|
124 |
|
|
return WDG->SR;
|
125 |
|
|
}
|
126 |
|
|
|
127 |
|
|
#endif // __WDG_H
|
128 |
|
|
|
129 |
|
|
/******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/
|