Browse Source

update

master
zhaohe 4 months ago
parent
commit
3e0faa055d
  1. 2
      a8000_protocol
  2. 96
      sdk/components/api/zi_module.cpp
  3. 87
      sdk/components/api/zi_module.hpp
  4. 1
      sdk/components/mini_servo_motor/mini_servo_motor_ctrl_module.hpp
  5. 2
      sdk/components/pipette_module/pipette_ctrl_module_v2.hpp
  6. 1
      sdk/components/sensors/m3078/m3078_code_scaner.hpp
  7. 3
      sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp
  8. 2
      sdk/components/tmc/ic/ztmc5130.cpp
  9. 3
      sdk/components/water_cooling_temperature_control_module/water_cooling_temperature_control_module.hpp
  10. 1
      sdk/components/xy_robot_ctrl_module/xy_robot_ctrl_module.hpp
  11. 1
      sdk/components/zcancmder/protocol_event_bus_sender.hpp
  12. 1
      sdk/components/zcancmder/zcan_board_module.hpp
  13. 1
      sdk/components/zcancmder/zcan_protocol_parser.hpp
  14. 2
      sdk/components/zcancmder/zcanreceiver.hpp
  15. 2
      usrc/public_service/ext_board_impl.hpp
  16. 1
      usrc/subboards/subboard100_idcard_reader/eeprom_service.hpp
  17. 1
      usrc/subboards/subboard20_plate_clamp_case/plate_code_scaner_module.hpp
  18. 1
      usrc/subboards/subboard40_and_50_temperature_ctrl/zcan_fan_ctrl_module.hpp
  19. 1
      usrc/subboards/subboard90_optical_module/optical_module_v2.hpp

2
a8000_protocol

@ -1 +1 @@
Subproject commit 508a8f8be82e5272ae21140cafbf7aee274f1367
Subproject commit 86281b73f485c01783197227b58d0a19699c7198

96
sdk/components/api/zi_module.cpp

@ -0,0 +1,96 @@
#include "zi_module.hpp"
#include <stdint.h>
#include <functional>
using namespace iflytop;
int32_t ZIModule::getid() {
int32_t id = 0;
getid(&id);
return id;
};
int32_t ZIModule::module_ping() { return 0; };
int32_t ZIModule::module_set_reg(int32_t param_id, int32_t param_value) { return _module_xxx_reg(param_id, false, param_value); }
int32_t ZIModule::module_get_reg(int32_t param_id, int32_t *param_value) { return _module_xxx_reg(param_id, true, *param_value); }
int32_t ZIModule::_module_xxx_reg(int32_t param_id, bool read, int32_t &val) {
if (param_id == kreg_module_version) {
if (read) {
module_get_version(&val);
return 0;
} else {
return 0;
}
}
else if (param_id == kreg_module_type) {
if (read) {
module_get_type(&val);
return 0;
} else {
return 0;
}
}
else if (param_id == kreg_module_status) {
if (read) {
module_get_status(&val);
return 0;
} else {
return 0;
}
}
else if (param_id == kreg_module_errorcode) {
if (read) {
val = creg.module_errorcode;
return 0;
} else {
return 0;
}
}
return module_xxx_reg(param_id, read, val);
}
int32_t ZIModule::_module_set_reg(int32_t regoff, int32_t *regval, int32_t val, int32_t min, int32_t max) {
if (val < min || val > max) {
return err::kparam_out_of_range;
}
*regval = val;
return 0;
}
int32_t ZIModule::_module_get_reg(int32_t regoff, int32_t regval, int32_t &val) {
val = regval;
return 0;
}
int32_t ZIModule::_module_set_reg_float(int32_t regoff, float *regval, int32_t val, float precision, int32_t min, int32_t max) {
if (val < min || val > max) {
return err::kparam_out_of_range;
}
*regval = val * precision;
return 0;
}
int32_t ZIModule::_module_get_reg_float(int32_t regoff, float regval, int32_t &val, float precision) {
val = regval / precision;
return 0;
}
int32_t ZIModule::module_get_error(int32_t *iserror) {
*iserror = creg.module_errorcode;
return 0;
}
int32_t ZIModule::module_clear_error() {
creg.module_errorcode = 0;
creg.module_status = 0;
return 0;
}
int32_t ZIModule::module_get_status(int32_t *status) {
*status = creg.module_status;
return 0;
}

87
sdk/components/api/zi_module.hpp

