Teensy 3.6 USBHost to CP2104

WillRow

New member
Hello,

I am having issues doing USBSerial communication between the Teensy 3.6 and the CP2104. The example code I'm using is:

Code:
// Simple test of USB Host Mouse/Keyboard
//
// This example is in the public domain

#include <Arduino.h>
#include "USBHost_t36.h"
#define USBBAUD 115200
uint32_t baud = USBBAUD;
uint32_t format = USBHOST_SERIAL_8N1;
USBHost myusb;
USBSerial userial(myusb);

USBDriver *drivers[] = {&userial};
#define CNT_DEVICES (sizeof(drivers)/sizeof(drivers[0]))
const char * driver_names[CNT_DEVICES] = { "USERIAL1" };
bool driver_active[CNT_DEVICES] = {true};

void setup()
{
  pinMode(13, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  for (int i = 0; i < 5; i++) {
    digitalWrite(2, HIGH);
    delayMicroseconds(50);
    digitalWrite(2, LOW);
    delayMicroseconds(50);
  }
  while (!Serial && (millis() < 5000)) ; // wait for Arduino Serial Monitor
  Serial.println("\n\nUSB Host Testing - Serial");
  myusb.begin();
  userial.begin(baud,format);
}

bool userial_prev = false;
void loop(){
  if (userial && !userial_prev) {
    userial.begin(baud ,format);
  }
  userial_prev = userial;  // remember the current state of being connected. 

  // Print out information about different devices.
  for (uint8_t i = 0; i < CNT_DEVICES; i++) {
    if (*drivers[i] != driver_active[i]) {
      if (driver_active[i]) {
        Serial.printf("*** Device %s - disconnected ***\n", driver_names[i]);
        driver_active[i] = false;
      } else {
        Serial.printf("*** Device %s %x:%x - connected ***\n", driver_names[i], drivers[i]->idVendor(), drivers[i]->idProduct());
        driver_active[i] = true;

        const uint8_t *psz = drivers[i]->manufacturer();
        if (psz && *psz) Serial.printf("  manufacturer: %s\n", psz);
        psz = drivers[i]->product();
        if (psz && *psz) Serial.printf("  product: %s\n", psz);
        psz = drivers[i]->serialNumber();
        if (psz && *psz) Serial.printf("  Serial: %s\n", psz);

        // If this is a new Serial device.
        // if (drivers[i] == &userial) {
        //   Serial.println("Try to start Serial...");
        //   // Lets try first outputting something to our USerial to see if it will go out...
        //   userial.begin(baud,format);

        // }
      }
    }
  }

  while (Serial.available()) {
    userial.write(Serial.read());
  }

  while (userial.available()) {
    Serial.println("USerial Available");
    Serial.write(userial.read());
  }
}

The CP2104 is correctly identified but I can then not communicate, the output log after enabling debugging is:

Code:
port change: 10001803
    connect
  begin reset
port change: 10001805
  port enabled
  end recovery
new_Device: 12 Mbit/sec
new_Pipe
enumeration:
enumeration:
enumeration:
Device Descriptor:
  12 01 00 02 00 00 00 40 C4 10 60 EA 00 01 01 02 03 01 
    VendorID = 10C4, ProductID = EA60, Version = 0100
    Class/Subclass/Protocol = 0 / 0 / 0
    Number of Configurations = 1
enumeration:
enumeration:
Manufacturer: Silicon Labs
enumeration:
Product: CP2104 USB to UART Bridge Controller
enumeration:
Serial Number: 025B6C6B
enumeration:
Config data length = 32
enumeration:
Configuration Descriptor:
  09 02 20 00 01 01 00 80 32 
    NumInterfaces = 1
    ConfigurationValue = 1
  09 04 00 00 02 FF 00 00 02 
    Interface = 0
    Number of endpoints = 2
    Class/Subclass/Protocol = 255 / 0 / 0
  07 05 01 02 40 00 00 
    Endpoint = 1 OUT
    Type = Bulk
    Max Size = 64
    Polling Interval = 0
  07 05 82 02 40 00 00 
    Endpoint = 2 IN
    Type = Bulk
    Max Size = 64
    Polling Interval = 0
enumeration:
USBSerial claim this=1FFF2020
vid=10C4, pid=EA60, bDeviceClass = 0, bDeviceSubClass = 0, bDeviceProtocol = 0
09 04 00 00 02 FF 00 00 02 07 05 01 02 40 00 00 07 05 82 02 40 00 00 
len = 23
USBSerial, rxep=2(64), txep=1(64)
  rx buffer size:196
  tx buffer size:196
new_Pipe
new_Pipe
CP210X:  0x41, 0x11, 0, 0, 0 - reset port
control callback (serial) F
control callback (serial) E
control callback (serial) C
control callback (serial) 8
ERROR Followup
    remain on followup list
    remain on followup list
    remain on followup list
*** Device USERIAL1 10c4:ea60 - connected ***
  manufacturer: Silicon Labs
  product: CP2104 USB to UART Bridge Controller

I would really appreciate any help with this.
 
Back
Top