[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] pointer to program memory string
From: |
E. Weddington |
Subject: |
Re: [avr-gcc-list] pointer to program memory string |
Date: |
Wed, 24 Nov 2004 07:11:29 -0700 |
On 24 Nov 2004 at 15:39, Leo Hendrawan wrote:
> Hello all,
>
> suppose i have a struct which is:
>
> struct a {
> char*data; // data to be sent
> unsigned int datalen;
> char*datasrc; // data source
> };
>
> and i have some program memory strings:
>
> char b[] PROGMEM = {"........"};
> char c[] PROGMEM = {"............."};
>
> then could point the datasrc above to these program memory strings like
> this:
>
> a->data = &buffer[0]; // point to the data buffer to be sent
>
> a->datasrc = &b[0]; (or) a->datasrc = &c[0];
>
> a->datalen = strlen_P(datasrc);
>
> for(i=0 ; i<(a->datalen-1) ; i++)
> {
> a->data[i]=PRG_RDB(a->datasrc[i]);
> }
>
Also PRG_RDB() is deprecated. Please use pgm_read_byte().