3.1.5. dac — Digital to analog convertion

Source code: src/drivers/basic/dac.h, src/drivers/basic/dac.c

Test code: tst/drivers/hardware/basic/dac/main.c


Functions

int dac_module_init(void)

Initialize DAC driver 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 dac_init(struct dac_driver_t *self_p, struct dac_device_t *dev_p, struct pin_device_t *pin0_dev_p, struct pin_device_t *pin1_dev_p, int sampling_rate)

Initialize given driver object from given configuration.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object to be initialized.
  • dev_p: Device to use.
  • pin0_dev_p: Pin used for mono or first stereo channel.
  • pin1_dev_p: Second stereo pin.
  • sampling_rate: Sampling rate in Hz.

int dac_async_convert(struct dac_driver_t *self_p, void *samples_p, size_t length)

Start an asynchronous convertion of samples to an analog signal.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object.
  • samples: Samples to convert to an analog signal.
  • length: Length of samples array.

int dac_async_wait(struct dac_driver_t *self_p)

Wait for ongoing asynchronous convertion to finish.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object.

int dac_convert(struct dac_driver_t *self_p, void *samples_p, size_t length)

Start synchronous convertion of samples to an analog signal.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object.
  • samples: Converted samlpes.
  • length: Length of samples array.

Variables

struct dac_device_t dac_device[DAC_DEVICE_MAX]