OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [Common/] [drivers/] [ST/] [STM32F10xFWLib/] [src/] [stm32f10x_iwdg.c] - Blame information for rev 610

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 608 jeremybenn
/******************** (C) COPYRIGHT 2007 STMicroelectronics ********************
2
* File Name          : stm32f10x_iwdg.c
3
* Author             : MCD Application Team
4
* Date First Issued  : 09/29/2006
5
* Description        : This file provides all the IWDG firmware functions.
6
********************************************************************************
7
* History:
8
* 04/02/2007: V0.2
9
* 02/05/2007: V0.1
10
* 09/29/2006: V0.01
11
********************************************************************************
12
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
13
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
14
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
15
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
16
* CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
17
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18
*******************************************************************************/
19
 
20
/* Includes ------------------------------------------------------------------*/
21
#include "stm32f10x_iwdg.h"
22
 
23
/* Private typedef -----------------------------------------------------------*/
24
/* Private define ------------------------------------------------------------*/
25
/* ---------------------- IWDG registers bit mask ------------------------ */
26
/* KR register bit mask */
27
#define KR_Reload    ((u16)0xAAAA)
28
#define KR_Enable    ((u16)0xCCCC)
29
 
30
/* Private macro -------------------------------------------------------------*/
31
/* Private variables ---------------------------------------------------------*/
32
/* Private function prototypes -----------------------------------------------*/
33
/* Private functions ---------------------------------------------------------*/
34
 
35
/*******************************************************************************
36
* Function Name  : IWDG_WriteAccessCmd
37
* Description    : Enables or disables write access to IWDG_PR and IWDG_RLR
38
*                  registers.
39
* Input          : - IWDG_WriteAccess: new state of write access to IWDG_PR and
40
*                    IWDG_RLR registers.
41
*                    This parameter can be one of the following values:
42
*                       - IWDG_WriteAccess_Enable: Enable write access to
43
*                         IWDG_PR and IWDG_RLR registers
44
*                       - IWDG_WriteAccess_Disable: Disable write access to
45
*                         IWDG_PR and IWDG_RLR registers
46
* Output         : None
47
* Return         : None
48
*******************************************************************************/
49
void IWDG_WriteAccessCmd(u16 IWDG_WriteAccess)
50
{
51
  /* Check the parameters */
52
  assert(IS_IWDG_WRITE_ACCESS(IWDG_WriteAccess));
53
 
54
  IWDG->KR = IWDG_WriteAccess;
55
}
56
 
57
/*******************************************************************************
58
* Function Name  : IWDG_SetPrescaler
59
* Description    : Sets IWDG Prescaler value.
60
* Input          : - IWDG_Prescaler: specifies the IWDG Prescaler value.
61
*                    This parameter can be one of the following values:
62
*                       - IWDG_Prescaler_4: IWDG prescaler set to 4
63
*                       - IWDG_Prescaler_8: IWDG prescaler set to 8
64
*                       - IWDG_Prescaler_16: IWDG prescaler set to 16
65
*                       - IWDG_Prescaler_32: IWDG prescaler set to 32
66
*                       - IWDG_Prescaler_64: IWDG prescaler set to 64
67
*                       - IWDG_Prescaler_128: IWDG prescaler set to 128
68
*                       - IWDG_Prescaler_256: IWDG prescaler set to 256
69
* Output         : None
70
* Return         : None
71
*******************************************************************************/
72
void IWDG_SetPrescaler(u8 IWDG_Prescaler)
73
{
74
  /* Check the parameters */
75
  assert(IS_IWDG_PRESCALER(IWDG_Prescaler));
76
 
77
  IWDG->PR = IWDG_Prescaler;
78
}
79
 
80
/*******************************************************************************
81
* Function Name  : IWDG_SetReload
82
* Description    : Sets IWDG Reload value.
83
* Input          : - Reload: specifies the IWDG Reload value.
84
*                    This parameter must be a number between 0 and 0x0FFF.
85
* Output         : None
86
* Return         : None
87
*******************************************************************************/
88
void IWDG_SetReload(u16 Reload)
89
{
90
  /* Check the parameters */
91
  assert(IS_IWDG_RELOAD(Reload));
92
 
93
  IWDG->RLR = Reload;
94
}
95
 
96
/*******************************************************************************
97
* Function Name  : IWDG_ReloadCounter
98
* Description    : Reloads IWDG counter with value defined in the reload register
99
*                  (write access to IWDG_PR and IWDG_RLR registers disabled).
100
* Input          : None
101
* Output         : None
102
* Return         : None
103
*******************************************************************************/
104
void IWDG_ReloadCounter(void)
105
{
106
  IWDG->KR = KR_Reload;
107
}
108
 
109
/*******************************************************************************
110
* Function Name  : IWDG_Enable
111
* Description    : Enables IWDG (write access to IWDG_PR and IWDG_RLR registers
112
*                  disabled).
113
* Input          : None
114
* Output         : None
115
* Return         : None
116
*******************************************************************************/
117
void IWDG_Enable(void)
118
{
119
  IWDG->KR = KR_Enable;
120
}
121
 
122
/*******************************************************************************
123
* Function Name  : IWDG_GetFlagStatus
124
* Description    : Checks whether the specified IWDG flag is set or not.
125
* Input          : - IWDG_FLAG: specifies the flag to check.
126
*                    This parameter can be one of the following values:
127
*                       - IWDG_FLAG_PVU: Prescaler Value Update on going
128
*                       - IWDG_FLAG_RVU: Reload Value Update on going
129
* Output         : None
130
* Return         : The new state of IWDG_FLAG (SET or RESET).
131
*******************************************************************************/
132
FlagStatus IWDG_GetFlagStatus(u16 IWDG_FLAG)
133
{
134
  FlagStatus bitstatus = RESET;
135
 
136
  /* Check the parameters */
137
  assert(IS_IWDG_FLAG(IWDG_FLAG));
138
 
139
  if ((IWDG->SR & IWDG_FLAG) != (u32)RESET)
140
  {
141
    bitstatus = SET;
142
  }
143
  else
144
  {
145
    bitstatus = RESET;
146
  }
147
 
148
  /* Return the flag status */
149
  return bitstatus;
150
}
151
 
152
/******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.