| 444 | } |
| 445 | |
| 446 | static void sensor_int(int argc, char **argv) |
| 447 | { |
| 448 | static rt_thread_t tid1 = RT_NULL; |
| 449 | rt_device_t dev = RT_NULL; |
| 450 | rt_sensor_t sensor; |
| 451 | |
| 452 | dev = rt_device_find(argv[1]); |
| 453 | if (dev == RT_NULL) |
| 454 | { |
| 455 | LOG_E("Can't find device:%s", argv[1]); |
| 456 | return; |
| 457 | } |
| 458 | sensor = (rt_sensor_t)dev; |
| 459 | |
| 460 | if (sensor_rx_sem == RT_NULL) |
| 461 | { |
| 462 | sensor_rx_sem = rt_sem_create("sen_rx_sem", 0, RT_IPC_FLAG_FIFO); |
| 463 | } |
| 464 | else |
| 465 | { |
| 466 | LOG_E("The thread is running, please reboot and try again"); |
| 467 | return; |
| 468 | } |
| 469 | |
| 470 | tid1 = rt_thread_create("sen_rx_thread", |
| 471 | sensor_irq_rx_entry, sensor, |
| 472 | 1024, |
| 473 | 15, 5); |
| 474 | |
| 475 | if (tid1 != RT_NULL) |
| 476 | rt_thread_startup(tid1); |
| 477 | |
| 478 | rt_device_set_rx_indicate(dev, rx_callback); |
| 479 | |
| 480 | if (rt_device_open(dev, RT_DEVICE_FLAG_INT_RX) != RT_EOK) |
| 481 | { |
| 482 | LOG_E("open device failed!"); |
| 483 | return; |
| 484 | } |
| 485 | } |
| 486 | MSH_CMD_EXPORT(sensor_int, Sensor interrupt mode test function); |
| 487 | |
| 488 | static void sensor_polling(int argc, char **argv) |
nothing calls this directly
no test coverage detected