1*852ba100SJustin Hibbits /* 2*852ba100SJustin Hibbits * Copyright 2008-2012 Freescale Semiconductor Inc. 30aeed3e9SJustin Hibbits * 40aeed3e9SJustin Hibbits * Redistribution and use in source and binary forms, with or without 50aeed3e9SJustin Hibbits * modification, are permitted provided that the following conditions are met: 60aeed3e9SJustin Hibbits * * Redistributions of source code must retain the above copyright 70aeed3e9SJustin Hibbits * notice, this list of conditions and the following disclaimer. 80aeed3e9SJustin Hibbits * * Redistributions in binary form must reproduce the above copyright 90aeed3e9SJustin Hibbits * notice, this list of conditions and the following disclaimer in the 100aeed3e9SJustin Hibbits * documentation and/or other materials provided with the distribution. 110aeed3e9SJustin Hibbits * * Neither the name of Freescale Semiconductor nor the 120aeed3e9SJustin Hibbits * names of its contributors may be used to endorse or promote products 130aeed3e9SJustin Hibbits * derived from this software without specific prior written permission. 140aeed3e9SJustin Hibbits * 150aeed3e9SJustin Hibbits * 160aeed3e9SJustin Hibbits * ALTERNATIVELY, this software may be distributed under the terms of the 170aeed3e9SJustin Hibbits * GNU General Public License ("GPL") as published by the Free Software 180aeed3e9SJustin Hibbits * Foundation, either version 2 of that License or (at your option) any 190aeed3e9SJustin Hibbits * later version. 200aeed3e9SJustin Hibbits * 210aeed3e9SJustin Hibbits * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY 220aeed3e9SJustin Hibbits * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 230aeed3e9SJustin Hibbits * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 240aeed3e9SJustin Hibbits * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY 250aeed3e9SJustin Hibbits * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 260aeed3e9SJustin Hibbits * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 270aeed3e9SJustin Hibbits * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 280aeed3e9SJustin Hibbits * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 290aeed3e9SJustin Hibbits * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 300aeed3e9SJustin Hibbits * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 310aeed3e9SJustin Hibbits */ 320aeed3e9SJustin Hibbits 33*852ba100SJustin Hibbits 340aeed3e9SJustin Hibbits /**************************************************************************//** 350aeed3e9SJustin Hibbits @File fm_rtc_ext.h 360aeed3e9SJustin Hibbits 370aeed3e9SJustin Hibbits @Description External definitions and API for FM RTC IEEE1588 Timer Module. 380aeed3e9SJustin Hibbits 390aeed3e9SJustin Hibbits @Cautions None. 400aeed3e9SJustin Hibbits *//***************************************************************************/ 410aeed3e9SJustin Hibbits 420aeed3e9SJustin Hibbits #ifndef __FM_RTC_EXT_H__ 430aeed3e9SJustin Hibbits #define __FM_RTC_EXT_H__ 440aeed3e9SJustin Hibbits 450aeed3e9SJustin Hibbits 460aeed3e9SJustin Hibbits #include "error_ext.h" 470aeed3e9SJustin Hibbits #include "std_ext.h" 48*852ba100SJustin Hibbits #include "fsl_fman_rtc.h" 490aeed3e9SJustin Hibbits 500aeed3e9SJustin Hibbits /**************************************************************************//** 510aeed3e9SJustin Hibbits 520aeed3e9SJustin Hibbits @Group FM_grp Frame Manager API 530aeed3e9SJustin Hibbits 540aeed3e9SJustin Hibbits @Description FM API functions, definitions and enums 550aeed3e9SJustin Hibbits 560aeed3e9SJustin Hibbits @{ 570aeed3e9SJustin Hibbits *//***************************************************************************/ 580aeed3e9SJustin Hibbits 590aeed3e9SJustin Hibbits /**************************************************************************//** 600aeed3e9SJustin Hibbits @Group fm_rtc_grp FM RTC 610aeed3e9SJustin Hibbits 620aeed3e9SJustin Hibbits @Description FM RTC functions, definitions and enums. 630aeed3e9SJustin Hibbits 640aeed3e9SJustin Hibbits @{ 650aeed3e9SJustin Hibbits *//***************************************************************************/ 660aeed3e9SJustin Hibbits 670aeed3e9SJustin Hibbits /**************************************************************************//** 680aeed3e9SJustin Hibbits @Group fm_rtc_init_grp FM RTC Initialization Unit 690aeed3e9SJustin Hibbits 700aeed3e9SJustin Hibbits @Description FM RTC initialization API. 710aeed3e9SJustin Hibbits 720aeed3e9SJustin Hibbits @{ 730aeed3e9SJustin Hibbits *//***************************************************************************/ 740aeed3e9SJustin Hibbits 750aeed3e9SJustin Hibbits /**************************************************************************//** 760aeed3e9SJustin Hibbits @Description FM RTC Alarm Polarity Options. 770aeed3e9SJustin Hibbits *//***************************************************************************/ 780aeed3e9SJustin Hibbits typedef enum e_FmRtcAlarmPolarity 790aeed3e9SJustin Hibbits { 80*852ba100SJustin Hibbits e_FM_RTC_ALARM_POLARITY_ACTIVE_HIGH = E_FMAN_RTC_ALARM_POLARITY_ACTIVE_HIGH, /**< Active-high output polarity */ 81*852ba100SJustin Hibbits e_FM_RTC_ALARM_POLARITY_ACTIVE_LOW = E_FMAN_RTC_ALARM_POLARITY_ACTIVE_LOW /**< Active-low output polarity */ 820aeed3e9SJustin Hibbits } e_FmRtcAlarmPolarity; 830aeed3e9SJustin Hibbits 840aeed3e9SJustin Hibbits /**************************************************************************//** 850aeed3e9SJustin Hibbits @Description FM RTC Trigger Polarity Options. 860aeed3e9SJustin Hibbits *//***************************************************************************/ 870aeed3e9SJustin Hibbits typedef enum e_FmRtcTriggerPolarity 880aeed3e9SJustin Hibbits { 89*852ba100SJustin Hibbits e_FM_RTC_TRIGGER_ON_RISING_EDGE = E_FMAN_RTC_TRIGGER_ON_RISING_EDGE, /**< Trigger on rising edge */ 90*852ba100SJustin Hibbits e_FM_RTC_TRIGGER_ON_FALLING_EDGE = E_FMAN_RTC_TRIGGER_ON_FALLING_EDGE /**< Trigger on falling edge */ 910aeed3e9SJustin Hibbits } e_FmRtcTriggerPolarity; 920aeed3e9SJustin Hibbits 930aeed3e9SJustin Hibbits /**************************************************************************//** 940aeed3e9SJustin Hibbits @Description IEEE1588 Timer Module FM RTC Optional Clock Sources. 950aeed3e9SJustin Hibbits *//***************************************************************************/ 960aeed3e9SJustin Hibbits typedef enum e_FmSrcClock 970aeed3e9SJustin Hibbits { 98*852ba100SJustin Hibbits e_FM_RTC_SOURCE_CLOCK_EXTERNAL = E_FMAN_RTC_SOURCE_CLOCK_EXTERNAL, /**< external high precision timer reference clock */ 99*852ba100SJustin Hibbits e_FM_RTC_SOURCE_CLOCK_SYSTEM = E_FMAN_RTC_SOURCE_CLOCK_SYSTEM, /**< MAC system clock */ 100*852ba100SJustin Hibbits e_FM_RTC_SOURCE_CLOCK_OSCILATOR = E_FMAN_RTC_SOURCE_CLOCK_OSCILATOR /**< RTC clock oscilator */ 1010aeed3e9SJustin Hibbits }e_FmSrcClk; 1020aeed3e9SJustin Hibbits 1030aeed3e9SJustin Hibbits /**************************************************************************//** 1040aeed3e9SJustin Hibbits @Description FM RTC configuration parameters structure. 1050aeed3e9SJustin Hibbits 1060aeed3e9SJustin Hibbits This structure should be passed to FM_RTC_Config(). 1070aeed3e9SJustin Hibbits *//***************************************************************************/ 1080aeed3e9SJustin Hibbits typedef struct t_FmRtcParams 1090aeed3e9SJustin Hibbits { 1100aeed3e9SJustin Hibbits t_Handle h_Fm; /**< FM Handle*/ 1110aeed3e9SJustin Hibbits uintptr_t baseAddress; /**< Base address of FM RTC registers */ 1120aeed3e9SJustin Hibbits t_Handle h_App; /**< A handle to an application layer object; This handle will 1130aeed3e9SJustin Hibbits be passed by the driver upon calling the above callbacks */ 1140aeed3e9SJustin Hibbits } t_FmRtcParams; 1150aeed3e9SJustin Hibbits 1160aeed3e9SJustin Hibbits 1170aeed3e9SJustin Hibbits /**************************************************************************//** 1180aeed3e9SJustin Hibbits @Function FM_RTC_Config 1190aeed3e9SJustin Hibbits 1200aeed3e9SJustin Hibbits @Description Configures the FM RTC module according to user's parameters. 1210aeed3e9SJustin Hibbits 1220aeed3e9SJustin Hibbits The driver assigns default values to some FM RTC parameters. 1230aeed3e9SJustin Hibbits These parameters can be overwritten using the advanced 1240aeed3e9SJustin Hibbits configuration routines. 1250aeed3e9SJustin Hibbits 1260aeed3e9SJustin Hibbits @Param[in] p_FmRtcParam - FM RTC configuration parameters. 1270aeed3e9SJustin Hibbits 1280aeed3e9SJustin Hibbits @Return Handle to the new FM RTC object; NULL pointer on failure. 1290aeed3e9SJustin Hibbits 1300aeed3e9SJustin Hibbits @Cautions None 1310aeed3e9SJustin Hibbits *//***************************************************************************/ 1320aeed3e9SJustin Hibbits t_Handle FM_RTC_Config(t_FmRtcParams *p_FmRtcParam); 1330aeed3e9SJustin Hibbits 1340aeed3e9SJustin Hibbits /**************************************************************************//** 1350aeed3e9SJustin Hibbits @Function FM_RTC_Init 1360aeed3e9SJustin Hibbits 1370aeed3e9SJustin Hibbits @Description Initializes the FM RTC driver and hardware. 1380aeed3e9SJustin Hibbits 1390aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 1400aeed3e9SJustin Hibbits 1410aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 1420aeed3e9SJustin Hibbits 1430aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously created using FM_RTC_Config(). 1440aeed3e9SJustin Hibbits *//***************************************************************************/ 1450aeed3e9SJustin Hibbits t_Error FM_RTC_Init(t_Handle h_FmRtc); 1460aeed3e9SJustin Hibbits 1470aeed3e9SJustin Hibbits /**************************************************************************//** 1480aeed3e9SJustin Hibbits @Function FM_RTC_Free 1490aeed3e9SJustin Hibbits 1500aeed3e9SJustin Hibbits @Description Frees the FM RTC object and all allocated resources. 1510aeed3e9SJustin Hibbits 1520aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 1530aeed3e9SJustin Hibbits 1540aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 1550aeed3e9SJustin Hibbits 1560aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously created using FM_RTC_Config(). 1570aeed3e9SJustin Hibbits *//***************************************************************************/ 1580aeed3e9SJustin Hibbits t_Error FM_RTC_Free(t_Handle h_FmRtc); 1590aeed3e9SJustin Hibbits 1600aeed3e9SJustin Hibbits 1610aeed3e9SJustin Hibbits /**************************************************************************//** 1620aeed3e9SJustin Hibbits @Group fm_rtc_adv_config_grp FM RTC Advanced Configuration Unit 1630aeed3e9SJustin Hibbits 1640aeed3e9SJustin Hibbits @Description FM RTC advanced configuration functions. 1650aeed3e9SJustin Hibbits 1660aeed3e9SJustin Hibbits @{ 1670aeed3e9SJustin Hibbits *//***************************************************************************/ 1680aeed3e9SJustin Hibbits 1690aeed3e9SJustin Hibbits /**************************************************************************//** 1700aeed3e9SJustin Hibbits @Function FM_RTC_ConfigPeriod 1710aeed3e9SJustin Hibbits 1720aeed3e9SJustin Hibbits @Description Configures the period of the timestamp if different than 173*852ba100SJustin Hibbits default [DEFAULT_clockPeriod]. 1740aeed3e9SJustin Hibbits 1750aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 1760aeed3e9SJustin Hibbits @Param[in] period - Period in nano-seconds. 1770aeed3e9SJustin Hibbits 1780aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 1790aeed3e9SJustin Hibbits 1800aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously created using FM_RTC_Config(). 1810aeed3e9SJustin Hibbits *//***************************************************************************/ 1820aeed3e9SJustin Hibbits t_Error FM_RTC_ConfigPeriod(t_Handle h_FmRtc, uint32_t period); 1830aeed3e9SJustin Hibbits 1840aeed3e9SJustin Hibbits /**************************************************************************//** 1850aeed3e9SJustin Hibbits @Function FM_RTC_ConfigSourceClock 1860aeed3e9SJustin Hibbits 1870aeed3e9SJustin Hibbits @Description Configures the source clock of the RTC. 1880aeed3e9SJustin Hibbits 1890aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 1900aeed3e9SJustin Hibbits @Param[in] srcClk - Source clock selection. 1910aeed3e9SJustin Hibbits @Param[in] freqInMhz - the source-clock frequency (in MHz). 1920aeed3e9SJustin Hibbits 1930aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 1940aeed3e9SJustin Hibbits 1950aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously created using FM_RTC_Config(). 1960aeed3e9SJustin Hibbits *//***************************************************************************/ 1970aeed3e9SJustin Hibbits t_Error FM_RTC_ConfigSourceClock(t_Handle h_FmRtc, 1980aeed3e9SJustin Hibbits e_FmSrcClk srcClk, 1990aeed3e9SJustin Hibbits uint32_t freqInMhz); 2000aeed3e9SJustin Hibbits 2010aeed3e9SJustin Hibbits /**************************************************************************//** 2020aeed3e9SJustin Hibbits @Function FM_RTC_ConfigPulseRealignment 2030aeed3e9SJustin Hibbits 2040aeed3e9SJustin Hibbits @Description Configures the RTC to automatic FIPER pulse realignment in 205*852ba100SJustin Hibbits response to timer adjustments [DEFAULT_pulseRealign] 2060aeed3e9SJustin Hibbits 2070aeed3e9SJustin Hibbits In this mode, the RTC clock is identical to the source clock. 2080aeed3e9SJustin Hibbits This feature can be useful when the system contains an external 2090aeed3e9SJustin Hibbits RTC with inherent frequency compensation. 2100aeed3e9SJustin Hibbits 2110aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 2120aeed3e9SJustin Hibbits @Param[in] enable - TRUE to enable automatic realignment. 2130aeed3e9SJustin Hibbits 2140aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 2150aeed3e9SJustin Hibbits 2160aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously created using FM_RTC_Config(). 2170aeed3e9SJustin Hibbits *//***************************************************************************/ 2180aeed3e9SJustin Hibbits t_Error FM_RTC_ConfigPulseRealignment(t_Handle h_FmRtc, bool enable); 2190aeed3e9SJustin Hibbits 2200aeed3e9SJustin Hibbits /**************************************************************************//** 2210aeed3e9SJustin Hibbits @Function FM_RTC_ConfigFrequencyBypass 2220aeed3e9SJustin Hibbits 2230aeed3e9SJustin Hibbits @Description Configures the RTC to bypass the frequency compensation 224*852ba100SJustin Hibbits mechanism. [DEFAULT_bypass] 2250aeed3e9SJustin Hibbits 2260aeed3e9SJustin Hibbits In this mode, the RTC clock is identical to the source clock. 2270aeed3e9SJustin Hibbits This feature can be useful when the system contains an external 2280aeed3e9SJustin Hibbits RTC with inherent frequency compensation. 2290aeed3e9SJustin Hibbits 2300aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 2310aeed3e9SJustin Hibbits @Param[in] enabled - TRUE to bypass frequency compensation; 2320aeed3e9SJustin Hibbits FALSE otherwise. 2330aeed3e9SJustin Hibbits 2340aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 2350aeed3e9SJustin Hibbits 2360aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously created using FM_RTC_Config(). 2370aeed3e9SJustin Hibbits *//***************************************************************************/ 2380aeed3e9SJustin Hibbits t_Error FM_RTC_ConfigFrequencyBypass(t_Handle h_FmRtc, bool enabled); 2390aeed3e9SJustin Hibbits 2400aeed3e9SJustin Hibbits /**************************************************************************//** 2410aeed3e9SJustin Hibbits @Function FM_RTC_ConfigInvertedInputClockPhase 2420aeed3e9SJustin Hibbits 2430aeed3e9SJustin Hibbits @Description Configures the RTC to invert the source clock phase on input. 244*852ba100SJustin Hibbits [DEFAULT_invertInputClkPhase] 2450aeed3e9SJustin Hibbits 2460aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 2470aeed3e9SJustin Hibbits @Param[in] inverted - TRUE to invert the source clock phase on input. 2480aeed3e9SJustin Hibbits FALSE otherwise. 2490aeed3e9SJustin Hibbits 2500aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 2510aeed3e9SJustin Hibbits 2520aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously created using FM_RTC_Config(). 2530aeed3e9SJustin Hibbits *//***************************************************************************/ 2540aeed3e9SJustin Hibbits t_Error FM_RTC_ConfigInvertedInputClockPhase(t_Handle h_FmRtc, bool inverted); 2550aeed3e9SJustin Hibbits 2560aeed3e9SJustin Hibbits /**************************************************************************//** 2570aeed3e9SJustin Hibbits @Function FM_RTC_ConfigInvertedOutputClockPhase 2580aeed3e9SJustin Hibbits 2590aeed3e9SJustin Hibbits @Description Configures the RTC to invert the output clock phase. 260*852ba100SJustin Hibbits [DEFAULT_invertOutputClkPhase] 2610aeed3e9SJustin Hibbits 2620aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 2630aeed3e9SJustin Hibbits @Param[in] inverted - TRUE to invert the output clock phase. 2640aeed3e9SJustin Hibbits FALSE otherwise. 2650aeed3e9SJustin Hibbits 2660aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 2670aeed3e9SJustin Hibbits 2680aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously created using FM_RTC_Config(). 2690aeed3e9SJustin Hibbits *//***************************************************************************/ 2700aeed3e9SJustin Hibbits t_Error FM_RTC_ConfigInvertedOutputClockPhase(t_Handle h_FmRtc, bool inverted); 2710aeed3e9SJustin Hibbits 2720aeed3e9SJustin Hibbits /**************************************************************************//** 2730aeed3e9SJustin Hibbits @Function FM_RTC_ConfigOutputClockDivisor 2740aeed3e9SJustin Hibbits 2750aeed3e9SJustin Hibbits @Description Configures the divisor for generating the output clock from 276*852ba100SJustin Hibbits the RTC clock. [DEFAULT_outputClockDivisor] 2770aeed3e9SJustin Hibbits 2780aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 2790aeed3e9SJustin Hibbits @Param[in] divisor - Divisor for generation of the output clock. 2800aeed3e9SJustin Hibbits 2810aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 2820aeed3e9SJustin Hibbits 2830aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously created using FM_RTC_Config(). 2840aeed3e9SJustin Hibbits *//***************************************************************************/ 2850aeed3e9SJustin Hibbits t_Error FM_RTC_ConfigOutputClockDivisor(t_Handle h_FmRtc, uint16_t divisor); 2860aeed3e9SJustin Hibbits 2870aeed3e9SJustin Hibbits /**************************************************************************//** 2880aeed3e9SJustin Hibbits @Function FM_RTC_ConfigAlarmPolarity 2890aeed3e9SJustin Hibbits 2900aeed3e9SJustin Hibbits @Description Configures the polarity (active-high/active-low) of a specific 291*852ba100SJustin Hibbits alarm signal. [DEFAULT_alarmPolarity] 2920aeed3e9SJustin Hibbits 2930aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 2940aeed3e9SJustin Hibbits @Param[in] alarmId - Alarm ID. 2950aeed3e9SJustin Hibbits @Param[in] alarmPolarity - Alarm polarity. 2960aeed3e9SJustin Hibbits 2970aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 2980aeed3e9SJustin Hibbits 2990aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously created using FM_RTC_Config(). 3000aeed3e9SJustin Hibbits *//***************************************************************************/ 3010aeed3e9SJustin Hibbits t_Error FM_RTC_ConfigAlarmPolarity(t_Handle h_FmRtc, 3020aeed3e9SJustin Hibbits uint8_t alarmId, 3030aeed3e9SJustin Hibbits e_FmRtcAlarmPolarity alarmPolarity); 3040aeed3e9SJustin Hibbits 3050aeed3e9SJustin Hibbits /**************************************************************************//** 3060aeed3e9SJustin Hibbits @Function FM_RTC_ConfigExternalTriggerPolarity 3070aeed3e9SJustin Hibbits 3080aeed3e9SJustin Hibbits @Description Configures the polarity (rising/falling edge) of a specific 309*852ba100SJustin Hibbits external trigger signal. [DEFAULT_triggerPolarity] 3100aeed3e9SJustin Hibbits 3110aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 3120aeed3e9SJustin Hibbits @Param[in] triggerId - Trigger ID. 3130aeed3e9SJustin Hibbits @Param[in] triggerPolarity - Trigger polarity. 3140aeed3e9SJustin Hibbits 3150aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 3160aeed3e9SJustin Hibbits 3170aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously created using FM_RTC_Config(). 3180aeed3e9SJustin Hibbits *//***************************************************************************/ 3190aeed3e9SJustin Hibbits t_Error FM_RTC_ConfigExternalTriggerPolarity(t_Handle h_FmRtc, 3200aeed3e9SJustin Hibbits uint8_t triggerId, 3210aeed3e9SJustin Hibbits e_FmRtcTriggerPolarity triggerPolarity); 3220aeed3e9SJustin Hibbits 3230aeed3e9SJustin Hibbits /** @} */ /* end of fm_rtc_adv_config_grp */ 3240aeed3e9SJustin Hibbits /** @} */ /* end of fm_rtc_init_grp */ 3250aeed3e9SJustin Hibbits 3260aeed3e9SJustin Hibbits 3270aeed3e9SJustin Hibbits /**************************************************************************//** 3280aeed3e9SJustin Hibbits @Group fm_rtc_control_grp FM RTC Control Unit 3290aeed3e9SJustin Hibbits 3300aeed3e9SJustin Hibbits @Description FM RTC runtime control API. 3310aeed3e9SJustin Hibbits 3320aeed3e9SJustin Hibbits @{ 3330aeed3e9SJustin Hibbits *//***************************************************************************/ 3340aeed3e9SJustin Hibbits 3350aeed3e9SJustin Hibbits /**************************************************************************//** 3360aeed3e9SJustin Hibbits @Function t_FmRtcExceptionsCallback 3370aeed3e9SJustin Hibbits 3380aeed3e9SJustin Hibbits @Description Exceptions user callback routine, used for RTC different mechanisms. 3390aeed3e9SJustin Hibbits 3400aeed3e9SJustin Hibbits @Param[in] h_App - User's application descriptor. 3410aeed3e9SJustin Hibbits @Param[in] id - source id. 3420aeed3e9SJustin Hibbits *//***************************************************************************/ 3430aeed3e9SJustin Hibbits typedef void (t_FmRtcExceptionsCallback) ( t_Handle h_App, uint8_t id); 3440aeed3e9SJustin Hibbits 3450aeed3e9SJustin Hibbits /**************************************************************************//** 3460aeed3e9SJustin Hibbits @Description FM RTC alarm parameters. 3470aeed3e9SJustin Hibbits *//***************************************************************************/ 3480aeed3e9SJustin Hibbits typedef struct t_FmRtcAlarmParams { 3490aeed3e9SJustin Hibbits uint8_t alarmId; /**< 0 or 1 */ 3500aeed3e9SJustin Hibbits uint64_t alarmTime; /**< In nanoseconds, the time when the alarm 3510aeed3e9SJustin Hibbits should go off - must be a multiple of 3520aeed3e9SJustin Hibbits the RTC period */ 3530aeed3e9SJustin Hibbits t_FmRtcExceptionsCallback *f_AlarmCallback; /**< This routine will be called when RTC 3540aeed3e9SJustin Hibbits reaches alarmTime */ 3550aeed3e9SJustin Hibbits bool clearOnExpiration; /**< TRUE to turn off the alarm once expired. */ 3560aeed3e9SJustin Hibbits } t_FmRtcAlarmParams; 3570aeed3e9SJustin Hibbits 3580aeed3e9SJustin Hibbits /**************************************************************************//** 3590aeed3e9SJustin Hibbits @Description FM RTC Periodic Pulse parameters. 3600aeed3e9SJustin Hibbits *//***************************************************************************/ 3610aeed3e9SJustin Hibbits typedef struct t_FmRtcPeriodicPulseParams { 3620aeed3e9SJustin Hibbits uint8_t periodicPulseId; /**< 0 or 1 */ 3630aeed3e9SJustin Hibbits uint64_t periodicPulsePeriod; /**< In Nanoseconds. Must be 3640aeed3e9SJustin Hibbits a multiple of the RTC period */ 3650aeed3e9SJustin Hibbits t_FmRtcExceptionsCallback *f_PeriodicPulseCallback; /**< This routine will be called every 3660aeed3e9SJustin Hibbits periodicPulsePeriod. */ 3670aeed3e9SJustin Hibbits } t_FmRtcPeriodicPulseParams; 3680aeed3e9SJustin Hibbits 3690aeed3e9SJustin Hibbits /**************************************************************************//** 3700aeed3e9SJustin Hibbits @Description FM RTC Periodic Pulse parameters. 3710aeed3e9SJustin Hibbits *//***************************************************************************/ 3720aeed3e9SJustin Hibbits typedef struct t_FmRtcExternalTriggerParams { 3730aeed3e9SJustin Hibbits uint8_t externalTriggerId; /**< 0 or 1 */ 3740aeed3e9SJustin Hibbits bool usePulseAsInput; /**< Use the pulse interrupt instead of 3750aeed3e9SJustin Hibbits an external signal */ 3760aeed3e9SJustin Hibbits t_FmRtcExceptionsCallback *f_ExternalTriggerCallback; /**< This routine will be called every 3770aeed3e9SJustin Hibbits periodicPulsePeriod. */ 3780aeed3e9SJustin Hibbits } t_FmRtcExternalTriggerParams; 3790aeed3e9SJustin Hibbits 3800aeed3e9SJustin Hibbits 3810aeed3e9SJustin Hibbits /**************************************************************************//** 3820aeed3e9SJustin Hibbits @Function FM_RTC_Enable 3830aeed3e9SJustin Hibbits 3840aeed3e9SJustin Hibbits @Description Enable the RTC (time count is started). 3850aeed3e9SJustin Hibbits 3860aeed3e9SJustin Hibbits The user can select to resume the time count from previous 3870aeed3e9SJustin Hibbits point, or to restart the time count. 3880aeed3e9SJustin Hibbits 3890aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 3900aeed3e9SJustin Hibbits @Param[in] resetClock - Restart the time count from zero. 3910aeed3e9SJustin Hibbits 3920aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 3930aeed3e9SJustin Hibbits 3940aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init(). 3950aeed3e9SJustin Hibbits *//***************************************************************************/ 3960aeed3e9SJustin Hibbits t_Error FM_RTC_Enable(t_Handle h_FmRtc, bool resetClock); 3970aeed3e9SJustin Hibbits 3980aeed3e9SJustin Hibbits /**************************************************************************//** 3990aeed3e9SJustin Hibbits @Function FM_RTC_Disable 4000aeed3e9SJustin Hibbits 4010aeed3e9SJustin Hibbits @Description Disables the RTC (time count is stopped). 4020aeed3e9SJustin Hibbits 4030aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 4040aeed3e9SJustin Hibbits 4050aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 4060aeed3e9SJustin Hibbits 4070aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init(). 4080aeed3e9SJustin Hibbits *//***************************************************************************/ 4090aeed3e9SJustin Hibbits t_Error FM_RTC_Disable(t_Handle h_FmRtc); 4100aeed3e9SJustin Hibbits 4110aeed3e9SJustin Hibbits /**************************************************************************//** 4120aeed3e9SJustin Hibbits @Function FM_RTC_SetClockOffset 4130aeed3e9SJustin Hibbits 4140aeed3e9SJustin Hibbits @Description Sets the clock offset (usually relative to another clock). 4150aeed3e9SJustin Hibbits 4160aeed3e9SJustin Hibbits The user can pass a negative offset value. 4170aeed3e9SJustin Hibbits 4180aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 4190aeed3e9SJustin Hibbits @Param[in] offset - New clock offset (in nanoseconds). 4200aeed3e9SJustin Hibbits 4210aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 4220aeed3e9SJustin Hibbits 4230aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init(). 4240aeed3e9SJustin Hibbits *//***************************************************************************/ 4250aeed3e9SJustin Hibbits t_Error FM_RTC_SetClockOffset(t_Handle h_FmRtc, int64_t offset); 4260aeed3e9SJustin Hibbits 4270aeed3e9SJustin Hibbits /**************************************************************************//** 4280aeed3e9SJustin Hibbits @Function FM_RTC_SetAlarm 4290aeed3e9SJustin Hibbits 4300aeed3e9SJustin Hibbits @Description Schedules an alarm event to a given RTC time. 4310aeed3e9SJustin Hibbits 4320aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 4330aeed3e9SJustin Hibbits @Param[in] p_FmRtcAlarmParams - Alarm parameters. 4340aeed3e9SJustin Hibbits 4350aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 4360aeed3e9SJustin Hibbits 4370aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init(). 4380aeed3e9SJustin Hibbits Must be called only prior to FM_RTC_Enable(). 4390aeed3e9SJustin Hibbits *//***************************************************************************/ 4400aeed3e9SJustin Hibbits t_Error FM_RTC_SetAlarm(t_Handle h_FmRtc, t_FmRtcAlarmParams *p_FmRtcAlarmParams); 4410aeed3e9SJustin Hibbits 4420aeed3e9SJustin Hibbits /**************************************************************************//** 4430aeed3e9SJustin Hibbits @Function FM_RTC_SetPeriodicPulse 4440aeed3e9SJustin Hibbits 4450aeed3e9SJustin Hibbits @Description Sets a periodic pulse. 4460aeed3e9SJustin Hibbits 4470aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 4480aeed3e9SJustin Hibbits @Param[in] p_FmRtcPeriodicPulseParams - Periodic pulse parameters. 4490aeed3e9SJustin Hibbits 4500aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 4510aeed3e9SJustin Hibbits 4520aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init(). 4530aeed3e9SJustin Hibbits Must be called only prior to FM_RTC_Enable(). 4540aeed3e9SJustin Hibbits *//***************************************************************************/ 4550aeed3e9SJustin Hibbits t_Error FM_RTC_SetPeriodicPulse(t_Handle h_FmRtc, t_FmRtcPeriodicPulseParams *p_FmRtcPeriodicPulseParams); 4560aeed3e9SJustin Hibbits 4570aeed3e9SJustin Hibbits /**************************************************************************//** 4580aeed3e9SJustin Hibbits @Function FM_RTC_ClearPeriodicPulse 4590aeed3e9SJustin Hibbits 4600aeed3e9SJustin Hibbits @Description Clears a periodic pulse. 4610aeed3e9SJustin Hibbits 4620aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 4630aeed3e9SJustin Hibbits @Param[in] periodicPulseId - Periodic pulse id. 4640aeed3e9SJustin Hibbits 4650aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 4660aeed3e9SJustin Hibbits 4670aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init(). 4680aeed3e9SJustin Hibbits *//***************************************************************************/ 4690aeed3e9SJustin Hibbits t_Error FM_RTC_ClearPeriodicPulse(t_Handle h_FmRtc, uint8_t periodicPulseId); 4700aeed3e9SJustin Hibbits 4710aeed3e9SJustin Hibbits /**************************************************************************//** 4720aeed3e9SJustin Hibbits @Function FM_RTC_SetExternalTrigger 4730aeed3e9SJustin Hibbits 4740aeed3e9SJustin Hibbits @Description Sets an external trigger indication and define a callback 4750aeed3e9SJustin Hibbits routine to be called on such event. 4760aeed3e9SJustin Hibbits 4770aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 4780aeed3e9SJustin Hibbits @Param[in] p_FmRtcExternalTriggerParams - External Trigger parameters. 4790aeed3e9SJustin Hibbits 4800aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 4810aeed3e9SJustin Hibbits 4820aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init(). 4830aeed3e9SJustin Hibbits *//***************************************************************************/ 4840aeed3e9SJustin Hibbits t_Error FM_RTC_SetExternalTrigger(t_Handle h_FmRtc, t_FmRtcExternalTriggerParams *p_FmRtcExternalTriggerParams); 4850aeed3e9SJustin Hibbits 4860aeed3e9SJustin Hibbits /**************************************************************************//** 4870aeed3e9SJustin Hibbits @Function FM_RTC_ClearExternalTrigger 4880aeed3e9SJustin Hibbits 4890aeed3e9SJustin Hibbits @Description Clears external trigger indication. 4900aeed3e9SJustin Hibbits 4910aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 4920aeed3e9SJustin Hibbits @Param[in] id - External Trigger id. 4930aeed3e9SJustin Hibbits 4940aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 4950aeed3e9SJustin Hibbits 4960aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init(). 4970aeed3e9SJustin Hibbits *//***************************************************************************/ 4980aeed3e9SJustin Hibbits t_Error FM_RTC_ClearExternalTrigger(t_Handle h_FmRtc, uint8_t id); 4990aeed3e9SJustin Hibbits 5000aeed3e9SJustin Hibbits /**************************************************************************//** 5010aeed3e9SJustin Hibbits @Function FM_RTC_GetExternalTriggerTimeStamp 5020aeed3e9SJustin Hibbits 5030aeed3e9SJustin Hibbits @Description Reads the External Trigger TimeStamp. 5040aeed3e9SJustin Hibbits 5050aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 5060aeed3e9SJustin Hibbits @Param[in] triggerId - External Trigger id. 5070aeed3e9SJustin Hibbits @Param[out] p_TimeStamp - External Trigger timestamp (in nanoseconds). 5080aeed3e9SJustin Hibbits 5090aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 5100aeed3e9SJustin Hibbits 5110aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init(). 5120aeed3e9SJustin Hibbits *//***************************************************************************/ 5130aeed3e9SJustin Hibbits t_Error FM_RTC_GetExternalTriggerTimeStamp(t_Handle h_FmRtc, 5140aeed3e9SJustin Hibbits uint8_t triggerId, 5150aeed3e9SJustin Hibbits uint64_t *p_TimeStamp); 5160aeed3e9SJustin Hibbits 5170aeed3e9SJustin Hibbits /**************************************************************************//** 5180aeed3e9SJustin Hibbits @Function FM_RTC_GetCurrentTime 5190aeed3e9SJustin Hibbits 5200aeed3e9SJustin Hibbits @Description Returns the current RTC time. 5210aeed3e9SJustin Hibbits 5220aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 5230aeed3e9SJustin Hibbits @Param[out] p_Ts - returned time stamp (in nanoseconds). 5240aeed3e9SJustin Hibbits 5250aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 5260aeed3e9SJustin Hibbits 5270aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init(). 5280aeed3e9SJustin Hibbits *//***************************************************************************/ 5290aeed3e9SJustin Hibbits t_Error FM_RTC_GetCurrentTime(t_Handle h_FmRtc, uint64_t *p_Ts); 5300aeed3e9SJustin Hibbits 5310aeed3e9SJustin Hibbits /**************************************************************************//** 5320aeed3e9SJustin Hibbits @Function FM_RTC_SetCurrentTime 5330aeed3e9SJustin Hibbits 5340aeed3e9SJustin Hibbits @Description Sets the current RTC time. 5350aeed3e9SJustin Hibbits 5360aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 5370aeed3e9SJustin Hibbits @Param[in] ts - The new time stamp (in nanoseconds). 5380aeed3e9SJustin Hibbits 5390aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 5400aeed3e9SJustin Hibbits 5410aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init(). 5420aeed3e9SJustin Hibbits *//***************************************************************************/ 5430aeed3e9SJustin Hibbits t_Error FM_RTC_SetCurrentTime(t_Handle h_FmRtc, uint64_t ts); 5440aeed3e9SJustin Hibbits 5450aeed3e9SJustin Hibbits /**************************************************************************//** 5460aeed3e9SJustin Hibbits @Function FM_RTC_GetFreqCompensation 5470aeed3e9SJustin Hibbits 548*852ba100SJustin Hibbits @Description Retrieves the frequency compensation value 5490aeed3e9SJustin Hibbits 5500aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 5510aeed3e9SJustin Hibbits @Param[out] p_Compensation - A pointer to the returned value of compensation. 5520aeed3e9SJustin Hibbits 5530aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 5540aeed3e9SJustin Hibbits 5550aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init(). 5560aeed3e9SJustin Hibbits *//***************************************************************************/ 5570aeed3e9SJustin Hibbits t_Error FM_RTC_GetFreqCompensation(t_Handle h_FmRtc, uint32_t *p_Compensation); 5580aeed3e9SJustin Hibbits 5590aeed3e9SJustin Hibbits /**************************************************************************//** 5600aeed3e9SJustin Hibbits @Function FM_RTC_SetFreqCompensation 5610aeed3e9SJustin Hibbits 562*852ba100SJustin Hibbits @Description Sets a new frequency compensation value. 5630aeed3e9SJustin Hibbits 5640aeed3e9SJustin Hibbits @Param[in] h_FmRtc - Handle to FM RTC object. 565*852ba100SJustin Hibbits @Param[in] freqCompensation - The new frequency compensation value to set. 5660aeed3e9SJustin Hibbits 5670aeed3e9SJustin Hibbits @Return E_OK on success; Error code otherwise. 5680aeed3e9SJustin Hibbits 5690aeed3e9SJustin Hibbits @Cautions h_FmRtc must have been previously initialized using FM_RTC_Init(). 5700aeed3e9SJustin Hibbits *//***************************************************************************/ 5710aeed3e9SJustin Hibbits t_Error FM_RTC_SetFreqCompensation(t_Handle h_FmRtc, uint32_t freqCompensation); 5720aeed3e9SJustin Hibbits 573*852ba100SJustin Hibbits #ifdef CONFIG_PTP_1588_CLOCK_DPAA 574*852ba100SJustin Hibbits /**************************************************************************//** 575*852ba100SJustin Hibbits *@Function FM_RTC_EnableInterrupt 576*852ba100SJustin Hibbits * 577*852ba100SJustin Hibbits *@Description Enable interrupt of FM RTC. 578*852ba100SJustin Hibbits * 579*852ba100SJustin Hibbits *@Param[in] h_FmRtc - Handle to FM RTC object. 580*852ba100SJustin Hibbits *@Param[in] events - Interrupt events. 581*852ba100SJustin Hibbits * 582*852ba100SJustin Hibbits *@Return E_OK on success; Error code otherwise. 583*852ba100SJustin Hibbits *//***************************************************************************/ 584*852ba100SJustin Hibbits t_Error FM_RTC_EnableInterrupt(t_Handle h_FmRtc, uint32_t events); 585*852ba100SJustin Hibbits 586*852ba100SJustin Hibbits /**************************************************************************//** 587*852ba100SJustin Hibbits *@Function FM_RTC_DisableInterrupt 588*852ba100SJustin Hibbits * 589*852ba100SJustin Hibbits *@Description Disable interrupt of FM RTC. 590*852ba100SJustin Hibbits * 591*852ba100SJustin Hibbits *@Param[in] h_FmRtc - Handle to FM RTC object. 592*852ba100SJustin Hibbits *@Param[in] events - Interrupt events. 593*852ba100SJustin Hibbits * 594*852ba100SJustin Hibbits *@Return E_OK on success; Error code otherwise. 595*852ba100SJustin Hibbits *//***************************************************************************/ 596*852ba100SJustin Hibbits t_Error FM_RTC_DisableInterrupt(t_Handle h_FmRtc, uint32_t events); 597*852ba100SJustin Hibbits #endif 598*852ba100SJustin Hibbits 5990aeed3e9SJustin Hibbits #if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0)) 6000aeed3e9SJustin Hibbits /**************************************************************************//** 6010aeed3e9SJustin Hibbits @Function FM_RTC_DumpRegs 6020aeed3e9SJustin Hibbits 6030aeed3e9SJustin Hibbits @Description Dumps all FM registers 6040aeed3e9SJustin Hibbits 6050aeed3e9SJustin Hibbits @Param[in] h_FmRtc A handle to an FM RTC Module. 6060aeed3e9SJustin Hibbits 6070aeed3e9SJustin Hibbits @Return E_OK on success; 6080aeed3e9SJustin Hibbits 6090aeed3e9SJustin Hibbits @Cautions Allowed only FM_Init(). 6100aeed3e9SJustin Hibbits *//***************************************************************************/ 6110aeed3e9SJustin Hibbits t_Error FM_RTC_DumpRegs(t_Handle h_FmRtc); 6120aeed3e9SJustin Hibbits #endif /* (defined(DEBUG_ERRORS) && ... */ 6130aeed3e9SJustin Hibbits 6140aeed3e9SJustin Hibbits /** @} */ /* end of fm_rtc_control_grp */ 6150aeed3e9SJustin Hibbits /** @} */ /* end of fm_rtc_grp */ 6160aeed3e9SJustin Hibbits /** @} */ /* end of FM_grp group */ 6170aeed3e9SJustin Hibbits 6180aeed3e9SJustin Hibbits 6190aeed3e9SJustin Hibbits #endif /* __FM_RTC_EXT_H__ */ 620