[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] How to use pointers to program memory?
From: |
Anich Gregor |
Subject: |
[avr-gcc-list] How to use pointers to program memory? |
Date: |
Sat, 27 Dec 2003 22:41:08 +0100 |
User-agent: |
KMail/1.5.4 |
Hi!
I have a function to transmit data, but it is able to transmit only up to a
maximum of 8 bytes at once. I have another function which shall now take data
from the .text section, put it into RAM and then tell the other function to
send that RAM.
How do i tell the compiler that the input to my function is a pointer to data
which is stored in the .text section that it uses the right instructions to
load bytes?
Do i have to put __attribute__(( section( ".text" ) )) somewhere onto const
unsigned char *data?
Thanks,
Gregor
The function:
static void usb_send_descriptor( const unsigned char *data, unsigned char
length )
{
volatile unsigned char *p;
unsigned char l;
// wait until buffer is empty
while (ep0_send_size != 0)
__asm__ volatile ( "nop" );
// send data
*ep0_send_buf = PID_DATA0;
while (length >= 8)
{
p = ep0_send_buf+1;
// copy 8 bytes
*p++ = *data++;
*p++ = *data++;
*p++ = *data++;
*p++ = *data++;
*p++ = *data++;
*p++ = *data++;
*p++ = *data++;
*p++ = *data++;
// send 8 bytes
ep0_send_size = 9;
while (ep0_send_size != 0)
__asm__ volatile ( "nop" );
length -= 8;
}
p = ep0_send_buf+1;
l = length;
do
*p++ = *data++;
while (--l);
ep0_send_size = length+1;
}