Tizen Native API  7.0

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.
int peripheral_pwm_close (peripheral_pwm_h pwm)
 Closes the PWM pin.
int peripheral_pwm_set_period (peripheral_pwm_h pwm, uint32_t period_ns)
 Sets period of the PWM pin.
int peripheral_pwm_set_duty_cycle (peripheral_pwm_h pwm, uint32_t duty_cycle_ns)
 Sets duty cycle of the PWM pin.
int peripheral_pwm_set_polarity (peripheral_pwm_h pwm, peripheral_pwm_polarity_e polarity)
 Sets polarity of the PWM pin.
int peripheral_pwm_set_enabled (peripheral_pwm_h pwm, bool enabled)
 Enables the PWM pin.

Typedefs

typedef struct _peripheral_pwm_s * peripheral_pwm_h
 The handle of the PWM peripherals.

Typedef Documentation

typedef struct _peripheral_pwm_s* peripheral_pwm_h

The handle of the PWM peripherals.

Since :
4.0

Enumeration Type Documentation

Enumeration for 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 the PWM pin.

Warning:
This is not for use by third-party applications.
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_IO_ERRORI/O operation failed
PERIPHERAL_ERROR_NO_DEVICEDevice does not exist or is removed
PERIPHERAL_ERROR_PERMISSION_DENIEDPermission denied
PERIPHERAL_ERROR_INVALID_PARAMETERInvalid parameter
PERIPHERAL_ERROR_NOT_SUPPORTEDNot supported
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.

Warning:
This is not for use by third-party applications.
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_IO_ERRORI/O operation failed
PERIPHERAL_ERROR_NO_DEVICEDevice does not exist or is removed
PERIPHERAL_ERROR_OUT_OF_MEMORYMemory allocation failed
PERIPHERAL_ERROR_PERMISSION_DENIEDPermission denied
PERIPHERAL_ERROR_RESOURCE_BUSYDevice is in use
PERIPHERAL_ERROR_INVALID_PARAMETERInvalid parameter
PERIPHERAL_ERROR_NOT_SUPPORTEDNot supported
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 duty cycle of the PWM pin.

Warning:
This is not for use by third-party applications.
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_IO_ERRORI/O operation failed
PERIPHERAL_ERROR_NO_DEVICEDevice does not exist or is removed
PERIPHERAL_ERROR_PERMISSION_DENIEDPermission denied
PERIPHERAL_ERROR_INVALID_PARAMETERInvalid parameter
PERIPHERAL_ERROR_NOT_SUPPORTEDNot supported
PERIPHERAL_ERROR_UNKNOWNUnknown internal error
int peripheral_pwm_set_enabled ( peripheral_pwm_h  pwm,
bool  enabled 
)

Enables the PWM pin.

Warning:
This is not for use by third-party applications.
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_IO_ERRORI/O operation failed
PERIPHERAL_ERROR_NO_DEVICEDevice does not exist or is removed
PERIPHERAL_ERROR_PERMISSION_DENIEDPermission denied
PERIPHERAL_ERROR_INVALID_PARAMETERInvalid parameter
PERIPHERAL_ERROR_NOT_SUPPORTEDNot supported
PERIPHERAL_ERROR_UNKNOWNUnknown internal error
int peripheral_pwm_set_period ( peripheral_pwm_h  pwm,
uint32_t  period_ns 
)

Sets period of the PWM pin.

Warning:
This is not for use by third-party applications.
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_IO_ERRORI/O operation failed
PERIPHERAL_ERROR_NO_DEVICEDevice does not exist or is removed
PERIPHERAL_ERROR_PERMISSION_DENIEDPermission denied
PERIPHERAL_ERROR_INVALID_PARAMETERInvalid parameter
PERIPHERAL_ERROR_NOT_SUPPORTEDNot supported
PERIPHERAL_ERROR_UNKNOWNUnknown internal error

Sets polarity of the PWM pin.

Warning:
This is not for use by third-party applications.
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_IO_ERRORI/O operation failed
PERIPHERAL_ERROR_NO_DEVICEDevice does not exist or is removed
PERIPHERAL_ERROR_PERMISSION_DENIEDPermission denied
PERIPHERAL_ERROR_INVALID_PARAMETERInvalid parameter
PERIPHERAL_ERROR_NOT_SUPPORTEDNot supported
PERIPHERAL_ERROR_UNKNOWNUnknown internal error
See also:
peripheral_pwm_polarity_e