aboutsummaryrefslogtreecommitdiff
path: root/wirish
diff options
context:
space:
mode:
authormlundinse <lundin@mlu.mine.nu>2013-05-10 17:06:53 +0200
committermlundinse <lundin@mlu.mine.nu>2013-05-10 17:06:53 +0200
commita96a2bd87b546e8a109a3c2e680e7615d11316ab (patch)
treec09523a6725264d955aa37bad62be8b83278c12f /wirish
parent6b2eff72c8038bca04e4a0591c05b4a3ac6afa33 (diff)
Use 32 bit midiusb messages
Integrated Donald Delmar Davis work to use 32bit midimessages for MIDI USB, more cleanup is stiill needed
Diffstat (limited to 'wirish')
-rw-r--r--wirish/include/wirish/usb_midi.h17
-rw-r--r--wirish/usb_midi.cpp25
2 files changed, 18 insertions, 24 deletions
diff --git a/wirish/include/wirish/usb_midi.h b/wirish/include/wirish/usb_midi.h
index 0e2d4f0..eca197c 100644
--- a/wirish/include/wirish/usb_midi.h
+++ b/wirish/include/wirish/usb_midi.h
@@ -42,7 +42,7 @@
/**
* @brief Virtual serial terminal.
*/
-class USBMidi : public Print {
+class USBMidi {
public:
USBMidi(void);
@@ -50,14 +50,13 @@ public:
void end(void);
uint32 available(void);
-
- uint32 read(void *buf, uint32 len);
- uint8 read(void);
-
- void write(uint8);
- void write(const char *str);
- void write(const void*, uint32);
-
+
+ uint32 readPackets(void *buf, uint32 len);
+ uint32 readPacket(void);
+
+ void writePacket(uint32);
+ void writePackets(const void*, uint32);
+
uint8 isConnected();
uint8 pending();
};
diff --git a/wirish/usb_midi.cpp b/wirish/usb_midi.cpp
index 5a48efb..5b0fc97 100644
--- a/wirish/usb_midi.cpp
+++ b/wirish/usb_midi.cpp
@@ -64,15 +64,11 @@ void USBMidi::end(void) {
#endif
}
-void USBMidi::write(uint8 ch) {
- this->write(&ch, 1);
+void USBMidi::writePacket(uint32 p) {
+ this->writePackets(&p, 1);
}
-void USBMidi::write(const char *str) {
- this->write(str, strlen(str));
-}
-
-void USBMidi::write(const void *buf, uint32 len) {
+void USBMidi::writePackets(const void *buf, uint32 len) {
if (!this->isConnected() || !buf) {
return;
}
@@ -84,8 +80,7 @@ void USBMidi::write(const void *buf, uint32 len) {
uint32 sent = 0;
while (txed < len && (millis() - start < USB_TIMEOUT)) {
-// sent = usb_midi_tx_buffered((const uint8*)buf + txed, len - txed);
- sent = usb_midi_tx((const uint8*)buf + txed, len - txed);
+ sent = usb_midi_tx((const uint32*)buf + txed, len - txed);
txed += sent;
if (old_txed != txed) {
start = millis();
@@ -106,24 +101,24 @@ uint32 USBMidi::available(void) {
return usb_midi_data_available();
}
-uint32 USBMidi::read(void *buf, uint32 len) {
+uint32 USBMidi::readPackets(void *buf, uint32 len) {
if (!buf) {
return 0;
}
uint32 rxed = 0;
while (rxed < len) {
- rxed += usb_midi_rx((uint8*)buf + rxed, len - rxed);
+ rxed += usb_midi_rx((uint32*)buf + rxed, len - rxed);
}
return rxed;
}
/* Blocks forever until 1 byte is received */
-uint8 USBMidi::read(void) {
- uint8 b;
- this->read(&b, 1);
- return b;
+uint32 USBMidi::readPacket(void) {
+ uint32 p;
+ this->readPackets(&p, 1);
+ return p;
}
uint8 USBMidi::pending(void) {