全司美特-单片机程序
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.

67 lines
4.0 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
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. /***********************************************************************************************************************
  10. * *
  11. ***********************************************************************************************************************/
  12. m_evaporation_bin_water_sensor.initAsInput(EVAPORATION_BIN_WATER_SENSOR_GPIO, kxs_gpio_nopull, kxs_gpio_no_irq, EVAPORATION_BIN_WATER_SENSOR_MIRROR /*mirror*/);
  13. m_device_bottom_water_sensor.initAsInput(DEVICE_BOTTOM_WATER_SENSOR_GPIO, kxs_gpio_nopull, kxs_gpio_no_irq, DEVICE_BOTTOM_WATER_SENSOR_MIRROR /*mirror*/);
  14. /***********************************************************************************************************************
  15. * *
  16. ***********************************************************************************************************************/
  17. m_motor_spi.init(&MOTOR_SPI);
  18. m_motor[0].initialize(&m_motor_spi, MOTOR1_ENN, MOTOR1_CSN);
  19. m_motor[0].setIHOLD_IRUN(1, 15, 0);
  20. m_motor[0].setMotorShaft(true);
  21. m_motor[0].setAcceleration(300000);
  22. m_motor[0].setDeceleration(300000);
  23. m_motor[1].initialize(&m_motor_spi, MOTOR2_ENN, MOTOR2_CSN);
  24. m_motor[1].setIHOLD_IRUN(1, 15, 0);
  25. m_motor[1].setMotorShaft(true);
  26. m_motor[1].setAcceleration(300000);
  27. m_motor[1].setDeceleration(300000);
  28. int32_t chipv0 = m_motor[0].readChipVERSION(); // 5130:0x11
  29. int32_t chipv1 = m_motor[1].readChipVERSION(); // 5130:0x11
  30. // m_motor[0].rotate(500000);
  31. // m_motor[1].rotate(500000);
  32. ZLOGI(TAG, "chipv0: %x, chipv1: %x", chipv0, chipv1);
  33. auto gstate0 = m_motor[0].getGState();
  34. auto gstate1 = m_motor[1].getGState();
  35. ZLOGI(TAG, "motor0: reset:%d drv_err:%d uv_cp:%d", gstate0.reset, gstate0.drv_err, gstate0.uv_cp);
  36. ZLOGI(TAG, "motor1: reset:%d drv_err:%d uv_cp:%d", gstate1.reset, gstate1.drv_err, gstate1.uv_cp);
  37. gstate0 = m_motor[0].getGState();
  38. gstate1 = m_motor[1].getGState();
  39. ZLOGI(TAG, "motor0: reset:%d drv_err:%d uv_cp:%d", gstate0.reset, gstate0.drv_err, gstate0.uv_cp);
  40. ZLOGI(TAG, "motor1: reset:%d drv_err:%d uv_cp:%d", gstate1.reset, gstate1.drv_err, gstate1.uv_cp);
  41. /***********************************************************************************************************************
  42. * *
  43. ***********************************************************************************************************************/
  44. triLight_R.initAsOutput(TRI_LIGHT_R, kxs_gpio_nopull, false, false);
  45. triLight_G.initAsOutput(TRI_LIGHT_G, kxs_gpio_nopull, false, false);
  46. triLight_B.initAsOutput(TRI_LIGHT_B, kxs_gpio_nopull, false, false);
  47. triLight_BEEP.initAsOutput(TRI_LIGHT_BEEP, kxs_gpio_nopull, false, false);
  48. /***********************************************************************************************************************
  49. * *
  50. ***********************************************************************************************************************/
  51. osDelay(1500); // 等待传感器上电
  52. m_modbusBlockHost.initialize(&PRESSURE_SENSOR_UART);
  53. m_pressureSensorBus.init(&m_modbusBlockHost);
  54. }