Subversion Repositories svn.mios

Rev

Rev 52 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
53 tk 1
; $Id: mios_midi.inc 53 2008-01-30 22:52:41Z tk $
1 tk 2
;
3
; MIDI Service Routines of MIOS
4
;
5
; ==========================================================================
6
;
7
;  Copyright 1998-2006 Thorsten Klose (tk@midibox.org)
8
;  Licensed for personal non-commercial use only.
9
;  All other rights reserved.
10
;
11
; ==========================================================================
12
 
13
MIOS_MIDI_MBLINK_START     EQU 0xf9	; control byte for begin of stream
14
MIOS_MIDI_MBLINK_STOP      EQU 0xfe	; control byte for end of stream
15
 
16
MIOS_MIDI_INTERFACE_COMMON	EQU	0x00
17
MIOS_MIDI_INTERFACE_TO_HOST	EQU	0x01
18
 
19
MIOS_MIDI_MERGER_DISABLED	EQU	0x00
20
MIOS_MIDI_MERGER_ENABLED	EQU	0x01
21
MIOS_MIDI_MERGER_MBLINK_EP	EQU	0x02
22
MIOS_MIDI_MERGER_MBLINK_FP	EQU	0x03
23
 
24
;; --------------------------------------------------------------------------
25
;;  FUNCTION: MIOS_MIDI_Init
26
;;  C_DECLARATION: void MIOS_MIDI_Init(void)
27
;;  DESCRIPTION: initialises the MIDI interface: baudrate will be set
28
;;  depending on To-Host/MIDI option, Rx and Tx buffer will be emptied
29
;;  IN:	  -
30
;;  C_IN:  -
31
;;  OUT:  -
32
;;  C_OUT:  -
33
;;  USES: BSR
34
;; --------------------------------------------------------------------------
35
MIOS_MIDI_Init
36
	;; enable transmitter and init baudrate
37
	movlw	(1 << TXEN) | (1 << BRGH)
38
	movwf	TXSTA
39
	rcall	MIOS_MIDI_Init_Baudrate
40
 
41
	; Configure Receive Status and Control Register
42
	movlw	(1 << SPEN) | (1 << CREN)
43
	movwf	RCSTA
44
 
45
	; initialize ringbuffers
46
	SET_BSR	MIOS_RX_BUFFER_TAIL
47
	movlw	MIOS_RX_BUFFER & 0xff
48
	movwf	MIOS_RX_BUFFER_TAIL, BANKED
49
	movwf	MIOS_RX_BUFFER_HEAD, BANKED
50
 
51
	movlw	MIOS_TX_BUFFER & 0xff
52
	movwf	MIOS_TX_BUFFER_TAIL, BANKED
53
	movwf	MIOS_TX_BUFFER_HEAD, BANKED
54
 
55
	;; annul "lastevent"
56
	setf	MIOS_MPROC_LASTEVENT0, BANKED
57
	setf	MIOS_MPROC_LASTEVENT1, BANKED
58
	setf	MIOS_MPROC_LASTEVENT2, BANKED
59
 
60
	return
61
 
62
;; -------
63
;; (function used by MIOS_MIDI_Init and MIOS_MIDI_InterfaceSet)
64
MIOS_MIDI_Init_Baudrate
65
	BRA_IFCLR MIOS_BOX_CFG0, MIOS_BOX_CFG0_TO_HOST, ACCESS, MIOS_MIDI_Init_Baudrate_31250
66
 
67
MIOS_MIDI_Init_Baudrate_38400
68
  	movlw	2*0x21-1			; set baudrate to 38400 baud
69
	btfsc	MIOS_BOX_CFG0, MIOS_BOX_CFG0_20MHz
70
	movlw	0x21-1
71
	rgoto	MIOS_MIDI_Init_Baudrate_End
72
 
73
MIOS_MIDI_Init_Baudrate_31250
74
  	movlw	8*0x0a-1			; set baudrate to 31250 baud
75
	btfsc	MIOS_BOX_CFG0, MIOS_BOX_CFG0_20MHz
76
	movlw	4*0x0a-1
77
	;; 	rgoto	MIOS_MIDI_Init_Baudrate_End
78
 
79
MIOS_MIDI_Init_Baudrate_End
80
	;; don't overwrite SPBRG if value already initialized - otherwise the
81
	;; baudrate generator will be reset, this can lead to invalid MIDI bytes
82
	xorwf	SPBRG, W
83
	bz	MIOS_MIDI_Init_Baudrate_NoUpdate
84
MIOS_MIDI_Init_Baudrate_Update
85
	xorwf	SPBRG, W	; (XOR back to new value)
86
	movwf	SPBRG		; (write new value)
87
MIOS_MIDI_Init_Baudrate_NoUpdate
88
	return
89
 
90
;; --------------------------------------------------------------------------
91
;;  FUNCTION: MIOS_MIDI_InterfaceSet
92
;;  C_DECLARATION: void MIOS_MIDI_InterfaceSet(unsigned char interface)
93
;;  DESCRIPTION: this function has two purposes:<BR>
94
;;  If the interface number is 0x00 or 0x01, the internal USART will be selected,
95
;;  and a baudrate of either 31250 or 38400 baud will be configured:<BR>
96
;;     0x00: MIOS_MIDI_INTERFACE_COMMON (common MIDI interface, 31250 baud)<BR>
97
;;     0x01: MIOS_MIDI_INTERFACE_TO_HOST (MIDIbox-to-COM interface, RS232, 38400 baud)<BR>
98
;;  <BR>
99
;;  With values >= 0x02 a MBHP_IIC_MIDI module will be selected for <B>outgoing</B>
100
;;  MIDI messages (which are sent with MIOS_MIDI_TxBufferPut)<BR>
101
;;  Incoming messages are still handled with the internal USART!<BR>
102
;;  If data should be received from a MBHP_IIC_MIDI module, please use the appr.
103
;;  functions of the software package which is provided together with the module.<BR>
104
;;  Note that the MIOS_MIDI_InterfaceAutoSet function allows you to derive the MIDI
105
;;  interface type and the IIC slave address from the PIC ID header!<BR>
106
;;  IN:	  interface type in WREG
107
;;  C_IN:  interface type in <interface>
108
;;  OUT:  -
109
;;  C_OUT:  -
110
;;  USES: BSR
111
;;  EXAMPLE:
112
;;
113
;;	;; send MIDI clock over internal MIDI Out with normal baudrate
114
;;	movlw	MIOS_MIDI_INTERFACE_COMMON
115
;;	call	MIOS_MIDI_InterfaceSet
116
;;
117
;;	movlw	0xf8  ; (MIDI Clock)
118
;;	call	MIOS_MIDI_TxBufferPut
119
;;
120
;;	;; send MIDI clock over MBHP_IIC_MIDI with address 0x10
121
;;	movlw	0x10
122
;;	call	MIOS_MIDI_InterfaceSet
123
;;
124
;;	movlw	0xf8  ; (MIDI Clock)
125
;;	call	MIOS_MIDI_TxBufferPut
126
;;
127
;;	;; switch back to the default interface
128
;;	call	MIOS_MIDI_InterfaceAutoSet
129
;;
130
;;  C_EXAMPLE:
131
;;
132
;;	// send MIDI clock over internal MIDI Out with normal baudrate
133
;;	MIOS_MIDI_InterfaceSet(MIOS_MIDI_INTERFACE_COMMON);
134
;;	MIOS_MIDI_TxBufferPut(0xf8);
135
;;
136
;;	// send MIDI clock over MBHP_IIC_MIDI with address 0x10
137
;;	MIOS_MIDI_InterfaceSet(0x10);
138
;;	MIOS_MIDI_TxBufferPut(0xf8);
139
;;
140
;;	// switch back to the default interface
141
;;	MIOS_MIDI_InterfaceAutoSet();
142
;;
143
;; --------------------------------------------------------------------------
144
MIOS_MIDI_InterfaceSet
145
	SET_BSR	MIOS_TMP1
