# MIOS32_USB_COM

## Data Structures
struct | LINE_CODING
## Defines
#define | SEND_ENCAPSULATED_COMMAND 0x00
#define | GET_ENCAPSULATED_RESPONSE 0x01
#define | SET_COMM_FEATURE 0x02
#define | GET_COMM_FEATURE 0x03
#define | CLEAR_COMM_FEATURE 0x04
#define | SET_LINE_CODING 0x20
#define | GET_LINE_CODING 0x21
#define | SET_CONTROL_LINE_STATE 0x22
#define | SEND_BREAK 0x23
#define | SEND_ENCAPSULATED_COMMAND 0x00
#define | GET_ENCAPSULATED_RESPONSE 0x01
#define | SET_COMM_FEATURE 0x02
#define | GET_COMM_FEATURE 0x03
#define | CLEAR_COMM_FEATURE 0x04
#define | SET_LINE_CODING 0x20
#define | GET_LINE_CODING 0x21
#define | SET_CONTROL_LINE_STATE 0x22
#define | SEND_BREAK 0x23
## Functions
void | MIOS32_USB_COM_TxBufferHandler (void)
void | MIOS32_USB_COM_RxBufferHandler (void)
s32 | MIOS32_USB_COM_Init (u32 mode)
s32 | MIOS32_USB_COM_ChangeConnectionState (u8 connected)
s32 | MIOS32_USB_COM_CheckAvailable (void)
s32 | MIOS32_USB_COM_RxBufferFree (u8 usb_com)
s32 | MIOS32_USB_COM_RxBufferUsed (u8 usb_com)
s32 | MIOS32_USB_COM_RxBufferGet (u8 usb_com)
s32 | MIOS32_USB_COM_RxBufferPeek (u8 usb_com)
s32 | MIOS32_USB_COM_TxBufferFree (u8 usb_com)
s32 | MIOS32_USB_COM_TxBufferUsed (u8 usb_com)
s32 | MIOS32_USB_COM_TxBufferPutMore_NonBlocking (u8 usb_com, u8 *buffer, u16 len)
s32 | MIOS32_USB_COM_TxBufferPutMore (u8 usb_com, u8 *buffer, u16 len)
s32 | MIOS32_USB_COM_TxBufferPut_NonBlocking (u8 usb_com, u8 b)
s32 | MIOS32_USB_COM_TxBufferPut (u8 usb_com, u8 b)
void | MIOS32_USB_COM_EP4_IN_Callback (void)
void | MIOS32_USB_COM_EP3_OUT_Callback (void)
void | MIOS32_USB_COM_CB_StatusIn (void)
u8 * | Virtual_Com_Port_SetLineCoding (u16 Length)
s32 | MIOS32_USB_COM_CB_Data_Setup (u8 RequestNo)
s32 | MIOS32_USB_COM_CB_NoData_Setup (u8 RequestNo)
void | MIOS32_USB_COM_EP4_IN_Callback (u8 bEP, u8 bEPStatus)
void | MIOS32_USB_COM_EP3_OUT_Callback (u8 bEP, u8 bEPStatus)
## Variables
u8 | Request = 0
LINE_CODING | linecoding
u8 | Request = 0
LINE_CODING | linecoding

## Detailed Description

USB COM layer for MIOS32

USB COM layer for MIOS32

Based on driver included in STM32 USB library Some code copied and modified from Virtual_COM_Port demo

Applications shouldn't call these functions directly, instead please use MIOS32_COM layer functions

Note:
  this module can be optionally *ENABLED* in a local mios32_config.h file (included from mios32.h) by adding 'define MIOS32_USE_USB_COM' it's disabled by default, since Windows doesn't allow to use USB MIDI and CDC in parallel!

USB COM layer for MIOS32

Not supported for STM32F4 (yet)

## Define Documentation

#define CLEAR_COMM_FEATURE 0x04

#define GET_COMM_FEATURE 0x03

#define GET_ENCAPSULATED_RESPONSE 0x01

#define GET_LINE_CODING 0x21

#define SEND_BREAK 0x23

#define SEND_ENCAPSULATED_COMMAND 0x00

#define SET_COMM_FEATURE 0x02

#define SET_CONTROL_LINE_STATE 0x22

