-
Notifications
You must be signed in to change notification settings - Fork 0
/
serialmidi.cpp
127 lines (101 loc) · 2.63 KB
/
serialmidi.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include "serialmidi.h"
#include "global_obj.h"
RingBuffer<uint8_t, 200> usartBufferIn;
RingBuffer<uint8_t, 100> usartBufferOut;
CSerialDevice_irq_wrapper::CSerialDevice_irq_wrapper(CSoundManager *pm_SoundManager, CInterruptSystem *pInterruptSystem , boolean bUseFIQ)
//CSerialDevice_irq_wrapper::CSerialDevice_irq_wrapper(CInterruptSystem *pInterruptSystem , boolean bUseFIQ)
:CSerialDevice_irq(pInterruptSystem ,bUseFIQ) //,
// pm_SoundManager (pm_SoundManager)
{
}
CSerialDevice_irq_wrapper::~CSerialDevice_irq_wrapper(void){
}
void CSerialDevice_irq_wrapper::InterruptHandler_ext(RingBuffer<u8,200> *pRXFifo){
u8 cmd = 0;
u8 note = 0;
u8 vel = 0;
u16 data16=0;
// data16 = pRXFifo->remove();
// if (data16 & 8000){
// return;
// }
// u8 data = (u8) data16;
// if ((data > 0xBF) && (data < 0xF8))
// {
// m_MIDIRunningStatus = 0;
// m_MIDIState = 0;
// }
// if (data & 0x80)
// {
// m_MIDIRunningStatus = data;
// m_MIDIState = 1;
// cmd = data;
// }
// if (data < 0x80)
// {
// if (m_MIDIState == 1)
// {
// note = data;
// m_MIDIState++;
// }
// }
// if (m_MIDIState == 2)
// {
// vel = data;
// m_MIDIState = 1;
// cmd = m_MIDIRunningStatus;
// if (m_MIDIRunningStatus == 0x90){ // Note On
// if (vel != 0){
// pm_SoundManager->NoteOn(cmd,note,vel);
// // m_LVGScreen.setText("Note On ");
// SMsg.cmd = NOTE_ON;
// m_LVGScreen.PutScreen(SMsg);
// }else{
// pm_SoundManager->NoteOff(cmd,note,0);
// SMsg.cmd = NOTE_OFF;
// m_LVGScreen.PutScreen(SMsg);
// // m_LVGScreen.setText("Note Off ");
// }
// }else if (m_MIDIRunningStatus == 0x80){ // Note Off
// pm_SoundManager->NoteOff(cmd,note,0);
// SMsg.cmd = NOTE_OFF;
// m_LVGScreen.PutScreen(SMsg);
// // m_LVGScreen.setText("Note Off ");
// }
// }
// pm_SoundManager->Process();
// out_led3.Invert();
}
CSerialMIDI::CSerialMIDI (CSoundManager *pm_SoundManager, CInterruptSystem *pInterruptSystem , boolean bUseFIQ)
: pm_SoundManager (pm_SoundManager),
m_Serial(pm_SoundManager,pInterruptSystem,bUseFIQ)
{
// OutPin.Write(0);
}
CSerialMIDI::~CSerialMIDI (void)
{
}
boolean CSerialMIDI::Initialize (void)
{
if (m_Serial.Initialize(31250))
{
m_bUseSerial = TRUE;
return TRUE;
}
return TRUE;
}
boolean CSerialMIDI::checkMIDI(void)
{
u8 Buffer[20];
int nResult = m_Serial.Read(Buffer, sizeof Buffer);
if (nResult <= 0)
{
return FALSE;
}
// out_led1.Invert();
return TRUE;
}
void CSerialMIDI::FlushMIDIOut(void)
{
m_Serial.TX_Flush();
}