打开task\_system.c文件,内容如下:
```
#include "task_system.h"
#include "svc_log.h"
#include "svc_system.h"
/*
* System Status for this task, we can contorls this status to decide work mode.
*
* Work mode(The following list is ordered from highest priority to lowest):
* SVC_SYSTEM_STATUS_BUSY
* SVC_SYSTEM_STATUS_PERIODIC_SLEEP
* SVC_SYSTEM_STATUS_SLEEP
* SVC_SYSTEM_STATUS_PERIODIC_DEEPSLEEP
* SVC_SYSTEM_STATUS_DEEPSLEEP
*
* @Warning: Working mode can be specified for each task.
*/
static svc_system_status_descripter_t task_system_status;
/*
* Function declaration: Runner for this task.
*/
static void task_system_run(void);
/*
* Function declaration: System status feedback function.
*/
static svc_system_status_descripter_t task_system_status_feedback(void);
/*
* Function declaration: System event monitor.
*/
static void task_system_on_event(uint8_t event, void *args);
/*
* Task initialization.
*/
void task_system_init()
{
/* Set current system status to BUSY */
task_system_status.indication = SVC_SYSTEM_STATUS_BUSY;
/* Register system status feedback function */
svc_system_register_status_feedback(task_system_status_feedback);
/* Register event monitor */
svc_system_register_event_monitor(task_system_on_event);
/* Start a periodic timer */
svc_system_start_timer(task_system_run, 100, 0);
/* Tips */
svc_log_write_lcd_lines(0, "system running!", 0, 0, 0);
}
/*
* Function implementation: Runner for this task.
*/
void task_system_run()
{
task_system_status.indication = SVC_SYSTEM_STATUS_DEEPSLEEP;
}
/*
* Function implementation: System status feedback function.
*/
svc_system_status_descripter_t task_system_status_feedback()
{
return task_system_status;
}
/*
* Function implementation: System event monitor.
*/
void task_system_on_event(uint8_t event, void *args)
{
switch (event) {
/* Event: Power On */
case SVC_SYSTEM_EVENT_POWERON:
break;
#ifdef __LPM__
/* Event(LPM): Before Sleep */
case SVC_SYSTEM_EVENT_BEFORE_SLEEP:
break;
/* Event(LPM): Before Deepsleep */
case SVC_SYSTEM_EVENT_BEFORE_DEEPSLEEP:
break;
/* Event(LPM): Wakeup From Sleep */
case SVC_SYSTEM_EVENT_WAKEUP_FROM_SLEEP:
break;
/* Event(LPM): Wakeup From Deepsleep */
case SVC_SYSTEM_EVENT_WAKEUP_FROM_DEEPSLEEP:
break;
#endif
/* Event(BUTTON): Click */
case SVC_SYSTEM_EVENT_BUTTON_ON_CLICK:
break;
/* Event(BUTTON): Double Clicks */
case SVC_SYSTEM_EVENT_BUTTON_DOUBLE_CLICKS:
break;
/* Event(BUTTON): Triple Clicks */
case SVC_SYSTEM_EVENT_BUTTON_TRIPLE_CLICKS:
break;
/* Event(BUTTON): Fivefold Clicks */
case SVC_SYSTEM_EVENT_BUTTON_FIVEFOLD_CLICKS:
break;
/* Event(BUTTON): Tenfold Clicks */
case SVC_SYSTEM_EVENT_BUTTON_TENFOLD_CLICKS:
break;
/* Event(BUTTON): Hold 3 Seconds */
case SVC_SYSTEM_EVENT_BUTTON_LONG_PRESS_3S:
break;
/* Event(BUTTON): Hold 5 Seconds */
case SVC_SYSTEM_EVENT_BUTTON_LONG_PRESS_5S:
break;
/* Event(BUTTON): Hold 10 Seconds */
case SVC_SYSTEM_EVENT_BUTTON_LONG_PRESS_10S:
break;
default:
break;
} /* switch */
}
```
- 框架介绍
- Main 函数
- HAL 函数接口说明
- hal_system.h
- hal_systick.h
- hal_idt.h
- hal_ioctl.h
- hal_flash.h
- hal_lpm.h
- hal_rtc.h
- hal_iwdg.h
- hal_uart.h
- hal_i2c.h
- hal_led.h
- hal_button.h
- hal_vht2x.h
- hal_lcd.h
- Services 函数接口说明
- svc_system.h
- svc_database.h
- svc_hid.h
- svc_msg.h
- svc_humiture.h
- svc_log.h
- Tasks 说明
- task_system.c
- task_example.c
- Libs 函数接口说明
- mathlib.h
- json.h
- atcmd.h
- atcmd_proxy.h
- libwifi.h
- libs1.h