Fork of https://developer.mbed.org/users/bscott/code/STM32_USBDevice/

Fork of STM32_USBDevice by Bradley Scott

Embed: (wiki syntax)

« Back to documentation index

USBWebUSBSerial Class Reference

USBWebUSBSerial Class Reference

WebUSB/USBSerial composite device class Handles outputting to standard CDC or WebUSB endpoint depending on mode. More...

#include <USBWebUSBSerial.h>

Inherits USBDevice.

Public Member Functions

 USBWebUSBSerial (uint16_t vendor_id, uint16_t product_id, uint16_t product_release=0x0001, bool connect_blocking=true)
 Constructor.
int read (uint8_t *buf, uint16_t size)
 Read up to size bytes from input buffer.
uint8_t available ()
 Check the number of bytes available.
int readable ()
 Determine if there is a character available to read.
int writeable ()
 Determine if there is space available to write a character.
bool writeBuffered (const uint8_t *buf, uint16_t size)
 Write data asynchronously using internal output buffer.
template<typename T >
void attach (T *tptr, void(T::*mptr)(void))
 Attach a member function to call when a packet is received.
void attach (void(*fptr)(void))
 Attach a callback called when a packet is received.
void attach (void(*fptr)(int baud, int bits, int parity, int stop))
 Attach a callback to call when serial's settings are changed.

Detailed Description

WebUSB/USBSerial composite device class Handles outputting to standard CDC or WebUSB endpoint depending on mode.

Definition at line 42 of file USBWebUSBSerial.h.


Constructor & Destructor Documentation

USBWebUSBSerial ( uint16_t  vendor_id,
uint16_t  product_id,
uint16_t  product_release = 0x0001,
bool  connect_blocking = true 
)

Constructor.

Parameters:
vendor_idYour vendor_id
product_idYour product_id
product_releaseYour product_release (default: 0x0001)
connect_blockingdefine if the connection must be blocked if USB not plugged in

Definition at line 108 of file USBWebUSBSerial.cpp.


Member Function Documentation

void attach ( T *  tptr,
void(T::*)(void)  mptr 
)

Attach a member function to call when a packet is received.

Parameters:
tptrpointer to the object to call the member function on
mptrpointer to the member function to be called

Definition at line 115 of file USBWebUSBSerial.h.

void attach ( void(*)(void)  fptr )

Attach a callback called when a packet is received.

Parameters:
fptrfunction pointer

Definition at line 128 of file USBWebUSBSerial.h.

void attach ( void(*)(int baud, int bits, int parity, int stop)  fptr )

Attach a callback to call when serial's settings are changed.

Parameters:
fptrfunction pointer

Definition at line 141 of file USBWebUSBSerial.h.

uint8_t available (  )

Check the number of bytes available.

Returns:
the number of bytes available

Definition at line 616 of file USBWebUSBSerial.cpp.

int read ( uint8_t *  buf,
uint16_t  size 
)

Read up to size bytes from input buffer.

Returns:
the number of bytes read

Definition at line 520 of file USBWebUSBSerial.cpp.

int readable (  )

Determine if there is a character available to read.

Returns:
1 if there is a character available to read, 0 otherwise

Definition at line 88 of file USBWebUSBSerial.h.

int writeable (  )

Determine if there is space available to write a character.

Returns:
1 if there is space to write a character, 0 otherwise

Definition at line 96 of file USBWebUSBSerial.h.

bool writeBuffered ( const uint8_t *  buf,
uint16_t  size 
)

Write data asynchronously using internal output buffer.

Parameters:
bufpointer to data
sizesize of the buffer. The maximum size of data is limited by the size of the internal buffer
Returns:
true if successfull

Definition at line 526 of file USBWebUSBSerial.cpp.