On Thursday 04 January 2007 19:27, polly wrote:

>    Thanks for the snippet, Ernst, I've been trying to locate the
> descriptors in flash a la uChip Demo code rather than in RAM
> as your code seems to do.
>
> regards, p

Well, I keep the descriptors in flash. (note the "code" keyword)

I just don't care where in flash, thats for the linker to worry about.

When sending an descriptor, I copy it into my transfer buffer, simply with:

-------------
unsigned char * outputData;
unsigned int dataSize;


static void fill_ep0in_buffer(void) {
  unsigned char i;
  unsigned int bufferSize;
  data unsigned char * dest;

  // How much to write this round?
  if(dataSize < EP0_SIZE)
    bufferSize = dataSize;
  else
    bufferSize = EP0_SIZE;

    // Load the high two bits of the byte count into BC8:BC9

    EP0Buff_in.StatusBits.countHigh=(unsigned char)(bufferSize >> 8);
    EP0Buff_in.count = (unsigned char)(bufferSize & 0xFF);
    EP0Buff_in.ADDR = PTR16(&controlTransferBuffer);

   // copy dest, source, bytes
    dest=controlTransferBuffer;
    for (i=0;i<bufferSize;i++) {
       *dest++ = *outputData++;
    }
    // Update the number of bytes that still need to be sent.  Getting
    // all the data back to the host can take multiple transactions, so
    // we need to track how far along we are.
    dataSize -= bufferSize;
}
------------------------

where "outputData" is a global variable pointing to the data to send.

its a generic pointer (three bytes long) so "*outputData" invokes gptr_get, 
and the function works transparently both with data from memory and flash.

/Ernst

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to