why aren't my 1024 bytes proccesd

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
ageurtse
Posts: 4
Joined: Sun Jan 08, 2012 10:39 am

why aren't my 1024 bytes proccesd

Post by ageurtse » Sun Feb 12, 2012 11:52 am

Hello,

i have the bellow code, it work's fine if a send 8 portion's of 128 bytes. if i alter it to 1 portion of 1024 bytes it receives them all. the report is 1024 but when i procces it the avr report -xx so what goes wrong. the code posted below is for proccesing 1024 bytes.

Code: Select all

#include <inttypes.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <avr/wdt.h>
#include <avr/eeprom.h>
#include <util/delay.h>

// Graphical drivers
#include "ks0108.h"
#include "arial8.h"

// use avrusb library
#include "usbdrv.h"
#include "oddebug.h"
#include "request.h"
#include "bitmap.h"


#define VERSION_MAJOR 1
#define VERSION_MINOR 9
#define VERSION_STR "1.09"


/* ------------------------------------------------------------------------- */
static uchar currentPosition, bytesRemaining;
static uchar image[1024];
uint8_t x,y,color;

/* ------------------------------------------------------------------------- */
uchar   usbFunctionSetup(uchar data[8]) {
    usbRequest_t    *rq = (void *)data;
   static uchar    replyBuf[4];

   

 //   usbMsgPtr = replyBuf;
   currentPosition = 0;
   bytesRemaining = rq->wLength.word;  // store the amount of data requested
    if(bytesRemaining > sizeof(image)) // limit to buffer size
       bytesRemaining = sizeof(image);

    if(rq->bRequest == cmd_LCD_WritePixel){  /* ECHO */
        x = rq->wValue.bytes[0];
        y = rq->wValue.bytes[1];
      color = rq->wIndex.bytes[0];
      ks0108SetDot(x,y,color);
    }
 
    if(rq->bRequest == cmd_USB_connected){  /* repaint screen on connect */
        ks0108ClearScreen();
      ks0108SelectFont(Arial9, ks0108ReadFontData, BLACK);
      ks0108GotoXY(8,10);
      // Print some text
      ks0108Puts_P(PSTR("GLCD-USB  interface by AJG"));
      ks0108GotoXY(25,20);
      // Print some text
      ks0108Puts_P(PSTR("Connected to host PC"));
      ks0108DrawRoundRect(0, 0, 126, 63, 8, BLACK);
   }
 
    if(rq->bRequest == cmd_USB_sendglcd1){  /* repaint screen on connect */
        x = 0;
        y = rq->wValue.bytes[1];
      return USB_NO_MSG;     
   }


  return 0;  // reply len
}



uchar usbFunctionWrite(uchar *data, uchar len)
{
    uchar i;
    uint16_t ii, jj, by;

   if(len > bytesRemaining)            // if this is the last incomplete chunk
       len = bytesRemaining;               // limit to the amount we can store


    bytesRemaining -= len;
    for(i = 0; i < len; i++){

//         ks0108GotoXY(x, y);
//         ks0108WriteData(data[i]);
//         x++;

      image[currentPosition++] = data[i];


      }

   /* after all data is proccesd execute below */
   if (bytesRemaining ==0){
            for(z=0; z<64; z+=8)
      for(j=0; j<128; j++)
      {
         by=image[(z*16)+j];
         ks0108GotoXY(j, z);
         ks0108WriteData(by);
      }
   }
   return bytesRemaining == 0;             // return 1 if we have all data
}

Post Reply