Kleber Silva / IOTON-API

Dependents:   ton_demo ton_template

Embed: (wiki syntax)

« Back to documentation index

USBTon Class Reference

USBTon Class Reference

USBTon example. More...

#include <USBTon.h>

Public Member Functions

 USBTon (uint16_t vendor_id=0x1f00, uint16_t product_id=0x2012, uint16_t product_release=0x0001, bool connect_blocking=true)
 Constructor.
virtual int _putc (int c)
 Send a character.
virtual int _getc ()
 Read a character: blocking.
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.

Detailed Description

USBTon example.

 #include "mbed.h"
 #include "USBTon.h"

 //Virtual serial port over USB
 USBTon usb;

 int main(void) {

    while(1)
    {
        usb.printf("I am a virtual serial port\n");
        wait(1);
    }
 }

Definition at line 28 of file USBTon.h.


Constructor & Destructor Documentation

USBTon ( uint16_t  vendor_id = 0x1f00,
uint16_t  product_id = 0x2012,
uint16_t  product_release = 0x0001,
bool  connect_blocking = true 
)

Constructor.

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

Definition at line 40 of file USBTon.h.


Member Function Documentation

int _getc (  ) [virtual]

Read a character: blocking.

Returns:
character read

Definition at line 9 of file USBTon.cpp.

int _putc ( int  c ) [virtual]

Send a character.

You can use puts, printf.

Parameters:
ccharacter to be sent
Returns:
true if there is no error, false otherwise

Definition at line 4 of file USBTon.cpp.

uint8_t available (  )

Check the number of bytes available.

Returns:
the number of bytes available

Definition at line 15 of file USBTon.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 73 of file USBTon.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 81 of file USBTon.h.