EE445M RTOS
Taken at the University of Texas Spring 2015
circularbuffer< T, N > Class Template Reference

#include <circularbuffer.hpp>

Inheritance diagram for circularbuffer< T, N >:
Inheritance graph
Collaboration diagram for circularbuffer< T, N >:
Collaboration graph

Public Member Functions

 circularbuffer ()
 
void increment_ptr (uint32_t *ptr, uint32_t increment, uint32_t wrap_len)
 
void add (const T ch)
 
peek ()
 
get (int32_t offset)
 
- Public Member Functions inherited from buffer< T, N >
 buffer ()
 
 buffer (semaphore *sem)
 
void clear ()
 
void init ()
 
void notify (const T data)
 
bool add (const T data)
 
peek ()
 
get (bool &ok)
 
bool full ()
 
bool empty ()
 
uint32_t length ()
 

Additional Inherited Members

- Public Attributes inherited from buffer< T, N >
uint32_t pos
 
uint32_t len
 
semaphoresem
 
buf [N]
 
uint32_t error_overflow
 
uint32_t error_underflow
 

Detailed Description

template<typename T, uint32_t N>
class circularbuffer< T, N >

Definition at line 13 of file circularbuffer.hpp.

Constructor & Destructor Documentation

template<typename T, uint32_t N>
circularbuffer< T, N >::circularbuffer ( )
inline

Definition at line 17 of file circularbuffer.hpp.

17 : buffer<T, N>() { }

Member Function Documentation

template<typename T, uint32_t N>
void circularbuffer< T, N >::add ( const T  ch)
inline

Definition at line 24 of file circularbuffer.hpp.

Referenced by ping::handle_gpio(), and ir::sample().

24  {
25  this->buf[this->pos] = ch;
26  increment_ptr(&(this->pos), 1, this->len);
27  }
void increment_ptr(uint32_t *ptr, uint32_t increment, uint32_t wrap_len)
T buf[N]
Definition: bufferpp.hpp:115
uint32_t len
Definition: bufferpp.hpp:113
uint32_t pos
Definition: bufferpp.hpp:112

Here is the caller graph for this function:

template<typename T, uint32_t N>
T circularbuffer< T, N >::get ( int32_t  offset)
inline

Definition at line 33 of file circularbuffer.hpp.

33  {
34 
35  int32_t position_to_get = ((this->pos+offset) % this->len);
36 
37  if (position_to_get < 0) {
38  return this->buf[position_to_get + this->len];
39  }
40  return this->buf[position_to_get];
41  }
T buf[N]
Definition: bufferpp.hpp:115
uint32_t len
Definition: bufferpp.hpp:113
uint32_t pos
Definition: bufferpp.hpp:112
template<typename T, uint32_t N>
void circularbuffer< T, N >::increment_ptr ( uint32_t *  ptr,
uint32_t  increment,
uint32_t  wrap_len 
)
inline

Definition at line 19 of file circularbuffer.hpp.

Referenced by circularbuffer< int16_t, 32 >::add().

20  {
21  *ptr = (*ptr + increment) % wrap_len;
22  }

Here is the caller graph for this function:

template<typename T, uint32_t N>
T circularbuffer< T, N >::peek ( )
inline

Definition at line 29 of file circularbuffer.hpp.

29  {
30  return this->buf(this->pos);
31  }
T buf[N]
Definition: bufferpp.hpp:115
uint32_t pos
Definition: bufferpp.hpp:112

The documentation for this class was generated from the following file: