Browse Source

update

master
zhaohe 2 years ago
parent
commit
e24e597312
  1. 8
      chip/zgpio.cpp
  2. 2
      chip/zgpio.hpp
  3. 9
      components/step_motor_ctrl_module/step_motor_ctrl_module.cpp
  4. 2
      components/step_motor_ctrl_module/step_motor_ctrl_module.hpp

8
chip/zgpio.cpp

@ -133,7 +133,7 @@ void regIRQGPIO(ZGPIO *gpio) {
bool ZGPIO::isMirror() { return m_mirror; }
void ZGPIO::initAsInput(Pin_t pin, GPIOMode_t mode, GPIOIrqType_t irqtype, bool mirror) {
ZEARLY_ASSERT(pin != PinNull);
if (pin == PinNull) return;
m_mirror = mirror;
m_mode = mode;
@ -188,7 +188,8 @@ void ZGPIO::initAsInput(Pin_t pin, GPIOMode_t mode, GPIOIrqType_t irqtype, bool
return;
}
void ZGPIO::initAsOutput(Pin_t pin, GPIOMode_t mode, bool mirror, bool initLevel) {
ZEARLY_ASSERT(pin != PinNull);
if (pin == PinNull) return;
m_mirror = mirror;
m_mode = mode;
m_irqtype = kIRQ_noIrq;
@ -301,6 +302,7 @@ uint32_t ZGPIO::getStateUint32() {
}
bool ZGPIO::getState() {
if (m_pin == PinNull) return false;
bool ret = false;
if (HAL_GPIO_ReadPin(m_gpio, m_pinoff) == GPIO_PIN_SET) {
ret = true;
@ -311,6 +313,8 @@ bool ZGPIO::getState() {
return ret;
}
bool ZGPIO::setState(bool state) {
if (m_pin == PinNull) return true;
if (m_mirror) state = !state;
if (m_log_when_setstate) ZEARLY_LOGI(TAG, "%s%s set %d", chip_gpio_group_get_name(m_gpio), chip_pinoff_get_name(m_pinoff), state);

2
chip/zgpio.hpp

@ -49,7 +49,7 @@ class ZGPIO {
} OutputGpioCfg_t;
private:
Pin_t m_pin;
Pin_t m_pin = PinNull;
GPIO_TypeDef *m_gpio;
uint16_t m_pinoff;
GPIOType_t m_gpiotype;

9
components/step_motor_ctrl_module/step_motor_ctrl_module.cpp

@ -605,7 +605,7 @@ int32_t StepMotorCtrlModule::factory_reset() {
void StepMotorCtrlModule::active_cfg() {
m_stepM1->setIHOLD_IRUN(m_param.ihold, m_param.irun, m_param.iholddelay);
m_stepM1->setScale(m_param.distance_scale);
m_stepM1->setScale(m_param.distance_scale_denominator);
m_stepM1->setScaleDenominator(m_param.distance_scale_denominator);
m_stepM1->setMotorShaft(m_param.x_shaft);
}
@ -700,6 +700,8 @@ int32_t StepMotorCtrlModule::module_get_reg(int32_t param_id, int32_t* val) {
GET_REG(kreg_motor_default_velocity, m_param.maxspeed);
GET_REG(kreg_motor_default_acc, m_param.acc);
GET_REG(kreg_motor_default_dec, m_param.dec);
GET_REG(kreg_module_input_state, _read_io());
// GET_REG(kreg_motor_default_break_dec, m_param.dec);
GET_REG(kreg_motor_run_to_zero_max_d, m_param.run_to_zero_max_d);
GET_REG(kreg_motor_look_zero_edge_max_d, m_param.look_zero_edge_max_d);
@ -741,6 +743,11 @@ int32_t StepMotorCtrlModule::module_readio(int32_t* io) {
}
return 0;
}
int32_t StepMotorCtrlModule::_read_io() {
int32_t iostate = 0;
module_readio(&iostate);
return iostate;
}
int32_t StepMotorCtrlModule::module_read_adc(int32_t adcindex, int32_t* adc) {
*adc = 0;

2
components/step_motor_ctrl_module/step_motor_ctrl_module.hpp

@ -188,5 +188,7 @@ class StepMotorCtrlModule : public I_StepMotorCtrlModule, public ZIModule, publi
void call_exec_status_cb(int32_t status, action_cb_status_t status_cb);
void set_last_exec_status(int32_t ecode, int32_t val0 = 0, int32_t val1 = 0, int32_t val2 = 0, int32_t val3 = 0, int32_t val4 = 0, int32_t val5 = 0);
private:
int32_t _read_io();
};
} // namespace iflytop
Loading…
Cancel
Save