初级会员

- 积分
- 111
- 金钱
- 111
- 注册时间
- 2019-10-30
- 在线时间
- 25 小时
|
10金钱
学习原子哥F4探索者RTC例程关于RTC_DateTypeDef结构体声明的疑问结构体原型在stm32f4xx_rtc.c文件中
typedef struct
{
uint8_t RTC_Hours; /*!< Specifies the RTC Time Hour.
This parameter must be set to a value in the 0-12 range
if the RTC_HourFormat_12 is selected or 0-23 range if
the RTC_HourFormat_24 is selected. */
uint8_t RTC_Minutes; /*!< Specifies the RTC Time Minutes.
This parameter must be set to a value in the 0-59 range. */
uint8_t RTC_Seconds; /*!< Specifies the RTC Time Seconds.
This parameter must be set to a value in the 0-59 range. */
uint8_t RTC_H12; /*!< Specifies the RTC AM/PM Time.
This parameter can be a value of @Ref RTC_AM_PM_Definitions */
}RTC_TimeTypeDef;
main.c文件中 这样声明
int main
{
RTC_DateTypeDef RTC_DateStruct;
XXXXXXXXXXXX//省略部分代码
sprintf((char*)tbuf,"Time:%02d:%02d:%02d",RTC_TimeStruct.RTC_Hours,RTC_TimeStruct.RTC_Minutes,RTC_TimeStruct.RTC_Seconds);
XXXXXXXXXX//省略部分代码
}
rcc.c文件中 声明
ErrorStatus RTC_Set_Time(u8 hour,u8 min,u8 sec,u8 ampm)
{
RTC_TimeTypeDef RTC_TimeTypeInitStructure;
RTC_TimeTypeInitStructure.RTC_Hours=hour;
RTC_TimeTypeInitStructure.RTC_Minutes=min;
RTC_TimeTypeInitStructure.RTC_Seconds=sec;
RTC_TimeTypeInitStructure.RTC_H12=ampm;
return RTC_SetTime(RTC_Format_BIN,&RTC_TimeTypeInitStructure);
}
疑问1:为什么不用统一的变量名
疑问2:为什么替换成统一的变量名也没有出现编译错误
背景:C语言突击小白
麻烦从C语言角度帮忙解答一下
|
|