cpu/lpc2387: implement periph/dac
The 10 bit DAC on the lpc23xx is very simple. It only has one channel and can only be mapped to a single pin (P0.26). After setting the pin mode to DAC no further configuration in needed.
This commit is contained in:
parent
af0c6e9319
commit
964725259a
@ -1,4 +1,5 @@
|
|||||||
# Put defined MCU peripherals here (in alphabetical order)
|
# Put defined MCU peripherals here (in alphabetical order)
|
||||||
FEATURES_PROVIDED += periph_gpio periph_gpio_irq
|
FEATURES_PROVIDED += periph_gpio periph_gpio_irq
|
||||||
|
FEATURES_PROVIDED += periph_dac
|
||||||
|
|
||||||
-include $(RIOTCPU)/arm7_common/Makefile.features
|
-include $(RIOTCPU)/arm7_common/Makefile.features
|
||||||
|
|||||||
@ -141,6 +141,18 @@ typedef enum {
|
|||||||
/** @} */
|
/** @} */
|
||||||
#endif /* ndef DOXYGEN */
|
#endif /* ndef DOXYGEN */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief DAC configuration, valid for all boards using this CPU
|
||||||
|
*
|
||||||
|
* lpc23xx has a fixed mapping of DAC pins and a fixed number of DAC channels,
|
||||||
|
* so this DAC configuration is valid for all boards using this CPU. No need for
|
||||||
|
* any board specific configuration.
|
||||||
|
*
|
||||||
|
* The DAC of the lpc23xx is mapped to the following fixed pin:
|
||||||
|
* - line 0 (ch0): P0.26
|
||||||
|
*/
|
||||||
|
#define DAC_NUMOF (1U)
|
||||||
|
|
||||||
/* @} */
|
/* @} */
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
53
cpu/lpc2387/periph/dac.c
Normal file
53
cpu/lpc2387/periph/dac.c
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 Beuth Hochschule für Technik Berlin
|
||||||
|
*
|
||||||
|
* 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 cpu_lpc2387
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file
|
||||||
|
* @brief Low-level DAC driver implementation
|
||||||
|
*
|
||||||
|
* @author Benjamin Valentin <benpicco@beuth-hochschule.de>
|
||||||
|
*
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cpu.h"
|
||||||
|
#include "periph/dac.h"
|
||||||
|
|
||||||
|
int8_t dac_init(dac_t line)
|
||||||
|
{
|
||||||
|
(void) line;
|
||||||
|
|
||||||
|
/* P0.26 is the only valid DAC pin */
|
||||||
|
PINSEL1 |= BIT21;
|
||||||
|
PINSEL1 &= ~BIT20;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dac_set(dac_t line, uint16_t value)
|
||||||
|
{
|
||||||
|
(void) line;
|
||||||
|
|
||||||
|
/* Bits 5:0 are reserved for future, higher-resolution D/A converters. */
|
||||||
|
DACR = value & 0xFFE0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dac_poweron(dac_t line)
|
||||||
|
{
|
||||||
|
/* The DAC is always on. */
|
||||||
|
(void) line;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dac_poweroff(dac_t line)
|
||||||
|
{
|
||||||
|
/* The DAC is always on. */
|
||||||
|
(void) line;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user