2.3. analog_output_pin — Analog output pin

Source code: src/drivers/analog_output_pin.h, src/drivers/analog_output_pin.c

Test code: tst/drivers/analog_output_pin/main.c


Functions

int analog_output_pin_module_init(void)

Initialize the analog output pin module. This function must be called before calling any other function in this module.

The module will only be initialized once even if this function is called multiple times.

Return
zero(0) or negative error code.

int analog_output_pin_init(struct analog_output_pin_t *self_p, struct pin_device_t *dev_p)

Initialize given driver object with given device and mode.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object to be initialized.
  • dev_p: Device to use.

int analog_output_pin_write(struct analog_output_pin_t *self_p, int value)

Write given value to the analog pin.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object.
  • value: The value to write to the pin. A number in the range 0 to 1023, where 0 is lowest output and 1023 is highest output.

int analog_output_pin_read(struct analog_output_pin_t *self_p)

Read the value that is currently written to given analog output pin.

Return
Value in the range 0 to 1023, or negative error code.
Parameters
  • self_p: Driver object.

struct analog_output_pin_t
#include <analog_output_pin.h>

Public Members

struct pwm_driver_t pwm