TM STM32F4xx Libraries  v1.0.0
Libraries for STM32F4xx devices from Tilen Majerle
TM_USB_VCP_Functions

Library Functions. More...

Functions

TM_USB_VCP_Result TM_USB_VCP_Init (void)
 Initializes USB VCP. More...
 
TM_USB_VCP_Result TM_USB_VCP_GetSettings (TM_USB_VCP_Settings_t *Settings)
 Reads settings from user. More...
 
TM_USB_VCP_Result TM_USB_VCP_Getc (uint8_t *c)
 Gets received character from internal buffer. More...
 
TM_USB_VCP_Result TM_USB_VCP_Putc (volatile char c)
 Puts character to USB VCP. More...
 
uint16_t TM_USB_VCP_Gets (char *buffer, uint16_t bufsize)
 Gets string from VCP port. More...
 
TM_USB_VCP_Result TM_USB_VCP_Puts (char *str)
 Puts string to USB VCP. More...
 
TM_USB_VCP_Result TM_USB_VCP_Send (uint8_t *DataArray, uint32_t Length)
 Sends array of data to USB VCP. More...
 
TM_USB_VCP_Result TM_USB_VCP_GetStatus (void)
 Gets VCP status. More...
 
uint8_t TM_USB_VCP_BufferEmpty (void)
 Checks if receive buffer is empty. More...
 
uint8_t TM_USB_VCP_BufferFull (void)
 Checks if receive buffer is fukk. More...
 
uint8_t TM_USB_VCP_FindCharacter (volatile char c)
 Checks if character is in buffer. More...
 
TM_USB_VCP_Result TM_INT_USB_VCP_AddReceived (uint8_t c)
 

Detailed Description

Library Functions.

Function Documentation

uint8_t TM_USB_VCP_BufferEmpty ( void  )

Checks if receive buffer is empty.

Parameters
None
Return values
Bufferstatus:
  • 0: Buffer is not empty
  • > 0: Buffer is empty
uint8_t TM_USB_VCP_BufferFull ( void  )

Checks if receive buffer is fukk.

Parameters
None
Return values
Bufferstatus:
  • 0: Buffer is not full
  • > 0: Buffer is full
uint8_t TM_USB_VCP_FindCharacter ( volatile char  c)

Checks if character is in buffer.

Parameters
cCharacter to be checked if available in buffer
Return values
Characterstatus:
  • 0: Character is not in buffer
  • > 0: Character is in buffer
TM_USB_VCP_Result TM_USB_VCP_Getc ( uint8_t *  c)

Gets received character from internal buffer.

Parameters
*cpointer to store new character to
Return values
Characterstatus:
  • TM_USB_VCP_DATA_OK: Character is valid inside *c_str
  • TM_USB_VCP_DATA_EMPTY: No character in *c
uint16_t TM_USB_VCP_Gets ( char *  buffer,
uint16_t  bufsize 
)

Gets string from VCP port.

Note
To use this method, you have to send
(0x0D) at the end of your string, otherwise data can be lost and you will fall in infinite loop.
Parameters
*bufferPointer to buffer variable where to save string
bufsizeMaximum buffer size
Return values
Numberof characters in buffer:
  • 0: String not valid
  • > 0: String valid, number of characters inside string
TM_USB_VCP_Result TM_USB_VCP_GetSettings ( TM_USB_VCP_Settings_t Settings)

Reads settings from user.

Note
These settings are set in terminal on PC
Parameters
*SettingsPointer to TM_USB_VCP_Settings_t structure where to save data
Return values
TM_USB_VCP_OK
TM_USB_VCP_Result TM_USB_VCP_GetStatus ( void  )

Gets VCP status.

Parameters
None
Return values
Devicestatus:
  • TM_USB_VCP_CONNECTED: Connected to computer
  • other: Not connected and not ready to communicate
TM_USB_VCP_Result TM_USB_VCP_Init ( void  )

Initializes USB VCP.

Parameters
None
Return values
TM_USB_VCP_OK
TM_USB_VCP_Result TM_USB_VCP_Putc ( volatile char  c)

Puts character to USB VCP.

Parameters
ccharacter to send over USB
Return values
TM_USB_VCP_OK
TM_USB_VCP_Result TM_USB_VCP_Puts ( char *  str)

Puts string to USB VCP.

Parameters
*strPointer to string variable
Return values
TM_USB_VCP_OK
TM_USB_VCP_Result TM_USB_VCP_Send ( uint8_t *  DataArray,
uint32_t  Length 
)

Sends array of data to USB VCP.

Parameters
*DataArrayPointer to 8-bit data array to be sent over USB
LengthNumber of elements to sent in units of bytes
Return values
Sendingstatus