Skip to content

Commit 45adb69

Browse files
committed
[drivers][rtc] Fixed software and hardware rtc device naming as rtc
1 parent ee5b7f1 commit 45adb69

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

components/drivers/rtc/dev_alarm.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006-2023, RT-Thread Development Team
2+
* Copyright (c) 2006-2024 RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -52,11 +52,7 @@ static rt_err_t alarm_set(struct rt_alarm *alarm)
5252
struct rt_rtc_wkalarm wkalarm;
5353
rt_err_t ret;
5454

55-
#ifdef RT_USING_SOFT_RTC
56-
device = rt_device_find("sw_rtc");
57-
#else
5855
device = rt_device_find("rtc");
59-
#endif
6056

6157
if (device == RT_NULL)
6258
{
@@ -813,4 +809,4 @@ int rt_alarm_system_init(void)
813809
}
814810

815811
INIT_PREV_EXPORT(rt_alarm_system_init);
816-
#endif
812+
#endif

components/drivers/rtc/dev_soft_rtc.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006-2023, RT-Thread Development Team
2+
* Copyright (c) 2006-2024 RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -226,8 +226,11 @@ static int rt_soft_rtc_init(void)
226226
{
227227
return 0;
228228
}
229-
/* make sure only one 'sw_rtc' device */
230-
RT_ASSERT(!rt_device_find("sw_rtc"));
229+
/* make sure only one 'rtc' device */
230+
#if defined(RT_USING_SOFT_RTC) && defined(RT_USING_RTC)
231+
#warning "Please note: Currently only one RTC device is allowed in the system, and the name is "rtc"."
232+
#endif
233+
RT_ASSERT(!rt_device_find("rtc"));
231234

232235
#ifdef RT_USING_ALARM
233236
rt_timer_init(&alarm_time,
@@ -258,7 +261,7 @@ static int rt_soft_rtc_init(void)
258261
/* no private */
259262
soft_rtc_dev.user_data = RT_NULL;
260263

261-
rt_device_register(&soft_rtc_dev, "sw_rtc", RT_DEVICE_FLAG_RDWR);
264+
rt_device_register(&soft_rtc_dev, "rtc", RT_DEVICE_FLAG_RDWR);
262265

263266
source_device = &soft_rtc_dev;
264267

@@ -294,7 +297,7 @@ static void rtc_sync_work_func(struct rt_work *work, void *work_data)
294297
rt_err_t rt_soft_rtc_set_source(const char *name)
295298
{
296299
RT_ASSERT(name != RT_NULL);
297-
RT_ASSERT(rt_device_find(name)); // make sure source is exist
300+
RT_ASSERT(rt_device_find(name)); /* make sure source is exist*/
298301

299302
source_device = rt_device_find(name);
300303
rt_work_init(&rtc_sync_work, rtc_sync_work_func, RT_NULL);
@@ -324,4 +327,4 @@ MSH_CMD_EXPORT_ALIAS(cmd_rtc_sync, rtc_sync, Update time by soft rtc);
324327

325328
#endif /* RT_USING_SYSTEM_WORKQUEUE */
326329

327-
#endif /* RT_USING_SOFT_RTC */
330+
#endif /* RT_USING_SOFT_RTC */

0 commit comments

Comments
 (0)