2 * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __TIZEN_SYSTEM_PERIPHERAL_IO_H__
18 #define __TIZEN_SYSTEM_PERIPHERAL_IO_H__
28 * @addtogroup CAPI_SYSTEM_PERIPHERAL_IO_MODULE
33 * @file peripheral_io.h
34 * @brief This file contains the peripheral-io API.
38 * @brief Enumeration for peripheral-io error.
42 PERIPHERAL_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
43 PERIPHERAL_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */
44 PERIPHERAL_ERROR_NO_DEVICE = TIZEN_ERROR_NO_SUCH_DEVICE, /**< No such device */
45 PERIPHERAL_ERROR_TRY_AGAIN = TIZEN_ERROR_TRY_AGAIN, /**< Try again */
46 PERIPHERAL_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
47 PERIPHERAL_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
48 PERIPHERAL_ERROR_RESOURCE_BUSY = TIZEN_ERROR_RESOURCE_BUSY, /**< Device or resource busy */
49 PERIPHERAL_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
50 PERIPHERAL_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
51 PERIPHERAL_ERROR_UNKNOWN = TIZEN_ERROR_UNKNOWN, /**< Unknown error */
59 * @addtogroup CAPI_SYSTEM_PERIPHERAL_IO_GPIO_MODULE
64 * @brief Enumeration of GPIO direction options.
68 PERIPHERAL_GPIO_DIRECTION_IN = 0, /**< Input Mode */
69 PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_HIGH, /**< Output mode with high value */
70 PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW, /**< Output mode with low value */
71 } peripheral_gpio_direction_e;
74 * @brief Enumeration of edge types for the GPIO interrupt.
78 PERIPHERAL_GPIO_EDGE_NONE = 0, /**< No interrupt on GPIO */
79 PERIPHERAL_GPIO_EDGE_RISING, /**< Interrupt on rising only */
80 PERIPHERAL_GPIO_EDGE_FALLING, /**< Interrupt on falling only */
81 PERIPHERAL_GPIO_EDGE_BOTH, /**< Interrupt on rising & falling */
82 } peripheral_gpio_edge_e;
85 * @brief The handle of a GPIO pin.
88 typedef struct _peripheral_gpio_s *peripheral_gpio_h;
92 * @brief Opens a GPIO pin.
95 * @privilege http://tizen.org/privilege/peripheralio
96 * @remarks @a gpio should be released with peripheral_gpio_close()
98 * @param[in] gpio_pin The GPIO pin number
99 * @param[out] gpio The GPIO handle is created on success
101 * @return 0 on success, otherwise a negative error value
102 * @retval #PERIPHERAL_ERROR_NONE Successful
103 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
104 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
105 * @retval #PERIPHERAL_ERROR_OUT_OF_MEMORY Memory allocation failed
106 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
107 * @retval #PERIPHERAL_ERROR_RESOURCE_BUSY Device is in use
108 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
109 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
110 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
112 * @post peripheral_gpio_close()
114 int peripheral_gpio_open(int gpio_pin, peripheral_gpio_h *gpio);
118 * @brief Closes a GPIO pin.
120 * @privlevel platform
121 * @privilege http://tizen.org/privilege/peripheralio
123 * @param[in] gpio The GPIO handle
125 * @return 0 on success, otherwise a negative error value
126 * @retval #PERIPHERAL_ERROR_NONE Successful
127 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
128 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
129 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
130 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
131 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
132 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
134 * @pre peripheral_gpio_open()
136 int peripheral_gpio_close(peripheral_gpio_h gpio);
140 * @brief Sets the GPIO direction.
142 * @privlevel platform
143 * @privilege http://tizen.org/privilege/peripheralio
145 * @param[in] gpio The GPIO handle
146 * @param[in] direction The direction of the GPIO pin
148 * @return 0 on success, otherwise a negative error value
149 * @retval #PERIPHERAL_ERROR_NONE Successful
150 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
151 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
152 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
153 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
154 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
155 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
157 * @see peripheral_gpio_direction_e
159 int peripheral_gpio_set_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e direction);
163 * @brief Sets the GPIO edge mode.
165 * @privlevel platform
166 * @privilege http://tizen.org/privilege/peripheralio
168 * @param[in] gpio The GPIO handle
169 * @param[in] edge The edge mode of the GPIO pin
171 * @return 0 on success, otherwise a negative error value
172 * @retval #PERIPHERAL_ERROR_NONE Successful
173 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
174 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
175 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
176 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
177 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
178 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
180 * @see peripheral_gpio_edge_e
182 int peripheral_gpio_set_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e edge);
186 * @brief The GPIO interrupted callback called when the GPIO interrupt is triggered.
189 * @param[in] gpio The GPIO handle
190 * @param[in] error The GPIO error
191 * @param[in] user_data The user data passed from the callback registration function
193 * @see peripheral_gpio_set_interrupted_cb()
195 typedef void(*peripheral_gpio_interrupted_cb)(peripheral_gpio_h gpio, peripheral_error_e error, void *user_data);
199 * @brief Sets the GPIO interrupted callback to be invoked when the GPIO interrupt is triggered.
201 * @privlevel platform
202 * @privilege http://tizen.org/privilege/peripheralio
204 * @param[in] gpio The GPIO handle
205 * @param[in] callback The GPIO interrupted callback function to set
206 * @param[in] user_data The user data to be passed to the callback function
208 * @return 0 on success, otherwise a negative error value
209 * @retval #PERIPHERAL_ERROR_NONE Successful
210 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
211 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
212 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
214 * @post peripheral_gpio_unset_interrupted_cb()
215 * @see peripheral_gpio_set_edge_mode()
217 int peripheral_gpio_set_interrupted_cb(peripheral_gpio_h gpio, peripheral_gpio_interrupted_cb callback, void *user_data);
221 * @brief Unsets the GPIO interrupted callback.
223 * @privlevel platform
224 * @privilege http://tizen.org/privilege/peripheralio
226 * @param[in] gpio The GPIO handle
228 * @return 0 on success, otherwise a negative error value
229 * @retval #PERIPHERAL_ERROR_NONE Successful
230 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
231 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
232 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
234 * @pre peripheral_gpio_set_interrupted_cb()
236 int peripheral_gpio_unset_interrupted_cb(peripheral_gpio_h gpio);
240 * @brief Gets the current value of the GPIO pin.
242 * @privlevel platform
243 * @privilege http://tizen.org/privilege/peripheralio
245 * @param[in] gpio The GPIO handle
246 * @param[out] value The value to get
248 * @return 0 on success, otherwise a negative error value
249 * @retval #PERIPHERAL_ERROR_NONE Successful
250 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
251 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
252 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
253 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
254 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
255 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
257 * @see peripheral_gpio_write()
259 int peripheral_gpio_read(peripheral_gpio_h gpio, uint32_t *value);
263 * @brief Sets the value of the GPIO pin.
265 * @privlevel platform
266 * @privilege http://tizen.org/privilege/peripheralio
268 * @param[in] gpio The GPIO handle
269 * @param[in] value The value to set (must be 0 or 1)
271 * @return 0 on success, otherwise a negative error value
272 * @retval #PERIPHERAL_ERROR_NONE Successful
273 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
274 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
275 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
276 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
277 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
278 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
280 * @see peripheral_gpio_read()
282 int peripheral_gpio_write(peripheral_gpio_h gpio, uint32_t value);
289 * @addtogroup CAPI_SYSTEM_PERIPHERAL_IO_I2C_MODULE
294 * @brief The handle of the I2C slave device.
297 typedef struct _peripheral_i2c_s *peripheral_i2c_h;
301 * @brief Opens an I2C slave device.
303 * @privlevel platform
304 * @privilege http://tizen.org/privilege/peripheralio
305 * @remarks @a i2c should be released with peripheral_i2c_close()
307 * @param[in] bus The I2C bus number that the slave device is connected
308 * @param[in] address The address of the slave device
309 * @param[out] i2c The I2C handle is created on success
311 * @return 0 on success, otherwise a negative error value
312 * @retval #PERIPHERAL_ERROR_NONE Successful
313 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
314 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
315 * @retval #PERIPHERAL_ERROR_OUT_OF_MEMORY Memory allocation failed
316 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
317 * @retval #PERIPHERAL_ERROR_RESOURCE_BUSY Device is in use
318 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
319 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
320 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
322 * @post peripheral_i2c_close()
324 int peripheral_i2c_open(int bus, int address, peripheral_i2c_h *i2c);
328 * @brief Closes an I2C slave device.
330 * @privlevel platform
331 * @privilege http://tizen.org/privilege/peripheralio
333 * @param[in] i2c The I2C handle
335 * @return 0 on success, otherwise a negative error value
336 * @retval #PERIPHERAL_ERROR_NONE Successful
337 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
338 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
339 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
340 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
342 * @pre peripheral_i2c_open()
344 int peripheral_i2c_close(peripheral_i2c_h i2c);
348 * @brief Reads the bytes data from the I2C slave device.
350 * @privlevel platform
351 * @privilege http://tizen.org/privilege/peripheralio
353 * @param[in] i2c The I2C handle
354 * @param[out] data The data buffer to read
355 * @param[in] length The size of data buffer (in bytes)
357 * @return 0 on success, otherwise a negative error value
358 * @retval #PERIPHERAL_ERROR_NONE Successful
359 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
360 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
361 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
362 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
363 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
365 * @see peripheral_i2c_write()
367 int peripheral_i2c_read(peripheral_i2c_h i2c, uint8_t *data, uint32_t length);
371 * @brief Writes the bytes data to the I2C slave device.
373 * @privlevel platform
374 * @privilege http://tizen.org/privilege/peripheralio
376 * @param[in] i2c The I2C handle
377 * @param[in] data The data buffer to write
378 * @param[in] length The size of data buffer (in bytes)
380 * @return 0 on success, otherwise a negative error value
381 * @retval #PERIPHERAL_ERROR_NONE Successful
382 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
383 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
384 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
385 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
386 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
388 * @see peripheral_i2c_read()
390 int peripheral_i2c_write(peripheral_i2c_h i2c, uint8_t *data, uint32_t length);
394 * @brief Reads single byte data from the register of the I2C slave device.
396 * @privlevel platform
397 * @privilege http://tizen.org/privilege/peripheralio
399 * @param[in] i2c The I2C handle
400 * @param[in] reg The register address of the I2C slave device to read
401 * @param[out] data The single byte data to read
403 * @return 0 on success, otherwise a negative error value
404 * @retval #PERIPHERAL_ERROR_NONE Successful
405 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
406 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
407 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
408 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
409 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
411 * @see peripheral_i2c_write_register_byte()
413 int peripheral_i2c_read_register_byte(peripheral_i2c_h i2c, uint8_t reg, uint8_t *data);
417 * @brief Writes single byte data to the register of the I2C slave device.
419 * @privlevel platform
420 * @privilege http://tizen.org/privilege/peripheralio
422 * @param[in] i2c The I2C handle
423 * @param[in] reg The register address of the I2C slave device to write
424 * @param[in] data The single byte data to write
426 * @return 0 on success, otherwise a negative error value
427 * @retval #PERIPHERAL_ERROR_NONE Successful
428 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
429 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
430 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
431 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
432 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
434 * @see peripheral_i2c_read_register_byte()
436 int peripheral_i2c_write_register_byte(peripheral_i2c_h i2c, uint8_t reg, uint8_t data);
440 * @brief Reads word data from the register of the I2C slave device.
442 * @privlevel platform
443 * @privilege http://tizen.org/privilege/peripheralio
445 * @param[in] i2c The I2C handle
446 * @param[in] reg The register address of the I2C slave device to read
447 * @param[out] data The word(2 bytes) data to read
449 * @return 0 on success, otherwise a negative error value
450 * @retval #PERIPHERAL_ERROR_NONE Successful
451 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
452 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
453 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
454 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
455 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
457 * @see peripheral_i2c_write_register_word()
459 int peripheral_i2c_read_register_word(peripheral_i2c_h i2c, uint8_t reg, uint16_t *data);
463 * @brief Writes word data to the register of the I2C slave device.
465 * @privlevel platform
466 * @privilege http://tizen.org/privilege/peripheralio
468 * @param[in] i2c The I2C handle
469 * @param[in] reg The register address of the I2C slave device to write
470 * @param[in] data The word(2 bytes) data to write
472 * @return 0 on success, otherwise a negative error value
473 * @retval #PERIPHERAL_ERROR_NONE Successful
474 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
475 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
476 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
477 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
478 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
480 * @see peripheral_i2c_read_register_word()
482 int peripheral_i2c_write_register_word(peripheral_i2c_h i2c, uint8_t reg, uint16_t data);
489 * @addtogroup CAPI_SYSTEM_PERIPHERAL_IO_PWM_MODULE
494 * @brief The handle of the PWM peripherals.
497 typedef struct _peripheral_pwm_s *peripheral_pwm_h;
500 * @brief Enumeration for Polarity.
504 PERIPHERAL_PWM_POLARITY_ACTIVE_HIGH = 0, /**< PWM signal start in the active high state (Normal) */
505 PERIPHERAL_PWM_POLARITY_ACTIVE_LOW, /**< PWM signal start in the active low state (Inversed) */
506 } peripheral_pwm_polarity_e;
510 * @brief Opens the PWM pin.
512 * @privlevel platform
513 * @privilege http://tizen.org/privilege/peripheralio
514 * @remarks @a pwm should be released with peripheral_pwm_close()
516 * @param[in] chip The PWM chip number
517 * @param[in] pin The PWM pin(channel) number to control
518 * @param[out] pwm The PWM handle is created on success
520 * @return 0 on success, otherwise a negative error value
521 * @retval #PERIPHERAL_ERROR_NONE Successful
522 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
523 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
524 * @retval #PERIPHERAL_ERROR_OUT_OF_MEMORY Memory allocation failed
525 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
526 * @retval #PERIPHERAL_ERROR_RESOURCE_BUSY Device is in use
527 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
528 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
529 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
531 * @post peripheral_pwm_close()
533 int peripheral_pwm_open(int chip, int pin, peripheral_pwm_h *pwm);
537 * @brief Closes the PWM pin.
539 * @privlevel platform
540 * @privilege http://tizen.org/privilege/peripheralio
542 * @param[in] pwm The PWM handle
544 * @return 0 on success, otherwise a negative error value
545 * @retval #PERIPHERAL_ERROR_NONE Successful
546 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
547 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
548 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
549 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
550 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
551 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
553 * @pre peripheral_pwm_open()
555 int peripheral_pwm_close(peripheral_pwm_h pwm);
559 * @brief Sets period of the PWM pin.
561 * @privlevel platform
562 * @privilege http://tizen.org/privilege/peripheralio
564 * @param[in] pwm The PWM handle
565 * @param[in] period_ns The total period of the PWM pin (in nanoseconds)
567 * @return 0 on success, otherwise a negative error value
568 * @retval #PERIPHERAL_ERROR_NONE Successful
569 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
570 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
571 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
572 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
573 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
574 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
576 int peripheral_pwm_set_period(peripheral_pwm_h pwm, uint32_t period_ns);
580 * @brief Sets duty cycle of the PWM pin.
582 * @privlevel platform
583 * @privilege http://tizen.org/privilege/peripheralio
585 * @param[in] pwm The PWM handle
586 * @param[in] duty_cycle_ns The duty cycle of the PWM pin (in nanoseconds)
588 * @return 0 on success, otherwise a negative error value
589 * @retval #PERIPHERAL_ERROR_NONE Successful
590 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
591 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
592 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
593 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
594 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
595 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
597 int peripheral_pwm_set_duty_cycle(peripheral_pwm_h pwm, uint32_t duty_cycle_ns);
601 * @brief Sets polarity of the PWM pin.
603 * @privlevel platform
604 * @privilege http://tizen.org/privilege/peripheralio
606 * @param[in] pwm The PWM handle
607 * @param[in] polarity The polarity of the PWM pin
609 * @return 0 on success, otherwise a negative error value
610 * @retval #PERIPHERAL_ERROR_NONE Successful
611 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
612 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
613 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
614 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
615 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
616 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
618 * @see peripheral_pwm_polarity_e
620 int peripheral_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e polarity);
624 * @brief Enables the PWM pin.
626 * @privlevel platform
627 * @privilege http://tizen.org/privilege/peripheralio
629 * @param[in] pwm The PWM handle
630 * @param[in] enabled Enable/disable the PWM pin
632 * @return 0 on success, otherwise a negative error value
633 * @retval #PERIPHERAL_ERROR_NONE Successful
634 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
635 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
636 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
637 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
638 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
639 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
641 int peripheral_pwm_set_enabled(peripheral_pwm_h pwm, bool enabled);
648 * @addtogroup CAPI_SYSTEM_PERIPHERAL_IO_UART_MODULE
653 * @brief The handle to the UART peripherals.
656 typedef struct _peripheral_uart_s *peripheral_uart_h;
659 * @brief Enumeration for baud rate.
663 PERIPHERAL_UART_BAUD_RATE_0 = 0, /**< The number of signal in one second is 0 */
664 PERIPHERAL_UART_BAUD_RATE_50, /**< The number of signal in one second is 50 */
665 PERIPHERAL_UART_BAUD_RATE_75, /**< The number of signal in one second is 75 */
666 PERIPHERAL_UART_BAUD_RATE_110, /**< The number of signal in one second is 110 */
667 PERIPHERAL_UART_BAUD_RATE_134, /**< The number of signal in one second is 134 */
668 PERIPHERAL_UART_BAUD_RATE_150, /**< The number of signal in one second is 150 */
669 PERIPHERAL_UART_BAUD_RATE_200, /**< The number of signal in one second is 200 */
670 PERIPHERAL_UART_BAUD_RATE_300, /**< The number of signal in one second is 300 */
671 PERIPHERAL_UART_BAUD_RATE_600, /**< The number of signal in one second is 600 */
672 PERIPHERAL_UART_BAUD_RATE_1200, /**< The number of signal in one second is 1200 */
673 PERIPHERAL_UART_BAUD_RATE_1800, /**< The number of signal in one second is 1800 */
674 PERIPHERAL_UART_BAUD_RATE_2400, /**< The number of signal in one second is 2400 */
675 PERIPHERAL_UART_BAUD_RATE_4800, /**< The number of signal in one second is 4800 */
676 PERIPHERAL_UART_BAUD_RATE_9600, /**< The number of signal in one second is 9600 */
677 PERIPHERAL_UART_BAUD_RATE_19200, /**< The number of signal in one second is 19200 */
678 PERIPHERAL_UART_BAUD_RATE_38400, /**< The number of signal in one second is 38400 */
679 PERIPHERAL_UART_BAUD_RATE_57600, /**< The number of signal in one second is 57600 */
680 PERIPHERAL_UART_BAUD_RATE_115200, /**< The number of signal in one second is 115200 */
681 PERIPHERAL_UART_BAUD_RATE_230400, /**< The number of signal in one second is 230400 */
682 } peripheral_uart_baud_rate_e;
685 * @brief Enumeration for byte size.
689 PERIPHERAL_UART_BYTE_SIZE_5BIT = 0, /**< 5 data bits */
690 PERIPHERAL_UART_BYTE_SIZE_6BIT, /**< 6 data bits */
691 PERIPHERAL_UART_BYTE_SIZE_7BIT, /**< 7 data bits */
692 PERIPHERAL_UART_BYTE_SIZE_8BIT, /**< 8 data bits */
693 } peripheral_uart_byte_size_e;
696 * @brief Enumeration for parity bit.
700 PERIPHERAL_UART_PARITY_NONE = 0, /**< No parity is used */
701 PERIPHERAL_UART_PARITY_EVEN, /**< Even parity is used */
702 PERIPHERAL_UART_PARITY_ODD, /**< ODD parity is used */
703 } peripheral_uart_parity_e;
706 * @brief Enumeration for stop bits.
710 PERIPHERAL_UART_STOP_BITS_1BIT = 0, /**< One stop bit */
711 PERIPHERAL_UART_STOP_BITS_2BIT, /**< Two stop bits */
712 } peripheral_uart_stop_bits_e;
715 * @brief Enumeration for hardware flow control.
719 PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_NONE = 0, /**< No hardware flow control */
720 PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_AUTO_RTSCTS, /**< Automatic RTS/CTS hardware flow control*/
721 } peripheral_uart_hardware_flow_control_e;
724 * @brief Enumeration for software flow control.
728 PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_NONE = 0, /**< No software flow control */
729 PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_XONXOFF, /**< XON/XOFF software flow control */
730 } peripheral_uart_software_flow_control_e;
734 * @brief Opens the UART slave device.
736 * @privlevel platform
737 * @privilege http://tizen.org/privilege/peripheralio
738 * @remarks @a uart should be released with peripheral_uart_close()
740 * @param[in] port The UART port number that the slave device is connected
741 * @param[out] uart The UART handle is created on success
743 * @return 0 on success, otherwise a negative error value
744 * @retval #PERIPHERAL_ERROR_NONE Successful
745 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
746 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
747 * @retval #PERIPHERAL_ERROR_OUT_OF_MEMORY Memory allocation failed
748 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
749 * @retval #PERIPHERAL_ERROR_RESOURCE_BUSY Device is in use
750 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
751 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
752 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
754 * @post peripheral_uart_close()
756 int peripheral_uart_open(int port, peripheral_uart_h *uart);
760 * @brief Closes the UART slave device.
762 * @privlevel platform
763 * @privilege http://tizen.org/privilege/peripheralio
765 * @param[in] uart The UART handle
767 * @return 0 on success, otherwise a negative error value
768 * @retval #PERIPHERAL_ERROR_NONE Successful
769 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
770 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
771 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
772 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
774 * @pre peripheral_uart_open()
776 int peripheral_uart_close(peripheral_uart_h uart);
780 * @brief Sets baud rate of the UART slave device.
782 * @privlevel platform
783 * @privilege http://tizen.org/privilege/peripheralio
785 * @param[in] uart The UART handle
786 * @param[in] baud Baud rate of the UART slave device
788 * @return 0 on success, otherwise a negative error value
789 * @retval #PERIPHERAL_ERROR_NONE Successful
790 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
791 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
792 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
793 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
794 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
795 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
797 * @see peripheral_uart_baud_rate_e
799 int peripheral_uart_set_baud_rate(peripheral_uart_h uart, peripheral_uart_baud_rate_e baud);
803 * @brief Sets byte size of the UART slave device.
805 * @privlevel platform
806 * @privilege http://tizen.org/privilege/peripheralio
808 * @param[in] uart The UART handle
809 * @param[in] byte_size Byte size of the UART slave device
811 * @return 0 on success, otherwise a negative error value
812 * @retval #PERIPHERAL_ERROR_NONE Successful
813 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
814 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
815 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
816 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
817 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
818 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
820 * @see peripheral_uart_byte_size_e
822 int peripheral_uart_set_byte_size(peripheral_uart_h uart, peripheral_uart_byte_size_e byte_size);
826 * @brief Sets parity bit of the UART slave device.
828 * @privlevel platform
829 * @privilege http://tizen.org/privilege/peripheralio
831 * @param[in] uart The UART handle
832 * @param[in] parity Parity bit of the UART slave device
834 * @return 0 on success, otherwise a negative error value
835 * @retval #PERIPHERAL_ERROR_NONE Successful
836 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
837 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
838 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
839 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
840 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
841 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
843 * @see peripheral_uart_parity_e
845 int peripheral_uart_set_parity(peripheral_uart_h uart, peripheral_uart_parity_e parity);
849 * @brief Sets stop bits of the UART slave device.
851 * @privlevel platform
852 * @privilege http://tizen.org/privilege/peripheralio
854 * @param[in] uart The UART handle
855 * @param[in] stop_bits Stop bits of the UART slave device
857 * @return 0 on success, otherwise a negative error value
858 * @retval #PERIPHERAL_ERROR_NONE Successful
859 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
860 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
861 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
862 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
863 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
864 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
866 * @see peripheral_uart_stop_bits_e
868 int peripheral_uart_set_stop_bits(peripheral_uart_h uart, peripheral_uart_stop_bits_e stop_bits);
872 * @brief Sets flow control of the UART slave device.
874 * @privlevel platform
875 * @privilege http://tizen.org/privilege/peripheralio
877 * @param[in] uart The UART handle
878 * @param[in] sw_flow_control Software flow control (Turns a transmitter on or off)
879 * @param[in] hw_flow_control Hardware flow control (Turns "Request to Send/Clear to Send" on or off)
881 * @return 0 on success, otherwise a negative error value
882 * @retval #PERIPHERAL_ERROR_NONE Successful
883 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
884 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
885 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
886 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
887 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
888 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
890 * @see peripheral_uart_software_flow_control_e
891 * @see peripheral_uart_hardware_flow_control_e
893 int peripheral_uart_set_flow_control(peripheral_uart_h uart,
894 peripheral_uart_software_flow_control_e sw_flow_control,
895 peripheral_uart_hardware_flow_control_e hw_flow_control);
899 * @brief Reads data from the UART slave device.
901 * @privlevel platform
902 * @privilege http://tizen.org/privilege/peripheralio
904 * @param[in] uart The UART handle
905 * @param[out] data The buffer to read
906 * @param[out] length The size of buffer (in bytes)
908 * @return the number of bytes read on success, otherwise a negative error value
909 * @retval #PERIPHERAL_ERROR_NONE Successful
910 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
911 * @retval #PERIPHERAL_ERROR_TRY_AGAIN Try again
912 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
913 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
914 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
915 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
917 * @see peripheral_uart_write()
919 int peripheral_uart_read(peripheral_uart_h uart, uint8_t *data, uint32_t length);
923 * @brief Writes data to the UART slave device.
925 * @privlevel platform
926 * @privilege http://tizen.org/privilege/peripheralio
928 * @param[in] uart The UART handle
929 * @param[in] data The buffer to write
930 * @param[in] length The size of buffer (in bytes)
932 * @return the number of bytes write on success, otherwise a negative error value
933 * @retval #PERIPHERAL_ERROR_NONE Successful
934 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
935 * @retval #PERIPHERAL_ERROR_TRY_AGAIN Try again
936 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
937 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
938 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
939 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
941 * @see peripheral_uart_read()
943 int peripheral_uart_write(peripheral_uart_h uart, uint8_t *data, uint32_t length);
950 * @addtogroup CAPI_SYSTEM_PERIPHERAL_IO_SPI_MODULE
955 * @brief The handle of a SPI peripherals.
958 typedef struct _peripheral_spi_s *peripheral_spi_h;
961 * @brief Enumeration of SPI transfer modes.
965 PERIPHERAL_SPI_MODE_0 = 0, /**< CPOL = 0, CPHa = 0 Mode */
966 PERIPHERAL_SPI_MODE_1, /**< CPOL = 0, CPHa = 1 Mode */
967 PERIPHERAL_SPI_MODE_2, /**< CPOL = 1, CPHa = 0 Mode */
968 PERIPHERAL_SPI_MODE_3, /**< CPOL = 1, CPHa = 1 Mode */
969 } peripheral_spi_mode_e;
972 * @brief Enumeration of bit orders.
976 PERIPHERAL_SPI_BIT_ORDER_MSB = 0, /**< Use most siginificant bit first */
977 PERIPHERAL_SPI_BIT_ORDER_LSB, /**< Use least significant bit first */
978 } peripheral_spi_bit_order_e;
982 * @brief Opens a SPI slave device.
984 * @privlevel platform
985 * @privilege http://tizen.org/privilege/peripheralio
986 * @remarks @a spi should be released with peripheral_spi_close()
988 * @param[in] bus The SPI bus number
989 * @param[in] cs The SPI chip select number
990 * @param[out] spi The SPI slave device handle
992 * @return 0 on success, otherwise a negative error value
993 * @retval #PERIPHERAL_ERROR_NONE Successful
994 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
995 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
996 * @retval #PERIPHERAL_ERROR_OUT_OF_MEMORY Memory allocation failed
997 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
998 * @retval #PERIPHERAL_ERROR_RESOURCE_BUSY Device is in use
999 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
1000 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
1001 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
1003 * @post peripheral_spi_close()
1005 int peripheral_spi_open(int bus, int cs, peripheral_spi_h *spi);
1009 * @brief Closes the SPI slave device.
1011 * @privlevel platform
1012 * @privilege http://tizen.org/privilege/peripheralio
1014 * @param[in] spi The SPI slave device handle
1016 * @return 0 on success, otherwise a negative error value
1017 * @retval #PERIPHERAL_ERROR_NONE Successful
1018 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
1019 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
1020 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
1021 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
1022 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
1023 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
1025 * @see peripheral_spi_open()
1027 int peripheral_spi_close(peripheral_spi_h spi);
1031 * @brief Sets the SPI transfer mode.
1033 * @privlevel platform
1034 * @privilege http://tizen.org/privilege/peripheralio
1036 * @param[in] spi The SPI slave device handle
1037 * @param[in] mode The SPI transfer mode
1039 * @return 0 on success, otherwise a negative error value
1040 * @retval #PERIPHERAL_ERROR_NONE Successful
1041 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
1042 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
1043 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
1044 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
1045 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
1046 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
1048 * @see peripheral_spi_mode_e
1050 int peripheral_spi_set_mode(peripheral_spi_h spi, peripheral_spi_mode_e mode);
1054 * @brief Sets the SPI bit order.
1056 * @privlevel platform
1057 * @privilege http://tizen.org/privilege/peripheralio
1059 * @param[in] spi The SPI slave device handle
1060 * @param[in] bit_order The transfer bit order
1062 * @return 0 on success, otherwise a negative error value
1063 * @retval #PERIPHERAL_ERROR_NONE Successful
1064 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
1065 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
1066 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
1067 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
1068 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
1069 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
1071 * @see peripheral_spi_bit_order_e
1073 int peripheral_spi_set_bit_order(peripheral_spi_h spi, peripheral_spi_bit_order_e bit_order);
1077 * @brief Sets the number of bits per word.
1079 * @privlevel platform
1080 * @privilege http://tizen.org/privilege/peripheralio
1082 * @param[in] spi The SPI slave device handle
1083 * @param[in] bits The number of bits per word (in bits)
1085 * @return 0 on success, otherwise a negative error value
1086 * @retval #PERIPHERAL_ERROR_NONE Successful
1087 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
1088 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
1089 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
1090 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
1091 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
1092 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
1094 int peripheral_spi_set_bits_per_word(peripheral_spi_h spi, uint8_t bits);
1098 * @brief Sets the frequency of the SPI bus.
1100 * @privlevel platform
1101 * @privilege http://tizen.org/privilege/peripheralio
1102 * @remarks The frequencies supported are board dependent.
1104 * @param[in] spi The SPI slave device handle
1105 * @param[in] freq_hz Frequency to set (in Hz)
1107 * @return 0 on success, otherwise a negative error value
1108 * @retval #PERIPHERAL_ERROR_NONE Successful
1109 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
1110 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
1111 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
1112 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
1113 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
1114 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
1116 int peripheral_spi_set_frequency(peripheral_spi_h spi, uint32_t freq_hz);
1120 * @brief Reads the bytes data from the SPI slave device.
1122 * @privlevel platform
1123 * @privilege http://tizen.org/privilege/peripheralio
1125 * @param[in] spi The SPI slave device handle
1126 * @param[out] data The data buffer to read
1127 * @param[in] length The size of data buffer (in bytes)
1129 * @return 0 on success, otherwise a negative error value
1130 * @retval #PERIPHERAL_ERROR_NONE Successful
1131 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
1132 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
1133 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
1134 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
1135 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
1136 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
1138 * @see peripheral_spi_write()
1140 int peripheral_spi_read(peripheral_spi_h spi, uint8_t *data, uint32_t length);
1144 * @brief Writes the bytes data to the SPI slave device.
1146 * @privlevel platform
1147 * @privilege http://tizen.org/privilege/peripheralio
1149 * @param[in] spi The SPI slave device handle
1150 * @param[in] data The data buffer to write
1151 * @param[in] length The size of data buffer (in bytes)
1153 * @return 0 on success, otherwise a negative error value
1154 * @retval #PERIPHERAL_ERROR_NONE Successful
1155 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
1156 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
1157 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
1158 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
1159 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
1160 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
1162 * @see peripheral_spi_read()
1164 int peripheral_spi_write(peripheral_spi_h spi, uint8_t *data, uint32_t length);
1168 * @brief Exchanges the bytes data to the SPI slave device.
1170 * @privlevel platform
1171 * @privilege http://tizen.org/privilege/peripheralio
1173 * @param[in] spi The SPI slave device handle
1174 * @param[in] txdata The data buffer to write
1175 * @param[out] rxdata The data buffer to read
1176 * @param[in] length The size of txdata and rxdata buffer (in bytes)
1178 * @return 0 on success, otherwise a negative error value
1179 * @retval #PERIPHERAL_ERROR_NONE Successful
1180 * @retval #PERIPHERAL_ERROR_IO_ERROR I/O operation failed
1181 * @retval #PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed
1182 * @retval #PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied
1183 * @retval #PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter
1184 * @retval #PERIPHERAL_ERROR_NOT_SUPPORTED Not supported
1185 * @retval #PERIPHERAL_ERROR_UNKNOWN Unknown internal error
1187 * @see peripheral_spi_read()
1188 * @see peripheral_spi_write()
1190 int peripheral_spi_transfer(peripheral_spi_h spi, uint8_t *txdata, uint8_t *rxdata, uint32_t length);
1200 #endif /* __TIZEN_SYSTEM_PERIPHERAL_IO_H__ */