Data Structures |
union | sysex_state_t |
union | sysex_timeout_ctr_flags_t |
Functions |
s32 | MIOS32_MIDI_Init (u32 mode) |
s32 | MIOS32_MIDI_CheckAvailable (mios32_midi_port_t port) |
s32 | MIOS32_MIDI_RS_OptimisationSet (mios32_midi_port_t port, u8 enable) |
s32 | MIOS32_MIDI_RS_OptimisationGet (mios32_midi_port_t port) |
s32 | MIOS32_MIDI_RS_Reset (mios32_midi_port_t port) |
s32 | MIOS32_MIDI_SendPackage_NonBlocking (mios32_midi_port_t port, mios32_midi_package_t package) |
s32 | MIOS32_MIDI_SendPackage (mios32_midi_port_t port, mios32_midi_package_t package) |
s32 | MIOS32_MIDI_SendEvent (mios32_midi_port_t port, u8 evnt0, u8 evnt1, u8 evnt2) |
s32 | MIOS32_MIDI_SendNoteOff (mios32_midi_port_t port, mios32_midi_chn_t chn, u8 note, u8 vel) |
s32 | MIOS32_MIDI_SendNoteOn (mios32_midi_port_t port, mios32_midi_chn_t chn, u8 note, u8 vel) |
s32 | MIOS32_MIDI_SendPolyPressure (mios32_midi_port_t port, mios32_midi_chn_t chn, u8 note, u8 val) |
s32 | MIOS32_MIDI_SendCC (mios32_midi_port_t port, mios32_midi_chn_t chn, u8 cc_number, u8 val) |
s32 | MIOS32_MIDI_SendProgramChange (mios32_midi_port_t port, mios32_midi_chn_t chn, u8 prg) |
s32 | MIOS32_MIDI_SendAftertouch (mios32_midi_port_t port, mios32_midi_chn_t chn, u8 val) |
s32 | MIOS32_MIDI_SendPitchBend (mios32_midi_port_t port, mios32_midi_chn_t chn, u16 val) |
s32 | MIOS32_MIDI_SendSpecialEvent (mios32_midi_port_t port, u8 type, u8 evnt0, u8 evnt1, u8 evnt2) |
s32 | MIOS32_MIDI_SendMTC (mios32_midi_port_t port, u8 val) |
s32 | MIOS32_MIDI_SendSongPosition (mios32_midi_port_t port, u16 val) |
s32 | MIOS32_MIDI_SendSongSelect (mios32_midi_port_t port, u8 val) |
s32 | MIOS32_MIDI_SendTuneRequest (mios32_midi_port_t port) |
s32 | MIOS32_MIDI_SendClock (mios32_midi_port_t port) |
s32 | MIOS32_MIDI_SendTick (mios32_midi_port_t port) |
s32 | MIOS32_MIDI_SendStart (mios32_midi_port_t port) |
s32 | MIOS32_MIDI_SendContinue (mios32_midi_port_t port) |
s32 | MIOS32_MIDI_SendStop (mios32_midi_port_t port) |
s32 | MIOS32_MIDI_SendActiveSense (mios32_midi_port_t port) |
s32 | MIOS32_MIDI_SendReset (mios32_midi_port_t port) |
s32 | MIOS32_MIDI_SendSysEx (mios32_midi_port_t port, u8 *stream, u32 count) |
s32 | MIOS32_MIDI_SendDebugStringHeader (mios32_midi_port_t port, char command, char first_byte) |
s32 | MIOS32_MIDI_SendDebugStringBody (mios32_midi_port_t port, char *str, u32 len) |
s32 | MIOS32_MIDI_SendDebugStringFooter (mios32_midi_port_t port) |
s32 | MIOS32_MIDI_SendDebugString (const char *str) |
s32 | MIOS32_MIDI_SendDebugMessage (const char *format,...) |
s32 | MIOS32_MIDI_SendDebugHexDump (const u8 *src, u32 len) |
s32 | MIOS32_MIDI_ReceivePackage (mios32_midi_port_t port, mios32_midi_package_t package, void *_callback_package) |
s32 | MIOS32_MIDI_Receive_Handler (void *_callback_package) |
s32 | MIOS32_MIDI_Periodic_mS (void) |
s32 | MIOS32_MIDI_DirectTxCallback_Init (s32(*callback_tx)(mios32_midi_port_t port, mios32_midi_package_t package)) |
s32 | MIOS32_MIDI_DirectRxCallback_Init (s32(*callback_rx)(mios32_midi_port_t port, u8 midi_byte)) |
s32 | MIOS32_MIDI_SendByteToRxCallback (mios32_midi_port_t port, u8 midi_byte) |
s32 | MIOS32_MIDI_SendPackageToRxCallback (mios32_midi_port_t port, mios32_midi_package_t midi_package) |
s32 | MIOS32_MIDI_DefaultPortSet (mios32_midi_port_t port) |
mios32_midi_port_t | MIOS32_MIDI_DefaultPortGet (void) |
s32 | MIOS32_MIDI_DebugPortSet (mios32_midi_port_t port) |
mios32_midi_port_t | MIOS32_MIDI_DebugPortGet (void) |
s32 | MIOS32_MIDI_DeviceIDSet (u8 device_id) |
u8 | MIOS32_MIDI_DeviceIDGet (void) |
s32 | MIOS32_MIDI_SysExCallback_Init (s32(*callback_sysex)(mios32_midi_port_t port, u8 midi_in)) |
s32 | MIOS32_MIDI_DebugCommandCallback_Init (s32(*callback_debug_command)(mios32_midi_port_t port, char c)) |
s32 | MIOS32_MIDI_FilebrowserCommandCallback_Init (s32(*filebrowser_debug_command)(mios32_midi_port_t port, char c)) |
s32 | MIOS32_MIDI_TimeOutCallback_Init (s32(*callback_timeout)(mios32_midi_port_t port)) |
Variables |
const u8 | mios32_midi_pcktype_num_bytes [16] |
const u8 | mios32_midi_expected_bytes_common [8] |
| Number if expected bytes for a common MIDI event - 1.
|
const u8 | mios32_midi_expected_bytes_system [16] |
| Number if expected bytes for a system MIDI event - 1.
|
const u8 | mios32_midi_sysex_header [5] = { 0xf0, 0x00, 0x00, 0x7e, 0x32 } |
| should only be used by MIOS32 internally and by the Bootloader!
|
unsigned sysex_state_t::MY_SYSEX:1 |
unsigned sysex_state_t::CMD:1 |
struct { |
unsigned CTR:3 |
unsigned sysex_state_t::MY_SYSEX:1 |
unsigned sysex_state_t::CMD:1 |
} | sysex_state_t::general |
unsigned sysex_state_t::MY_SYSEX:1 |
unsigned sysex_state_t::CMD:1 |
unsigned sysex_state_t::PING_BYTE_RECEIVED |
struct { |
unsigned CTR:3 |
unsigned sysex_state_t::MY_SYSEX:1 |
unsigned sysex_state_t::CMD:1 |
unsigned sysex_state_t::PING_BYTE_RECEIVED |
} | sysex_state_t::ping |
unsigned long long sysex_timeout_ctr_flags_t::iic_receives:16 |
unsigned long long sysex_timeout_ctr_flags_t::spi_receives:16 |
struct { |
unsigned long long usb_receives:16 |
unsigned long long sysex_timeout_ctr_flags_t::iic_receives:16 |
unsigned long long sysex_timeout_ctr_flags_t::spi_receives:16 |
}; | |
Installs the Rx callback function which is executed immediately on each incoming/outgoing MIDI byte, partly from interrupt handlers.
This function should be executed so fast as possible. It can be used to trigger MIDI Rx LEDs or to trigger on MIDI clock events. In order to avoid MIDI buffer overruns, the max. recommented execution time is 100 uS!
It is possible to filter incoming MIDI bytes with the return value of the callback function.
- Parameters:
-
[in] | *callback_rx | pointer to callback function:
The byte will be forwarded into the MIDI Rx queue if the function returns 0.
It will be filtered out if the callback returns != 0 (e.g. 1 for "filter", or -1 for "error"). |
- Returns:
- < 0 on errors
- Note:
- Please use the filtering capabilities with special care - if a port is filtered which is also used for code upload, you won't be able to exchange the erroneous code w/o starting the bootloader in hold mode after power-on.
s32 MIOS32_MIDI_SendDebugHexDump |
( |
const u8 * |
src, |
|
|
u32 |
len | |
|
) |
| | |
Sends an hex dump (formatted representation of memory content) to the MIOS Terminal in MIOS Studio.
The MIDI port used for debugging (MIDI_DEBUG) can be declared in mios32_config.h:
#define MIOS32_MIDI_DEBUG_PORT USB0
(USB0 is the default value)
Optionally, the port can be changed during runtime with MIOS32_MIDI_DebugPortSet
- Parameters:
-
[in] | *src | pointer to memory location which should be dumped |
[in] | len | number of bytes which should be sent |
- Returns:
- < 0 on errors
s32 MIOS32_MIDI_SendDebugMessage |
( |
const char * |
format, |
|
|
|
... | |
|
) |
| | |
Sends a formatted Debug Message to the MIOS Terminal in MIOS Studio.
Formatting parameters are like known from printf, e.g.
The MIDI port used for debugging (MIDI_DEBUG) can be declared in mios32_config.h:
#define MIOS32_MIDI_DEBUG_PORT USB0
(USB0 is the default value)
Optionally, the port can be changed during runtime with MIOS32_MIDI_DebugPortSet
Please note that the resulting string shouldn't be longer than 128 characters!
If the *format string is already longer than 100 characters an error message will be sent to notify about the programming error.
The limit is set to save allocated stack memory! Just reduce the formated string to print out the intended message.
- Parameters:
-
[in] | *format | zero-terminated format string - 128 characters supported maximum! |
| ... | additional arguments |
- Returns:
- < 0 on errors
Sends a MIDI Event This function is provided for a more comfortable use model o MIOS32_MIDI_SendNoteOff(port, chn, note, vel) o MIOS32_MIDI_SendNoteOn(port, chn, note, vel) o MIOS32_MIDI_SendPolyAftertouch(port, chn, note, val) o MIOS32_MIDI_SendCC(port, chn, cc, val) o MIOS32_MIDI_SendProgramChange(port, chn, prg) o MIOS32_MIDI_ChannelAftertouch(port, chn, val) o MIOS32_MIDI_PitchBend(port, chn, val)
- Parameters:
-
[in] | port | MIDI port (DEFAULT, USB0..USB7, UART0..UART3, IIC0..IIC7, SPIM0..SPIM7) |
[in] | evnt0 | first MIDI byte |
[in] | evnt1 | second MIDI byte |
[in] | evnt2 | third MIDI byte |
- Returns:
- -1 if port not available
-
0 on success
Sends a package over given port
This is a low level function. In difference to other MIOS32_MIDI_Send* functions, It allows to send packages in non-blocking mode (caller has to retry if -2 is returned)
Before the package is forwarded, an optional Tx Callback function will be called which allows to filter/monitor/route the package, or extend the MIDI transmitter by custom MIDI Output ports (e.g. for internal busses, OSC, AOUT, etc.)
- Parameters:
-
[in] | port | MIDI port (DEFAULT, USB0..USB7, UART0..UART3, IIC0..IIC7, SPIM0..SPIM7) |
[in] | package | MIDI package |
- Returns:
- -1 if port not available
-
-2 buffer is full caller should retry until buffer is free again
-
-3 Tx Callback reported an error
-
1 if package has been filtered by Tx callback
-
0 on success
Installs an optional SysEx callback which is called by MIOS32_MIDI_Receive_Handler() to simplify the parsing of SysEx streams.
Without this callback (or with MIOS32_MIDI_SysExCallback_Init(NULL)), SysEx messages are only forwarded to APP_MIDI_NotifyPackage() in chunks of 1, 2 or 3 bytes, tagged with midi_package.type == 0x4..0x7 or 0xf
In this case, the application has to take care for different transmission approaches which are under control of the package sender. E.g., while Windows uses Package Type 4..7 to transmit a SysEx stream, PortMIDI under MacOS sends a mix of 0xf (single byte) and 0x4 (continued 3-byte) packages instead.
By using the SysEx callback, the type of package doesn't play a role anymore, instead the application can parse a serial stream.
MIOS32 ensures, that realtime events (0xf8..0xff) are still forwarded to APP_MIDI_NotifyPackage(), regardless if they are transmitted in a package type 0x5 or 0xf, so that the SysEx parser doesn't need to filter out such events, which could otherwise appear inside a SysEx stream.
- Parameters:
-
[in] | *callback_sysex | pointer to callback function:
If the function returns 0, SysEx bytes will be forwarded to APP_MIDI_NotifyPackage() as well. With return value != 0, APP_MIDI_NotifyPackage() won't get the already processed package. |
- Returns:
- < 0 on errors
Installs the Timeout callback function which is executed on incomplete MIDI packages received via UART, or on incomplete SysEx streams.
A timeout is detected after 1 second.
On a timeout, it is recommented to reset MIDI parsing relevant variables, e.g. the state of a SysEx parser.
Example:
s32 NOTIFY_MIDI_TimeOut(mios32_midi_port_t port)
{
if( sysex_state.general.MY_SYSEX && port == last_sysex_port )
MySYSEX_CmdFinished();
return 0;
}
The callback function has been installed in an Init() function with:
- Parameters:
-
[in] | callback_timeout | the callback function (NULL disables the callback) |
- Returns:
- < 0 on errors