Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sol-uart.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Soletta (TM) Project
3  *
4  * Copyright (C) 2015 Intel Corporation. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #pragma once
20 
21 #include <stdbool.h>
22 #include <stdint.h>
23 
24 #include <sol-types.h>
25 #include <sol-buffer.h>
26 #include <sol-common-buildopts.h>
27 #include <sol-macros.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
54 struct sol_uart;
55 typedef struct sol_uart sol_uart;
56 
68 };
69 
78 };
79 
88 };
89 
96 };
97 
104 typedef struct sol_uart_config {
105 #ifndef SOL_NO_API_VERSION
106 #define SOL_UART_CONFIG_API_VERSION (1)
107  uint16_t api_version;
108 #endif
109 
118  ssize_t (*on_data)(void *data, struct sol_uart *uart, const struct sol_buffer *buf);
129  void (*on_feed_done)(void *data, struct sol_uart *uart, struct sol_blob *blob, int status);
130  const void *user_data;
140  size_t feed_size;
152 
164 enum sol_uart_baud_rate sol_uart_baud_rate_from_str(const char *baud_rate)
165 #ifndef DOXYGEN_RUN
167 #endif
168  ;
169 
181 const char *sol_uart_baud_rate_to_str(enum sol_uart_baud_rate baud_rate)
182 #ifndef DOXYGEN_RUN
183  SOL_ATTR_WARN_UNUSED_RESULT
184 #endif
185  ;
186 
198 enum sol_uart_data_bits sol_uart_data_bits_from_str(const char *data_bits)
199 #ifndef DOXYGEN_RUN
200  SOL_ATTR_WARN_UNUSED_RESULT
201 #endif
202  ;
203 
215 const char *sol_uart_data_bits_to_str(enum sol_uart_data_bits data_bits)
216 #ifndef DOXYGEN_RUN
217  SOL_ATTR_WARN_UNUSED_RESULT
218 #endif
219  ;
220 
232 enum sol_uart_parity sol_uart_parity_from_str(const char *parity)
233 #ifndef DOXYGEN_RUN
234  SOL_ATTR_WARN_UNUSED_RESULT
235 #endif
236  ;
237 
249 const char *sol_uart_parity_to_str(enum sol_uart_parity parity)
250 #ifndef DOXYGEN_RUN
251  SOL_ATTR_WARN_UNUSED_RESULT
252 #endif
253  ;
254 
266 enum sol_uart_stop_bits sol_uart_stop_bits_from_str(const char *stop_bits)
267 #ifndef DOXYGEN_RUN
268  SOL_ATTR_WARN_UNUSED_RESULT
269 #endif
270  ;
271 
283 const char *sol_uart_stop_bits_to_str(enum sol_uart_stop_bits stop_bits)
284 #ifndef DOXYGEN_RUN
285  SOL_ATTR_WARN_UNUSED_RESULT
286 #endif
287  ;
288 
300 struct sol_uart *sol_uart_open(const char *port_name, const struct sol_uart_config *config);
301 
311 void sol_uart_close(struct sol_uart *uart);
312 
328 int sol_uart_feed(struct sol_uart *uart, struct sol_blob *blob);
329 
334 #ifdef __cplusplus
335 }
336 #endif
const char * sol_uart_baud_rate_to_str(enum sol_uart_baud_rate baud_rate)
Converts sol_uart_baud_rate to a string name.
no parity is used.
Definition: sol-uart.h:85
enum sol_uart_baud_rate sol_uart_baud_rate_from_str(const char *baud_rate)
Converts a string UART baudRate to sol_uart_baud_rate.
sol_uart_stop_bits
Amount of stop bits.
Definition: sol-uart.h:93
Definition: sol-uart.h:66
Use 7 data bits.
Definition: sol-uart.h:75
ssize_t(* on_data)(void *data, struct sol_uart *uart, const struct sol_buffer *buf)
Callback containing data was read from UART.
Definition: sol-uart.h:118
bool flow_control
Enables software flow control(XOFF and XON)
Definition: sol-uart.h:150
Use 6 data bits.
Definition: sol-uart.h:76
enum sol_uart_parity parity
The parity value.
Definition: sol-uart.h:148
These routines are used for Soletta types' manipulation.
const char * sol_uart_parity_to_str(enum sol_uart_parity parity)
Converts sol_uart_parity to a string name.
Definition: sol-uart.h:65
the last data bit transmitted will be a logical 1 if the data transmitted had an odd amount of 0 bits...
Definition: sol-uart.h:87
Definition: sol-uart.h:64
sol_uart_baud_rate
Baud rate is the number of times the signal can switch states in one second.
Definition: sol-uart.h:62
These are common Soletta macros.
void(* on_feed_done)(void *data, struct sol_uart *uart, struct sol_blob *blob, int status)
Informs that a feed operation has ended.
Definition: sol-uart.h:129
These are routines that Soletta provides for its buffer implementation.
void sol_uart_close(struct sol_uart *uart)
Close an UART bus.
const char * sol_uart_stop_bits_to_str(enum sol_uart_stop_bits stop_bits)
Converts sol_uart_stop_bits to a string name.
#define SOL_ATTR_WARN_UNUSED_RESULT
Causes a warning to be emitted if a caller of the function with this attribute does not use its retur...
Definition: sol-macros.h:187
const char * sol_uart_data_bits_to_str(enum sol_uart_data_bits data_bits)
Converts sol_uart_data_bits to a string name.
const void * user_data
User data to sol_uart_config::on_feed_done() and sol_uart_config::on_data()
Definition: sol-uart.h:130
size_t data_buffer_size
The receiving buffer max size.
Definition: sol-uart.h:145
void * data
Buffer data.
Definition: sol-buffer.h:131
enum sol_uart_data_bits data_bits
The data bits value.
Definition: sol-uart.h:147
int sol_uart_feed(struct sol_uart *uart, struct sol_blob *blob)
Perform an UART asynchronous transmission.
Definition: sol-uart.h:63
enum sol_uart_stop_bits sol_uart_stop_bits_from_str(const char *stop_bits)
Converts a string UART stopBits to sol_uart_stop_bits.
Use one stop bit.
Definition: sol-uart.h:94
Use 5 data bits.
Definition: sol-uart.h:77
Data type describing the default blob implementation.
Definition: sol-types.h:468
size_t feed_size
The feed buffer max size.
Definition: sol-uart.h:140
Use two stop bits.
Definition: sol-uart.h:95
Use 8 data bits.
Definition: sol-uart.h:74
enum sol_uart_stop_bits stop_bits
The stop bits value.
Definition: sol-uart.h:149
sol_uart_data_bits
Amount of data bits.
Definition: sol-uart.h:73
enum sol_uart_data_bits sol_uart_data_bits_from_str(const char *data_bits)
Converts a string UART dataBits to sol_uart_data_bits.
sol_uart_parity
The parity characteristic can be even, odd, or none and it influences last trasmitted bit...
Definition: sol-uart.h:84
enum sol_uart_parity sol_uart_parity_from_str(const char *parity)
Converts a string UART parity to sol_uart_parity.
enum sol_uart_baud_rate baud_rate
The baud rate value.
Definition: sol-uart.h:146
the last data bit transmitted will be a logical 1 if the data transmitted had an even amount of 0 bit...
Definition: sol-uart.h:86
A sol_buffer is a dynamic array, that can be resized if needed.
Definition: sol-buffer.h:130
struct sol_uart sol_uart
A handle to a UART device.
Definition: sol-uart.h:55
A configuration struct used to set the UART paramenters.
Definition: sol-uart.h:104
Definition: sol-uart.h:67
struct sol_uart * sol_uart_open(const char *port_name, const struct sol_uart_config *config)
Open an UART bus.
struct sol_uart_config sol_uart_config
A configuration struct used to set the UART paramenters.