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

Function rt_console_isr

bsp/x86/drivers/console.c:214–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212}
213
214static void rt_console_isr(int vector, void* param)
215{
216 char c;
217 rt_bool_t ret;
218 rt_base_t level;
219
220 if(INTUART0_RX == vector)
221 {
222 c = rt_serial_getc();
223 ret = RT_TRUE;
224 }
225 else
226 {
227 rt_keyboard_isr();
228 ret = rt_keyboard_getc(&c);
229 }
230
231 if(ret == RT_FALSE)
232 {
233 /* do nothing */
234 }
235 else
236 {
237 /* disable interrupt */
238 level = rt_hw_interrupt_disable();
239
240 /* save character */
241 rx_buffer[save_index] = c;
242 save_index ++;
243 if (save_index >= CONSOLE_RX_BUFFER_SIZE)
244 save_index = 0;
245
246 /* if the next position is read index, discard this 'read char' */
247 if (save_index == read_index)
248 {
249 read_index ++;
250 if (read_index >= CONSOLE_RX_BUFFER_SIZE)
251 read_index = 0;
252 }
253
254 /* enable interrupt */
255 rt_hw_interrupt_enable(level);
256 }
257
258 /* invoke callback */
259 if (console_device.rx_indicate != RT_NULL)
260 {
261 rt_size_t rx_length;
262
263 /* get rx length */
264 rx_length = read_index > save_index ?
265 CONSOLE_RX_BUFFER_SIZE - read_index + save_index :
266 save_index - read_index;
267
268 if(rx_length > 0)
269 {
270 console_device.rx_indicate(&console_device, rx_length);
271 }

Callers

nothing calls this directly

Calls 5

rt_keyboard_isrFunction · 0.85
rt_keyboard_getcFunction · 0.85
rt_serial_getcFunction · 0.70
rt_hw_interrupt_disableFunction · 0.50
rt_hw_interrupt_enableFunction · 0.50

Tested by

no test coverage detected