#define SET_LINE_CODING 0x20

## Function Documentation

s32 MIOS32_USB_COM_CB_Data_Setup | ( | u8 | RequestNo | ) |

Here is the call graph for this function:

s32 MIOS32_USB_COM_CB_NoData_Setup | ( | u8 | RequestNo | ) |

void MIOS32_USB_COM_CB_StatusIn | ( | void |  | ) |

MIOS32_USB callback functions (forwarded from STM32 USB driver)

Note:
  Applications shouldn't call this function directly, instead please use MIOS32_COM layer functions

s32 MIOS32_USB_COM_ChangeConnectionState | ( | u8 | connected | ) |

This function is called by the USB driver on cable connection/disconnection

Parameters:

  `[in]` | connected | connection status (1 if connected)

Returns:
  < 0 on errors

Note:
  Applications shouldn't call this function directly, instead please use MIOS32_COM layer functions

s32 MIOS32_USB_COM_CheckAvailable | ( | void |  | ) |

This function returns the connection status of the USB COM interface

Returns:
  1: interface available
  0: interface not available

Note:
  Applications shouldn't call this function directly, instead please use MIOS32_COM layer functions

void MIOS32_USB_COM_EP3_OUT_Callback | ( | u8 | bEP,
|  | u8 | bEPStatus |
| ) |  |  |

Called by STM32 USB driver to check for OUT streams

Note:
  Applications shouldn't call this function directly, instead please use MIOS32_COM layer functions
  also: bEP, bEPStatus only relevant for LPC17xx port

void MIOS32_USB_COM_EP3_OUT_Callback | ( | void |  | ) |

Called by STM32 USB driver to check for OUT streams

Note:
  Applications shouldn't call this function directly, instead please use MIOS32_COM layer functions

void MIOS32_USB_COM_EP4_IN_Callback | ( | u8 | bEP,
|  | u8 | bEPStatus |
| ) |  |  |

Called by STM32 USB driver to check for IN streams

Note:
  Applications shouldn't call this function directly, instead please use MIOS32_COM layer functions
  also: bEP, bEPStatus only relevant for LPC17xx port

void MIOS32_USB_COM_EP4_IN_Callback | ( | void |  | ) |

Called by STM32 USB driver to check for IN streams

Note:
  Applications shouldn't call this function directly, instead please use MIOS32_COM layer functions

s32 MIOS32_USB_COM_Init | ( | u32 | mode | ) |

Initializes USB COM layer

Parameters:

  `[in]` | mode | currently only mode 0 supported

Returns:
  < 0 if initialisation failed

Note:
  Applications shouldn't call this function directly, instead please use MIOS32_COM layer functions

s32 MIOS32_USB_COM_RxBufferFree | ( | u8 | usb_com | ) |

Returns number of free bytes in receive buffer

Parameters:

  `[in]` | usb_com | USB_COM number (not supported yet, should always be 0)

Returns:
  number of free bytes
  0 if usb_com not available

Note:
  Applications shouldn't call this function directly, instead please use MIOS32_COM layer functions

s32 MIOS32_USB_COM_RxBufferGet | ( | u8 | usb_com | ) |

Gets a byte from the receive buffer

Parameters:

  `[in]` | usb_com | USB_COM number (not supported yet, should always be 0)

Returns:
  -1 if USB_COM not available
  -2 if no new byte available
  >= 0: received byte

Note:
  Applications shouldn't call this function directly, instead please use MIOS32_COM layer functions

void MIOS32_USB_COM_RxBufferHandler | ( | void |  | ) |

s32 MIOS32_USB_COM_RxBufferPeek | ( | u8 | usb_com | ) |

Returns the next byte of the receive buffer without taking it

Parameters:

  `[in]` | usb_com | USB_COM number (not supported yet, should always be 0)

Returns:
  -1 if USB_COM not available
  -2 if no new byte available
  >= 0: received byte

Note:
  Applications shouldn't call this function directly, instead please use MIOS32_COM layer functions

s32 MIOS32_USB_COM_RxBufferUsed | ( | u8 | usb_com | ) |

Returns number of used bytes in receive buffer

Parameters:

  `[in]` | usb_com | USB_COM number (not supported yet, should always be 0)

Returns:
  number of used bytes
  0 if usb_com not available

