more ci fix

This commit is contained in:
hathach
2025-02-12 13:58:01 +07:00
parent 7c405236cf
commit 86d371fb79
4 changed files with 117 additions and 98 deletions

View File

@@ -109,8 +109,7 @@
// only hub class is enabled // only hub class is enabled
#define CFG_TUH_HUB 1 #define CFG_TUH_HUB 1
// max device support (excluding hub device) // max device support (excluding hub device): 1 hub typically has 4 ports
// 1 hub typically has 4 ports
#define CFG_TUH_DEVICE_MAX (3*CFG_TUH_HUB + 1) #define CFG_TUH_DEVICE_MAX (3*CFG_TUH_HUB + 1)
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -23,8 +23,8 @@
* *
*/ */
#include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include "bsp/board_api.h" #include "bsp/board_api.h"
@@ -44,16 +44,19 @@ void led_blinking_task(void);
void midi_host_rx_task(void); void midi_host_rx_task(void);
/*------------- MAIN -------------*/ /*------------- MAIN -------------*/
int main(void) int main(void) {
{
board_init(); board_init();
printf("TinyUSB Host MIDI Example\r\n"); printf("TinyUSB Host MIDI Example\r\n");
tusb_init(); // init host stack on configured roothub port
tusb_rhport_init_t host_init = {
.role = TUSB_ROLE_HOST,
.speed = TUSB_SPEED_AUTO
};
tusb_init(BOARD_TUH_RHPORT, &host_init);
while (1) while (1) {
{
tuh_task(); tuh_task();
led_blinking_task(); led_blinking_task();
midi_host_rx_task(); midi_host_rx_task();
@@ -67,8 +70,7 @@ int main(void)
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// Blinking Task // Blinking Task
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
void led_blinking_task(void) void led_blinking_task(void) {
{
const uint32_t interval_ms = 1000; const uint32_t interval_ms = 1000;
static uint32_t start_ms = 0; static uint32_t start_ms = 0;
@@ -85,15 +87,12 @@ void led_blinking_task(void)
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// MIDI host receive task // MIDI host receive task
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
void midi_host_rx_task(void) void midi_host_rx_task(void) {
{
// device must be attached and have at least one endpoint ready to receive a message // device must be attached and have at least one endpoint ready to receive a message
if (!midi_dev_addr || !tuh_midi_configured(midi_dev_addr)) if (!midi_dev_addr || !tuh_midi_configured(midi_dev_addr)) {
{
return; return;
} }
if (tuh_midih_get_num_rx_cables(midi_dev_addr) < 1) if (tuh_midih_get_num_rx_cables(midi_dev_addr) < 1) {
{
return; return;
} }
tuh_midi_read_poll(midi_dev_addr); tuh_midi_read_poll(midi_dev_addr);
@@ -108,8 +107,7 @@ void midi_host_rx_task(void)
// can be used to parse common/simple enough descriptor. // can be used to parse common/simple enough descriptor.
// Note: if report descriptor length > CFG_TUH_ENUMERATION_BUFSIZE, it will be skipped // Note: if report descriptor length > CFG_TUH_ENUMERATION_BUFSIZE, it will be skipped
// therefore report_desc = NULL, desc_len = 0 // therefore report_desc = NULL, desc_len = 0
void tuh_midi_mount_cb(uint8_t dev_addr, uint8_t in_ep, uint8_t out_ep, uint8_t num_cables_rx, uint16_t num_cables_tx) void tuh_midi_mount_cb(uint8_t dev_addr, uint8_t in_ep, uint8_t out_ep, uint8_t num_cables_rx, uint16_t num_cables_tx) {
{
(void) in_ep; (void) in_ep;
(void) out_ep; (void) out_ep;
(void) num_cables_rx; (void) num_cables_rx;
@@ -122,8 +120,7 @@ void tuh_midi_mount_cb(uint8_t dev_addr, uint8_t in_ep, uint8_t out_ep, uint8_t
} }
// Invoked when device with hid interface is un-mounted // Invoked when device with hid interface is un-mounted
void tuh_midi_umount_cb(uint8_t dev_addr, uint8_t instance) void tuh_midi_umount_cb(uint8_t dev_addr, uint8_t instance) {
{
(void) dev_addr; (void) dev_addr;
(void) instance; (void) instance;
@@ -131,15 +128,12 @@ void tuh_midi_umount_cb(uint8_t dev_addr, uint8_t instance)
midi_dev_addr = 0; midi_dev_addr = 0;
} }
void tuh_midi_rx_cb(uint8_t dev_addr, uint32_t num_packets) void tuh_midi_rx_cb(uint8_t dev_addr, uint32_t num_packets) {
{ if (midi_dev_addr != dev_addr) {
if (midi_dev_addr != dev_addr)
{
return; return;
} }
if(num_packets == 0) if (num_packets == 0) {
{
return; return;
} }
@@ -152,7 +146,6 @@ void tuh_midi_rx_cb(uint8_t dev_addr, uint32_t num_packets)
TU_LOG1_MEM(buffer, bytes_read, 2); TU_LOG1_MEM(buffer, bytes_read, 2);
} }
void tuh_midi_tx_cb(uint8_t dev_addr) void tuh_midi_tx_cb(uint8_t dev_addr) {
{
(void) dev_addr; (void) dev_addr;
} }

View File

@@ -23,15 +23,15 @@
* *
*/ */
#ifndef _TUSB_CONFIG_H_ #ifndef TUSB_CONFIG_H_
#define _TUSB_CONFIG_H_ #define TUSB_CONFIG_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// COMMON CONFIGURATION // Common Configuration
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// defined by compiler flags for flexibility // defined by compiler flags for flexibility
@@ -39,18 +39,18 @@ extern "C" {
#error CFG_TUSB_MCU must be defined #error CFG_TUSB_MCU must be defined
#endif #endif
#if CFG_TUSB_MCU == OPT_MCU_LPC43XX || CFG_TUSB_MCU == OPT_MCU_LPC18XX || CFG_TUSB_MCU == OPT_MCU_MIMXRT10XX // Espressif IDF requires "freertos/" prefix in include path
#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_HOST | OPT_MODE_HIGH_SPEED) #if TUSB_MCU_VENDOR_ESPRESSIF
#else #define CFG_TUSB_OS_INC_PATH freertos/
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_HOST
#endif #endif
#ifndef CFG_TUSB_OS #ifndef CFG_TUSB_OS
#define CFG_TUSB_OS OPT_OS_NONE #define CFG_TUSB_OS OPT_OS_NONE
#endif #endif
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build #ifndef CFG_TUSB_DEBUG
// #define CFG_TUSB_DEBUG 0 #define CFG_TUSB_DEBUG 0
#endif
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment. /* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
* Tinyusb use follows macros to declare transferring memory so that they can be put * Tinyusb use follows macros to declare transferring memory so that they can be put
@@ -59,38 +59,63 @@ extern "C" {
* - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") )) * - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") ))
* - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4))) * - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4)))
*/ */
#ifndef CFG_TUSB_MEM_SECTION #ifndef CFG_TUH_MEM_SECTION
#define CFG_TUSB_MEM_SECTION #define CFG_TUH_MEM_SECTION
#endif #endif
#ifndef CFG_TUSB_MEM_ALIGN #ifndef CFG_TUH_MEM_ALIGN
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4))) #define CFG_TUH_MEM_ALIGN __attribute__ ((aligned(4)))
#endif #endif
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// CONFIGURATION // Host Configuration
//--------------------------------------------------------------------
// Enable Host stack
#define CFG_TUH_ENABLED 1
#if CFG_TUSB_MCU == OPT_MCU_RP2040
// #define CFG_TUH_RPI_PIO_USB 1 // use pio-usb as host controller
// #define CFG_TUH_MAX3421 1 // use max3421 as host controller
// host roothub port is 1 if using either pio-usb or max3421
#if (defined(CFG_TUH_RPI_PIO_USB) && CFG_TUH_RPI_PIO_USB) || (defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421)
#define BOARD_TUH_RHPORT 1
#endif
#endif
// Default is max speed that hardware controller could support with on-chip PHY
#define CFG_TUH_MAX_SPEED BOARD_TUH_MAX_SPEED
//------------------------- Board Specific --------------------------
// RHPort number used for host can be defined by board.mk, default to port 0
#ifndef BOARD_TUH_RHPORT
#define BOARD_TUH_RHPORT 0
#endif
// RHPort max operational speed can defined by board.mk
#ifndef BOARD_TUH_MAX_SPEED
#define BOARD_TUH_MAX_SPEED OPT_MODE_DEFAULT_SPEED
#endif
//--------------------------------------------------------------------
// Driver Configuration
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// Size of buffer to hold descriptors and other data used for enumeration // Size of buffer to hold descriptors and other data used for enumeration
#define CFG_TUH_ENUMERATION_BUFSIZE 256 #define CFG_TUH_ENUMERATION_BUFSIZE 256
#define CFG_TUH_HUB 1 #define CFG_TUH_HUB 1
#define CFG_TUH_CDC 0
#define CFG_TUH_HID 0 // typical keyboard + mouse device can have 3-4 HID interfaces
#define CFG_TUH_MIDI 1 // there will be at most one MIDIStreaming Interface descriptor #define CFG_TUH_MIDI 1 // there will be at most one MIDIStreaming Interface descriptor
#define CFG_TUH_MSC 0
#define CFG_TUH_VENDOR 0
// max device support (excluding hub device) // max device support (excluding hub device): 1 hub typically has 4 ports
#define CFG_TUH_DEVICE_MAX (CFG_TUH_HUB ? 4 : 1) // hub typically has 4 ports #define CFG_TUH_DEVICE_MAX (3*CFG_TUH_HUB + 1)
#define CFG_MIDI_HOST_DEVSTRINGS 1 #define CFG_MIDI_HOST_DEVSTRINGS 1
//------------- HID -------------//
#define CFG_TUH_HID_EPIN_BUFSIZE 64
#define CFG_TUH_HID_EPOUT_BUFSIZE 64
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* _TUSB_CONFIG_H_ */ #endif

View File

@@ -266,7 +266,9 @@ int board_getchar(void) {
#if CFG_TUH_ENABLED && defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421 #if CFG_TUH_ENABLED && defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
void max3421_int_handler(uint gpio, uint32_t event_mask) { void max3421_int_handler(uint gpio, uint32_t event_mask) {
if (!(gpio == MAX3421_INTR_PIN && event_mask & GPIO_IRQ_EDGE_FALL)) return; if (!(gpio == MAX3421_INTR_PIN && event_mask & GPIO_IRQ_EDGE_FALL)) {
return;
}
tuh_int_handler(BOARD_TUH_RHPORT, true); tuh_int_handler(BOARD_TUH_RHPORT, true);
} }