Subversion Repositories svn.mios32

Rev

Rev 2646 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2646 Antichambr 1
// $Id: mios32_can_midi.h 528 2009-05-17 16:45:51Z tk $
2
/*
3
 * Header file for CAN MIDI functions
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
#ifndef _MIOS32_CAN_MIDI_H
15
#define _MIOS32_CAN_MIDI_H
16
 
17
/////////////////////////////////////////////////////////////////////////////
18
// Global definitions
19
/////////////////////////////////////////////////////////////////////////////
20
 
21
// allowed numbers: 1..16
22
#ifndef MIOS32_CAN_MIDI_NUM_PORTS
23
#define MIOS32_CAN_MIDI_NUM_PORTS 16
24
#else
25
#if MIOS32_CAN_MIDI_NUM_PORTS >16
26
#define MIOS32_CAN_MIDI_NUM_PORTS 16
27
#endif
28
#endif
29
 
30
/* - Enhanced mode allowed (send/receive extended message)
31
 if necessary (if needed and requested by an other node).
32
 Note: Message type and cable filter is used in this mode.
33
 - If not precised, MCAN is in Basic Mode(not able to send/receive extended message)
34
 */
35
//#define MIOS32_CAN_MIDI_ENHANCED
36
 
37
/* Change MCAN verbose level here, default is 0
38
 note: can be changed in terminal
39
 no verbose if not defined
40
 */
41
//#define MIOS32_CAN_MIDI_VERBOSE_LEVEL 1
42
 
43
/* forces the MCAN Input to work with streamed SYSEX
44
 if not defined:
45
 normal flow is: "packet->package"
46
 -> package using APP_MIDI_NotifySysex (MIOS32_MIDI_SysExCallback_Init)
47
 -> package using APP_MIDI_NotifyPackage
48
 (+)less RAM use (-)_SysExStreamCallback_ not usable, more packaging process
49
 if defined flow becomes: "packet->stream" first then stream->package
50
 -> stream using APP_MCAN_NotifySysexStream (MIOS32_CAN_MIDI_SysExStreamCallback_Init)
51
 -> to normal flow
52
 (+)stream ready, less process (-)16KB RAM is used for Sysex buffering
53
 */
54
//#define MIOS32_CAN_MIDI_SYSEX_STREAM_FIRST
55
 
56
// by default, equal to the mios32 Device_Id (BSL)
57
//#define MIOS32_CAN_MIDI_NODE_ID     0
58
 
59
// MCAN Common Layer applicaton Code
60
#define MIOS32_MCAN_APP_CODE      0 // MCAN
61
 
62
/* Default application code
63
 */
64
#ifndef MIOS32_CAN_MIDI_APP_CODE
65
#define MIOS32_CAN_MIDI_APP_CODE      MIOS32_MCAN_APP_CODE
66
#endif
67
 
68
#define MIOS32_CAN_MIDI_BROADCAST_ID  0xff
69
#define MIOS32_CAN_MIDI_PORT_ALL      0x02
70
 
71
// default node destination is all
72
#ifndef MIOS32_CAN_MIDI_DEF_DEST_ID
73
#define MIOS32_CAN_MIDI_DEF_DEST_ID  MIOS32_CAN_MIDI_BROADCAST_ID
74
#endif
75
// default is vlan 0
76
#ifndef MIOS32_CAN_MIDI_DEF_VMAN
77
#define MIOS32_CAN_MIDI_DEF_VMAN      0
78
#endif
79
// default destination port is
80
#ifndef MIOS32_CAN_MIDI_DEF_DEST_PORT
81
#define MIOS32_CAN_MIDI_DEF_DEST_PORT MIOS32_CAN_MIDI_PORT_ALL
82
#endif
83
 
84
 
85
/////////////////////////////////////////////////////////////////////////////
86
// Global Types
87
/////////////////////////////////////////////////////////////////////////////
88
 
89
typedef union {
2657 Antichambr 90
    mios32_can_packet_t  packet;
2646 Antichambr 91
  struct {
2657 Antichambr 92
    mios32_can_ext_id_t id;
93
    mios32_can_ctrl_t ctrl;
94
    mios32_can_data_t data;
2646 Antichambr 95
  };
2657 Antichambr 96
} mios32_mcan_packet_t;
2646 Antichambr 97
 
2657 Antichambr 98
 
