ubinos
Classes | Macros | Typedefs | Functions
cirbuf.h File Reference

ubiclib circular buffer API More...

#include <ubinos_config.h>
#include <ubinos/type.h>

Go to the source code of this file.

Classes

struct  _cirbuf_t
 

Macros

#define CIRBUF_OPT__NOOVERWRITE   0x0001
 
#define CIRBUF_OPT__MTPROTECTION   0x0002
 
#define cirbuf_init(cirbuf, maxsize)
 

Typedefs

typedef struct _cirbuf_t cirbuf_t
 
typedef cirbuf_tcirbuf_pt
 

Functions

int cirbuf_create (cirbuf_pt *cirbuf_p, unsigned int maxsize)
 
int cirbuf_create_ext (cirbuf_pt *cirbuf_p, unsigned int maxsize, unsigned int option)
 
int cirbuf_delete (cirbuf_pt *cirbuf_p)
 
int cirbuf_write (cirbuf_pt cirbuf, unsigned char *buf, unsigned int size, unsigned int *written_p)
 
int cirbuf_read (cirbuf_pt cirbuf, unsigned char *buf, unsigned int size, unsigned int *read_p)
 
int cirbuf_clear (cirbuf_pt cirbuf)
 

Detailed Description

ubiclib circular buffer API

ubiclib 환형버퍼 API를 정의합니다.

Macro Definition Documentation

◆ cirbuf_init

#define cirbuf_init (   cirbuf,
  maxsize 
)
Value:
{ \
(cirbuf)->maxsize = maxsize; \
(cirbuf)->buf = (unsigned char *) ((unsigned int) cirbuf + sizeof(cirbuf_t)); \
\
(cirbuf)->head = (cirbuf)->buf; \
(cirbuf)->tail = (cirbuf)->buf; \
(cirbuf)->size = 0; \
\
(cirbuf)->overflowcount = 0; \
(cirbuf)->mtprotection = 0; \
(cirbuf)->overwrite = 0; \
(cirbuf)->reserved = 0; \
}

환형버퍼를 초기화하는 매크로

Parameters
cirbuf대상 환형버퍼 포인터
maxsize버퍼 최대 크기

◆ CIRBUF_OPT__MTPROTECTION

#define CIRBUF_OPT__MTPROTECTION   0x0002

선택 사항: 다중 태스크 환경에서 사용할 수 있음 (데이터는 손실될 수 있음)

◆ CIRBUF_OPT__NOOVERWRITE

#define CIRBUF_OPT__NOOVERWRITE   0x0001

선택 사항: 버퍼가 가득차면 새 데이터를 버림

Typedef Documentation

◆ cirbuf_pt

typedef cirbuf_t* cirbuf_pt

환형버퍼 포인터 형 정의

◆ cirbuf_t

typedef struct _cirbuf_t cirbuf_t

환형버퍼 형 정의

Function Documentation

◆ cirbuf_clear()

int cirbuf_clear ( cirbuf_pt  cirbuf)

환형버퍼의 데이터를 모두 지우는 함수

Parameters
cirbuf대상 환형버퍼 포인터
Returns
0: 성공

-1: 오류
-n: n-1 번째 매개변수가 잘못되었음

◆ cirbuf_create()

int cirbuf_create ( cirbuf_pt cirbuf_p,
unsigned int  maxsize 
)

환형버퍼를 생성하는 함수

Parameters
cirbuf_p생성한 환형버퍼의 주소를 저장할 포인터의 주소
maxsize버퍼 최대 크기
Returns
0: 성공

-1: 오류
-n: n-1 번째 매개변수가 잘못되었음

◆ cirbuf_create_ext()

int cirbuf_create_ext ( cirbuf_pt cirbuf_p,
unsigned int  maxsize,
unsigned int  option 
)

환형버퍼를 생성하는 함수 (확장형)

Parameters
cirbuf_p생성한 환형버퍼의 주소를 저장할 포인터의 주소
maxsize버퍼 최대 크기
option옵션 (CIRBUF_OPT__...)
0: 기본 설정
Returns
0: 성공

-1: 오류
-n: n-1 번째 매개변수가 잘못되었음

◆ cirbuf_delete()

int cirbuf_delete ( cirbuf_pt cirbuf_p)

환형버퍼를 제거하는 함수

Parameters
cirbuf_p제거할 환형버퍼의 주소가 저장된 포인터의 주소
제거에 성공하면 *cirbuf_p는 NULL이 됨
Returns
0: 성공

-1: 오류
-n: n-1 번째 매개변수가 잘못되었음

◆ cirbuf_read()

int cirbuf_read ( cirbuf_pt  cirbuf,
unsigned char *  buf,
unsigned int  size,
unsigned int *  read_p 
)

환형버퍼에서 데이터를 읽는 함수

Parameters
cirbuf대상 환형버퍼 포인터
buf읽은 데이터를 저장할 버퍼
size읽을 데이터 크기
read_p읽은 데이터 크기를 저장할 변수의 주소 (NULL이면 무시)
Returns
0: 성공

-1: 오류
-n: n-1 번째 매개변수가 잘못되었음

◆ cirbuf_write()

int cirbuf_write ( cirbuf_pt  cirbuf,
unsigned char *  buf,
unsigned int  size,
unsigned int *  written_p 
)

환형버퍼에 데이터를 쓰는 함수

Parameters
cirbuf대상 환형버퍼 포인터
buf쓸 데이터가 저장되어 있는 버퍼
size쓸 데이터 크기
written_p쓴 데이터 크기를 저장할 변수의 주소 (NULL이면 무시)
Returns
0: 성공

-1: 오류
-n: n-1 번째 매개변수가 잘못되었음
_cirbuf_t
Definition: cirbuf.h:56