Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

periph/dac: support for DAC extension API #10512

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
8 changes: 4 additions & 4 deletions cpu/efm32/periph/dac.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "em_dac.h"
#endif

int8_t dac_init(dac_t line)
int8_t dac_init_cpu(dac_t line)
{
/* check if device is valid */
if (line >= DAC_NUMOF) {
Expand Down Expand Up @@ -60,7 +60,7 @@ int8_t dac_init(dac_t line)
return 0;
}

void dac_set(dac_t line, uint16_t value)
void dac_set_cpu(dac_t line, uint16_t value)
{
uint8_t dev = dac_channel_config[line].dev;

Expand All @@ -69,14 +69,14 @@ void dac_set(dac_t line, uint16_t value)
value & 0xfff);
}

void dac_poweron(dac_t line)
void dac_poweron_cpu(dac_t line)
{
uint8_t dev = dac_channel_config[line].dev;

CMU_ClockEnable(dac_config[dev].cmu, true);
}

void dac_poweroff(dac_t line)
void dac_poweroff_cpu(dac_t line)
{
uint8_t dev = dac_channel_config[line].dev;

Expand Down
8 changes: 4 additions & 4 deletions cpu/esp32/periph/adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ static void _adc_module_init(void)
static bool _dac_conf_check(void);
static bool _dac_module_initialized = false;

int8_t dac_init (dac_t line)
int8_t dac_init_cpu(dac_t line)
{
CHECK_PARAM_RET (line < dac_chn_num, DAC_NOLINE)

Expand Down Expand Up @@ -461,18 +461,18 @@ int8_t dac_init (dac_t line)
return DAC_OK;
}

void dac_set (dac_t line, uint16_t value)
void dac_set_cpu(dac_t line, uint16_t value)
{
CHECK_PARAM (line < dac_chn_num);
RTCIO.pad_dac[_gpio_rtcio_map[dac_pins[line]] - RTCIO_DAC1].dac = value >> 8;
}

void dac_poweroff (dac_t line)
void dac_poweroff_cpu(dac_t line)
{
CHECK_PARAM (line < dac_chn_num);
}

void dac_poweron (dac_t line)
void dac_poweron_cpu(dac_t line)
{
CHECK_PARAM (line < dac_chn_num);
}
Expand Down
8 changes: 4 additions & 4 deletions cpu/kinetis/periph/dac.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static inline DAC_Type *dev(dac_t line)
return dac_config[line].dev;
}

