MAX32680 Peripheral Driver API
Peripheral Driver API for the MAX32680
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Modules
wut.h
1
6/******************************************************************************
7 *
8 * Copyright (C) 2022-2023 Maxim Integrated Products, Inc. (now owned by
9 * Analog Devices, Inc.),
10 * Copyright (C) 2023-2024 Analog Devices, Inc.
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *
24 ******************************************************************************/
25
26/* Define to prevent redundant inclusion */
27#ifndef LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32680_WUT_H_
28#define LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32680_WUT_H_
29
30/* **** Includes **** */
31#include "mxc_device.h"
32#include "wut_regs.h"
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
47typedef enum {
48 MXC_WUT_PRES_1 = MXC_S_WUT_CTRL_PRES_DIV1,
67
71typedef enum {
72 MXC_WUT_MODE_ONESHOT = MXC_V_WUT_CTRL_TMODE_ONESHOT,
81
85typedef enum {
91
95typedef struct {
96 mxc_wut_mode_t mode;
97 uint32_t cmp_cnt;
99
106typedef void (*mxc_wut_complete_cb_t)(int result);
107
108/* **** Definitions **** */
109
110/* **** Function Prototypes **** */
111
118
124
130
136
143
150
157
163
170
178void MXC_WUT_SetCompare(mxc_wut_regs_t *wut, uint32_t cmp_cnt);
179
185void MXC_WUT_SetCount(mxc_wut_regs_t *wut, uint32_t cnt);
186
196int MXC_WUT_GetTicks(mxc_wut_regs_t *wut, uint32_t time, mxc_wut_unit_t units, uint32_t *ticks);
197
207int MXC_WUT_GetTime(mxc_wut_regs_t *wut, uint32_t ticks, uint32_t *time, mxc_wut_unit_t *units);
208
214
220
226void MXC_WUT_RestoreBBClock(mxc_wut_regs_t *wut, uint32_t dbbFreq);
227
235
241void MXC_WUT_Delay_MS(mxc_wut_regs_t *wut, uint32_t waitMs);
242
254
266
274
281
284#ifdef __cplusplus
285}
286#endif
287
288#endif // LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32680_WUT_H_
#define MXC_S_WUT_CTRL_PRES_DIV8
Definition: wut_regs.h:172
#define MXC_S_WUT_CTRL_PRES_DIV2
Definition: wut_regs.h:168
#define MXC_S_WUT_CTRL_PRES_DIV32
Definition: wut_regs.h:176
#define MXC_S_WUT_CTRL_PRES_DIV4
Definition: wut_regs.h:170
#define MXC_S_WUT_CTRL_PRES_DIV1
Definition: wut_regs.h:166
#define MXC_V_WUT_CTRL_TMODE_ONESHOT
Definition: wut_regs.h:148
#define MXC_V_WUT_CTRL_TMODE_CONTINUOUS
Definition: wut_regs.h:150
#define MXC_V_WUT_CTRL_TMODE_COMPARE
Definition: wut_regs.h:156
#define MXC_V_WUT_CTRL_TMODE_GATED
Definition: wut_regs.h:158
#define MXC_F_WUT_CTRL_PRES3
Definition: wut_regs.h:189
#define MXC_V_WUT_CTRL_TMODE_CAPTURECOMPARE
Definition: wut_regs.h:160
#define MXC_S_WUT_CTRL_PRES_DIV64
Definition: wut_regs.h:178
#define MXC_V_WUT_CTRL_TMODE_COUNTER
Definition: wut_regs.h:152
#define MXC_V_WUT_CTRL_TMODE_CAPTURE
Definition: wut_regs.h:154
#define MXC_S_WUT_CTRL_PRES_DIV128
Definition: wut_regs.h:180
#define MXC_S_WUT_CTRL_PRES_DIV16
Definition: wut_regs.h:174
Definition: wut_regs.h:76
uint32_t cmp_cnt
Desired timer mode.
Definition: wut.h:97
uint32_t MXC_WUT_GetCount(mxc_wut_regs_t *wut)
Get the timer count.
void MXC_WUT_Shutdown(mxc_wut_regs_t *wut)
Shutdown timer module clock.
void MXC_WUT_Init(mxc_wut_regs_t *wut, mxc_wut_pres_t pres)
Initialize timer module clock.
int MXC_WUT_GetTicks(mxc_wut_regs_t *wut, uint32_t time, mxc_wut_unit_t units, uint32_t *ticks)
Convert real time to timer ticks.
void MXC_WUT_Edge(mxc_wut_regs_t *wut)
Wait for an edge of the WUT count register.
void MXC_WUT_Config(mxc_wut_regs_t *wut, const mxc_wut_cfg_t *cfg)
Configure the timer.
int MXC_WUT_Handler(mxc_wut_regs_t *wut)
Interrupt handler for trim procedure.
void MXC_WUT_Delay_MS(mxc_wut_regs_t *wut, uint32_t waitMs)
Delays for the given number of milliseconds.
int MXC_WUT_GetTime(mxc_wut_regs_t *wut, uint32_t ticks, uint32_t *time, mxc_wut_unit_t *units)
Convert timer ticks to real time.
int MXC_WUT_TrimPending(mxc_wut_regs_t *wut)
Check to see if the trim procedure is ongoing.
void MXC_WUT_Disable(mxc_wut_regs_t *wut)
Disable the timer.
void MXC_WUT_IntClear(mxc_wut_regs_t *wut)
Clear the timer interrupt.
uint32_t MXC_WUT_GetSleepTicks(mxc_wut_regs_t *wut)
Get the difference between the stored counter value and the current counter value.
void MXC_WUT_SetCount(mxc_wut_regs_t *wut, uint32_t cnt)
Set the timer count.
void(* mxc_wut_complete_cb_t)(int result)
The callback routine used by the MXC_WUT_TrimCrystalAsync() function to indicate the transaction has ...
Definition: wut.h:106
mxc_wut_pres_t
Wakeup Timer prescaler values.
Definition: wut.h:47
void MXC_WUT_RestoreBBClock(mxc_wut_regs_t *wut, uint32_t dbbFreq)
Restore the DBB clock with the stored count and snapshot values.
int MXC_WUT_TrimCrystal(mxc_wut_regs_t *wut)
Trim the 32 kHz crystal load settings, blocks until complete.
void MXC_WUT_Enable(mxc_wut_regs_t *wut)
Enable the timer.
void MXC_WUT_SetCompare(mxc_wut_regs_t *wut, uint32_t cmp_cnt)
Set the timer compare count.
void MXC_WUT_Store(mxc_wut_regs_t *wut)
Store the count and snapshot values.
int MXC_WUT_TrimCrystalAsync(mxc_wut_regs_t *wut, mxc_wut_complete_cb_t cb)
Trim the 32 kHz crystal load settings, non-blocking interrupt based.
uint32_t MXC_WUT_GetCompare(mxc_wut_regs_t *wut)
Get the timer compare count.
mxc_wut_unit_t
Wakeup Timer units of time enumeration.
Definition: wut.h:85
mxc_wut_mode_t
Wakeup Timer modes.
Definition: wut.h:71
uint32_t MXC_WUT_IntStatus(mxc_wut_regs_t *wut)
Get the timer interrupt status.
@ MXC_WUT_PRES_8
Divide input clock by 4.
Definition: wut.h:51
@ MXC_WUT_PRES_512
Divide input clock by 256.
Definition: wut.h:58
@ MXC_WUT_PRES_16
Divide input clock by 8.
Definition: wut.h:52
@ MXC_WUT_PRES_1024
Divide input clock by 512.
Definition: wut.h:60
@ MXC_WUT_PRES_4
Divide input clock by 2.
Definition: wut.h:50
@ MXC_WUT_PRES_256
Divide input clock by 128.
Definition: wut.h:56
@ MXC_WUT_PRES_4096
Divide input clock by 2048.
Definition: wut.h:64
@ MXC_WUT_PRES_2
Divide input clock by 1.
Definition: wut.h:49
@ MXC_WUT_PRES_32
Divide input clock by 16.
Definition: wut.h:53
@ MXC_WUT_PRES_128
Divide input clock by 64.
Definition: wut.h:55
@ MXC_WUT_PRES_2048
Divide input clock by 1024.
Definition: wut.h:62
@ MXC_WUT_PRES_64
Divide input clock by 32.
Definition: wut.h:54
@ MXC_WUT_UNIT_SEC
Definition: wut.h:89
@ MXC_WUT_UNIT_NANOSEC
Definition: wut.h:86
@ MXC_WUT_UNIT_MILLISEC
Definition: wut.h:88
@ MXC_WUT_UNIT_MICROSEC
Definition: wut.h:87
@ MXC_WUT_MODE_COUNTER
Wakeup Timer Mode CONTINUOUS.
Definition: wut.h:74
@ MXC_WUT_MODE_CAPTURE_COMPARE
Wakeup Timer Mode GATED.
Definition: wut.h:78
@ MXC_WUT_MODE_CAPTURE
Wakeup Timer Mode COUNTER.
Definition: wut.h:75
@ MXC_WUT_MODE_COMPARE
Wakeup Timer Mode CAPTURE.
Definition: wut.h:76
@ MXC_WUT_MODE_GATED
Wakeup Timer Mode COMPARE.
Definition: wut.h:77
@ MXC_WUT_MODE_CONTINUOUS
Wakeup Timer Mode ONESHOT.
Definition: wut.h:73
Wakeup Timer Configuration.
Definition: wut.h:95
Registers, Bit Masks and Bit Positions for the WUT Peripheral Module.