px-fwlib 0.10.0
Cross-platform embedded library and documentation for 8/16/32-bit microcontrollers generated with Doxygen 1.9.2

Description

Driver to output analogue values.

File(s):

The driver must be configured by supplying a project specific "px_dac_cfg.h". "px_dac_cfg_template.h" can be copied, renamed and modified to supply compile time options.

Example:
#include "px_dac.h"
#include "px_board.h"
// Create DAC handle object
static px_dac_handle_t px_dac_handle;
int main(void)
{
uint16_t data;
// Initialise board
// Initialise DAC driver
// Open handle to DAC peripheral
px_dac_open(&px_dac_handle, PX_DAC_NR_1);
// Perform an DAC measurement on channel 0
data = px_dac_sample(&px_dac_handle, PX_DAC_CH0);
// Close DAC Handle
px_dac_close(px_dac_handle);
}
void px_board_init(void)
Initialise the board hardware.
Definition: px_board.c:168
bool px_dac_close(px_dac_handle_t *handle)
Close specified device.
Definition: px_dac.c:154
void px_dac_init(void)
Initialise DAC driver.
Definition: px_dac.c:101
bool px_dac_open(px_dac_handle_t *handle, px_dac_nr_t dac_nr)
Open DAC peripheral using predefined (default) parameters.
Definition: px_dac.c:109
Define DAC handle.
Definition: px_dac.h:87

Data Structures

struct  px_dac_handle_t
 Define DAC handle. More...
 

Macros

#define PX_DAC_CFG_PER_COUNT   (PX_DAC_CFG_DAC1_EN)
 Number of enabled peripherals. More...
 
#define PX_DAC_CFG_DAC1_EN   1
 Enable/disable support for DAC1 peripheral. More...
 
#define PX_DAC_CFG_DAC1_CH1_EN   1
 Enable/disable support for DAC1 Channel 1. More...
 
#define PX_DAC_CFG_DAC1_CH2_EN   0
 Enable/disable support for DAC1 Channel 2. More...
 

Enumerations

enum  px_dac_nr_t
 Specify DAC peripheral. More...
 
enum  px_dac_channel_t
 Specify DAC channel. More...
 

Functions

void px_dac_init (void)
 Initialise DAC driver. More...
 
bool px_dac_open (px_dac_handle_t *handle, px_dac_nr_t dac_nr)
 Open DAC peripheral using predefined (default) parameters. More...
 
bool px_dac_close (px_dac_handle_t *handle)
 Close specified device. More...
 
void px_dac_wr (px_dac_handle_t *handle, px_dac_channel_t channel, uint16_t data)
 Perform a single output on the specified DAC channel. More...
 

Data Structure Documentation

◆ px_dac_handle_t

struct px_dac_handle_t

Define DAC handle.

Definition at line 86 of file px_dac.h.

Data Fields
struct px_dac_per_s * dac_per DAC peripheral data.

Macro Definition Documentation

◆ PX_DAC_CFG_PER_COUNT

#define PX_DAC_CFG_PER_COUNT   (PX_DAC_CFG_DAC1_EN)

Number of enabled peripherals.

Definition at line 63 of file px_dac.h.

◆ PX_DAC_CFG_DAC1_EN

#define PX_DAC_CFG_DAC1_EN   1

Enable/disable support for DAC1 peripheral.

Definition at line 34 of file px_dac_cfg_template.h.

◆ PX_DAC_CFG_DAC1_CH1_EN

#define PX_DAC_CFG_DAC1_CH1_EN   1

Enable/disable support for DAC1 Channel 1.

Definition at line 37 of file px_dac_cfg_template.h.

◆ PX_DAC_CFG_DAC1_CH2_EN

#define PX_DAC_CFG_DAC1_CH2_EN   0

Enable/disable support for DAC1 Channel 2.

Definition at line 40 of file px_dac_cfg_template.h.

Enumeration Type Documentation

◆ px_dac_nr_t

Specify DAC peripheral.

Definition at line 73 of file px_dac.h.

◆ px_dac_channel_t

Specify DAC channel.

Definition at line 79 of file px_dac.h.

Function Documentation

◆ px_dac_init()

void px_dac_init ( void  )

Initialise DAC driver.

Definition at line 101 of file px_dac.c.

◆ px_dac_open()

bool px_dac_open ( px_dac_handle_t handle,
px_dac_nr_t  dac_nr 
)

Open DAC peripheral using predefined (default) parameters.

Parameters
handlePointer to handle data structure
dac_nrDAC peripheral number
Return values
falseError: peripheral was not opened
trueSuccess: peripheral was opened

Definition at line 109 of file px_dac.c.

◆ px_dac_close()

bool px_dac_close ( px_dac_handle_t handle)

Close specified device.

Parameters
handlePointer to handle data structure
Return values
trueSuccess
falseSpecified device was already closed (or not opened)

Definition at line 154 of file px_dac.c.

◆ px_dac_wr()

void px_dac_wr ( px_dac_handle_t handle,
px_dac_channel_t  channel,
uint16_t  data 
)

Perform a single output on the specified DAC channel.

Parameters
handlePointer to handle data structure
channelDAC channel (1 or 2)
dataData value to output

Definition at line 211 of file px_dac.c.