Tiny protocol  0.9.3
Tiny communication protocol for microcontrollers
Classes | Macros | Typedefs | Functions
tiny_types.h File Reference

Tiny protocol Types. More...

#include "include/arduino_hal.h"
#include <stdint.h>
Include dependency graph for tiny_types.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  STinyStats
 

Macros

#define TINY_SUCCESS   (0)
 Tiny operation successful. Only tiny_send_start and tiny_read_start functions return this code.
 
#define TINY_ERR_FAILED   (-1)
 Timeout.
 
#define TINY_ERR_TIMEOUT   (-2)
 Timeout happened. The function must be called once again.
 
#define TINY_ERR_DATA_TOO_LARGE   (-3)
 Data too large to fit the user buffer.
 
#define TINY_ERR_INVALID_DATA   (-4)
 Some invalid data passed to Tiny API function.
 
#define TINY_ERR_BUSY   (-5)
 API function detected that operation cannot be performed right now.
 
#define TINY_ERR_OUT_OF_SYNC   (-6)
 Out of sync - received some data, which are not part of the frame (tiny_read)
 
#define TINY_ERR_AGAIN   (-7)
 No data for now, need to retry reading once again.
 
#define TINY_ERR_WRONG_CRC   (-8)
 Invalid crc field of incoming frame.
 
#define TINY_FLAG_NO_WAIT   (0)
 This flag makes tiny API functions perform as non-blocking.
 
#define TINY_FLAG_READ_ALL   (1)
 This flag makes tiny_read function to read whole frame event if it doesn't fit the buffer.
 
#define TINY_FLAG_LOCK_SEND   (2)
 Informs advanced API that caller wants to start transmit new frame to the channel.
 
#define TINY_FLAG_WAIT_FOREVER   (0x80)
 This flag makes tiny API functions perform in blocking mode.
 
#define EVENT_BIS_ALL   0xFF
 All bits supported by tiny protocol HAL events.
 
#define EVENT_BITS_CLEAR   1
 Flag, used in tiny_events_wait()
 
#define EVENT_BITS_LEAVE   0
 Flag, used in tiny_events_wait()
 

Typedefs

typedef int(* write_block_cb_t) (void *pdata, const void *buffer, int size)
 
typedef int(* read_block_cb_t) (void *pdata, void *buffer, int size)
 
typedef void(* on_frame_cb_t) (void *handle, uint16_t uid, uint8_t *pdata, int size)
 

Functions

void tiny_mutex_create (tiny_mutex_t *mutex)
 
void tiny_mutex_destroy (tiny_mutex_t *mutex)
 
void tiny_mutex_lock (tiny_mutex_t *mutex)
 
uint8_t tiny_mutex_try_lock (tiny_mutex_t *mutex)
 
void tiny_mutex_unlock (tiny_mutex_t *mutex)
 
void tiny_events_create (tiny_events_t *events)
 
void tiny_events_destroy (tiny_events_t *events)
 
uint8_t tiny_events_wait (tiny_events_t *event, uint8_t bits, uint8_t clear, uint32_t timeout)
 
void tiny_events_set (tiny_events_t *event, uint8_t bits)
 
void tiny_events_clear (tiny_events_t *event, uint8_t bits)
 
void tiny_sleep (uint32_t ms)
 
uint32_t tiny_millis ()
 
void tiny_log_level (uint8_t level)
 

Detailed Description

Tiny protocol Types.

This is Tiny protocol implementation for microcontrollers

Typedef Documentation

◆ on_frame_cb_t

typedef void(* on_frame_cb_t) (void *handle, uint16_t uid, uint8_t *pdata, int size)

on_frame_cb_t is a callback function, which is called every time new frame is received, or sent. refer to tiny_set_callbacks

Parameters
handle- handle of Tiny.
uid- UID of the received frame or sent frame (if uids are enabled).
pdata- data received over Tiny Protocol.
size- size of data received.
Returns
None.
See also
tiny_set_callbacks

◆ read_block_cb_t

typedef int(* read_block_cb_t) (void *pdata, void *buffer, int size)

The function reads data from communication channel.

Parameters
pdata- pointer to user private data. - absent in Arduino version
buffer- pointer to a buffer to read data to from the channel.
size- maximum size of the buffer.
See also
write_block_cb_t
Returns
the function must return negative value in case of error or number of bytes actually read or zero.

◆ write_block_cb_t

typedef int(* write_block_cb_t) (void *pdata, const void *buffer, int size)

The function writes data to communication channel port.

Parameters
pdata- pointer to user private data - absent in Arduino version
buffer- pointer to the data to send to channel.
size- size of data to write.
See also
read_block_cb_t
Returns
the function must return negative value in case of error or number of bytes written or zero.

Function Documentation

◆ tiny_events_clear()

void tiny_events_clear ( tiny_events_t *  event,
uint8_t  bits 
)

Clears bits for cross-platform event group object.

Parameters
eventpointer to tiny_event_t variable.
bitsbits to clear

◆ tiny_events_create()

void tiny_events_create ( tiny_events_t *  events)

Creates cross platform event group object.

Parameters
eventspointer to tiny_event_t variable.

◆ tiny_events_destroy()

void tiny_events_destroy ( tiny_events_t *  events)

Destroys cross platform event group object.

Parameters
eventspointer to tiny_event_t variable.

◆ tiny_events_set()

void tiny_events_set ( tiny_events_t *  event,
uint8_t  bits 
)

Sets bits for cross-platform event group object.

Parameters
eventpointer to tiny_event_t variable.
bitsbits to set

◆ tiny_events_wait()

uint8_t tiny_events_wait ( tiny_events_t *  event,
uint8_t  bits,
uint8_t  clear,
uint32_t  timeout 
)

Waits until any of specified bits is set or timeout.

Parameters
eventpointer to tiny_event_t variable.
bitsbits to wait for
clearflags EVENT_BITS_CLEAR or EVENT_BITS_LEAVE
timeouttimeout in milliseconds to wait
Returns
0 on timeout list of bits from the input argument, which were set

◆ tiny_log_level()

void tiny_log_level ( uint8_t  level)

Sets logging level if tiny library is compiled with logs

Parameters
levellog level to set, or 0 to disable logs

◆ tiny_millis()

uint32_t tiny_millis ( )

Returns timestamp in milliseconds since system started up.

◆ tiny_mutex_create()

void tiny_mutex_create ( tiny_mutex_t *  mutex)

Creates cross-platform mutex.

Parameters
mutexpointer to tiny_mutex_t variable.

◆ tiny_mutex_destroy()

void tiny_mutex_destroy ( tiny_mutex_t *  mutex)

Destroys cross-platform mutex.

Parameters
mutexpointer to tiny_mutex_t variable.

◆ tiny_mutex_lock()

void tiny_mutex_lock ( tiny_mutex_t *  mutex)

Locks cross-platform mutex.

Parameters
mutexpointer to tiny_mutex_t variable.

◆ tiny_mutex_try_lock()

uint8_t tiny_mutex_try_lock ( tiny_mutex_t *  mutex)

Attempts to lock cross-platform mutex.

Parameters
mutexpointer to tiny_mutex_t variable.
Returns
0 if failed to lock 1 if success

◆ tiny_mutex_unlock()

void tiny_mutex_unlock ( tiny_mutex_t *  mutex)

Unlocks cross-platform mutex.

Parameters
mutexpointer to tiny_mutex_t variable.

◆ tiny_sleep()

void tiny_sleep ( uint32_t  ms)

Sleeps for specified period in milliseconds.

Parameters
mstime in milliseconds to sleep