Page 1 of 1

v-usb and matrix led hangups

Posted: Thu Dec 24, 2015 5:58 am
by Davo
I'm trying to accept up to eight bytes through a USB port and display them on an 8x8 matrix controlled by a MAX7219. With some slight modifications to the hid-data example, I managed to do this. When I send bytes to the 328p, the display updates instantly, but then hidtool hangs like this for about five seconds:

Code: Select all

$ sudo ./hidtool write 0x66,0x66
Error sending message: Connection timed out
error writing data: Communication error with device


Here are the changes I made to the hid-data example main.c:

Code: Select all

#include "ledmatrix7219d88.h"
uint8_t rows[8];
...
uchar   usbFunctionWrite(uchar *data, uchar len)
{
    uchar i;

    if (len > bytesRemaining)
        len = bytesRemaining;
    bytesRemaining -= len;
    for (i = 0; i < len; i++)
        rows[currentAddress++] = data[i];
    return bytesRemaining;
}
...
usbMsgLen_t usbFunctionSetup(uchar data[8])
{
    usbRequest_t    *rq = (void *)data;

    if((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_CLASS){    /* HID class request */
        if(rq->bRequest == USBRQ_HID_GET_REPORT){  /* wValue: ReportType (highbyte), ReportID (lowbyte) */
            /* since we have only one report type, we can ignore the report-ID */
            bytesRemaining = 8;
            currentAddress = 0;
            return USB_NO_MSG;  /* use usbFunctionRead() to obtain data */
        }else if(rq->bRequest == USBRQ_HID_SET_REPORT){
            /* since we have only one report type, we can ignore the report-ID */
            bytesRemaining = 8;
            currentAddress = 0;
            return USB_NO_MSG;  /* use usbFunctionWrite() to receive data from host */
        }
    }else{
        /* ignore vendor type requests, we don't use any */
    }
    return 0;
}
...
ledmatrix7219d88_setmatrix(0, rows); /*this one added right after the call to usbPoll() in main() */


What am I doing wrong?

Re: v-usb and matrix led hangups

Posted: Sat Dec 26, 2015 12:44 pm
by Davo
I'm going to chalk this up to late night blundering. I managed to get the avr to behave as expected. Still some testing.