librpipPwmConfigRead

uint32_t librpipPwmConfigRead(uint32_t id, uint32_t* pin, uint32_t* period, uint32_t* duty_cycle, uint32_t* flags);

Description

Reads the current configuration of a PWM.

Parameters

  • uint32_t id
    The PWM device to read. The PWM device needs to have been detected during the librpipInit().
  • uint32_t* pin
    A pointer to a uint32_t which will hold the GPIO pin as a bit mask that the PWM is currently set to. e.g. if pin 12 is assigned to the PWM then this will be represented as 0x00001000 Note that is some situations it may not be possible to work it out (e.g. if /dev/gpiomem is not readable). In that case zero will be returned and you will have to consult the /boot/config.txt. See the peripheral config page for details on how to configure the PWM.
  • uint32_t* period
    A pointer to a uint32_t which will hold the current period in nano seconds.
  • uint32_t* duty_cycle
    A pointer to a uint32_t which will hold the current duty cycle in nano seconds.
  • uint32_t* flags
    A pointer to a uint32_t which will hold the current flags set. See LIBRPIP_PWM_FLAGS_*  for possible flags.

Returns

0 on failure, 1 on success.

Example

Get the current configuration for PWM0:

uint32_t feature_set, pin, period, duty_cycle, flags;
feature_set = librpipInit(LIBRPIP_BOARD_DETECT, LIBRPIP_FLAG_DEBUG_ON, 0);
if(feature_set & LIBRPIP_FEATURE_PWM0) { 
        librpipPwmConfigRead(0, &pin, &period, &duty_cycle, &flags);
}
librpipClose();