Society of Robots - Robot Forum
Software => Software => Topic started by: joseph14 on July 21, 2008, 01:55:45 PM
-
I want to create a bitbuffer for my program. I want it so that I can read and write to it. The problem is I'm not quite sure how to safely initialize this. I'm trying to use the bitbuf.h and bitbuf.c from the AVR library.
This is the specific function I'm trying to use.
void bitbufInit (BitBuf *bitBuffer, unsigned char *start, unsigned short bytesize)
initialize a buffer to start at a given address and have given size
00024 void bitbufInit(BitBuf* bitBuffer, unsigned char *start, unsigned short bytesize)
00025 {
00026 // set start pointer of the buffer
00027 bitBuffer->dataptr = start;
00028 bitBuffer->size = bytesize;
00029 // initialize indexing and length
00030 bitBuffer->dataindex = 0;
00031 bitbufFlush(bitBuffer);
00032 }
How can i make sure that the address i choose for the buffer, and the size. don't overlap with some other data already in memory?
-
Presumably you can staticly initialise the array ie
unsigned char theBuffer[256];
BitBuf bitBuf;
and then call your bitufInit routine:
bitbufInit(&bitBuf, theBuffer, sizeof(theBuffer));
-
Thank you very much :)