tinyproto
Macros | Typedefs | Functions
tiny_types.h File Reference

This is Tiny HAL implementation for microcontrollers. More...

#include "no_platform/no_platform_hal.h"
#include <stdint.h>
#include <stdbool.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.

Macros

#define CONFIG_TINYHAL_THREAD_SUPPORT   0
 By default disable thread support.
 
#define TINY_ALIGNED(x)
 This macro is used internally for aligning the structures.
 
#define TINY_ALIGN_STRUCT_VALUE   (uintptr_t)(sizeof(uintptr_t))
 This macro is used internally for aligning the structures.
 
#define TINY_ALIGNED_STRUCT   TINY_ALIGNED(TINY_ALIGN_STRUCT_VALUE)
 This macro is used internally for aligning the structures.
 
#define TINY_ALIGN_BUFFER(x)   ((uint8_t *)( ((uintptr_t)x + TINY_ALIGN_STRUCT_VALUE - 1) & (~(TINY_ALIGN_STRUCT_VALUE - 1)) ))
 This macro is used internally for aligning the structures.
 
#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_BITS_ALL   0xFF
 All bits supported by tiny HAL events.
 
#define EVENT_BITS_CLEAR   1
 Flag, used in tiny_events_wait()
 
#define EVENT_BITS_LEAVE   0
 Flag, used in tiny_events_wait()
 
#define TINY_SUCCESS   (0)
 
#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_ERR_OUT_OF_MEMORY   (-9)
 Out of memory during operation.
 
#define TINY_ERR_UNKNOWN_PEER   (-10)
 Unknown remote peer.
 
#define TINY_ERR_IO   (-11)
 IO error.
 

Typedefs

typedef int(* write_block_cb_t) (void *pdata, const void *buffer, int size)
 The function writes data to communication channel port. More...
 
typedef int(* read_block_cb_t) (void *pdata, void *buffer, int size)
 The function reads data from communication channel. More...
 
typedef void(* on_frame_cb_t) (void *udata, uint8_t *pdata, int size)
 on_frame_cb_t is a callback function, which is called every time new frame is received. More...
 
typedef void(* on_tx_frame_cb_t) (void *udata, const uint8_t *pdata, int size)
 on_frame_send_cb_t is a callback function, which is called every time new frame is sent. More...
 
typedef void(* on_frame_read_cb_t) (void *udata, uint8_t address, uint8_t *pdata, int size)
 on_frame_read_cb_t is a callback function, which is called every time new frame is received. More...
 
typedef void(* on_frame_send_cb_t) (void *udata, uint8_t address, const uint8_t *pdata, int size)
 on_frame_send_cb_t is a callback function, which is called every time new frame is sent. More...
 
typedef void(* on_connect_event_cb_t) (void *udata, uint8_t address, bool connected)
 on_connect_event_cb_t is a callback function, which is called every time connection is established or interrupted. More...
 

Functions

void tiny_log_level (uint8_t level)
 Sets logging level if tiny library is compiled with logs. More...
 
void tiny_mutex_create (tiny_mutex_t *mutex)
 Creates cross-platform mutex. More...
 
void tiny_mutex_destroy (tiny_mutex_t *mutex)
 Destroys cross-platform mutex. More...
 
void tiny_mutex_lock (tiny_mutex_t *mutex)
 Locks cross-platform mutex. More...
 
uint8_t tiny_mutex_try_lock (tiny_mutex_t *mutex)
 Attempts to lock cross-platform mutex. More...
 
void tiny_mutex_unlock (tiny_mutex_t *mutex)
 Unlocks cross-platform mutex. More...
 
void tiny_events_create (tiny_events_t *events)
 Creates cross platform event group object. More...
 
void tiny_events_destroy (tiny_events_t *events)
 Destroys cross platform event group object. More...
 
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. More...
 
uint8_t tiny_events_check_int (tiny_events_t *event, uint8_t bits, uint8_t clear)
 Checks specified bits. More...
 
void tiny_events_set (tiny_events_t *event, uint8_t bits)
 Sets bits for cross-platform event group object. More...
 
void tiny_events_clear (tiny_events_t *event, uint8_t bits)
 Clears bits for cross-platform event group object. More...
 
void tiny_sleep (uint32_t ms)
 Sleeps for specified period in milliseconds. More...
 
void tiny_sleep_us (uint32_t us)
 Sleeps for specified period in microseconds. More...
 
uint32_t tiny_millis ()
 Returns timestamp in milliseconds since system started up.
 
uint32_t tiny_micros ()
 Returns timestamp in microseconds since system started up.
 

Detailed Description

This is Tiny HAL implementation for microcontrollers.

Tiny HAL Types

Typedef Documentation

◆ on_connect_event_cb_t

typedef void(* on_connect_event_cb_t) (void *udata, uint8_t address, bool connected)

on_connect_event_cb_t is a callback function, which is called every time connection is established or interrupted.

Parameters
udatauser data
addressremote client id (only for master device).
connectedevent occured.
Returns
None.

◆ on_frame_cb_t

typedef void(* on_frame_cb_t) (void *udata, uint8_t *pdata, int size)

on_frame_cb_t is a callback function, which is called every time new frame is received.

Parameters
udatauser data
pdatapointer to data received from the channel.
sizesize of data received.
Returns
None.

◆ on_frame_read_cb_t

typedef void(* on_frame_read_cb_t) (void *udata, uint8_t address, uint8_t *pdata, int size)

on_frame_read_cb_t is a callback function, which is called every time new frame is received.

Parameters
udatauser data
addressaddress if peer station
pdatapointer to data received from the channel.
sizesize of data received.
Returns
None.

◆ on_frame_send_cb_t

typedef void(* on_frame_send_cb_t) (void *udata, uint8_t address, const uint8_t *pdata, int size)

on_frame_send_cb_t is a callback function, which is called every time new frame is sent.

Parameters
udatauser data
addressaddress of peer station
pdatapointer data sent to the channel.
sizesize of data sent.
Returns
None.

◆ on_tx_frame_cb_t

typedef void(* on_tx_frame_cb_t) (void *udata, const uint8_t *pdata, int size)

on_frame_send_cb_t is a callback function, which is called every time new frame is sent.

Parameters
udatauser data
pdatapointer data sent to the channel.
sizesize of data sent.
Returns
None.

◆ 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_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