GlobLib
HAL and API libraries for MCUs and hardware.
|
This module contains low level functions for USB interaction. More...
Files | |
file | stm32f103cb_usb.h |
Header file for stm32f103cb USB. | |
Functions | |
void | USB_setup (void) |
Initialize the USB device. More... | |
void | USB_update (void) |
Update the USB peripheral. More... | |
void | USB_put (uint8_t byte) |
Send a single byte on USB. More... | |
void | USB_setGet (void(*data_available)(uint8_t)) |
Set the function called when data is received on the USB. More... | |
void | USB_disconnect (void) |
Dissconnect the USB device from the HOST. More... | |
This module contains low level functions for USB interaction.
The USB stack is taken from a modified version of OPENCM3 lib.
The USB module has a maximum data rate of 64kb / second.
When using the USB, USB_update must be called at at least 4KHz. Higher frequencies can be used, however this just causes unneccesary CPU usage.
The clock frequency for the MCU must be either internal 48MHz or external 72MHz for the USB to function.
void USB_disconnect | ( | void | ) |
Dissconnect the USB device from the HOST.
This is also called internally at the start of USB_setup(). This allows a software reset to register with the host and the USB to be reconfigured.
Definition at line 271 of file stm32f103cb_usb.c.
void USB_put | ( | uint8_t | byte | ) |
Send a single byte on USB.
This function actually loads the byte into the internal software buffer. The byte is send internally in USB_update().
byte | The byte to send (add to buffer). |
Definition at line 340 of file stm32f103cb_usb.c.
void USB_setGet | ( | void(*)(uint8_t) | data_available | ) |
Set the function called when data is received on the USB.
data_available | Funtion pointer to the function to be called |
Definition at line 309 of file stm32f103cb_usb.c.
void USB_setup | ( | void | ) |
Initialize the USB device.
This must be called before any other API feature is used.
The clock must be > 48Mhz This function has a internal delay for the USB to setup (approx 0.3s);
Definition at line 287 of file stm32f103cb_usb.c.
void USB_update | ( | void | ) |
Update the USB peripheral.
This must be call at at least 4kHz.
This function handles control requests from the host and sends any data waiting in the internal software buffer.
Definition at line 318 of file stm32f103cb_usb.c.