mraa  1.8.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros 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 {
63 
67 typedef struct _spi* mraa_spi_context;
68 
75 mraa_spi_context mraa_spi_init(int bus);
76 
84 mraa_spi_context mraa_spi_init_raw(unsigned int bus, unsigned int cs);
85 
93 mraa_result_t mraa_spi_mode(mraa_spi_context dev, mraa_spi_mode_t mode);
94 
102 mraa_result_t mraa_spi_frequency(mraa_spi_context dev, int hz);
103 
111 int mraa_spi_write(mraa_spi_context dev, uint8_t data);
112 
120 int mraa_spi_write_word(mraa_spi_context dev, uint16_t data);
121 
131 uint8_t* mraa_spi_write_buf(mraa_spi_context dev, uint8_t* data, int length);
132 
142 uint16_t* mraa_spi_write_buf_word(mraa_spi_context dev, uint16_t* data, int length);
143 
154 mraa_result_t mraa_spi_transfer_buf(mraa_spi_context dev, uint8_t* data, uint8_t* rxbuf, int length);
155 
166 mraa_result_t mraa_spi_transfer_buf_word(mraa_spi_context dev, uint16_t* data, uint16_t* rxbuf, int length);
167 
175 mraa_result_t mraa_spi_lsbmode(mraa_spi_context dev, mraa_boolean_t lsb);
176 
184 mraa_result_t mraa_spi_bit_per_word(mraa_spi_context dev, unsigned int bits);
185 
192 mraa_result_t mraa_spi_stop(mraa_spi_context dev);
193 
194 #ifdef __cplusplus
195 }
196 #endif
Definition: spi.h:58
Definition: spi.h:56
unsigned int mraa_boolean_t
Definition: common.h:67
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:67
Definition: spi.h:60
int mraa_spi_write_word(mraa_spi_context dev, uint16_t data)
mraa_result_t mraa_spi_stop(mraa_spi_context dev)
int mraa_spi_write(mraa_spi_context dev, uint8_t data)
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)
mraa_result_t
Definition: types.h:206
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)
uint16_t * mraa_spi_write_buf_word(mraa_spi_context dev, uint16_t *data, int length)
mraa_result_t mraa_spi_transfer_buf_word(mraa_spi_context dev, uint16_t *data, uint16_t *rxbuf, int length)