Fix some bugs about USBHost common codes.

Find some bugs in USBHost common codes. Bugs as below.
- USBHostMouse.cpp
 - Memory destroy will occur when the size of interrupt transfer is larger than 4 bytes.

- USBHostMSD.cpp
 - Type declaration of vender dependent.
     U16 -> uint16_t

- USBHostSerial.cpp
  - connected() will not be "true".
  - Communication with USBSerial will not start.
pull/844/head
Masao Hamanaka 2015-01-15 14:01:48 +09:00
parent 7726496957
commit 63cfe8da23
3 changed files with 14 additions and 3 deletions

View File

@ -47,6 +47,7 @@ bool USBHostMouse::connected() {
}
bool USBHostMouse::connect() {
int len_listen;
if (dev_connected) {
return true;
@ -69,7 +70,11 @@ bool USBHostMouse::connect() {
host->registerDriver(dev, mouse_intf, this, &USBHostMouse::init);
int_in->attach(this, &USBHostMouse::rxHandler);
host->interruptRead(dev, int_in, report, int_in->getSize(), false);
len_listen = int_in->getSize();
if (len_listen > sizeof(report)) {
len_listen = sizeof(report);
}
host->interruptRead(dev, int_in, report, len_listen, false);
dev_connected = true;
return true;
@ -109,6 +114,10 @@ void USBHostMouse::rxHandler() {
y = report[2];
z = report[3];
if (len_listen > sizeof(report)) {
len_listen = sizeof(report);
}
if (dev)
host->interruptRead(dev, int_in, report, len_listen, false);
}

View File

@ -303,7 +303,7 @@ int USBHostMSD::getMaxLun() {
int USBHostMSD::disk_initialize() {
USB_DBG("FILESYSTEM: init");
U16 i, timeout = 10;
uint16_t i, timeout = 10;
getMaxLun();

View File

@ -71,6 +71,7 @@ bool USBHostSerial::connect() {
{
USBHostSerialPort::connect(host,d,port_intf,bulk_in, bulk_out);
dev = d;
dev_connected = true;
}
}
}
@ -171,6 +172,7 @@ bool USBHostMultiSerial::connect() {
{
ports[port]->connect(host,d,port_intf[port],bulk_in, bulk_out);
dev = d;
dev_connected = true;
}
}
}
@ -242,7 +244,7 @@ void USBHostSerialPort::connect(USBHost* _host, USBDeviceConnected * _dev,
USB_INFO("New Serial device: VID:%04x PID:%04x [dev: %p - intf: %d]", dev->getVid(), dev->getPid(), dev, serial_intf);
dev->setName("Serial", serial_intf);
host->registerDriver(dev, serial_intf, this, &USBHostSerialPort::init);
//baud(9600);
baud(9600);
size_bulk_in = bulk_in->getSize();
size_bulk_out = bulk_out->getSize();
bulk_in->attach(this, &USBHostSerialPort::rxHandler);