|
|
@ -2,9 +2,11 @@ |
|
|
|
|
|
|
|
#include "sdk\components\zprotocols\zcancmder_v2\api\errorcode.hpp"
|
|
|
|
using namespace iflytop; |
|
|
|
|
|
|
|
#define TAG "PWM_SCM"
|
|
|
|
void PWMSpeedCtrlModule::initialize(config_t* pcfg) { |
|
|
|
ZASSERT(pcfg->name != nullptr); |
|
|
|
ZASSERT(pcfg); |
|
|
|
m_mutex.init(); |
|
|
|
// ZASSERT(pcfg->fanCtrlTim);
|
|
|
|
cfg = *pcfg; |
|
|
|
m_enablefbcheck = pcfg->enablefbcheck; |
|
|
@ -35,6 +37,7 @@ void PWMSpeedCtrlModule::initialize(config_t* pcfg) { |
|
|
|
} |
|
|
|
cfg.pwm_cfg.calltrace = pcfg->enableTrace; |
|
|
|
m_fanCtrlPwm.initialize(&cfg.pwm_cfg); |
|
|
|
OSDefaultSchduler::getInstance()->regPeriodJob([this](OSDefaultSchduler::Context&) { checkfanState(); }, 1000); |
|
|
|
} |
|
|
|
|
|
|
|
void PWMSpeedCtrlModule::onfbgpioirq(int32_t fanindex) { |
|
|
@ -44,6 +47,8 @@ void PWMSpeedCtrlModule::onfbgpioirq(int32_t fanindex) { |
|
|
|
} |
|
|
|
|
|
|
|
int32_t PWMSpeedCtrlModule::startModule(int32_t duty) { |
|
|
|
// ZLOGI("startModule duty:%d", duty);
|
|
|
|
zlock_guard lck(m_mutex); |
|
|
|
if (duty < 20) duty = 20; |
|
|
|
fanisworking = true; |
|
|
|
|
|
|
@ -54,6 +59,8 @@ int32_t PWMSpeedCtrlModule::startModule(int32_t duty) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t PWMSpeedCtrlModule::stopModule() { |
|
|
|
zlock_guard lck(m_mutex); |
|
|
|
|
|
|
|
fanisworking = false; |
|
|
|
stopFanPWM(); |
|
|
|
powerOff(); |
|
|
@ -81,9 +88,10 @@ bool PWMSpeedCtrlModule::isError() { |
|
|
|
} |
|
|
|
|
|
|
|
void PWMSpeedCtrlModule::checkfanState() { |
|
|
|
zlock_guard lck(m_mutex); |
|
|
|
if (!m_enablefbcheck) return; |
|
|
|
|
|
|
|
if (zos_haspassedms(m_lastcheckTime) < 10 * 1000) { |
|
|
|
if (zos_haspassedms(m_lastcheckTime) < 3 * 1000) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
@ -96,7 +104,8 @@ void PWMSpeedCtrlModule::checkfanState() { |
|
|
|
void PWMSpeedCtrlModule::checkfanState(int32_t fanindex) { |
|
|
|
if (fanisworking && zos_haspassedms(m_fanstate[fanindex].lastupdateFanFBCountTime) > 10 * 1000) { |
|
|
|
m_fanstate[fanindex].fanerrorstate = 1; |
|
|
|
powerOff(); |
|
|
|
ZLOGE(TAG, "%s checkfanState fanindex:%d error", cfg.name, fanindex); |
|
|
|
stopModule(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|