SerialUSB

Aus LaborWiki
Version vom 25. Mai 2015, 19:25 Uhr von Laurenz (Diskussion | Beiträge) (svn -> github)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu: Navigation, Suche
       
SerialUSB

Release status: stable [box doku]

Description Code Example for STM32F4xx
Author(s)  siro (siro)
Platform  STM32F4xx
License  mixed
Download  [1]




Overview

serialUSB is a c code-example for STM32F4xx.
It will create a virtual com port VCP using the built in USB device stack. On the host PC the VCP acts like a physical terminal (COM-port).
The default device name is /dev/ttyACM0 .
Make sute to blacklist the device and/or shut down modem-manager as it tries to sent AT-commands to it.
/dev/ttyACM0 can be accessed like any other terminal /dev/tty0 (physical) or /dev/ttyUSB0 (PL2303).


Virtual Com Port

void VCP_send_str(uint8_t* buf)

will sent a string to host
note: too long strings may cause buffer overrun

void VCP_put_char(uint8_t buf)

will sent a single char to host

uint8_t VCP_get_char(uint8_t *buf)

nonblocking:
return 1 on success, 0 otherwise
on success buf contains the read character

uint8_t VCP_get_string(uint8_t *buf)

nonblocking:
return read bytes on success, 0 otherwise
on success buf contains the read characters