# MIOS32_COM

## Functions
s32 | MIOS32_COM_Init (u32 mode)
s32 | MIOS32_COM_CheckAvailable (mios32_com_port_t port)
s32 | MIOS32_COM_SendBuffer_NonBlocking (mios32_com_port_t port, u8 *buffer, u16 len)
s32 | MIOS32_COM_SendBuffer (mios32_com_port_t port, u8 *buffer, u16 len)
s32 | MIOS32_COM_SendChar_NonBlocking (mios32_com_port_t port, char c)
s32 | MIOS32_COM_SendChar (mios32_com_port_t port, char c)
s32 | MIOS32_COM_SendString_NonBlocking (mios32_com_port_t port, char *str)
s32 | MIOS32_COM_SendString (mios32_com_port_t port, char *str)
s32 | MIOS32_COM_SendFormattedString_NonBlocking (mios32_com_port_t port, char *format,...)
s32 | MIOS32_COM_SendFormattedString (mios32_com_port_t port, char *format,...)
s32 | MIOS32_COM_Receive_Handler (void)
s32 | MIOS32_COM_ReceiveCallback_Init (void *callback_receive)
s32 | MIOS32_COM_DefaultPortSet (mios32_com_port_t port)
mios32_com_port_t | MIOS32_COM_DefaultPortGet (void)
s32 | MIOS32_COM_DebugPortSet (mios32_com_port_t port)
mios32_com_port_t | MIOS32_COM_DebugPortGet (void)

## Detailed Description

COM layer functions for MIOS32

## Function Documentation

s32 MIOS32_COM_CheckAvailable | ( | mios32_com_port_t | port | ) |

This function checks the availability of a COM port

Parameters:

  `[in]` | port | COM port (DEFAULT, USB0..USB7, UART0..UART1, IIC0..IIC7)

Returns:
  1: port available
  0: port not available

Here is the call graph for this function:

mios32_com_port_t MIOS32_COM_DebugPortGet | ( | void |  | ) |

This function returns the COM_DEBUG port

Returns:
  the debug port

s32 MIOS32_COM_DebugPortSet | ( | mios32_com_port_t | port | ) |

This function allows to change the COM_DEBUG port.
The preset which will be used after application reset can be set in mios32_config.h via "#define MIOS32_COM_DEBUG_PORT <port>".
It's set to USB0 as long as not overruled in mios32_config.h

Parameters:

  `[in]` | port | COM port (USB0..USB7, UART0..UART1, IIC0..IIC7)

Returns:
  < 0 on errors

mios32_com_port_t MIOS32_COM_DefaultPortGet | ( | void |  | ) |

This function returns the DEFAULT port

Returns:
  the default port

s32 MIOS32_COM_DefaultPortSet | ( | mios32_com_port_t | port | ) |

This function allows to change the DEFAULT port.
The preset which will be used after application reset can be set in mios32_config.h via "#define MIOS32_COM_DEFAULT_PORT <port>".
It's set to USB0 as long as not overruled in mios32_config.h

Parameters:

  `[in]` | port | COM port (USB0..USB7, UART0..UART1, IIC0..IIC7)

Returns:
  < 0 on errors

s32 MIOS32_COM_Init | ( | u32 | mode | ) |

Initializes COM layer

Parameters:

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

Returns:
  < 0 if initialisation failed

Here is the call graph for this function:

s32 MIOS32_COM_Receive_Handler | ( | void |  | ) |

Checks for incoming COM messages, calls the callback function which has been installed via MIOS32_COM_ReceiveCallback_Init()

Not for use in an application - this function is called by by a task in the programming model!

Returns:
  < 0 on errors

Here is the call graph for this function:

s32 MIOS32_COM_ReceiveCallback_Init | ( | void * | callback_receive | ) |

Installs the callback function which is executed on incoming characters from a COM interface.

Example:

     s32 CONSOLE_Parse(mios32_com_port_t port, char c)
     {
       // see $MIOS32_PATH/apps/examples/com_console/

       return 0; // no error
     }

The callback function has been installed in an Init() function with:

       MIOS32_COM_ReceiveCallback_Init(CONSOLE_Parse);