2646 Antichambr 99
typedef union {
100
  struct {
2657 Antichambr 101
    mios32_can_ext_id_t id;
2646 Antichambr 102
    u16 data_l;
103
  };
104
  struct {
105
    u32 ext_id;
106
    u16 ports;
107
  };
108
  struct {
109
    // extended
110
    u32 none:1;
111
    u32 is_request:1;
112
    u32 is_extended:1;
113
    u32 src_node:7;
114
    u32 dst_node:8;
115
    u32 app_type:3;
116
    // standard
117
    u32 cable:4;
118
    u32 type:4;
119
    u32 vman_prio:3;
120
    // ports
121
    u8  src_port;
122
    u8  dst_port;
123
  };
2657 Antichambr 124
} mios32_mcan_header_t;
2646 Antichambr 125
 
126
 
127
/////////////////////////////////////////////////////////////////////////////
128
// Prototypes
129
/////////////////////////////////////////////////////////////////////////////
130
 
131
extern s32 MIOS32_CAN_MIDI_Init(u32 mode);
132
 
133
extern s32 MIOS32_CAN_MIDI_VerboseSet(u8 level);
134
extern s32 MIOS32_CAN_MIDI_VerboseGet(void);
135
extern s32 MIOS32_CAN_MIDI_NodeIDSet(u8 node_id);
136
extern s32 MIOS32_CAN_MIDI_NodeIDGet(void);
137
extern s32 MIOS32_CAN_MIDI_ModeSet(u8 enabled);
138
extern s32 MIOS32_CAN_MIDI_ModeGet(void);
139
 
140
extern s32 MIOS32_CAN_MIDI_FilterInit(u8 bypass);
141
 
142
extern s32 MIOS32_CAN_MIDI_CheckAvailable(u8 cable);
143
 
144
extern s32 MIOS32_CAN_MIDI_Periodic_mS(void);
145
 
2657 Antichambr 146
extern s32 MIOS32_CAN_MIDI_PacketTransmit_NonBlocking(mios32_mcan_packet_t p);
147
extern s32 MIOS32_CAN_MIDI_PacketTransmit(mios32_mcan_packet_t p);
2646 Antichambr 148
 
2657 Antichambr 149
extern s32 MIOS32_CAN_MIDI_PacketSend_NonBlocking(mios32_mcan_header_t header, mios32_midi_package_t package);
150
extern s32 MIOS32_CAN_MIDI_PacketSend(mios32_mcan_header_t header, mios32_midi_package_t package);
2646 Antichambr 151
 
152
extern s32 MIOS32_CAN_MIDI_PackageSend_NonBlocking(mios32_midi_package_t package);
153
extern s32 MIOS32_CAN_MIDI_PackageSend(mios32_midi_package_t package);
2657 Antichambr 154
extern s32 MIOS32_CAN_MIDI_SysexRepackSend(mios32_mcan_header_t header, mios32_midi_package_t package);
2646 Antichambr 155
 
2657 Antichambr 156
extern s32 MIOS32_CAN_MIDI_SysexSend_NonBlocking(mios32_mcan_header_t header, u8 *stream, u16 size);
157
extern s32 MIOS32_CAN_MIDI_SysexSend(mios32_mcan_header_t header, u8 *stream, u16 size);
2646 Antichambr 158
 
2657 Antichambr 159
extern s32 MIOS32_CAN_MIDI_SysExStreamCallback_Init(s32 (*callback_sysex_stream)(mios32_mcan_header_t header, u8* stream, u16 size));
2646 Antichambr 160
 
2657 Antichambr 161
extern s32 MIOS32_CAN_MIDI_PackageCallback_Init(s32 (*direct_package_callback)(mios32_mcan_header_t header, mios32_midi_package_t package));
2646 Antichambr 162
 
163
extern s32 MIOS32_CAN_MIDI_PackageReceive(mios32_midi_package_t *package);
164
 
2657 Antichambr 165
extern u32 MIOS32_CAN_MIDI_DefaultHeaderInit(mios32_mcan_header_t* header);
2646 Antichambr 166
/////////////////////////////////////////////////////////////////////////////
167
// Export global variables
168
/////////////////////////////////////////////////////////////////////////////
169
extern u8 mios32_mcan_id;
170
 
171
 
172
#endif /* _MIOS32_CAN_MIDI_H */