le_spi_common.h

Go to the documentation of this file.
1 
2 /*
3  * ====================== WARNING ======================
4  *
5  * THE CONTENTS OF THIS FILE HAVE BEEN AUTO-GENERATED.
6  * DO NOT MODIFY IN ANY WAY.
7  *
8  * ====================== WARNING ======================
9  */
10 /**
11  * @file le_spi_common.h
12  *
13  * Type definitions for le_spi.
14  *
15  */
16 #ifndef LE_SPI_COMMON_H_INCLUDE_GUARD
17 #define LE_SPI_COMMON_H_INCLUDE_GUARD
18 
19 
20 #include "legato.h"
21 
22 #define IFGEN_LE_SPI_PROTOCOL_ID "740a490bba2182b36d04362adb42f669"
23 #define IFGEN_LE_SPI_MSG_SIZE 1046
24 /** @addtogroup le_spi
25  * @{ **/
26 
27 
28 //--------------------------------------------------------------------------------------------------
29 /**
30  * Max byte storage size for write buffer
31  */
32 //--------------------------------------------------------------------------------------------------
33 #define LE_SPI_MAX_WRITE_SIZE 1024
34 
35 //--------------------------------------------------------------------------------------------------
36 /**
37  * Max byte storage size for read buffer
38  */
39 //--------------------------------------------------------------------------------------------------
40 #define LE_SPI_MAX_READ_SIZE 1024
41 
42 //--------------------------------------------------------------------------------------------------
43 /**
44  * Handle for passing to related functions to access the SPI device
45  */
46 //--------------------------------------------------------------------------------------------------
47 typedef struct le_spi_DeviceHandle* le_spi_DeviceHandleRef_t;
48 
49 
50 
51 //--------------------------------------------------------------------------------------------------
52 /**
53  * Get if this client bound locally.
54  */
55 //--------------------------------------------------------------------------------------------------
56 LE_SHARED bool ifgen_le_spi_HasLocalBinding
57 (
58  void
59 );
60 
61 
62 //--------------------------------------------------------------------------------------------------
63 /**
64  * Init data that is common across all threads
65  */
66 //--------------------------------------------------------------------------------------------------
67 LE_SHARED void ifgen_le_spi_InitCommonData
68 (
69  void
70 );
71 
72 
73 //--------------------------------------------------------------------------------------------------
74 /**
75  * Perform common initialization and open a session
76  */
77 //--------------------------------------------------------------------------------------------------
78 LE_SHARED le_result_t ifgen_le_spi_OpenSession
79 (
80  le_msg_SessionRef_t _ifgen_sessionRef,
81  bool isBlocking
82 );
83 
84 //--------------------------------------------------------------------------------------------------
85 /**
86  * Opens an SPI device so that the attached device may be accessed.
87  *
88  * @return
89  * - LE_OK on success
90  * - LE_BAD_PARAMETER if the device name string is bad
91  * - LE_NOT_FOUND if the SPI device file could not be found
92  * - LE_NOT_PERMITTED if the SPI device file can't be opened for read/write
93  * - LE_DUPLICATE if the given device file is already opened by another spiService client
94  * - LE_FAULT for non-specific failures
95  */
96 //--------------------------------------------------------------------------------------------------
97 LE_SHARED le_result_t ifgen_le_spi_Open
98 (
99  le_msg_SessionRef_t _ifgen_sessionRef,
100  const char* LE_NONNULL deviceName,
101  ///< [IN] Handle for the SPI master to open
102  le_spi_DeviceHandleRef_t* handlePtr
103  ///< [OUT] Handle for passing to related functions in order to
104  ///< access the SPI device
105 );
106 
107 //--------------------------------------------------------------------------------------------------
108 /**
109  * Closes the device associated with the given handle and frees the associated resources.
110  *
111  * @note
112  * Once a handle is closed, it's not permitted to use it for future SPI access without first
113  * calling Open.
114  */
115 //--------------------------------------------------------------------------------------------------
116 LE_SHARED void ifgen_le_spi_Close
117 (
118  le_msg_SessionRef_t _ifgen_sessionRef,
120  ///< [IN] Handle for the SPI master to close
121 );
122 
123 //--------------------------------------------------------------------------------------------------
124 /**
125  * Configures an SPI device's data sample settings. The required values should be
126  * included in your target's datasheet. Most common @c Mode values are
127  * @c 0 and @c 3.
128  *
129  * These are the SPI Mode options:
130  * | Mode | Clock Polarity | Clock Phase | Clock Edge |
131  * | :-----: | :----------------: | :------------: | :------------: |
132  * | 0 | 0 | 0 | 1 |
133  * | 1 | 0 | 1 | 0 |
134  * | 2 | 1 | 0 | 1 |
135  * | 3 | 1 | 1 | 0 |
136  *
137  * @note
138  * This function should be called before any of the Read/Write functions to ensure
139  * the SPI bus configuration is in a known state.
140  */
141 //--------------------------------------------------------------------------------------------------
142 LE_SHARED void ifgen_le_spi_Configure
143 (
144  le_msg_SessionRef_t _ifgen_sessionRef,
146  ///< [IN] Handle for the SPI master to configure
147  int32_t mode,
148  ///< [IN] Choose mode options for the bus per above table
149  uint8_t bits,
150  ///< [IN] bits per word, typically 8 bits per word
151  uint32_t speed,
152  ///< [IN] max speed (Hz), this is slave dependant
153  int32_t msb
154  ///< [IN] set as 0 for MSB as first bit or 1 for LSB as first bit
155 );
156 
157 //--------------------------------------------------------------------------------------------------
158 /**
159  * Performs SPI WriteRead Half Duplex. You can send send Read command/ address of data to read.
160  *
161  * @return
162  * LE_OK on success or LE_FAULT on failure.
163  */
164 //--------------------------------------------------------------------------------------------------
165 LE_SHARED le_result_t ifgen_le_spi_WriteReadHD
166 (
167  le_msg_SessionRef_t _ifgen_sessionRef,
169  ///< [IN] Handle for the SPI master to perform the write-read on
170  const uint8_t* writeDataPtr,
171  ///< [IN] TX command/address being sent to slave with size
172  size_t writeDataSize,
173  ///< [IN]
174  uint8_t* readDataPtr,
175  ///< [OUT] RX response from slave with number of bytes reserved
176  ///< on master
177  size_t* readDataSizePtr
178  ///< [INOUT]
179 );
180 
181 //--------------------------------------------------------------------------------------------------
182 /**
183  * SPI Write for Half Duplex Communication
184  *
185  * @return
186  * LE_OK on success or LE_FAULT on failure.
187  */
188 //--------------------------------------------------------------------------------------------------
189 LE_SHARED le_result_t ifgen_le_spi_WriteHD
190 (
191  le_msg_SessionRef_t _ifgen_sessionRef,
193  ///< [IN] Handle for the SPI master to perform the write on
194  const uint8_t* writeDataPtr,
195  ///< [IN] TX command/address being sent to slave with size
196  size_t writeDataSize
197  ///< [IN]
198 );
199 
200 //--------------------------------------------------------------------------------------------------
201 /**
202  * SPI Read for Half Duplex Communication
203  *
204  * @return
205  * LE_OK on success or LE_FAULT on failure.
206  */
207 //--------------------------------------------------------------------------------------------------
208 LE_SHARED le_result_t ifgen_le_spi_ReadHD
209 (
210  le_msg_SessionRef_t _ifgen_sessionRef,
212  ///< [IN] Handle for the SPI master to perform the read from
213  uint8_t* readDataPtr,
214  ///< [OUT] RX response from slave with number of bytes reserved
215  ///< on master
216  size_t* readDataSizePtr
217  ///< [INOUT]
218 );
219 
220 //--------------------------------------------------------------------------------------------------
221 /**
222  * Simultaneous SPI Write and Read for full duplex communication
223  *
224  * @return
225  * LE_OK on success or LE_FAULT on failure.
226  */
227 //--------------------------------------------------------------------------------------------------
228 LE_SHARED le_result_t ifgen_le_spi_WriteReadFD
229 (
230  le_msg_SessionRef_t _ifgen_sessionRef,
232  ///< [IN] Handle for the SPI master to perform full duplex write-read on
233  const uint8_t* writeDataPtr,
234  ///< [IN] TX command/address being sent to slave with size
235  size_t writeDataSize,
236  ///< [IN]
237  uint8_t* readDataPtr,
238  ///< [OUT] RX response from slave with same buffer size as TX
239  size_t* readDataSizePtr
240  ///< [INOUT]
241 );
242 /** @} **/
243 #endif // LE_SPI_COMMON_H_INCLUDE_GUARD
#define LE_SHARED
Definition: le_basics.h:287
le_result_t
Definition: le_basics.h:46
struct le_spi_DeviceHandle * le_spi_DeviceHandleRef_t
Definition: le_spi_common.h:47
struct le_msg_Session * le_msg_SessionRef_t
Definition: le_messaging.h:860