Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

code for circular queue or circular buffer required

Status
Not open for further replies.

yasir0403

Member level 2
Joined
Jun 22, 2007
Messages
53
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,288
Location
Pakistan
Activity points
1,676
Could somebody please upload the C code for circular buffer or circular queue

i urgently need this code

regards
m.yasir
 

btbass

Advanced Member level 5
Joined
Jul 20, 2001
Messages
1,897
Helped
438
Reputation
880
Reaction score
287
Trophy points
1,363
Location
Oberon
Activity points
12,861
Code:
#define BUFFER_SIZE 10
unsigned char buffer[BUFFER_SIZE];
signed char index = 0;  /* Max buffer size 127 */

void put_byte(unsigned char data)
  {
  buffer[index++] = data;
  index = index > BUFFER_SIZE ? 0 : index;
  }

unsigned char get_byte(void)
  {
  --index;
  index = index < 0 ? BUFFER_SIZE : index;
  return buffer[index];
  }
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top