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"
int main(void)
{
uint16_t data;
data = px_dac_sample(&px_dac_handle, PX_DAC_CH0);
}
void px_board_init(void)
Initialise the board hardware.
bool px_dac_close(px_dac_handle_t *handle)
Close specified device.
void px_dac_init(void)
Initialise DAC driver.
bool px_dac_open(px_dac_handle_t *handle, px_dac_nr_t dac_nr)
Open DAC peripheral using predefined (default) parameters.
◆ 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. |
◆ PX_DAC_CFG_PER_COUNT
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 |
◆ PX_DAC_CFG_DAC1_CH1_EN
| #define PX_DAC_CFG_DAC1_CH1_EN 1 |
◆ PX_DAC_CFG_DAC1_CH2_EN
| #define PX_DAC_CFG_DAC1_CH2_EN 0 |
◆ 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.
◆ px_dac_init()
| void px_dac_init |
( |
void |
| ) |
|
Initialise DAC driver.
Definition at line 101 of file px_dac.c.
◆ px_dac_open()
Open DAC peripheral using predefined (default) parameters.
- Parameters
-
| handle | Pointer to handle data structure |
| dac_nr | DAC peripheral number |
- Return values
-
| false | Error: peripheral was not opened |
| true | Success: peripheral was opened |
Definition at line 109 of file px_dac.c.
◆ px_dac_close()
Close specified device.
- Parameters
-
| handle | Pointer to handle data structure |
- Return values
-
| true | Success |
| false | Specified device was already closed (or not opened) |
Definition at line 154 of file px_dac.c.
◆ px_dac_wr()
Perform a single output on the specified DAC channel.
- Parameters
-
| handle | Pointer to handle data structure |
| channel | DAC channel (1 or 2) |
| data | Data value to output |
Definition at line 211 of file px_dac.c.