1 #ifndef __HAL_SENSOR_HUB_H__ 2 #define __HAL_SENSOR_HUB_H__ 3 4 #ifdef __cplusplus 5 extern "C" { 6 #endif 7 8 #include "hal_dma.h" 9 #include "hal_gpio.h" 10 11 enum HAL_SENSOR_ENGINE_ID_T { 12 HAL_SENSOR_ENGINE_ID_0 = 0, 13 HAL_SENSOR_ENGINE_ID_1, 14 HAL_SENSOR_ENGINE_ID_2, 15 HAL_SENSOR_ENGINE_ID_3, 16 17 HAL_SENSOR_ENGINE_ID_QTY, 18 }; 19 20 enum HAL_SENSOR_ENGINE_TRIGGER_T { 21 HAL_SENSOR_ENGINE_TRIGGER_TIMER = 0, 22 HAL_SENSOR_ENGINE_TRIGGER_GPIO, 23 24 HAL_SENSOR_ENGINE_TRIGGER_QTY, 25 }; 26 27 enum HAL_SENSOR_ENGINE_DEVICE_T { 28 HAL_SENSOR_ENGINE_DEVICE_I2C0 = 0, 29 HAL_SENSOR_ENGINE_DEVICE_I2C1, 30 HAL_SENSOR_ENGINE_DEVICE_SPI0 = 4, 31 HAL_SENSOR_ENGINE_DEVICE_SPI1, 32 HAL_SENSOR_ENGINE_DEVICE_SPI2, 33 }; 34 35 typedef void (*HAL_SENSOR_ENG_HANDLER_T)(enum HAL_SENSOR_ENGINE_ID_T id, enum HAL_SENSOR_ENGINE_DEVICE_T device, const uint8_t *buf, uint32_t len); 36 37 struct HAL_SENSOR_ENGINE_CFG_T { 38 enum HAL_SENSOR_ENGINE_ID_T id; 39 enum HAL_SENSOR_ENGINE_DEVICE_T device; 40 enum HAL_SENSOR_ENGINE_TRIGGER_T trigger_type; 41 enum HAL_GPIO_PIN_T trigger_gpio; 42 uint32_t period_us; 43 struct HAL_DMA_CH_CFG_T *tx_dma_cfg; 44 struct HAL_DMA_CH_CFG_T *rx_dma_cfg; 45 uint16_t device_address; 46 uint16_t rx_burst_len; 47 uint8_t rx_burst_cnt; 48 uint8_t data_to_vad; 49 HAL_SENSOR_ENG_HANDLER_T handler; 50 }; 51 52 int hal_sensor_engine_open(const struct HAL_SENSOR_ENGINE_CFG_T *cfg); 53 int hal_sensor_engine_close(enum HAL_SENSOR_ENGINE_ID_T id); 54 55 void hal_sensor_process_rx_buffer(void); 56 57 #ifdef __cplusplus 58 } 59 #endif 60 61 #endif 62 63 64