Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a252bb8
create README_midi_host.md
rppicomidi Dec 1, 2021
17bcd39
Make pedantic change to MS ENDPOINT
rppicomidi Dec 1, 2021
9f928b0
Fix encoding of the CIN field for note on and note off
rppicomidi Dec 1, 2021
326a8ef
Create midi_cs_desc_endpoint_t structure
rppicomidi Dec 1, 2021
319c194
Add support for bulk endpoints
rppicomidi Dec 1, 2021
e2aaca6
Create midi_host.c/h
rppicomidi Dec 1, 2021
a73a95e
Integrate MIDI host code to the stack
rppicomidi Dec 1, 2021
5ba5287
Create MIDI host test code
rppicomidi Dec 1, 2021
72064dd
Fix command line build failure
rppicomidi Dec 3, 2021
8144761
Do not try to manage IN endpoint NAK flag
rppicomidi Dec 9, 2021
e158447
Add support for forcing the LAST_BUFF flag to be set for an endpoint …
rppicomidi Dec 9, 2021
ad5a510
Add a more useful callback for the app to manage MIDI host IN endpoin…
rppicomidi Dec 9, 2021
fe8ae2c
create tuh_midi_stream_read() utility
rppicomidi Dec 9, 2021
fb0849e
Demonstrate MIDI Host IN endpoint works with OUT endpoint disabled
rppicomidi Dec 9, 2021
a99545c
Try to fix build error for device-side USB RP2040 build
rppicomidi Dec 10, 2021
e30708a
Remove dead code
rppicomidi Dec 10, 2021
d800bcf
Create API for alternating between IN endpoint and OUT endpoint
rppicomidi Dec 10, 2021
55393fd
Fix MIDI host example app to support both IN endpoint and OUT endpoint
rppicomidi Dec 10, 2021
5e4364f
Fix random bulk transfer start failure
rppicomidi Dec 12, 2021
9feff49
Remove unnecessary need_to_poll_device flag from test app
rppicomidi Dec 12, 2021
bb7e564
Always call tuh_midi_rx_cb on IN complete
rppicomidi Dec 12, 2021
b919951
Assert if usbh_edpt_xfer fails
rppicomidi Dec 12, 2021
82e78f5
make variable names in busy logic consistent
rppicomidi Dec 12, 2021
1c69bd1
Add debug prints to test tx
rppicomidi Dec 22, 2021
8a9de2b
Remove dead code
rppicomidi Dec 22, 2021
59c3b82
modify the midi host module to support use with a hub
rppicomidi Dec 22, 2021
946a108
Disable RP2040 auto NAK retry for bulk IN transfers
rppicomidi Dec 22, 2021
d5b2f04
Flush the transmit queue right after a successful IN transfer
rppicomidi Dec 22, 2021
89beebf
fix cable number bug on receive
rppicomidi Dec 23, 2021
b7af5ef
Shorten NAK auto-retry interval to 100us
rppicomidi Dec 23, 2021
5eeee32
Remove unnecessary midi stream flush
rppicomidi Dec 23, 2021
5ad9e8c
Make example more keyboard friendly
rppicomidi Dec 23, 2021
0ab2127
Handle real time system messages mid stream
rppicomidi Jan 11, 2022
95020e4
handle sending incomplete streams
rppicomidi Jan 11, 2022
537150f
Fix typos in midi_host.c
rppicomidi Jan 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/host/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ family_initialize_project(tinyusb_host_examples ${CMAKE_CURRENT_LIST_DIR})
# family_add_subdirectory will filter what to actually add based on selected FAMILY
family_add_subdirectory(cdc_msc_hid)
family_add_subdirectory(hid_controller)
family_add_subdirectory(midi)
Empty file.
28 changes: 28 additions & 0 deletions examples/host/midi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 3.5)

include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/family_support.cmake)

# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})

project(${PROJECT})

