imc_api.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * imc_api.h
  3. *
  4. * Created on: Jul 21, 2022
  5. * Author: yoojin.lim d(yoojin.lim@etri.re.kr)
  6. */
  7. #ifndef INC_IMC_IMC_API_H_
  8. #define INC_IMC_IMC_API_H_
  9. #include "stm32l5xx_hal.h"
  10. #include "sc03mpd/sc03mpd.h"
  11. #define UART_HANDLER_SBC huart1
  12. #define UART_HANDLER_CAM huart3
  13. #define NUM_OF_LED 4
  14. #define LED0_GPIO GPIOB
  15. #define LED1_GPIO GPIOB
  16. #define LED2_GPIO GPIOC
  17. #define LED3_GPIO GPIOC
  18. #define LED0_GPIO_PIN GPIO_PIN_1
  19. #define LED1_GPIO_PIN GPIO_PIN_2
  20. #define LED2_GPIO_PIN GPIO_PIN_6
  21. #define LED3_GPIO_PIN GPIO_PIN_7
  22. #define SBC_POWER_GPIO GPIOG
  23. #define CAM_POWER_GPIO GPIOC
  24. #define SBC_POWER_GPIO_PIN GPIO_PIN_11
  25. #define CAM_POWER_GPIO_PIN GPIO_PIN_7
  26. #define POWER_ON_SBC GPIO_PIN_RESET // LOW; only for SBC
  27. #define POWER_OFF_SBC GPIO_PIN_SET // HIGH; only for SBC
  28. #define POWER_ON GPIO_PIN_SET // CAM, Sensors, etc. (KETI, 230811)
  29. #define POWER_OFF GPIO_PIN_RESET // CAM, Sensors, etc. (KETI, 230811)
  30. #define EPS_CAP_VOLT_GPIO 0
  31. #define EPS_CAP_VOLT_ADC 1
  32. #if (EPS_CAP_VOLT_GPIO)
  33. #define EPS_SBC_OFF_LEVEL 1 // 1~7
  34. #define ENERGY_LV0_GPIO GPIOF
  35. #define ENERGY_LV1_GPIO GPIOF
  36. #define ENERGY_LV2_GPIO GPIOF
  37. #define ENERGY_LV0_GPIO_PIN GPIO_PIN_8
  38. #define ENERGY_LV1_GPIO_PIN GPIO_PIN_9
  39. #define ENERGY_LV2_GPIO_PIN GPIO_PIN_10
  40. #endif
  41. #if (EPS_CAP_VOLT_ADC)
  42. #define ADC_HANDLER_SBC hadc1
  43. #define ADC_HANDLER_CAM hadc2
  44. #define EPS_CAP_VOLT_LOW_THRESHOLD_SBC (3600) // Voltage threshold to do the checkpointing in MilliVolt
  45. #define EPS_CAP_VOLT_LOW_THRESHOLD_CAM (3700) // Voltage threshold to do the checkpointing in MilliVolt
  46. #define EPS_CAP_VOLT_HIGH_THRESHOLD_CAM (4800) // Voltage threshold to do the checkpointing in MilliVolt
  47. #define DELAY_WAIT_CAP_CHECK (2000)
  48. #define COUNTER_WAIT_CAP_CHECK (60)
  49. #define EPS_CAP_ID_SBC 0
  50. #define EPS_CAP_ID_CAM 1
  51. int measure_voltage(ADC_HandleTypeDef hadc, uint8_t ch);
  52. int32_t imc_sc03mpd_cap_check (ADC_HandleTypeDef hadc);
  53. #endif
  54. #define CAM_SHOT_PIN GPIO_PIN_6
  55. #define DELAY_IGNORE_REQ (500) // 500ticks
  56. #define DELAY_AFTER_POWERUP (1000) // 2500 ms in manual
  57. #define DELAY_AFTER_CAPTURE (250) // 250
  58. #define DELAY_AFTER_LENGTH (10) //
  59. #define DELAY_DURING_DOWNLOAD (1)
  60. #define DELAY_BEFORE_ERR_HANDLING (100) // 50 ms
  61. #define DELAY_GET_ENERGY_LEVEL (3) // 3 ms
  62. #define DELAY_AFTER_WORK (100) // 50ms
  63. #define DELAY_DO_SOMETHING (1000)
  64. #define IMG_RAM_ADDR (0x68200000)
  65. #define IMG_BLK_SIZE (256)
  66. #define CAM_STS_ENON ( 0) // Executing right
  67. #define CAM_STS_EINI (-1) // Error during init.
  68. #define CAM_STS_ECAP (-2) // Error during image capturing
  69. #define CAM_STS_EDWN (-3) // Error during image downloading
  70. #define CAM_CHANGE_BAUDRATE 0 // set 1 and execute once when change CAM default baudrate
  71. #define CAM_BAUDRATE_OPERATING 115200
  72. #define CAM_BAUDRATE_CURRENT 38400
  73. #define CAM_IMAGE_FIRST_TWO_BYTES 0
  74. #define CAM_FAST_READY 0
  75. #define CAM_BLACK_WHITE 0
  76. #define CAM_COMP_ZERO 1
  77. #define CAM_ERROR_COUNT_MAX 5 // successive ERRORs -> SBC reboot
  78. #define IMAGE_RESOLUTION SC03MPD_RES_160_120 // _640_480, _320_240 (default), _160_120
  79. #if CAM_COMP_ZERO
  80. #define IMAGE_COMPRESSIBILTY 0x00 // SKKU needs raw pixel format to feed an image to AI
  81. #else
  82. #define IMAGE_COMPRESSIBILTY 0x36 // 0x00~FF, 0x36 (default)
  83. #endif
  84. void imc_led_on (uint8_t ledSet[], uint8_t count, uint32_t msec);
  85. void imc_led_blink (uint8_t ledSet[], uint8_t count, uint32_t msec);
  86. int32_t imc_sc03mpd_init(sc03mpd_ifx_t* ifx);
  87. int32_t imc_sc03mpd_capture (sc03mpd_ifx_t* ifx);
  88. int32_t imc_sc03mpd_reset (sc03mpd_ifx_t* ifx);
  89. void imc_sbc_power_off ();
  90. void imc_sbc_power_on ();
  91. void imc_cam_power_off ();
  92. void imc_cam_power_on ();
  93. uint8_t imc_get_energy_level ();
  94. extern uint16_t ilen;
  95. #endif /* INC_IMC_IMC_API_H_ */