#pragma once #include "app_config.h" #include "includes.h" #include "circular_buf.h" #define RET_OK (0) #define RET_ERR (-1) typedef enum { SENSOR_DRV_ACCELER = 0x00, SENSOR_DRV_GYRO, SENSOR_DRV_MAGNETIC, SENSOR_DRV_HR, SENSOR_DRV_SPO2, SENSOR_DRV_HR_SPO2, SENSOR_DRV_WEAR_DETECTION, SENSOR_DRV_TEMP, SENSOR_DRV_MAX_NUM, SENSOR_ALGO_WRIST_TILT = 0x20, SENSOR_ALGO_HR, SENSOR_ALGO_SPO2, SENSOR_ALGO_STEP_COUNTER, } sensor_type_t; typedef enum { SENSOR_STATE_OFFLINE = 0, SENSOR_STATE_ONLINE = 1, SENSOR_STATE_CLOSE = 1, SENSOR_STATE_OPEN = 2, } sensor_state_t; typedef struct { u8 addr; u8 value; } sensor_regs_t; typedef struct { u8 type; u8 state; u8 name[20]; u8 odr[4]; u16 range[4]; cbuffer_t *cbuffer; } sensor_info_t; typedef struct { u8 type; u8 enable; u8 odr; u16 range; } p11_sensor_t; typedef struct { sensor_info_t *info; s8(*open)(u16 range, u16 odr); s8(*close)(void); s8(*run)(void *arg, u16 *len); s8(*online)(void); s8(*sleep)(void); } SENSOR_INTERFACE; extern SENSOR_INTERFACE sensor_dev_begin[]; extern SENSOR_INTERFACE sensor_dev_end[]; #define REGISTER_SENSOR(Sensor) \ static const SENSOR_INTERFACE Sensor SEC_USED(.sensor_dev) #define list_for_each_sensor(c) \ for (c=sensor_dev_begin; c