|
@ -47,7 +47,7 @@ int32_t ZCanBoardModule::module_xxx_reg(int32_t param_id, bool read, int32_t &va |
|
|
PROCESS_REG(kreg_module_version, /* */ REG_GET(0x0001), ACTION_NONE); |
|
|
PROCESS_REG(kreg_module_version, /* */ REG_GET(0x0001), ACTION_NONE); |
|
|
PROCESS_REG(kreg_module_type, /* */ REG_GET(0), ACTION_NONE); |
|
|
PROCESS_REG(kreg_module_type, /* */ REG_GET(0), ACTION_NONE); |
|
|
default: |
|
|
default: |
|
|
return err::kmodule_not_find_config_index; |
|
|
|
|
|
|
|
|
return err::kmodule_not_find_reg; |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
return 0; |
|
|
return 0; |
|
@ -82,68 +82,68 @@ int32_t ZCanBoardModule::readoutput() { |
|
|
|
|
|
|
|
|
int32_t ZCanBoardModule::readTemperature(int32_t sensorId, int32_t &temperature_val) { |
|
|
int32_t ZCanBoardModule::readTemperature(int32_t sensorId, int32_t &temperature_val) { |
|
|
if (sensorId < 0 || sensorId >= ZARRAY_SIZE(m_cfg.temperature_sensor)) { |
|
|
if (sensorId < 0 || sensorId >= ZARRAY_SIZE(m_cfg.temperature_sensor)) { |
|
|
return err::kmodule_not_find_config_index; |
|
|
|
|
|
|
|
|
return err::kmodule_not_find_reg; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (m_cfg.temperature_sensor[sensorId] == nullptr) { |
|
|
if (m_cfg.temperature_sensor[sensorId] == nullptr) { |
|
|
return err::kmodule_not_find_config_index; |
|
|
|
|
|
|
|
|
return err::kmodule_not_find_reg; |
|
|
} |
|
|
} |
|
|
return m_cfg.temperature_sensor[sensorId]->getTemperature(temperature_val); |
|
|
return m_cfg.temperature_sensor[sensorId]->getTemperature(temperature_val); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int32_t ZCanBoardModule::setPwmState(int32_t pwmId, int32_t state) { |
|
|
int32_t ZCanBoardModule::setPwmState(int32_t pwmId, int32_t state) { |
|
|
if (pwmId < 0 || pwmId >= ZARRAY_SIZE(m_cfg.pwmctrl)) { |
|
|
if (pwmId < 0 || pwmId >= ZARRAY_SIZE(m_cfg.pwmctrl)) { |
|
|
return err::kmodule_not_find_config_index; |
|
|
|
|
|
|
|
|
return err::kmodule_not_find_reg; |
|
|
} |
|
|
} |
|
|
if (m_cfg.pwmctrl[pwmId] == nullptr) { |
|
|
if (m_cfg.pwmctrl[pwmId] == nullptr) { |
|
|
return err::kmodule_not_find_config_index; |
|
|
|
|
|
|
|
|
return err::kmodule_not_find_reg; |
|
|
} |
|
|
} |
|
|
return m_cfg.pwmctrl[pwmId]->pwm_set_state(state); |
|
|
return m_cfg.pwmctrl[pwmId]->pwm_set_state(state); |
|
|
} |
|
|
} |
|
|
int32_t ZCanBoardModule::getPwmState(int32_t pwmId, int32_t &state) { |
|
|
int32_t ZCanBoardModule::getPwmState(int32_t pwmId, int32_t &state) { |
|
|
if (pwmId < 0 || pwmId >= ZARRAY_SIZE(m_cfg.pwmctrl)) { |
|
|
if (pwmId < 0 || pwmId >= ZARRAY_SIZE(m_cfg.pwmctrl)) { |
|
|
return err::kmodule_not_find_config_index; |
|
|
|
|
|
|
|
|
return err::kmodule_not_find_reg; |
|
|
} |
|
|
} |
|
|
if (m_cfg.pwmctrl[pwmId] == nullptr) { |
|
|
if (m_cfg.pwmctrl[pwmId] == nullptr) { |
|
|
return err::kmodule_not_find_config_index; |
|
|
|
|
|
|
|
|
return err::kmodule_not_find_reg; |
|
|
} |
|
|
} |
|
|
return m_cfg.pwmctrl[pwmId]->pwm_get_state(state); |
|
|
return m_cfg.pwmctrl[pwmId]->pwm_get_state(state); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int32_t ZCanBoardModule::readPwmDuty(int32_t pwmId, int32_t &duty) { |
|
|
int32_t ZCanBoardModule::readPwmDuty(int32_t pwmId, int32_t &duty) { |
|
|
if (pwmId < 0 || pwmId >= ZARRAY_SIZE(m_cfg.pwmctrl)) { |
|
|
if (pwmId < 0 || pwmId >= ZARRAY_SIZE(m_cfg.pwmctrl)) { |
|
|
return err::kmodule_not_find_config_index; |
|
|
|
|
|
|
|
|
return err::kmodule_not_find_reg; |
|
|
} |
|
|
} |
|
|
if (m_cfg.pwmctrl[pwmId] == nullptr) { |
|
|
if (m_cfg.pwmctrl[pwmId] == nullptr) { |
|
|
return err::kmodule_not_find_config_index; |
|
|
|
|
|
|
|
|
return err::kmodule_not_find_reg; |
|
|
} |
|
|
} |
|
|
return m_cfg.pwmctrl[pwmId]->get_pwm_duty(duty); |
|
|
return m_cfg.pwmctrl[pwmId]->get_pwm_duty(duty); |
|
|
} |
|
|
} |
|
|
int32_t ZCanBoardModule::setPwmDuty(int32_t pwmId, int32_t duty) { |
|
|
int32_t ZCanBoardModule::setPwmDuty(int32_t pwmId, int32_t duty) { |
|
|
if (pwmId < 0 || pwmId >= ZARRAY_SIZE(m_cfg.pwmctrl)) { |
|
|
if (pwmId < 0 || pwmId >= ZARRAY_SIZE(m_cfg.pwmctrl)) { |
|
|
return err::kmodule_not_find_config_index; |
|
|
|
|
|
|
|
|
return err::kmodule_not_find_reg; |
|
|
} |
|
|
} |
|
|
if (m_cfg.pwmctrl[pwmId] == nullptr) { |
|
|
if (m_cfg.pwmctrl[pwmId] == nullptr) { |
|
|
return err::kmodule_not_find_config_index; |
|
|
|
|
|
|
|
|
return err::kmodule_not_find_reg; |
|
|
} |
|
|
} |
|
|
return m_cfg.pwmctrl[pwmId]->set_pwm_duty(duty); |
|
|
return m_cfg.pwmctrl[pwmId]->set_pwm_duty(duty); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int32_t ZCanBoardModule::readPwmFreq(int32_t pwmId, int32_t &freq) { |
|
|
int32_t ZCanBoardModule::readPwmFreq(int32_t pwmId, int32_t &freq) { |
|
|
if (pwmId < 0 || pwmId >= ZARRAY_SIZE(m_cfg.pwmctrl)) { |
|
|
if (pwmId < 0 || pwmId >= ZARRAY_SIZE(m_cfg.pwmctrl)) { |
|
|
return err::kmodule_not_find_config_index; |
|
|
|
|
|
|
|
|
return err::kmodule_not_find_reg; |
|
|
} |
|
|
} |
|
|
if (m_cfg.pwmctrl[pwmId] == nullptr) { |
|
|
if (m_cfg.pwmctrl[pwmId] == nullptr) { |
|
|
return err::kmodule_not_find_config_index; |
|
|
|
|
|
|
|
|
return err::kmodule_not_find_reg; |
|
|
} |
|
|
} |
|
|
return m_cfg.pwmctrl[pwmId]->get_pwm_freq(freq); |
|
|
return m_cfg.pwmctrl[pwmId]->get_pwm_freq(freq); |
|
|
} |
|
|
} |
|
|
int32_t ZCanBoardModule::setPwmFreq(int32_t pwmId, int32_t freq) { |
|
|
int32_t ZCanBoardModule::setPwmFreq(int32_t pwmId, int32_t freq) { |
|
|
if (pwmId < 0 || pwmId >= ZARRAY_SIZE(m_cfg.pwmctrl)) { |
|
|
if (pwmId < 0 || pwmId >= ZARRAY_SIZE(m_cfg.pwmctrl)) { |
|
|
return err::kmodule_not_find_config_index; |
|
|
|
|
|
|
|
|
return err::kmodule_not_find_reg; |
|
|
} |
|
|
} |
|
|
if (m_cfg.pwmctrl[pwmId] == nullptr) { |
|
|
if (m_cfg.pwmctrl[pwmId] == nullptr) { |
|
|
return err::kmodule_not_find_config_index; |
|
|
|
|
|
|
|
|
return err::kmodule_not_find_reg; |
|
|
} |
|
|
} |
|
|
return m_cfg.pwmctrl[pwmId]->set_pwm_freq(freq); |
|
|
return m_cfg.pwmctrl[pwmId]->set_pwm_freq(freq); |
|
|
} |
|
|
} |