1
2 /******************************************************************************
3 * @brief providing APIs for configuring PMC.
4 *
5 *******************************************************************************
6 *
7 * provide APIs for configuring PMC
8 ******************************************************************************/
9 #include "common.h"
10 #include "pmc.h"
11
12 /******************************************************************************
13 * Constants
14 ******************************************************************************/
15 /******************************************************************************
16 * Macros
17 ******************************************************************************/
18 /******************************************************************************
19 * Types
20 ******************************************************************************/
21 /******************************************************************************
22 * Global variables
23 ******************************************************************************/
24 /******************************************************************************
25 * Global functions
26 ******************************************************************************/
27
28 /******************************************************************************
29 * PMC api list.
30 *
31 *//*! @addtogroup pmc_api_list
32 * @{
33 *******************************************************************************/
34 /*****************************************************************************//*!
35 *
36 * @brief configure PMC with given parameters.
37 *
38 * @param[in] pPMC_Config PMC configuration structure.
39 * @param[in] pPMC pointer to the PMC module.
40 *
41 * @return none.
42 *
43 * @ Pass/ Fail criteria: none.
44 *
45 * @see PMC_DeInit.
46 *
47 *****************************************************************************/
PMC_Init(PMC_Type * pPMC,PMC_ConfigType * pPMC_Config)48 void PMC_Init(PMC_Type *pPMC, PMC_ConfigType *pPMC_Config)
49 {
50 pPMC->SPMSC1 = pPMC_Config->sCtrlstatus.byte;
51 pPMC->SPMSC2 = pPMC_Config->sDetectVoltSelect.byte;
52 }
53
54
55 /*****************************************************************************//*!
56 *
57 * @brief config the pmc register to the default mode.
58 *
59 * @param[in] pPMC pointer to the PMC module.
60 *
61 * @return none.
62 *
63 * @ Pass/ Fail criteria: none.
64 *
65 * @see PMC_Init.
66 *
67 *****************************************************************************/
PMC_DeInit(PMC_Type * pPMC)68 void PMC_DeInit(PMC_Type *pPMC)
69 {
70 pPMC->SPMSC1 = 0x1C;
71 pPMC->SPMSC2 = 0;
72 }
73
74
75 /*****************************************************************************//*!
76 *
77 * @brief config the pmc mode among run, wait and stop modes.
78 *
79 * @param[in] u8PmcMode PMC mode select.
80 * @param[in] pPMC pointer to the PMC module.
81 *
82 * @return none.
83 *
84 * @ Pass/ Fail criteria: none.
85 *
86 *****************************************************************************/
PMC_SetMode(PMC_Type * pPMC,uint8_t u8PmcMode)87 void PMC_SetMode(PMC_Type *pPMC,uint8_t u8PmcMode)
88 {
89 switch(u8PmcMode & 0x3)
90 {
91 case PmcModeRun:
92 break;
93 case PmcModeWait:
94 wait();
95 break;
96 case PmcModeStop4:
97 /* enable LVD in stop mode */
98 pPMC->SPMSC1 |= (PMC_SPMSC1_LVDE_MASK | PMC_SPMSC1_LVDSE_MASK);
99 stop();
100 break;
101 case PmcModeStop3:
102 /* disable LVD in stop mode */
103 pPMC->SPMSC1 &= ~(PMC_SPMSC1_LVDE_MASK | PMC_SPMSC1_LVDRE_MASK | PMC_SPMSC1_LVDSE_MASK);
104 stop();
105 break;
106 default:
107 break;
108 }
109
110 }
111
112 /*! @} End of pmc_api_list */
113
114