23#define rt_sensor_get_ts() time(RT_NULL)
25#define rt_sensor_get_ts() rt_tick_get()
28#define RT_DEVICE_FLAG_FIFO_RX 0x200
30#define RT_SENSOR_MODULE_MAX (3)
32#define RT_SENSOR_MACRO_GET_NAME(macro) (macro##_STR)
35#define RT_SENSOR_TYPE_NONE (0)
36#define RT_SENSOR_TYPE_NONE_STR "None"
37#define RT_SENSOR_TYPE_ACCE (1)
38#define RT_SENSOR_TYPE_ACCE_STR "Accelerometer"
39#define RT_SENSOR_TYPE_GYRO (2)
40#define RT_SENSOR_TYPE_GYRO_STR "Gyroscope"
41#define RT_SENSOR_TYPE_MAG (3)
42#define RT_SENSOR_TYPE_MAG_STR "Magnetometer"
43#define RT_SENSOR_TYPE_TEMP (4)
44#define RT_SENSOR_TYPE_TEMP_STR "Temperature"
45#define RT_SENSOR_TYPE_HUMI (5)
46#define RT_SENSOR_TYPE_HUMI_STR "Relative Humidity"
47#define RT_SENSOR_TYPE_BARO (6)
48#define RT_SENSOR_TYPE_BARO_STR "Barometer"
49#define RT_SENSOR_TYPE_LIGHT (7)
50#define RT_SENSOR_TYPE_LIGHT_STR "Ambient Light"
51#define RT_SENSOR_TYPE_PROXIMITY (8)
52#define RT_SENSOR_TYPE_PROXIMITY_STR "Proximity"
53#define RT_SENSOR_TYPE_HR (9)
54#define RT_SENSOR_TYPE_HR_STR "Heart Rate"
55#define RT_SENSOR_TYPE_TVOC (10)
56#define RT_SENSOR_TYPE_TVOC_STR "TVOC Level"
57#define RT_SENSOR_TYPE_NOISE (11)
58#define RT_SENSOR_TYPE_NOISE_STR "Noise Loudness"
59#define RT_SENSOR_TYPE_STEP (12)
60#define RT_SENSOR_TYPE_STEP_STR "Step"
61#define RT_SENSOR_TYPE_FORCE (13)
62#define RT_SENSOR_TYPE_FORCE_STR "Force"
63#define RT_SENSOR_TYPE_DUST (14)
64#define RT_SENSOR_TYPE_DUST_STR "Dust"
65#define RT_SENSOR_TYPE_ECO2 (15)
66#define RT_SENSOR_TYPE_ECO2_STR "eCO2"
67#define RT_SENSOR_TYPE_GNSS (16)
68#define RT_SENSOR_TYPE_GNSS_STR "GNSS"
69#define RT_SENSOR_TYPE_TOF (17)
70#define RT_SENSOR_TYPE_TOF_STR "ToF"
71#define RT_SENSOR_TYPE_SPO2 (18)
72#define RT_SENSOR_TYPE_SPO2_STR "SpO2"
73#define RT_SENSOR_TYPE_IAQ (19)
74#define RT_SENSOR_TYPE_IAQ_STR "IAQ"
75#define RT_SENSOR_TYPE_ETOH (20)
76#define RT_SENSOR_TYPE_ETOH_STR "EtOH"
77#define RT_SENSOR_TYPE_BP (21)
78#define RT_SENSOR_TYPE_BP_STR "Blood Pressure"
79#define RT_SENSOR_TYPE_VOLTAGE (22)
80#define RT_SENSOR_TYPE_VOLTAGE_STR "Voltage"
81#define RT_SENSOR_TYPE_CURRENT (23)
82#define RT_SENSOR_TYPE_CURRENT_STR "Current"
85#define RT_SENSOR_VENDOR_UNKNOWN (0)
86#define RT_SENSOR_VENDOR_UNKNOWN_STR "Unknown"
87#define RT_SENSOR_VENDOR_VIRTUAL (1)
88#define RT_SENSOR_VENDOR_VIRTUAL_STR "Virtual Sensor"
89#define RT_SENSOR_VENDOR_ONCHIP (2)
90#define RT_SENSOR_VENDOR_ONCHIP_STR "OnChip"
91#define RT_SENSOR_VENDOR_STM (3)
92#define RT_SENSOR_VENDOR_STM_STR "STMicroelectronics"
93#define RT_SENSOR_VENDOR_BOSCH (4)
94#define RT_SENSOR_VENDOR_BOSCH_STR "Bosch"
95#define RT_SENSOR_VENDOR_INVENSENSE (5)
96#define RT_SENSOR_VENDOR_INVENSENSE_STR "Invensense"
97#define RT_SENSOR_VENDOR_SEMTECH (6)
98#define RT_SENSOR_VENDOR_SEMTECH_STR "Semtech"
99#define RT_SENSOR_VENDOR_GOERTEK (7)
100#define RT_SENSOR_VENDOR_GOERTEK_STR "Goertek"
101#define RT_SENSOR_VENDOR_MIRAMEMS (8)
102#define RT_SENSOR_VENDOR_MIRAMEMS_STR "MiraMEMS"
103#define RT_SENSOR_VENDOR_DALLAS (9)
104#define RT_SENSOR_VENDOR_DALLAS_STR "Dallas"
105#define RT_SENSOR_VENDOR_ASAIR (10)
106#define RT_SENSOR_VENDOR_ASAIR_STR "Aosong"
107#define RT_SENSOR_VENDOR_SHARP (11)
108#define RT_SENSOR_VENDOR_SHARP_STR "Sharp"
109#define RT_SENSOR_VENDOR_SENSIRION (12)
110#define RT_SENSOR_VENDOR_SENSIRION_STR "Sensirion"
111#define RT_SENSOR_VENDOR_TI (13)
112#define RT_SENSOR_VENDOR_TI_STR "Texas Instruments"
113#define RT_SENSOR_VENDOR_PLANTOWER (14)
114#define RT_SENSOR_VENDOR_PLANTOWER_STR "Plantower"
115#define RT_SENSOR_VENDOR_AMS (15)
116#define RT_SENSOR_VENDOR_AMS_STR "ams-OSRAM AG"
117#define RT_SENSOR_VENDOR_MAXIM (16)
118#define RT_SENSOR_VENDOR_MAXIM_STR "Maxim Integrated"
119#define RT_SENSOR_VENDOR_MELEXIS (17)
120#define RT_SENSOR_VENDOR_MELEXIS_STR "Melexis"
121#define RT_SENSOR_VENDOR_LSC (18)
122#define RT_SENSOR_VENDOR_LSC_STR "Lite On"
125#define RT_SENSOR_UNIT_NONE (0)
126#define RT_SENSOR_UNIT_NONE_STR ""
127#define RT_SENSOR_UNIT_MG (1)
128#define RT_SENSOR_UNIT_MG_STR "mG"
129#define RT_SENSOR_UNIT_MDPS (2)
130#define RT_SENSOR_UNIT_MDPS_STR "mdps"
131#define RT_SENSOR_UNIT_MGAUSS (3)
132#define RT_SENSOR_UNIT_MGAUSS_STR "mGauss"
133#define RT_SENSOR_UNIT_LUX (4)
134#define RT_SENSOR_UNIT_LUX_STR "lux"
135#define RT_SENSOR_UNIT_M (5)
136#define RT_SENSOR_UNIT_M_STR "m"
137#define RT_SENSOR_UNIT_CM (6)
138#define RT_SENSOR_UNIT_CM_STR "cm"
139#define RT_SENSOR_UNIT_MM (7)
140#define RT_SENSOR_UNIT_MM_STR "mm"
141#define RT_SENSOR_UNIT_PA (8)
142#define RT_SENSOR_UNIT_PA_STR "Pa"
143#define RT_SENSOR_UNIT_MMHG (9)
144#define RT_SENSOR_UNIT_MMHG_STR "mmHg"
145#define RT_SENSOR_UNIT_PERCENTAGE (10)
146#define RT_SENSOR_UNIT_PERCENTAGE_STR "%"
147#define RT_SENSOR_UNIT_PERMILLAGE (11)
148#define RT_SENSOR_UNIT_PERMILLAGE_STR "‰"
149#define RT_SENSOR_UNIT_CELSIUS (12)
150#define RT_SENSOR_UNIT_CELSIUS_STR "℃"
151#define RT_SENSOR_UNIT_FAHRENHEIT (13)
152#define RT_SENSOR_UNIT_FAHRENHEIT_STR "℉"
153#define RT_SENSOR_UNIT_KELVIN (14)
154#define RT_SENSOR_UNIT_KELVIN_STR "K"
155#define RT_SENSOR_UNIT_HZ (15)
156#define RT_SENSOR_UNIT_HZ_STR "Hz"
157#define RT_SENSOR_UNIT_V (16)
158#define RT_SENSOR_UNIT_V_STR "V"
159#define RT_SENSOR_UNIT_MV (17)
160#define RT_SENSOR_UNIT_MV_STR "mV"
161#define RT_SENSOR_UNIT_A (18)
162#define RT_SENSOR_UNIT_A_STR "A"
163#define RT_SENSOR_UNIT_MA (19)
164#define RT_SENSOR_UNIT_MA_STR "mA"
165#define RT_SENSOR_UNIT_N (20)
166#define RT_SENSOR_UNIT_N_STR "N"
167#define RT_SENSOR_UNIT_MN (21)
168#define RT_SENSOR_UNIT_MN_STR "mN"
169#define RT_SENSOR_UNIT_BPM (22)
170#define RT_SENSOR_UNIT_BPM_STR "bpm"
171#define RT_SENSOR_UNIT_PPM (23)
172#define RT_SENSOR_UNIT_PPM_STR "ppm"
173#define RT_SENSOR_UNIT_PPB (24)
174#define RT_SENSOR_UNIT_PPB_STR "ppb"
175#define RT_SENSOR_UNIT_DMS (25)
176#define RT_SENSOR_UNIT_DMS_STR "DMS"
177#define RT_SENSOR_UNIT_DD (26)
178#define RT_SENSOR_UNIT_DD_STR "DD"
179#define RT_SENSOR_UNIT_MGM3 (27)
180#define RT_SENSOR_UNIT_MGM3_STR "mg/m3"
183#define RT_SENSOR_INTF_I2C (1 << 0)
184#define RT_SENSOR_INTF_I2C_STR "I2C"
185#define RT_SENSOR_INTF_SPI (1 << 1)
186#define RT_SENSOR_INTF_SPI_STR "SPI"
187#define RT_SENSOR_INTF_UART (1 << 2)
188#define RT_SENSOR_INTF_UART_STR "UART"
189#define RT_SENSOR_INTF_ONEWIRE (1 << 3)
190#define RT_SENSOR_INTF_ONEWIRE_STR "1-Wire"
191#define RT_SENSOR_INTF_CAN (1 << 4)
192#define RT_SENSOR_INTF_CAN_STR "CAN"
193#define RT_SENSOR_INTF_MODBUS (1 << 5)
194#define RT_SENSOR_INTF_MODBUS_STR "Modbus"
202#define RT_SENSOR_MODE_ACCURACY_BIT_OFFSET (8)
203#define RT_SENSOR_MODE_POWER_BIT_OFFSET (4)
204#define RT_SENSOR_MODE_FETCH_BIT_OFFSET (0)
206#define RT_SENSOR_MODE_GET_ACCURACY(mode) (rt_uint8_t)((mode >> RT_SENSOR_MODE_ACCURACY_BIT_OFFSET) & 0x0F)
207#define RT_SENSOR_MODE_GET_POWER(mode) (rt_uint8_t)((mode >> RT_SENSOR_MODE_POWER_BIT_OFFSET) & 0x0F)
208#define RT_SENSOR_MODE_GET_FETCH(mode) (rt_uint8_t)((mode >> RT_SENSOR_MODE_FETCH_BIT_OFFSET) & 0x0F)
210#define RT_SENSOR_MODE_CLEAR_ACCURACY(mode) (mode &= ((rt_uint16_t)~((rt_uint16_t)0x0F << RT_SENSOR_MODE_ACCURACY_BIT_OFFSET)))
211#define RT_SENSOR_MODE_CLEAR_POWER(mode) (mode &= ((rt_uint16_t)~((rt_uint16_t)0x0F << RT_SENSOR_MODE_POWER_BIT_OFFSET)))
212#define RT_SENSOR_MODE_CLEAR_FETCH(mode) (mode &= ((rt_uint16_t)~((rt_uint16_t)0x0F << RT_SENSOR_MODE_FETCH_BIT_OFFSET)))
214#define RT_SENSOR_MODE_SET_ACCURACY(mode, accuracy_mode) RT_SENSOR_MODE_CLEAR_ACCURACY(mode); (mode |= (accuracy_mode << RT_SENSOR_MODE_ACCURACY_BIT_OFFSET))
215#define RT_SENSOR_MODE_SET_POWER(mode, power_mode) RT_SENSOR_MODE_CLEAR_POWER(mode); (mode |= (power_mode << RT_SENSOR_MODE_POWER_BIT_OFFSET))
216#define RT_SENSOR_MODE_SET_FETCH(mode, fetch_mode) RT_SENSOR_MODE_CLEAR_FETCH(mode); (mode |= (fetch_mode << RT_SENSOR_MODE_FETCH_BIT_OFFSET))
219#define RT_SENSOR_MODE_ACCURACY_HIGHEST (0)
220#define RT_SENSOR_MODE_ACCURACY_HIGHEST_STR "Accuracy Highest"
221#define RT_SENSOR_MODE_ACCURACY_HIGH (1)
222#define RT_SENSOR_MODE_ACCURACY_HIGH_STR "Accuracy High"
223#define RT_SENSOR_MODE_ACCURACY_MEDIUM (2)
224#define RT_SENSOR_MODE_ACCURACY_MEDIUM_STR "Accuracy Medium"
225#define RT_SENSOR_MODE_ACCURACY_LOW (3)
226#define RT_SENSOR_MODE_ACCURACY_LOW_STR "Accuracy Low"
227#define RT_SENSOR_MODE_ACCURACY_LOWEST (4)
228#define RT_SENSOR_MODE_ACCURACY_LOWEST_STR "Accuracy Lowest"
229#define RT_SENSOR_MODE_ACCURACY_NOTRUST (5)
230#define RT_SENSOR_MODE_ACCURACY_NOTRUST_STR "Accuracy No Trust"
233#define RT_SENSOR_MODE_POWER_HIGHEST (0)
234#define RT_SENSOR_MODE_POWER_HIGHEST_STR "Power Highest"
235#define RT_SENSOR_MODE_POWER_HIGH (1)
236#define RT_SENSOR_MODE_POWER_HIGH_STR "Power High"
237#define RT_SENSOR_MODE_POWER_MEDIUM (2)
238#define RT_SENSOR_MODE_POWER_MEDIUM_STR "Power Medium"
239#define RT_SENSOR_MODE_POWER_LOW (3)
240#define RT_SENSOR_MODE_POWER_LOW_STR "Power Low"
241#define RT_SENSOR_MODE_POWER_LOWEST (4)
242#define RT_SENSOR_MODE_POWER_LOWEST_STR "Power Lowest"
243#define RT_SENSOR_MODE_POWER_DOWN (5)
244#define RT_SENSOR_MODE_POWER_DOWN_STR "Power Down"
247#define RT_SENSOR_MODE_FETCH_POLLING (0)
248#define RT_SENSOR_MODE_FETCH_POLLING_STR "Polling Mode"
249#define RT_SENSOR_MODE_FETCH_INT (1)
250#define RT_SENSOR_MODE_FETCH_INT_STR "Interrupt Mode"
251#define RT_SENSOR_MODE_FETCH_FIFO (2)
252#define RT_SENSOR_MODE_FETCH_FIFO_STR "FIFO Mode"
255#define RT_SENSOR_CTRL_GET_ID (RT_DEVICE_CTRL_BASE(Sensor) + 0)
256#define RT_SENSOR_CTRL_SELF_TEST (RT_DEVICE_CTRL_BASE(Sensor) + 1)
257#define RT_SENSOR_CTRL_SOFT_RESET (RT_DEVICE_CTRL_BASE(Sensor) + 2)
258#define RT_SENSOR_CTRL_SET_FETCH_MODE (RT_DEVICE_CTRL_BASE(Sensor) + 3)
259#define RT_SENSOR_CTRL_SET_POWER_MODE (RT_DEVICE_CTRL_BASE(Sensor) + 4)
260#define RT_SENSOR_CTRL_SET_ACCURACY_MODE (RT_DEVICE_CTRL_BASE(Sensor) + 5)
262#define RT_SENSOR_CTRL_USER_CMD_START 0x100
265#ifdef RT_USING_SENSOR_DOUBLE_FLOAT
struct rt_mutex * rt_mutex_t
unsigned short rt_uint16_t
#define RT_SENSOR_MODULE_MAX
struct rt_sensor_device * rt_sensor_t
struct rt_sensor_scale * rt_sensor_scale_t
struct rt_sensor_info * rt_sensor_info_t
int rt_hw_sensor_register(rt_sensor_t sensor, const char *name, rt_uint32_t flag, void *data)
rt_sensor_t rt_sensor_device_find(const char *name)
struct rt_sensor_device * rt_sensor_t
struct rt_sensor_accuracy * rt_sensor_accuracy_t
struct rt_sensor_data * rt_sensor_data_t
rt_sensor_float_t resolution
struct rt_sensor_intf intf
struct rt_device_pin_mode irq_pin
union rt_sensor_data::@022165123134134131071120365022351202312371364346 data
struct sensor_3_axis gyro
struct sensor_3_axis acce
struct rt_sensor_module * module
const struct rt_sensor_ops * ops
struct rt_sensor_info info
struct rt_sensor_config config
rt_err_t(* irq_handle)(rt_sensor_t sensor)
rt_sensor_float_t acquire_min
struct rt_sensor_scale scale
struct rt_sensor_accuracy accuracy
rt_sensor_t sen[RT_SENSOR_MODULE_MAX]
rt_ssize_t(* fetch_data)(struct rt_sensor_device *sensor, void *buf, rt_size_t len)
rt_err_t(* control)(struct rt_sensor_device *sensor, int cmd, void *arg)
rt_sensor_float_t range_min
rt_sensor_float_t range_max