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

Function rt_vbus_data_push

components/vbus/vbus.c:474–516  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

472}
473
474void rt_vbus_data_push(unsigned int id, struct rt_vbus_data *act)
475{
476 rt_base_t level;
477
478 RT_ASSERT(0 < id && id < RT_VBUS_CHANNEL_NR);
479
480 level = rt_hw_interrupt_disable();
481
482 if (_bus_in_action[id][_IN_ACT_HEAD] == RT_NULL)
483 {
484 _bus_in_action[id][_IN_ACT_HEAD] = act;
485 _bus_in_action[id][_IN_ACT_TAIL] = act;
486 }
487 else
488 {
489 _bus_in_action[id][_IN_ACT_TAIL]->next = act;
490 _bus_in_action[id][_IN_ACT_TAIL] = act;
491 }
492
493#ifdef RT_VBUS_STATISTICS
494 _bus_in_action_nr[id]++;
495#endif
496
497 rt_hw_interrupt_enable(level);
498
499#ifdef RT_VBUS_USING_FLOW_CONTROL
500 _chn_recv_wm[id].level++;
501 if (_chn_recv_wm[id].level == 0)
502 _chn_recv_wm[id].level = ~0;
503 if (_chn_recv_wm[id].level > _chn_recv_wm[id].high_mark &&
504 _chn_recv_wm[id].level > _chn_recv_wm[id].last_warn)
505 {
506 unsigned char buf[2];
507
508 buf[0] = RT_VBUS_CHN0_CMD_SUSPEND;
509 buf[1] = id;
510 vbus_debug("%s --> remote\n", dump_cmd_pkt(buf, sizeof(buf)));
511 _chn0_post(buf, sizeof(buf), RT_WAITING_FOREVER);
512 /* Warn the other side in 100 more pkgs. */
513 _chn_recv_wm[id].last_warn = _chn_recv_wm[id].level + 100;
514 }
515#endif
516}
517
518struct rt_vbus_data* rt_vbus_data_pop(unsigned int id)
519{

Callers 1

_bus_in_entryFunction · 0.85

Calls 4

dump_cmd_pktFunction · 0.85
_chn0_postFunction · 0.85
rt_hw_interrupt_disableFunction · 0.50
rt_hw_interrupt_enableFunction · 0.50

Tested by

no test coverage detected