PWM_Apply Function

Header: #include <applibs/pwm.h>

Sets the state of a PWM channel for a PWM controller.

int PWM_Apply(int pwmFd, PWM_ChannelId pwmChannel, const PwmState *newState);

Parameters

  • pwmFd The file descriptor for the PWM controller. PWM_Open retrieves the file descriptor.

  • pwmChannel The zero-based index that identifies the PWM channel to update. The maximum value permitted depends on the platform.

  • newState A pointer to a PwmState struct that contains the new settings to apply. The pointer must remain valid for the duration of the call.

Errors

Returns -1 if an error is encountered and sets errno to the error value.

  • EBADF: the file descriptor is invalid.

  • ENODEV: the pwmChannel parameter is invalid. Verify whether the channel is valid for the hardware platform.

  • EINVAL: the newState parameter passed is invalid. Verify that the newState parameter isn't NULL, and contains valid settings.

Return value

Returns 0 for success, or -1 for failure, in which case errno is set to the error value.

Application manifest requirements

To access a PWM controller, your application must identify it in the Pwm field of the application manifest.