MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / sensor_int

Function sensor_int

components/drivers/sensor/v1/sensor_cmd.c:199–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199static void sensor_int(int argc, char **argv)
200{
201 static rt_thread_t tid1 = RT_NULL;
202 rt_device_t dev = RT_NULL;
203 rt_sensor_t sensor;
204
205 dev = rt_device_find(argv[1]);
206 if (dev == RT_NULL)
207 {
208 LOG_E("Can't find device:%s", argv[1]);
209 return;
210 }
211 sensor = (rt_sensor_t)dev;
212
213 if (sensor_rx_sem == RT_NULL)
214 {
215 sensor_rx_sem = rt_sem_create("sen_rx_sem", 0, RT_IPC_FLAG_FIFO);
216 }
217 else
218 {
219 LOG_E("The thread is running, please reboot and try again");
220 return;
221 }
222
223 tid1 = rt_thread_create("sen_rx_thread",
224 sensor_irq_rx_entry, sensor,
225 1024,
226 15, 5);
227
228 if (tid1 != RT_NULL)
229 rt_thread_startup(tid1);
230
231 rt_device_set_rx_indicate(dev, rx_callback);
232
233 if (rt_device_open(dev, RT_DEVICE_FLAG_INT_RX) != RT_EOK)
234 {
235 LOG_E("open device failed!");
236 return;
237 }
238 rt_device_control(dev, RT_SENSOR_CTRL_SET_ODR, (void *)20);
239}
240#ifdef RT_USING_FINSH
241 MSH_CMD_EXPORT(sensor_int, Sensor interrupt mode test function);
242#endif

Callers

nothing calls this directly

Calls 7

rt_device_findFunction · 0.85
rt_sem_createFunction · 0.85
rt_thread_createFunction · 0.85
rt_thread_startupFunction · 0.85
rt_device_openFunction · 0.85
rt_device_controlFunction · 0.85

Tested by

no test coverage detected