代码拉取完成,页面将自动刷新
本案例使用到了2个副板,一个时钟板一个OLED板。 本案例代码流程有两种情况 1、接了OLED副板情况(JYRTC_rtc.c中宏定义have_oled设置为1) 按下OLED副板上的右边按键,触发中断,释放信号量,因为ntpwifi连接前一直在等待信号量,所以这步必须。 通过ntpwifi连接阿里云,通过UDP服务获取阿里云时间,把阿里云时间写入RTC相应寄存器后,读取RTC时间并把它显示到OLED上。 2、没有接OLED副板情况(JYRTC_rtc.c中宏定义have_oled设置为0) 直接获取RTC时间并把时间用串口信息打印出来
JYRTC_rtc.h --JYRTC时钟控制头文件
ntpUdp.h --ntpUdp头文件
wifi_connect.h --Wifi连接头文件
ssd1306_font.h --oled头文件
ssd1306_oled.h --oled头文件
JYRTC_example.c --JYRTC示例源文件
JYRTC_rtc.c --JYRTC时钟控制源文件
ntpUdp.c --ntpUdp源文件
wifi_connect.c --Wifi源文件
ssd1306_oled.c --ssd1306_oled源文件
osSemaphoreNew(uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr): Creates and initializes a semaphore object.
参数:
max_count – Indicates the maximum number of available tokens that can be applied for.
initial_count – Indicates the initial number of available tokens.
attr – Indicates the pointer to the semaphore attributes. This parameter is not used.
IoTGpioInit(unsigned int id): Initializes a GPIO device.
参数:
id – Indicates the GPIO pin number.
IotIoSetFunc(IOT_GPIO_IO_NAME id, unsigned char val): 注册GPIO功能
参数:
id – Indicates the GPIO pin number.
val – 注册GPIO功能
IotIoSetPull(IOT_GPIO_IO_NAME id, IOT_IO_PULL val): 设置上拉或下拉
参数:
id – Indicates the GPIO pin number.
val – 上拉或下拉
IoTGpioSetDir(unsigned int id, IotGpioDir dir): Sets the direction for a GPIO pin.
参数:
id – Indicates the GPIO pin number.
dir – Indicates the GPIO input/output direction.
IoTGpioRegisterIsrFunc(unsigned int id, IotGpioIntType intType, IotGpioIntPolarity intPolarity, GpioIsrCallbackFunc func, char *arg): Enables the interrupt feature for a GPIO pin.
参数:
id – Indicates the GPIO pin number.
intType – Indicates the interrupt type.
intPolarity – Indicates the interrupt polarity.
func – Indicates the interrupt callback function.
arg – Indicates the pointer to the argument used in the interrupt callback function.
osThreadNew(osThreadFunc_t func, void *argument, const osThreadAttr_t *attr): Creates an active thread.
参数:
func – Indicates the entry of the thread callback function.
argument – Indicates the pointer to the argument passed to the thread.
attr – Indicates the thread attributes.
osSemaphoreRelease(osSemaphoreId_t semaphore_id): Releases a token of a semaphore object.
参数:
semaphore_id – Indicates the semaphore ID, which is obtained using osSemaphoreNew
osSemaphoreAcquire(osSemaphoreId_t semaphore_id, uint32_t timeout): Acquires a token of a semaphore object.
参数:
semaphore_id – Indicates the semaphore ID, which is obtained using osSemaphoreNew.
timeout – Indicates the timeout duration. This parameter is the number of ticks.
RegisterWifiEvent(WifiEvent *event): Registers a callback for a specified Wi-Fi event.
参数:
event – Indicates the event for which the callback is to be registered.
......
1、接了OLED副板情况(JYRTC_rtc.c中宏定义have_oled设置为1) 实时的年月日与实时的时分秒分别显示在OLED上。 2、没有接OLED副板情况(JYRTC_rtc.c中宏定义have_oled设置为0) 实时的RTC时间在串口信息中打印
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。