mraa  0.6.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
 All Data Structures Namespaces Files Functions 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 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 #include <stdio.h>
45 #include <fcntl.h>
46 #include <stdint.h>
47 
48 #include "common.h"
49 
53 typedef enum {
59 
63 typedef struct _spi* mraa_spi_context;
64 
71 mraa_spi_context mraa_spi_init(int bus);
72 
80 mraa_spi_context mraa_spi_init_raw(unsigned int bus, unsigned int cs);
81 
89 mraa_result_t mraa_spi_mode(mraa_spi_context dev, mraa_spi_mode_t mode);
90 
97 mraa_result_t mraa_spi_frequency(mraa_spi_context dev, int hz);
98 
105 uint8_t mraa_spi_write(mraa_spi_context dev, uint8_t data);
106 
115 uint8_t* mraa_spi_write_buf(mraa_spi_context dev, uint8_t* data, int length);
116 
126 mraa_result_t mraa_spi_transfer_buf(mraa_spi_context dev, uint8_t* data, uint8_t* rxbuf, int length);
127 
135 mraa_result_t mraa_spi_lsbmode(mraa_spi_context dev, mraa_boolean_t lsb);
136 
144 mraa_result_t mraa_spi_bit_per_word(mraa_spi_context dev, unsigned int bits);
145 
152 mraa_result_t mraa_spi_stop(mraa_spi_context dev);
153 
154 #ifdef __cplusplus
155 }
156 #endif
Definition: spi.h:56
Definition: spi.h:55
unsigned int mraa_boolean_t
Definition: common.h:44
mraa_spi_context mraa_spi_init_raw(unsigned int bus, unsigned int cs)
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:63
Definition: spi.h:57
mraa_result_t mraa_spi_stop(mraa_spi_context dev)
mraa_spi_mode_t
Definition: spi.h:53
Definition: spi.h:54
mraa_result_t mraa_spi_transfer_buf(mraa_spi_context dev, uint8_t *data, uint8_t *rxbuf, int length)
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:145
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)