1 /******************************************************************************
2 *
3 * Copyright (C) 2022-2023 Maxim Integrated Products, Inc. (now owned by
4 * Analog Devices, Inc.),
5 * Copyright (C) 2023-2024 Analog Devices, Inc.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 ******************************************************************************/
20
21 /* **** Includes **** */
22 #include "mxc_device.h"
23 #include "mxc_assert.h"
24 #include "wut.h"
25 #include "wut_reva.h"
26
27 /* **** Definitions **** */
28
29 /* **** Globals **** */
30
31 /* **** Local Variables **** */
32
33 /* **** Functions **** */
34
35 /* ************************************************************************** */
MXC_WUT_Init(mxc_wut_pres_t pres)36 void MXC_WUT_Init(mxc_wut_pres_t pres)
37 {
38 #ifndef MSDK_NO_GPIO_CLK_INIT
39 MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_ERTCO);
40 #endif
41 MXC_WUT_RevA_Init((mxc_wut_reva_regs_t *)MXC_WUT, pres);
42 }
43
MXC_WUT_Shutdown(void)44 void MXC_WUT_Shutdown(void)
45 {
46 MXC_WUT_RevA_Shutdown((mxc_wut_reva_regs_t *)MXC_WUT);
47 }
48
49 /* ************************************************************************** */
MXC_WUT_Enable(void)50 void MXC_WUT_Enable(void)
51 {
52 MXC_WUT_RevA_Enable((mxc_wut_reva_regs_t *)MXC_WUT);
53 }
54
55 /* ************************************************************************** */
MXC_WUT_Disable(void)56 void MXC_WUT_Disable(void)
57 {
58 MXC_WUT_RevA_Disable((mxc_wut_reva_regs_t *)MXC_WUT);
59 }
60
61 /* ************************************************************************** */
MXC_WUT_Config(const mxc_wut_cfg_t * cfg)62 void MXC_WUT_Config(const mxc_wut_cfg_t *cfg)
63 {
64 MXC_WUT_RevA_Config((mxc_wut_reva_regs_t *)MXC_WUT, (mxc_wut_reva_cfg_t *)cfg);
65 }
66
67 /* ************************************************************************** */
MXC_WUT_GetCompare(void)68 uint32_t MXC_WUT_GetCompare(void)
69 {
70 return MXC_WUT_RevA_GetCompare((mxc_wut_reva_regs_t *)MXC_WUT);
71 }
72
73 ///* ************************************************************************** */
74 //uint32_t MXC_WUT_GetCapture(void)
75 //{
76 // return MXC_WUT_RevA_GetCapture((mxc_wut_reva_regs_t*) MXC_WUT);
77 //}
78
79 /* ************************************************************************* */
MXC_WUT_GetCount(void)80 uint32_t MXC_WUT_GetCount(void)
81 {
82 return MXC_WUT_RevA_GetCount((mxc_wut_reva_regs_t *)MXC_WUT);
83 }
84
85 /* ************************************************************************* */
MXC_WUT_IntClear(void)86 void MXC_WUT_IntClear(void)
87 {
88 MXC_WUT_RevA_IntClear((mxc_wut_reva_regs_t *)MXC_WUT);
89 }
90
91 /* ************************************************************************* */
MXC_WUT_IntStatus(void)92 uint32_t MXC_WUT_IntStatus(void)
93 {
94 return MXC_WUT_RevA_IntStatus((mxc_wut_reva_regs_t *)MXC_WUT);
95 }
96
97 /* ************************************************************************* */
MXC_WUT_SetCompare(uint32_t cmp_cnt)98 void MXC_WUT_SetCompare(uint32_t cmp_cnt)
99 {
100 MXC_WUT_RevA_SetCompare((mxc_wut_reva_regs_t *)MXC_WUT, cmp_cnt);
101 }
102
103 /* ************************************************************************* */
MXC_WUT_SetCount(uint32_t cnt)104 void MXC_WUT_SetCount(uint32_t cnt)
105 {
106 MXC_WUT_RevA_SetCount((mxc_wut_reva_regs_t *)MXC_WUT, cnt);
107 }
108
109 /* ************************************************************************* */
MXC_WUT_GetTicks(uint32_t time,mxc_wut_unit_t units,uint32_t * ticks)110 int MXC_WUT_GetTicks(uint32_t time, mxc_wut_unit_t units, uint32_t *ticks)
111 {
112 return MXC_WUT_RevA_GetTicks((mxc_wut_reva_regs_t *)MXC_WUT, ERTCO_FREQ, time, units, ticks);
113 }
114
115 /* ************************************************************************* */
MXC_WUT_GetTime(uint32_t ticks,uint32_t * time,mxc_wut_unit_t * units)116 int MXC_WUT_GetTime(uint32_t ticks, uint32_t *time, mxc_wut_unit_t *units)
117 {
118 return MXC_WUT_RevA_GetTime((mxc_wut_reva_regs_t *)MXC_WUT, ERTCO_FREQ, ticks, time,
119 (mxc_wut_reva_unit_t *)units);
120 }
121
122 /* ************************************************************************** */
MXC_WUT_Edge(void)123 void MXC_WUT_Edge(void)
124 {
125 MXC_WUT_RevA_Edge((mxc_wut_reva_regs_t *)MXC_WUT);
126 }
127
128 /* ************************************************************************** */
MXC_WUT_Store(void)129 void MXC_WUT_Store(void)
130 {
131 MXC_WUT_RevA_Store((mxc_wut_reva_regs_t *)MXC_WUT);
132 }
133
134 /* ************************************************************************** */
MXC_WUT_RestoreBBClock(uint32_t dbbFreq)135 void MXC_WUT_RestoreBBClock(uint32_t dbbFreq)
136 {
137 MXC_WUT_RevA_RestoreBBClock((mxc_wut_reva_regs_t *)MXC_WUT, dbbFreq, ERTCO_FREQ);
138 }
139
140 /* ************************************************************************** */
MXC_WUT_GetSleepTicks(void)141 uint32_t MXC_WUT_GetSleepTicks(void)
142 {
143 return MXC_WUT_RevA_GetSleepTicks((mxc_wut_reva_regs_t *)MXC_WUT);
144 }
145
146 /* ************************************************************************** */
MXC_WUT_Delay_MS(uint32_t waitMs)147 void MXC_WUT_Delay_MS(uint32_t waitMs)
148 {
149 MXC_WUT_RevA_Delay_MS((mxc_wut_reva_regs_t *)MXC_WUT, waitMs, ERTCO_FREQ);
150 }
151