Tizen RT Public API  v1.0 D5
iotbus_spi.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright 2016 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the License.
16  *
17  ****************************************************************************/
18 
31 #include <stdint.h>
32 
33 #ifndef IOTBUS_SPI_H_
34 #define IOTBUS_SPI_H_
35 
45 typedef enum {
46  IOTBUS_SPI_MODE0 = 0, IOTBUS_SPI_MODE1, IOTBUS_SPI_MODE2, IOTBUS_SPI_MODE3,
48 
53  char bits_per_word;
54  int lsb; // 0 is MSB, 1 is LSB
55  unsigned int chip_select;
56  unsigned int frequency; // frequency in Hz
57  iotbus_spi_mode_e mode;
58 };
59 
60 struct _iotbus_spi_s;
61 
65 typedef struct _iotbus_spi_s *iotbus_spi_context_h;
66 
67 #ifdef __cplusplus
68 extern "C"
69 {
70 #endif
71 
85 iotbus_spi_context_h iotbus_spi_open(unsigned int bus, const struct iotbus_spi_config_s *config);
86 
96 int iotbus_spi_write(iotbus_spi_context_h hnd, uint8_t *txbuf, int length);
97 
107 int iotbus_spi_recv(iotbus_spi_context_h hnd, uint8_t *rxbuf, int length);
108 
119 int iotbus_spi_transfer_buf(iotbus_spi_context_h hnd, uint8_t *txbuf, uint8_t *rxbuf, int length);
120 
129 
130 #ifdef __cplusplus
131 }
132 #endif
133 
134 #endif /* IOTBUS_SPI_H_ */
135  // end of SPI group
iotbus_spi_context_h iotbus_spi_open(unsigned int bus, const struct iotbus_spi_config_s *config)
initializes spi_context.
int iotbus_spi_transfer_buf(iotbus_spi_context_h hnd, uint8_t *txbuf, uint8_t *rxbuf, int length)
transfers rx and tx data over spi bus.
struct _iotbus_spi_s * iotbus_spi_context_h
Pointer definition to the internal struct _iotbus_spi_s.
Definition: iotbus_spi.h:65
Structure of SPI configuration.
Definition: iotbus_spi.h:52
int iotbus_spi_recv(iotbus_spi_context_h hnd, uint8_t *rxbuf, int length)
reads data over spi bus.
iotbus_spi_mode_e
Enumeration of SPI mode.
Definition: iotbus_spi.h:45
int iotbus_spi_close(iotbus_spi_context_h hnd)
closes spi_context.
int iotbus_spi_write(iotbus_spi_context_h hnd, uint8_t *txbuf, int length)
writes data over spi bus.