The peripheral handles all the host-side handshaking, along with the Data0 and Data1 toggling when sending data. An endpoint may be disabled, stalled, NAK’ing, or ready. The USB peripheral keeps track of the endpoint status.There is a single interrupt for handling all events associated with the USB peripheral.This is called the “ Buffer Descriptor Table” ( BDT) and functions in a very similar way to the BDT on the K20. A table located in the PMA (location in the PMA is at the user’s discretion) points to all the other buffers in the PMA which are actually used for transferring data.I’m going to talk about this at length later, since it has some special considerations. This memory is used to copy packets to and from the host.
This area of memory in the STM32 is called the Packet Memory Area or PMA. I’m not sure which way I like better, as they have their pros and cons. This contrasts with the K20 peripheral which required that a portion of the microcontroller’s general SRAM be allocated by the program for the peripheral to use and flag bits be used to inform the peripheral of who “owns” some portion of the memory.
#IMPRIVATA STM32 DRIVER MANUAL#
The family reference manual (very very long document, >1000 pages usually).As I’ve discovered is very common for microcontrollers, you need the following: Next, you will need to locate the appropriate datasheets. The “hook pattern”, callbacks based on weak linksĪs I have recommended in my previous post, please visit to get up to speed on how USB works. Feel free to leave a comment with your thoughts.
#IMPRIVATA STM32 DRIVER HOW TO#
My intent here is to show how to interact with the STM32 USB peripheral and one way to get started writing your own HAL around it, rather than relying on others’ software. In fact, I believe some of it might be wrong (specifically my treatment of the PMA on the STM32L052).
#IMPRIVATA STM32 DRIVER CODE#
My objective here is to walk quickly through the operation of the USB Peripheral, specifically the Packet Memory Area, then talk a bit about how the USB Peripheral does transfers, and move on to how I structured my code to abstract the USB packetizing logic away from the application. (mainly in common/src/usb.c and common/include/usb.h) Example code for this post can be found here: