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 #ifndef LIBRARIES_PERIPHDRIVERS_SOURCE_TMR_TMR_REVB_H_
22 #define LIBRARIES_PERIPHDRIVERS_SOURCE_TMR_TMR_REVB_H_
23 
24 /* **** Includes **** */
25 #include <stddef.h>
26 #include "mxc_assert.h"
27 #include "tmr.h"
28 #include "gpio.h"
29 #include "mxc_pins.h"
30 #include "mxc_lock.h"
31 #include "tmr_revb_regs.h"
32 
33 typedef enum {
34     MXC_TMR_CLK0,
35     MXC_TMR_CLK1,
36     MXC_TMR_CLK2,
37     MXC_TMR_CLK3,
38 } mxc_tmr_clksel_t;
39 
40 /* **** Functions **** */
41 int MXC_TMR_RevB_Init(mxc_tmr_revb_regs_t *tmr, mxc_tmr_cfg_t *cfg, uint8_t clk_src);
42 void MXC_TMR_RevB_SetClockSourceFreq(mxc_tmr_revb_regs_t *tmr, int clksrc_freq);
43 int MXC_TMR_RevB_GetClockSourceFreq(mxc_tmr_revb_regs_t *tmr);
44 void MXC_TMR_RevB_ConfigGeneric(mxc_tmr_revb_regs_t *tmr, mxc_tmr_cfg_t *cfg);
45 void MXC_TMR_RevB_Shutdown(mxc_tmr_revb_regs_t *tmr);
46 void MXC_TMR_RevB_Start(mxc_tmr_revb_regs_t *tmr);
47 void MXC_TMR_RevB_Stop(mxc_tmr_revb_regs_t *tmr);
48 int MXC_TMR_RevB_SetPWM(mxc_tmr_revb_regs_t *tmr, uint32_t pwm);
49 uint32_t MXC_TMR_RevB_GetCompare(mxc_tmr_revb_regs_t *tmr);
50 uint32_t MXC_TMR_RevB_GetCapture(mxc_tmr_revb_regs_t *tmr);
51 uint32_t MXC_TMR_RevB_GetCount(mxc_tmr_revb_regs_t *tmr);
52 uint32_t MXC_TMR_RevB_GetPeriod(mxc_tmr_revb_regs_t *tmr, uint32_t clk_frequency,
53                                 uint32_t prescalar, uint32_t frequency);
54 void MXC_TMR_RevB_ClearFlags(mxc_tmr_revb_regs_t *tmr);
55 uint32_t MXC_TMR_RevB_GetFlags(mxc_tmr_revb_regs_t *tmr);
56 void MXC_TMR_RevB_EnableInt(mxc_tmr_revb_regs_t *tmr);
57 void MXC_TMR_RevB_DisableInt(mxc_tmr_revb_regs_t *tmr);
58 void MXC_TMR_RevB_EnableWakeup(mxc_tmr_revb_regs_t *tmr, mxc_tmr_cfg_t *cfg);
59 void MXC_TMR_RevB_DisableWakeup(mxc_tmr_revb_regs_t *tmr, mxc_tmr_cfg_t *cfg);
60 void MXC_TMR_RevB_SetCompare(mxc_tmr_revb_regs_t *tmr, uint32_t cmp_cnt);
61 void MXC_TMR_RevB_SetCount(mxc_tmr_revb_regs_t *tmr, uint32_t cnt);
62 void MXC_TMR_RevB_TO_Start(mxc_tmr_revb_regs_t *tmr, uint32_t us);
63 int MXC_TMR_RevB_GetTime(mxc_tmr_revb_regs_t *tmr, uint32_t ticks, uint32_t *time,
64                          mxc_tmr_unit_t *units);
65 int MXC_TMR_RevB_GetTicks(mxc_tmr_revb_regs_t *tmr, uint32_t time, mxc_tmr_unit_t units,
66                           uint32_t *ticks);
67 
68 #endif // LIBRARIES_PERIPHDRIVERS_SOURCE_TMR_TMR_REVB_H_
69