tinyproto
Classes | Macros | Typedefs | Enumerations | Functions
tiny_fd.h File Reference

This is Tiny Full-Duplex protocol implementation for microcontrollers. More...

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

Go to the source code of this file.

Classes

struct  tiny_fd_init_t_
 This structure is used for initialization of Tiny Full Duplex protocol. More...
 

Macros

#define TINY_FD_PRIMARY_ADDR   (0)
 Address of primary stations to use with the protocol. More...
 

Typedefs

typedef struct tiny_fd_data_ttiny_fd_handle_t
 This handle points to service data, required for full-duplex functioning.
 
typedef void(* tiny_fd_log_frame_cb_t) (void *udata, tiny_fd_handle_t handle, tiny_fd_frame_direction_t direction, tiny_fd_frame_type_t frame_type, tiny_fd_frame_subtype_t frame_subtype, uint8_t ns, uint8_t nr, const uint8_t *data, int len)
 tiny_fd_log_frame_cb_t is a callback function, which is called every time frame is sent or received. More...
 
typedef struct tiny_fd_init_t_ tiny_fd_init_t
 This structure is used for initialization of Tiny Full Duplex protocol.
 

Enumerations

enum  { TINY_FD_MODE_ABM = 0x00, TINY_FD_MODE_NRM = 0x01, TINY_FD_MODE_ARM = 0x02 }
 
enum  tiny_fd_frame_type_t { TINY_FD_FRAME_TYPE_I = 0x00, TINY_FD_FRAME_TYPE_S = 0x01, TINY_FD_FRAME_TYPE_U = 0x02 }
 Enumeration of frame types used in Tiny Full Duplex protocol. More...
 
enum  tiny_fd_frame_subtype_t {
  TINY_FD_FRAME_SUBTYPE_RR = 0x00, TINY_FD_FRAME_SUBTYPE_REJ = 0x08, TINY_FD_FRAME_SUBTYPE_UA = 0x60, TINY_FD_FRAME_SUBTYPE_FRMR = 0x84,
  TINY_FD_FRAME_SUBTYPE_RSET = 0x8C, TINY_FD_FRAME_SUBTYPE_SABM = 0x2C, TINY_FD_FRAME_SUBTYPE_SNRM = 0x80, TINY_FD_FRAME_SUBTYPE_DISC = 0x40
}
 Enumeration of frame subtypes used in Tiny Full Duplex protocol. More...
 
enum  tiny_fd_frame_direction_t { TINY_FD_FRAME_DIRECTION_IN = 0x00, TINY_FD_FRAME_DIRECTION_OUT = 0x01 }
 Enumeration of frame directions used in Tiny Full Duplex protocol. More...
 

Functions

int tiny_fd_init (tiny_fd_handle_t *handle, tiny_fd_init_t *init)
 Initialized communication for Tiny Full Duplex protocol. More...
 
int tiny_fd_get_status (tiny_fd_handle_t handle)
 Returns status of the connection. More...
 
int tiny_fd_disconnect (tiny_fd_handle_t handle)
 Sends DISC command to remote side. More...
 
void tiny_fd_close (tiny_fd_handle_t handle)
 stops Tiny Full Duplex state machine More...
 
int tiny_fd_get_tx_data (tiny_fd_handle_t handle, void *data, int len, uint32_t timeout)
 runs tx processing to fill specified buffer with data. More...
 
int tiny_fd_run_tx (tiny_fd_handle_t handle, write_block_cb_t write_func)
 sends tx data to the communication channel via user callback write_func(). More...
 
int tiny_fd_on_rx_data (tiny_fd_handle_t handle, const void *data, int len)
 runs rx bytes processing for specified buffer. More...
 
int tiny_fd_run_rx (tiny_fd_handle_t handle, read_block_cb_t read_func)
 reads rx data from the communication channel via user callback read_func() More...
 
int tiny_fd_send_packet_to (tiny_fd_handle_t handle, uint8_t address, const void *buf, int len, uint32_t timeout)
 Sends userdata over full-duplex protocol. More...
 
int tiny_fd_buffer_size_by_mtu (int mtu, int window)
 Returns minimum required buffer size for specified parameters. More...
 
int tiny_fd_buffer_size_by_mtu_ex (uint8_t peers_count, int mtu, int tx_window, hdlc_crc_t crc_type, int rx_window)
 Returns minimum required buffer size for specified parameters. More...
 
int tiny_fd_get_mtu (tiny_fd_handle_t handle)
 returns max packet size in bytes. More...
 
int tiny_fd_send_to (tiny_fd_handle_t handle, uint8_t address, const void *buf, int len, uint32_t timeout)
 Sends userdata over full-duplex protocol. More...
 
void tiny_fd_set_ka_timeout (tiny_fd_handle_t handle, uint32_t keep_alive)
 Sets keep alive timeout in milliseconds. More...
 
int tiny_fd_register_peer (tiny_fd_handle_t handle, uint8_t address)
 Registers remote peer with specified address. More...
 
int tiny_fd_send (tiny_fd_handle_t handle, const void *buf, int len, uint32_t timeout)
 Sends userdata over full-duplex protocol to primary station. More...
 
int tiny_fd_send_packet (tiny_fd_handle_t handle, const void *buf, int len, uint32_t timeout)
 Sends packet to primary station. More...
 

Detailed Description

This is Tiny Full-Duplex protocol implementation for microcontrollers.

It is built on top of Tiny Protocol (hdlc/low_level/hdlc.c)

Tiny Protocol Full Duplex API

Implements full duplex asynchronous ballanced mode (ABM)