Tiny protocol  0.7.0
Tiny communication protocol for microcontrollers
Classes | Typedefs | Enumerations | Functions
Tiny HDLC protocol API functions

Classes

struct  _hdlc_handle_t
 

Typedefs

typedef struct _hdlc_handle_t hdlc_struct_t
 
typedef struct _hdlc_handle_thdlc_handle_t
 

Enumerations

enum  hdlc_crc_t {
  HDLC_CRC_DEFAULT = 0, HDLC_CRC_8 = 8, HDLC_CRC_16 = 16, HDLC_CRC_32 = 32,
  HDLC_CRC_OFF = 0xFF
}
 

Functions

hdlc_handle_t hdlc_init (hdlc_struct_t *hdlc_info)
 
int hdlc_close (hdlc_handle_t handle)
 
void hdlc_reset (hdlc_handle_t handle)
 
int hdlc_run_rx (hdlc_handle_t handle, void *data, int len)
 
int hdlc_run_tx (hdlc_handle_t handle)
 
int hdlc_send (hdlc_handle_t handle, const void *data, int len)
 

Detailed Description

Typedef Documentation

◆ hdlc_struct_t

typedef struct _hdlc_handle_t hdlc_struct_t

Structure describes configuration of lowest HDLC level Initialize this structure by 0 before passing to hdlc_init() function.

Function Documentation

◆ hdlc_close()

int hdlc_close ( hdlc_handle_t  handle)

Shutdowns all hdlc activity

Parameters
handlehandle to hdlc instance

◆ hdlc_init()

hdlc_handle_t hdlc_init ( hdlc_struct_t hdlc_info)

Initializes hdlc level and returns hdlc handle or NULL in case of error.

Parameters
hdlc_infopointer to hdlc_struct_t structure, which defines user-specific configuration
Returns
handle to hdlc instance or NULL.
Warning
hdlc_info structure passed to the function must be allocated all the time.

◆ hdlc_reset()

void hdlc_reset ( hdlc_handle_t  handle)

Resets hdlc state. Use this function, if hw error happened on tx or rx line, and this requires hardware change, and cancelling current operation.

Parameters
handlehandle to hdlc instance

◆ hdlc_run_rx()

int hdlc_run_rx ( hdlc_handle_t  handle,
void *  data,
int  len 
)

Processes incoming data. Implementation of reading data from hw is user responsibility. If hdlc_run_rx() returns value less than size of data passed to the function, then hdlc_run_rx() must be called later second time with the pointer to and size of not processed bytes.

Parameters
handlehandle to hdlc instance
datapointer to incoming data to process
lensize of received data in bytes
Returns
number of bytes actually processed.

◆ hdlc_run_tx()

int hdlc_run_tx ( hdlc_handle_t  handle)

Runs transmission at hdlc level. If there is frame to send, or send is in progress, this function will call send_tx() callback multiple times. If send_tx() callback reports 0, that means that hw device is busy, then hdlc_run_tx() will return immediately and hdlc_run_tx() must be called later next time.

Parameters
handlehandle to hdlc instance
Returns
negative value in case of error 0 if hw is busy, or no data is waiting for sending positive number of bytes passed to hw channel.

◆ hdlc_send()

int hdlc_send ( hdlc_handle_t  handle,
const void *  data,
int  len 
)

Puts next frame for sending.

Parameters
handlehandle to hdlc instance
datapointer to new data to send
lensize of data to send in bytes
Returns
0 if output queue is busy 1 if pointer to data is passed to output queue
Warning
buffer with data must be available all the time until data are actually sent to tx hw channel