Пример #1
0
uint16_t network_device_read() {
  uint16_t ret = 0;
  int i;
  packet_t *packet = 0;
  //if (xxx) DBG("device read");

  vicDisable(INT_CHANNEL_USB);
  if (!RING_IS_EMPTY(receive_ring_head, receive_ring_tail, RECEIVE_RING_SIZE)) {
    packet = &receive_ring[receive_ring_head];
    if (packet->size == 0) packet = 0;
  }
  vicEnable(INT_CHANNEL_USB);

  if (packet) {
    /* we got ip packet, copy it and notify uip framework */
    //ETH_DEV_DBG_INFO("Got a packet!");
    DBG("Got a packet! (%d bytes)",packet->size);
    packet = &receive_ring[receive_ring_head];
    for (i=0; i<packet->size; i++) {
      uip_buf[i] = packet->data[i];
      //packet->data[i] = 0;
    }
    ret = packet->size;
    packet->size = 0;

    vicDisable(INT_CHANNEL_USB);
    RING_INC(receive_ring_head, RECEIVE_RING_SIZE);
    vicEnable(INT_CHANNEL_USB);
  }
  return ret;
}
Пример #2
0
void network_device_send()
{
  int i;
  uint16_t len;

  if (packet_pending) {
    ETH_DEV_DBG_ERROR("network_device_send: already pending packet, discarding request");
    return;
  }

  if (uip_len == 0) {
    ETH_DEV_DBG_ERROR("network_device_send: uip_len == 0");
    return;
  }

  len = MIN(sizeof(send_buffer), uip_len);
  
  vicDisable(INT_CHANNEL_USB);
  
  for (i=0; i<len; i++) {
    send_buffer[i] = uip_buf[i];
  }
  bytes_sent=0;
  bytes_to_send = len;
  packet_pending = 1;

  usbEnableNAKInterrupts(INACK_BI);
  vicEnable(INT_CHANNEL_USB);

}
Пример #3
0
int usbnet_pop_completed_recv() {
    vicDisable(INT_CHANNEL_USB);
    int len = usbring_pop_freed(&recv_ring);
    vicEnable(INT_CHANNEL_USB);
    
    return len;
}
Пример #4
0
int usbnet_recv(uint8_t* buffer, uint16_t length) {
    vicDisable(INT_CHANNEL_USB);
    int success = usbring_post_buffer(&recv_ring, buffer, length);
    vicEnable(INT_CHANNEL_USB);
    
    return success;
}
Пример #5
0
void network_device_send()
{
  int i;
  uint16_t len;

  DBG("network device send! (%d bytes)",uip_len);

  if (uip_len == 0) {
    ETH_DEV_DBG_ERROR("network_device_send: uip_len == 0");
    return;
  }

  vicDisable(INT_CHANNEL_USB);
  uint8_t packet_pending_copy = packet_pending;
  vicEnable(INT_CHANNEL_USB);

  if (packet_pending_copy) {
    ETH_DEV_DBG_ERROR("network_device_send: already pending packet, discarding request");
    return;
  }

  len = MIN(sizeof(send_buffer), uip_len);

  for (i=0; i<len; i++) {
    send_buffer[i] = uip_buf[i];
  }

  vicDisable(INT_CHANNEL_USB);

  bytes_sent=0;
  bytes_to_send = len;
  packet_pending = 1;

  eth_nak_interrupts |= INACK_BI;
  usbEnableNAKInterrupts(eth_nak_interrupts);

  vicEnable(INT_CHANNEL_USB);

  //ETH_DEV_DBG_ERROR("network_device_send: NACK Interrupts enable on bulk in");

  //DBG("leaving network send");
}
int vcomGetchar(void)
{
  uint8_t c;
  bool    eof;

  vicDisable(INT_CHANNEL_USB);
  eof = fifoGet(&rxfifo, &c);
  vicEnable(INT_CHANNEL_USB);  
  
  return eof ? c : -1;
}
Пример #7
0
int usbnet_send(uint8_t* buffer, uint16_t length) {
    vicDisable(INT_CHANNEL_USB);
    int success = usbring_post_buffer(&send_ring, buffer, length);
    vicEnable(INT_CHANNEL_USB);
    
    if (success) {
        eth_nak_interrupts |= INACK_BI;
        usbEnableNAKInterrupts(eth_nak_interrupts);
    }

    return success;
}
void vcomPutchar(int c) {
  vicDisable(INT_CHANNEL_USB);
  fifoPut(&txfifo, c);
  usbEnableNAKInterrupts(INACK_BI);
  vicEnable(INT_CHANNEL_USB);
}