MIDIReadAsync

Syntax

#include <cafe/midi.h>

#define MIDI_JSTAT_MASK           0x3a
#define MIDI_JSTAT_FLAGS_SHIFT       4
#define MIDI_JSTAT_FLAGS_MASK     0x30
#define MIDI_JSTAT_SEND           0x08
#define MIDI_JSTAT_RECV           0x02

#define MIDI_READY      0
#define MIDI_BUSY       2

typedef void (*MIDICallback)(s32 chan, u8* buf, void* context, s32 ret);

s32 MIDIReadAsync(s32 chan, u8* dst, u8* status, void* context, MIDICallback callback);

Parameters

chan 0
dst Pointer to a u8 variable that stores read data.
status Pointer to a u8 variable that stores the status value returned by the MIDI adapter. The value is masked using MIDI_JSTAT_MASK and is valid only when execution terminates normally.
context Value that is passed to callback as its context argument.
callback Callback function called when the process terminates.

Return Values

Returns one of the following codes. If MIDI_READY is returned, it indicates that API execution has terminated normally.

Description

Asynchronously issues a command for obtaining 4 bytes of data from the MIDI adapter. The specified callback function is called if the command is issued successfully and there is a response from the MIDI adapter. The second argument of the callback function is the same as the return value of the synchronous function MIDIRead. If the MIDI_JSTAT_SEND bit of status is 0, it indicates that the MIDI adapter has not yet output data. The function call fails if a MIDI adapter is not connected.

Do Not Call From

Background Do not call this function from the background.
Multiple threads This function is not thread-safe.
Callbacks Do not call this function from any callback function.
Interrupt handler Do not call this function from any interrupt handler.
Exception handler Do not call this function from any exception handler.
Production code Do not call this function in production code. It is available only for debugging purposes.

See Also

MIDIRead

Revision History

2013/06/21 Clarify that chan should always be 0.
2013/05/08 Automated cleanup pass.
2013/05/01 Add missing values.
2012/08/06 Cleanup pass.
2012/04/11 Port to Cafe.
2007/05/09 Initial version.


CONFIDENTIAL