# Checks this example is valid for the family and initializes the project
family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})

add_executable(${PROJECT})

# Example source
target_sources(${PROJECT} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src/midi_app.c
${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
)

# Example include
target_include_directories(${PROJECT} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src
)

# Configure compilation flags and libraries for the example... see the corresponding function
# in hw/bsp/FAMILY/family.cmake for details.
family_configure_host_example(${PROJECT})
29 changes: 29 additions & 0 deletions examples/host/midi/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
include ../../../tools/top.mk
include ../../make.mk

INC += \
src \
$(TOP)/hw \

# Example source
EXAMPLE_SOURCE += $(wildcard src/*.c)
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))

# TODO: suppress warning caused by host stack
CFLAGS += -Wno-error=cast-align -Wno-error=null-dereference

# TinyUSB Host Stack source
SRC_C += \
src/class/cdc/cdc_host.c \
src/class/hid/hid_host.c \
src/class/midi/midi_host.c \
src/class/msc/msc_host.c \
src/host/hub.c \
src/host/usbh.c \
src/host/usbh_control.c \
src/portable/ehci/ehci.c \
src/portable/ohci/ohci.c \
src/portable/nxp/transdimension/hcd_transdimension.c \
src/portable/nxp/lpc17_40/hcd_lpc17_40.c

include ../../rules.mk
28 changes: 28 additions & 0 deletions examples/host/midi/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 3.5)

include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/family_support.cmake)

# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})

project(${PROJECT})

# Checks this example is valid for the family and initializes the project
family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})

add_executable(${PROJECT})

# Example source
target_sources(${PROJECT} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src/midi_app.c
${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
)

# Example include
target_include_directories(${PROJECT} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src
)

# Configure compilation flags and libraries for the example... see the corresponding function
# in hw/bsp/FAMILY/family.cmake for details.
family_configure_host_example(${PROJECT})
27 changes: 27 additions & 0 deletions examples/host/midi/src/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
include ../../../tools/top.mk
include ../../make.mk

INC += \
src \
$(TOP)/hw \

# Example source
EXAMPLE_SOURCE += $(wildcard src/*.c)
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))

# TODO: suppress warning caused by host stack
CFLAGS += -Wno-error=cast-align -Wno-error=null-dereference

# TinyUSB Host Stack source
SRC_C += \
src/class/midi/midi_host.c \
src/host/hub.c \
src/host/usbh.c \
src/host/usbh_control.c \
src/portable/ehci/ehci.c \
src/portable/ohci/ohci.c \
src/portable/nxp/transdimension/hcd_transdimension.c \
src/portable/nxp/lpc17_40/hcd_lpc17_40.c \
src/portable/raspberrypi/rp2040/hcd_rp2040.c

include ../../rules.mk
85 changes: 85 additions & 0 deletions examples/host/midi/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Ha Thach (tinyusb.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "bsp/board.h"
#include "tusb.h"
#if CFG_TUH_MIDI

//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF PROTYPES
//--------------------------------------------------------------------+
void led_blinking_task(void);

extern void midi_host_app_task(void);

/*------------- MAIN -------------*/
int main(void)
{
board_init();

printf("TinyUSB Host MIDI Example\r\n");

tusb_init();

while (1)
{
// tinyusb host task
tuh_task();
led_blinking_task();

midi_host_app_task();

}

return 0;
}

#endif

//--------------------------------------------------------------------+
// TinyUSB Callbacks
//--------------------------------------------------------------------+

//--------------------------------------------------------------------+
// Blinking Task
//--------------------------------------------------------------------+
void led_blinking_task(void)
{
const uint32_t interval_ms = 1000;
static uint32_t start_ms = 0;

static bool led_state = false;

// Blink every interval ms
if ( board_millis() - start_ms < interval_ms) return; // not enough time
start_ms += interval_ms;

board_led_write(led_state);
led_state = 1 - led_state; // toggle
}
Loading