| 516 | } |
| 517 | |
| 518 | struct rt_vbus_data* rt_vbus_data_pop(unsigned int id) |
| 519 | { |
| 520 | struct rt_vbus_data *act; |
| 521 | rt_base_t level; |
| 522 | |
| 523 | RT_ASSERT(0 < id && id < RT_VBUS_CHANNEL_NR); |
| 524 | |
| 525 | level = rt_hw_interrupt_disable(); |
| 526 | |
| 527 | act = _bus_in_action[id][_IN_ACT_HEAD]; |
| 528 | if (act) |
| 529 | { |
| 530 | _bus_in_action[id][_IN_ACT_HEAD] = act->next; |
| 531 | } |
| 532 | |
| 533 | rt_hw_interrupt_enable(level); |
| 534 | |
| 535 | #ifdef RT_VBUS_USING_FLOW_CONTROL |
| 536 | if (_chn_recv_wm[id].level != 0) |
| 537 | { |
| 538 | _chn_recv_wm[id].level--; |
| 539 | if (_chn_recv_wm[id].level <= _chn_recv_wm[id].low_mark && |
| 540 | _chn_recv_wm[id].last_warn > _chn_recv_wm[id].low_mark) |
| 541 | { |
| 542 | unsigned char buf[2]; |
| 543 | |
| 544 | buf[0] = RT_VBUS_CHN0_CMD_RESUME; |
| 545 | buf[1] = id; |
| 546 | vbus_debug("%s --> remote\n", dump_cmd_pkt(buf, sizeof(buf))); |
| 547 | _chn0_post(buf, sizeof(buf), RT_WAITING_FOREVER); |
| 548 | _chn_recv_wm[id].last_warn = 0; |
| 549 | } |
| 550 | } |
| 551 | #endif |
| 552 | return act; |
| 553 | } |
| 554 | |
| 555 | /* dump cmd that is not start with ACK/NAK */ |
| 556 | static size_t __dump_naked_cmd(char *dst, size_t lsize, |
no test coverage detected