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.
42 lines
1.3 KiB
42 lines
1.3 KiB
#include "chip.hpp"
|
|
|
|
extern "C" {
|
|
|
|
static iflytop::ZGPIO g_debuglight;
|
|
static Pin_t g_debuglight_pin = PinNull;
|
|
static bool g_error_state = false;
|
|
|
|
void chip_set_error() { g_error_state = true; }
|
|
|
|
void chip_init(chip_cfg_t *cfg) {
|
|
g_debuglight_pin = cfg->debuglight;
|
|
if (g_debuglight_pin != PinNull) {
|
|
g_debuglight.initAsOutput(g_debuglight_pin, iflytop::ZGPIO::kMode_nopull, false, false);
|
|
}
|
|
//
|
|
zchip_loggger_init(cfg->huart);
|
|
//
|
|
zchip_clock_cfg_t zchip_clock_cfg;
|
|
zchip_clock_cfg.usdleaytim = cfg->us_dleay_tim;
|
|
zchip_clock_init(&zchip_clock_cfg);
|
|
//
|
|
iflytop::ChipTimIrqShceduler::Cfg ChipTimIrqShceduler_cfg;
|
|
ChipTimIrqShceduler_cfg.schedulertim = cfg->tim_irq_scheduler_tim;
|
|
iflytop::ChipTimIrqShceduler::instance().initialize(&ChipTimIrqShceduler_cfg);
|
|
|
|
iflytop::ChipTimIrqShceduler::instance().regPeriodJob(
|
|
[](iflytop::ChipTimIrqShceduler::Job *job) {
|
|
if (g_error_state) return;
|
|
if (g_debuglight_pin == PinNull) return;
|
|
g_debuglight.toggleState();
|
|
},
|
|
300);
|
|
iflytop::ChipTimIrqShceduler::instance().regPeriodJob(
|
|
[](iflytop::ChipTimIrqShceduler::Job *job) {
|
|
if (!g_error_state) return;
|
|
if (g_debuglight_pin == PinNull) return;
|
|
g_debuglight.toggleState();
|
|
},
|
|
50);
|
|
}
|
|
}
|