summaryrefslogtreecommitdiff
path: root/components/drivers/src
diff options
context:
space:
mode:
authorWang-Huachen <[email protected]>2020-12-07 09:44:37 +0800
committerWang-Huachen <[email protected]>2020-12-07 09:44:37 +0800
commit1af5b72a99850644d87b19df89e105d18b30ec9f (patch)
tree513dfa298961c065c381fa2d2b7afcf86dc88a72 /components/drivers/src
parent72583289231b5664b38363c1d3d5d411a970bb57 (diff)
parentcc9374f052c2fd6f4b70d76ee8fefa331942dd3a (diff)
Merge branch 'master' of https://github.com/RT-Thread/rt-thread
Diffstat (limited to 'components/drivers/src')
-rw-r--r--components/drivers/src/ringbuffer.c34
-rw-r--r--components/drivers/src/workqueue.c2
2 files changed, 35 insertions, 1 deletions
diff --git a/components/drivers/src/ringbuffer.c b/components/drivers/src/ringbuffer.c
index c6a491a7cc..88afd19506 100644
--- a/components/drivers/src/ringbuffer.c
+++ b/components/drivers/src/ringbuffer.c
@@ -194,6 +194,40 @@ rt_size_t rt_ringbuffer_get(struct rt_ringbuffer *rb,
RTM_EXPORT(rt_ringbuffer_get);
/**
+ * peak data from ring buffer
+ */
+rt_size_t rt_ringbuffer_peak(struct rt_ringbuffer *rb, rt_uint8_t **ptr)
+{
+ RT_ASSERT(rb != RT_NULL);
+
+ *ptr = RT_NULL;
+
+ /* whether has enough data */
+ rt_size_t size = rt_ringbuffer_data_len(rb);
+
+ /* no data */
+ if (size == 0)
+ return 0;
+
+ *ptr = &rb->buffer_ptr[rb->read_index];
+
+ if(rb->buffer_size - rb->read_index > size)
+ {
+ rb->read_index += size;
+ return size;
+ }
+
+ size = rb->buffer_size - rb->read_index;
+
+ /* we are going into the other side of the mirror */
+ rb->read_mirror = ~rb->read_mirror;
+ rb->read_index = 0;
+
+ return size;
+}
+RTM_EXPORT(rt_ringbuffer_peak);
+
+/**
* put a character into ring buffer
*/
rt_size_t rt_ringbuffer_putchar(struct rt_ringbuffer *rb, const rt_uint8_t ch)
diff --git a/components/drivers/src/workqueue.c b/components/drivers/src/workqueue.c
index 2e0280df3a..2b5630d8d0 100644
--- a/components/drivers/src/workqueue.c
+++ b/components/drivers/src/workqueue.c
@@ -424,6 +424,6 @@ int rt_work_sys_workqueue_init(void)
return RT_EOK;
}
-INIT_DEVICE_EXPORT(rt_work_sys_workqueue_init);
+INIT_PREV_EXPORT(rt_work_sys_workqueue_init);
#endif
#endif