146
	movwf	MIOS_TMP1, BANKED
147
 
148
	andlw	0xfe
149
	bz	MIOS_MIDI_InterfaceSet_Int
150
 
151
MIOS_MIDI_InterfaceSet_IIC
152
	;; (we've already ensured that bit #0 is not set with the "andlw 0xfe"!)
153
	movwf	MIOS_IIC_MIDI_ADDR, BANKED
154
	rgoto	MIOS_MIDI_InterfaceSet_End
155
 
156
MIOS_MIDI_InterfaceSet_Int
157
	clrf	MIOS_IIC_MIDI_ADDR, BANKED
158
 
159
	bcf	MIOS_BOX_CFG0, MIOS_BOX_CFG0_TO_HOST
160
	btfsc	MIOS_TMP1, 0, BANKED
161
	bsf	MIOS_BOX_CFG0, MIOS_BOX_CFG0_TO_HOST
162
	rcall	MIOS_MIDI_Init_Baudrate	; set selected baudrate
163
	;; 	rgoto	MIOS_MIDI_InterfaceSet_End
164
 
165
MIOS_MIDI_InterfaceSet_End
166
	return
167
 
168
;; --------------------------------------------------------------------------
169
;;  FUNCTION: MIOS_MIDI_InterfaceAutoSet
170
;;  C_DECLARATION: void MIOS_MIDI_InterfaceAutoSet(void)
171
;;  DESCRIPTION: derives the MIDI interface type and the MBHP_IIC_MIDI module address
172
;;  from the PIC ID header.<BR>
173
;;  To-Host flag: ID Byte 6, Bit 0<BR>
174
;;  MBHP_IIC_MIDI module address: ID Byte 5<BR>
175
;;  If the slave address is != 0x00 and != 0xff, it will be taken as default
176
;;  MIDI Out by MIOS
177
;;  IN:	  -
178
;;  C_IN:  -
179
;;  OUT:  -
180
;;  C_OUT:  -
181
;;  USES: BSR, TBLPTR
182
;;  EXAMPLE:
183
;;
184
;;	;; set MIDI interface to the specified type in the PIC ID header
185
;;	call	MIOS_MIDI_InterfaceAutoSet
186
;;
187
;;  C_EXAMPLE:
188
;;
189
;;	// set MIDI interface to the specified type in the PIC ID header
190
;;	MIOS_MIDI_InterfaceAutoSet();
191
;;
192
;; --------------------------------------------------------------------------
193
MIOS_MIDI_InterfaceAutoSet
194
	IRQ_DISABLE			; we change TBLPTRU - IRQs have to be disabled!
195
	TABLE_ADDR_FULL _IDLOC6		; derive interface type from ID sector
196
 
197
	tblrd*-				; get to-host flag
198
	movf	TABLAT, W
199
	andlw	0x01
200
	rcall	MIOS_MIDI_InterfaceSet
201
	;; note: clears also MIOS_IIC_MIDI_ADDR
202
 
203
	tblrd*-				; get MBHP_IIC_MIDI module address
204
	movf	TABLAT, W		; don't use IIC if ID entry is 0x00 or 0xff
205
	bz	MIOS_MIDI_InterfaceAutoSet_NoIIC
206
	addlw	1
207
	bz	MIOS_MIDI_InterfaceAutoSet_NoIIC
208
	movf	TABLAT, W
209
	rcall	MIOS_MIDI_InterfaceSet
210
MIOS_MIDI_InterfaceAutoSet_NoIIC
211
 
212
	clrf	TBLPTRU			; clear upper table pointer so
213
	IRQ_ENABLE			; that the IRQs can be enabled again
214
	return
215
 
216
;; --------------------------------------------------------------------------
217
;;  FUNCTION: MIOS_MIDI_InterfaceGet
218
;;  C_DECLARATION: unsigned char MIOS_MIDI_InterfaceGet(void)
219
;;  DESCRIPTION: returns the current MIDI interface type
220
;;  following Interface types are provided:<BR>
221
;;     0x00: MIOS_MIDI_INTERFACE_COMMON (common MIDI interface, 31250 baud)<BR>
222
;;     0x01: MIOS_MIDI_INTERFACE_TO_HOST (MIDIbox-to-COM interface, RS232, 38400 baud)<BR>
223
;;     >= 0x02: MBHP_IIC_MIDI module address
224
;;  IN:	  -
225
;;  C_IN:  -
226
;;  OUT:  interface type in WREG and MIOS_PARAMETER1
227
;;  C_OUT:  interface type
228
;;  USES: BSR
229
;;  EXAMPLE:
230
;;
231
;;	;; branch if MBHP_IIC_MIDI module is selected
232
;;	call	MIOS_MIDI_InterfaceGet
233
;;	andlw   0xfe
234
;;	bnz     HandleExternalMIDI
235
;;
236
;;  C_EXAMPLE:
237
;;
238
;;	// get current interface type and branch depending on setting
239
;;	switch( MIOS_MIDI_InterfaceGet() ) {
240
;;	  case MIOS_MIDI_INTERFACE_COMMON:
241
;;	    // do this...
242
;;	    break;
243
;;	  case MIOS_MIDI_INTERFACE_TO_HOST:
244
;;	    // do that...
245
;;	    break;
246
;;	  default:
247
;;	    // IIC slave selected...
248
;;	}
249
;;
250
;; --------------------------------------------------------------------------
251
MIOS_MIDI_InterfaceGet
252
	SET_BSR	MIOS_IIC_MIDI_ADDR
253
	movf	MIOS_IIC_MIDI_ADDR, W, BANKED
254
	bz	MIOS_MIDI_InterfaceGet_Int
255
 
256
MIOS_MIDI_InterfaceGet_Ext
257
	;; (address already in WREG)
258
	rgoto	MIOS_MIDI_InterfaceGet_End
259
 
260
MIOS_MIDI_InterfaceGet_Int
261
	movlw	0x00
262
	btfsc	MIOS_BOX_CFG0, MIOS_BOX_CFG0_TO_HOST
263
	iorlw	0x01
264
	;; 	rgoto	MIOS_MIDI_InterfaceGet_End
265
 
266
MIOS_MIDI_InterfaceGet_End
267
	movwf	MIOS_PARAMETER1
268
	andlw	0xff		; (update STATUS)
269
	return
270
 
271
;; --------------------------------------------------------------------------
272
;;  FUNCTION: MIOS_MIDI_DeviceIDSet
273
;;  C_DECLARATION: void MIOS_MIDI_DeviceIDSet(unsigned char device_id)
274
;;  DESCRIPTION: sets the MIDI device ID. Should be a unique number in a MIDI
275
;;  chain. Normaly this ID is derived from the PIC ID header with the
276
;;  MIOS_MIDI_DeviceIDAutoSet function
277
;;  IN:	  device number in WREG (0x00-0x7f)
278
;;  C_IN:  device number in <device_id>
279
;;  OUT:  -
280
;;  C_OUT:  -
281
;;  USES: BSR
282
;;  EXAMPLE:
283
;;
284
;;	;; set device ID to 0x03
285
;;	movlw	0x03
286
;;	call	MIOS_MIDI_DeviceIDSet
287
;;
288
;;  C_EXAMPLE:
289
;;
290
;;	;; change device ID
291
;;	MIOS_MIDI_DeviceIDSet(0x03);
292
;;
293
;; --------------------------------------------------------------------------
294
MIOS_MIDI_DeviceIDSet
295
	andlw	0x7f
296
	SET_BSR	MIOS_MIDI_DEVICE_ID
297
	movwf	MIOS_MIDI_DEVICE_ID, BANKED
298
	return
299
 
300
;; --------------------------------------------------------------------------
301
;;  FUNCTION: MIOS_MIDI_DeviceIDAutoSet
302
;;  C_DECLARATION: void MIOS_MIDI_DeviceIDAutoSet(void)
303
;;  DESCRIPTION: derives the MIDI device ID from the PIC ID header
304
;;  IN:	  -
305
;;  C_IN:  -
306
;;  OUT:  -
307
;;  C_OUT:  -
308
;;  USES: BSR, TBLPTR
309
;;  EXAMPLE:
310
;;
311
;;	;; set device ID to the specified value in the PIC ID header
312
;;	call	MIOS_MIDI_DeviceIDAutoSet
313
;;
314
;;  C_EXAMPLE:
315
;;
316
;;	// set device ID to the specified value in the PIC ID header
317
;;	MIOS_MIDI_DeviceIDAutoSet();
318
;;
319
;; --------------------------------------------------------------------------
320
MIOS_MIDI_DeviceIDAutoSet
321
	IRQ_DISABLE			; we change TBLPTRU - IRQs have to be disabled!
322
	TABLE_ADDR_FULL _IDLOC7		; derive device ID from ID sector
323
	tblrd*				; get first byte
324
	movf	TABLAT, W		; copy 7-bit value to DEVICE_ID
325
	rcall	MIOS_MIDI_DeviceIDSet
326
	clrf	TBLPTRU			; clear upper table pointer so
327
	IRQ_ENABLE			; that the IRQs can be enabled again
328
	return
329
 
330
;; --------------------------------------------------------------------------
331
;;  FUNCTION: MIOS_MIDI_DeviceIDGet
332
;;  C_DECLARATION: unsigned char MIOS_MIDI_DeviceIDGet(void)
333
;;  DESCRIPTION: returns the MIDI device ID
334
;;  IN:	  -
335
;;  C_IN:  -
336
;;  OUT:  device number in WREG and MIOS_PARAMETER1 (0x00-0x7f)
337
;;  C_OUT:  device number
338
;;  USES: BSR
339
;;  EXAMPLE:
340
;;
341
;;	;; print device ID on display
342
;;	call	MIOS_MIDI_DeviceIDGet
343
;;	call	MIOS_LCD_PrintHex2
344
;;
345
;;  C_EXAMPLE:
346
;;
347
;;	// print device ID on display
348
;;	MIOS_LCD_PrintHex2(MIOS_MIDI_DeviceIDGet());
349
;;
350
;; --------------------------------------------------------------------------
351
MIOS_MIDI_DeviceIDGet
352
	SET_BSR	MIOS_MIDI_DEVICE_ID
353
	movf	MIOS_MIDI_DEVICE_ID, W, BANKED
354
	movwf	MIOS_PARAMETER1
355
	return
356
 
357
;; --------------------------------------------------------------------------
358
;;  FUNCTION: MIOS_MIDI_MergerSet
359
;;  C_DECLARATION: void MIOS_MIDI_MergerSet(unsigned char mode)
360
;;  DESCRIPTION: configures the integrated MIDI merger
361
;;  following Merger IDs are provided:<BR>
362
;;     0x00: MIOS_MIDI_MERGER_DISABLED  (merger disabled)<BR>
363
;;     0x01: MIOS_MIDI_MERGER_ENABLED   (merger enabled)<BR>
364
;;     0x02: MIOS_MIDI_MERGER_MBLINK_EP (MIDIbox Link End Point)<BR>
365
;;     0x03: MIOS_MIDI_MERGER_MBLINK_FP (MIDIbox Link Forwarding Point)
366
;;  IN:	  merger function ID in WREG
367
;;  C_IN:  merger function ID in <mode>
368
;;  OUT:  -
369
;;  USES: -
370
;;  EXAMPLE:
371
;;
372
;;	;; configure the MIDIbox as MIDIbox Link End Point
373
;;	;; (means: merger enabled only for events which has
374
;;	;; been generated by another MIDIbox which is configured
375
;;	;; as MIDIbox Link Forwarding Point)
376
;;	movlw	MIOS_MIDI_MERGER_MBLINK_EP
377
;;	call	MIOS_MIDI_MergerSet
378
;;
379
;;  C_EXAMPLE:
380
;;
381
;;	// configure the MIDIbox as MIDIbox Link End Point
382
;;	// (means: merger enabled only for events which has
383
;;	// been generated by another MIDIbox which is configured
384
;;	// as MIDIbox Link Forwarding Point)
385
;;	MIOS_MIDI_MergerSet(MIOS_MIDI_MERGER_MBLINK_EP);
386
;;
387
;; --------------------------------------------------------------------------
388
MIOS_MIDI_MergerSet
389
	bcf	MIOS_BOX_CFG0, MIOS_BOX_CFG0_MERGER
390
	bcf	MIOS_BOX_CFG0, MIOS_BOX_CFG0_MBLINK
391
 
392
	btfsc	WREG, 0
393
	bsf	MIOS_BOX_CFG0, MIOS_BOX_CFG0_MERGER
394
	btfsc	WREG, 1
395
	bsf	MIOS_BOX_CFG0, MIOS_BOX_CFG0_MBLINK
396
	return
397
 
398
;; --------------------------------------------------------------------------
399
;;  FUNCTION: MIOS_MIDI_MergerGet
400
;;  C_DECLARATION: unsigned char MIOS_MIDI_MergerGet(void)
401
;;  DESCRIPTION: returns configuration of integrated MIDI merger:
402
;;     0x00: MIOS_MIDI_MERGER_DISABLED  (merger disabled)<BR>
403
;;     0x01: MIOS_MIDI_MERGER_ENABLED   (merger enabled)<BR>
404
;;     0x02: MIOS_MIDI_MERGER_MBLINK_EP (MIDIbox Link End Point)<BR>
405
;;     0x03: MIOS_MIDI_MERGER_MBLINK_FP (MIDIbox Link Forwarding Point)
406
;;  IN:	  -
407
;;  C_IN:  -
408
;;  OUT:  merger function ID in WREG and MIOS_PARAMETER1
409
;;  C_OUT:  merger function ID
410
;;  USES: -
411
;;  EXAMPLE:
412
;;
413
;;	;; get current merger configuration and branch depending on setting
414
;;	call	MIOS_MIDI_MergerGet
415
;;	BRA_IFSET WREG, 1, ACCESS, MBLinkEnabled
416
;;	rgoto	MBLinkNotEnabled
417
;;
418
;;  C_EXAMPLE:
419
;;
420
;;	// get current merger configuration and branch depending on setting
421
;;	switch( MIOS_MIDI_MergerGet() ) {
422
;;	  case MIOS_MIDI_MERGER_ENABLED:
423
;;	    // do this...
424
;;	    break;
425
;;	  case MIOS_MIDI_MERGER_MBLINK_EP:
426
;;	    // do this...
427
;;	    break;
428
;;	  case MIOS_MIDI_MERGER_MBLINK_FP:
429
;;	    // do this...
430
;;	    break;
431
;;	  default: // MIOS_MIDI_MERGER_DISABLED:
432
;;	    // do that...
433
;;	}
434
;;
435
;; --------------------------------------------------------------------------
436
MIOS_MIDI_MergerGet
437
	movlw	0x00
438
	btfsc	MIOS_BOX_CFG0, MIOS_BOX_CFG0_MERGER
439
	iorlw	0x01
440
	btfsc	MIOS_BOX_CFG0, MIOS_BOX_CFG0_MBLINK
441
	iorlw	0x02
442
	movwf	MIOS_PARAMETER1
443
	andlw	0xff		; (update STATUS)
444
	return
445
 
446
;; --------------------------------------------------------------------------
447
;;  FUNCTION: MIOS_MIDI_BeginStream
448
;;  C_DECLARATION: void MIOS_MIDI_BeginStream(void)
449
;;  DESCRIPTION: use this function before a new MIDI event or stream should
450
;;  be sent. Necessary for a correct function of the MIDIbox Link feature!
451
;;  IN:	  -
452
;;  C_IN:  -
453
;;  OUT:  -
454
;;  C_OUT:  -
455
;;  USES: -
456
;;  EXAMPLE:
457
;;
458
;;	;; send the MIDI event B0 07 7F
459
;;	call	MIOS_MIDI_BeginStream
460
;;	movlw	0xb0
461
;;	call	MIOS_MIDI_TxBufferPut
462
;;	movlw	0x07
463
;;	call	MIOS_MIDI_TxBufferPut
464
;;	movlw	0x7f
465
;;	call	MIOS_MIDI_TxBufferPut
466
;;	call	MIOS_MIDI_EndStream
467
;;
468
;;  C_EXAMPLE:
469
;;
470
;;	// send the MIDI event B0 07 7F
471
;;	MIOS_MIDI_BeginStream();
472
;;	MIOS_MIDI_TxBufferPut(0xb0);
473
;;	MIOS_MIDI_TxBufferPut(0x07);
474
;;	MIOS_MIDI_TxBufferPut(0x7f);
475
;;	MIOS_MIDI_EndStream();
476
;;
477
;; --------------------------------------------------------------------------
478
MIOS_MIDI_BeginStream
479
	movlw	MIOS_MIDI_MBLINK_START
480
	btfss	MIOS_BOX_CFG0, MIOS_BOX_CFG0_MBLINK
481
	return
482
	btfss	MIOS_BOX_CFG0, MIOS_BOX_CFG0_MERGER
483
	return
484
	rgoto	MIOS_MIDI_TxBufferPut
485
 
486
;; --------------------------------------------------------------------------
487
;;  FUNCTION: MIOS_MIDI_EndStream
488
;;  C_DECLARATION: void MIOS_MIDI_EndStream(void)
489
;;  DESCRIPTION: use this function after a MIDI event or stream has been
490
;;  sent. Necessary for a correct function of the MIDIbox Link feature!
491
;;  IN:	  -
492
;;  C_IN:  -
493
;;  OUT:  -
494
;;  C_OUT:  -
495
;;  USES: -
496
;;  EXAMPLE:
497
;;
498
;;	;; send the MIDI event 90 36 7F
499
;;	call	MIOS_MIDI_BeginStream
500
;;	movlw	0x90
501
;;	call	MIOS_MIDI_TxBufferPut
502
;;	movlw	0x36
503
;;	call	MIOS_MIDI_TxBufferPut
504
;;	movlw	0x7f
505
;;	call	MIOS_MIDI_TxBufferPut
506
;;	call	MIOS_MIDI_EndStream
507
;;
508
;;  C_EXAMPLE:
509
;;
510
;;	// send the MIDI event 90 36 7F
511
;;	MIOS_MIDI_BeginStream();
512
;;	MIOS_MIDI_TxBufferPut(0x90);
513
;;	MIOS_MIDI_TxBufferPut(0x36);
514
;;	MIOS_MIDI_TxBufferPut(0x7f);
515
;;	MIOS_MIDI_EndStream();
516
;;
517
;; --------------------------------------------------------------------------
518
MIOS_MIDI_EndStream
519
	movlw	MIOS_MIDI_MBLINK_STOP
520
	btfss	MIOS_BOX_CFG0, MIOS_BOX_CFG0_MBLINK
521
	return
522
	btfss	MIOS_BOX_CFG0, MIOS_BOX_CFG0_MERGER
523
	return
524
	rgoto	MIOS_MIDI_TxBufferPut
525
 
526
;; --------------------------------------------------------------------------
527
;;  FUNCTION: MIOS_MIDI_RxBufferUsed
528
;;  C_DECLARATION: unsigned char MIOS_MIDI_RxBufferUsed(void)
529
;;  DESCRIPTION: returns number of used bytes in receive buffer
530
;;  IN:	  -
531
;;  C_IN:  -
532
;;  OUT:  number of used bytes in WREG
533
;;  C_OUT:  number of used bytes
534
;;  USES: BSR
535
;;  EXAMPLE:
536
;;
537
;;	;; branch if something has been received via MIDI
538
;;	call	MIOS_MIDI_RxBufferUsed
539
;;	bz	ReceivedSomething
540
;;
541
;;  C_EXAMPLE:
542
;;
543
;;	// branch if something has been received via MIDI
544
;;	if( MIOS_MIDI_RxBufferUsed() ) {
545
;;	  // do something...
546
;;	}
547
;;
548
;;  NOTE: <I>this function is for internal use within MIOS only!<BR>
549
;;  Received bytes will be notified by the MPROC hooks!</I>
550
;; --------------------------------------------------------------------------
551
MIOS_MIDI_RxBufferUsed
552
	SET_BSR	MIOS_RX_BUFFER_HEAD
553
	movf	MIOS_RX_BUFFER_HEAD, W, BANKED
554
	cpfslt	MIOS_RX_BUFFER_TAIL, BANKED
555
	rgoto MIOS_MIDI_RxBufferUsed_Geq
556
	sublw	(MIOS_RX_BUFFER_END+1-MIOS_RX_BUFFER)
557
	addwf	MIOS_RX_BUFFER_TAIL, W, BANKED
558
	return
559
MIOS_MIDI_RxBufferUsed_Geq
560
	subwf	MIOS_RX_BUFFER_TAIL, W, BANKED
561
MIOS_MIDI_RxBufferUsed_End
562
	return
563
 
564
;; --------------------------------------------------------------------------
565
;;  FUNCTION: MIOS_MIDI_RxBufferFree
566
;;  C_DECLARATION: unsigned char MIOS_MIDI_RxBufferFree(void)
567
;;  DESCRIPTION: returns number of free bytes in receive buffer
568
;;  IN:	  -
569
;;  C_IN:  -
570
;;  OUT:  number of free bytes in WREG
571
;;  C_OUT:  number of free bytes
572
;;  USES: BSR
573
;;  EXAMPLE:
574
;;
575
;;	;; put a MIDI byte into the Rx Buffer if it isn't full
576
;;	call	MIOS_MIDI_RxBufferFree
577
;;	bz	BufferIsFull
578
;;	movlw	0xf8	; (MIDI Clock)
579
;;	call	MIOS_MIDI_RxBufferPut
580
;;
581
;;  C_EXAMPLE:
582
;;
583
;;	// put a MIDI byte into the Rx Buffer if it isn't full
584
;;	if( MIOS_MIDI_RxBufferFree() ) {
585
;;	  MIOS_MIDI_RxBufferPut(0xf8); // MIDI Clock
586
;;	}
587
;;
588
;;  NOTE: <I>this function is for internal use within MIOS only!<BR>
589
;;  Received bytes will be notified by the MPROC hooks!</I>
590
;; --------------------------------------------------------------------------
591
MIOS_MIDI_RxBufferFree
592
	rcall	MIOS_MIDI_RxBufferUsed
593
	sublw	(MIOS_RX_BUFFER_END-MIOS_RX_BUFFER)
594
	return
595
 
596
;; --------------------------------------------------------------------------
597
;;  FUNCTION: MIOS_MIDI_RxBufferPut
598
;;  C_DECLARATION: void MIOS_MIDI_RxBufferPut(unsigned char b)
599
;;  DESCRIPTION: puts a byte onto the receive buffer
600
;;  IN:	  byte in WREG
601
;;  C_IN:  byte in <b>
602
;;  OUT:  -
603
;;  C_OUT:  -
604
;;  USES: BSR, FSR1
605
;;  EXAMPLE:
606
;;
607
;;	;; put a MIDI byte into the Rx Buffer if it isn't full
608
;;	call	MIOS_MIDI_RxBufferFree
609
;;	bz	BufferIsFull
610
;;	movlw	0xf8	; (MIDI Clock)
611
;;	call	MIOS_MIDI_RxBufferPut
612
;;
613
;;  C_EXAMPLE:
614
;;
615
;;	// put a MIDI byte into the Rx Buffer if it isn't full
616
;;	if( MIOS_MIDI_RxBufferFree() ) {
617
;;	  MIOS_MIDI_RxBufferPut(0xf8); // MIDI Clock
618
;;	}
619
;;
620
;;  NOTE: <I>this function is for internal use within MIOS only!<BR>
621
;;  Received bytes will be notified by the MPROC hooks!</I>
622
;; --------------------------------------------------------------------------
623
MIOS_MIDI_RxBufferPut
624
	SET_BSR	MIOS_RX_BUFFER_TMP
625
	movwf	MIOS_RX_BUFFER_TMP, BANKED		; save byte which should be sent
626
 
627
	;; call user hook
628
	CALL_IFCLR MIOS_BOX_STAT, MIOS_BOX_STAT_SUSPEND_USER, ACCESS, USER_MIDI_NotifyRx
629
 
630
	SET_BSR	MIOS_RX_BUFFER_TMP
631
	incf	MIOS_RX_BUFFER_TAIL, W, BANKED	; increment ringcounter, but don't save yet
632
	xorlw	(MIOS_RX_BUFFER_END&0xff)+1
633
	skpnz
634
	movlw	(MIOS_RX_BUFFER&0xff) ^ ((MIOS_RX_BUFFER_END&0xff)+1)
635
	xorlw	(MIOS_RX_BUFFER_END&0xff)+1
636
	cpfseq	MIOS_RX_BUFFER_HEAD, BANKED
637
	rgoto MIOS_MIDI_RxBufferPut_Ok
638
	return					; prevent overrun
639
MIOS_MIDI_RxBufferPut_Ok
640
	movwf	MIOS_RX_BUFFER_TAIL, BANKED		; save counter
641
	lfsr	FSR1, MIOS_RX_BUFFER			; prepare FSR
642
	movwf	FSR1L
643
	movf	MIOS_RX_BUFFER_TMP, W, BANKED	; push byte onto buffer
644
	movwf	INDF1
645
	return
646
 
647
;; --------------------------------------------------------------------------
648
;;  FUNCTION: MIOS_MIDI_RxBufferGet
649
;;  C_DECLARATION: unsigned char MIOS_MIDI_RxBufferGet(void)
650
;;  DESCRIPTION: gets a byte from the receive buffer
651
;;  IN:	  -
652
;;  C_IN:  -
653
;;  OUT:  received byte in WREG
654
;;  C_OUT:  received byte
655
;;  USES: BSR, FSR1
656
;;  EXAMPLE:
657
;;
658
;;	;; get a MIDI byte from the Rx Buffer if something has been received
659
;;	call	MIOS_MIDI_RxBufferUsed
660
;;	bz	NothingReceived
661
;;	call	MIOS_MIDI_RxBufferGet
662
;;
663
;;  C_EXAMPLE:
664
;;
665
;;	unsigned char b;
666
;;
667
;;	// get a MIDI byte from the Rx Buffer if something has been received
668
;;	if( MIOS_MIDI_RxBufferUsed() ) {
669
;;	  b = MIOS_MIDI_RxBufferGet();
670
;;	}
671
;;
672
;;  NOTE: <I>this function is for internal use within MIOS only!<BR>
673
;;  Received bytes will be notified by the MPROC hooks!</I>
674
;; --------------------------------------------------------------------------
675
MIOS_MIDI_RxBufferGet
676
	SET_BSR	MIOS_RX_BUFFER_HEAD
677
	incf	MIOS_RX_BUFFER_HEAD, F, BANKED
678
	movlw	(MIOS_RX_BUFFER_END&0xff)+1
679
	cpfseq	MIOS_RX_BUFFER_HEAD, BANKED
680
	rgoto MIOS_MIDI_RxBufferGet_NoReset
681
	movlw	MIOS_RX_BUFFER & 0xff
682
	movwf	MIOS_RX_BUFFER_HEAD, BANKED
683
MIOS_MIDI_RxBufferGet_NoReset
684
	lfsr	FSR1, MIOS_RX_BUFFER
685
	movff	MIOS_RX_BUFFER_HEAD, FSR1L
686
	movf	INDF1, W
687
	return
688
 
689
;; --------------------------------------------------------------------------
690
;;  FUNCTION: MIOS_MIDI_TxBufferUsed
691
;;  C_DECLARATION: unsigned char MIOS_MIDI_TxBufferUsed(void)
692
;;  DESCRIPTION: returns number of used bytes in buffer
693
;;  NOTE: always deliver the result of the internal UART buffer, and not of a MBHP_IIC_MIDI module
694
;;  IN:	  -
695
;;  C_IN:  -
696
;;  OUT:  number of used bytes in WREG
697
;;  C_OUT:  number of used bytes
698
;;  USES: BSR
699
;;  EXAMPLE:
700
;;
701
;;	;; branch if something has been put into the Tx Buffer
702
;;	call	MIOS_MIDI_TxBufferUsed
703
;;	bz	GotSomething
704
;;
705
;;  C_EXAMPLE:
706
;;
707
;;	// branch if something has been put into the Tx Buffer
708
;;	if( MIOS_MIDI_TxBufferUsed() ) {
709
;;	  // got something
710
;;	}
711
;;
712
;;  NOTE: <I>this function is for internal use within MIOS only!<BR>
713
;;  The MIOS_MIDI_TxBufferPut() function will wait if the buffer is full.</I>
714
;; --------------------------------------------------------------------------
715
MIOS_MIDI_TxBufferUsed
716
	SET_BSR	MIOS_TX_BUFFER_HEAD
717
	movf	MIOS_TX_BUFFER_HEAD, W, BANKED
718
	cpfslt	MIOS_TX_BUFFER_TAIL, BANKED
719
	rgoto MIOS_MIDI_TxBufferUsed_Geq
720
	sublw	(MIOS_TX_BUFFER_END+1-MIOS_TX_BUFFER)
721
	addwf	MIOS_TX_BUFFER_TAIL, W, BANKED
722
	return
723
MIOS_MIDI_TxBufferUsed_Geq
724
	subwf	MIOS_TX_BUFFER_TAIL, W, BANKED
725
MIOS_MIDI_TxBufferUsed_End
726
	return
727
 
728
;; --------------------------------------------------------------------------
729
;;  FUNCTION: MIOS_MIDI_TxBufferFree
730
;;  C_DECLARATION: unsigned char MIOS_MIDI_TxBufferFree(void)
731
;;  DESCRIPTION: returns number of free bytes in transmit buffer
732
;;  NOTE: always deliver the result of the internal UART buffer, and not of a MBHP_IIC_MIDI module
733
;;  IN:	  -
734
;;  C_IN:  -
735
;;  OUT:  number of free bytes in WREG
736
;;  C_OUT:  number of free bytes
737
;;  USES: BSR
738
;;  EXAMPLE:
739
;;
740
;;	;; put a MIDI byte into the Tx Buffer if it isn't full
741
;;	call	MIOS_MIDI_TxBufferFree
742
;;	bz	BufferIsFull
743
;;	movlw	0xf8	; (MIDI Clock)
744
;;	call	MIOS_MIDI_TxBufferPut
745
;;
746
;;  C_EXAMPLE:
747
;;
748
;;	// put a MIDI byte into the Tx Buffer if it isn't full
749
;;	if( MIOS_MIDI_TxBufferFree() ) {
750
;;	  MIOS_MIDI_TxBufferPut(0xf8);
751
;;	}
752
;;
753
;;  NOTE: <I>this function is for internal use within MIOS only!<BR>
754
;;  The MIOS_MIDI_TxBufferPut() function will wait if the buffer is full.</I>
755
;; --------------------------------------------------------------------------
756
MIOS_MIDI_TxBufferFree
757
	rcall	MIOS_MIDI_TxBufferUsed
758
	sublw	(MIOS_TX_BUFFER_END-MIOS_TX_BUFFER)
759
	return
760
 
761
;; --------------------------------------------------------------------------
762
;;  FUNCTION: MIOS_MIDI_TxBufferPut
763
;;  C_DECLARATION: void MIOS_MIDI_TxBufferPut(unsigned char b)
764
;;  DESCRIPTION: puts a byte onto the transmit buffer.<BR>
765
;;  If Tx buffer is full, the function will be suspended until one byte has been
766
;;  transmitted via MIDI.<BR>
767
;;  This function redirects outgoing bytes to the MBHP_IIC_MIDI module if it has
768
;;  been selected with the MIOS_MIDI_InterfaceSet or MIOS_MIDI_InterfaceAutoSet function
769
;;  IN:	  byte in WREG
770
;;  C_IN: byte to be transmitted in <b>
771
;;  OUT:  -
772
;;  C_OUT:  -
773
;;  USES: BSR, FSR1
774
;;  EXAMPLE:
775
;;
776
;;	;; put a MIDI byte into the Tx Buffer if it isn't full
777
;;	movlw	0xf8	; (MIDI Clock)
778
;;	call	MIOS_MIDI_TxBufferPut
779
;;
780
;;  C_EXAMPLE:
781
;;
782
;;	// put a MIDI byte into the Tx Buffer
783
;;	MIOS_MIDI_TxBufferPut(0xf8); // MIDI Clock
784
;;
785
;; --------------------------------------------------------------------------
786
MIOS_MIDI_TxBufferPut
787
	SET_BSR	MIOS_TX_BUFFER_TMP
788
	movwf	MIOS_TX_BUFFER_TMP, BANKED		; save byte which should be sent
789
 
790
	;; branch to IIC send function if IIC slave enabled
791
	SET_BSR	MIOS_IIC_MIDI_ADDR
792
	movf	MIOS_IIC_MIDI_ADDR, F, BANKED
793
	bnz	MIOS_MIDI_IIC_Send
794
 
795
	incf	MIOS_TX_BUFFER_TAIL, W, BANKED	; increment ringcounter, but don't save yet
796
	xorlw	(MIOS_TX_BUFFER_END&0xff)+1
797
	skpnz
798
	movlw	(MIOS_TX_BUFFER&0xff) ^ ((MIOS_TX_BUFFER_END&0xff)+1)
799
	xorlw	(MIOS_TX_BUFFER_END&0xff)+1
800
	cpfseq	MIOS_TX_BUFFER_HEAD, BANKED
801
	rgoto MIOS_MIDI_TxBufferPut_Ok
802
#if 0
803
	return					; prevent overrun
804
#else
805
	movf	MIOS_TX_BUFFER_TMP, W, BANKED
806
	rgoto	MIOS_MIDI_TxBufferPut		; repeat until buffer is free again
807
#endif
808
MIOS_MIDI_TxBufferPut_Ok
809
	IRQ_DISABLE				; disable interrupts to avoid a malfunction when a Tx IRQ happens here
810
	movwf	MIOS_TX_BUFFER_TAIL, BANKED	; save counter
811
	lfsr	FSR1, MIOS_TX_BUFFER		; prepare FSR
812
	movwf	FSR1L
813
	movf	MIOS_TX_BUFFER_TMP, W, BANKED	; push byte onto buffer
814
	movwf	INDF1
815
 
816
	bsf	PIE1, TXIE			; (re-)enable transmit IRQ
817
	IRQ_ENABLE				; enable interrupts again
818
	return
819
 
820
;; --------------------------------------------------------------------------
821
;;  FUNCTION: MIOS_MIDI_TxBufferGet
822
;;  C_DECLARATION: unsigned char MIOS_MIDI_TxBufferGet(void)
823
;;  DESCRIPTION: gets a byte from the transmit buffer
824
;;  IN:	  -
825
;;  C_IN:  -
826
;;  OUT:  byte to be transmitted in WREG
827
;;  C_OUT:  byte to be transmitted
828
;;  USES: BSR, FSR1
829
;;  EXAMPLE:
830
;;
831
;;	;; get a MIDI byte from the Tx Buffer if new byte is available
832
;;	call	MIOS_MIDI_TxBufferUsed
833
;;	bz	NoByteAvailable
834
;;	call	MIOS_MIDI_TxBufferGet
835
;;
836
;;  C_EXAMPLE:
837
;;
838
;;	unsigned char b;
839
;;
840
;;	// get a MIDI byte from the Tx Buffer if new byte is available
841
;;	if( MIOS_MIDI_TxBufferUsed() ) {
842
;;	  b = MIOS_MIDI_TxBufferGet();
843
;;	}
844
;;
845
;;  NOTE: <I>this function is for internal use within MIOS only!</I>
846
;; --------------------------------------------------------------------------
847
MIOS_MIDI_TxBufferGet
848
	SET_BSR	MIOS_TX_BUFFER_HEAD
849
	incf	MIOS_TX_BUFFER_HEAD, F, BANKED
850
	movlw	(MIOS_TX_BUFFER_END&0xff)+1
851
	cpfseq	MIOS_TX_BUFFER_HEAD, BANKED
852
	rgoto MIOS_MIDI_TxBufferGet_NoReset
853
	movlw	MIOS_TX_BUFFER & 0xff
854
	movwf	MIOS_TX_BUFFER_HEAD, BANKED
855
MIOS_MIDI_TxBufferGet_NoReset
856
	lfsr	FSR1, MIOS_TX_BUFFER
857
	movff	MIOS_TX_BUFFER_HEAD, FSR1L
858
	movf	INDF1, W
859
 
860
	;; call user hook
861
	CALL_IFCLR MIOS_BOX_STAT, MIOS_BOX_STAT_SUSPEND_USER, ACCESS, USER_MIDI_NotifyTx
862
 
863
	lfsr	FSR1, MIOS_TX_BUFFER
864
	movff	MIOS_TX_BUFFER_HEAD, FSR1L
865
	movf	INDF1, W
866
	return
867
 
868
;; --------------------------------------------------------------------------
869
;;  FUNCTION: MIOS_MIDI_TxBufferFlush
870
;;  C_DECLARATION: void MIOS_MIDI_TxBufferFlush(void)
871
;;  DESCRIPTION: waits until all MIDI bytes in the Tx buffer have been transmitted
872
;;  IN:	  -
873
;;  C_IN:  -
874
;;  OUT:  -
875
;;  C_OUT:  -
876
;;  USES: BSR, FSR1
877
;;  EXAMPLE:
878
;;
879
;;	;; wait until buffer is empty, thereafter send a bunch of new bytes
880
;;	call	MIOS_MIDI_TxBufferFlush
881
;;	movlw	0xf0
882
;;	call	MIOS_MIDI_TxBufferPut
883
;;	;;  ...
884
;;
885
;;  C_EXAMPLE:
886
;;
887
;;	// wait until buffer is empty, thereafter send a bunch of new bytes
888
;;	MIOS_MIDI_TxBufferFlush();
889
;;	MIOS_MIDI_TxBufferPut(0xf0);
890
;;	//  ...
891
;;
892
;; --------------------------------------------------------------------------
893
MIOS_MIDI_TxBufferFlush
894
	clrwdt
895
MIOS_MIDI_TxBufferFlush_WaitTx
896
	rcall	MIOS_MIDI_TxBufferUsed
897
	bnz	MIOS_MIDI_TxBufferFlush_WaitTx
898
	;; wait until byte has been sent
899
MIOS_MIDI_TxBufferFlush_Sync
900
	GOTO_IFCLR TXSTA, TRMT, ACCESS, MIOS_MIDI_TxBufferFlush_Sync
901
	return
902
 
903
;; --------------------------------------------------------------------------
904
;; internal function to send a byte via MBHP_IIC_MIDI
905
;; note that this module comes with a seperate package for optimized transfers
906
;; --------------------------------------------------------------------------
907
;; --------------------------------------------------------------------------
908
;;  IIC MIDI Send function
909
;;  In:	 byte to send in W
910
;;  Out: sent byte
911
;; --------------------------------------------------------------------------
912
MIOS_MIDI_IIC_Send
913
	;; temporary store value
914
	movwf	MIOS_MIDI_IIC_TMP, BANKED
915
 
916
	;; check if 0xff (control byte) should be sent - if so, we have to
917
	;; send it twice (one for entering command mode, one for exiting
918
	;; command mode + sending a 0xff at MIDI Out)
919
	xorlw	0xff
920
	bnz	MIOS_MIDI_IIC_Send_NotFF
921
MIOS_MIDI_IIC_Send_FF
922
	call	MIOS_MIDI_IIC_Send_FFOne ; first time
923
	;; second time...
924
 
925
MIOS_MIDI_IIC_Send_FFOne
926
MIOS_MIDI_IIC_Send_NotFF
927
 
928
	;; clear timeout counter (256 tries - more than enough!)
929
	clrf	MIOS_MIDI_IIC_RETRY_CTR, BANKED
930
 
931
MIOS_MIDI_IIC_SendRestart
932
	rcall	MIOS_MIDI_IIC_TransmitStart	; start transfer
933
	BRA_IFSET MIOS_BOX_STAT, MIOS_BOX_STAT_BS_AVAILABLE, ACCESS, MIOS_MIDI_IIC_SendTry
934
MIOS_MIDI_IIC_SendRetry
935
	call	MIOS_IIC_Stop		; stop transfer
936
	decfsz	MIOS_MIDI_IIC_RETRY_CTR, F, BANKED	; restart until counter reaches zero
937
	rgoto	MIOS_MIDI_IIC_SendRestart
938
 
939
	;; give up!
940
	bcf	MIOS_BOX_STAT, MIOS_BOX_STAT_BS_AVAILABLE ; notify that slave is not available
941
	rgoto	MIOS_MIDI_IIC_Send_End
942
 
943
MIOS_MIDI_IIC_SendTry
944
	;; try to send byte
945
	movf	MIOS_MIDI_IIC_TMP, W, BANKED
946
	call	MIOS_IIC_ByteSend
947
 
948
	;; retry if no acknowledge received
949
	BRA_IFCLR MIOS_BOX_STAT, MIOS_BOX_STAT_BS_AVAILABLE, ACCESS, MIOS_MIDI_IIC_SendRetry
950
 
951
	;; stop transfer
952
	call	MIOS_IIC_Stop
953
 
954
MIOS_MIDI_IIC_Send_End
955
	return
956
 
957
;; --------------------------------------------------------------------------
958
 
959
MIOS_MIDI_IIC_TransmitStart
960
	call	MIOS_IIC_Start		; start IIC
961
	movf	MIOS_IIC_MIDI_ADDR, W, BANKED	; send address (write transfer)
962
	andlw	0xfe			; ensure that read flag not set
963
	goto	MIOS_IIC_ByteSend
964
	;; (check MIOS_BOX_STAT, MIOS_BOX_STAT_BS_AVAILABLE after this function call!)
965
 
966
 
967
;; --------------------------------------------------------------------------
968
;;  FUNCTION: USER_MIDI_NotifyTx
969
;;  C_DECLARATION: not available in C - code has to be added to mios_wrapper
970
;;  DESCRIPTION: This function is called by MIOS before the transfer of
971
;;  a MIDI byte. It can be used to monitor the Tx activity or to do any
972
;;  other actions (e.g. to switch a pin for multiplexed MIDI Outs) before
973
;;  the byte will be sent.
974
;;
975
;;  Note that this is an interrupt service routine! Use FSR2 instead of FSR0
976
;;  and IRQ_TMPx instead of TMPx -- and make the routine as fast as possible!
977
;;  IN:	  transmitted byte in WREG
978
;;  OUT:  -
979
;;  ISR: yes
980
;; --------------------------------------------------------------------------
981
 
982
;; --------------------------------------------------------------------------
983
;;  FUNCTION: USER_MIDI_NotifyRx
984
;;  C_DECLARATION: not available in C - code has to be added to mios_wrapper
985
;;  DESCRIPTION: This function is called by MIOS when a MIDI byte has been
986
;;  received. It can be used to monitor the Rx activity or to do any
987
;;  action - e.g. to react on realtime events like MIDI clock (0xf8) with
988
;;  a minimum latency.
989
;;
990
;;  Note that this is an interrupt service routine! Use FSR2 instead of FSR0
991
;;  and IRQ_TMPx instead of TMPx -- and make the routine as fast as possible!
992
;;  IN:	  received byte in WREG
993
;;  OUT:  -
994
;;  ISR: yes
995
;; --------------------------------------------------------------------------