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

Function serial_thread_entry_dma

bsp/hc32/tests/test_uart_v2.c:134–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134static void serial_thread_entry_dma(void *parameter)
135{
136 struct rx_msg msg;
137 rt_err_t result;
138 rt_uint32_t rx_length;
139 static char rx_buffer[256];
140 static rt_uint32_t buf_size = sizeof(rx_buffer);
141 static rt_uint32_t put_index = 0;
142
143 while (1)
144 {
145 rt_memset(&msg, 0, sizeof(msg));
146 /* 从消息队列中读取消息 */
147 result = rt_mq_recv(&rx_mq, &msg, sizeof(msg), RT_WAITING_FOREVER);
148 if (result > 0UL)
149 {
150 while (msg.size)
151 {
152 if (msg.size > (buf_size - put_index))
153 {
154 rx_length = rt_device_read(msg.dev, 0, rx_buffer + put_index, buf_size - put_index);
155 msg.size -= rx_length;
156 }
157 else
158 {
159 rx_length = rt_device_read(msg.dev, 0, rx_buffer + put_index, msg.size);
160 msg.size = 0UL;
161 }
162 rt_device_write(serial, 0, rx_buffer + put_index, rx_length);
163 put_index += rx_length;
164 put_index %= sizeof(rx_buffer);
165 }
166 }
167 }
168}
169
170static void serial_thread_entry_int(void *parameter)
171{

Callers

nothing calls this directly

Calls 4

rt_memsetFunction · 0.85
rt_mq_recvFunction · 0.85
rt_device_readFunction · 0.85
rt_device_writeFunction · 0.85

Tested by

no test coverage detected