mraa  1.0.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
 All Data Structures Namespaces Files Functions Typedefs Enumerations Enumerator Macros Pages
uart_ow.h
Go to the documentation of this file.
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2016 Intel Corporation
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #pragma once
26 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 #include <stdio.h>
63 
64 #include "common.h"
65 
66 /* for now, we simply use the normal MRAA UART context */
67 typedef struct _uart* mraa_uart_ow_context;
68 
69 /* 8 bytes (64 bits) for a device rom code */
70 static const int MRAA_UART_OW_ROMCODE_SIZE = 8;
71 
75 typedef enum {
82 
89 mraa_uart_ow_context mraa_uart_ow_init(int uart);
90 
97 mraa_uart_ow_context mraa_uart_ow_init_raw(const char* path);
98 
106 const char* mraa_uart_ow_get_dev_path(mraa_uart_ow_context dev);
107 
114 mraa_result_t mraa_uart_ow_stop(mraa_uart_ow_context dev);
115 
122 int mraa_uart_ow_read_byte(mraa_uart_ow_context dev);
123 
131 int mraa_uart_ow_write_byte(mraa_uart_ow_context dev, uint8_t byte);
132 
142 int mraa_uart_ow_bit(mraa_uart_ow_context dev, uint8_t bit);
143 
150 mraa_result_t mraa_uart_ow_reset(mraa_uart_ow_context dev);
151 
165 mraa_result_t mraa_uart_ow_rom_search(mraa_uart_ow_context dev, mraa_boolean_t start, uint8_t* id);
166 
176 mraa_result_t mraa_uart_ow_command(mraa_uart_ow_context dev, uint8_t command, uint8_t* id);
177 
185 uint8_t mraa_uart_ow_crc8(uint8_t* buffer, uint16_t length);
186 
187 #ifdef __cplusplus
188 }
189 #endif
Definition: uart_ow.h:80
mraa_uart_ow_context mraa_uart_ow_init_raw(const char *path)
unsigned int mraa_boolean_t
Definition: common.h:60
mraa_result_t mraa_uart_ow_rom_search(mraa_uart_ow_context dev, mraa_boolean_t start, uint8_t *id)
int mraa_uart_ow_read_byte(mraa_uart_ow_context dev)
Definition: uart_ow.h:76
mraa_uart_ow_context mraa_uart_ow_init(int uart)
const char * mraa_uart_ow_get_dev_path(mraa_uart_ow_context dev)
Definition: uart_ow.h:77
uint8_t mraa_uart_ow_crc8(uint8_t *buffer, uint16_t length)
Definition: uart_ow.h:79
int mraa_uart_ow_write_byte(mraa_uart_ow_context dev, uint8_t byte)
Definition: uart_ow.h:78
int mraa_uart_ow_bit(mraa_uart_ow_context dev, uint8_t bit)
mraa_result_t mraa_uart_ow_command(mraa_uart_ow_context dev, uint8_t command, uint8_t *id)
mraa_result_t
Definition: types.h:196
mraa_result_t mraa_uart_ow_reset(mraa_uart_ow_context dev)
mraa_result_t mraa_uart_ow_stop(mraa_uart_ow_context dev)
mraa_uart_ow_rom_cmd_t
Definition: uart_ow.h:75