You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.6 KiB
92 lines
2.6 KiB
|
3 days ago
|
/******************************************************************************
|
||
|
|
|
||
|
|
版权所有 (C), 2018-2099, Radkil
|
||
|
|
|
||
|
|
******************************************************************************
|
||
|
|
文 件 名 : rd_time.c
|
||
|
|
版 本 号 : 初稿
|
||
|
|
作 者 : Radkil
|
||
|
|
生成日期 : 2026年2月24日星期二
|
||
|
|
最近修改 :
|
||
|
|
功能描述 : 时间相关函数抽象层
|
||
|
|
|
||
|
|
修改历史 :
|
||
|
|
1.日 期 : 2026年2月24日星期二
|
||
|
|
作 者 : Radkil
|
||
|
|
修改内容 : 创建文件
|
||
|
|
|
||
|
|
******************************************************************************/
|
||
|
|
#include "rd_time.h"
|
||
|
|
|
||
|
|
/*----------------------------------------------*
|
||
|
|
* 外部变量说明 *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
|
||
|
|
/*----------------------------------------------*
|
||
|
|
* 外部函数原型说明 *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
|
||
|
|
/*----------------------------------------------*
|
||
|
|
* 内部函数原型说明 *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
|
||
|
|
/*----------------------------------------------*
|
||
|
|
* 全局变量 *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
|
||
|
|
/*----------------------------------------------*
|
||
|
|
* 模块级变量 *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
WEAK unsigned int g_uiRandSeed = 12345;
|
||
|
|
|
||
|
|
/*----------------------------------------------*
|
||
|
|
* 常量定义 *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
|
||
|
|
/*----------------------------------------------*
|
||
|
|
* 宏定义 *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
|
||
|
|
WEAK time_t rd_time(time_t *tloc)
|
||
|
|
{
|
||
|
|
if (tloc != NULL)
|
||
|
|
{
|
||
|
|
*tloc = (time_t)-1;
|
||
|
|
}
|
||
|
|
return (time_t)-1; // 表示时间功能不可用
|
||
|
|
}
|
||
|
|
|
||
|
|
WEAK struct tm *rd_localtime_r(const time_t *timep, struct tm *result)
|
||
|
|
{
|
||
|
|
return NULL;
|
||
|
|
}
|
||
|
|
|
||
|
|
WEAK size_t rd_strftime(char *s, size_t max, const char *format, const struct tm *tm)
|
||
|
|
{
|
||
|
|
return (size_t)-1;
|
||
|
|
}
|
||
|
|
|
||
|
|
WEAK void rd_srand(unsigned int seed)
|
||
|
|
{
|
||
|
|
g_uiRandSeed = seed ? seed : 12345; // 种子不能为 0
|
||
|
|
}
|
||
|
|
|
||
|
|
// 简单的线性同余生成器 (LCG)
|
||
|
|
WEAK int rd_rand(void)
|
||
|
|
{
|
||
|
|
g_uiRandSeed = g_uiRandSeed * 1103515245 + 12345;
|
||
|
|
return (g_uiRandSeed >> 16) & 0x7FFF; // 返回 0~32767
|
||
|
|
}
|
||
|
|
|
||
|
|
WEAK uint32_t Rd_GetTime(void)
|
||
|
|
{
|
||
|
|
uint32_t HAL_GetTick(void);
|
||
|
|
return (int)HAL_GetTick();
|
||
|
|
}
|
||
|
|
|
||
|
|
WEAK void Rd_Delay(uint32_t Delay)
|
||
|
|
{
|
||
|
|
void HAL_Delay(uint32_t Delay);
|
||
|
|
HAL_Delay(Delay);
|
||
|
|
}
|