Subversion Repositories svn.mios32

Rev

Rev 33 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
32 tk 1
// $Id: mios32_midi.c 32 2008-09-17 23:59:36Z tk $
2
/*
3
 * MIDI layer functions for MIOS32
4
 *
5
 * ==========================================================================
6
 *
7
 *  Copyright (C) 2008 Thorsten Klose (tk@midibox.org)
8
 *  Licensed for personal non-commercial use only.
9
 *  All other rights reserved.
10
 *
11
 * ==========================================================================
12
 */
13
 
14
/////////////////////////////////////////////////////////////////////////////
15
// Include files
16
/////////////////////////////////////////////////////////////////////////////
17
 
18
#include <mios32.h>
19
 
20
// this module can be optionally disabled in a local mios32_config.h file (included from mios32.h)
21
#if !defined(MIOS32_DONT_USE_MIDI)
22
 
23
 
24
/////////////////////////////////////////////////////////////////////////////
25
// Global variables
26
/////////////////////////////////////////////////////////////////////////////
27
 
28
 
29
/////////////////////////////////////////////////////////////////////////////
30
// Local variables
31
/////////////////////////////////////////////////////////////////////////////
32
 
33
 
34
/////////////////////////////////////////////////////////////////////////////
35
// Initializes MIDI layer
36
// IN: <mode>: currently only mode 0 supported
37
//             later we could provide operation modes
38
// OUT: returns < 0 if initialisation failed
39
/////////////////////////////////////////////////////////////////////////////
40
s32 MIOS32_MIDI_Init(u32 mode)
41
{
42
  s32 ret = 0;
43
 
44
  // currently only mode 0 supported
45
  if( mode != 0 )
46
    return -1; // unsupported mode
47
 
48
#if !defined(MIOS32_DONT_USE_USB)
49
  if( MIOS32_USB_Init(mode) < 0 )
50
    ret |= (1 << 0);
51
#endif
52
 
53
  return -ret;
54
}
55
 
56
 
57
/////////////////////////////////////////////////////////////////////////////
58
// Sends a package over given port
59
// IN: <port>: MIDI port 
60
//             0..15: USB, 16..31: USART, 32..47: IIC, 48..63: Ethernet
61
//     <package>: MIDI package (see definition in mios32_midi.h)
62
// OUT: returns -1 if port not available
63
//      returns -2 if port available, but buffer full (retry it)
64
//      returns 0 on success
65
/////////////////////////////////////////////////////////////////////////////
66
s32 MIOS32_MIDI_PackageSend(u8 port, midi_package_t package)
67
{
68
  // insert subport number into package
69
  package.ptype = (package.ptype&0x0f) | (port << 4);
70
 
71
  // branch depending on selected port
72
  switch( port >> 4 ) {
73
    case 0:
74
#if !defined(MIOS32_DONT_USE_USB)
75
      return (MIOS32_USB_MIDIPackageSend(package.ALL) < 0) ? -2 : 0;
76
#else
77
      return -1; // USB has been disabled
78
#endif
79
 
80
    case 1:
81
      return -1; // USART not implemented yet
82
 
83
    case 2:
84
      return -1; // IIC not implemented yet
85
 
86
    case 3:
87
      return -1; // Ethernet not implemented yet
88
 
89
    default:
90
      // invalid port
91
      return -1;
92
  }
93
}
94
 
95
 
96
/////////////////////////////////////////////////////////////////////////////
97
// Initializes MIDI layer
98
// IN: <mode>: currently only mode 0 supported
99
//             later we could provide operation modes
100
// OUT: returns < 0 if initialisation failed
101
/////////////////////////////////////////////////////////////////////////////
102
s32 MIOS32_MIDI_PackageReceive_Handler(void *callback)
103
{
104
}
105
 
106
 
107
#endif /* MIOS32_DONT_USE_MIDI */