123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678 |
- //*****************************************************************************
- //
- // am_hal_rtc.c
- //! @file
- //!
- //! @brief Functions for interfacing with the Real-Time Clock (RTC).
- //!
- //! @addtogroup rtc2 Real-Time Clock (RTC)
- //! @ingroup apollo2hal
- //! @{
- //
- //*****************************************************************************
- //*****************************************************************************
- //
- // Copyright (c) 2017, Ambiq Micro
- // All rights reserved.
- //
- // Redistribution and use in source and binary forms, with or without
- // modification, are permitted provided that the following conditions are met:
- //
- // 1. Redistributions of source code must retain the above copyright notice,
- // this list of conditions and the following disclaimer.
- //
- // 2. Redistributions in binary form must reproduce the above copyright
- // notice, this list of conditions and the following disclaimer in the
- // documentation and/or other materials provided with the distribution.
- //
- // 3. Neither the name of the copyright holder nor the names of its
- // contributors may be used to endorse or promote products derived from this
- // software without specific prior written permission.
- //
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- // POSSIBILITY OF SUCH DAMAGE.
- //
- // This is part of revision 1.2.11 of the AmbiqSuite Development Package.
- //
- //*****************************************************************************
- #include <stdint.h>
- #include <stdbool.h>
- #include "am_mcu_apollo.h"
- //*****************************************************************************
- //
- // Converts a Binary Coded Decimal (BCD) byte to its Decimal form.
- //
- //*****************************************************************************
- static uint8_t
- bcd_to_dec(uint8_t ui8BCDByte)
- {
- return (((ui8BCDByte & 0xF0) >> 4) * 10) + (ui8BCDByte & 0x0F);
- }
- //*****************************************************************************
- //
- // Converts a Decimal byte to its Binary Coded Decimal (BCD) form.
- //
- //*****************************************************************************
- static uint8_t
- dec_to_bcd(uint8_t ui8DecimalByte)
- {
- return (((ui8DecimalByte / 10) << 4) | (ui8DecimalByte % 10));
- }
- //*****************************************************************************
- //
- //! @brief Selects the clock source for the RTC.
- //!
- //! @param ui32OSC the clock source for the RTC.
- //!
- //! This function selects the clock source for the RTC.
- //!
- //! Valid values for ui32OSC are:
- //!
- //! AM_HAL_RTC_OSC_LFRC
- //! AM_HAL_RTC_OSC_XT
- //!
- //! @return None
- //
- //*****************************************************************************
- void
- am_hal_rtc_osc_select(uint32_t ui32OSC)
- {
- //
- // Set XT if flag is set.
- // Otherwise configure for LFRC.
- //
- if (ui32OSC)
- {
- AM_REG(CLKGEN, OCTRL) |= AM_REG_CLKGEN_OCTRL_OSEL_M;
- }
- else
- {
- AM_REG(CLKGEN, OCTRL) &= ~AM_REG_CLKGEN_OCTRL_OSEL_M;
- }
- }
- //*****************************************************************************
- //
- //! @brief Enable/Start the RTC oscillator.
- //!
- //! Starts the RTC oscillator.
- //!
- //! @return None.
- //
- //*****************************************************************************
- void
- am_hal_rtc_osc_enable(void)
- {
- //
- // Start the RTC Oscillator.
- //
- AM_REG(RTC, RTCCTL) &= ~AM_REG_RTC_RTCCTL_RSTOP(1);
- }
- //*****************************************************************************
- //
- //! @brief Disable/Stop the RTC oscillator.
- //!
- //! Stops the RTC oscillator.
- //!
- //! @return None.
- //
- //*****************************************************************************
- void
- am_hal_rtc_osc_disable(void)
- {
- //
- // Stop the RTC Oscillator.
- //
- AM_REG(RTC, RTCCTL) |= AM_REG_RTC_RTCCTL_RSTOP(1);
- }
- //*****************************************************************************
- //
- //! @brief Configures the RTC for 12 or 24 hour time keeping.
- //!
- //! @param b12Hour - A 'true' configures the RTC for 12 hour time keeping.
- //!
- //! Configures the RTC for 12 (true) or 24 (false) hour time keeping.
- //!
- //! @return None.
- //
- //*****************************************************************************
- void
- am_hal_rtc_time_12hour(bool b12Hour)
- {
- //
- // Set the 12/24 hour bit.
- //
- AM_REG(RTC, RTCCTL) |= AM_REG_RTC_RTCCTL_HR1224(b12Hour);
- }
- //*****************************************************************************
- //
- //! @brief Enable selected RTC interrupts.
- //!
- //! @param ui32Interrupt - desired interrupts
- //!
- //! Enables the RTC interrupts.
- //!
- //! ui32Interrupt should be an OR of the following:
- //!
- //! AM_HAL_RTC_INT_ALM
- //! AM_HAL_RTC_INT_OF
- //! AM_HAL_RTC_INT_ACC
- //! AM_HAL_RTC_INT_ACF
- //!
- //! @return None.
- //
- //*****************************************************************************
- void
- am_hal_rtc_int_enable(uint32_t ui32Interrupt)
- {
- //
- // Enable the interrupts.
- //
- AM_REG(RTC, INTEN) |= ui32Interrupt;
- }
- //*****************************************************************************
- //
- //! @brief Return the enabled RTC interrupts.
- //!
- //! Returns the enabled RTC interrupts.
- //!
- //! @return enabled RTC interrupts. Return is a logical or of:
- //!
- //! AM_HAL_RTC_INT_ALM
- //! AM_HAL_RTC_INT_OF
- //! AM_HAL_RTC_INT_ACC
- //! AM_HAL_RTC_INT_ACF
- //
- //*****************************************************************************
- uint32_t
- am_hal_rtc_int_enable_get(void)
- {
- //
- // Read the RTC interrupt enable register, and return its contents.
- //
- return AM_REG(RTC, INTEN);
- }
- //*****************************************************************************
- //
- //! @brief Disable selected RTC interrupts.
- //!
- //! @param ui32Interrupt - desired interrupts
- //!
- //! Disables the RTC interrupts.
- //!
- //! ui32Interrupt should be an OR of the following:
- //!
- //! AM_HAL_RTC_INT_ALM
- //! AM_HAL_RTC_INT_OF
- //! AM_HAL_RTC_INT_ACC
- //! AM_HAL_RTC_INT_ACF
- //!
- //! @return None.
- //
- //*****************************************************************************
- void
- am_hal_rtc_int_disable(uint32_t ui32Interrupt)
- {
- //
- // Disable the interrupts.
- //
- AM_REG(RTC, INTEN) &= ~ui32Interrupt;
- }
- //*****************************************************************************
- //
- //! @brief Sets the selected RTC interrupts.
- //!
- //! @param ui32Interrupt - desired interrupts
- //!
- //! Sets the RTC interrupts causing them to immediately trigger.
- //!
- //! ui32Interrupt should be an OR of the following:
- //!
- //! AM_HAL_RTC_INT_ALM
- //! AM_HAL_RTC_INT_OF
- //! AM_HAL_RTC_INT_ACC
- //! AM_HAL_RTC_INT_ACF
- //!
- //! @return None.
- //
- //*****************************************************************************
- void
- am_hal_rtc_int_set(uint32_t ui32Interrupt)
- {
- //
- // Set the interrupts.
- //
- AM_REG(RTC, INTSET) = ui32Interrupt;
- }
- //*****************************************************************************
- //
- //! @brief Clear selected RTC interrupts.
- //!
- //! @param ui32Interrupt - desired interrupts
- //!
- //! Clears the RTC interrupts.
- //!
- //! ui32Interrupt should be an OR of the following:
- //!
- //! AM_HAL_RTC_INT_ALM
- //! AM_HAL_RTC_INT_OF
- //! AM_HAL_RTC_INT_ACC
- //! AM_HAL_RTC_INT_ACF
- //!
- //! @return None.
- //
- //*****************************************************************************
- void
- am_hal_rtc_int_clear(uint32_t ui32Interrupt)
- {
- //
- // Clear the interrupts.
- //
- AM_REG(RTC, INTCLR) = ui32Interrupt;
- }
- //*****************************************************************************
- //
- //! @brief Returns the RTC interrupt status.
- //!
- //! @param bEnabledOnly - return the status of only the enabled interrupts.
- //!
- //! Returns the RTC interrupt status.
- //!
- //! @return Bitwise representation of the current interrupt status.
- //!
- //! The return value will be the logical OR of one or more of the following
- //! values:
- //!
- //! AM_HAL_RTC_INT_ALM
- //! AM_HAL_RTC_INT_OF
- //! AM_HAL_RTC_INT_ACC
- //! AM_HAL_RTC_INT_ACF
- //
- //*****************************************************************************
- uint32_t
- am_hal_rtc_int_status_get(bool bEnabledOnly)
- {
- //
- // Get the interrupt status.
- //
- if (bEnabledOnly)
- {
- uint32_t u32RetVal;
- u32RetVal = AM_REG(RTC, INTSTAT);
- u32RetVal &= AM_REG(RTC, INTEN);
- return u32RetVal &
- (AM_HAL_RTC_INT_ALM | AM_HAL_RTC_INT_OF |
- AM_HAL_RTC_INT_ACC | AM_HAL_RTC_INT_ACF);
- }
- else
- {
- return (AM_REG(RTC, INTSTAT) & (AM_HAL_RTC_INT_ALM |
- AM_HAL_RTC_INT_OF |
- AM_HAL_RTC_INT_ACC |
- AM_HAL_RTC_INT_ACF));
- }
- }
- //*****************************************************************************
- //
- //! @brief Set the Real Time Clock counter registers.
- //!
- //! @param *pTime - A pointer to the time structure.
- //!
- //! Sets the RTC counter registers to the supplied values.
- //!
- //! @return None.
- //
- //*****************************************************************************
- void
- am_hal_rtc_time_set(am_hal_rtc_time_t *pTime)
- {
- //
- // Enable writing to the counters.
- //
- AM_REG(RTC, RTCCTL) |= AM_REG_RTC_RTCCTL_WRTC(1);
- //
- // Write the RTCLOW register.
- //
- AM_REG(RTC, CTRLOW) =
- AM_REG_RTC_CTRLOW_CTRHR(dec_to_bcd(pTime->ui32Hour)) |
- AM_REG_RTC_CTRLOW_CTRMIN(dec_to_bcd(pTime->ui32Minute)) |
- AM_REG_RTC_CTRLOW_CTRSEC(dec_to_bcd(pTime->ui32Second)) |
- AM_REG_RTC_CTRLOW_CTR100(dec_to_bcd(pTime->ui32Hundredths));
- //
- // Write the RTCUP register.
- //
- AM_REG(RTC, CTRUP) =
- AM_REG_RTC_CTRUP_CEB((pTime->ui32CenturyEnable)) |
- AM_REG_RTC_CTRUP_CB((pTime->ui32Century)) |
- AM_REG_RTC_CTRUP_CTRWKDY((pTime->ui32Weekday)) |
- AM_REG_RTC_CTRUP_CTRYR(dec_to_bcd((pTime->ui32Year))) |
- AM_REG_RTC_CTRUP_CTRMO(dec_to_bcd((pTime->ui32Month))) |
- AM_REG_RTC_CTRUP_CTRDATE(dec_to_bcd((pTime->ui32DayOfMonth)));
- //
- // Disable writing to the counters.
- //
- AM_REG(RTC, RTCCTL) |= AM_REG_RTC_RTCCTL_WRTC(0);
- }
- //*****************************************************************************
- //
- //! @brief Get the Real Time Clock current time.
- //!
- //! @param *pTime - A pointer to the time structure to store the current time.
- //!
- //! Gets the RTC's current time
- //!
- //! @return 0 for success and 1 for error.
- //
- //*****************************************************************************
- uint32_t
- am_hal_rtc_time_get(am_hal_rtc_time_t *pTime)
- {
- uint32_t ui32RTCLow, ui32RTCUp, ui32Value;
- //
- // Read the upper and lower RTC registers.
- //
- ui32RTCLow = AM_REG(RTC, CTRLOW);
- ui32RTCUp = AM_REG(RTC, CTRUP);
- //
- // Break out the lower word.
- //
- ui32Value =
- ((ui32RTCLow & AM_REG_RTC_CTRLOW_CTRHR_M) >> AM_REG_RTC_CTRLOW_CTRHR_S);
- pTime->ui32Hour = bcd_to_dec(ui32Value);
- ui32Value =
- ((ui32RTCLow & AM_REG_RTC_CTRLOW_CTRMIN_M) >> AM_REG_RTC_CTRLOW_CTRMIN_S);
- pTime->ui32Minute = bcd_to_dec(ui32Value);
- ui32Value =
- ((ui32RTCLow & AM_REG_RTC_CTRLOW_CTRSEC_M) >> AM_REG_RTC_CTRLOW_CTRSEC_S);
- pTime->ui32Second = bcd_to_dec(ui32Value);
- ui32Value =
- ((ui32RTCLow & AM_REG_RTC_CTRLOW_CTR100_M) >> AM_REG_RTC_CTRLOW_CTR100_S);
- pTime->ui32Hundredths = bcd_to_dec(ui32Value);
- //
- // Break out the upper word.
- //
- pTime->ui32ReadError =
- ((ui32RTCUp & AM_REG_RTC_CTRUP_CTERR_M) >> AM_REG_RTC_CTRUP_CTERR_S);
- pTime->ui32CenturyEnable =
- ((ui32RTCUp & AM_REG_RTC_CTRUP_CEB_M) >> AM_REG_RTC_CTRUP_CEB_S);
- pTime->ui32Century =
- ((ui32RTCUp & AM_REG_RTC_CTRUP_CB_M) >> AM_REG_RTC_CTRUP_CB_S);
- ui32Value =
- ((ui32RTCUp & AM_REG_RTC_CTRUP_CTRWKDY_M) >> AM_REG_RTC_CTRUP_CTRWKDY_S);
- pTime->ui32Weekday = bcd_to_dec(ui32Value);
- ui32Value =
- ((ui32RTCUp & AM_REG_RTC_CTRUP_CTRYR_M) >> AM_REG_RTC_CTRUP_CTRYR_S);
- pTime->ui32Year = bcd_to_dec(ui32Value);
- ui32Value =
- ((ui32RTCUp & AM_REG_RTC_CTRUP_CTRMO_M) >> AM_REG_RTC_CTRUP_CTRMO_S);
- pTime->ui32Month = bcd_to_dec(ui32Value);
- ui32Value =
- ((ui32RTCUp & AM_REG_RTC_CTRUP_CTRDATE_M) >> AM_REG_RTC_CTRUP_CTRDATE_S);
- pTime->ui32DayOfMonth = bcd_to_dec(ui32Value);
- //
- // Was there a read error?
- //
- if (pTime->ui32ReadError)
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- //*****************************************************************************
- //
- //! @brief Sets the alarm repeat interval.
- //!
- //! @param ui32RepeatInterval the desired repeat interval.
- //!
- //! Sets the alarm repeat interval.
- //!
- //! Valid values for ui32RepeatInterval:
- //!
- //! AM_HAL_RTC_ALM_RPT_DIS
- //! AM_HAL_RTC_ALM_RPT_YR
- //! AM_HAL_RTC_ALM_RPT_MTH
- //! AM_HAL_RTC_ALM_RPT_WK
- //! AM_HAL_RTC_ALM_RPT_DAY
- //! AM_HAL_RTC_ALM_RPT_HR
- //! AM_HAL_RTC_ALM_RPT_MIN
- //! AM_HAL_RTC_ALM_RPT_SEC
- //! AM_HAL_RTC_ALM_RPT_10TH
- //! AM_HAL_RTC_ALM_RPT_100TH
- //!
- //! @return None.
- //
- //*****************************************************************************
- void
- am_hal_rtc_alarm_interval_set(uint32_t ui32RepeatInterval)
- {
- uint32_t ui32RptInt, ui32Alm100, ui32Value;
- switch(ui32RepeatInterval)
- {
- //
- // If repeat every 10th set RPT and ALM100 field accordinly
- //
- case AM_HAL_RTC_ALM_RPT_10TH:
- ui32RptInt = AM_HAL_RTC_ALM_RPT_SEC;
- ui32Alm100 = AM_HAL_RTC_ALM100_10TH;
- break;
- //
- // If repeat every 100th set RPT and ALM100 field accordinly
- //
- case AM_HAL_RTC_ALM_RPT_100TH:
- ui32RptInt = AM_HAL_RTC_ALM_RPT_SEC;
- ui32Alm100 = AM_HAL_RTC_ALM100_100TH;
- break;
- //
- // Otherwise set RPT as value passed. ALM100 values need to be 0xnn
- // in this setting where n = 0-9.
- //
- default:
- //
- // Get the current value of the ALM100 field.
- //
- ui32Value = AM_BFR(RTC, ALMLOW, ALM100);
- //
- // If ALM100 was previous EVERY_10TH or EVERY_100TH reset to zero
- // otherwise keep previous setting.
- //
- ui32Alm100 = ui32Value >= 0xF0 ? 0 : ui32Value;
- //
- // Set RPT value to value passed.
- //
- ui32RptInt = ui32RepeatInterval;
- break;
- }
- //
- // Write the interval to the register.
- //
- AM_BFW(RTC, RTCCTL, RPT, ui32RptInt);
- //
- // Write the Alarm 100 bits in the ALM100 register.
- //
- AM_BFW(RTC, ALMLOW, ALM100, ui32Alm100);
- }
- //*****************************************************************************
- //
- //! @brief Sets the RTC's Alarm.
- //!
- //! @param *pTime - A pointer to the time structure.
- //! @param ui32RepeatInterval - the desired alarm repeat interval.
- //!
- //! Set the Real Time Clock Alarm Parameters.
- //!
- //! Valid values for ui32RepeatInterval:
- //!
- //! AM_HAL_RTC_ALM_RPT_DIS
- //! AM_HAL_RTC_ALM_RPT_YR
- //! AM_HAL_RTC_ALM_RPT_MTH
- //! AM_HAL_RTC_ALM_RPT_WK
- //! AM_HAL_RTC_ALM_RPT_DAY
- //! AM_HAL_RTC_ALM_RPT_HR
- //! AM_HAL_RTC_ALM_RPT_MIN
- //! AM_HAL_RTC_ALM_RPT_SEC
- //! AM_HAL_RTC_ALM_RPT_10TH
- //! AM_HAL_RTC_ALM_RPT_EVERY_100TH
- //!
- //! @return None.
- //
- //*****************************************************************************
- void
- am_hal_rtc_alarm_set(am_hal_rtc_time_t *pTime, uint32_t ui32RepeatInterval)
- {
- uint8_t ui8Value = 0;
- //
- // Write the interval to the register.
- //
- AM_REG(RTC, RTCCTL) |=
- AM_REG_RTC_RTCCTL_RPT(ui32RepeatInterval > 0x7 ? 0x7 : ui32RepeatInterval);
- //
- // Check if the interval is 10th or every 100th and track it in ui8Value.
- //
- if (ui32RepeatInterval == AM_HAL_RTC_ALM_RPT_10TH)
- {
- ui8Value = 0xF0;
- }
- else if (ui32RepeatInterval == AM_HAL_RTC_ALM_RPT_100TH)
- {
- ui8Value = 0xFF;
- }
- //
- // Write the ALMUP register.
- //
- AM_REG(RTC, ALMUP) =
- AM_REG_RTC_ALMUP_ALMWKDY((pTime->ui32Weekday)) |
- AM_REG_RTC_ALMUP_ALMMO(dec_to_bcd((pTime->ui32Month))) |
- AM_REG_RTC_ALMUP_ALMDATE(dec_to_bcd((pTime->ui32DayOfMonth)));
- //
- // Write the ALMLOW register.
- //
- AM_REG(RTC, ALMLOW) =
- AM_REG_RTC_ALMLOW_ALMHR(dec_to_bcd(pTime->ui32Hour)) |
- AM_REG_RTC_ALMLOW_ALMMIN(dec_to_bcd(pTime->ui32Minute)) |
- AM_REG_RTC_ALMLOW_ALMSEC(dec_to_bcd(pTime->ui32Second)) |
- AM_REG_RTC_ALMLOW_ALM100(dec_to_bcd(pTime->ui32Hundredths) | ui8Value);
- }
- //*****************************************************************************
- //
- //! @brief Get the Real Time Clock Alarm Parameters
- //!
- //! @param *pTime - A pointer to the time structure to store the current alarm.
- //!
- //! Gets the RTC's Alarm time
- //!
- //! @return None.
- //
- //*****************************************************************************
- void
- am_hal_rtc_alarm_get(am_hal_rtc_time_t *pTime)
- {
- uint32_t ui32ALMLow, ui32ALMUp, ui32Value;
- //
- // Read the upper and lower RTC registers.
- //
- ui32ALMLow = AM_REG(RTC, ALMLOW);
- ui32ALMUp = AM_REG(RTC, ALMUP);
- //
- // Break out the lower word.
- //
- ui32Value =
- ((ui32ALMLow & AM_REG_RTC_ALMLOW_ALMHR_M) >> AM_REG_RTC_ALMLOW_ALMHR_S);
- pTime->ui32Hour = bcd_to_dec(ui32Value);
- ui32Value =
- ((ui32ALMLow & AM_REG_RTC_ALMLOW_ALMMIN_M) >> AM_REG_RTC_ALMLOW_ALMMIN_S);
- pTime->ui32Minute = bcd_to_dec(ui32Value);
- ui32Value =
- ((ui32ALMLow & AM_REG_RTC_ALMLOW_ALMSEC_M) >> AM_REG_RTC_ALMLOW_ALMSEC_S);
- pTime->ui32Second = bcd_to_dec(ui32Value);
- ui32Value =
- ((ui32ALMLow & AM_REG_RTC_ALMLOW_ALM100_M) >> AM_REG_RTC_ALMLOW_ALM100_S);
- pTime->ui32Hundredths = bcd_to_dec(ui32Value);
- //
- // Break out the upper word.
- //
- pTime->ui32ReadError = 0;
- pTime->ui32CenturyEnable = 0;
- pTime->ui32Century = 0;
- ui32Value =
- ((ui32ALMUp & AM_REG_RTC_ALMUP_ALMWKDY_M) >> AM_REG_RTC_ALMUP_ALMWKDY_S);
- pTime->ui32Weekday = bcd_to_dec(ui32Value);
- pTime->ui32Year = 0;
- ui32Value =
- ((ui32ALMUp & AM_REG_RTC_ALMUP_ALMMO_M) >> AM_REG_RTC_ALMUP_ALMMO_S);
- pTime->ui32Month = bcd_to_dec(ui32Value);
- ui32Value =
- ((ui32ALMUp & AM_REG_RTC_ALMUP_ALMDATE_M) >> AM_REG_RTC_ALMUP_ALMDATE_S);
- pTime->ui32DayOfMonth = bcd_to_dec(ui32Value);
- }
- //*****************************************************************************
- //
- // End Doxygen group.
- //! @}
- //
- //*****************************************************************************
|