Sensing time : 2.0 -> 5.0
[apps/native/position-finder-server.git] / inc / peripheral_io.h
1 /*\r
2  * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd.\r
3  *\r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  * http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 #ifndef __TIZEN_SYSTEM_PERIPHERAL_IO_H__\r
18 #define __TIZEN_SYSTEM_PERIPHERAL_IO_H__\r
19 \r
20 #include <stdint.h>\r
21 #include <tizen.h>\r
22 \r
23 #ifdef __cplusplus\r
24 extern "C" {\r
25 #endif\r
26 \r
27 /**\r
28  * @addtogroup CAPI_SYSTEM_PERIPHERAL_IO_MODULE\r
29  * @{\r
30  */\r
31 \r
32 /**\r
33  * @file peripheral_io.h\r
34  * @brief This file contains the peripheral-io API.\r
35  */\r
36 \r
37 /**\r
38  * @brief Enumeration for peripheral-io error.\r
39  * @since_tizen 4.0\r
40  */\r
41 typedef enum {\r
42         PERIPHERAL_ERROR_NONE                = TIZEN_ERROR_NONE,                /**< Successful */\r
43         PERIPHERAL_ERROR_IO_ERROR            = TIZEN_ERROR_IO_ERROR,            /**< I/O error */\r
44         PERIPHERAL_ERROR_NO_DEVICE           = TIZEN_ERROR_NO_SUCH_DEVICE,      /**< No such device */\r
45         PERIPHERAL_ERROR_TRY_AGAIN           = TIZEN_ERROR_TRY_AGAIN,           /**< Try again */\r
46         PERIPHERAL_ERROR_OUT_OF_MEMORY       = TIZEN_ERROR_OUT_OF_MEMORY,       /**< Out of memory */\r
47         PERIPHERAL_ERROR_PERMISSION_DENIED   = TIZEN_ERROR_PERMISSION_DENIED,   /**< Permission denied */\r
48         PERIPHERAL_ERROR_RESOURCE_BUSY       = TIZEN_ERROR_RESOURCE_BUSY,       /**< Device or resource busy */\r
49         PERIPHERAL_ERROR_INVALID_PARAMETER   = TIZEN_ERROR_INVALID_PARAMETER,   /**< Invalid parameter */\r
50         PERIPHERAL_ERROR_NOT_SUPPORTED       = TIZEN_ERROR_NOT_SUPPORTED,       /**< Not supported */\r
51         PERIPHERAL_ERROR_UNKNOWN             = TIZEN_ERROR_UNKNOWN,             /**< Unknown error */\r
52 } peripheral_error_e;\r
53 \r
54 /**\r
55 * @}\r
56 */\r
57 \r
58 /**\r
59  * @addtogroup CAPI_SYSTEM_PERIPHERAL_IO_GPIO_MODULE\r
60  * @{\r
61  */\r
62 \r
63 /**\r
64  * @brief Enumeration of GPIO direction options.\r
65  * @since_tizen 4.0\r
66  */\r
67 typedef enum {\r
68         PERIPHERAL_GPIO_DIRECTION_IN = 0,              /**< Input Mode */\r
69         PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_HIGH,  /**< Output mode with high value */\r
70         PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW,   /**< Output mode with low value */\r
71 } peripheral_gpio_direction_e;\r
72 \r
73 /**\r
74  * @brief Enumeration of edge types for the GPIO interrupt.\r
75  * @since_tizen 4.0\r
76  */\r
77 typedef enum {\r
78         PERIPHERAL_GPIO_EDGE_NONE = 0,  /**< No interrupt on GPIO */\r
79         PERIPHERAL_GPIO_EDGE_RISING,    /**< Interrupt on rising only */\r
80         PERIPHERAL_GPIO_EDGE_FALLING,   /**< Interrupt on falling only */\r
81         PERIPHERAL_GPIO_EDGE_BOTH,      /**< Interrupt on rising & falling */\r
82 } peripheral_gpio_edge_e;\r
83 \r
84 /**\r
85  * @brief The handle of a GPIO pin.\r
86  * @since_tizen 4.0\r
87  */\r
88 typedef struct _peripheral_gpio_s *peripheral_gpio_h;\r
89 \r
90 /**\r
91  * @platform\r
92  * @brief Opens a GPIO pin.\r
93  * @since_tizen 4.0\r
94  * @privlevel platform\r
95  * @privilege http://tizen.org/privilege/peripheralio\r
96  * @remarks @a gpio should be released with peripheral_gpio_close()\r
97  *\r
98  * @param[in] gpio_pin The GPIO pin number\r
99  * @param[out] gpio The GPIO handle is created on success\r
100  *\r
101  * @return 0 on success, otherwise a negative error value\r
102  * @retval #PERIPHERAL_ERROR_NONE Successful\r
103  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
104  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
105  * @retval #PERIPHERAL_ERROR_OUT_OF_MEMORY Memory allocation failed\r
106  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
107  * @retval #PERIPHERAL_ERROR_RESOURCE_BUSY Device is in use\r
108  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
109  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
110  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
111  *\r
112  * @post peripheral_gpio_close()\r
113  */\r
114 int peripheral_gpio_open(int gpio_pin, peripheral_gpio_h *gpio);\r
115 \r
116 /**\r
117  * @platform\r
118  * @brief Closes a GPIO pin.\r
119  * @since_tizen 4.0\r
120  * @privlevel platform\r
121  * @privilege http://tizen.org/privilege/peripheralio\r
122  *\r
123  * @param[in] gpio The GPIO handle\r
124  *\r
125  * @return 0 on success, otherwise a negative error value\r
126  * @retval #PERIPHERAL_ERROR_NONE Successful\r
127  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
128  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
129  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
130  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
131  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
132  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
133  *\r
134  * @pre peripheral_gpio_open()\r
135  */\r
136 int peripheral_gpio_close(peripheral_gpio_h gpio);\r
137 \r
138 /**\r
139  * @platform\r
140  * @brief Sets the GPIO direction.\r
141  * @since_tizen 4.0\r
142  * @privlevel platform\r
143  * @privilege http://tizen.org/privilege/peripheralio\r
144  *\r
145  * @param[in] gpio The GPIO handle\r
146  * @param[in] direction The direction of the GPIO pin\r
147  *\r
148  * @return 0 on success, otherwise a negative error value\r
149  * @retval #PERIPHERAL_ERROR_NONE Successful\r
150  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
151  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
152  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
153  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
154  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
155  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
156  *\r
157  * @see peripheral_gpio_direction_e\r
158  */\r
159 int peripheral_gpio_set_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e direction);\r
160 \r
161 /**\r
162  * @platform\r
163  * @brief Sets the GPIO edge mode.\r
164  * @since_tizen 4.0\r
165  * @privlevel platform\r
166  * @privilege http://tizen.org/privilege/peripheralio\r
167  *\r
168  * @param[in] gpio The GPIO handle\r
169  * @param[in] edge The edge mode of the GPIO pin\r
170  *\r
171  * @return 0 on success, otherwise a negative error value\r
172  * @retval #PERIPHERAL_ERROR_NONE Successful\r
173  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
174  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
175  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
176  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
177  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
178  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
179  *\r
180  * @see peripheral_gpio_edge_e\r
181  */\r
182 int peripheral_gpio_set_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e edge);\r
183 \r
184 /**\r
185  * @platform\r
186  * @brief The GPIO interrupted callback called when the GPIO interrupt is triggered.\r
187  * @since_tizen 4.0\r
188  *\r
189  * @param[in] gpio The GPIO handle\r
190  * @param[in] error The GPIO error\r
191  * @param[in] user_data The user data passed from the callback registration function\r
192  *\r
193  * @see peripheral_gpio_set_interrupted_cb()\r
194  */\r
195 typedef void(*peripheral_gpio_interrupted_cb)(peripheral_gpio_h gpio, peripheral_error_e error, void *user_data);\r
196 \r
197 /**\r
198  * @platform\r
199  * @brief Sets the GPIO interrupted callback to be invoked when the GPIO interrupt is triggered.\r
200  * @since_tizen 4.0\r
201  * @privlevel platform\r
202  * @privilege http://tizen.org/privilege/peripheralio\r
203  *\r
204  * @param[in] gpio The GPIO handle\r
205  * @param[in] callback The GPIO interrupted callback function to set\r
206  * @param[in] user_data The user data to be passed to the callback function\r
207  *\r
208  * @return 0 on success, otherwise a negative error value\r
209  * @retval #PERIPHERAL_ERROR_NONE Successful\r
210  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
211  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
212  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
213  *\r
214  * @post peripheral_gpio_unset_interrupted_cb()\r
215  * @see peripheral_gpio_set_edge_mode()\r
216  */\r
217 int peripheral_gpio_set_interrupted_cb(peripheral_gpio_h gpio, peripheral_gpio_interrupted_cb callback, void *user_data);\r
218 \r
219 /**\r
220  * @platform\r
221  * @brief Unsets the GPIO interrupted callback.\r
222  * @since_tizen 4.0\r
223  * @privlevel platform\r
224  * @privilege http://tizen.org/privilege/peripheralio\r
225  *\r
226  * @param[in] gpio The GPIO handle\r
227  *\r
228  * @return 0 on success, otherwise a negative error value\r
229  * @retval #PERIPHERAL_ERROR_NONE Successful\r
230  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
231  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
232  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
233  *\r
234  * @pre peripheral_gpio_set_interrupted_cb()\r
235  */\r
236 int peripheral_gpio_unset_interrupted_cb(peripheral_gpio_h gpio);\r
237 \r
238 /**\r
239  * @platform\r
240  * @brief Gets the current value of the GPIO pin.\r
241  * @since_tizen 4.0\r
242  * @privlevel platform\r
243  * @privilege http://tizen.org/privilege/peripheralio\r
244  *\r
245  * @param[in] gpio The GPIO handle\r
246  * @param[out] value The value to get\r
247  *\r
248  * @return 0 on success, otherwise a negative error value\r
249  * @retval #PERIPHERAL_ERROR_NONE Successful\r
250  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
251  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
252  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
253  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
254  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
255  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
256  *\r
257  * @see peripheral_gpio_write()\r
258  */\r
259 int peripheral_gpio_read(peripheral_gpio_h gpio, uint32_t *value);\r
260 \r
261 /**\r
262  * @platform\r
263  * @brief Sets the value of the GPIO pin.\r
264  * @since_tizen 4.0\r
265  * @privlevel platform\r
266  * @privilege http://tizen.org/privilege/peripheralio\r
267  *\r
268  * @param[in] gpio The GPIO handle\r
269  * @param[in] value The value to set (must be 0 or 1)\r
270  *\r
271  * @return 0 on success, otherwise a negative error value\r
272  * @retval #PERIPHERAL_ERROR_NONE Successful\r
273  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
274  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
275  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
276  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
277  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
278  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
279  *\r
280  * @see peripheral_gpio_read()\r
281  */\r
282 int peripheral_gpio_write(peripheral_gpio_h gpio, uint32_t value);\r
283 \r
284 /**\r
285 * @}\r
286 */\r
287 \r
288 /**\r
289  * @addtogroup CAPI_SYSTEM_PERIPHERAL_IO_I2C_MODULE\r
290  * @{\r
291  */\r
292 \r
293 /**\r
294  * @brief The handle of the I2C slave device.\r
295  * @since_tizen 4.0\r
296  */\r
297 typedef struct _peripheral_i2c_s *peripheral_i2c_h;\r
298 \r
299 /**\r
300  * @platform\r
301  * @brief Opens an I2C slave device.\r
302  * @since_tizen 4.0\r
303  * @privlevel platform\r
304  * @privilege http://tizen.org/privilege/peripheralio\r
305  * @remarks @a i2c should be released with peripheral_i2c_close()\r
306  *\r
307  * @param[in] bus The I2C bus number that the slave device is connected\r
308  * @param[in] address The address of the slave device\r
309  * @param[out] i2c The I2C handle is created on success\r
310  *\r
311  * @return 0 on success, otherwise a negative error value\r
312  * @retval #PERIPHERAL_ERROR_NONE Successful\r
313  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
314  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
315  * @retval #PERIPHERAL_ERROR_OUT_OF_MEMORY Memory allocation failed\r
316  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
317  * @retval #PERIPHERAL_ERROR_RESOURCE_BUSY Device is in use\r
318  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
319  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
320  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
321  *\r
322  * @post peripheral_i2c_close()\r
323  */\r
324 int peripheral_i2c_open(int bus, int address, peripheral_i2c_h *i2c);\r
325 \r
326 /**\r
327  * @platform\r
328  * @brief Closes an I2C slave device.\r
329  * @since_tizen 4.0\r
330  * @privlevel platform\r
331  * @privilege http://tizen.org/privilege/peripheralio\r
332  *\r
333  * @param[in] i2c The I2C handle\r
334  *\r
335  * @return 0 on success, otherwise a negative error value\r
336  * @retval #PERIPHERAL_ERROR_NONE Successful\r
337  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
338  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
339  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
340  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
341  *\r
342  * @pre peripheral_i2c_open()\r
343  */\r
344 int peripheral_i2c_close(peripheral_i2c_h i2c);\r
345 \r
346 /**\r
347  * @platform\r
348  * @brief Reads the bytes data from the I2C slave device.\r
349  * @since_tizen 4.0\r
350  * @privlevel platform\r
351  * @privilege http://tizen.org/privilege/peripheralio\r
352  *\r
353  * @param[in] i2c The I2C handle\r
354  * @param[out] data The data buffer to read\r
355  * @param[in] length The size of data buffer (in bytes)\r
356  *\r
357  * @return 0 on success, otherwise a negative error value\r
358  * @retval #PERIPHERAL_ERROR_NONE Successful\r
359  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
360  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
361  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
362  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
363  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
364  *\r
365  * @see peripheral_i2c_write()\r
366  */\r
367 int peripheral_i2c_read(peripheral_i2c_h i2c, uint8_t *data, uint32_t length);\r
368 \r
369 /**\r
370  * @platform\r
371  * @brief Writes the bytes data to the I2C slave device.\r
372  * @since_tizen 4.0\r
373  * @privlevel platform\r
374  * @privilege http://tizen.org/privilege/peripheralio\r
375  *\r
376  * @param[in] i2c The I2C handle\r
377  * @param[in] data The data buffer to write\r
378  * @param[in] length The size of data buffer (in bytes)\r
379  *\r
380  * @return 0 on success, otherwise a negative error value\r
381  * @retval #PERIPHERAL_ERROR_NONE Successful\r
382  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
383  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
384  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
385  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
386  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
387  *\r
388  * @see peripheral_i2c_read()\r
389  */\r
390 int peripheral_i2c_write(peripheral_i2c_h i2c, uint8_t *data, uint32_t length);\r
391 \r
392 /**\r
393  * @platform\r
394  * @brief Reads single byte data from the register of the I2C slave device.\r
395  * @since_tizen 4.0\r
396  * @privlevel platform\r
397  * @privilege http://tizen.org/privilege/peripheralio\r
398  *\r
399  * @param[in] i2c The I2C handle\r
400  * @param[in] reg The register address of the I2C slave device to read\r
401  * @param[out] data The single byte data to read\r
402  *\r
403  * @return 0 on success, otherwise a negative error value\r
404  * @retval #PERIPHERAL_ERROR_NONE Successful\r
405  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
406  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
407  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
408  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
409  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
410  *\r
411  * @see peripheral_i2c_write_register_byte()\r
412  */\r
413 int peripheral_i2c_read_register_byte(peripheral_i2c_h i2c, uint8_t reg, uint8_t *data);\r
414 \r
415 /**\r
416  * @platform\r
417  * @brief Writes single byte data to the register of the I2C slave device.\r
418  * @since_tizen 4.0\r
419  * @privlevel platform\r
420  * @privilege http://tizen.org/privilege/peripheralio\r
421  *\r
422  * @param[in] i2c The I2C handle\r
423  * @param[in] reg The register address of the I2C slave device to write\r
424  * @param[in] data The single byte data to write\r
425  *\r
426  * @return 0 on success, otherwise a negative error value\r
427  * @retval #PERIPHERAL_ERROR_NONE Successful\r
428  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
429  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
430  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
431  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
432  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
433  *\r
434  * @see peripheral_i2c_read_register_byte()\r
435  */\r
436 int peripheral_i2c_write_register_byte(peripheral_i2c_h i2c, uint8_t reg, uint8_t data);\r
437 \r
438 /**\r
439  * @platform\r
440  * @brief Reads word data from the register of the I2C slave device.\r
441  * @since_tizen 4.0\r
442  * @privlevel platform\r
443  * @privilege http://tizen.org/privilege/peripheralio\r
444  *\r
445  * @param[in] i2c The I2C handle\r
446  * @param[in] reg The register address of the I2C slave device to read\r
447  * @param[out] data The word(2 bytes) data to read\r
448  *\r
449  * @return 0 on success, otherwise a negative error value\r
450  * @retval #PERIPHERAL_ERROR_NONE Successful\r
451  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
452  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
453  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
454  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
455  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
456  *\r
457  * @see peripheral_i2c_write_register_word()\r
458  */\r
459 int peripheral_i2c_read_register_word(peripheral_i2c_h i2c, uint8_t reg, uint16_t *data);\r
460 \r
461 /**\r
462  * @platform\r
463  * @brief Writes word data to the register of the I2C slave device.\r
464  * @since_tizen 4.0\r
465  * @privlevel platform\r
466  * @privilege http://tizen.org/privilege/peripheralio\r
467  *\r
468  * @param[in] i2c The I2C handle\r
469  * @param[in] reg The register address of the I2C slave device to write\r
470  * @param[in] data The word(2 bytes) data to write\r
471  *\r
472  * @return 0 on success, otherwise a negative error value\r
473  * @retval #PERIPHERAL_ERROR_NONE Successful\r
474  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
475  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
476  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
477  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
478  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
479  *\r
480  * @see peripheral_i2c_read_register_word()\r
481  */\r
482 int peripheral_i2c_write_register_word(peripheral_i2c_h i2c, uint8_t reg, uint16_t data);\r
483 \r
484 /**\r
485 * @}\r
486 */\r
487 \r
488 /**\r
489  * @addtogroup CAPI_SYSTEM_PERIPHERAL_IO_PWM_MODULE\r
490  * @{\r
491  */\r
492 \r
493 /**\r
494  * @brief The handle of the PWM device.\r
495  * @since_tizen 4.0\r
496  */\r
497 typedef struct _peripheral_pwm_s *peripheral_pwm_h;\r
498 \r
499 /**\r
500  * @brief Enumeration for Polarity.\r
501  * @since_tizen 4.0\r
502  */\r
503 typedef enum {\r
504         PERIPHERAL_PWM_POLARITY_ACTIVE_HIGH = 0, /**< PWM signal start in the active high state (Normal) */\r
505         PERIPHERAL_PWM_POLARITY_ACTIVE_LOW,      /**< PWM signal start in the active low state (Inversed) */\r
506 } peripheral_pwm_polarity_e;\r
507 \r
508 /**\r
509  * @platform\r
510  * @brief Opens the PWM pin.\r
511  * @since_tizen 4.0\r
512  * @privlevel platform\r
513  * @privilege http://tizen.org/privilege/peripheralio\r
514  * @remarks @a pwm should be released with peripheral_pwm_close()\r
515  *\r
516  * @param[in] chip The PWM chip number\r
517  * @param[in] pin The PWM pin(channel) number to control\r
518  * @param[out] pwm The PWM handle is created on success\r
519  *\r
520  * @return 0 on success, otherwise a negative error value\r
521  * @retval #PERIPHERAL_ERROR_NONE Successful\r
522  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
523  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
524  * @retval #PERIPHERAL_ERROR_OUT_OF_MEMORY Memory allocation failed\r
525  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
526  * @retval #PERIPHERAL_ERROR_RESOURCE_BUSY Device is in use\r
527  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
528  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
529  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
530  *\r
531  * @post peripheral_pwm_close()\r
532  */\r
533 int peripheral_pwm_open(int chip, int pin, peripheral_pwm_h *pwm);\r
534 \r
535 /**\r
536  * @platform\r
537  * @brief Closes the PWM pin.\r
538  * @since_tizen 4.0\r
539  * @privlevel platform\r
540  * @privilege http://tizen.org/privilege/peripheralio\r
541  *\r
542  * @param[in] pwm The PWM handle\r
543  *\r
544  * @return 0 on success, otherwise a negative error value\r
545  * @retval #PERIPHERAL_ERROR_NONE Successful\r
546  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
547  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
548  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
549  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
550  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
551  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
552  *\r
553  * @pre peripheral_pwm_open()\r
554  */\r
555 int peripheral_pwm_close(peripheral_pwm_h pwm);\r
556 \r
557 /**\r
558  * @platform\r
559  * @brief Sets period of the PWM pin.\r
560  * @since_tizen 4.0\r
561  * @privlevel platform\r
562  * @privilege http://tizen.org/privilege/peripheralio\r
563  *\r
564  * @param[in] pwm The PWM handle\r
565  * @param[in] period_ns The total period of the PWM pin (in nanoseconds)\r
566  *\r
567  * @return 0 on success, otherwise a negative error value\r
568  * @retval #PERIPHERAL_ERROR_NONE Successful\r
569  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
570  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
571  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
572  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
573  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
574  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
575  */\r
576 int peripheral_pwm_set_period(peripheral_pwm_h pwm, uint32_t period_ns);\r
577 \r
578 /**\r
579  * @platform\r
580  * @brief Sets duty cycle of the PWM pin.\r
581  * @since_tizen 4.0\r
582  * @privlevel platform\r
583  * @privilege http://tizen.org/privilege/peripheralio\r
584  *\r
585  * @param[in] pwm The PWM handle\r
586  * @param[in] duty_cycle_ns The duty cycle of the PWM pin (in nanoseconds)\r
587  *\r
588  * @return 0 on success, otherwise a negative error value\r
589  * @retval #PERIPHERAL_ERROR_NONE Successful\r
590  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
591  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
592  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
593  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
594  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
595  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
596  */\r
597 int peripheral_pwm_set_duty_cycle(peripheral_pwm_h pwm, uint32_t duty_cycle_ns);\r
598 \r
599 /**\r
600  * @platform\r
601  * @brief Sets polarity of the PWM pin.\r
602  * @since_tizen 4.0\r
603  * @privlevel platform\r
604  * @privilege http://tizen.org/privilege/peripheralio\r
605  *\r
606  * @param[in] pwm The PWM handle\r
607  * @param[in] polarity The polarity of the PWM pin\r
608  *\r
609  * @return 0 on success, otherwise a negative error value\r
610  * @retval #PERIPHERAL_ERROR_NONE Successful\r
611  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
612  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
613  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
614  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
615  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
616  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
617  *\r
618  * @see peripheral_pwm_polarity_e\r
619  */\r
620 int peripheral_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e polarity);\r
621 \r
622 /**\r
623  * @platform\r
624  * @brief Enables the PWM pin.\r
625  * @since_tizen 4.0\r
626  * @privlevel platform\r
627  * @privilege http://tizen.org/privilege/peripheralio\r
628  *\r
629  * @param[in] pwm The PWM handle\r
630  * @param[in] enabled Enable/disable the PWM pin\r
631  *\r
632  * @return 0 on success, otherwise a negative error value\r
633  * @retval #PERIPHERAL_ERROR_NONE Successful\r
634  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
635  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
636  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
637  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
638  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
639  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
640  */\r
641 int peripheral_pwm_set_enabled(peripheral_pwm_h pwm, bool enabled);\r
642 \r
643 /**\r
644 * @}\r
645 */\r
646 \r
647 /**\r
648  * @addtogroup CAPI_SYSTEM_PERIPHERAL_IO_UART_MODULE\r
649  * @{\r
650  */\r
651 \r
652 /**\r
653  * @brief The handle to the UART device.\r
654  * @since_tizen 4.0\r
655  */\r
656 typedef struct _peripheral_uart_s *peripheral_uart_h;\r
657 \r
658 /**\r
659  * @brief Enumeration for baud rate.\r
660  * @since_tizen 4.0\r
661  */\r
662 typedef enum {\r
663         PERIPHERAL_UART_BAUD_RATE_0 = 0,  /**< The number of signal in one second is 0 */\r
664         PERIPHERAL_UART_BAUD_RATE_50,     /**< The number of signal in one second is 50 */\r
665         PERIPHERAL_UART_BAUD_RATE_75,     /**< The number of signal in one second is 75 */\r
666         PERIPHERAL_UART_BAUD_RATE_110,    /**< The number of signal in one second is 110 */\r
667         PERIPHERAL_UART_BAUD_RATE_134,    /**< The number of signal in one second is 134 */\r
668         PERIPHERAL_UART_BAUD_RATE_150,    /**< The number of signal in one second is 150 */\r
669         PERIPHERAL_UART_BAUD_RATE_200,    /**< The number of signal in one second is 200 */\r
670         PERIPHERAL_UART_BAUD_RATE_300,    /**< The number of signal in one second is 300 */\r
671         PERIPHERAL_UART_BAUD_RATE_600,    /**< The number of signal in one second is 600 */\r
672         PERIPHERAL_UART_BAUD_RATE_1200,   /**< The number of signal in one second is 1200 */\r
673         PERIPHERAL_UART_BAUD_RATE_1800,   /**< The number of signal in one second is 1800 */\r
674         PERIPHERAL_UART_BAUD_RATE_2400,   /**< The number of signal in one second is 2400 */\r
675         PERIPHERAL_UART_BAUD_RATE_4800,   /**< The number of signal in one second is 4800 */\r
676         PERIPHERAL_UART_BAUD_RATE_9600,   /**< The number of signal in one second is 9600 */\r
677         PERIPHERAL_UART_BAUD_RATE_19200,  /**< The number of signal in one second is 19200 */\r
678         PERIPHERAL_UART_BAUD_RATE_38400,  /**< The number of signal in one second is 38400 */\r
679         PERIPHERAL_UART_BAUD_RATE_57600,  /**< The number of signal in one second is 57600 */\r
680         PERIPHERAL_UART_BAUD_RATE_115200, /**< The number of signal in one second is 115200 */\r
681         PERIPHERAL_UART_BAUD_RATE_230400, /**< The number of signal in one second is 230400 */\r
682 } peripheral_uart_baud_rate_e;\r
683 \r
684 /**\r
685  * @brief Enumeration for byte size.\r
686  * @since_tizen 4.0\r
687  */\r
688 typedef enum {\r
689         PERIPHERAL_UART_BYTE_SIZE_5BIT = 0, /**< 5 data bits */\r
690         PERIPHERAL_UART_BYTE_SIZE_6BIT,     /**< 6 data bits */\r
691         PERIPHERAL_UART_BYTE_SIZE_7BIT,     /**< 7 data bits */\r
692         PERIPHERAL_UART_BYTE_SIZE_8BIT,     /**< 8 data bits */\r
693 } peripheral_uart_byte_size_e;\r
694 \r
695 /**\r
696  * @brief Enumeration for parity bit.\r
697  * @since_tizen 4.0\r
698  */\r
699 typedef enum {\r
700         PERIPHERAL_UART_PARITY_NONE = 0, /**< No parity is used */\r
701         PERIPHERAL_UART_PARITY_EVEN,     /**< Even parity is used */\r
702         PERIPHERAL_UART_PARITY_ODD,      /**< ODD parity is used */\r
703 } peripheral_uart_parity_e;\r
704 \r
705 /**\r
706  * @brief Enumeration for stop bits.\r
707  * @since_tizen 4.0\r
708  */\r
709 typedef enum {\r
710         PERIPHERAL_UART_STOP_BITS_1BIT = 0, /**< One stop bit */\r
711         PERIPHERAL_UART_STOP_BITS_2BIT,     /**< Two stop bits */\r
712 } peripheral_uart_stop_bits_e;\r
713 \r
714 /**\r
715  * @brief Enumeration for hardware flow control.\r
716  * @since_tizen 4.0\r
717  */\r
718 typedef enum {\r
719         PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_NONE = 0,    /**< No hardware flow control */\r
720         PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_AUTO_RTSCTS, /**< Automatic RTS/CTS hardware flow control*/\r
721 } peripheral_uart_hardware_flow_control_e;\r
722 \r
723 /**\r
724  * @brief Enumeration for software flow control.\r
725  * @since_tizen 4.0\r
726  */\r
727 typedef enum {\r
728         PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_NONE = 0,    /**< No software flow control */\r
729         PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_XONXOFF,     /**< XON/XOFF software flow control */\r
730 } peripheral_uart_software_flow_control_e;\r
731 \r
732 /**\r
733  * @platform\r
734  * @brief Opens the UART slave device.\r
735  * @since_tizen 4.0\r
736  * @privlevel platform\r
737  * @privilege http://tizen.org/privilege/peripheralio\r
738  * @remarks @a uart should be released with peripheral_uart_close()\r
739  *\r
740  * @param[in] port The UART port number that the slave device is connected\r
741  * @param[out] uart The UART handle is created on success\r
742  *\r
743  * @return 0 on success, otherwise a negative error value\r
744  * @retval #PERIPHERAL_ERROR_NONE Successful\r
745  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
746  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
747  * @retval #PERIPHERAL_ERROR_OUT_OF_MEMORY Memory allocation failed\r
748  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
749  * @retval #PERIPHERAL_ERROR_RESOURCE_BUSY Device is in use\r
750  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
751  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
752  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
753  *\r
754  * @post peripheral_uart_close()\r
755  */\r
756 int peripheral_uart_open(int port, peripheral_uart_h *uart);\r
757 \r
758 /**\r
759  * @platform\r
760  * @brief Closes the UART slave device.\r
761  * @since_tizen 4.0\r
762  * @privlevel platform\r
763  * @privilege http://tizen.org/privilege/peripheralio\r
764  *\r
765  * @param[in] uart The UART handle\r
766  *\r
767  * @return 0 on success, otherwise a negative error value\r
768  * @retval #PERIPHERAL_ERROR_NONE Successful\r
769  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
770  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
771  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
772  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
773  *\r
774  * @pre peripheral_uart_open()\r
775  */\r
776 int peripheral_uart_close(peripheral_uart_h uart);\r
777 \r
778 /**\r
779  * @platform\r
780  * @brief Sets baud rate of the UART slave device.\r
781  * @since_tizen 4.0\r
782  * @privlevel platform\r
783  * @privilege http://tizen.org/privilege/peripheralio\r
784  *\r
785  * @param[in] uart The UART handle\r
786  * @param[in] baud Baud rate of the UART device\r
787  *\r
788  * @return 0 on success, otherwise a negative error value\r
789  * @retval #PERIPHERAL_ERROR_NONE Successful\r
790  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
791  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
792  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
793  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
794  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
795  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
796  *\r
797  * @see peripheral_uart_baud_rate_e\r
798  */\r
799 int peripheral_uart_set_baud_rate(peripheral_uart_h uart, peripheral_uart_baud_rate_e baud);\r
800 \r
801 /**\r
802  * @platform\r
803  * @brief Sets byte size of the UART slave device.\r
804  * @since_tizen 4.0\r
805  * @privlevel platform\r
806  * @privilege http://tizen.org/privilege/peripheralio\r
807  *\r
808  * @param[in] uart The UART handle\r
809  * @param[in] byte_size Byte size of the UART device\r
810  *\r
811  * @return 0 on success, otherwise a negative error value\r
812  * @retval #PERIPHERAL_ERROR_NONE Successful\r
813  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
814  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
815  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
816  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
817  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
818  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
819  *\r
820  * @see peripheral_uart_byte_size_e\r
821  */\r
822 int peripheral_uart_set_byte_size(peripheral_uart_h uart, peripheral_uart_byte_size_e byte_size);\r
823 \r
824 /**\r
825  * @platform\r
826  * @brief Sets parity bit of the UART slave device.\r
827  * @since_tizen 4.0\r
828  * @privlevel platform\r
829  * @privilege http://tizen.org/privilege/peripheralio\r
830  *\r
831  * @param[in] uart The UART handle\r
832  * @param[in] parity Parity bit of the UART device\r
833  *\r
834  * @return 0 on success, otherwise a negative error value\r
835  * @retval #PERIPHERAL_ERROR_NONE Successful\r
836  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
837  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
838  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
839  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
840  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
841  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
842  *\r
843  * @see peripheral_uart_parity_e\r
844  */\r
845 int peripheral_uart_set_parity(peripheral_uart_h uart, peripheral_uart_parity_e parity);\r
846 \r
847 /**\r
848  * @platform\r
849  * @brief Sets stop bits of the UART slave device.\r
850  * @since_tizen 4.0\r
851  * @privlevel platform\r
852  * @privilege http://tizen.org/privilege/peripheralio\r
853  *\r
854  * @param[in] uart The UART handle\r
855  * @param[in] stop_bits Stop bits of the UART device\r
856  *\r
857  * @return 0 on success, otherwise a negative error value\r
858  * @retval #PERIPHERAL_ERROR_NONE Successful\r
859  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
860  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
861  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
862  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
863  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
864  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
865  *\r
866  * @see peripheral_uart_stop_bits_e\r
867  */\r
868 int peripheral_uart_set_stop_bits(peripheral_uart_h uart, peripheral_uart_stop_bits_e stop_bits);\r
869 \r
870 /**\r
871  * @platform\r
872  * @brief Sets flow control of the UART slave device.\r
873  * @since_tizen 4.0\r
874  * @privlevel platform\r
875  * @privilege http://tizen.org/privilege/peripheralio\r
876  *\r
877  * @param[in] uart The UART handle\r
878  * @param[in] sw_flow_control Software flow control (Turns a transmitter on or off)\r
879  * @param[in] hw_flow_control Hardware flow control (Turns "Request to Send/Clear to Send" on or off)\r
880  *\r
881  * @return 0 on success, otherwise a negative error value\r
882  * @retval #PERIPHERAL_ERROR_NONE Successful\r
883  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
884  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
885  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
886  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
887  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
888  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
889  *\r
890  * @see peripheral_uart_software_flow_control_e\r
891  * @see peripheral_uart_hardware_flow_control_e\r
892  */\r
893 int peripheral_uart_set_flow_control(peripheral_uart_h uart,\r
894                         peripheral_uart_software_flow_control_e sw_flow_control,\r
895                         peripheral_uart_hardware_flow_control_e hw_flow_control);\r
896 \r
897 /**\r
898  * @platform\r
899  * @brief Reads data from the UART slave device.\r
900  * @since_tizen 4.0\r
901  * @privlevel platform\r
902  * @privilege http://tizen.org/privilege/peripheralio\r
903  *\r
904  * @param[in] uart The UART handle\r
905  * @param[out] data The buffer to read\r
906  * @param[out] length The size of buffer (in bytes)\r
907  *\r
908  * @return the number of bytes read on success, otherwise a negative error value\r
909  * @retval #PERIPHERAL_ERROR_NONE Successful\r
910  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
911  * @retval #PERIPHERAL_ERROR_TRY_AGAIN Try again\r
912  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
913  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
914  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
915  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
916  *\r
917  * @see peripheral_uart_write()\r
918  */\r
919 int peripheral_uart_read(peripheral_uart_h uart, uint8_t *data, uint32_t length);\r
920 \r
921 /**\r
922  * @platform\r
923  * @brief Writes data to the UART slave device.\r
924  * @since_tizen 4.0\r
925  * @privlevel platform\r
926  * @privilege http://tizen.org/privilege/peripheralio\r
927  *\r
928  * @param[in] uart The UART handle\r
929  * @param[in] data The buffer to write\r
930  * @param[in] length The size of buffer (in bytes)\r
931  *\r
932  * @return the number of bytes write on success, otherwise a negative error value\r
933  * @retval #PERIPHERAL_ERROR_NONE Successful\r
934  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
935  * @retval #PERIPHERAL_ERROR_TRY_AGAIN Try again\r
936  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
937  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
938  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
939  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
940  *\r
941  * @see peripheral_uart_read()\r
942  */\r
943 int peripheral_uart_write(peripheral_uart_h uart, uint8_t *data, uint32_t length);\r
944 \r
945 /**\r
946 * @}\r
947 */\r
948 \r
949 /**\r
950  * @addtogroup CAPI_SYSTEM_PERIPHERAL_IO_SPI_MODULE\r
951  * @{\r
952  */\r
953 \r
954 /**\r
955  * @brief The handle of a SPI device.\r
956  * @since_tizen 4.0\r
957  */\r
958 typedef struct _peripheral_spi_s *peripheral_spi_h;\r
959 \r
960 /**\r
961  * @brief Enumeration of SPI transfer modes.\r
962  * @since_tizen 4.0\r
963  */\r
964 typedef enum {\r
965         PERIPHERAL_SPI_MODE_0 = 0,   /**< CPOL = 0, CPHa = 0 Mode */\r
966         PERIPHERAL_SPI_MODE_1,       /**< CPOL = 0, CPHa = 1 Mode */\r
967         PERIPHERAL_SPI_MODE_2,       /**< CPOL = 1, CPHa = 0 Mode */\r
968         PERIPHERAL_SPI_MODE_3,       /**< CPOL = 1, CPHa = 1 Mode */\r
969 } peripheral_spi_mode_e;\r
970 \r
971 /**\r
972  * @brief Enumeration of bit orders.\r
973  * @since_tizen 4.0\r
974  */\r
975 typedef enum {\r
976         PERIPHERAL_SPI_BIT_ORDER_MSB = 0, /**< Use most siginificant bit first */\r
977         PERIPHERAL_SPI_BIT_ORDER_LSB,     /**< Use least significant bit first */\r
978 } peripheral_spi_bit_order_e;\r
979 \r
980 /**\r
981  * @platform\r
982  * @brief Opens a SPI slave device.\r
983  * @since_tizen 4.0\r
984  * @privlevel platform\r
985  * @privilege http://tizen.org/privilege/peripheralio\r
986  * @remarks @a spi should be released with peripheral_spi_close()\r
987  *\r
988  * @param[in] bus The SPI bus number\r
989  * @param[in] cs The SPI chip select number\r
990  * @param[out] spi The SPI device handle\r
991  *\r
992  * @return 0 on success, otherwise a negative error value\r
993  * @retval #PERIPHERAL_ERROR_NONE Successful\r
994  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
995  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
996  * @retval #PERIPHERAL_ERROR_OUT_OF_MEMORY Memory allocation failed\r
997  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
998  * @retval #PERIPHERAL_ERROR_RESOURCE_BUSY Device is in use\r
999  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
1000  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
1001  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
1002  *\r
1003  * @post peripheral_spi_close()\r
1004  */\r
1005 int peripheral_spi_open(int bus, int cs, peripheral_spi_h *spi);\r
1006 \r
1007 /**\r
1008  * @platform\r
1009  * @brief Closes the SPI slave device.\r
1010  * @since_tizen 4.0\r
1011  * @privlevel platform\r
1012  * @privilege http://tizen.org/privilege/peripheralio\r
1013  *\r
1014  * @param[in] spi The SPI device handle\r
1015  *\r
1016  * @return 0 on success, otherwise a negative error value\r
1017  * @retval #PERIPHERAL_ERROR_NONE Successful\r
1018  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
1019  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
1020  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
1021  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
1022  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
1023  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
1024  *\r
1025  * @see peripheral_spi_open()\r
1026  */\r
1027 int peripheral_spi_close(peripheral_spi_h spi);\r
1028 \r
1029 /**\r
1030  * @platform\r
1031  * @brief Sets the SPI transfer mode.\r
1032  * @since_tizen 4.0\r
1033  * @privlevel platform\r
1034  * @privilege http://tizen.org/privilege/peripheralio\r
1035  *\r
1036  * @param[in] spi The SPI device handle\r
1037  * @param[in] mode The SPI transfer mode\r
1038  *\r
1039  * @return 0 on success, otherwise a negative error value\r
1040  * @retval #PERIPHERAL_ERROR_NONE Successful\r
1041  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
1042  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
1043  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
1044  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
1045  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
1046  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
1047  *\r
1048  * @see peripheral_spi_mode_e\r
1049  */\r
1050 int peripheral_spi_set_mode(peripheral_spi_h spi, peripheral_spi_mode_e mode);\r
1051 \r
1052 /**\r
1053  * @platform\r
1054  * @brief Sets the SPI bit order.\r
1055  * @since_tizen 4.0\r
1056  * @privlevel platform\r
1057  * @privilege http://tizen.org/privilege/peripheralio\r
1058  *\r
1059  * @param[in] spi The SPI device handle\r
1060  * @param[in] bit_order The transfer bit order\r
1061  *\r
1062  * @return 0 on success, otherwise a negative error value\r
1063  * @retval #PERIPHERAL_ERROR_NONE Successful\r
1064  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
1065  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
1066  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
1067  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
1068  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
1069  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
1070  *\r
1071  * @see peripheral_spi_bit_order_e\r
1072  */\r
1073 int peripheral_spi_set_bit_order(peripheral_spi_h spi, peripheral_spi_bit_order_e bit_order);\r
1074 \r
1075 /**\r
1076  * @platform\r
1077  * @brief Sets the number of bits per word.\r
1078  * @since_tizen 4.0\r
1079  * @privlevel platform\r
1080  * @privilege http://tizen.org/privilege/peripheralio\r
1081  *\r
1082  * @param[in] spi The SPI device handle\r
1083  * @param[in] bits The number of bits per word (in bits)\r
1084  *\r
1085  * @return 0 on success, otherwise a negative error value\r
1086  * @retval #PERIPHERAL_ERROR_NONE Successful\r
1087  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
1088  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
1089  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
1090  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
1091  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
1092  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
1093  */\r
1094 int peripheral_spi_set_bits_per_word(peripheral_spi_h spi, uint8_t bits);\r
1095 \r
1096 /**\r
1097  * @platform\r
1098  * @brief Sets the frequency of the SPI bus.\r
1099  * @since_tizen 4.0\r
1100  * @privlevel platform\r
1101  * @privilege http://tizen.org/privilege/peripheralio\r
1102  * @remarks The frequencies supported are board dependent.\r
1103  *\r
1104  * @param[in] spi The SPI device handle\r
1105  * @param[in] freq_hz Frequency to set (in Hz)\r
1106  *\r
1107  * @return 0 on success, otherwise a negative error value\r
1108  * @retval #PERIPHERAL_ERROR_NONE Successful\r
1109  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
1110  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
1111  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
1112  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
1113  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
1114  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
1115  */\r
1116 int peripheral_spi_set_frequency(peripheral_spi_h spi, uint32_t freq_hz);\r
1117 \r
1118 /**\r
1119  * @platform\r
1120  * @brief Reads the bytes data from the SPI slave device.\r
1121  * @since_tizen 4.0\r
1122  * @privlevel platform\r
1123  * @privilege http://tizen.org/privilege/peripheralio\r
1124  *\r
1125  * @param[in] spi The SPI device handle\r
1126  * @param[out] data The data buffer to read\r
1127  * @param[in] length The size of data buffer (in bytes)\r
1128  *\r
1129  * @return 0 on success, otherwise a negative error value\r
1130  * @retval #PERIPHERAL_ERROR_NONE Successful\r
1131  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
1132  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
1133  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
1134  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
1135  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
1136  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
1137  *\r
1138  * @see peripheral_spi_write()\r
1139  */\r
1140 int peripheral_spi_read(peripheral_spi_h spi, uint8_t *data, uint32_t length);\r
1141 \r
1142 /**\r
1143  * @platform\r
1144  * @brief Writes the bytes data to the SPI slave device.\r
1145  * @since_tizen 4.0\r
1146  * @privlevel platform\r
1147  * @privilege http://tizen.org/privilege/peripheralio\r
1148  *\r
1149  * @param[in] spi The SPI device handle\r
1150  * @param[in] data The data buffer to write\r
1151  * @param[in] length The size of data buffer (in bytes)\r
1152  *\r
1153  * @return 0 on success, otherwise a negative error value\r
1154  * @retval #PERIPHERAL_ERROR_NONE Successful\r
1155  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
1156  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
1157  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
1158  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
1159  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
1160  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
1161  *\r
1162  * @see peripheral_spi_read()\r
1163  */\r
1164 int peripheral_spi_write(peripheral_spi_h spi, uint8_t *data, uint32_t length);\r
1165 \r
1166 /**\r
1167  * @platform\r
1168  * @brief Exchanges the bytes data to the SPI slave device.\r
1169  * @since_tizen 4.0\r
1170  * @privlevel platform\r
1171  * @privilege http://tizen.org/privilege/peripheralio\r
1172  *\r
1173  * @param[in] spi The SPI device handle\r
1174  * @param[in] txdata The data buffer to write\r
1175  * @param[out] rxdata The data buffer to read\r
1176  * @param[in] length The size of txdata and rxdata buffer (in bytes)\r
1177  *\r
1178  * @return 0 on success, otherwise a negative error value\r
1179  * @retval #PERIPHERAL_ERROR_NONE Successful\r
1180  * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed\r
1181  * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed\r
1182  * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied\r
1183  * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter\r
1184  * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported\r
1185  * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error\r
1186  *\r
1187  * @see peripheral_spi_read()\r
1188  * @see peripheral_spi_write()\r
1189  */\r
1190 int peripheral_spi_transfer(peripheral_spi_h spi, uint8_t *txdata, uint8_t *rxdata, uint32_t length);\r
1191 \r
1192 /**\r
1193 * @}\r
1194 */\r
1195 \r
1196 #ifdef __cplusplus\r
1197 }\r
1198 #endif\r
1199 \r
1200 #endif /* __TIZEN_SYSTEM_PERIPHERAL_IO_H__ */\r