Author Topic: bitbuf.h  (Read 2946 times)

0 Members and 1 Guest are viewing this topic.

Offline joseph14Topic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
bitbuf.h
« 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.
Quote
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?



Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: bitbuf.h
« Reply #1 on: July 21, 2008, 05:28:54 PM »
Presumably you can staticly initialise the array ie

Code: [Select]
unsigned char theBuffer[256];
BitBuf bitBuf;

and then call your bitufInit routine:
Code: [Select]
bitbufInit(&bitBuf, theBuffer, sizeof(theBuffer));
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline joseph14Topic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
Re: bitbuf.h
« Reply #2 on: July 22, 2008, 11:40:37 AM »
Thank you very much :)

 

SMF spam blocked by CleanTalk