Tiny protocol  0.7.0
Tiny communication protocol for microcontrollers
Functions
Tiny Half Duplex API functions

Functions

int tiny_hd_init (STinyHdData *handle, STinyHdInit *init)
 Initialized communication for Tiny Half Duplex protocol. More...
 
void tiny_hd_close (STinyHdData *handle)
 stops Tiny Half Duplex state machine More...
 
int tiny_hd_run (STinyHdData *handle)
 runs receive functions of Tiny Half Duplex protocol. More...
 
int tiny_send_wait_ack (STinyHdData *handle, void *buf, uint16_t len)
 Sends userdata and waits for acknowledgement from remote side. More...
 

Detailed Description

Function Documentation

◆ tiny_hd_close()

void tiny_hd_close ( STinyHdData handle)

stops Tiny Half Duplex state machine

stops Tiny Half Duplex state machine.

Parameters
handle- pointer to STinyHdData

◆ tiny_hd_init()

int tiny_hd_init ( STinyHdData handle,
STinyHdInit init 
)

Initialized communication for Tiny Half Duplex protocol.

The function initializes internal structures for Tiny Half Duplex state machine.

Parameters
handle- pointer to Tiny Half Duplex data
init- pointer to STinyHdInit data.
Returns
TINY_NO_ERROR in case of success. TINY_ERR_FAILED if init parameters are incorrect.
Remarks
This function is not thread safe.

◆ tiny_hd_run()

int tiny_hd_run ( STinyHdData handle)

runs receive functions of Tiny Half Duplex protocol.

Runs receive functions of Tiny Half Duplex protocol. This function must be called all the time in the loop if send operation is not performed. For atmega controllers this means to call tiny_hd_run() in loop() routine. If user packet is received during execution of the function, it wil call on_frame_cb_t callback to process received packet.

Parameters
handle- pointer to STinyHdData
See also
TINY_ERR_FAILED
TINY_ERR_DATA_TOO_LARGE
TINY_ERR_OUT_OF_SYNC
TINY_ERR_BUSY
TINY_NO_ERROR
Returns
TINY_ERR_OUT_OF_SYNC - if first byte received from the channel is not packet marker. You may ignore this error. TINY_ERR_DATA_TOO_LARGE - if incoming packet is too large to fit the buffer TINY_ERR_FAILED - if something wrong with received data TINY_BUSY - if another receive operation is in progress. TINY_NO_ERROR - if nothing is received. greater 0 - number of received bytes. Callbak will be called in this case.
Warning
do not use blocking send (tiny_send_wait_ack) in on_frame_cb_t callback.

◆ tiny_send_wait_ack()

int tiny_send_wait_ack ( STinyHdData handle,
void *  buf,
uint16_t  len 
)

Sends userdata and waits for acknowledgement from remote side.

Sends userdata and waits for acknowledgement from remote side.

Remarks
Each outoing packet is assigned 16-bit uid, and remote side must confirm with service packet sent back with this 16-bit uid. Generated uids have range in [0 : 0x0FFF]. Higher 4 bits of uid field are used to pass flags with the packet.
Parameters
handle- pointer to STinyHdData
buf- data to send
len- length of data to send
Returns
number of bytes, sent. TINY_ERR_TIMEOUT - if no response from remote side after 3 retries. TINY_ERR_FAILED - if request was cancelled, by tiny_hd_close(). other error codes - if send/receive errors happened.