mraa  0.4.5
Low Level Skeleton Library for Communication on GNU/Linux platforms
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
spi.h
Go to the documentation of this file.
1 /*
2  * Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
3  * Copyright (c) 2014 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 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #include <stdio.h>
41 #include <fcntl.h>
42 #include <stdint.h>
43 
44 #include "common.h"
45 
49 typedef enum {
55 
59 typedef struct _spi* mraa_spi_context;
60 
67 mraa_spi_context mraa_spi_init(int bus);
68 
76 mraa_result_t mraa_spi_mode(mraa_spi_context dev, mraa_spi_mode_t mode);
77 
84 mraa_result_t mraa_spi_frequency(mraa_spi_context dev, int hz);
85 
92 uint8_t mraa_spi_write(mraa_spi_context dev, uint8_t data);
93 
102 uint8_t* mraa_spi_write_buf(mraa_spi_context dev, uint8_t* data, int length);
103 
111 mraa_result_t mraa_spi_lsbmode(mraa_spi_context dev, mraa_boolean_t lsb);
112 
120 mraa_result_t mraa_spi_bit_per_word(mraa_spi_context dev, unsigned int bits);
121 
128 mraa_result_t mraa_spi_stop(mraa_spi_context dev);
129 
130 #ifdef __cplusplus
131 }
132 #endif
Definition: spi.h:52
Definition: spi.h:51
unsigned int mraa_boolean_t
Definition: common.h:42
mraa_result_t mraa_spi_lsbmode(mraa_spi_context dev, mraa_boolean_t lsb)
mraa_result_t mraa_spi_frequency(mraa_spi_context dev, int hz)
mraa_result_t mraa_spi_bit_per_word(mraa_spi_context dev, unsigned int bits)
struct _spi * mraa_spi_context
Definition: spi.h:59
Definition: spi.h:53
mraa_result_t mraa_spi_stop(mraa_spi_context dev)
mraa_spi_mode_t
Definition: spi.h:49
Definition: spi.h:50
mraa_spi_context mraa_spi_init(int bus)
uint8_t mraa_spi_write(mraa_spi_context dev, uint8_t data)
mraa_result_t
Definition: types.h:49
uint8_t * mraa_spi_write_buf(mraa_spi_context dev, uint8_t *data, int length)
mraa_result_t mraa_spi_mode(mraa_spi_context dev, mraa_spi_mode_t mode)