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.
128 lines
3.5 KiB
128 lines
3.5 KiB
#include <stddef.h>
|
|
#include <stdio.h>
|
|
//
|
|
#include "base/appdep.hpp"
|
|
|
|
//
|
|
#include "app/dmapp.hpp"
|
|
#include "app/ext_ch_selector_app.hpp"
|
|
#include "app/exth2o2_sensor.hpp"
|
|
//
|
|
#include "board/public_board.hpp"
|
|
//
|
|
#include "base/protocol_processer_mgr.hpp"
|
|
#include "protocol_processer_impl/public_cmd_processer.hpp"
|
|
//
|
|
|
|
#define TAG "main"
|
|
using namespace iflytop;
|
|
|
|
extern void umain();
|
|
extern "C" {
|
|
void StartDefaultTask(void const* argument) { umain(); }
|
|
}
|
|
/*******************************************************************************
|
|
* MAIN *
|
|
*******************************************************************************/
|
|
|
|
extern "C" {
|
|
}
|
|
|
|
void debug_light_ctrl() {
|
|
static uint32_t lastcall = 0;
|
|
static bool light_status = false;
|
|
|
|
if (!gInitErrorFlag) {
|
|
if (zhas_passedms(lastcall) > 300) {
|
|
PublicBoard::ins()->toggleDebugLight();
|
|
lastcall = zget_ticket();
|
|
}
|
|
} else {
|
|
if (zhas_passedms(lastcall) > 30) {
|
|
PublicBoard::ins()->toggleDebugLight();
|
|
lastcall = zget_ticket();
|
|
}
|
|
}
|
|
}
|
|
|
|
#define REG_PROCESSER(processer) ProtocolProcesserMgr::ins()->regProcesser(processer);
|
|
|
|
/* IWDG init function */
|
|
void MX_IWDG_Init(void) {
|
|
hiwdg.Instance = IWDG;
|
|
hiwdg.Init.Prescaler = IWDG_PRESCALER_256;
|
|
hiwdg.Init.Reload = 501;
|
|
if (HAL_IWDG_Init(&hiwdg) != HAL_OK) {
|
|
Error_Handler();
|
|
}
|
|
}
|
|
|
|
void umain() {
|
|
gBoardFlagSetResetFlag();
|
|
|
|
PORT::idtable_init();
|
|
deviceInfo_init();
|
|
// config_init();
|
|
AppPeriodTaskMgr::ins()->initialize();
|
|
PublicBoard::ins()->initialize();
|
|
|
|
ZLOGI(TAG, "======================= boardinfo ==================== ");
|
|
ZLOGI(TAG, "project : %s ", PROJECT);
|
|
ZLOGI(TAG, "version : %d ", SOFTWARE_VERSION);
|
|
ZLOGI(TAG, "pversion : %d", deviceInfo_getProtocolVersion());
|
|
ZLOGI(TAG, "sn : %s", sn_get_str());
|
|
ZLOGI(TAG, "boardTypeId : %s(%d)", BoardTypeId2Str(PublicBoard::ins()->getBoardTypeId()), PublicBoard::ins()->getBoardTypeId());
|
|
ZLOGI(TAG, "boardId : %d", PublicBoard::ins()->getBoardId());
|
|
ZLOGI(TAG, "=");
|
|
|
|
zcanbus_init(PublicBoard::ins()->getBoardId());
|
|
|
|
ProtocolProcesserMgr::ins()->initialize();
|
|
PublicCmdProcesser::ins()->initialize();
|
|
|
|
switch (PublicBoard::ins()->getBoardTypeId()) {
|
|
case DT100N_LC_Board:
|
|
case DT100N_PC_Board:
|
|
// not suppport now
|
|
gInitErrorFlag = true;
|
|
break;
|
|
case DT600N_LC_Board:
|
|
case DT600N_PC_Board:
|
|
case DT300N_LC_Board:
|
|
case DT300N_PC_Board:
|
|
case DT300W_LC_Board:
|
|
case DT300W_PC_Board:
|
|
case DT600B_LC_BOARD:
|
|
case DT600B_PC_BOARD:
|
|
DisinfectionApp::ins()->initialize();
|
|
break;
|
|
case DT100N_EXT_CH_SELECTOR:
|
|
ExtChSelector::ins()->initialize();
|
|
break;
|
|
case EX_H2O2_SENSOR_BOARD:
|
|
ExtH2O2Sensor::ins()->initialize();
|
|
break;
|
|
default:
|
|
gInitErrorFlag = true;
|
|
break;
|
|
}
|
|
|
|
ZLOGI(TAG, "======================= init processer ================ ");
|
|
ProtocolProcesserMgr::ins()->startSchedule(PublicBoard::ins()->getBoardId());
|
|
ZLOGI(TAG, "=");
|
|
|
|
AppPeriodTaskMgr::ins()->startScheduler();
|
|
|
|
ZLOGI(TAG, "======================= sysinfo ======================= ");
|
|
SysMgr::ins()->initedFinished();
|
|
SysMgr::ins()->dumpSysInfo();
|
|
ZLOGI(TAG, "=");
|
|
uint8_t resetReason = SysMgr::ins()->chipGetResetReason();
|
|
zcanbus_send_report(kreport_device_reset, &resetReason, 1, 100);
|
|
MX_IWDG_Init();
|
|
while (true) {
|
|
osDelay(30);
|
|
debug_light_ctrl();
|
|
HAL_IWDG_Refresh(&hiwdg);
|
|
}
|
|
}
|