浏览代码

ADK read now returns a byte, not uint32_t.

main
MatthewBergman 5 年前
父节点
当前提交
3e8ce3eed7
共有 2 个文件被更改,包括 20 次插入6 次删除
  1. +2
    -2
      USBHost_t36.h
  2. +18
    -4
      adk.cpp

+ 2
- 2
USBHost_t36.h 查看文件

@@ -1877,12 +1877,12 @@ private:
Pipe_t *rxpipe;
Pipe_t *txpipe;
enum { MAX_PACKET_SIZE = 512 };
enum { RX_QUEUE_SIZE = 160 }; // must be more than MAX_PACKET_SIZE/4
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];
uint16_t rx_size;
uint16_t tx_size;
uint32_t rx_queue[RX_QUEUE_SIZE];
uint8_t rx_queue[RX_QUEUE_SIZE];
bool rx_packet_queued;
uint16_t rx_head;
uint16_t rx_tail;

+ 18
- 4
adk.cpp 查看文件

@@ -233,7 +233,7 @@ void ADK::sendStr(Device_t *dev, uint8_t index, char *str)

void ADK::control(const Transfer_t *transfer)
{
println("Control callback state=%i",state);
println("Control callback state=",state);
switch (state)
{
@@ -312,13 +312,26 @@ void ADK::rx_data(const Transfer_t *transfer)
uint32_t head = rx_head;
uint32_t tail = rx_tail;
for (uint32_t i=0; i < ceil(len/4); i++)
for (uint32_t i=0; i < len; i++)
{
uint32_t msg = rx_buffer[i];
if (msg) {
if (msg)
{
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_head = head;
@@ -336,7 +349,8 @@ void ADK::rx_queue_packets(uint32_t head, uint32_t tail)
println("rx_size = ", rx_size);
println("avail = ", avail);
if (avail >= (uint32_t)(rx_size>>2)) {
if (avail >= rx_size)
{
// enough space to accept another full packet
println("queue another receive packet");
queue_Data_Transfer(rxpipe, rx_buffer, rx_size, this);

正在加载...
取消
保存