Skip to content

Commit

Permalink
mcu: apollo4p: Update RTC for ERR126
Browse files Browse the repository at this point in the history
Updated RTC due to Errata ERR126

Signed-off-by: Richard Wheatley <[email protected]>
  • Loading branch information
RichardSWheatley committed Aug 5, 2024
1 parent c6d8093 commit df4a986
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 34 deletions.
13 changes: 5 additions & 8 deletions mcu/apollo4p/hal/mcu/am_hal_rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

//*****************************************************************************
//
// Copyright (c) 2023, Ambiq Micro, Inc.
// Copyright (c) 2024, Ambiq Micro, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -41,7 +41,7 @@
// 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 stable-7da8bae71f of the AmbiqSuite Development Package.
// This is part of revision release_sdk_4_5_0-a1ef3b89f9 of the AmbiqSuite Development Package.
//
//*****************************************************************************

Expand Down Expand Up @@ -253,8 +253,7 @@ am_hal_rtc_time_set(am_hal_rtc_time_t *pTime)
// Write the RTCUP register.
//
RTC->CTRUP =
_VAL2FLD(RTC_CTRUP_CEB, (pTime->ui32CenturyEnable)) |
_VAL2FLD(RTC_CTRUP_CB, (pTime->ui32Century)) |
_VAL2FLD(RTC_CTRUP_CB, (pTime->ui32CenturyBit)) |
_VAL2FLD(RTC_CTRUP_CTRWKDY, (pTime->ui32Weekday)) |
_VAL2FLD(RTC_CTRUP_CTRYR, dec_to_bcd((pTime->ui32Year))) |
_VAL2FLD(RTC_CTRUP_CTRMO, dec_to_bcd((pTime->ui32Month))) |
Expand Down Expand Up @@ -315,9 +314,8 @@ am_hal_rtc_time_get(am_hal_rtc_time_t *pTime)
//
// Break out the upper word.
//
pTime->ui32CenturyEnable = _FLD2VAL(RTC_CTRUP_CEB, ui32RTCUp);

pTime->ui32Century = _FLD2VAL(RTC_CTRUP_CB, ui32RTCUp);
pTime->ui32CenturyBit = _FLD2VAL(RTC_CTRUP_CB, ui32RTCUp);

ui32Value = _FLD2VAL(RTC_CTRUP_CTRWKDY, ui32RTCUp);
pTime->ui32Weekday = bcd_to_dec(ui32Value);
Expand Down Expand Up @@ -511,9 +509,8 @@ am_hal_rtc_alarm_get(am_hal_rtc_time_t *pTime,
//
// Break out the upper word.
//
pTime->ui32CenturyBit = 0;
pTime->ui32ReadError = 0;
pTime->ui32CenturyEnable = 0;
pTime->ui32Century = 0;

ui32Value = ((ui32ALMUp & RTC_ALMUP_ALMWKDY_Msk) >> RTC_ALMUP_ALMWKDY_Pos);
pTime->ui32Weekday = bcd_to_dec(ui32Value);
Expand Down
29 changes: 3 additions & 26 deletions mcu/apollo4p/hal/mcu/am_hal_rtc.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

//*****************************************************************************
//
// Copyright (c) 2023, Ambiq Micro, Inc.
// Copyright (c) 2024, Ambiq Micro, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -41,7 +41,7 @@
// 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 stable-7da8bae71f of the AmbiqSuite Development Package.
// This is part of revision release_sdk_4_5_0-a1ef3b89f9 of the AmbiqSuite Development Package.
//
//*****************************************************************************
#ifndef AM_HAL_RTC_H
Expand Down Expand Up @@ -134,9 +134,8 @@ am_hal_rtc_config_t;
typedef struct am_hal_rtc_time_struct
{
uint32_t ui32ReadError;
uint32_t ui32CenturyEnable;
uint32_t ui32Weekday;
uint32_t ui32Century;
uint32_t ui32CenturyBit;
uint32_t ui32Year;
uint32_t ui32Month;
uint32_t ui32DayOfMonth;
Expand Down Expand Up @@ -196,28 +195,6 @@ extern uint32_t am_hal_rtc_osc_enable(void);
//*****************************************************************************
extern uint32_t am_hal_rtc_osc_disable(void);

//*****************************************************************************
//
//! @brief Enable/Start the RTC.
//!
//! Starts the RTC.
//!
//! @return AM_HAL_STATUS_SUCCESS or relevant HAL error code.
//
//*****************************************************************************
extern uint32_t am_hal_rtc_enable(void);

//*****************************************************************************
//
//! @brief Disable/Stop the RTC.
//!
//! Stops the RTC.
//!
//! @return AM_HAL_STATUS_SUCCESS or relevant HAL error code.
//
//*****************************************************************************
extern uint32_t am_hal_rtc_disable(void);

//*****************************************************************************
//
//! @brief Set the Real Time Clock counter registers.
Expand Down

0 comments on commit df4a986

Please sign in to comment.