Tizen Native API
9.0
|
The UART API provides functions to control UART peripherals connected to the IoT device.
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 and returns a handle representing it. | |
int | peripheral_uart_open_flags (int port, peripheral_open_flags_e flags, peripheral_uart_h *uart) |
Opens the UART slave device using specified open flags, and returns a handle representing it. | |
int | peripheral_uart_close (peripheral_uart_h uart) |
Closes the UART slave device and frees resources associated with the handle. | |
int | peripheral_uart_set_baud_rate (peripheral_uart_h uart, peripheral_uart_baud_rate_e baud) |
Sets the baud rate for the given UART slave device. | |
int | peripheral_uart_set_byte_size (peripheral_uart_h uart, peripheral_uart_byte_size_e byte_size) |
Sets data byte size for the given UART slave device. | |
int | peripheral_uart_set_parity (peripheral_uart_h uart, peripheral_uart_parity_e parity) |
Sets the parity bit for the given UART slave device. | |
int | peripheral_uart_set_stop_bits (peripheral_uart_h uart, peripheral_uart_stop_bits_e stop_bits) |
Sets the number of stop bits for 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 hardware and software 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 into a local buffer. | |
int | peripheral_uart_flush (peripheral_uart_h uart) |
Discards data queued for writing to UART slave device, but not yet transmitted. | |
int | peripheral_uart_drain (peripheral_uart_h uart) |
Waits for all data queued for UART to be transmitted. | |
int | peripheral_uart_write (peripheral_uart_h uart, uint8_t *data, uint32_t length) |
Writes data from a buffer to the UART slave device. | |
Typedefs | |
typedef struct _peripheral_uart_s * | peripheral_uart_h |
An opaque handle representing a UART peripherals device. |
Typedef Documentation
typedef struct _peripheral_uart_s* peripheral_uart_h |
An opaque handle representing a UART peripherals device.
A handle to a single UART slave device, for use with most UART peripherals interfaces
- Since :
- 4.0
Enumeration Type Documentation
Enumeration for signal baud rate for UART slave devices.
Controls the baud rate, i.e. signals per second on a UART device
- Since :
- 4.0
- Enumerator:
Enumeration for data byte size for UART slave devices.
Controls how many bits per byte are there for data, on UART slave devices.
- Since :
- 4.0
Enumeration for hardware flow control for UART slave devices.
Controls details of the hardware flow control on UART devices
- Since :
- 4.0
Function Documentation
int peripheral_uart_close | ( | peripheral_uart_h | uart | ) |
Closes the UART slave device and frees resources associated with the handle.
- Warning:
- This is not for use by third-party applications.
This function should be called at the end of the object's lifetime to avoid a memleak.
- 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_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_UNKNOWN Unknown internal error
- Precondition:
- peripheral_uart_open()
int peripheral_uart_drain | ( | peripheral_uart_h | uart | ) |
Waits for all data queued for UART to be transmitted.
- Warning:
- This is not for use by third-party applications.
Waits for all data queued for UART to be transmitted.
- Since :
- 8.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] uart The UART handle
- Returns:
- PERIPHERAL_ERROR_NONE on success, otherwise a negative error value
- Return values:
-
PERIPHERAL_ERROR_NONE Successful PERIPHERAL_ERROR_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_IO_ERROR I/O operation failed PERIPHERAL_ERROR_TRY_AGAIN Try again PERIPHERAL_ERROR_UNKNOWN Unknown internal error
int peripheral_uart_flush | ( | peripheral_uart_h | uart | ) |
Discards data queued for writing to UART slave device, but not yet transmitted.
- Warning:
- This is not for use by third-party applications.
Discards data queued for writing to UART slave device, but not yet transmitted.
- Since :
- 8.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] uart The UART handle
- Returns:
- PERIPHERAL_ERROR_NONE on success, otherwise a negative error value
- Return values:
-
PERIPHERAL_ERROR_NONE Successful PERIPHERAL_ERROR_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_IO_ERROR I/O operation failed PERIPHERAL_ERROR_TRY_AGAIN Try again PERIPHERAL_ERROR_UNKNOWN Unknown internal error
int peripheral_uart_open | ( | int | port, |
peripheral_uart_h * | uart | ||
) |
Opens the UART slave device and returns a handle representing it.
- Warning:
- This is not for use by third-party applications.
Starts the lifetime of the handle and allocates its needed resources.
- 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_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter 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_RESOURCE_BUSY Device is in use PERIPHERAL_ERROR_UNKNOWN Unknown internal error
- Postcondition:
- peripheral_uart_close()
int peripheral_uart_open_flags | ( | int | port, |
peripheral_open_flags_e | flags, | ||
peripheral_uart_h * | uart | ||
) |
Opens the UART slave device using specified open flags, and returns a handle representing it.
- Warning:
- This is not for use by third-party applications.
Starts the lifetime of the handle and allocates its needed resources.
- Since :
- 6.5
- 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 [in] flags The flags to open call [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_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter 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_RESOURCE_BUSY Device is in use 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 into a local buffer.
- Warning:
- This is not for use by third-party applications.
Reads data from the UART slave device into a local buffer.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] uart The UART handle [out] data The buffer to read [in] 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_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_IO_ERROR I/O operation failed PERIPHERAL_ERROR_TRY_AGAIN Try again 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 the baud rate for the given UART slave device.
- Warning:
- This is not for use by third-party applications.
Sets the baud rate for the given UART slave device.
- 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_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_IO_ERROR I/O operation failed PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed 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 data byte size for the given UART slave device.
- Warning:
- This is not for use by third-party applications.
Sets data byte size for the given UART slave device.
- 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_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_IO_ERROR I/O operation failed PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed 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 hardware and software flow control of the UART slave device.
- Warning:
- This is not for use by third-party applications.
Sets hardware and software flow control of the UART slave device.
- 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_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_IO_ERROR I/O operation failed PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed PERIPHERAL_ERROR_UNKNOWN Unknown internal error
int peripheral_uart_set_parity | ( | peripheral_uart_h | uart, |
peripheral_uart_parity_e | parity | ||
) |
Sets the parity bit for the given UART slave device.
- Warning:
- This is not for use by third-party applications.
Sets the parity bit for the given UART slave device.
- 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_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_IO_ERROR I/O operation failed PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed 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 the number of stop bits for the UART slave device.
- Warning:
- This is not for use by third-party applications.
Sets the number of stop bits for the UART slave device.
- 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_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_IO_ERROR I/O operation failed PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed 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 from a buffer to the UART slave device.
- Warning:
- This is not for use by third-party applications.
Writes data from a buffer to the UART slave device.
- 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_NOT_SUPPORTED Not supported PERIPHERAL_ERROR_PERMISSION_DENIED Permission denied PERIPHERAL_ERROR_INVALID_PARAMETER Invalid parameter PERIPHERAL_ERROR_IO_ERROR I/O operation failed PERIPHERAL_ERROR_TRY_AGAIN Try again PERIPHERAL_ERROR_UNKNOWN Unknown internal error
- See also:
- peripheral_uart_read()