Tizen Native API
5.5
|
The UART API provides functions to control UART peripherals connected to the IoT device.
Required Header
#include <peripheral_io.h>
Overview
This UART API provides functions to control UART peripherals connected to the IoT device.
Realted Features
This API is related with the following feature:
It is recommended to use features in your application for reliability.
You can check if a IoT device supports the related features for this API
by using System Information, and control your application's actions accordingly.
To ensure your application is only running on the IoT device with specific features,
please define the features in your manifest file using the manifest editor in the SDK.
More details on featuring your application can be found from Feature Element.
Functions | |
int | peripheral_uart_open (int port, peripheral_uart_h *uart) |
Opens the UART slave device. | |
int | peripheral_uart_close (peripheral_uart_h uart) |
Closes the UART slave device. | |
int | peripheral_uart_set_baud_rate (peripheral_uart_h uart, peripheral_uart_baud_rate_e baud) |
Sets baud rate of the UART slave device. | |
int | peripheral_uart_set_byte_size (peripheral_uart_h uart, peripheral_uart_byte_size_e byte_size) |
Sets byte size of the UART slave device. | |
int | peripheral_uart_set_parity (peripheral_uart_h uart, peripheral_uart_parity_e parity) |
Sets parity bit of the UART slave device. | |
int | peripheral_uart_set_stop_bits (peripheral_uart_h uart, peripheral_uart_stop_bits_e stop_bits) |
Sets stop bits of the UART slave device. | |
int | peripheral_uart_set_flow_control (peripheral_uart_h uart, peripheral_uart_software_flow_control_e sw_flow_control, peripheral_uart_hardware_flow_control_e hw_flow_control) |
Sets flow control of the UART slave device. | |
int | peripheral_uart_read (peripheral_uart_h uart, uint8_t *data, uint32_t length) |
Reads data from the UART slave device. | |
int | peripheral_uart_write (peripheral_uart_h uart, uint8_t *data, uint32_t length) |
Writes data to the UART slave device. | |
Typedefs | |
typedef struct _peripheral_uart_s * | peripheral_uart_h |
The handle to the UART peripherals. |
Typedef Documentation
typedef struct _peripheral_uart_s* peripheral_uart_h |
The handle to the UART peripherals.
- Since :
- 4.0
Enumeration Type Documentation
Enumeration for baud rate.
- Since :
- 4.0
- Enumerator:
Function Documentation
int peripheral_uart_close | ( | peripheral_uart_h | uart | ) |
Closes the UART slave device.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] uart The UART handle
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
PERIPHERAL_ERROR_NONE Successful PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_UNKNOWN Unknown internal error
- Precondition:
- peripheral_uart_open()
int peripheral_uart_open | ( | int | port, |
peripheral_uart_h * | uart | ||
) |
Opens the UART slave device.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Remarks:
- uart should be released with peripheral_uart_close()
- Parameters:
-
[in] port The UART port number that the slave device is connected [out] uart The UART handle is created on success
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
PERIPHERAL_ERROR_NONE Successful PERIPHERAL_ERROR_IO_ERROR I/O operation failed PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed PERIPHERAL_ERROR_OUT_OF_MEMORY Memory allocation failed PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_RESOURCE_BUSY Device is in use PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_UNKNOWN Unknown internal error
- Postcondition:
- peripheral_uart_close()
int peripheral_uart_read | ( | peripheral_uart_h | uart, |
uint8_t * | data, | ||
uint32_t | length | ||
) |
Reads data from the UART slave device.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] uart The UART handle [out] data The buffer to read [out] length The size of buffer (in bytes)
- Returns:
- the number of bytes read on success, otherwise a negative error value
- Return values:
-
PERIPHERAL_ERROR_NONE Successful PERIPHERAL_ERROR_IO_ERROR I/O operation failed PERIPHERAL_ERROR_TRY_AGAIN Try again PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_UNKNOWN Unknown internal error
- See also:
- peripheral_uart_write()
int peripheral_uart_set_baud_rate | ( | peripheral_uart_h | uart, |
peripheral_uart_baud_rate_e | baud | ||
) |
Sets baud rate of the UART slave device.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] uart The UART handle [in] baud Baud rate of the UART slave device
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
PERIPHERAL_ERROR_NONE Successful PERIPHERAL_ERROR_IO_ERROR I/O operation failed PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_UNKNOWN Unknown internal error
- See also:
- peripheral_uart_baud_rate_e
int peripheral_uart_set_byte_size | ( | peripheral_uart_h | uart, |
peripheral_uart_byte_size_e | byte_size | ||
) |
Sets byte size of the UART slave device.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] uart The UART handle [in] byte_size Byte size of the UART slave device
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
PERIPHERAL_ERROR_NONE Successful PERIPHERAL_ERROR_IO_ERROR I/O operation failed PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_UNKNOWN Unknown internal error
- See also:
- peripheral_uart_byte_size_e
int peripheral_uart_set_flow_control | ( | peripheral_uart_h | uart, |
peripheral_uart_software_flow_control_e | sw_flow_control, | ||
peripheral_uart_hardware_flow_control_e | hw_flow_control | ||
) |
Sets flow control of the UART slave device.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] uart The UART handle [in] sw_flow_control Software flow control (Turns a transmitter on or off) [in] hw_flow_control Hardware flow control (Turns "Request to Send/Clear to Send" on or off)
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
PERIPHERAL_ERROR_NONE Successful PERIPHERAL_ERROR_IO_ERROR I/O operation failed PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_UNKNOWN Unknown internal error
int peripheral_uart_set_parity | ( | peripheral_uart_h | uart, |
peripheral_uart_parity_e | parity | ||
) |
Sets parity bit of the UART slave device.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] uart The UART handle [in] parity Parity bit of the UART slave device
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
PERIPHERAL_ERROR_NONE Successful PERIPHERAL_ERROR_IO_ERROR I/O operation failed PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_UNKNOWN Unknown internal error
- See also:
- peripheral_uart_parity_e
int peripheral_uart_set_stop_bits | ( | peripheral_uart_h | uart, |
peripheral_uart_stop_bits_e | stop_bits | ||
) |
Sets stop bits of the UART slave device.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] uart The UART handle [in] stop_bits Stop bits of the UART slave device
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
PERIPHERAL_ERROR_NONE Successful PERIPHERAL_ERROR_IO_ERROR I/O operation failed PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_UNKNOWN Unknown internal error
- See also:
- peripheral_uart_stop_bits_e
int peripheral_uart_write | ( | peripheral_uart_h | uart, |
uint8_t * | data, | ||
uint32_t | length | ||
) |
Writes data to the UART slave device.
- Warning:
- This is not for use by third-party applications.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] uart The UART handle [in] data The buffer to write [in] length The size of buffer (in bytes)
- Returns:
- the number of bytes write on success, otherwise a negative error value
- Return values:
-
PERIPHERAL_ERROR_NONE Successful PERIPHERAL_ERROR_IO_ERROR I/O operation failed PERIPHERAL_ERROR_TRY_AGAIN Try again PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_UNKNOWN Unknown internal error
- See also:
- peripheral_uart_read()