Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 9 months ago. This question has been closed. Reason: Duplicate question
USBHostのインタラプト転送間隔について
LPC1768でUSBHostライブラリを用いてXboxONEのコントローラと通信しようとしています。 通信はできているのですが、パソコンとの通信と比較するとデータの受信間隔が大きいのです。 そのせいで受信できないパケットがあり、困っています。 パソコンとの通信では、最短8msごとにデータが受信できていたのですが、mbedとの通信では最短32msごとでしかデータを受信できません。 手持ちのマウスとの通信も試してみたのですが、パソコンとの通信では最短8msごとにデータを受信できたのに対し、mbedとの通信では最短32msごとでしかデータを受信できませんでした。 マウスとの通信では、下記のプログラムでonMouseEventが呼ばれる間隔をTimerで計りました。 パソコンとの通信はWiresharkでモニターしました。 何故最短32ms間隔でしかデータを受信できないのでしょうか、また、解決するにはどうすればよいでしょうか。
#include "mbed.h"
#include "USBHostMouse.h"
Serial pc(USBTX, USBRX);
DigitalOut led(LED1);
Timer timer;
void onMouseEvent(uint8_t buttons, int8_t x, int8_t y, int8_t z) {
printf("buttons: %d, x: %d, y: %d, z: %d\r\n", buttons, x, y, z);
std::printf("timer=%f\r\n", timer.read());
timer.reset();
timer.start();
}
void mouse_task(void const *) {
USBHostMouse mouse;
while(1) {
// try to connect a USB mouse
while(!mouse.connect())
Thread::wait(500);
// when connected, attach handler called on mouse event
mouse.attachEvent(onMouseEvent);
// wait until the mouse is disconnected
while(mouse.connected())
Thread::wait(500);
}
}
int main() {
pc.baud(115200);
pc.printf("----------\r\n");
Thread mouseTask(mouse_task, NULL, osPriorityNormal, 256 * 4);
timer.start();
while(1) {
led=!led;
Thread::wait(500);
}
}