
Credits:
Optimistic / Inspirational by Mixaund | https://mixaund.bandcamp.com
Music promoted by https://www.free-stock-music.com
Credits:
Five stars: http://www.pngall.com/?p=39082
The definition of universal serial bus (USB) and the motivation behind USB development.
The history of USB development and USB versions.
The most common USB cables and connectors.
A quick look on the inner-structure of the specified cable in USB 2.0.
The main features of USB protocol regardless of the USB version.
Demonstration of the USB star topology and the meaning of USB function.
Explanation about the history of different power supply specifications for USB devices.
Explanation about the principle of smart chargers.
Identify USB 2.0 speed by noting host pull-downs on D+ and D− data lines, and device pull-ups on D− for low speed or D+ for full/high speed.
Explain how frames, marked by the start of frame signal every one millisecond in full-speed USB, allocate minimum portions to each device, balancing camera, keyboard, and mouse bandwidth.
Here you can find a PDF file that contains the slides of some of the important upcoming lectures that you may need frequently to be opened next to you while watching the videos (e.g. to be able to compare the transaction types without switching between the videos).
Understand how USB transmits data in packets, with packet structure, endpoint-based size decisions, and signaling from sync to end, including bit stuffing and least significant bit first.
Understand USB packet identifiers (PIDs) and the PID field, outlining token, data, and handshake packets, their in and out directions, and how a PID value indicates packet type.
Explore how USB is host driven, where the host triggers all transactions with out and setup tokens, and the host requests device data using in tokens.
Understand the four USB transfer types—interrupt, bulk, isochronous, and control—and how endpoints, including the control endpoint zero, perform transfers. The host learns endpoint configuration and descriptors during device enumeration.
Explore how USB control transfer enables device enumeration and configuration through endpoint zero, detailing setup, data, and status stages and their handshaking for error-free transmission.
Organize a logging helper for hid firmware by adding include and source helpers and implementing logger c and h with error, information, and debug levels, and set system_log_level in system_init.
Configure the microcontroller clock to feed a fixed 48 MHz USB clock, using an 8 MHz external oscillator, HSE, PLL multipliers/dividers, and prescalers, with CubeMX guiding the calculations.
Explain how to configure MCO one source mux to output the PLL clock on PA8, routing USB and system clocks, and verify a 36 MHz signal on the MCO1 pin.
Configure flash memory read latency as wait states before raising the CPU clock to 72 MHz, by modifying the flash ACR latency field using standard macros and datasheet guidance.
Use the fld2val macro to convert a value into a field with proper bit shifting and masking, then examine the first register modification and USB-related code glimpses.
Configure mco1 to output clock on pin a8 by selecting the clock source, setting prescaler to two, enabling gpio a, and setting pin a8 to alternate function with medium speed.
Discover a three-layer USB firmware architecture—driver layer, framework (protocol-specific) layer, and application layer—balancing hardware access, host interactions, endpoints, and FIFO buffer management.
Use two firmware functions to connect or disconnect the USB device by setting the software disconnect bit in the device control register and toggling the power down bit for transceivers.
Explore argument validation within the USB HID driver abstraction and learn to document code with doxygen, balancing hardware specific checks with forward progress in the driver layer.
Implement the rx fifo not-empty interrupt handler by popping the status word, decoding endpoint and byte count, and routing setup versus out data packets.
Understand how setup and out transfer statuses from the fifo may appear without data, and how to re-enable endpoints after transfers in USB HID firmware.
Resolve compilation errors by including the USB standards header, then reorder functions so definitions appear before use, enabling the project to compile successfully.
Define a usb_device structure in header to store device state, default address, endpoint zero control transfer stage, current configuration, and data buffers; declare a usb_events variable in the driver header.
Initialize the USB device by passing and storing a USB device pointer in a static global variable, then set an out buffer in main.c and compile.
investigate the host's first usb request by examining the get device descriptor transaction, showing an eight-byte setup with bm request 0x80, bRequest 6, descriptor type 1, length 64.
Define the USB standard device descriptor and other descriptor types, explain get descriptor requests, and show how host requests specify descriptor types using the value byte.
Define standard USB request macros in the USB standards header and handle get descriptor requests by extracting the descriptor type from the w value field.
Implement the function to process the control transfer stage and handle the USB pulled event to manage setup and data in stages, including get device descriptor, in a bus-polling loop.
Define and attach the in transfer completed handler to USB events, check the in data buffer, and resume the in data stage to send the next packet to endpoint zero.
Set address requests are handled in the outer switch with no data stage; read W value, update device address via the driver, then switch to in status stage.
Demonstrate viewing a USB set address request and its immediate response in Wireshark, alongside capturing device descriptor traffic and debugging USB timeouts during firmware development.
Explore usb device classes and how peripherals like mice interact with hosts, and implement a simple hid mouse firmware that moves the cursor periodically, with buttons and position sensor enhancements.
Write the USB configuration descriptor for a mouse HID device, defining the configuration, interfaces, and endpoints, calculating the total length, and setting attributes, max power, and wake capability.
Add the USB ID descriptor for HID, create a dedicated ID standards header, link to an ID report descriptor, and clarify descriptor versus report descriptor to prepare testing.
Describe HID buttons by setting the usage page to button, defining min/max and logical ranges, and specifying report size, count, input as absolute, with padding for compatibility.
Implement handling of standard USB interface requests, including get report descriptor, to deliver HID report data via a control transfer and endpoint three.
Instantiate a mouse report, fill the x and y values, and write it to endpoint three after a successful transfer using the in transfer completed handler.
Have you ever wanted to develop your own device that can be connected to a computer using USB? Are you familiar with using USB <-> UART adapters but want to take your USB knowledge and understanding to the next ultimate level? If yes, then this course is absolutely for you!
I made the whole content of slides and code by myself after a lot of preparation and fine-tuning to give you the best experience you can find today online to learn and understand USB protocol and framework in theory and in practice.
Your journey with me in this course should save you from any frustration that could happen when you try to learn or understand USB from any other online source. USB is for most a mystery and a very complex protocol, and most engineers try to avoid it or at least try to convert it to other simpler protocols. However, after taking this course, you will be able to be a confident native USB engineer, and you will be able to develop your first bare-metal USB device with me without using any library, which will give you full control over the powers of USB. Even if you want in your career to use a USB library, taking this course will give you a full understanding of what is going on behind the scenes, and will allow you to be able to develop and fine-tune and USB device you want, because, after the end of this course, I would expect from you to have a full understanding of the concept of USB and how it works.
In this course, we will:
- Start with some theoretical information about USB.
- Understand the essential details of USB protocol.
- Take our time to understand how to configure the clock of any embedded system correctly.
- Implement a bare-metal USB firmware for ARM Cortex M4 based microcontroller (STM32F4xx family).
- Implement a bare-metal USB framework.
- Develop our own USB HID mouse from zero to fully functional!
Of course, the source code of the project we are going to develop together in this course will be available for you to download. You may use it as a template (fully or partially) for your projects in the future.
This course is in its early stages and some new additional content will be added or enhanced if necessary frequently. Nevertheless, the current content is full and sufficient to get a fully functional USB human interface device.
Happy engineering! See you inside the course!