Tizen Native API
9.0
|
The PWM API provides functions to control PWM peripherals connected to the IoT device.
The PWM API provides functions to control PWM peripherals connected to the IoT device.
Required Header
#include <peripheral_io.h>
Overview
This PWM API provides functions to control PWM 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_pwm_open (int chip, int pin, peripheral_pwm_h *pwm) |
Opens the PWM pin and returns a handle representing it. | |
int | peripheral_pwm_close (peripheral_pwm_h pwm) |
Closes a PWM pin and frees resources associated with the handle. | |
int | peripheral_pwm_set_period (peripheral_pwm_h pwm, uint32_t period_ns) |
Sets the period length in nanoseconds for the given PWM pin. | |
int | peripheral_pwm_set_duty_cycle (peripheral_pwm_h pwm, uint32_t duty_cycle_ns) |
Sets the length of a duty cycle of the given PWM pin. | |
int | peripheral_pwm_set_polarity (peripheral_pwm_h pwm, peripheral_pwm_polarity_e polarity) |
Sets the active signal polarity of the given PWM pin. | |
int | peripheral_pwm_set_enabled (peripheral_pwm_h pwm, bool enabled) |
Toggles whether given PWM peripherals pin is enabled. | |
Typedefs | |
typedef struct _peripheral_pwm_s * | peripheral_pwm_h |
An opaque handle representing a PWM peripherals pin. |
Typedef Documentation
typedef struct _peripheral_pwm_s* peripheral_pwm_h |
An opaque handle representing a PWM peripherals pin.
A handle to a single PWM peripherals pin, for use with most PWM interfaces
- Since :
- 4.0
Enumeration Type Documentation
Enumeration for representing PWN active signal Polarity.
Controls whether an active PWM signal has high or low/inversed polarity.
- Since :
- 4.0
Function Documentation
int peripheral_pwm_close | ( | peripheral_pwm_h | pwm | ) |
Closes a PWM pin 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] pwm The PWM 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_IO_ERROR I/O operation failed PERIPHERAL_ERROR_NO_DEVICE Device does not exist or is removed PERIPHERAL_ERROR_UNKNOWN Unknown internal error
- Precondition:
- peripheral_pwm_open()
int peripheral_pwm_open | ( | int | chip, |
int | pin, | ||
peripheral_pwm_h * | pwm | ||
) |
Opens the PWM pin 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:
- pwm should be released with peripheral_pwm_close()
- Parameters:
-
[in] chip The PWM chip number [in] pin The PWM pin(channel) number to control [out] pwm The PWM 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_pwm_close()
int peripheral_pwm_set_duty_cycle | ( | peripheral_pwm_h | pwm, |
uint32_t | duty_cycle_ns | ||
) |
Sets the length of a duty cycle of the given PWM pin.
- Warning:
- This is not for use by third-party applications.
Sets the length of a duty cycle of the given PWM pin.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] pwm The PWM handle [in] duty_cycle_ns The duty cycle of the PWM pin (in nanoseconds)
- 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_pwm_set_enabled | ( | peripheral_pwm_h | pwm, |
bool | enabled | ||
) |
Toggles whether given PWM peripherals pin is enabled.
- Warning:
- This is not for use by third-party applications.
Toggles whether given PWM peripherals pin is enabled.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] pwm The PWM handle [in] enabled Enable/disable the PWM pin
- 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_pwm_set_period | ( | peripheral_pwm_h | pwm, |
uint32_t | period_ns | ||
) |
Sets the period length in nanoseconds for the given PWM pin.
- Warning:
- This is not for use by third-party applications.
Sets the period length in nanoseconds for the given PWM pin.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] pwm The PWM handle [in] period_ns The total period of the PWM pin (in nanoseconds)
- 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_pwm_set_polarity | ( | peripheral_pwm_h | pwm, |
peripheral_pwm_polarity_e | polarity | ||
) |
Sets the active signal polarity of the given PWM pin.
- Warning:
- This is not for use by third-party applications.
Sets the active signal polarity of the given PWM pin.
- Since :
- 4.0
- Privilege Level:
- platform
- Privilege:
- http://tizen.org/privilege/peripheralio
- Parameters:
-
[in] pwm The PWM handle [in] polarity The polarity of the PWM pin
- 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_pwm_polarity_e