doc/syscalls/00010_pwm.md
The PWM driver provides userspace to control a specific PWM pin. The pin's frequency and duty cycle can be changed.
The PWM pins are indexed in the array starting at 0. The order of the pins and the mapping between indexes and the actual pins is set by the kernel in the board's main file.
0Description: Existence check.
Argument 1: Unused
Argument 2: Unused
Returns: Success, or NODEVICE if this driver is not present on the board.
1Description: Start the PWM output.
Argument 1: First 16 bits represent the duty cycle, as a percentage with 2 decimals (100% being the maximum possible duty cycle), and the last 16 bits represent the PWM pin to be controlled. This format was chosen because there are only 2 parameters in the command function that can be used for storing values, but in this case, 3 values are needed (pin, frequency, duty cycle), so data1 stores two of these values, which can be represented using only 16 bits.
Argument 2: The frequency in hertz.
Returns: Ok(()) if the start attempt was successful, INVAL if the pin is invalid, RESERVE if the app doesn't have permission to use this pin at this time.
2Description: Stop the PWM output.
Argument 1: The PWM pin to be stopped.
Argument 2: unused
Returns: Ok(()) if the stop attempt was successful, INVAL if the pin is invalid, RESERVE if the app doesn't have permission to use this pin at this time, OFF if the requested pin is already off.
3Description: Get the maximum frequency of the pin.
Argument 1: The PWM pin to get the maximum frequency from.
Argument 2: unused
Returns: The maximum frequency of the pin, INVAL if the pin is invalid.
4Description: How many PWM pins are supported on this board.
Argument 1: unused
Argument 2: unused
Returns: The number of PWM pins on this board.
Unused for the PWM driver. Will always return ENOSUPPORT.
Unused for the PWM driver. Will always return ENOSUPPORT.