Parameters:

  `[in]` | callback_debug_command | the callback function (NULL disables the callback)

Returns:
  < 0 on errors

s32 MIOS32_COM_SendBuffer | ( | mios32_com_port_t | port,
|  | u8 * | buffer,
|  | u16 | len |
| ) |  |  |

Sends a package over given port (blocking function)

Parameters:

  `[in]` | port | COM port (DEFAULT, USB0..USB7, UART0..UART1, IIC0..IIC7)
  `[in]` | buffer | character buffer
  `[in]` | len | buffer length

Returns:
  -1 if port not available
  0 on success

Here is the call graph for this function:

s32 MIOS32_COM_SendBuffer_NonBlocking | ( | mios32_com_port_t | port,
|  | u8 * | buffer,
|  | u16 | len |
| ) |  |  |

Sends a package over given port

Parameters:

  `[in]` | port | COM port (DEFAULT, USB0..USB7, UART0..UART1, IIC0..IIC7)
  `[in]` | buffer | character buffer
  `[in]` | len | buffer length

Returns:
  -1 if port not available
  -2 if non-blocking mode activated: buffer is full caller should retry until buffer is free again
  0 on success

Here is the call graph for this function:

s32 MIOS32_COM_SendChar | ( | mios32_com_port_t | port,
|  | char | c |
| ) |  |  |

Sends a single character over given port (blocking function)

Parameters:

  `[in]` | port | COM port (DEFAULT, USB0..USB7, UART0..UART1, IIC0..IIC7)
  `[in]` | c | character

Returns:
  -1 if port not available
  0 on success

Here is the call graph for this function:

s32 MIOS32_COM_SendChar_NonBlocking | ( | mios32_com_port_t | port,
|  | char | c |
| ) |  |  |

Sends a single character over given port

Parameters:

  `[in]` | port | COM port (DEFAULT, USB0..USB7, UART0..UART1, IIC0..IIC7)
  `[in]` | c | character

Returns:
  -1 if port not available
  -2 buffer is full caller should retry until buffer is free again
  0 on success

Here is the call graph for this function:

s32 MIOS32_COM_SendFormattedString | ( | mios32_com_port_t | port,
|  | char * | format,
|  |  | ... |
| ) |  |  |

Sends a formatted string (-> printf) over given port (blocking function)

Parameters:

  `[in]` | port | COM port (DEFAULT, USB0..USB7, UART0..UART1, IIC0..IIC7)
  `[in]` | *format | zero-terminated format string - 128 characters supported maximum!
  `[in]` | ... | optional arguments,

Returns:
  -1 if port not available
  0 on success

Here is the call graph for this function:

s32 MIOS32_COM_SendFormattedString_NonBlocking | ( | mios32_com_port_t | port,
|  | char * | format,
|  |  | ... |
| ) |  |  |

Sends a formatted string (-> printf) over given port

Parameters:

  `[in]` | port | COM port (DEFAULT, USB0..USB7, UART0..UART1, IIC0..IIC7)
  `[in]` | *format | zero-terminated format string - 128 characters supported maximum!
  `[in]` | ... | optional arguments, 128 characters supported maximum!

Returns:
  -2 if non-blocking mode activated: buffer is full caller should retry until buffer is free again
  0 on success

Here is the call graph for this function:

s32 MIOS32_COM_SendString | ( | mios32_com_port_t | port,
|  | char * | str |
| ) |  |  |

Sends a string over given port (blocking function)

Parameters:

  `[in]` | port | COM port (DEFAULT, USB0..USB7, UART0..UART1, IIC0..IIC7)
  `[in]` | str | zero-terminated string

Returns:
  -1 if port not available
  0 on success

Here is the call graph for this function:

s32 MIOS32_COM_SendString_NonBlocking | ( | mios32_com_port_t | port,
|  | char * | str |
| ) |  |  |

Sends a string over given port

Parameters:

  `[in]` | port | COM port (DEFAULT, USB0..USB7, UART0..UART1, IIC0..IIC7)
  `[in]` | str | zero-terminated string

Returns:
  -1 if port not available
  -2 buffer is full caller should retry until buffer is free again
  0 on success

Here is the call graph for this function: