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.

91 lines
3.5 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. #include <stddef.h>
  2. #include <stdio.h>
  3. #include "board.h"
  4. #include "sdk\components\subcanmodule\zcancmder_subboard_initer.hpp"
  5. /*******************************************************************************
  6. * PROJECT_INCLUDE *
  7. *******************************************************************************/
  8. #include "sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp"
  9. #include "sdk\components\mini_servo_motor\feite_servo_motor.hpp"
  10. #include "sdk\components\mini_servo_motor\mini_servo_motor_ctrl_module.hpp"
  11. #include "sdk\components\pipette_module\pipette_ctrl_module_v2.hpp"
  12. #include "sdk\components\sensors\m3078\m3078_code_scaner.hpp"
  13. #include "sdk\components\tmc\ic\ztmc4361A.hpp"
  14. #include "sdk\components\tmc\ic\ztmc5130.hpp"
  15. #include "temperature_sensor.hpp"
  16. #define TAG "main"
  17. using namespace iflytop;
  18. using namespace std;
  19. static ZCancmderSubboardIniter initer;
  20. extern void umain();
  21. extern "C" {
  22. void StartDefaultTask(void const* argument) { umain(); }
  23. extern DMA_HandleTypeDef hdma_usart3_rx;
  24. extern DMA_HandleTypeDef hdma_usart3_tx;
  25. }
  26. /*******************************************************************************
  27. * GET_DEVICE_ID *
  28. *******************************************************************************/
  29. static int32_t getDeviceId() {
  30. static bool init = false;
  31. static ZGPIO ID0;
  32. static ZGPIO ID1;
  33. static ZGPIO ID2;
  34. static ZGPIO ID3;
  35. static ZGPIO ID4;
  36. if (!init) {
  37. ID0.initAsInput(ID0_IO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
  38. ID1.initAsInput(ID1_IO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
  39. ID2.initAsInput(ID2_IO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
  40. ID3.initAsInput(ID3_IO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
  41. ID4.initAsInput(ID4_IO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
  42. init = true;
  43. }
  44. uint8_t id = ID0.getState() * 1 + ID1.getState() * 2 + ID2.getState() * 4 + ID3.getState() * 8 + ID4.getState() * 16;
  45. return id;
  46. }
  47. /*******************************************************************************
  48. * INIT_SUBMODULE *
  49. *******************************************************************************/
  50. void nvs_init_cb() {}
  51. TemperatureSensor m_temperature_sensor[8];
  52. static void initsubmodule() {
  53. osDelay(1000);
  54. {
  55. m_temperature_sensor[0].initialize(&hadc1, ADC_CHANNEL_10);
  56. m_temperature_sensor[1].initialize(&hadc1, ADC_CHANNEL_11);
  57. m_temperature_sensor[2].initialize(&hadc1, ADC_CHANNEL_12);
  58. m_temperature_sensor[3].initialize(&hadc1, ADC_CHANNEL_13);
  59. m_temperature_sensor[4].initialize(&hadc1, ADC_CHANNEL_14);
  60. }
  61. {}
  62. }
  63. /*******************************************************************************
  64. * MAIN *
  65. *******************************************************************************/
  66. void umain() {
  67. ZCancmderSubboardIniter::cfg_t cfg = //
  68. {
  69. .deviceId = getDeviceId(),
  70. .input_gpio = {},
  71. .output_gpio = {},
  72. .temperature_sensor =
  73. {
  74. &m_temperature_sensor[0],
  75. &m_temperature_sensor[1],
  76. &m_temperature_sensor[2],
  77. &m_temperature_sensor[3],
  78. &m_temperature_sensor[4],
  79. },
  80. };
  81. initer.init(&cfg);
  82. initsubmodule();
  83. initer.loop();
  84. }