The Maple stm32 microprocessor includes a dedicated USB peripheral which can be configured to act as a general USB slave device with transfer rates up to 12mbps (it unfortunately can not be configured as a host or on-the-go device). By default the peripheral is configured for two uses: first to recieve sketch/program uploads from the IDE, and second to emulate a regular serial port for use as a terminal (text read/write).
The emulated terminal is relatively slow and inefficient; it is best for transfering data at regulat serial speeds (kilobaud). Users requiring faster data transfer should consider implementing a different communications protocol; the Maple could be reprogrammed to appear as a mass storage device (thumb drive), human interface device (mouse or keyboard), microphone, or any other USB device.
SerialUsb.print(...)
SerialUsb.println(...)
print(1234,DEC)
; to print out
the binary numner '1001' use print(9,BIN)
.
SerialUsb.available()
SerialUsb.read()
read()
will return any data that has been recieved over the
port and available()
will tell if any such data acutally exists,
and if so how many bytes. If there is no data read()
will
block/fail, so the usual program structure is to poll with
available()
and only read()
if there's something
ready.
This documentation is released under a
Creative Commons Attribution-Share Alike 3.0 license.
Translations are welcomed; give us a ping to make sure we aren't in the process of revising or editing first.