ソースを参照

CLeanup of RX buffer/queue management.

main
MatthewBergman 4年前
コミット
0d0d0a6116
2個のファイルの変更11行の追加23行の削除
  1. +2
    -3
      USBHost_t36.h
  2. +9
    -20
      adk.cpp

+ 2
- 3
USBHost_t36.h ファイルの表示

@@ -60,7 +60,6 @@
//#define USBHOST_PRINT_DEBUG
//#define USBHDBGSerial Serial1


#ifndef USBHDBGSerial
#define USBHDBGSerial Serial
#endif
@@ -1878,8 +1877,8 @@ private:
Pipe_t *txpipe;
enum { MAX_PACKET_SIZE = 512 };
enum { RX_QUEUE_SIZE = 1024 }; // must be more than MAX_PACKET_SIZE
uint32_t rx_buffer[MAX_PACKET_SIZE/4];
uint32_t tx_buffer[MAX_PACKET_SIZE/4];
uint8_t rx_buffer[MAX_PACKET_SIZE];
uint8_t tx_buffer[MAX_PACKET_SIZE];
uint16_t rx_size;
uint16_t tx_size;
uint8_t rx_queue[RX_QUEUE_SIZE];

+ 9
- 20
adk.cpp ファイルの表示

@@ -310,34 +310,22 @@ void ADK::rx_data(const Transfer_t *transfer)
print_hexbytes(transfer->buffer, len);
uint32_t head = rx_head;
uint32_t tail = rx_tail;
for (uint32_t i=0; i < len; i++)
uint8_t *p = (const uint8_t *)transfer->buffer;
if (p != NULL && len != 0)
{
uint32_t msg = rx_buffer[i];
if (msg)
do
{
if (++head >= RX_QUEUE_SIZE)
head = 0;
rx_queue[head] = msg;
if (++head >= RX_QUEUE_SIZE)
head = 0;
rx_queue[head] = msg >> 8;
if (++head >= RX_QUEUE_SIZE)
head = 0;
rx_queue[head] = msg >> 16;
if (++head >= RX_QUEUE_SIZE)
head = 0;
rx_queue[head] = msg >> 24;
}
rx_queue[head] = *p++;
} while (--len);
}
rx_head = head;
rx_packet_queued = false;
rx_queue_packets(head, tail);
rx_queue_packets(rx_head, rx_tail);
}

void ADK::rx_queue_packets(uint32_t head, uint32_t tail)
@@ -353,6 +341,7 @@ void ADK::rx_queue_packets(uint32_t head, uint32_t tail)
{
// enough space to accept another full packet
println("queue another receive packet");
queue_Data_Transfer(rxpipe, rx_buffer, rx_size, this);
rx_packet_queued = true;
} else {
@@ -453,7 +442,7 @@ size_t ADK::write(size_t len, uint8_t *buf)
{
memcpy(tx_buffer, buf, len);
__disable_irq();
queue_Data_Transfer(txpipe, tx_buffer, len, this);
queue_Data_Transfer(txpipe, tx_buffer, len, this);
__enable_irq();
return len;

読み込み中…
キャンセル
保存