| 132 | } |
| 133 | |
| 134 | static void sensor_fifo(int argc, char **argv) |
| 135 | { |
| 136 | static rt_thread_t tid1 = RT_NULL; |
| 137 | rt_device_t dev = RT_NULL; |
| 138 | rt_sensor_t sensor; |
| 139 | |
| 140 | dev = rt_device_find(argv[1]); |
| 141 | if (dev == RT_NULL) |
| 142 | { |
| 143 | LOG_E("Can't find device:%s", argv[1]); |
| 144 | return; |
| 145 | } |
| 146 | sensor = (rt_sensor_t)dev; |
| 147 | |
| 148 | if (rt_device_open(dev, RT_DEVICE_FLAG_FIFO_RX) != RT_EOK) |
| 149 | { |
| 150 | LOG_E("open device failed!"); |
| 151 | return; |
| 152 | } |
| 153 | |
| 154 | if (sensor_rx_sem == RT_NULL) |
| 155 | { |
| 156 | sensor_rx_sem = rt_sem_create("sen_rx_sem", 0, RT_IPC_FLAG_FIFO); |
| 157 | } |
| 158 | else |
| 159 | { |
| 160 | LOG_E("The thread is running, please reboot and try again"); |
| 161 | return; |
| 162 | } |
| 163 | |
| 164 | tid1 = rt_thread_create("sen_rx_thread", |
| 165 | sensor_fifo_rx_entry, sensor, |
| 166 | 1024, |
| 167 | 15, 5); |
| 168 | |
| 169 | if (tid1 != RT_NULL) |
| 170 | rt_thread_startup(tid1); |
| 171 | |
| 172 | rt_device_set_rx_indicate(dev, rx_callback); |
| 173 | |
| 174 | rt_device_control(dev, RT_SENSOR_CTRL_SET_ODR, (void *)20); |
| 175 | } |
| 176 | #ifdef RT_USING_FINSH |
| 177 | MSH_CMD_EXPORT(sensor_fifo, Sensor fifo mode test function); |
| 178 | #endif |
nothing calls this directly
no test coverage detected