You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Are there any known issues using TinyUSB as a host to connect to a mobile phone's CDC interface please? I'm using the Arduino port with a Waveshare RP-2040 Zero.
The waveshare is powered and I can get it to enumerate HIDs (mice and keyboard). I pared right down to the bare bones but tuh_cdc_mount_cb() just doesn't seem to be called when the phone is connected as the LED doesn't change colour (debug probe on order!)
This version is based on Adafruit's serial_host_bridge:
#include <FastLED.h>
#define NUM_LEDS 1 // Single LED
#define DATA_PIN 16 // Waveshare RP-2040 Zero
// Define the array of leds
CRGB leds[NUM_LEDS];
int mounted=CRGB::Red;
#include "Adafruit_TinyUSB.h"
// CDC Host object
Adafruit_USBH_CDC SerialHost;
const uint32_t interval_ms = 500;
uint32_t start_ms = 0;
bool led_state = false;
void setup() {
USBHost.begin(0);
FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS); // GRB ordering is typical
// Initialize SerialHost
SerialHost.begin(115200);
}
void loop() {
USBHost.task();
// Blink every interval ms
if ( millis() - start_ms >= interval_ms) {
start_ms += interval_ms;
leds[0] = (led_state ? mounted : CRGB::Black);
FastLED.show();
led_state = 1 - led_state; // toggle
}
}
//--------------------------------------------------------------------+
// TinyUSB Host callbacks
//--------------------------------------------------------------------+
extern "C" {
// Invoked when a device with CDC interface is mounted
// idx is index of cdc interface in the internal pool.
void tuh_cdc_mount_cb(uint8_t idx) {
// bind SerialHost object to this interface index
SerialHost.mount(idx);
leds[0] = CRGB::Green;
}
// Invoked when a device with CDC interface is unmounted
void tuh_cdc_umount_cb(uint8_t idx) {
SerialHost.umount(idx);
leds[0] = CRGB::Orange;
}
}
My blinken lights remain firmly on red unless I place similar LED hooks in tuh_mount_cb but then they are only called for 'regular' USB devices.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Are there any known issues using TinyUSB as a host to connect to a mobile phone's CDC interface please? I'm using the Arduino port with a Waveshare RP-2040 Zero.
The waveshare is powered and I can get it to enumerate HIDs (mice and keyboard). I pared right down to the bare bones but tuh_cdc_mount_cb() just doesn't seem to be called when the phone is connected as the LED doesn't change colour (debug probe on order!)
This version is based on Adafruit's serial_host_bridge:
My blinken lights remain firmly on red unless I place similar LED hooks in tuh_mount_cb but then they are only called for 'regular' USB devices.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions