# MIOS32_UART_MIDI

## Data Structures
struct | midi_rec_t
## Functions
s32 | MIOS32_UART_MIDI_Init (u32 mode)
s32 | MIOS32_UART_MIDI_CheckAvailable (u8 uart_port)
s32 | MIOS32_UART_MIDI_RS_OptimisationSet (u8 uart_port, u8 enable)
s32 | MIOS32_UART_MIDI_RS_OptimisationGet (u8 uart_port)
s32 | MIOS32_UART_MIDI_RS_Reset (u8 uart_port)
s32 | MIOS32_UART_MIDI_Periodic_mS (void)
s32 | MIOS32_UART_MIDI_PackageSend_NonBlocking (u8 uart_port, mios32_midi_package_t package)
s32 | MIOS32_UART_MIDI_PackageSend (u8 uart_port, mios32_midi_package_t package)
s32 | MIOS32_UART_MIDI_PackageReceive (u8 uart_port, mios32_midi_package_t *package)
## Variables
u8 | midi_rec_t::running_status
u8 | midi_rec_t::expected_bytes
u8 | midi_rec_t::wait_bytes
u8 | midi_rec_t::sysex_ctr
u16 | midi_rec_t::timeout_ctr

## Detailed Description

UART MIDI layer for MIOS32

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

## Function Documentation

s32 MIOS32_UART_MIDI_CheckAvailable | ( | u8 | uart_port | ) |

This function can be used to determine, if a UART interface is available

Parameters:

  `[in]` | uart_port | UART number (0..2)

Returns:
  1: interface available
  0: interface not available

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

s32 MIOS32_UART_MIDI_Init | ( | u32 | mode | ) |

Initializes UART MIDI 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_MIDI layer functions

Here is the call graph for this function:

s32 MIOS32_UART_MIDI_PackageReceive | ( | u8 | uart_port,
|  | mios32_midi_package_t * | package |
| ) |  |  |

This function checks for a new package

Parameters:

  `[in]` | uart_port | UART_MIDI module number (0..2)
  `[out]` | package | pointer to MIDI package (received package will be put into the given variable

Returns:
  0: no error
  -1: no package in buffer
  -10: incoming MIDI package timed out (incomplete package received)

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

Here is the call graph for this function:

s32 MIOS32_UART_MIDI_PackageSend | ( | u8 | uart_port,
|  | mios32_midi_package_t | package |
| ) |  |  |

This function sends a new MIDI package to the selected UART_MIDI port (blocking function)

Parameters:

  `[in]` | uart_port | UART_MIDI module number (0..2)
  `[in]` | package | MIDI package

Returns:
  0: no error
  -1: UART_MIDI device not available

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

Here is the call graph for this function:

s32 MIOS32_UART_MIDI_PackageSend_NonBlocking | ( | u8 | uart_port,
|  | mios32_midi_package_t | package |
| ) |  |  |

This function sends a new MIDI package to the selected UART_MIDI port

Parameters:

  `[in]` | uart_port | UART_MIDI module number (0..2)
  `[in]` | package | MIDI package

Returns:
  0: no error
  -1: UART_MIDI device not available
  -2: UART_MIDI buffer is full caller should retry until buffer is free again

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

Here is the call graph for this function:

s32 MIOS32_UART_MIDI_Periodic_mS | ( | void |  | ) |

This function should be called periodically each mS to handle timeout and expire counters.

Not for use in an application - this function is called from MIOS32_MIDI_Periodic_mS(), which is called by a task in the programming model!

Returns:
  < 0 on errors

Here is the call graph for this function:

s32 MIOS32_UART_MIDI_RS_OptimisationGet | ( | u8 | uart_port | ) |

This function returns the running status optimisation enable/disable flag for the given MIDI OUT port.

Parameters:

  `[in]` | uart_port | UART number (0..2)

Returns:
  -1 if port not available
  0 if optimisation disabled
  1 if optimisation enabled

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

s32 MIOS32_UART_MIDI_RS_OptimisationSet | ( | u8 | uart_port,
|  | u8 | enable |
| ) |  |  |

This function enables/disables running status optimisation for a given MIDI OUT port to improve bandwidth if MIDI events with the same status byte are sent back-to-back.
Note that the optimisation is enabled by default.

Parameters:

  `[in]` | uart_port | UART number (0..2)
  `[in]` | enable | 0=optimisation disabled, 1=optimisation enabled

Returns:
  -1 if port not available
  0 on success

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

s32 MIOS32_UART_MIDI_RS_Reset | ( | u8 | uart_port | ) |

This function resets the current running status, so that it will be sent again with the next MIDI Out package.

Parameters:

  `[in]` | uart_port | UART number (0..2)

Returns:
  -1 if port not available
  < 0 on errors

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

Here is the call graph for this function:

## Variable Documentation

u8 midi_rec_t::expected_bytes`[inherited]`

u8 midi_rec_t::running_status`[inherited]`

u8 midi_rec_t::sysex_ctr`[inherited]`

u16 midi_rec_t::timeout_ctr`[inherited]`

u8 midi_rec_t::wait_bytes`[inherited]`