@ -0,0 +1,87 @@
#pragma once
#include <stdint.h>
#include <functional>
#include "a8000_protocol\protocol.hpp"
namespace iflytop {
using namespace std;
#define REG_SET(reg, ...) _module_set_reg(param_id, &reg, val, ##__VA_ARGS__)
#define REG_GET(reg) _module_get_reg(param_id, reg, val)
#define REG_SET_FLOAT(reg, precision, ...) _module_set_reg_float(param_id, &reg, val, precision, ##__VA_ARGS__)
#define REG_GET_FLOAT(reg, precision) _module_get_reg_float(param_id, reg, val, precision)
#define ACTION_NONE 0
#define PROCESS_REG(param_id, readaction, writeacton) \
case param_id: { \
if (read) { \
return readaction; \
} else { \
return writeacton; \
} \
} break;
#define ENABLE_MODULE(name, type, version) \
public: \
virtual int32_t module_get_version(int32_t *val) { \
*val = version; \
return 0; \
} \
virtual int32_t module_get_type(int32_t *val) { \
*val = type; \
return 0; \
}
#define MODULE_COMMON_PROCESS_REG_CB()
typedef struct {
int32_t module_errorcode;
int32_t module_status;
} module_common_reg_t;
class ZIModule {
int32_t m_inited_flag = 0;
protected:
module_common_reg_t creg;
public:
virtual ~ZIModule() {}
public:
virtual int32_t getid();
virtual int32_t module_ping();
virtual int32_t module_get_error(int32_t *iserror);
virtual int32_t module_clear_error();
virtual int32_t module_set_reg(int32_t param_id, int32_t param_value);
virtual int32_t module_get_reg(int32_t param_id, int32_t *param_value);
virtual int32_t module_get_status(int32_t *status);
virtual int32_t module_get_version(int32_t *val) = 0;
virtual int32_t module_get_type(int32_t *val) = 0;
virtual int32_t module_stop() { return 0; }
virtual int32_t module_active_cfg() { return 0; }
/***********************************************************************************************************************
* *
***********************************************************************************************************************/
virtual int32_t getid(int32_t *id) = 0;
virtual int32_t module_xxx_reg(int32_t param_id, bool read, int32_t &val) = 0;
public:
// slice
virtual int32_t bfcall(int32_t cmdid, uint8_t *param, int32_t len) { return 0; };
virtual void aftercall(int32_t cmdid, uint8_t *param, int32_t len, uint8_t *ack, int32_t acklen, int32_t ret) {};
protected:
virtual int32_t _module_set_reg(int32_t regoff, int32_t *regval, int32_t val, int32_t min = INT32_MIN, int32_t max = INT32_MAX);
virtual int32_t _module_get_reg(int32_t regoff, int32_t regval, int32_t &val);
virtual int32_t _module_set_reg_float(int32_t regoff, float *regval, int32_t val, float precision, int32_t min = INT32_MIN, int32_t max = INT32_MAX);
virtual int32_t _module_get_reg_float(int32_t regoff, float regval, int32_t &val, float precision);
virtual int32_t _module_xxx_reg(int32_t param_id, bool read, int32_t &val);
public:
public:
};
} // namespace iflytop

1
sdk/components/mini_servo_motor/mini_servo_motor_ctrl_module.hpp

