Tiny protocol  0.9.0
Tiny communication protocol for microcontrollers
tiny_light.h
Go to the documentation of this file.
1 /*
2  Copyright 2017-2019 (C) Alexey Dynda
3 
4  This file is part of Tiny Protocol Library.
5 
6  Protocol Library is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Protocol Library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with Protocol Library. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
26 #ifndef _TINY_LIGHT_H_
27 #define _TINY_LIGHT_H_
28 
29 #include "proto/hdlc/tiny_hdlc.h"
30 #include "proto/hal/tiny_types.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
41 /*************************************************************
42  *
43  * Tiny defines
44  *
45  *************************************************************/
46 
51 typedef struct
52 {
53 #ifdef CONFIG_ENABLE_STATS
54  STinyStats stat;
56 #endif
57  write_block_cb_t write_func;
62  void *user_data;
63 #ifndef DOXYGEN_SHOULD_SKIP_THIS
64  hdlc_struct_t _hdlc;
65  uint8_t _received;
66  uint8_t _sent;
67 #endif
69 
70 
71 
85 extern int tiny_light_init(void *handle,
86  write_block_cb_t write_func,
87  read_block_cb_t read_func,
88  void *pdata);
89 
90 
98 extern int tiny_light_close(void *handle);
99 
114 extern int tiny_light_send(void *handle, const uint8_t *pbuf, int len);
115 
134 extern int tiny_light_read(void *handle, uint8_t *pbuf, int len);
135 
146 extern hdlc_handle_t tiny_light_get_hdlc(void *handle);
147 
152 #ifdef __cplusplus
153 }
154 #endif
155 
156 #endif /* _TINY_PROTOCOL_H_ */
hdlc_handle_t tiny_light_get_hdlc(void *handle)
returns lower level hdlc handle.
Definition: tiny_light.c:185
int tiny_light_close(void *handle)
Definition: tiny_light.c:105
int tiny_light_send(void *handle, const uint8_t *pbuf, int len)
sends frame with user payload to communication channel in blocking mode
Definition: tiny_light.c:136
Definition: tiny_types.h:103
int tiny_light_read(void *handle, uint8_t *pbuf, int len)
reads frame from the channel in blocking mode.
Definition: tiny_light.c:158
int(* read_block_cb_t)(void *pdata, void *buffer, int size)
Definition: tiny_types.h:139
read_block_cb_t read_func
pointer to platform related read function
Definition: tiny_light.h:60
Definition: tiny_light.h:51
Tiny protocol Types.
void * user_data
user-specific data
Definition: tiny_light.h:62
Definition: tiny_hdlc.h:47
int(* write_block_cb_t)(void *pdata, const void *buffer, int size)
Definition: tiny_types.h:128
int tiny_light_init(void *handle, write_block_cb_t write_func, read_block_cb_t read_func, void *pdata)
Definition: tiny_light.c:72