Note:
  Applications shouldn't call this function directly, instead please use MIOS32_COM layer functions

s32 MIOS32_USB_COM_TxBufferFree | ( | u8 | usb_com | ) |

returns number of free bytes in transmit buffer

Parameters:

  `[in]` | usb_com | USB_COM number (not supported yet, should always be 0)

Returns:
  number of free bytes
  0 if usb_com not available

Note:
  Applications shouldn't call this function directly, instead please use MIOS32_COM layer functions

void MIOS32_USB_COM_TxBufferHandler | ( | void |  | ) |

s32 MIOS32_USB_COM_TxBufferPut | ( | u8 | usb_com,
|  | u8 | b |
| ) |  |  |

puts a byte onto the transmit buffer
(blocking function)

Parameters:

  `[in]` | usb_com | USB_COM number (not supported yet, should always be 0)
  `[in]` | b | byte which should be put into Tx buffer

Returns:
  0 if no error
  -1 if USB_COM not available
  -3 if USB_COM not supported by MIOS32_USB_COM_TxBufferPut Routine

Note:
  Applications shouldn't call this function directly, instead please use MIOS32_COM layer functions

Here is the call graph for this function:

s32 MIOS32_USB_COM_TxBufferPut_NonBlocking | ( | u8 | usb_com,
|  | u8 | b |
| ) |  |  |

puts a byte onto the transmit buffer

Parameters:

  `[in]` | usb_com | USB_COM number (not supported yet, should always be 0)
  `[in]` | b | byte which should be put into Tx buffer

Returns:
  0 if no error
  -1 if USB_COM not available
  -2 if buffer full (retry)
  -3 if USB_COM not supported by MIOS32_USB_COM_TxBufferPut Routine

Note:
  Applications shouldn't call this function directly, instead please use MIOS32_COM layer functions

Here is the call graph for this function:

s32 MIOS32_USB_COM_TxBufferPutMore | ( | u8 | usb_com,
|  | u8 * | buffer,
|  | u16 | len |
| ) |  |  |

puts more than one byte onto the transmit buffer (used for atomic sends)
(blocking function)

Parameters:

  `[in]` | usb_com | USB_COM number (not supported yet, should always be 0)
  `[in]` | *buffer | pointer to buffer which should be transmitted
  `[in]` | len | number of bytes which should be transmitted

Returns:
  0 if no error
  -1 if USB_COM not available
  -3 if USB_COM not supported by MIOS32_USB_COM_TxBufferPut Routine
  -4 if too many bytes should be sent

Note:
  Applications shouldn't call this function directly, instead please use MIOS32_COM layer functions

Here is the call graph for this function:

s32 MIOS32_USB_COM_TxBufferPutMore_NonBlocking | ( | u8 | usb_com,
|  | u8 * | buffer,
|  | u16 | len |
| ) |  |  |

puts more than one byte onto the transmit buffer (used for atomic sends)

Parameters:

  `[in]` | usb_com | USB_COM number (not supported yet, should always be 0)
  `[in]` | *buffer | pointer to buffer which should be transmitted
  `[in]` | len | number of bytes which should be transmitted

Returns:
  0 if no error
  -1 if USB_COM not available
  -2 if buffer full or cannot get all requested bytes (retry)
  -3 if USB_COM not supported by MIOS32_USB_COM_TxBufferPut Routine
  -4 if too many bytes should be sent

Note:
  Applications shouldn't call this function directly, instead please use MIOS32_COM layer functions

s32 MIOS32_USB_COM_TxBufferUsed | ( | u8 | usb_com | ) |

Returns number of used bytes in transmit buffer

Parameters:

  `[in]` | usb_com | USB_COM number (not supported yet, should always be 0)

Returns:
  number of used bytes
  0 if usb_com not available

Note:
  Applications shouldn't call this function directly, instead please use MIOS32_COM layer functions

u8 * Virtual_Com_Port_SetLineCoding | ( | u16 | Length | ) |

## Variable Documentation

LINE_CODING linecoding

Initial value:

     {
      115200,
      0x00,
      0x00,
      0x08
    }

LINE_CODING linecoding

Initial value:

     {
      115200,
      0x00,
      0x00,
      0x08
    }

u8 Request = 0

u8 Request = 0