Code Confidencebuild 3.0.0.201402161939

API Function

Name

usbs_serial_start, usbs_serial_init, usbs_serial_start, usbs_serial_wait_until_configured, usbs_serial_is_configured, usbs_serial_start_tx, usbs_serial_wait_for_tx, usbs_serial_tx, usbs_serial_start_rx, usbs_serial_wait_for_rx, usbs_serial_rx, usbs_serial_state_change_handler --  eCos USB Serial like Peripherals API

Synopsis

#include <cyg/io/usb/usbs_serial.h>
        

void usbs_serial_start (void);

void usbs_serial_init (usbs_serial * ser, usbs_tx_endpoint * tx_ep, usbs_rx_endpoint * rx_ep);

void usbs_serial_wait_until_configured (void>);

cyg_bool usbs_serial_is_configured (void);

void usbs_serial_start_tx (usbs_serial * ser, const void *buf, int * n);

int usbs_serial_wait_for_tx (usbs_serial * ser);

void usbs_serial_start_rx (usbs_serial * ser, const void *buf, int * n);

int usbs_serial_wait_for_rx (usbs_serial * ser);

int usbs_serial_rx (usbs_serial * ser, const void *buf, int * n);

void usbs_serial_state_change_handler (usbs_control_endpoint * ep, void * data, usbs_state_change change, int prev_state);

Description

For examples of how to use this API see the files .../tests/usbserial_echo.c and .../tests/usb2serial.c

The first function that needs calling is usbs_serial_start(). This will initialise the eCos USB slave layer, creating all the enumeration data and then let the host know that the device exists.

Once the USB subsystem has been started it is necessary to wait for the host to configure the device using the function usbs_serial_wait_until_configured(). The host will assign the device an ID and then load the appropriate device driver in the host in order to make use the device.

Once the device is configured it is then possible to make use of it, i.e. send and receive data. This transfer of data can be accomplished either asynchronously or synchronously. It is also possible to mix asynchronously and synchronously between receiving and sending data.

To perform asynchronous operations the functions usbs_serial_start_rx() and usbs_serial_start_tx() is used to start the operation. These functions start the necessary actions and then return immediately. At a later time the functions usbs_serial_wait_for_tx() or usbs_serial_wait_for_rx() should be called. These will, if necessary, block and then return the status and any data for the previously started asynchronous call.

To perform synchronous operations the functions usbs_serial_rx() and usbs_serial_tx() are used. These functions will block until the requested action is complete.