mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #6852 from mprse/issue_5308_fix
Fix for issue #5308 - RTC set/get time issue on NCS36510pull/6887/head
commit
30e39eeb10
|
@ -144,7 +144,7 @@ void test_attach_RTC_stub_funtions()
|
|||
TEST_ASSERT_EQUAL(false, rtc_init_called);
|
||||
|
||||
/* Check if time has been successfully set and retrieved. */
|
||||
TEST_ASSERT_EQUAL(CUSTOM_TIME_1, seconds);
|
||||
TEST_ASSERT_UINT32_WITHIN(RTC_DELTA, CUSTOM_TIME_1, seconds);
|
||||
}
|
||||
|
||||
/* This test verifies if attach_rtc provides availability to
|
||||
|
@ -183,7 +183,7 @@ void test_attach_RTC_org_funtions()
|
|||
TEST_ASSERT_EQUAL(false, rtc_init_called);
|
||||
|
||||
/* Check if time has been successfully set and retrieved. */
|
||||
TEST_ASSERT_EQUAL(CUSTOM_TIME_1, seconds);
|
||||
TEST_ASSERT_UINT32_WITHIN(RTC_DELTA, CUSTOM_TIME_1, seconds);
|
||||
}
|
||||
|
||||
/* This test verifies if time() function returns
|
||||
|
@ -430,7 +430,7 @@ void test_functional_set()
|
|||
set_time(timeValue);
|
||||
|
||||
/* Get current time and verify that new value has been set. */
|
||||
TEST_ASSERT_EQUAL(timeValue, time(NULL));
|
||||
TEST_ASSERT_UINT32_WITHIN(1, timeValue, time(NULL));
|
||||
}
|
||||
|
||||
/* This test verifies if RTC counts seconds.
|
||||
|
|
|
@ -39,6 +39,15 @@
|
|||
#include "rtc.h"
|
||||
#include "cmsis_nvic.h"
|
||||
|
||||
#define US_PER_SEC 1000000
|
||||
|
||||
static time_t m_time_base;
|
||||
|
||||
static uint32_t rtc_seconds_get()
|
||||
{
|
||||
return (uint32_t)((fRtcRead() / US_PER_SEC) & 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
/* See rtc_apc.h for description */
|
||||
|
||||
void rtc_init(void)
|
||||
|
@ -61,13 +70,20 @@ int rtc_isenabled(void)
|
|||
/* See rtc_apc.h for description */
|
||||
time_t rtc_read(void)
|
||||
{
|
||||
return (uint32_t)(fRtcRead() & 0xFFFFFFFF); /* TODO Truncating 64 bit value to 32 bit */
|
||||
return m_time_base + rtc_seconds_get();
|
||||
}
|
||||
|
||||
/* See rtc_apc.h for description */
|
||||
void rtc_write(time_t t)
|
||||
{
|
||||
fRtcWrite(t);
|
||||
uint32_t seconds;
|
||||
do {
|
||||
seconds = rtc_seconds_get();
|
||||
m_time_base = t - seconds;
|
||||
/* If the number of seconds indicated by the counter changed during the
|
||||
update of the time base, just repeat the update, now using the new
|
||||
number of seconds. */
|
||||
} while (seconds != rtc_seconds_get());
|
||||
}
|
||||
|
||||
#endif /* DEVICE_RTC */
|
||||
|
|
|
@ -3753,7 +3753,7 @@
|
|||
"post_binary_hook": {"function": "NCS36510TargetCode.ncs36510_addfib"},
|
||||
"macros": ["CM3", "CPU_NCS36510", "TARGET_NCS36510", "LOAD_ADDRESS=0x3000"],
|
||||
"supported_toolchains": ["GCC_ARM", "ARM", "IAR"],
|
||||
"device_has": ["ANALOGIN", "SERIAL", "I2C", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "LOWPOWERTIMER", "TRNG", "SPISLAVE"],
|
||||
"device_has": ["ANALOGIN", "SERIAL", "I2C", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "LOWPOWERTIMER", "TRNG", "SPISLAVE", "RTC"],
|
||||
"release_versions": ["2", "5"]
|
||||
},
|
||||
"NUMAKER_PFM_M453": {
|
||||
|
|
Loading…
Reference in New Issue