Can't copy vaiable "data" to another variable inside "usbFunctionWrite"

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
mostafayasin
Posts: 6
Joined: Sun Oct 21, 2018 12:30 am

Can't copy vaiable "data" to another variable inside "usbFunctionWrite"

Post by mostafayasin » Sun Oct 21, 2018 12:37 am

Hello guys,
I tried to copy the whole content of "data" to global array to deal with it as shown in the for loop below :

Code: Select all

volatile static uchar   myData[8];
uchar   usbFunctionWrite(uchar *data, uchar len)
{
    if(bytesRemaining == 0)
        return 1;               /* end of transfer */
    if(len > bytesRemaining)
        len = bytesRemaining;

   currentAddress += len;
    bytesRemaining -= len;

    // copy the whole content of "data"
    uchar i;
    for ( i=0 ; i<len ; i++ ){
       myData[i] = data[i];
    }

    return bytesRemaining == 0; /* return 1 if this was the last chunk */
}


But when trying to send it to the host it seems that my array "myData" is empty and the host prints all zeros, the code below shows how I tried to send it to the host :

Code: Select all

uchar   usbFunctionRead(uchar *data, uchar len)
{
    if(len > bytesRemaining)
        len = bytesRemaining;

    uchar i;
    for ( i=0 ; i<len ; i++ ){
       data[i] = myData[i];
    }

    currentAddress += len;
    bytesRemaining -= len;
    return len;
}


Am I doing something wrongly?
Thanks for the advice.

Post Reply