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.

37 lines
1.5 KiB

1 year ago
1 year ago
1 year ago
  1. #include "hardware.hpp"
  2. #include "zsdk/zcanreceiver/zcanreceiver.hpp"
  3. #define TAG "PROTO"
  4. using namespace iflytop;
  5. /***********************************************************************************************************************
  6. * EXT *
  7. ***********************************************************************************************************************/
  8. void Hardware::init() {
  9. m_motor_spi.init(&MOTOR_SPI);
  10. m_modbusBlockHost.initialize(&huart3);
  11. m_sl_mini_ac_ctrl.initAsOutput(PD14, kxs_gpio_nopull, true, false); // m_sl_mini_ac_ctrl
  12. m_atta_mini_air_compressor_ctrl.initAsOutput(PD15, kxs_gpio_nopull, true, false); // m_atta_mini_air_compressor_ctrl
  13. m_motor[0].initialize(&m_motor_spi, MOTOR1_ENN, MOTOR1_CSN);
  14. m_motor[0].setIHOLD_IRUN(1, 15, 0);
  15. m_motor[0].setMotorShaft(true);
  16. m_motor[0].setAcceleration(300000);
  17. m_motor[0].setDeceleration(300000);
  18. m_motor[1].initialize(&m_motor_spi, MOTOR2_ENN, MOTOR2_CSN);
  19. m_motor[1].setIHOLD_IRUN(1, 15, 0);
  20. m_motor[1].setMotorShaft(true);
  21. m_motor[1].setAcceleration(300000);
  22. m_motor[1].setDeceleration(300000);
  23. int32_t chipv0 = m_motor[0].readChipVERSION(); // 5130:0x11
  24. int32_t chipv1 = m_motor[1].readChipVERSION(); // 5130:0x11
  25. // m_motor[0].rotate(500000);
  26. // m_motor[1].rotate(500000);
  27. ZLOGI(TAG, "chipv0: %x, chipv1: %x", chipv0, chipv1);
  28. m_pressureSensorBus.init(&m_modbusBlockHost);
  29. }