mraa  1.5.1
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 #include "uart.h"
66 
67 /* 8 bytes (64 bits) for a device rom code */
68 #define MRAA_UART_OW_ROMCODE_SIZE 8
69 
70 /* for now, we simply use the normal MRAA UART context */
71 typedef struct _mraa_uart_ow {
72  mraa_uart_context uart;
73  /* search state */
74  unsigned char ROM_NO[MRAA_UART_OW_ROMCODE_SIZE]; /* 8 byte (64b) rom code */
75  int LastDiscrepancy;
76  int LastFamilyDiscrepancy;
77  mraa_boolean_t LastDeviceFlag;
79 
83 typedef enum {
90 
98 
106 
115 
123 
131 
139 int mraa_uart_ow_write_byte(mraa_uart_ow_context dev, uint8_t byte);
140 
150 int mraa_uart_ow_bit(mraa_uart_ow_context dev, uint8_t bit);
151 
159 
174 
184 mraa_result_t mraa_uart_ow_command(mraa_uart_ow_context dev, uint8_t command, uint8_t* id);
185 
193 uint8_t mraa_uart_ow_crc8(uint8_t* buffer, uint16_t length);
194 
195 #ifdef __cplusplus
196 }
197 #endif
UART module.
Definition: uart_ow.h:88
mraa_uart_ow_context mraa_uart_ow_init_raw(const char *path)
unsigned int mraa_boolean_t
Definition: common.h:61
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:84
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:71
Definition: uart_ow.h:85
uint8_t mraa_uart_ow_crc8(uint8_t *buffer, uint16_t length)
Definition: uart_ow.h:87
int mraa_uart_ow_write_byte(mraa_uart_ow_context dev, uint8_t byte)
Definition: uart_ow.h:86
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:204
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:83