Course Highlights
  • Write a bare-metal firmware for USB 2.0 human interface devices (HID) without using any third-party libraries or code generators.
  • Implement USB device driver and USB 2.0 protocol framework.
  • Program a fully functional USB mouse from zero.
  • Understand the generic USB descriptors and the descriptors specific to human interface device (HID) class.
  • Deal with native USB (WITHOUT any conversion to UART)
  • Use ARM Cortex-M4 based microcontroller (STM32F4xx), one of the most developed and famous MCU in the world.
  • Debug USB communication using Wireshark and Linux SysLog.
  • Read different parts of ARM Cortex-M4 reference manual and extract the important information efficiently.
  • Understanding how USB 2.0 protocol works in full speed mode.
  • Understand USB endpoints, pipes, transfer types, packets, transactions, frames, power supply, topology, and many more.
  • Learn the basic mechanical and electrical specifications of the USB (connectors, cables, speed enumeration resistors, and many more).
  • Know the history and motivation behind developing the universal serial bus (USB).
  • Learn using Single Wire Output (SWO) to send logs to the debugging host.
  • Increase your productivity and code portability by using ARM CMSIS.
  • Document your code using Doxygen syntax.
Curriculum

5 Topics
Introduction
How to Get the Most of This Course?
Discord Server for Student Communication
Why STM32F429ZI (ARM Cortex-M4 Based) Microcontroller?
Udemy Review

9 Topics
Definition and Motivation
History
Cables and Connectors
USB 2.0 Cable Structure
Main Features
Bus Topology and Functions
VBUS
Power Delivery Specification
Smart Charger

28 Topics
Differential States
Bus States
Timing Tolerance
USB 2.0 Speed Identification
Bit Stuffing
Non-Return-to-Zero Inverted (NRZI)
Host Controllers
Frames
Endpoints
(PDF) Packet and Transaction Types
Packets
Packet Types and Packet Fields
Transaction
Packet Identifiers
Token Packets
Data Packets
Handshake Packets
Device Address
Bus Polling
USB is Host Driver
USB is Host Driver Demonstration
Endpoint Types (Transfer Types)
Interrupt Transfer
Bulk Transfer
Isochronous Transfer
Control Transfer
Control Transfer Stages
Bus Bandwidth Allocation

8 Topics
Installing STM32CubeIDE
Creating a New Project
Including ARM CMSIS
Removing Sysmem and Syscalls
Log to Debugger Using SWO
Logging Helper
Configuring Debugger and SVW for Logging
Project source code

20 Topics
NO CODE GENERATION IN STM32CubeMX
My Method to Explain Clocking
Creating Temporary STM32CubeMX Project
USB Module Requires 48 MHz Signal
Understanding Clock Frequency Requirements
Understanding PLL Prescalers SYSCLK and HCLK
Understanding MCO Divider
Initial Steps to Configure the Clock
CMSIS Bit Operations
Configuring Flash Latency
CMSIS Fld2Val and Val2Fld Macros
Enabling HSE
Enabling and Configuring PLL
Configuring APB-Prescaler
Disabling HSI
Correction of PLL Configuration Trap
Testing Clock Configuration
Configuring MCO
Verifying the Clock Frequency Using Oscilloscope
Reconfiguring SWO Clock Frequency

2 Topics
Installing Wireshark on Linux
Viewing Linux System Log

9 Topics
Firmware Architecture We Will Be Using
Creating Driver Source and Header Files and Accessing USB Regions
Configuring GPIOs as USB Pins
Tips to Get the Most Benefits
Skimming Core and Device Configuration
USB Core Initialization
Initializing USB Core Interrupts
Connecting the USB Device to the Bus (Using Firmware)
Testing Connecting the USB Device to the Host

23 Topics
USB Core Global Interrupts
USB Global Interrupt Handler
Steps of Handling USB Reset Signal
USB Reset Handler
Configuring Endpoint 0
Configuring IN Endpoints
NOTICE about "Deconfiguring Endpoint" lecture
Deconfiguring Endpoint
NOTE: Parameters Validation and Code Documentation
Understanding FIFO Dedicated Memory
Configuring FIFO Size
Configuring FIFO Offset
Configuring FIFOs While Configuring Endpoints
Flushing FIFOs
Accessing the FIFOs
Transfer Completed Interrupts
USB Speed Enumeration Done Handler
Implementing RxFIFO Not Empty Interrupt Handler
SETUP and OUT Transfer Completed Status Data
Popping Data from the RxFIFO (From an OUT endpoint)
Pushing Data into a TxFIFO (To an IN endpoint)
Fixing Compilaiton Error (Reorder Some Functions)
Defining USB Driver Type

45 Topics
Polling on Interrupt Level
Defining USB Events Type
Defining USB Device States
Defining USB Control Transfer Stages
Defining USB Device Instance Structure
Starting to Configure the USB Device Instance
Implementing USB Reset Handler
[DRIVER] Implementing USB Set Address
Triggering USB Reset Event (Calling the Handler)
Reading the Received Requests
Understanding USB Request Structure
Understanding USB Standard Device Requests
Defining the Structure of USB Requests
Starting Processing the Requests
Investigating the First Request
Defining Descriptor Structure
Writing the Device Descriptor
Defining the Standard Request Macros (wValue)
Defining a Variable after a Switch Case Error
Write a Packet ONLY when the Endpoint is Empty
Starting Implementing Control Stage Processor
Handling GET DEVICE Descriptor Request
Processing IN-DATA Stage
Handling IN and OUT Endpoint Interrupts
Handling IN and OUT Transfer Completed
Sending the Last Packet of Transactions
Processing OUT-STATUS Stage
Processing IN-DATA Zero Sub-Stage
Call the Implemented Functions Before Testing
Viewing the First Successful Communication in SysLog
Viewing the First Successful Communication in Wireshark
Processing SET ADDRESS Request
Setting Device Address after transaction completion
Processing IN-STATUS Stage
Viewing no SET ADDRESS Error in SysLog
Viewing SET ADDRESS Request and Response in Wireshark
Viewing full GET DEVICE DESCRIPTOR response in Wireshark
Viewing GET CONFIGURATION request in Wireshark
Understanding the idea of combining descriptors
Defining CONFIGURATION descriptor placeholder
Merging the CONFIG-Combination into one definition
Handling GET CONFIGURATION DESCRIPTOR request
Understanding the size of CONFIG-Combination
Processing SET CONFIGURATION request
Defining use-case-specific configuration function

16 Topics
Simple USB Mouse specifications
Writing CONFIGURATION descriptor
Writing INTERFACE descriptor
Writing ENDPOINT descriptor
Writing HID descriptor
Introducing HID Report descriptor / HID report structure
Describing HID buttons
Describing HID axes
Compacting HID report descriptor
Packing data encapsulations (no word alignment)
Introducing Set Idle and Get HID Report descriptor requests
Handling SET IDLE request
Handling GET HID REPORT descriptor request
Responding to INTERRUPT IN tokens
Testing the USB HID Mouse
Changing descriptors order (Windows compatibility)

1 Topic
Conclusion Next Steps and Thank you!

  Write a Review

USB Behind the Scenes: Hands-on HID Firmware Development

Go to Paid Course