int8_t dac_init(dac_t line)
int8_t dac_init_cpu(dac_t line)
{
if (line >= DAC_NUMOF) {
return DAC_NOLINE;
Expand All @@ -57,7 +57,7 @@ int8_t dac_init(dac_t line)
return DAC_OK;
}

void dac_set(dac_t line, uint16_t value)
void dac_set_cpu(dac_t line, uint16_t value)
{
assert(line < DAC_NUMOF);

Expand All @@ -68,14 +68,14 @@ void dac_set(dac_t line, uint16_t value)
dev(line)->DAT[0].DATL = (value & 0xff);
}

void dac_poweron(dac_t line)
void dac_poweron_cpu(dac_t line)
{
assert(line < DAC_NUMOF);

bit_set8(&dac_config[line].dev->C0, DAC_C0_DACEN_SHIFT);
}

void dac_poweroff(dac_t line)
void dac_poweroff_cpu(dac_t line)
{
assert(line < DAC_NUMOF);

Expand Down
8 changes: 4 additions & 4 deletions cpu/sam3/periph/dac.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#define DAC_REFRESH (DACC_MR_REFRESH(128))
#endif

int8_t dac_init(dac_t line)
int8_t dac_init_cpu(dac_t line)
{
assert(line < DAC_NUMOF);

Expand All @@ -53,22 +53,22 @@ int8_t dac_init(dac_t line)
return 0;
}

void dac_set(dac_t line, uint16_t value)
void dac_set_cpu(dac_t line, uint16_t value)
{
assert(line < DAC_NUMOF);

DACC->DACC_CDR = ((value >> 4) | (line << 12));
}

void dac_poweron(dac_t line)
void dac_poweron_cpu(dac_t line)
{
assert(line < DAC_NUMOF);

PMC->PMC_PCER1 = PMC_BIT;
DACC->DACC_CHER = (1 << line);
}

void dac_poweroff(dac_t line)
void dac_poweroff_cpu(dac_t line)
{
assert(line < DAC_NUMOF);

Expand Down
8 changes: 4 additions & 4 deletions cpu/stm32_common/periph/dac.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static inline DAC_TypeDef *dev(dac_t line)
#endif
}

int8_t dac_init(dac_t line)
int8_t dac_init_cpu(dac_t line)
{
if (line >= DAC_NUMOF) {
return DAC_NOLINE;
Expand All @@ -69,7 +69,7 @@ int8_t dac_init(dac_t line)
return DAC_OK;
}

void dac_set(dac_t line, uint16_t value)
void dac_set_cpu(dac_t line, uint16_t value)
{
assert(line < DAC_NUMOF);

Expand All @@ -88,7 +88,7 @@ void dac_set(dac_t line, uint16_t value)
#endif
}

void dac_poweron(dac_t line)
void dac_poweron_cpu(dac_t line)
{
assert(line < DAC_NUMOF);

Expand All @@ -104,7 +104,7 @@ void dac_poweron(dac_t line)
dev(line)->CR |= (1 << (16 * (dac_config[line].chan & 0x01)));
}

void dac_poweroff(dac_t line)
void dac_poweroff_cpu(dac_t line)
{
assert(line < DAC_NUMOF);

Expand Down
4 changes: 4 additions & 0 deletions drivers/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ ifneq (,$(filter ethos,$(USEMODULE)))
USEMODULE += tsrb
endif

ifneq (,$(filter extend_dac,$(USEMODULE)))
ZetaR60 marked this conversation as resolved.
Show resolved Hide resolved
USEMODULE += extend
endif

ifneq (,$(filter feetech,$(USEMODULE)))
USEMODULE += uart_half_duplex
endif
Expand Down
4 changes: 4 additions & 0 deletions drivers/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ ifneq (,$(filter encx24j600,$(USEMODULE)))
USEMODULE_INCLUDES += $(RIOTBASE)/drivers/encx24j600/include
endif

ifneq (,$(filter extend,$(USEMODULE)))
USEMODULE_INCLUDES += $(RIOTBASE)/drivers/extend/include
endif

ifneq (,$(filter feetech,$(USEMODULE)))
USEMODULE_INCLUDES += $(RIOTBASE)/drivers/feetech/include
endif
Expand Down
1 change: 1 addition & 0 deletions drivers/extend/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(RIOTBASE)/Makefile.base
83 changes: 83 additions & 0 deletions drivers/extend/dac_notsup.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Copyright (C) 2018 Gunar Schorcht
* Copyright (C) 2018 Acutam Automation, LLC
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup drivers_extend_dac
*
* @{
*
* @file
* @brief DAC extension not-supported functions
*
* @author Gunar Schorcht <gunar@schorcht.net>
* @author Matthew Blue <matthew.blue.neuro@gmail.com>
*
* @}
*/

#if MODULE_EXTEND_DAC

#include "periph/dac.h"
#include "extend/dac.h"

#define ENABLE_DEBUG (0)
#include "debug.h"

int8_t dac_ext_init_notsup(void *dev, dac_t line)
{
(void)dev;
(void)line;

DEBUG("[%s] call for dev %p line %u\n", __func__, dev, line);

return -1;
}

void dac_ext_set_notsup(void *dev, dac_t line, uint16_t value)
{
(void)dev;
(void)line;
(void)value;

DEBUG("[%s] call for dev %p line %u value %u\n", __func__, dev, line, value);
}

void dac_ext_poweron_notsup(void *dev, dac_t line)
{
(void)dev;
(void)line;

DEBUG("[%s] call for dev %p line %u\n", __func__, dev, line);
}

void dac_ext_poweroff_notsup(void *dev, dac_t line)
{
(void)dev;
(void)line;

DEBUG("[%s] call for dev %p line %u\n", __func__, dev, line);
}

unsigned int dac_ext_channels_notsup(void *dev)
{
(void)dev;

DEBUG("[%s] call for dev %p\n", __func__, dev);
return 0;
}

/* not-supported driver */
const dac_ext_driver_t dac_ext_notsup_driver = {
.init = dac_ext_init_notsup,
.set = dac_ext_set_notsup,
.poweron = dac_ext_poweron_notsup,
.poweroff = dac_ext_poweroff_notsup,
.channels = dac_ext_channels_notsup
};
#endif /* MODULE_EXTEND_DAC */
Loading