blob: 2c6a604e833404dee94a9648c7216643b342bccd (
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
|
/******************************************************************************
* @brief providing APIs for configuring PMC.
*
*******************************************************************************
*
* provide APIs for configuring PMC
******************************************************************************/
#include "common.h"
#include "pmc.h"
/******************************************************************************
* Constants
******************************************************************************/
/******************************************************************************
* Macros
******************************************************************************/
/******************************************************************************
* Types
******************************************************************************/
/******************************************************************************
* Global variables
******************************************************************************/
/******************************************************************************
* Global functions
******************************************************************************/
/******************************************************************************
* PMC api list.
*
*//*! @addtogroup pmc_api_list
* @{
*******************************************************************************/
/*****************************************************************************//*!
*
* @brief configure PMC with given parameters.
*
* @param[in] pPMC_Config PMC configuration structure.
* @param[in] pPMC pointer to the PMC module.
*
* @return none.
*
* @ Pass/ Fail criteria: none.
*
* @see PMC_DeInit.
*
*****************************************************************************/
void PMC_Init(PMC_Type *pPMC, PMC_ConfigType *pPMC_Config)
{
pPMC->SPMSC1 = pPMC_Config->sCtrlstatus.byte;
pPMC->SPMSC2 = pPMC_Config->sDetectVoltSelect.byte;
}
/*****************************************************************************//*!
*
* @brief config the pmc register to the default mode.
*
* @param[in] pPMC pointer to the PMC module.
*
* @return none.
*
* @ Pass/ Fail criteria: none.
*
* @see PMC_Init.
*
*****************************************************************************/
void PMC_DeInit(PMC_Type *pPMC)
{
pPMC->SPMSC1 = 0x1C;
pPMC->SPMSC2 = 0;
}
/*****************************************************************************//*!
*
* @brief config the pmc mode among run, wait and stop modes.
*
* @param[in] u8PmcMode PMC mode select.
* @param[in] pPMC pointer to the PMC module.
*
* @return none.
*
* @ Pass/ Fail criteria: none.
*
*****************************************************************************/
void PMC_SetMode(PMC_Type *pPMC,uint8_t u8PmcMode)
{
switch(u8PmcMode & 0x3)
{
case PmcModeRun:
break;
case PmcModeWait:
wait();
break;
case PmcModeStop4:
/* enable LVD in stop mode */
pPMC->SPMSC1 |= (PMC_SPMSC1_LVDE_MASK | PMC_SPMSC1_LVDSE_MASK);
stop();
break;
case PmcModeStop3:
/* disable LVD in stop mode */
pPMC->SPMSC1 &= ~(PMC_SPMSC1_LVDE_MASK | PMC_SPMSC1_LVDRE_MASK | PMC_SPMSC1_LVDSE_MASK);
stop();
break;
default:
break;
}
}
/*! @} End of pmc_api_list */
|