49 lines
913 B
C
49 lines
913 B
C
#include "dac_drv.h"
|
|
|
|
#if (DEF_MAX5136_ENABLED)
|
|
extern dac_drv_if_t max5316_drv;
|
|
static const dac_drv_if_t *p_inst = &max5316_drv;
|
|
#else
|
|
static dac_drv_if_t *p_inst = NULL;
|
|
#endif /* ! DEF_MAX5136_ENABLED */
|
|
|
|
#if (DEF_DAC_DRV_ENABLED)
|
|
|
|
int dac_init(void)
|
|
{
|
|
if (p_inst == NULL)
|
|
{
|
|
return DAC_DRV_ERROR;
|
|
}
|
|
return p_inst->init();
|
|
}
|
|
|
|
int dac_write(uint32_t channel_mask, int32_t dac_val)
|
|
{
|
|
if (p_inst == NULL)
|
|
{
|
|
return DAC_DRV_ERROR;
|
|
}
|
|
return p_inst->write_mode(channel_mask, dac_val);
|
|
}
|
|
|
|
int dac_load(uint32_t channel_mask)
|
|
{
|
|
if (p_inst == NULL)
|
|
{
|
|
return DAC_DRV_ERROR;
|
|
}
|
|
return p_inst->ldac_mode(channel_mask);
|
|
}
|
|
|
|
int dac_write_through(uint32_t channel_mask, int32_t dac_val)
|
|
{
|
|
if (p_inst == NULL)
|
|
{
|
|
return DAC_DRV_ERROR;
|
|
}
|
|
return p_inst->write_through_mode(channel_mask, dac_val);
|
|
}
|
|
|
|
#endif /* ! DEF_DAC_DRV_ENABLED */
|