2 * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd.
\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
8 * http://www.apache.org/licenses/LICENSE-2.0
\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
17 #ifndef __TIZEN_SYSTEM_PERIPHERAL_IO_H__
\r
18 #define __TIZEN_SYSTEM_PERIPHERAL_IO_H__
\r
28 * @addtogroup CAPI_SYSTEM_PERIPHERAL_IO_MODULE
\r
33 * @file peripheral_io.h
\r
34 * @brief This file contains the peripheral-io API.
\r
38 * @brief Enumeration for peripheral-io error.
\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
59 * @addtogroup CAPI_SYSTEM_PERIPHERAL_IO_GPIO_MODULE
\r
64 * @brief Enumeration of GPIO direction options.
\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
74 * @brief Enumeration of edge types for the GPIO interrupt.
\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
85 * @brief The handle of a GPIO pin.
\r
88 typedef struct _peripheral_gpio_s *peripheral_gpio_h;
\r
92 * @brief Opens a GPIO pin.
\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
98 * @param[in] gpio_pin The GPIO pin number
\r
99 * @param[out] gpio The GPIO handle is created on success
\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
112 * @post peripheral_gpio_close()
\r
114 int peripheral_gpio_open(int gpio_pin, peripheral_gpio_h *gpio);
\r
118 * @brief Closes a GPIO pin.
\r
120 * @privlevel platform
\r
121 * @privilege http://tizen.org/privilege/peripheralio
\r
123 * @param[in] gpio The GPIO handle
\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
134 * @pre peripheral_gpio_open()
\r
136 int peripheral_gpio_close(peripheral_gpio_h gpio);
\r
140 * @brief Sets the GPIO direction.
\r
142 * @privlevel platform
\r
143 * @privilege http://tizen.org/privilege/peripheralio
\r
145 * @param[in] gpio The GPIO handle
\r
146 * @param[in] direction The direction of the GPIO pin
\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
157 * @see peripheral_gpio_direction_e
\r
159 int peripheral_gpio_set_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e direction);
\r
163 * @brief Sets the GPIO edge mode.
\r
165 * @privlevel platform
\r
166 * @privilege http://tizen.org/privilege/peripheralio
\r
168 * @param[in] gpio The GPIO handle
\r
169 * @param[in] edge The edge mode of the GPIO pin
\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
180 * @see peripheral_gpio_edge_e
\r
182 int peripheral_gpio_set_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e edge);
\r
186 * @brief The GPIO interrupted callback called when the GPIO interrupt is triggered.
\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
193 * @see peripheral_gpio_set_interrupted_cb()
\r
195 typedef void(*peripheral_gpio_interrupted_cb)(peripheral_gpio_h gpio, peripheral_error_e error, void *user_data);
\r
199 * @brief Sets the GPIO interrupted callback to be invoked when the GPIO interrupt is triggered.
\r
201 * @privlevel platform
\r
202 * @privilege http://tizen.org/privilege/peripheralio
\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
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
214 * @post peripheral_gpio_unset_interrupted_cb()
\r
215 * @see peripheral_gpio_set_edge_mode()
\r
217 int peripheral_gpio_set_interrupted_cb(peripheral_gpio_h gpio, peripheral_gpio_interrupted_cb callback, void *user_data);
\r
221 * @brief Unsets the GPIO interrupted callback.
\r
223 * @privlevel platform
\r
224 * @privilege http://tizen.org/privilege/peripheralio
\r
226 * @param[in] gpio The GPIO handle
\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
234 * @pre peripheral_gpio_set_interrupted_cb()
\r
236 int peripheral_gpio_unset_interrupted_cb(peripheral_gpio_h gpio);
\r
240 * @brief Gets the current value of the GPIO pin.
\r
242 * @privlevel platform
\r
243 * @privilege http://tizen.org/privilege/peripheralio
\r
245 * @param[in] gpio The GPIO handle
\r
246 * @param[out] value The value to get
\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
257 * @see peripheral_gpio_write()
\r
259 int peripheral_gpio_read(peripheral_gpio_h gpio, uint32_t *value);
\r
263 * @brief Sets the value of the GPIO pin.
\r
265 * @privlevel platform
\r
266 * @privilege http://tizen.org/privilege/peripheralio
\r
268 * @param[in] gpio The GPIO handle
\r
269 * @param[in] value The value to set (must be 0 or 1)
\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
280 * @see peripheral_gpio_read()
\r
282 int peripheral_gpio_write(peripheral_gpio_h gpio, uint32_t value);
\r
289 * @addtogroup CAPI_SYSTEM_PERIPHERAL_IO_I2C_MODULE
\r
294 * @brief The handle of the I2C slave device.
\r
297 typedef struct _peripheral_i2c_s *peripheral_i2c_h;
\r
301 * @brief Opens an I2C slave device.
\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
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
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
322 * @post peripheral_i2c_close()
\r
324 int peripheral_i2c_open(int bus, int address, peripheral_i2c_h *i2c);
\r
328 * @brief Closes an I2C slave device.
\r
330 * @privlevel platform
\r
331 * @privilege http://tizen.org/privilege/peripheralio
\r
333 * @param[in] i2c The I2C handle
\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
342 * @pre peripheral_i2c_open()
\r
344 int peripheral_i2c_close(peripheral_i2c_h i2c);
\r
348 * @brief Reads the bytes data from the I2C slave device.
\r
350 * @privlevel platform
\r
351 * @privilege http://tizen.org/privilege/peripheralio
\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
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
365 * @see peripheral_i2c_write()
\r
367 int peripheral_i2c_read(peripheral_i2c_h i2c, uint8_t *data, uint32_t length);
\r
371 * @brief Writes the bytes data to the I2C slave device.
\r
373 * @privlevel platform
\r
374 * @privilege http://tizen.org/privilege/peripheralio
\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
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
388 * @see peripheral_i2c_read()
\r
390 int peripheral_i2c_write(peripheral_i2c_h i2c, uint8_t *data, uint32_t length);
\r
394 * @brief Reads single byte data from the register of the I2C slave device.
\r
396 * @privlevel platform
\r
397 * @privilege http://tizen.org/privilege/peripheralio
\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
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
411 * @see peripheral_i2c_write_register_byte()
\r
413 int peripheral_i2c_read_register_byte(peripheral_i2c_h i2c, uint8_t reg, uint8_t *data);
\r
417 * @brief Writes single byte data to the register of the I2C slave device.
\r
419 * @privlevel platform
\r
420 * @privilege http://tizen.org/privilege/peripheralio
\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
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
434 * @see peripheral_i2c_read_register_byte()
\r
436 int peripheral_i2c_write_register_byte(peripheral_i2c_h i2c, uint8_t reg, uint8_t data);
\r
440 * @brief Reads word data from the register of the I2C slave device.
\r
442 * @privlevel platform
\r
443 * @privilege http://tizen.org/privilege/peripheralio
\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
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
457 * @see peripheral_i2c_write_register_word()
\r
459 int peripheral_i2c_read_register_word(peripheral_i2c_h i2c, uint8_t reg, uint16_t *data);
\r
463 * @brief Writes word data to the register of the I2C slave device.
\r
465 * @privlevel platform
\r
466 * @privilege http://tizen.org/privilege/peripheralio
\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
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
480 * @see peripheral_i2c_read_register_word()
\r
482 int peripheral_i2c_write_register_word(peripheral_i2c_h i2c, uint8_t reg, uint16_t data);
\r
489 * @addtogroup CAPI_SYSTEM_PERIPHERAL_IO_PWM_MODULE
\r
494 * @brief The handle of the PWM device.
\r
497 typedef struct _peripheral_pwm_s *peripheral_pwm_h;
\r
500 * @brief Enumeration for Polarity.
\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
510 * @brief Opens the PWM pin.
\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
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
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
531 * @post peripheral_pwm_close()
\r
533 int peripheral_pwm_open(int chip, int pin, peripheral_pwm_h *pwm);
\r
537 * @brief Closes the PWM pin.
\r
539 * @privlevel platform
\r
540 * @privilege http://tizen.org/privilege/peripheralio
\r
542 * @param[in] pwm The PWM handle
\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
553 * @pre peripheral_pwm_open()
\r
555 int peripheral_pwm_close(peripheral_pwm_h pwm);
\r
559 * @brief Sets period of the PWM pin.
\r
561 * @privlevel platform
\r
562 * @privilege http://tizen.org/privilege/peripheralio
\r
564 * @param[in] pwm The PWM handle
\r
565 * @param[in] period_ns The total period of the PWM pin (in nanoseconds)
\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
576 int peripheral_pwm_set_period(peripheral_pwm_h pwm, uint32_t period_ns);
\r
580 * @brief Sets duty cycle of the PWM pin.
\r
582 * @privlevel platform
\r
583 * @privilege http://tizen.org/privilege/peripheralio
\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
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
597 int peripheral_pwm_set_duty_cycle(peripheral_pwm_h pwm, uint32_t duty_cycle_ns);
\r
601 * @brief Sets polarity of the PWM pin.
\r
603 * @privlevel platform
\r
604 * @privilege http://tizen.org/privilege/peripheralio
\r
606 * @param[in] pwm The PWM handle
\r
607 * @param[in] polarity The polarity of the PWM pin
\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
618 * @see peripheral_pwm_polarity_e
\r
620 int peripheral_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e polarity);
\r
624 * @brief Enables the PWM pin.
\r
626 * @privlevel platform
\r
627 * @privilege http://tizen.org/privilege/peripheralio
\r
629 * @param[in] pwm The PWM handle
\r
630 * @param[in] enabled Enable/disable the PWM pin
\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
641 int peripheral_pwm_set_enabled(peripheral_pwm_h pwm, bool enabled);
\r
648 * @addtogroup CAPI_SYSTEM_PERIPHERAL_IO_UART_MODULE
\r
653 * @brief The handle to the UART device.
\r
656 typedef struct _peripheral_uart_s *peripheral_uart_h;
\r
659 * @brief Enumeration for baud rate.
\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
685 * @brief Enumeration for byte size.
\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
696 * @brief Enumeration for parity bit.
\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
706 * @brief Enumeration for stop bits.
\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
715 * @brief Enumeration for hardware flow control.
\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
724 * @brief Enumeration for software flow control.
\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
734 * @brief Opens the UART slave device.
\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
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
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
754 * @post peripheral_uart_close()
\r
756 int peripheral_uart_open(int port, peripheral_uart_h *uart);
\r
760 * @brief Closes the UART slave device.
\r
762 * @privlevel platform
\r
763 * @privilege http://tizen.org/privilege/peripheralio
\r
765 * @param[in] uart The UART handle
\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
774 * @pre peripheral_uart_open()
\r
776 int peripheral_uart_close(peripheral_uart_h uart);
\r
780 * @brief Sets baud rate of the UART slave device.
\r
782 * @privlevel platform
\r
783 * @privilege http://tizen.org/privilege/peripheralio
\r
785 * @param[in] uart The UART handle
\r
786 * @param[in] baud Baud rate of the UART device
\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
797 * @see peripheral_uart_baud_rate_e
\r
799 int peripheral_uart_set_baud_rate(peripheral_uart_h uart, peripheral_uart_baud_rate_e baud);
\r
803 * @brief Sets byte size of the UART slave device.
\r
805 * @privlevel platform
\r
806 * @privilege http://tizen.org/privilege/peripheralio
\r
808 * @param[in] uart The UART handle
\r
809 * @param[in] byte_size Byte size of the UART device
\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
820 * @see peripheral_uart_byte_size_e
\r
822 int peripheral_uart_set_byte_size(peripheral_uart_h uart, peripheral_uart_byte_size_e byte_size);
\r
826 * @brief Sets parity bit of the UART slave device.
\r
828 * @privlevel platform
\r
829 * @privilege http://tizen.org/privilege/peripheralio
\r
831 * @param[in] uart The UART handle
\r
832 * @param[in] parity Parity bit of the UART device
\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
843 * @see peripheral_uart_parity_e
\r
845 int peripheral_uart_set_parity(peripheral_uart_h uart, peripheral_uart_parity_e parity);
\r
849 * @brief Sets stop bits of the UART slave device.
\r
851 * @privlevel platform
\r
852 * @privilege http://tizen.org/privilege/peripheralio
\r
854 * @param[in] uart The UART handle
\r
855 * @param[in] stop_bits Stop bits of the UART device
\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
866 * @see peripheral_uart_stop_bits_e
\r
868 int peripheral_uart_set_stop_bits(peripheral_uart_h uart, peripheral_uart_stop_bits_e stop_bits);
\r
872 * @brief Sets flow control of the UART slave device.
\r
874 * @privlevel platform
\r
875 * @privilege http://tizen.org/privilege/peripheralio
\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
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
890 * @see peripheral_uart_software_flow_control_e
\r
891 * @see peripheral_uart_hardware_flow_control_e
\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
899 * @brief Reads data from the UART slave device.
\r
901 * @privlevel platform
\r
902 * @privilege http://tizen.org/privilege/peripheralio
\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
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
917 * @see peripheral_uart_write()
\r
919 int peripheral_uart_read(peripheral_uart_h uart, uint8_t *data, uint32_t length);
\r
923 * @brief Writes data to the UART slave device.
\r
925 * @privlevel platform
\r
926 * @privilege http://tizen.org/privilege/peripheralio
\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
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
941 * @see peripheral_uart_read()
\r
943 int peripheral_uart_write(peripheral_uart_h uart, uint8_t *data, uint32_t length);
\r
950 * @addtogroup CAPI_SYSTEM_PERIPHERAL_IO_SPI_MODULE
\r
955 * @brief The handle of a SPI device.
\r
958 typedef struct _peripheral_spi_s *peripheral_spi_h;
\r
961 * @brief Enumeration of SPI transfer modes.
\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
972 * @brief Enumeration of bit orders.
\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
982 * @brief Opens a SPI slave device.
\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
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
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
1003 * @post peripheral_spi_close()
\r
1005 int peripheral_spi_open(int bus, int cs, peripheral_spi_h *spi);
\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
1014 * @param[in] spi The SPI device handle
\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
1025 * @see peripheral_spi_open()
\r
1027 int peripheral_spi_close(peripheral_spi_h spi);
\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
1036 * @param[in] spi The SPI device handle
\r
1037 * @param[in] mode The SPI transfer mode
\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
1048 * @see peripheral_spi_mode_e
\r
1050 int peripheral_spi_set_mode(peripheral_spi_h spi, peripheral_spi_mode_e mode);
\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
1059 * @param[in] spi The SPI device handle
\r
1060 * @param[in] bit_order The transfer bit order
\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
1071 * @see peripheral_spi_bit_order_e
\r
1073 int peripheral_spi_set_bit_order(peripheral_spi_h spi, peripheral_spi_bit_order_e bit_order);
\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
1082 * @param[in] spi The SPI device handle
\r
1083 * @param[in] bits The number of bits per word (in bits)
\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
1094 int peripheral_spi_set_bits_per_word(peripheral_spi_h spi, uint8_t bits);
\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
1104 * @param[in] spi The SPI device handle
\r
1105 * @param[in] freq_hz Frequency to set (in Hz)
\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
1116 int peripheral_spi_set_frequency(peripheral_spi_h spi, uint32_t freq_hz);
\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
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
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
1138 * @see peripheral_spi_write()
\r
1140 int peripheral_spi_read(peripheral_spi_h spi, uint8_t *data, uint32_t length);
\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
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
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
1162 * @see peripheral_spi_read()
\r
1164 int peripheral_spi_write(peripheral_spi_h spi, uint8_t *data, uint32_t length);
\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
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
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
1187 * @see peripheral_spi_read()
\r
1188 * @see peripheral_spi_write()
\r
1190 int peripheral_spi_transfer(peripheral_spi_h spi, uint8_t *txdata, uint8_t *rxdata, uint32_t length);
\r
1196 #ifdef __cplusplus
\r
1200 #endif /* __TIZEN_SYSTEM_PERIPHERAL_IO_H__ */
\r