-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add wrapper function for MXC_RTC_Init
This commit adds a wrapper function for MXC_RTC_Init to set clock source for MAX32657. Signed-off-by: Mert Vatansever <[email protected]>
- Loading branch information
1 parent
5fd0303
commit 8230420
Showing
1 changed file
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/****************************************************************************** | ||
* | ||
* Copyright (C) 2024 Analog Devices, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
******************************************************************************/ | ||
|
||
#ifndef LIBRARIES_ZEPHYR_MAX_INCLUDE_WRAP_MAX32_RTC_H_ | ||
#define LIBRARIES_ZEPHYR_MAX_INCLUDE_WRAP_MAX32_RTC_H_ | ||
|
||
/***** Includes *****/ | ||
#include <rtc.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#if defined(CONFIG_SOC_MAX32657) | ||
|
||
static inline mxc_rtc_clock_t wrap_get_clock_source_instance(uint8_t clock_source) | ||
{ | ||
mxc_rtc_clock_t clk_src; | ||
|
||
switch (clock_source) { | ||
case 4: // ADI_MAX32_PRPH_CLK_SRC_ERTCO | ||
clk_src = MXC_RTC_ERTCO_CLK; | ||
break; | ||
case 5: // ADI_MAX32_PRPH_CLK_SRC_INRO | ||
clk_src = MXC_RTC_INRO_CLK; | ||
break; | ||
default: | ||
return -1; | ||
} | ||
|
||
return clk_src; | ||
} | ||
|
||
static inline int WRAP_MXC_RTC_Init(uint32_t sec, uint16_t ssec, uint8_t clock_source) | ||
{ | ||
int ret; | ||
mxc_rtc_clock_t clk_src; | ||
|
||
clk_src = wrap_get_clock_source_instance(clock_source); | ||
|
||
MXC_RTC_SetClockSource(clk_src); | ||
|
||
ret = MXC_RTC_Init(sec, ssec); | ||
|
||
return ret; | ||
} | ||
|
||
#else | ||
|
||
static inline int WRAP_MXC_RTC_Init(uint32_t sec, uint16_t ssec, uint8_t clk_src) | ||
{ | ||
int ret; | ||
|
||
ret = MXC_RTC_Init(sec, ssec); | ||
|
||
return ret; | ||
} | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // LIBRARIES_ZEPHYR_MAX_INCLUDE_WRAP_MAX32_RTC_H_ |