Skip to content

USB: USB_Host_Shield_2.0

hasu@tmk edited this page Nov 22, 2021 · 6 revisions

Address Assignment

  • Hub with parent = 0 is assigned to 0x41. port is not used.
  • Device with parent = 0 is assigned to 0x01. port is not used.
  • Hub with parent != 0 is assigned using hubCounter. port is not used.
  • Device with parent != 0 is assigned using port.

address.h:

virtual uint8_t AllocAddress(uint8_t parent, bool is_hub = false, uint8_t port = 0)

UsbDeviceAddress:

struct UsbDeviceAddress {
        union {

                struct {
                        uint8_t bmAddress : 3; // device address/port number
                        uint8_t bmParent : 3; // parent hub address
                        uint8_t bmHub : 1; // hub flag
                        uint8_t bmReserved : 1; // reserved, must be zero
                } __attribute__((packed));
                uint8_t devAddress;
        };
} __attribute__((packed));
    bit ____________________________ Reserved(0)
       /   _________________________ Hub flag(bmHub)
      /   /   ______________________ Parent Hub no(bmParent)
     /   /   /   /   /   ___________ Hub no or Port no(bmAddress)
    /   /   /   /   /   /   /   /
    7   6   5   4   3   2   1   0
    -----------------------------
    0   0   0   0   0   0   0   0  00   Default Address
    0   0   0   0   0   0   0   1  01   Device directly attached on Host Controller
    0   1   0   0   0   0   0   1  41   Hub 1 directly attached to Host Controller
    0   1   0   0   1   0   1   0  4A   Hub 2 on Hub 1
    0   1   0   0   1   0   1   1  4B   Hub 3 on Hub 1
    0   1   0   1   0   0   1   1  53   Hub 3 on Hub 2
    0   0   0   0   1   0   0   1  09   Device on Port 1 of Hub 1(Root Hub)
    0   0   0   0   1   0   1   0  0A   Device on Port 2 of Hub 1(Root Hub)
    0   0   0   1   0   0   0   1  11   Device on Port 1 of Hub 2
    0   0   0   1   0   0   1   0  12   Device on Port 2 of Hub 2

Clone this wiki locally