24#include "px_stm32cube.h"
31typedef struct px_dac_per_s
51static void px_dac_init_per(DAC_TypeDef * dac_base_adr,
54 uint32_t dac_channel = 0;
61 LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_DAC1);
69#if PX_DAC_CFG_DAC1_CH1_EN
70 dac_channel |= LL_DAC_CHANNEL_1;
72#if PX_DAC_CFG_DAC1_CH2_EN
73 dac_channel |= LL_DAC_CHANNEL_2;
75 LL_DAC_Enable(dac_base_adr, dac_channel);
104#if PX_DAC_CFG_DAC1_EN
105 px_dac_init_per_data(PX_DAC_NR_1, &px_dac_per_1);
128#if PX_DAC_CFG_DAC1_EN
130 dac_per = &px_dac_per_1;
134 PX_LOG_E(
"Invalid peripheral specified");
157 DAC_TypeDef * dac_base_adr;
158 uint32_t dac_channel = 0;
165 ||(handle->
dac_per->open_counter == 0 ) )
187#if PX_DAC_CFG_DAC1_CH1_EN
188 dac_channel |= LL_DAC_CHANNEL_1;
190#if PX_DAC_CFG_DAC1_CH2_EN
191 dac_channel |= LL_DAC_CHANNEL_2;
193 LL_DAC_Disable(dac_base_adr, dac_channel);
195 switch(handle->
dac_per->dac_nr)
197#if PX_DAC_CFG_DAC1_EN
199 LL_APB1_GRP1_DisableClock(LL_APB1_GRP1_PERIPH_DAC1);
216 DAC_TypeDef * dac_base_adr;
223 ||(handle->
dac_per->open_counter == 0 ) )
237 case PX_DAC_CHANNEL_1:
238 dac_base_adr->DHR12R1 = data;
240 case PX_DAC_CHANNEL_2:
241 dac_base_adr->DHR12R2 = data;
244 PX_LOG_E(
"Invalid DAC channel specified");
#define NULL
NULL pointer.
#define PX_LOG_NAME(name)
Macro to declare a log name string once for each file to reduce code size.
#define PX_LOG_E(format,...)
Macro to display a formatted ERROR message.
#define PX_LOG_ASSERT(expression)
Macro that will test an expression, and block indefinitely if false.
struct px_dac_per_s * dac_per
DAC peripheral data.
bool px_dac_close(px_dac_handle_t *handle)
Close specified device.
px_dac_channel_t
Specify DAC channel.
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.
void px_dac_init(void)
Initialise DAC driver.
px_dac_nr_t
Specify DAC peripheral.
bool px_dac_open(px_dac_handle_t *handle, px_dac_nr_t dac_nr)
Open DAC peripheral using predefined (default) parameters.
Internal data for each DAC handle.
uint8_t open_counter
Number of open handles referencing peripheral.
px_dac_nr_t dac_nr
Peripheral.
DAC_TypeDef * dac_base_adr
DAC peripheral base register address.