* @brief This function will close the pipe and release the pipe buffer. * * @param device is a pointer to the pipe device descriptor. * * @return Return the operation status. * When the return value is RT_EOK, the operation is successful. * When the return value is -RT_EINVAL, it means the device handle is empty. */
| 461 | * When the return value is -RT_EINVAL, it means the device handle is empty. |
| 462 | */ |
| 463 | rt_err_t rt_pipe_close(rt_device_t device) |
| 464 | { |
| 465 | rt_pipe_t *pipe = (rt_pipe_t *)device; |
| 466 | |
| 467 | if (device == RT_NULL) |
| 468 | { |
| 469 | return -RT_EINVAL; |
| 470 | } |
| 471 | rt_mutex_take(&pipe->lock, RT_WAITING_FOREVER); |
| 472 | |
| 473 | rt_ringbuffer_destroy(pipe->fifo); |
| 474 | pipe->fifo = RT_NULL; |
| 475 | |
| 476 | rt_mutex_release(&pipe->lock); |
| 477 | |
| 478 | return RT_EOK; |
| 479 | } |
| 480 | |
| 481 | /** |
| 482 | * @brief This function will read the specified length of data from the pipe. |
nothing calls this directly
no test coverage detected