summaryrefslogtreecommitdiffstats
path: root/uc_str912/prj_blinky_simple_startup/str91x_lib/src/91x_wiu.c
blob: 3154a3c87efcc91b0ba981fa603cc698d0869c56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/******************** (C) COPYRIGHT 2006 STMicroelectronics ********************
* File Name          : 91x_wiu.c
* Author             : MCD Application Team
* Date First Issued  : 05/18/2006 : Version 1.0
* Description        : This file provides all the WIU software functions.
**********************************************************************************
* History:
* 05/24/2006 : Version 1.1
* 05/18/2006 : Version 1.0
**********************************************************************************
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
* CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
* OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
* OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
* CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*********************************************************************************/

/* Standard include ----------------------------------------------------------*/
#include "91x_wiu.h"
#include "91x_scu.h"

/* Include of other module interface headers ---------------------------------*/
/* Local includes ------------------------------------------------------------*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Interface functions -------------------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/******************************************************************************
* Function Name  : WIU_Init
* Description    : Initializes the WIU unit according to the specified parameters
*                  in the WIU_InitTypeDef structure.
* Input          : WIU_InitStruct: pointer to a WIU_InitTypeDef structure that
*                  contains the configuration information for the WIU peripheral.
* Output         : None
* Return         : None
******************************************************************************/
void WIU_Init(WIU_InitTypeDef* WIU_InitStruct)
{
  /* select the Wake-up line to be used */
  WIU->MR |= WIU_InitStruct->WIU_Line;

  /* configure the triggering edge */
  if(WIU_InitStruct->WIU_TriggerEdge == WIU_RisingEdge)
  {
    /* trigger on rising edge */
    WIU->TR |= WIU_InitStruct->WIU_Line;
  }
  else
  {
    /* trigger on falling edge */
    WIU->TR &= ~WIU_InitStruct->WIU_Line;
  }

  if(WIU_InitStruct->WIU_Mode == WIU_Mode_SWInterrupt)
  {
    /* enable interrupt mode */
    WIU->CTRL |= WIU_Mode_Interrupt;

    /* set the corresponding WUINT bit*/
    WIU->INTR |= WIU_InitStruct->WIU_Line;
  }
  else
  {
    /* configure the WIU mode */
    WIU->CTRL |= WIU_InitStruct->WIU_Mode;
  }
}

/******************************************************************************
* Function Name  : WIU_DeInit
* Description    : Deinitializes the WIU registers to their default reset values.
* Input          : None
* Output         : None
* Return         : None
******************************************************************************/
void WIU_DeInit(void)
{
  /* initialize the WIU registers to their reset value */
  SCU_APBPeriphReset(__WIU, ENABLE);
  SCU_APBPeriphReset(__WIU, DISABLE);
}

/******************************************************************************
* Function Name  : WIU_StructInit
* Description    : Fills in a WIU_InitTypeDef structure with the reset value of
*                  each parameter.
* Input          : WIU_InitStruct : pointer to a WIU_InitTypeDef structure
*                  which will be initialized.
* Output         : None
* Return         : None
******************************************************************************/
void WIU_StructInit(WIU_InitTypeDef* WIU_InitStruct)
{
  /* initialize the WIU_InitStruct fields to their reset values */
  WIU_InitStruct->WIU_Mode = 0x0 ;
  WIU_InitStruct->WIU_Line = 0x0 ;
  WIU_InitStruct->WIU_TriggerEdge = WIU_FallingEdge ;
}


/*******************************************************************************
* Function Name  : WIU_GenerateSWInterrupt
* Description    : Generates a Software interrupt.
* Input          : - WIU_Line: specifies the WIU lines to be enabled or
*                    disabled. This parameter can be:
*                     - WIU_Linex: External interrupt line x where x(0..31)
* Output         : None
* Return         : None
*******************************************************************************/
void WIU_GenerateSWInterrupt(u32 WIU_Line)
{
  WIU->INTR |= WIU_Line;
}

/*******************************************************************************
* Function Name  : WIU_GetFlagStatus
* Description    : Checks whether the specified WIU line flag is set or not.
* Input          : - WIU_Line: specifies the WIU lines flag to check.
*                    This parameter can be:
*                     - WIU_Linex: External interrupt line x where x(0..31)
* Output         : None
* Return         : The new state of WIU_Line (SET or RESET).
*******************************************************************************/
FlagStatus WIU_GetFlagStatus(u32 WIU_Line)
{
  if((WIU->PR & WIU_Line) != RESET)
  {
    return SET;
  }
  else
  {
    return RESET;
  }
}

/*******************************************************************************
* Function Name  : WIU_ClearFlag
* Description    : Clears the WIU’s line pending flags.
* Input          : - WIU_Line: specifies the WIU lines flags to clear.
*                    This parameter can be:
*                     - WIU_Linex: External interrupt line x where x(0..31)
* Output         : None
* Return         : None
*******************************************************************************/
void WIU_ClearFlag(u32 WIU_Line)
{
  WIU->PR = WIU_Line;
}

/*******************************************************************************
* Function Name  : WIU_GetITStatus
* Description    : Checks whether the specified WIU line is asserted or not.
* Input          : - WIU_Line: specifies the WIU lines to check.
*                    This parameter can be:
*                     - WIU_Linex: External interrupt line x where x(0..31)
* Output         : None
* Return         : The new state of WIU_Line (SET or RESET).
*******************************************************************************/
ITStatus WIU_GetITStatus(u32 WIU_Line)
{
  if(((WIU->PR & WIU_Line) != RESET)&& ((WIU->MR & WIU_Line) != RESET))
  {
    return SET;
  }
  else
  {
    return RESET;
  }
}

/*******************************************************************************
* Function Name  : WIU_ClearITPendingBit
* Description    : Clears the WIU’s line pending bits.
* Input          : - WIU_Line: specifies the WIU lines to clear.
*                    This parameter can be:
*                     - WIU_Linex: External interrupt line x where x(0..31)
* Output         : None
* Return         : None
*******************************************************************************/
void WIU_ClearITPendingBit(u32 WIU_Line)
{
  WIU->PR = WIU_Line;
}


/******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/
OpenPOWER on IntegriCloud