#define DBG_SECtiON_NAME "drv_rtc"
#define DBG_LEVEL DBG_INFO
#include
static struct rt_rtc_device rtc_device;
#ifdef RT_USING_ALARM
静态 rt_err_t rtc_alarm_time_set(struct rt_rtc_device* p_dev);
静态 int rt_rtc_alarm_init(void);
静态 RTC_AlarmTypeDef 警报结构;
#endif
#ifndef RTC_BKP_DR1
#define RTC_BKP_DR1 RT_NULL
#endif
#define BKUP_REG_DATA 0xA5A5
static RTC_HandleTypeDef RTC_Handler;
RT_WEAK uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister)
{
return (~BKUP_REG_DATA);
}
RT_WEAK void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data)
{
return;
}
静态 time_t get_rtc_timestamp(void)
{
RTC_TimeTypeDef RTC_TimeStruct = {0};
RTC_DateTypeDef RTC_DateStruct = {0};
结构 tm tm_new = {0};
HAL_RTC_GetTime(&RTC_Handler, &RTC_TimeStruct, RTC_FORMAT_BIN);
HAL_RTC_GetDate(&RTC_Handler, &RTC_DateStruct, RTC_FORMAT_BIN);
tm_new.tm_sec = RTC_TimeStruct.Seconds;
tm_new.tm_min = RTC_TimeStruct.Minutes;
tm_new.tm_hour = RTC_TimeStruct.Hours;
tm_new.tm_mday = RTC_DateStruct.Date;
tm_new.tm_mon = RTC_DateStruct.Month - 1;
tm_new.tm_year = RTC_DateStruct.Year + 100;
返回 mktime(&tm_new);
}
静态 rt_err_t set_rtc_time_stamp(time_t time_stamp)
{
RTC_TimeTypeDef RTC_TimeStruct = {0};
RTC_DateTypeDef RTC_DateStruct = {0};
结构 tm *p_tm;
p_tm = localtime(&time_stamp);
if (p_tm->tm_year < 100)
{
return -RT_ERROR;
}
RTC_TimeStruct.Seconds = p_tm->tm_sec ;
RTC_TimeStruct.Minutes = p_tm->tm_min ;
RTC_TimeStruct.Hours = p_tm->tm_hour;
RTC_DateStruct.Date = p_tm->tm_mday;
RTC_DateStruct.Month = p_tm->tm_mon + 1 ;
RTC_DateStruct.Year = p_tm->tm_year - 100;
RTC_DateStruct.WeekDay = p_tm->tm_wday + 1;
if (HAL_RTC_SetTime(&RTC_Handler, &RTC_TimeStruct, RTC_FORMAT_BIN) != HAL_OK)
{
return -RT_ERROR;
}
if (HAL_RTC_SetDate(&RTC_Handler, &RTC_DateStruct, RTC_FORMAT_BIN) != HAL_OK)
{
return -RT_ERROR;
}
LOG_D("设置 rtc 时间。");
HAL_RTCEx_BKUPWrite(&RTC_Handler, RTC_BKP_DR1, BKUP_REG_DATA);
#ifdef SOC_SERIES_STM32F1
/* F1 系列不保存年/月/日数据。所以将这些数据保存到 bkp reg */
HAL_RTCEx_BKUPWrite(&RTC_Handler, RTC_BKP_DR2, RTC_DateStruct.Year);
HAL_RTCEx_BKUPWrite(&RTC_Handler, RTC_BKP_DR3, RTC_DateStruct.Month);
HAL_RTCEx_BKUPWrite(&RTC_Handler, RTC_BKP_DR4, RTC_DateStruct.Date);
HAL_RTCEx_BKUPWrite(&RTC_Handler, RTC_BKP_DR5, RTC_DateStruct.WeekDay);
#endif
返回 RT_EOK;
}
静态无效 rt_rtc_init(void)
{
#if !defined(SOC_SERIES_STM32H7) && !defined(SOC_SERIES_STM32WB)
__HAL_RCC_PWR_CLK_ENABLE();
#endif
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
#ifdef BSP_RTC_USING_LSI
#ifdef SOC_SERIES_STM32WB
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI1;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
#别的
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
#endif
#else
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.LSIState = RCC_LSI_OFF;
#endif
HAL_RCC_OscConfig(&RCC_OscInitStruct);
}
#ifdef SOC_SERIES_STM32F1
/* 更新 RTC_BKP_DRx*/
static void rt_rtc_f1_bkp_update(void)
{
RTC_DateTypeDef RTC_DateStruct = {0};
HAL_PWR_EnableBkUpAccess();
__HAL_RCC_BKP_CLK_ENABLE();
RTC_DateStruct.Year = HAL_RTCEx_BKUPRead(&RTC_Handler, RTC_BKP_DR2);
RTC_DateStruct.Month = HAL_RTCEx_BKUPRead(&RTC_Handler, RTC_BKP_DR3);
RTC_DateStruct.Date = HAL_RTCEx_BKUPRead(&RTC_Handler, RTC_BKP_DR4);
RTC_DateStruct.WeekDay = HAL_RTCEx_BKUPRead(&RTC_Handler, RTC_BKP_DR5);
if (HAL_RTC_SetDate(&RTC_Handler, &RTC_DateStruct, RTC_FORMAT_BIN) != HAL_OK)
{
Error_Handler();
}
HAL_RTC_GetDate(&RTC_Handler, &RTC_DateStruct, RTC_FORMAT_BIN);
if (HAL_RTCEx_BKUPRead(&RTC_Handler, RTC_BKP_DR4) != RTC_DateStruct.Date)
{
HAL_RTCEx_BKUPWrite(&RTC_Handler, RTC_BKP_DR1, BKUP_REG_DATA);
HAL_RTCEx_BKUPWrite(&RTC_Handler, RTC_BKP_DR2, RTC_DateStruct.Year);
HAL_RTCEx_BKUPWrite(&RTC_Handler, RTC_BKP_DR3, RTC_DateStruct.Month);
HAL_RTCEx_BKUPWrite(&RTC_Handler, RTC_BKP_DR4, RTC_DateStruct.Date);
HAL_RTCEx_BKUPWrite(&RTC_Handler, RTC_BKP_DR5, RTC_DateStruct.WeekDay);
}
}
#endif
静态 rt_err_t rt_rtc_config(struct rt_device *dev)
{
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
HAL_PWR_EnableBkUpAccess();
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
#ifdef BSP_RTC_USING_LSI
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;
#else
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
#endif
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
/* 启用 RTC 时钟 */
__HAL_RCC_RTC_ENABLE();
RTC_Handler.Instance = RTC;
if (HAL_RTCEx_BKUPRead(&RTC_Handler, RTC_BKP_DR1) != BKUP_REG_DATA)
{
LOG_I("RTC尚未配置,请使用命令配置。");
#如果定义(SOC_SERIES_STM32F1)
RTC_Handler.Init.OutPut = RTC_OUTPUTSOURCE_NONE;
RTC_Handler.Init.AsynchPrediv = RTC_AUTO_1_SECOND;
#elif 定义(SOC_SERIES_STM32F0)
/* 设置分频 */
#ifdef BSP_RTC_USING_LSI
RTC_Handler.Init.AsynchPrediv = 0XA0;
RTC_Handler.Init.SynchPrediv = 0xFA;
#else
RTC_Handler.Init.AsynchPrediv = 0X7F;
RTC_Handler.Init.SynchPrediv = 0x0130;
#endif /* BSP_RTC_USING_LSI */
RTC_Handler.Init.HourFormat = RTC_HOURFORMAT_24;
RTC_Handler.Init.OutPut = RTC_OUTPUT_DISABLE;
RTC_Handler.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
RTC_Handler.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
#elif 定义(SOC_SERIES_STM32F2)|| 定义(SOC_SERIES_STM32F4)|| 定义(SOC_SERIES_STM32F7)|| 定义(SOC_SERIES_STM32L4)|| 定义(SOC_SERIES_STM32H7)|| defined (SOC_SERIES_STM32WB)
/* 设置分频 */
#ifdef BSP_RTC_USING_LSI
RTC_Handler.Init.AsynchPrediv = 0X7D;
#else
RTC_Handler.Init.AsynchPrediv = 0X7F;
#endif /* BSP_RTC_USING_LSI */
RTC_Handler.Init.SynchPrediv = 0XFF;
RTC_Handler.Init.HourFormat = RTC_HOURFORMAT_24;
RTC_Handler.Init.OutPut = RTC_OUTPUT_DISABLE;
RTC_Handler.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
RTC_Handler.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
#万一
if (HAL_RTC_Init(&RTC_Handler) != HAL_OK)
{
return -RT_ERROR;
}
}
#ifdef SOC_SERIES_STM32F1
else
{
/* F1 系列需要通过 bkp reg datas 更新 */
rt_rtc_f1_bkp_update();
}
#endif
返回 RT_EOK;
}
静态 rt_err_t rt_rtc_control(rt_device_t dev, int cmd, void *args)
{
rt_err_t 结果 = RT_EOK;
#ifdef RT_USING_ALARM
结构 rt_rtc_wkaarm *p_wkalarm = RT_NULL;
#endif
RT_ASSERT(dev != RT_NULL);
开关 (cmd)
{
案例 RT_DEVICE_CTRL_RTC_GET_TIME:
*(rt_uint32_t *)args = get_rtc_timestamp();
LOG_D("RTC: 获取 rtc_time %x
", *(rt_uint32_t *)args);
休息;
案例 RT_DEVICE_CTRL_RTC_SET_TIME:
if (set_rtc_time_stamp(*(rt_uint32_t *)args))
{
result = -RT_ERROR;
}
#ifdef RT_USING_ALARM
rt_alarm_update(&rtc_device.device, 1);
#endif
LOG_D("RTC: 设置 rtc_time %x
", *(rt_uint32_t *)args);
休息;
#ifdef RT_USING_ALARM
案例 RT_DEVICE_CTRL_RTC_GET_ALARM:
args = &rtc_device.wkalarm;
LOG_D("GET_ALARM %d:%d:%d",rtc_device.wkaarm.tm_hour,
rtc_device.wkaarm.tm_min,rtc_device.wkaarm.tm_sec);
休息;
案例 RT_DEVICE_CTRL_RTC_SET_ALARM:
LOG_D("RT_DEVICE_CTRL_RTC_SET_ALARM");
p_wkaarm = (struct rt_rtc_wkaarm *)args;
如果(p_wkalarm!= RT_NULL)
{
rtc_device.wkalarm.enable = p_wkalarm->启用;
rtc_device.wkaarm.tm_hour = p_wkaarm->tm_hour;
rtc_device.wkaarm.tm_min = p_wkaarm->tm_min;
rtc_device.wkaarm.tm_sec = p_wkaarm->tm_sec;
rtc_alarm_time_set(&rtc_device);
}
其他
{
结果 = -RT_ERROR;
LOG_E("RT_DEVICE_CTRL_RTC_SET_ALARM 错误!!");
}
LOG_D("SET_ALARM %d:%d:%d",p_wkalarm->tm_hour,
p_wkalarm->tm_min,p_wkaarm->tm_sec);
休息;
#endif
}
返回结果;
}
#ifdef RT_USING_DEVICE_OPS
常量静态结构 rt_device_ops rtc_ops =
{
RT_NULL,
RT_NULL,
RT_NULL,
RT_NULL,
RT_NULL,
rt_rtc_control
};
#endif
static rt_err_t rt_hw_rtc_register(rt_device_t device, const char *name, rt_uint32_t flag)
{
RT_ASSERT(device != RT_NULL);
rt_rtc_init();
if (rt_rtc_config(device) != RT_EOK)
{
return -RT_ERROR;
}
#ifdef RT_USING_DEVICE_OPS
设备->ops = &rtc_ops;
#else
设备->init = RT_NULL;
设备->打开 = RT_NULL;
设备->关闭 = RT_NULL;
设备->读取 = RT_NULL;
设备->写= RT_NULL;
设备->控制 = rt_rtc_control;
#endif
设备->类型 = RT_Device_Class_RTC;
设备->rx_indicate = RT_NULL;
设备->tx_complete = RT_NULL;
设备->user_data = RT_NULL;
/* 注册一个字符设备 */
return rt_device_register(device, name, flag);
}
int rt_hw_rtc_init(void)
{
rt_err_t 结果;
结果 = rt_hw_rtc_register(&rtc_device.device, "rtc", RT_DEVICE_FLAG_RDWR);
if (result != RT_EOK)
{
LOG_E("rtc register err code: %d
", result);
返回结果;
}
#ifdef RT_USING_ALARM
rt_rtc_alarm_init();
#endif
LOG_D("rtc 初始化成功
");
返回 RT_EOK;
}
#ifdef RT_USING_ALARM
无效 rt_rtc_alarm_enable(void)
{
HAL_RTC_SetAlarm_IT(&RTC_Handler,&salarmstructure,RTC_FORMAT_BIN);
HAL_RTC_GetAlarm(&RTC_Handler,&salarmstructure,RTC_ALARM_A,RTC_FORMAT_BIN);
LOG_D("报警读取:%d:%d:%d", salarmstructure.AlarmTime.Hours,
salarmstructure.AlarmTime.Minutes,
salarmstructure.AlarmTime.Seconds);
HAL_NVIC_SetPriority(RTC_Alarm_IRQn, 0x02, 0);
HAL_NVIC_EnableIRQ(RTC_Alarm_IRQn);
}
void rt_rtc_alarm_disable(void)
{
HAL_RTC_DeactivateAlarm(&RTC_Handler, RTC_ALARM_A);
HAL_NVIC_DisableIRQ(RTC_Alarm_IRQn);
}
static int rt_rtc_alarm_init(void)
{
return RT_EOK;
}
静态 rt_err_t rtc_alarm_time_set(struct rt_rtc_device* p_dev)
{
if (p_dev->wkalarm.enable)
{
salarmstructure.Alarm = RTC_ALARM_A;
salarmstructure.AlarmDateWeekDay = RTC_WEEKDAY_MONDAY;
salarmstructure.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_WEEKDAY;
salarmstructure.AlarmMask = RTC_ALARMMASK_DATEWEEKDAY;
salarmstructure.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_NONE;
salarmstructure.AlarmTime.TimeFormat = RTC_HOURFORMAT12_AM;
salarmstructure.AlarmTime.Hours = p_dev->wkaarm.tm_hour;
salarmstructure.AlarmTime.Minutes = p_dev->wkaarm.tm_min;
salarmstructure.AlarmTime.Seconds = p_dev->wkaarm.tm_sec;
LOG_D("报警设置:%d:%d:%d", salarmstructure.AlarmTime.Hours,
salarmstructure.AlarmTime.Minutes,
salarmstructure.AlarmTime.Seconds);
rt_rtc_alarm_enable();
}
返回 RT_EOK;
}
void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc)
{
//LOG_D("rtc alarm isr.
");
rt_alarm_update(&rtc_device.device, 1);
}
void RTC_Alarm_IRQHandler(void)
{
HAL_RTC_AlarmIRQHandler(&RTC_Handler);
}
#endif
INIT_DEVICE_EXPORT(rt_hw_rtc_init);
#endif /* BSP_USING_ONCHIP_RTC */
RTC_Alarm 测试代码,供
#include
#include "board.h"
#include
#include
#define RTC_DEBUG
#define DBG_ENABLE
#define DBG_SECTION_NAME “rtc.test”
#define DBG_LEVEL DBG_LOG
#include
#ifdef RTC_DEBUG
静态结构 rt_alarm * p_alarm_sec = RT_NULL;
静态结构 rt_alarm * p_alarm_min = RT_NULL;
静态结构 rt_alarm * p_alarm_hour = RT_NULL;
静态结构 rt_alarm * p_alarm_time = RT_NULL;
static rt_err_t rtc_set_time(time_t timestamp)
{
/* 将本地时间及时转换为日历时间。*/
rt_device_t rtc_device;
rt_err_t ret = -RT_ERROR;
rtc_device = rt_device_find("rtc");
if (rtc_device == RT_NULL)
{
return -RT_ERROR;
}
/* 更新到 RTC 设备。*/
ret = rt_device_control(rtc_device, RT_DEVICE_CTRL_RTC_SET_TIME, ×tamp);
返回 ret;
}
static time_t rtc_gettime(void)
{
static time_t now;
静态结构 tm tm;
现在 = 时间(NULL);
#ifdef _WIN32
_gmtime32_s(&tm, &now);
#else
gmtime_r(&now, &tm);
#endif
LOG_D("北京时间:%04d-%02d-%02d %02d:%02d:%02d.% 03d
",
tm.tm_year + 1900, tm.tm_mon + 1,
tm.tm_mday, tm.tm_hour + 8 , tm.tm_min,
tm.tm_sec, rt_tick_get() % 1000);
立即返回;
}
静态无效alarm_time_cb(rt_alarm_t警报,time_t时间戳)
{
LOG_D("alarm_time_cb ok!
");
}
static void alarm_hour_cb(rt_alarm_t 闹钟,time_t 时间戳)
{
LOG_D("alarm_hour_cb ok!
");
}
static void alarm_minute_cb(rt_alarm_t 警报,time_t 时间戳)
{
LOG_D("alarm_minute_cb ok!
");
}
static void alarm_second_cb(rt_alarm_t 警报,time_t 时间戳)
{
LOG_D("alarm_second_cb ok!
");
}
静态结构 rt_alarm * rtc_alarm_test_create(rt_alarm_callback_t 回调,rt_uint32_t 标志,结构 tm *p_tm)
{
结构 rt_alarm_setup alarm_setup_test;
alarm_setup_test.flag = 标志;
alarm_setup_test.wktime.tm_year = p_tm->tm_year;
alarm_setup_test.wktime.tm_mon = p_tm->tm_mon;
alarm_setup_test.wktime.tm_mday = p_tm->tm_mday;
alarm_setup_test.wktime.tm_wday = p_tm->tm_wday;
alarm_setup_test.wktime.tm_hour = p_tm->tm_hour;
alarm_setup_test.wktime.tm_min = p_tm->tm_min;
alarm_setup_test.wktime.tm_sec = p_tm->tm_sec;
返回 rt_alarm_create(callback, &alarm_setup_test);
}
静态无效 rtc_alarm_time_create(void)
{
静态时间_现在;
静态结构 tm tm;
如果 (p_alarm_time != RT_NULL)
返回;
现在=时间(NULL)+ 65;
#ifdef _WIN32
_gmtime32_s(&tm, &now);
#else
gmtime_r(&now, &tm);
#endif
p_alarm_time = rtc_alarm_test_create(alarm_time_cb, RT_ALARM_DAILY, &tm);
}
静态无效 rtc_alarm_time_start(void)
{
if (p_alarm_time != RT_NULL)
rt_alarm_start(p_alarm_time);
}
静态无效 rtc_alarm_time_stop(void)
{
if (p_alarm_time != RT_NULL)
rt_alarm_stop(p_alarm_time);
}
静态无效 rtc_alarm_time_delete(void)
{
if (p_alarm_time != RT_NULL)
{
if (rt_alarm_delete(p_alarm_time) == RT_EOK)
p_alarm_time = RT_NULL;
}
}
静态无效 rtc_alarm_second_create(无效)
{
静态时间_t 现在;
静态结构 tm tm;
如果 (p_alarm_sec != RT_NULL)
返回;
现在=时间(NULL)+ 1;
#ifdef _WIN32
_gmtime32_s(&tm, &now);
#else
gmtime_r(&now, &tm);
#endif
p_alarm_sec = rtc_alarm_test_create(alarm_second_cb, RT_ALARM_SECOND, &tm);
}
静态无效 rtc_alarm_second_start(void)
{
if (p_alarm_sec != RT_NULL)
rt_alarm_start(p_alarm_sec);
}
静态无效 rtc_alarm_second_stop(void)
{
if (p_alarm_sec != RT_NULL)
rt_alarm_stop(p_alarm_sec);
}
静态无效 rtc_alarm_second_delete(void)
{
if (p_alarm_sec != RT_NULL)
{
if (rt_alarm_delete(p_alarm_sec) == RT_EOK)
p_alarm_sec = RT_NULL;
}
}
静态无效 rtc_alarm_minute_create(void)
{
静态时间_现在;
静态结构 tm tm;
如果 (p_alarm_min != RT_NULL)
返回;
现在=时间(NULL)+ 60;
#ifdef _WIN32
_gmtime32_s(&tm, &now);
#else
gmtime_r(&now, &tm);
#endif
p_alarm_min = rtc_alarm_test_create(alarm_minute_cb, RT_ALARM_MINUTE, &tm);
}
静态无效 rtc_alarm_minute_start(void)
{
if (p_alarm_min != RT_NULL)
rt_alarm_start(p_alarm_min);
}
静态无效 rtc_alarm_minute_stop(void)
{
if (p_alarm_min != RT_NULL)
rt_alarm_stop(p_alarm_min);
}
静态无效 rtc_alarm_minute_delete(void)
{
if (p_alarm_min != RT_NULL)
{
if (rt_alarm_delete(p_alarm_min) == RT_EOK)
p_alarm_min = RT_NULL;
}
}
静态无效 rtc_alarm_hour_create(void)
{
静态时间_现在;
静态结构 tm tm;
如果 (p_alarm_hour != RT_NULL)
返回;
现在=时间(NULL)+ 3600;
#ifdef _WIN32
_gmtime32_s(&tm, &now);
#别的
gmtime_r(&现在, &tm);
#endif
p_alarm_hour = rtc_alarm_test_create(alarm_hour_cb, RT_ALARM_HOUR, &tm);
}
静态无效 rtc_alarm_hour_start(void)
{
if (p_alarm_hour != RT_NULL)
rt_alarm_start(p_alarm_hour);
}
静态无效 rtc_alarm_hour_stop(void)
{
if (p_alarm_hour != RT_NULL)
rt_alarm_stop(p_alarm_hour);
}
静态无效 rtc_alarm_hour_delete(void)
{
if (p_alarm_hour != RT_NULL)
{
if (rt_alarm_delete(p_alarm_hour) == RT_EOK)
p_alarm_hour = RT_NULL;
}
}
void rtc_alarm_start(int argc, char **argv)
{
整数索引 = 0;
if (argc >= 2)
{
index = atoi(argv[1]);
}
switch(index)
{
case 0:
rtc_alarm_hour_start();
休息;
案例一:
rtc_alarm_minute_start();
休息;
案例2:
rtc_alarm_second_start();
休息;
案例3:
rtc_alarm_time_start();
休息;
默认值:
中断;
}
}
void rtc_alarm_stop(int argc, char **argv)
{
int index = 0;
如果 (argc >= 2)
{
索引 = atoi(argv[1]);
}
switch(index)
{
case 0:
rtc_alarm_hour_stop();
休息;
案例一:
rtc_alarm_minute_stop();
休息;
案例2:
rtc_alarm_second_stop();
休息;
案例3:
rtc_alarm_time_stop();
休息;
默认值:
中断;
}
}
void rtc_alarm_create(int argc, char **argv)
{
int index = 0;
if (argc >= 2)
{
index = atoi(argv[1]);
}
开关(索引)
{
案例0:
rtc_alarm_hour_create();
休息;
案例一:
rtc_alarm_minute_create();
休息;
案例2:
rtc_alarm_second_create();
休息;
案例3:
rtc_alarm_time_create();
休息;
默认值:
中断;
}
}
void rtc_alarm_delete(int argc, char **argv)
{
int index = 0;
if (argc >= 2)
{
index = atoi(argv[1]);
}
开关(索引)
{
案例0:
rtc_alarm_hour_delete();
休息;
案例一:
rtc_alarm_minute_delete();
休息;
案例2:
rtc_alarm_second_delete();
休息;
案例3:
rtc_alarm_time_delete();
休息;
默认值:
中断;
}
}
msh />rtc_alarm_c
rtc_alarm_create
msh />rtc_alarm_create 1
msh />al
alarm_dump
msh />alarm_dump
| 编号 | YYYY-MM-DD hh:mm:ss | 周 | 标志 | zh |
+----+----------+------+------+----+
| 0 | 2000-01-01 08:13:12 | 6 | 中号 | 0 |
| 1 | 2000-01-01 09:12:07 | 6 | H | 0 |
| 2 | 2000-01-01 08:12:13 | 6 | 小号 | 1 |
+----+----------+------+------+----+
msh /> rt
rtc_gettime
rtc_alarm_create
rtc_alarm_delete
rtc_alarm_start
rtc_alarm_stop
msh />rtc_al
rtc_alarm_create
rtc_alarm_delete
rtc_alarm_start
rtc_alarm_stop
msh />rtc_alarm_st
rtc_alarm_start
rtc_alarm_stop
MSH /> rtc_alarm_sta
rtc_alarm_start
MSH /> rtc_alarm_start 0
MSH /> RTC
rtc_gettime
rtc_alarm_create
rtc_alarm_delete
rtc_alarm_start
rtc_alarm_stop
MSH /> rtc_al
rtc_alarm_create
rtc_alarm_delete
rtc_alarm_start
rtc_alarm_stop
MSH /> rtc_alarm_st
rtc_alarm_start
rtc_alarm_stop
MSH /> rtc_alarm_sta
rtc_alarm_start
MSH /> rtc_alarm_start 1
MSH />人
alarm_dump
msh />alarm_dump
| 编号 | YYYY-MM-DD hh:mm:ss | 周 | 标志 | zh |
+----+----------+------+------+----+
| 0 | 2000-01-01 08:13:12 | 6 | 中号 | 1 |
| 1 | 2000-01-01 09:12:07 | 6 | H | 1 |
| 2 | 2000-01-01 08:12:29 | 6 | 小号 | 1 |
+----+----------+------+------+----+
msh />
MSH /> rtc_al
rtc_alarm_create
rtc_alarm_delete
rtc_alarm_start
rtc_alarm_stop
MSH /> rtc_alarm_crw
MSH /> rtc_alarm_cr
rtc_alarm_create
MSH /> rtc_alarm_create 2
MSH /> RTC
rtc_gettime
rtc_alarm_create
rtc_alarm_delete
rtc_alarm_start
rtc_alarm_stop
MSH /> rtc_al
rtc_alarm_create
rtc_alarm_delete
rtc_alarm_start
rtc_alarm_stop
MSH /> rtc_alarm_star
rtc_alarm_start
msh />rtc_alarm_start 2
msh />[D/rtc.test] alarm_second_cb 好的!
[D/rtc.test] alarm_second_cb 好的!
[D/rtc.test] alarm_second_cb 好的!
[D/rtc.test] alarm_second_cb 好的!
rtc
rtc_gettime
rtc_alarm_create
rtc_alarm_delete
rtc_alarm_start
rtc_alarm_stop
msh />rtc_[D/rtc.test] alarm_second_cb 好的!
a-[D/rtc.test] alarm_second_cb 好的!
msh />rtc_a-[D/rtc.test] alarm_second_cb 好的!
rtc_alarm_create
rtc_alarm_delete
rtc_alarm_start
rtc_alarm_stop
msh />rtc_alarm_[D/rtc.test] alarm_second_cb 好的!
s[D/rtc.test] alarm_second_cb 好!
rtc_alarm_start
rtc_alarm_stop
msh />rtc_alarm_st
rtc_alarm_start
rtc_alarm_stop
msh />rtc_alarm_sto
rtc_alarm_stop
msh />rtc_alarm_stop[D/rtc.test] alarm_second_cb 好的!
rtc_alarm_stop
msh />rtc_alarm_stop
rtc_alarm_stop
msh />rtc_alarm_stop 2
msh />al
alarm_dump
msh />alarm_dump
| 编号 | YYYY-MM-DD hh:mm:ss | 周 | 标志 | zh |
+----+----------+------+------+----+
| 0 | 2000-01-01 08:13:05 | 6 | 小号 | 0 |
| 1 | 2000-01-01 08:13:12 | 6 | 中号 | 1 |
| 2 | 2000-01-01 09:12:07 | 6 | H | 1 |
| 3 | 2000-01-01 08:13:11 | 6 | 小号 | 1 |
+----+----------+------+------+----+
msh />[D/rtc.test] alarm_minute_cb 好的!
|