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
Enumerator:
PERIPHERAL_PWM_POLARITY_ACTIVE_HIGH 

PWM signal start in the active high state (Normal)

PERIPHERAL_PWM_POLARITY_ACTIVE_LOW 

PWM signal start in the active low state (Inversed)


Function Documentation

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]pwmThe PWM handle
Returns:
0 on success, otherwise a negative error value
Return values:
PERIPHERAL_ERROR_NONESuccessful
PERIPHERAL_ERROR_NOT_SUPPORTEDNot supported
PERIPHERAL_ERROR_PERMISSION_DENIEDPermission denied
PERIPHERAL_ERROR_INVALID_PARAMETERInvalid parameter
PERIPHERAL_ERROR_IO_ERRORI/O operation failed
PERIPHERAL_ERROR_NO_DEVICEDevice does not exist or is removed
PERIPHERAL_ERROR_UNKNOWNUnknown 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]chipThe PWM chip number
[in]pinThe PWM pin(channel) number to control
[out]pwmThe PWM handle is created on success
Returns:
0 on success, otherwise a negative error value
Return values:
PERIPHERAL_ERROR_NONESuccessful
PERIPHERAL_ERROR_NOT_SUPPORTEDNot supported
PERIPHERAL_ERROR_PERMISSION_DENIEDPermission denied
PERIPHERAL_ERROR_INVALID_PARAMETERInvalid parameter
PERIPHERAL_ERROR_IO_ERRORI/O operation failed
PERIPHERAL_ERROR_NO_DEVICEDevice does not exist or is removed
PERIPHERAL_ERROR_OUT_OF_MEMORYMemory allocation failed
PERIPHERAL_ERROR_RESOURCE_BUSYDevice is in use
PERIPHERAL_ERROR_UNKNOWNUnknown 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]pwmThe PWM handle
[in]duty_cycle_nsThe duty cycle of the PWM pin (in nanoseconds)
Returns:
0 on success, otherwise a negative error value
Return values:
PERIPHERAL_ERROR_NONESuccessful
PERIPHERAL_ERROR_NOT_SUPPORTEDNot supported
PERIPHERAL_ERROR_PERMISSION_DENIEDPermission denied
PERIPHERAL_ERROR_INVALID_PARAMETERInvalid parameter
PERIPHERAL_ERROR_IO_ERRORI/O operation failed
PERIPHERAL_ERROR_NO_DEVICEDevice does not exist or is removed
PERIPHERAL_ERROR_UNKNOWNUnknown 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]pwmThe PWM handle
[in]enabledEnable/disable the PWM pin
Returns:
0 on success, otherwise a negative error value
Return values:
PERIPHERAL_ERROR_NONESuccessful
PERIPHERAL_ERROR_NOT_SUPPORTEDNot supported
PERIPHERAL_ERROR_PERMISSION_DENIEDPermission denied
PERIPHERAL_ERROR_INVALID_PARAMETERInvalid parameter
PERIPHERAL_ERROR_IO_ERRORI/O operation failed
PERIPHERAL_ERROR_NO_DEVICEDevice does not exist or is removed
PERIPHERAL_ERROR_UNKNOWNUnknown 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]pwmThe PWM handle
[in]period_nsThe total period of the PWM pin (in nanoseconds)
Returns:
0 on success, otherwise a negative error value
Return values:
PERIPHERAL_ERROR_NONESuccessful
PERIPHERAL_ERROR_NOT_SUPPORTEDNot supported
PERIPHERAL_ERROR_PERMISSION_DENIEDPermission denied
PERIPHERAL_ERROR_INVALID_PARAMETERInvalid parameter
PERIPHERAL_ERROR_IO_ERRORI/O operation failed
PERIPHERAL_ERROR_NO_DEVICEDevice does not exist or is removed
PERIPHERAL_ERROR_UNKNOWNUnknown internal error

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]pwmThe PWM handle
[in]polarityThe polarity of the PWM pin
Returns:
0 on success, otherwise a negative error value
Return values:
PERIPHERAL_ERROR_NONESuccessful
PERIPHERAL_ERROR_NOT_SUPPORTEDNot supported
PERIPHERAL_ERROR_PERMISSION_DENIEDPermission denied
PERIPHERAL_ERROR_INVALID_PARAMETERInvalid parameter
PERIPHERAL_ERROR_IO_ERRORI/O operation failed
PERIPHERAL_ERROR_NO_DEVICEDevice does not exist or is removed
PERIPHERAL_ERROR_UNKNOWNUnknown internal error
See also:
peripheral_pwm_polarity_e