@ -4,6 +4,7 @@
// //
#include "feite_servo_motor.hpp" #include "feite_servo_motor.hpp"
#include "sdk\components\zcancmder\zcanreceiver.hpp" #include "sdk\components\zcancmder\zcanreceiver.hpp"
#include "sdk\components\api\zi_module.hpp"
namespace iflytop { namespace iflytop {
class MiniServoCtrlModule : public ZIModule{ class MiniServoCtrlModule : public ZIModule{

2
sdk/components/pipette_module/pipette_ctrl_module_v2.hpp

@ -6,6 +6,8 @@
#include "sdk\components\tmc\basic\tmc_ic_interface.hpp" #include "sdk\components\tmc\basic\tmc_ic_interface.hpp"
#include "sdk\components\tmc\ic\ztmc5130.hpp" #include "sdk\components\tmc\ic\ztmc5130.hpp"
#include "sdk\components\zcancmder\zcanreceiver.hpp" #include "sdk\components\zcancmder\zcanreceiver.hpp"
#include "sdk\components\api\zi_module.hpp"
// #include "StepMotorCtrlModule" // #include "StepMotorCtrlModule"
/** /**

1
sdk/components/sensors/m3078/m3078_code_scaner.hpp

@ -5,6 +5,7 @@
#pragma once #pragma once
#include "a8000_protocol\protocol.hpp" #include "a8000_protocol\protocol.hpp"
#include "sdk/os/zos.hpp" #include "sdk/os/zos.hpp"
#include "sdk\components\api\zi_module.hpp"
/** /**
* @brief * @brief

3
sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp

@ -4,6 +4,9 @@
#include "sdk\components\tmc\basic\tmc_ic_interface.hpp" #include "sdk\components\tmc\basic\tmc_ic_interface.hpp"
#include "sdk\components\tmc\ic\ztmc5130.hpp" #include "sdk\components\tmc\ic\ztmc5130.hpp"
#include "sdk\components\zcancmder\zcanreceiver.hpp" #include "sdk\components\zcancmder\zcanreceiver.hpp"
#include "sdk\components\api\zi_module.hpp"
#include "sdk\components\api\zi_module.hpp"
namespace iflytop { namespace iflytop {
class StepMotorCtrlModule : public ZIModule { class StepMotorCtrlModule : public ZIModule {
ENABLE_MODULE(StepMotorCtrlModule, ktmc_step_motor, PC_VERSION); ENABLE_MODULE(StepMotorCtrlModule, ktmc_step_motor, PC_VERSION);

2
sdk/components/tmc/ic/ztmc5130.cpp

@ -1,6 +1,6 @@
#include "ztmc5130.hpp" #include "ztmc5130.hpp"
#include "a8000_protocol\api\apibasic\errorcode.hpp"
#include "a8000_protocol\protocol.hpp"
#include "sdk/os/zos.hpp" #include "sdk/os/zos.hpp"
#ifdef HAL_SPI_MODULE_ENABLED #ifdef HAL_SPI_MODULE_ENABLED

3
sdk/components/water_cooling_temperature_control_module/water_cooling_temperature_control_module.hpp

@ -22,10 +22,11 @@
#include "sdk\components\api\zi_pwm_fan_ctrl_module.hpp" #include "sdk\components\api\zi_pwm_fan_ctrl_module.hpp"
#include "sdk\components\api\zi_pwm_pump_ctrl_module.hpp" #include "sdk\components\api\zi_pwm_pump_ctrl_module.hpp"
// //
#include "a8000_protocol\api\zi_module.hpp"
#include "sdk\components\api\zi_module.hpp"
#include "pid_module.hpp" #include "pid_module.hpp"
#include "sdk\components\api\zi_temperature_sensor.hpp" #include "sdk\components\api\zi_temperature_sensor.hpp"
#include "sdk\components\ti\drv8710.hpp" #include "sdk\components\ti\drv8710.hpp"
#include "sdk\components\api\zi_module.hpp"
namespace iflytop { namespace iflytop {
/** /**

1
sdk/components/xy_robot_ctrl_module/xy_robot_ctrl_module.hpp

@ -5,6 +5,7 @@
#include "sdk\components\tmc\basic\tmc_ic_interface.hpp" #include "sdk\components\tmc\basic\tmc_ic_interface.hpp"
#include "sdk\components\tmc\ic\ztmc5130.hpp" #include "sdk\components\tmc\ic\ztmc5130.hpp"
#include "sdk\components\zcancmder\zcanreceiver.hpp" #include "sdk\components\zcancmder\zcanreceiver.hpp"
#include "sdk\components\api\zi_module.hpp"
namespace iflytop { namespace iflytop {

1
sdk/components/zcancmder/protocol_event_bus_sender.hpp

@ -4,6 +4,7 @@
#include "basic.hpp" #include "basic.hpp"
#include "sdk/os/zos.hpp" #include "sdk/os/zos.hpp"
#include "sdk\components\zcancmder\zcanreceiver.hpp" #include "sdk\components\zcancmder\zcanreceiver.hpp"
#include "sdk\components\api\zi_module.hpp"
namespace iflytop { namespace iflytop {
using namespace std; using namespace std;

1
sdk/components/zcancmder/zcan_board_module.hpp

@ -9,6 +9,7 @@
#include "sdk/chip/api/zi_temperature.hpp" #include "sdk/chip/api/zi_temperature.hpp"
#include "sdk\chip\api\zi_adc.hpp" #include "sdk\chip\api\zi_adc.hpp"
#include "a8000_protocol\protocol.hpp" #include "a8000_protocol\protocol.hpp"
#include "sdk\components\api\zi_module.hpp"
/** /**
* @brief * @brief

1
sdk/components/zcancmder/zcan_protocol_parser.hpp

@ -3,6 +3,7 @@
#include "a8000_protocol\protocol.hpp" #include "a8000_protocol\protocol.hpp"
#include "sdk\components\zcancmder\zcanreceiver.hpp" #include "sdk\components\zcancmder\zcanreceiver.hpp"
#include "sdk\components\api\zi_module.hpp"
#define CMDFN(name) static int32_t name(cmdcontxt_t* cxt) #define CMDFN(name) static int32_t name(cmdcontxt_t* cxt)
#define CMDFN_IMPL(name) int32_t ZCanProtocolParser::name(cmdcontxt_t* cxt) #define CMDFN_IMPL(name) int32_t ZCanProtocolParser::name(cmdcontxt_t* cxt)

2
sdk/components/zcancmder/zcanreceiver.hpp

@ -6,6 +6,8 @@
#include "a8000_protocol\protocol.hpp" #include "a8000_protocol\protocol.hpp"
#include "basic.hpp" #include "basic.hpp"
#include "sdk/os/zos.hpp" #include "sdk/os/zos.hpp"
#include "sdk\components\api\zi_module.hpp"
#ifdef HAL_CAN_MODULE_ENABLED #ifdef HAL_CAN_MODULE_ENABLED
namespace iflytop { namespace iflytop {
using namespace zcr; using namespace zcr;

2
usrc/public_service/ext_board_impl.hpp

@ -8,6 +8,8 @@
#include "instance_init.hpp" #include "instance_init.hpp"
#include "sdk/chip/chip.hpp" #include "sdk/chip/chip.hpp"
#include "sdk/os/zos.hpp" #include "sdk/os/zos.hpp"
#include "sdk\components\api\zi_module.hpp"
// //
namespace iflytop { namespace iflytop {

1
usrc/subboards/subboard100_idcard_reader/eeprom_service.hpp

@ -5,6 +5,7 @@
#include "sdk\components\zcancmder\protocol_event_bus_sender.hpp" #include "sdk\components\zcancmder\protocol_event_bus_sender.hpp"
// //
#include "sdk\os\zos.hpp" #include "sdk\os\zos.hpp"
#include "sdk\components\api\zi_module.hpp"
#ifdef HAL_I2C_MODULE_ENABLED #ifdef HAL_I2C_MODULE_ENABLED
namespace iflytop { namespace iflytop {

1
usrc/subboards/subboard20_plate_clamp_case/plate_code_scaner_module.hpp

@ -6,6 +6,7 @@
#include "sdk\chip\api\zi_adc.hpp" #include "sdk\chip\api\zi_adc.hpp"
#include "sdk\components\hardware\adc\z_simple_adc.hpp" #include "sdk\components\hardware\adc\z_simple_adc.hpp"
#include "sdk\components\step_motor_ctrl_module\step_motor_ctrl_module.hpp" #include "sdk\components\step_motor_ctrl_module\step_motor_ctrl_module.hpp"
#include "sdk\components\api\zi_module.hpp"
namespace iflytop { namespace iflytop {
using namespace std; using namespace std;

1
usrc/subboards/subboard40_and_50_temperature_ctrl/zcan_fan_ctrl_module.hpp

@ -18,6 +18,7 @@
// //
#include "a8000_protocol\protocol.hpp" #include "a8000_protocol\protocol.hpp"
#include "sdk\components\api\zi_pwm_fan_ctrl_module.hpp" #include "sdk\components\api\zi_pwm_fan_ctrl_module.hpp"
#include "sdk\components\api\zi_module.hpp"
namespace iflytop { namespace iflytop {
/** /**

1
usrc/subboards/subboard90_optical_module/optical_module_v2.hpp

@ -6,6 +6,7 @@
#include "sdk\chip\api\zi_adc.hpp" #include "sdk\chip\api\zi_adc.hpp"
#include "sdk\components\hardware\adc\z_simple_adc.hpp" #include "sdk\components\hardware\adc\z_simple_adc.hpp"
#include "sdk\components\step_motor_ctrl_module\step_motor_ctrl_module.hpp" #include "sdk\components\step_motor_ctrl_module\step_motor_ctrl_module.hpp"
#include "sdk\components\api\zi_module.hpp"
namespace iflytop { namespace iflytop {
using namespace std; using namespace std;

Loading…
Cancel
Save