aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortheshed <theshed@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-03-01 21:27:40 +0000
committertheshed <theshed@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-03-01 21:27:40 +0000
commit3565edd4cd06559b7fe563c73cd25f864f9f18bf (patch)
tree7eeba0aa771fb4a5ac8b2b5ec1babafa31333910
parent8d356f98e72be582fbcf815ed2668f29740e08f5 (diff)
downloadChibiOS-3565edd4cd06559b7fe563c73cd25f864f9f18bf.tar.gz
ChibiOS-3565edd4cd06559b7fe563c73cd25f864f9f18bf.tar.bz2
ChibiOS-3565edd4cd06559b7fe563c73cd25f864f9f18bf.zip
LPC17xx DAC driver added, DMA lli fixed.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@6737 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--os/hal/platforms/LPC17xx/dac_lld.c210
-rw-r--r--os/hal/platforms/LPC17xx/dac_lld.h207
-rw-r--r--os/hal/platforms/LPC17xx/lpc17xx_dma.h9
-rw-r--r--os/hal/platforms/LPC17xx/platform.mk3
-rw-r--r--os/hal/src/hal.c3
-rw-r--r--testhal/LPC17xx/DAC/Makefile197
-rw-r--r--testhal/LPC17xx/DAC/chconf.h531
-rw-r--r--testhal/LPC17xx/DAC/halconf.h346
-rw-r--r--testhal/LPC17xx/DAC/main.c115
-rw-r--r--testhal/LPC17xx/DAC/mcuconf.h96
10 files changed, 1715 insertions, 2 deletions
diff --git a/os/hal/platforms/LPC17xx/dac_lld.c b/os/hal/platforms/LPC17xx/dac_lld.c
new file mode 100644
index 000000000..11a423d69
--- /dev/null
+++ b/os/hal/platforms/LPC17xx/dac_lld.c
@@ -0,0 +1,210 @@
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+ LPC17xx DAC driver - Copyright (C) 2013 Marcin Jokel
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file LPC17xx/dac_lld.c
+ * @brief LPC17xx DAC subsystem low level driver source.
+ *
+ * @addtogroup DAC
+ * @{
+ */
+
+#include "ch.h"
+#include "hal.h"
+
+#if HAL_USE_DAC || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/** @brief CHN1 driver identifier.*/
+DACDriver DACD1;
+
+/*===========================================================================*/
+/* Driver local variables. */
+/*===========================================================================*/
+
+static lpc17xx_dma_lli_config_t lpc_dac_lli[2] __attribute__((aligned(0x10)));
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+
+/**
+ * @brief DAC DMA interrupt function.
+ *
+ * @param[in] dacp pointer to the @p DACDriver object
+ * @param[in] flags dma error flags
+ */
+static void dac_serve_dma_interrupt(DACDriver *dacp, uint32_t flags) {
+
+ if ((flags & (1 << LPC17xx_DAC_DMA_CHANNEL)) != 0) {
+ _dac_isr_error_code(dacp, flags); /* DMA errors handling.*/
+ }
+ else {
+ if (dacp->half_buffer == false) {
+ _dac_isr_half_code(dacp);
+ dacp->half_buffer = true;
+ }
+ else {
+ _dac_isr_full_code(dacp);
+ dacp->half_buffer = false;
+ }
+ }
+}
+
+/*===========================================================================*/
+/* Driver interrupt handlers. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+/**
+ * @brief Low level DAC driver initialization.
+ *
+ * @notapi
+ */
+void dac_lld_init(void) {
+ dacObjectInit(&DACD1);
+}
+
+/**
+ * @brief Configures and activates the DAC peripheral.
+ *
+ * @param[in] dacp pointer to the @p DACDriver object
+ *
+ * @notapi
+ */
+void dac_lld_start(DACDriver *dacp) {
+
+ if (dacp->state == DAC_STOP) {
+
+ /* Enable DAC */
+ LPC_PINCON->PINSEL1 |= (2UL << 20); /* Set AOUT P0.26 pin.*/
+
+ LPC_DAC->CR = 0;
+ LPC_DAC->CTRL = 0;
+ LPC_DAC->CNTVAL = LPC17xx_PCLK/dacp->config->frequency;
+
+ dmaChannelAllocate(LPC17xx_DAC_DMA_CHANNEL, \
+ (lpc17xx_dmaisr_t)dac_serve_dma_interrupt, \
+ (void *)dacp);
+ }
+}
+
+/**
+ * @brief Deactivates the DAC peripheral.
+ *
+ * @param[in] dacp pointer to the @p DACDriver object
+ *
+ * @notapi
+ */
+void dac_lld_stop(DACDriver *dacp) {
+
+ /* If in ready state then disables the DAC clock.*/
+ if (dacp->state == DAC_READY) {
+
+ /* DMA disable.*/
+ dmaChannelDisable(LPC17xx_DAC_DMA_CHANNEL);
+ dmaChannelRelease(LPC17xx_DAC_DMA_CHANNEL);
+
+ /* Disable DAC */
+ LPC_PINCON->PINSEL1 &= ~(2UL << 20); /* Disable AOUT P0.26 pin.*/
+ }
+}
+
+/**
+ * @brief Sends data over the DAC bus.
+ * @details This asynchronous function starts a transmit operation.
+ * @post At the end of the operation the configured callback is invoked.
+ *
+ * @param[in] dacp pointer to the @p DACDriver object
+ * @param[in] n number of words to send
+ * @param[in] txbuf the pointer to the transmit buffer
+ *
+ * @notapi
+ */
+void dac_lld_start_conversion(DACDriver *dacp) {
+
+ dacp->half_buffer = false;
+ uint32_t dma_ch_config;
+
+ /* DMA configuration */
+ lpc_dac_lli[0].srcaddr = (uint32_t) &dacp->samples[0];
+ lpc_dac_lli[0].dstaddr = (uint32_t)&LPC_DAC->CR;
+ lpc_dac_lli[0].lli = (uint32_t) &lpc_dac_lli[1];
+ lpc_dac_lli[0].control =
+ DMA_CTRL_TRANSFER_SIZE(dacp->depth/2) |
+ DMA_CTRL_SRC_BSIZE_1 |
+ DMA_CTRL_DST_BSIZE_1 |
+ DMA_CTRL_SRC_WIDTH_WORD |
+ DMA_CTRL_DST_WIDTH_WORD |
+ DMA_CTRL_SRC_INC |
+ DMA_CTRL_DST_NOINC |
+ DMA_CTRL_PROT1_USER |
+ DMA_CTRL_PROT2_NONBUFF |
+ DMA_CTRL_PROT3_NONCACHE |
+ DMA_CTRL_INT;
+
+ lpc_dac_lli[1].srcaddr = (uint32_t) &dacp->samples[dacp->depth/2];
+ lpc_dac_lli[1].dstaddr = lpc_dac_lli[0].dstaddr;
+ lpc_dac_lli[1].control = lpc_dac_lli[0].control;
+
+ if (dacp->grpp->circular == true) {
+ lpc_dac_lli[1].lli = (uint32_t) &lpc_dac_lli[0];
+ }
+ else {
+ lpc_dac_lli[1].lli = 0;
+ }
+
+ dma_ch_config =
+ DMA_CFG_CH_ENABLE |
+ DMA_CFG_DST_PERIPH(DMA_DAC) |
+ DMA_CFG_TTYPE_M2P |
+ DMA_CFG_IE |
+ DMA_CFG_ITC;
+
+ dmaChannelSrcAddr(LPC17xx_DAC_DMA_CHANNEL, lpc_dac_lli[0].srcaddr);
+ dmaChannelDstAddr(LPC17xx_DAC_DMA_CHANNEL, lpc_dac_lli[0].dstaddr);
+ dmaChannelLinkedList(LPC17xx_DAC_DMA_CHANNEL, lpc_dac_lli[0].lli);
+ dmaChannelControl(LPC17xx_DAC_DMA_CHANNEL, lpc_dac_lli[0].control);
+ dmaChannelConfig(LPC17xx_DAC_DMA_CHANNEL, dma_ch_config);
+
+ LPC_DAC->CTRL = DACCTRL_DMA_ENA | DACCTRL_CNT_ENA | DACCTRL_DBLBUF_ENA;
+}
+
+void dac_lld_stop_conversion(DACDriver *dacp) {
+
+ /* If in active state then disables the DAC.*/
+ if (dacp->state == DAC_ACTIVE) {
+
+ /* DMA disable.*/
+ dmaChannelDisable(LPC17xx_DAC_DMA_CHANNEL);
+ }
+};
+
+#endif /* HAL_USE_DAC */
+
+/** @} */
diff --git a/os/hal/platforms/LPC17xx/dac_lld.h b/os/hal/platforms/LPC17xx/dac_lld.h
new file mode 100644
index 000000000..26c23da11
--- /dev/null
+++ b/os/hal/platforms/LPC17xx/dac_lld.h
@@ -0,0 +1,207 @@
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+ LPC17xx DAC driver - Copyright (C) 2013 Marcin Jokel
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file LPC17xx/dac_lld.h
+ * @brief LPC17xx DAC subsystem low level driver header.
+ *
+ * @addtogroup DAC
+ * @{
+ */
+
+#ifndef _DAC_LLD_H_
+#define _DAC_LLD_H_
+
+#if HAL_USE_DAC || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Driver constants. */
+/*===========================================================================*/
+
+#define DACR_BIAS (1UL << 16)
+
+#define DACCTRL_INT_DMA_REQ (1UL << 0)
+#define DACCTRL_DBLBUF_ENA (1UL << 1)
+#define DACCTRL_CNT_ENA (1UL << 2)
+#define DACCTRL_DMA_ENA (1UL << 3)
+
+/*===========================================================================*/
+/* Driver pre-compile time settings. */
+/*===========================================================================*/
+
+/**
+ * @name Configuration options
+ * @{
+ */
+
+/**
+ * @brief DMA stream used for DAC CHN1 TX operations.
+ * @note This option is only available on platforms with enhanced DMA.
+ */
+#if !defined(LPC17xx_DAC_DMA_CHANNEL) || defined(__DOXYGEN__)
+#define LPC17xx_DAC_DMA_CHANNEL DMA_CHANNEL5
+#endif
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+#if !defined(LPC17xx_DMA_REQUIRED)
+#define LPC17xx_DMA_REQUIRED
+#endif
+
+/*===========================================================================*/
+/* Driver data structures and types. */
+/*===========================================================================*/
+
+/**
+ * @brief Type of a structure representing an DAC driver.
+ */
+typedef struct DACDriver DACDriver;
+
+/**
+ * @brief Type representing a DAC sample.
+ */
+typedef uint32_t dacsample_t;
+
+/**
+ * @brief DAC notification callback type.
+ *
+ * @param[in] dacp pointer to the @p DACDriver object triggering the
+ * callback
+ */
+typedef void (*dacendcallback_t)(DACDriver *dacp, const dacsample_t * samples, size_t pos);
+
+/**
+ * @brief DAC notification callback type.
+ *
+ * @param[in] dacp pointer to the @p DACDriver object triggering the
+ * callback
+ */
+typedef void (*dacerrcallback_t)(DACDriver *dacp, uint32_t flags);
+
+/**
+ * @brief DAC Conversion group structure.
+ */
+typedef struct {
+ /**
+ * @brief Number of DAC channels.
+ */
+ uint16_t num_channels;
+ /**
+ * @brief Operation complete callback or @p NULL.
+ */
+ dacendcallback_t end_cb;
+ /**
+ * @brief Error handling callback or @p NULL.
+ */
+ dacerrcallback_t error_cb;
+ /**
+ * @brief Error handling callback or @p NULL.
+ */
+ bool circular;
+
+} DACConversionGroup;
+
+/**
+ * @brief Driver configuration structure.
+ */
+typedef struct {
+ /**
+ * @brief Timer frequency in Hz.
+ */
+ uint32_t frequency;
+ /* End of the mandatory fields.*/
+} DACConfig;
+
+/**
+ * @brief Structure representing a DAC driver.
+ */
+struct DACDriver {
+ /**
+ * @brief Driver state.
+ */
+ dacstate_t state;
+ /**
+ * @brief Conversion group.
+ */
+ const DACConversionGroup *grpp;
+ /**
+ * @brief Samples buffer pointer.
+ */
+ const dacsample_t *samples;
+ /**
+ * @brief Samples buffer size.
+ */
+ uint16_t depth;
+ /**
+ * @brief Current configuration data.
+ */
+ const DACConfig *config;
+#if DAC_USE_WAIT || defined(__DOXYGEN__)
+ /**
+ * @brief Waiting thread.
+ */
+ Thread *thread;
+#endif /* DAC_USE_WAIT */
+#if DAC_USE_MUTUAL_EXCLUSION || defined(__DOXYGEN__)
+#if CH_USE_MUTEXES || defined(__DOXYGEN__)
+ /**
+ * @brief Mutex protecting the bus.
+ */
+ Mutex mutex;
+#elif CH_USE_SEMAPHORES
+ Semaphore semaphore;
+#endif
+#endif /* DAC_USE_MUTUAL_EXCLUSION */
+#if defined(DAC_DRIVER_EXT_FIELDS)
+ DAC_DRIVER_EXT_FIELDS
+#endif
+ /* End of the mandatory fields.*/
+ /**
+ * @brief Half buffer indicator.
+ */
+ bool_t half_buffer;
+};
+
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+extern DACDriver DACD1;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void dac_lld_init(void);
+ void dac_lld_start(DACDriver *dacp);
+ void dac_lld_stop(DACDriver *dacp);
+ void dac_lld_start_conversion(DACDriver *dacp);
+ void dac_lld_stop_conversion(DACDriver *dacp);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HAL_USE_DAC */
+
+#endif /* _DAC_LLD_H_ */
+
+/** @} */
diff --git a/os/hal/platforms/LPC17xx/lpc17xx_dma.h b/os/hal/platforms/LPC17xx/lpc17xx_dma.h
index e581265a5..952c24a17 100644
--- a/os/hal/platforms/LPC17xx/lpc17xx_dma.h
+++ b/os/hal/platforms/LPC17xx/lpc17xx_dma.h
@@ -217,6 +217,13 @@ typedef struct {
volatile uint32_t config; /**< @brief Configuration. */
} lpc17xx_dma_channel_config_t;
+typedef struct {
+ volatile uint32_t srcaddr; /**< @brief Source address. */
+ volatile uint32_t dstaddr; /**< @brief Destination address. */
+ volatile uint32_t lli; /**< @brief Linked List Item. */
+ volatile uint32_t control; /**< @brief Control. */
+} lpc17xx_dma_lli_config_t;
+
/**
* @brief DMA channel number.
*/
@@ -312,7 +319,7 @@ typedef void (*lpc17xx_dmaisr_t)(void *p, uint32_t flags);
* @special
*/
#define dmaChannelLinkedList(dmach, addr) \
- _lpc17xx_dma_channel_config_t[dmach]->CLLI = (((uint32_t)(addr)) << 2)
+ _lpc17xx_dma_channel_config_t[dmach]->CLLI = ((uint32_t)(addr))
/**
* @brief Set control configuration to a DMA channel.
diff --git a/os/hal/platforms/LPC17xx/platform.mk b/os/hal/platforms/LPC17xx/platform.mk
index b3e3f8eed..1cc18db5b 100644
--- a/os/hal/platforms/LPC17xx/platform.mk
+++ b/os/hal/platforms/LPC17xx/platform.mk
@@ -7,7 +7,8 @@ PLATFORMSRC = ${CHIBIOS}/os/hal/platforms/LPC17xx/hal_lld.c \
${CHIBIOS}/os/hal/platforms/LPC17xx/serial_lld.c \
${CHIBIOS}/os/hal/platforms/LPC17xx/rtc_lld.c \
${CHIBIOS}/os/hal/platforms/LPC17xx/i2c_lld.c \
- ${CHIBIOS}/os/hal/platforms/LPC17xx/spi_lld.c
+ ${CHIBIOS}/os/hal/platforms/LPC17xx/spi_lld.c \
+ ${CHIBIOS}/os/hal/platforms/LPC17xx/dac_lld.c
# Required include directories
diff --git a/os/hal/src/hal.c b/os/hal/src/hal.c
index 974a8854b..d7a088ec9 100644
--- a/os/hal/src/hal.c
+++ b/os/hal/src/hal.c
@@ -74,6 +74,9 @@ void halInit(void) {
#if HAL_USE_CAN || defined(__DOXYGEN__)
canInit();
#endif
+#if HAL_USE_DAC || defined(__DOXYGEN__)
+ dacInit();
+#endif
#if HAL_USE_EXT || defined(__DOXYGEN__)
extInit();
#endif
diff --git a/testhal/LPC17xx/DAC/Makefile b/testhal/LPC17xx/DAC/Makefile
new file mode 100644
index 000000000..8a7273417
--- /dev/null
+++ b/testhal/LPC17xx/DAC/Makefile
@@ -0,0 +1,197 @@
+##############################################################################
+# Build global options
+# NOTE: Can be overridden externally.
+#
+
+# Compiler options here.
+ifeq ($(USE_OPT),)
+ USE_OPT = -O2 -ggdb -fomit-frame-pointer
+endif
+
+# C specific options here (added to USE_OPT).
+ifeq ($(USE_COPT),)
+ USE_COPT =
+endif
+
+# C++ specific options here (added to USE_OPT).
+ifeq ($(USE_CPPOPT),)
+ USE_CPPOPT = -fno-rtti
+endif
+
+# Enable this if you want the linker to remove unused code and data
+ifeq ($(USE_LINK_GC),)
+ USE_LINK_GC = yes
+endif
+
+# If enabled, this option allows to compile the application in THUMB mode.
+ifeq ($(USE_THUMB),)
+ USE_THUMB = yes
+endif
+
+# Enable this if you want to see the full log while compiling.
+ifeq ($(USE_VERBOSE_COMPILE),)
+ USE_VERBOSE_COMPILE = no
+endif
+
+#
+# Build global options
+##############################################################################
+
+##############################################################################
+# Architecture or project specific options
+#
+
+#
+# Architecture or project specific options
+##############################################################################
+
+##############################################################################
+# Project, sources and paths
+#
+
+# Define project name here
+PROJECT = ch
+
+# Imported source files and paths
+CHIBIOS = ../../..
+include $(CHIBIOS)/boards/EA_LPCXPRESSO_LPC1769/board.mk
+include $(CHIBIOS)/os/hal/platforms/LPC17xx/platform.mk
+include $(CHIBIOS)/os/hal/hal.mk
+include $(CHIBIOS)/os/ports/GCC/ARMCMx/LPC17xx/port.mk
+include $(CHIBIOS)/os/kernel/kernel.mk
+include $(CHIBIOS)/test/test.mk
+
+# Define linker script file here
+LDSCRIPT= $(PORTLD)/LPC1769.ld
+
+# C sources that can be compiled in ARM or THUMB mode depending on the global
+# setting.
+CSRC = $(PORTSRC) \
+ $(KERNSRC) \
+ $(TESTSRC) \
+ $(HALSRC) \
+ $(PLATFORMSRC) \
+ $(BOARDSRC) \
+ $(CHIBIOS)/os/various/evtimer.c \
+ $(CHIBIOS)/os/various/syscalls.c \
+ main.c
+
+# C++ sources that can be compiled in ARM or THUMB mode depending on the global
+# setting.
+CPPSRC =
+
+# C sources to be compiled in ARM mode regardless of the global setting.
+# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
+# option that results in lower performance and larger code size.
+ACSRC =
+
+# C++ sources to be compiled in ARM mode regardless of the global setting.
+# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
+# option that results in lower performance and larger code size.
+ACPPSRC =
+
+# C sources to be compiled in THUMB mode regardless of the global setting.
+# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
+# option that results in lower performance and larger code size.
+TCSRC =
+
+# C sources to be compiled in THUMB mode regardless of the global setting.
+# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
+# option that results in lower performance and larger code size.
+TCPPSRC =
+
+# List ASM source files here
+ASMSRC = $(PORTASM)
+
+INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \
+ $(HALINC) $(PLATFORMINC) $(BOARDINC) \
+ $(CHIBIOS)/os/various
+
+#
+# Project, sources and paths
+##############################################################################
+
+##############################################################################
+# Compiler settings
+#
+
+MCU = cortex-m3
+
+#TRGT = arm-elf-
+TRGT = arm-none-eabi-
+CC = $(TRGT)gcc
+CPPC = $(TRGT)g++
+# Enable loading with g++ only if you need C++ runtime support.
+# NOTE: You can use C++ even without C++ support if you are careful. C++
+# runtime support makes code size explode.
+LD = $(TRGT)gcc
+#LD = $(TRGT)g++
+CP = $(TRGT)objcopy
+AS = $(TRGT)gcc -x assembler-with-cpp
+OD = $(TRGT)objdump
+HEX = $(CP) -O ihex
+BIN = $(CP) -O binary
+
+# ARM-specific options here
+AOPT =
+
+# THUMB-specific options here
+TOPT = -mthumb -DTHUMB
+
+# Define C warning options here
+CWARN = -Wall -Wextra -Wstrict-prototypes
+
+# Define C++ warning options here
+CPPWARN = -Wall -Wextra
+
+#
+# Compiler settings
+##############################################################################
+
+##############################################################################
+# Start of default section
+#
+
+# List all default C defines here, like -D_DEBUG=1
+DDEFS = -DLPC17XX -D__NEWLIB__
+
+# List all default ASM defines here, like -D_DEBUG=1
+DADEFS =
+
+# List all default directories to look for include files here
+DINCDIR =
+
+# List the default directory to look for the libraries here
+DLIBDIR =
+
+# List all default libraries here
+DLIBS =
+
+#
+# End of default section
+##############################################################################
+
+##############################################################################
+# Start of user section
+#
+
+# List all user C define here, like -D_DEBUG=1
+UDEFS =
+
+# Define ASM defines here
+UADEFS =
+
+# List all user directories here
+UINCDIR =
+
+# List the user directory to look for the libraries here
+ULIBDIR =
+
+# List all user libraries here
+ULIBS =
+
+#
+# End of user defines
+##############################################################################
+
+include $(CHIBIOS)/os/ports/GCC/ARMCMx/rules.mk
diff --git a/testhal/LPC17xx/DAC/chconf.h b/testhal/LPC17xx/DAC/chconf.h
new file mode 100644
index 000000000..f4682cb9d
--- /dev/null
+++ b/testhal/LPC17xx/DAC/chconf.h
@@ -0,0 +1,531 @@
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file templates/chconf.h
+ * @brief Configuration file template.
+ * @details A copy of this file must be placed in each project directory, it
+ * contains the application specific kernel settings.
+ *
+ * @addtogroup config
+ * @details Kernel related settings and hooks.
+ * @{
+ */
+
+#ifndef _CHCONF_H_
+#define _CHCONF_H_
+
+/*===========================================================================*/
+/**
+ * @name Kernel parameters and options
+ * @{
+ */
+/*===========================================================================*/
+
+/**
+ * @brief System tick frequency.
+ * @details Frequency of the system timer that drives the system ticks. This
+ * setting also defines the system tick time unit.
+ */
+#if !defined(CH_FREQUENCY) || defined(__DOXYGEN__)
+#define CH_FREQUENCY 1000
+#endif
+
+/**
+ * @brief Round robin interval.
+ * @details This constant is the number of system ticks allowed for the
+ * threads before preemption occurs. Setting this value to zero
+ * disables the preemption for threads with equal priority and the
+ * round robin becomes cooperative. Note that higher priority
+ * threads can still preempt, the kernel is always preemptive.
+ *
+ * @note Disabling the round robin preemption makes the kernel more compact
+ * and generally faster.
+ */
+#if !defined(CH_TIME_QUANTUM) || defined(__DOXYGEN__)
+#define CH_TIME_QUANTUM 20
+#endif
+
+/**
+ * @brief Managed RAM size.
+ * @details Size of the RAM area to be managed by the OS. If set to zero
+ * then the whole available RAM is used. The core memory is made
+ * available to the heap allocator and/or can be used directly through
+ * the simplified core memory allocator.
+ *
+ * @note In order to let the OS manage the whole RAM the linker script must
+ * provide the @p __heap_base__ and @p __heap_end__ symbols.
+ * @note Requires @p CH_USE_MEMCORE.
+ */
+#if !defined(CH_MEMCORE_SIZE) || defined(__DOXYGEN__)
+#define CH_MEMCORE_SIZE 0
+#endif
+
+/**
+ * @brief Idle thread automatic spawn suppression.
+ * @details When this option is activated the function @p chSysInit()
+ * does not spawn the idle thread automatically. The application has
+ * then the responsibility to do one of the following:
+ * - Spawn a custom idle thread at priority @p IDLEPRIO.
+ * - Change the main() thread priority to @p IDLEPRIO then enter
+ * an endless loop. In this scenario the @p main() thread acts as
+ * the idle thread.
+ * .
+ * @note Unless an idle thread is spawned the @p main() thread must not
+ * enter a sleep state.
+ */
+#if !defined(CH_NO_IDLE_THREAD) || defined(__DOXYGEN__)
+#define CH_NO_IDLE_THREAD FALSE
+#endif
+
+/** @} */
+
+/*===========================================================================*/
+/**
+ * @name Performance options
+ * @{
+ */
+/*===========================================================================*/
+
+/**
+ * @brief OS optimization.
+ * @details If enabled then time efficient rather than space efficient code
+ * is used when two possible implementations exist.
+ *
+ * @note This is not related to the compiler optimization options.
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__)
+#define CH_OPTIMIZE_SPEED TRUE
+#endif
+
+/** @} */
+
+/*===========================================================================*/
+/**
+ * @name Subsystem options
+ * @{
+ */
+/*===========================================================================*/
+
+/**
+ * @brief Threads registry APIs.
+ * @details If enabled then the registry APIs are included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_USE_REGISTRY) || defined(__DOXYGEN__)
+#define CH_USE_REGISTRY TRUE
+#endif
+
+/**
+ * @brief Threads synchronization APIs.
+ * @details If enabled then the @p chThdWait() function is included in
+ * the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_USE_WAITEXIT) || defined(__DOXYGEN__)
+#define CH_USE_WAITEXIT TRUE
+#endif
+
+/**
+ * @brief Semaphores APIs.
+ * @details If enabled then the Semaphores APIs are included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_USE_SEMAPHORES) || defined(__DOXYGEN__)
+#define CH_USE_SEMAPHORES TRUE
+#endif
+
+/**
+ * @brief Semaphores queuing mode.
+ * @details If enabled then the threads are enqueued on semaphores by
+ * priority rather than in FIFO order.
+ *
+ * @note The default is @p FALSE. Enable this if you have special requirements.
+ * @note Requires @p CH_USE_SEMAPHORES.
+ */
+#if !defined(CH_USE_SEMAPHORES_PRIORITY) || defined(__DOXYGEN__)
+#define CH_USE_SEMAPHORES_PRIORITY FALSE
+#endif
+
+/**
+ * @brief Atomic semaphore API.
+ * @details If enabled then the semaphores the @p chSemSignalWait() API
+ * is included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ * @note Requires @p CH_USE_SEMAPHORES.
+ */
+#if !defined(CH_USE_SEMSW) || defined(__DOXYGEN__)
+#define CH_USE_SEMSW TRUE
+#endif
+
+/**
+ * @brief Mutexes APIs.
+ * @details If enabled then the mutexes APIs are included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_USE_MUTEXES) || defined(__DOXYGEN__)
+#define CH_USE_MUTEXES TRUE
+#endif
+
+/**
+ * @brief Conditional Variables APIs.
+ * @details If enabled then the conditional variables APIs are included
+ * in the kernel.
+ *
+ * @note The default is @p TRUE.
+ * @note Requires @p CH_USE_MUTEXES.
+ */
+#if !defined(CH_USE_CONDVARS) || defined(__DOXYGEN__)
+#define CH_USE_CONDVARS TRUE
+#endif
+
+/**
+ * @brief Conditional Variables APIs with timeout.
+ * @details If enabled then the conditional variables APIs with timeout
+ * specification are included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ * @note Requires @p CH_USE_CONDVARS.
+ */
+#if !defined(CH_USE_CONDVARS_TIMEOUT) || defined(__DOXYGEN__)
+#define CH_USE_CONDVARS_TIMEOUT TRUE
+#endif
+
+/**
+ * @brief Events Flags APIs.
+ * @details If enabled then the event flags APIs are included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_USE_EVENTS) || defined(__DOXYGEN__)
+#define CH_USE_EVENTS TRUE
+#endif
+
+/**
+ * @brief Events Flags APIs with timeout.
+ * @details If enabled then the events APIs with timeout specification
+ * are included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ * @note Requires @p CH_USE_EVENTS.
+ */
+#if !defined(CH_USE_EVENTS_TIMEOUT) || defined(__DOXYGEN__)
+#define CH_USE_EVENTS_TIMEOUT TRUE
+#endif
+
+/**
+ * @brief Synchronous Messages APIs.
+ * @details If enabled then the synchronous messages APIs are included
+ * in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_USE_MESSAGES) || defined(__DOXYGEN__)
+#define CH_USE_MESSAGES TRUE
+#endif
+
+/**
+ * @brief Synchronous Messages queuing mode.
+ * @details If enabled then messages are served by priority rather than in
+ * FIFO order.
+ *
+ * @note The default is @p FALSE. Enable this if you have special requirements.
+ * @note Requires @p CH_USE_MESSAGES.
+ */
+#if !defined(CH_USE_MESSAGES_PRIORITY) || defined(__DOXYGEN__)
+#define CH_USE_MESSAGES_PRIORITY FALSE
+#endif
+
+/**
+ * @brief Mailboxes APIs.
+ * @details If enabled then the asynchronous messages (mailboxes) APIs are
+ * included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ * @note Requires @p CH_USE_SEMAPHORES.
+ */
+#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__)
+#define CH_USE_MAILBOXES TRUE
+#endif
+
+/**
+ * @brief I/O Queues APIs.
+ * @details If enabled then the I/O queues APIs are included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_USE_QUEUES) || defined(__DOXYGEN__)
+#define CH_USE_QUEUES TRUE
+#endif
+
+/**
+ * @brief Core Memory Manager APIs.
+ * @details If enabled then the core memory manager APIs are included
+ * in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_USE_MEMCORE) || defined(__DOXYGEN__)
+#define CH_USE_MEMCORE TRUE
+#endif
+
+/**
+ * @brief Heap Allocator APIs.
+ * @details If enabled then the memory heap allocator APIs are included
+ * in the kernel.
+ *
+ * @note The default is @p TRUE.
+ * @note Requires @p CH_USE_MEMCORE and either @p CH_USE_MUTEXES or
+ * @p CH_USE_SEMAPHORES.
+ * @note Mutexes are recommended.
+ */
+#if !defined(CH_USE_HEAP) || defined(__DOXYGEN__)
+#define CH_USE_HEAP TRUE
+#endif
+
+/**
+ * @brief C-runtime allocator.
+ * @details If enabled the the heap allocator APIs just wrap the C-runtime
+ * @p malloc() and @p free() functions.
+ *
+ * @note The default is @p FALSE.
+ * @note Requires @p CH_USE_HEAP.
+ * @note The C-runtime may or may not require @p CH_USE_MEMCORE, see the
+ * appropriate documentation.
+ */
+#if !defined(CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
+#define CH_USE_MALLOC_HEAP FALSE
+#endif
+
+/**
+ * @brief Memory Pools Allocator APIs.
+ * @details If enabled then the memory pools allocator APIs are included
+ * in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_USE_MEMPOOLS) || defined(__DOXYGEN__)
+#define CH_USE_MEMPOOLS TRUE
+#endif
+
+/**
+ * @brief Dynamic Threads APIs.
+ * @details If enabled then the dynamic threads creation APIs are included
+ * in the kernel.
+ *
+ * @note The default is @p TRUE.
+ * @note Requires @p CH_USE_WAITEXIT.
+ * @note Requires @p CH_USE_HEAP and/or @p CH_USE_MEMPOOLS.
+ */
+#if !defined(CH_USE_DYNAMIC) || defined(__DOXYGEN__)
+#define CH_USE_DYNAMIC TRUE
+#endif
+
+/** @} */
+
+/*===========================================================================*/
+/**
+ * @name Debug options
+ * @{
+ */
+/*===========================================================================*/
+
+/**
+ * @brief Debug option, system state check.
+ * @details If enabled the correct call protocol for system APIs is checked
+ * at runtime.
+ *
+ * @note The default is @p FALSE.
+ */
+#if !defined(CH_DBG_SYSTEM_STATE_CHECK) || defined(__DOXYGEN__)
+#define CH_DBG_SYSTEM_STATE_CHECK FALSE
+#endif
+
+/**
+ * @brief Debug option, parameters checks.
+ * @details If enabled then the checks on the API functions input
+ * parameters are activated.
+ *
+ * @note The default is @p FALSE.
+ */
+#if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__)
+#define CH_DBG_ENABLE_CHECKS FALSE
+#endif
+
+/**
+ * @brief Debug option, consistency checks.
+ * @details If enabled then all the assertions in the kernel code are
+ * activated. This includes consistency checks inside the kernel,
+ * runtime anomalies and port-defined checks.
+ *
+ * @note The default is @p FALSE.
+ */
+#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
+#define CH_DBG_ENABLE_ASSERTS FALSE
+#endif
+
+/**
+ * @brief Debug option, trace buffer.
+ * @details If enabled then the context switch circular trace buffer is
+ * activated.
+ *
+ * @note The default is @p FALSE.
+ */
+#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__)
+#define CH_DBG_ENABLE_TRACE FALSE
+#endif
+
+/**
+ * @brief Debug option, stack checks.
+ * @details If enabled then a runtime stack check is performed.
+ *
+ * @note The default is @p FALSE.
+ * @note The stack check is performed in a architecture/port dependent way.
+ * It may not be implemented or some ports.
+ * @note The default failure mode is to halt the system with the global
+ * @p panic_msg variable set to @p NULL.
+ */
+#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
+#define CH_DBG_ENABLE_STACK_CHECK FALSE
+#endif
+
+/**
+ * @brief Debug option, stacks initialization.
+ * @details If enabled then the threads working area is filled with a byte
+ * value when a thread is created. This can be useful for the
+ * runtime measurement of the used stack.
+ *
+ * @note The default is @p FALSE.
+ */
+#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__)
+#define CH_DBG_FILL_THREADS FALSE
+#endif
+
+/**
+ * @brief Debug option, threads profiling.
+ * @details If enabled then a field is added to the @p Thread structure that
+ * counts the system ticks occurred while executing the thread.
+ *
+ * @note The default is @p TRUE.
+ * @note This debug option is defaulted to TRUE because it is required by
+ * some test cases into the test suite.
+ */
+#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__)
+#define CH_DBG_THREADS_PROFILING TRUE
+#endif
+
+/** @} */
+
+/*===========================================================================*/
+/**
+ * @name Kernel hooks
+ * @{
+ */
+/*===========================================================================*/
+
+/**
+ * @brief Threads descriptor structure extension.
+ * @details User fields added to the end of the @p Thread structure.
+ */
+#if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__)
+#define THREAD_EXT_FIELDS \
+ /* Add threads custom fields here.*/
+#endif
+
+/**
+ * @brief Threads initialization hook.
+ * @details User initialization code added to the @p chThdInit() API.
+ *
+ * @note It is invoked from within @p chThdInit() and implicitly from all
+ * the threads creation APIs.
+ */
+#if !defined(THREAD_EXT_INIT_HOOK) || defined(__DOXYGEN__)
+#define THREAD_EXT_INIT_HOOK(tp) { \
+ /* Add threads initialization code here.*/ \
+}
+#endif
+
+/**
+ * @brief Threads finalization hook.
+ * @details User finalization code added to the @p chThdExit() API.
+ *
+ * @note It is inserted into lock zone.
+ * @note It is also invoked when the threads simply return in order to
+ * terminate.
+ */
+#if !defined(THREAD_EXT_EXIT_HOOK) || defined(__DOXYGEN__)
+#define THREAD_EXT_EXIT_HOOK(tp) { \
+ /* Add threads finalization code here.*/ \
+}
+#endif
+
+/**
+ * @brief Context switch hook.
+ * @details This hook is invoked just before switching between threads.
+ */
+#if !defined(THREAD_CONTEXT_SWITCH_HOOK) || defined(__DOXYGEN__)
+#define THREAD_CONTEXT_SWITCH_HOOK(ntp, otp) { \
+ /* System halt code here.*/ \
+}
+#endif
+
+/**
+ * @brief Idle Loop hook.
+ * @details This hook is continuously invoked by the idle thread loop.
+ */
+#if !defined(IDLE_LOOP_HOOK) || defined(__DOXYGEN__)
+#define IDLE_LOOP_HOOK() { \
+ /* Idle loop code here.*/ \
+}
+#endif
+
+/**
+ * @brief System tick event hook.
+ * @details This hook is invoked in the system tick handler immediately
+ * after processing the virtual timers queue.
+ */
+#if !defined(SYSTEM_TICK_EVENT_HOOK) || defined(__DOXYGEN__)
+#define SYSTEM_TICK_EVENT_HOOK() { \
+ /* System tick event code here.*/ \
+}
+#endif
+
+/**
+ * @brief System halt hook.
+ * @details This hook is invoked in case to a system halting error before
+ * the system is halted.
+ */
+#if !defined(SYSTEM_HALT_HOOK) || defined(__DOXYGEN__)
+#define SYSTEM_HALT_HOOK() { \
+ /* System halt code here.*/ \
+}
+#endif
+
+/** @} */
+
+/*===========================================================================*/
+/* Port-specific settings (override port settings defaulted in chcore.h). */
+/*===========================================================================*/
+
+#endif /* _CHCONF_H_ */
+
+/** @} */
diff --git a/testhal/LPC17xx/DAC/halconf.h b/testhal/LPC17xx/DAC/halconf.h
new file mode 100644
index 000000000..6ad145842
--- /dev/null
+++ b/testhal/LPC17xx/DAC/halconf.h
@@ -0,0 +1,346 @@
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file templates/halconf.h
+ * @brief HAL configuration header.
+ * @details HAL configuration file, this file allows to enable or disable the
+ * various device drivers from your application. You may also use
+ * this file in order to override the device drivers default settings.
+ *
+ * @addtogroup HAL_CONF
+ * @{
+ */
+
+#ifndef _HALCONF_H_
+#define _HALCONF_H_
+
+#include "mcuconf.h"
+
+/**
+ * @brief Enables the TM subsystem.
+ */
+#if !defined(HAL_USE_TM) || defined(__DOXYGEN__)
+#define HAL_USE_TM FALSE
+#endif
+
+/**
+ * @brief Enables the PAL subsystem.
+ */
+#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
+#define HAL_USE_PAL TRUE
+#endif
+
+/**
+ * @brief Enables the ADC subsystem.
+ */
+#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
+#define HAL_USE_ADC TRUE
+#endif
+
+/**
+ * @brief Enables the CAN subsystem.
+ */
+#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__)
+#define HAL_USE_CAN FALSE
+#endif
+
+/**
+ * @brief Enables the DAC subsystem.
+ */
+#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
+#define HAL_USE_DAC TRUE
+#endif
+
+/**
+ * @brief Enables the EXT subsystem.
+ */
+#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__)
+#define HAL_USE_EXT FALSE
+#endif
+
+/**
+ * @brief Enables the GPT subsystem.
+ */
+#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
+#define HAL_USE_GPT TRUE
+#endif
+
+/**
+ * @brief Enables the I2C subsystem.
+ */
+#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
+#define HAL_USE_I2C TRUE
+#endif
+
+/**
+ * @brief Enables the ICU subsystem.
+ */
+#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
+#define HAL_USE_ICU FALSE
+#endif
+
+/**
+ * @brief Enables the MAC subsystem.
+ */
+#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__)
+#define HAL_USE_MAC FALSE
+#endif
+
+/**
+ * @brief Enables the MMC_SPI subsystem.
+ */
+#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
+#define HAL_USE_MMC_SPI FALSE
+#endif
+
+/**
+ * @brief Enables the PWM subsystem.
+ */
+#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
+#define HAL_USE_PWM FALSE
+#endif
+
+/**
+ * @brief Enables the RTC subsystem.
+ */
+#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
+#define HAL_USE_RTC TRUE
+#endif
+
+/**
+ * @brief Enables the SDC subsystem.
+ */
+#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
+#define HAL_USE_SDC FALSE
+#endif
+
+/**
+ * @brief Enables the SERIAL subsystem.
+ */
+#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
+#define HAL_USE_SERIAL TRUE
+#endif
+
+/**
+ * @brief Enables the SERIAL over USB subsystem.
+ */
+#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
+#define HAL_USE_SERIAL_USB FALSE
+#endif
+
+/**
+ * @brief Enables the SPI subsystem.
+ */
+#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
+#define HAL_USE_SPI FALSE
+#endif
+
+/**
+ * @brief Enables the UART subsystem.
+ */
+#if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
+#define HAL_USE_UART FALSE
+#endif
+
+/**
+ * @brief Enables the USB subsystem.
+ */
+#if !defined(HAL_USE_USB) || defined(__DOXYGEN__)
+#define HAL_USE_USB FALSE
+#endif
+
+/**
+ * @brief Enables the DAC subsystem.
+ */
+#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
+#define HAL_USE_DAC TRUE
+#endif
+
+/*===========================================================================*/
+/* ADC driver related settings. */
+/*===========================================================================*/
+
+/**
+ * @brief Enables synchronous APIs.
+ * @note Disabling this option saves both code and data space.
+ */
+#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__)
+#define ADC_USE_WAIT TRUE
+#endif
+
+/**
+ * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs.
+ * @note Disabling this option saves both code and data space.
+ */
+#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
+#define ADC_USE_MUTUAL_EXCLUSION TRUE
+#endif
+
+/*===========================================================================*/
+/* CAN driver related settings. */
+/*===========================================================================*/
+
+/**
+ * @brief Sleep mode related APIs inclusion switch.
+ */
+#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
+#define CAN_USE_SLEEP_MODE TRUE
+#endif
+
+/*===========================================================================*/
+/* I2C driver related settings. */
+/*===========================================================================*/
+
+/**
+ * @brief Enables the mutual exclusion APIs on the I2C bus.
+ */
+#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
+#define I2C_USE_MUTUAL_EXCLUSION TRUE
+#endif
+
+/*===========================================================================*/
+/* MAC driver related settings. */
+/*===========================================================================*/
+
+/**
+ * @brief Enables an event sources for incoming packets.
+ */
+#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__)
+#define MAC_USE_ZERO_COPY FALSE
+#endif
+
+/**
+ * @brief Enables an event sources for incoming packets.
+ */
+#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__)
+#define MAC_USE_EVENTS TRUE
+#endif
+
+/*===========================================================================*/
+/* MMC_SPI driver related settings. */
+/*===========================================================================*/
+
+/**
+ * @brief Delays insertions.
+ * @details If enabled this options inserts delays into the MMC waiting
+ * routines releasing some extra CPU time for the threads with
+ * lower priority, this may slow down the driver a bit however.
+ * This option is recommended also if the SPI driver does not
+ * use a DMA channel and heavily loads the CPU.
+ */
+#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__)
+#define MMC_NICE_WAITING TRUE
+#endif
+
+/*===========================================================================*/
+/* SDC driver related settings. */
+/*===========================================================================*/
+
+/**
+ * @brief Number of initialization attempts before rejecting the card.
+ * @note Attempts are performed at 10mS intervals.
+ */
+#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__)
+#define SDC_INIT_RETRY 100
+#endif
+
+/**
+ * @brief Include support for MMC cards.
+ * @note MMC support is not yet implemented so this option must be kept
+ * at @p FALSE.
+ */
+#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__)
+#define SDC_MMC_SUPPORT FALSE
+#endif
+
+/**
+ * @brief Delays insertions.
+ * @details If enabled this options inserts delays into the MMC waiting
+ * routines releasing some extra CPU time for the threads with
+ * lower priority, this may slow down the driver a bit however.
+ */
+#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__)
+#define SDC_NICE_WAITING TRUE
+#endif
+
+/*===========================================================================*/
+/* SERIAL driver related settings. */
+/*===========================================================================*/
+
+/**
+ * @brief Default bit rate.
+ * @details Configuration parameter, this is the baud rate selected for the
+ * default configuration.
+ */
+#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__)
+#define SERIAL_DEFAULT_BITRATE 38400
+#endif
+
+/**
+ * @brief Serial buffers size.
+ * @details Configuration parameter, you can change the depth of the queue
+ * buffers depending on the requirements of your application.
+ * @note The default is 64 bytes for both the transmission and receive
+ * buffers.
+ */
+#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
+#define SERIAL_BUFFERS_SIZE 16
+#endif
+
+/*===========================================================================*/
+/* SPI driver related settings. */
+/*===========================================================================*/
+
+/**
+ * @brief Enables synchronous APIs.
+ * @note Disabling this option saves both code and data space.
+ */
+#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__)
+#define SPI_USE_WAIT TRUE
+#endif
+
+/**
+ * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs.
+ * @note Disabling this option saves both code and data space.
+ */
+#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
+#define SPI_USE_MUTUAL_EXCLUSION TRUE
+#endif
+
+/*===========================================================================*/
+/* DAC driver related settings. */
+/*===========================================================================*/
+
+/**
+ * @brief Enables synchronous APIs.
+ * @note Disabling this option saves both code and data space.
+ */
+#if !defined(DAC_USE_WAIT) || defined(__DOXYGEN__)
+#define DAC_USE_WAIT TRUE
+#endif
+
+/**
+ * @brief Enables the @p dacAcquireBus() and @p dacReleaseBus() APIs.
+ * @note Disabling this option saves both code and data space.
+ */
+#if !defined(DAC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
+#define DAC_USE_MUTUAL_EXCLUSION TRUE
+#endif
+
+#endif /* _HALCONF_H_ */
+
+/** @} */
diff --git a/testhal/LPC17xx/DAC/main.c b/testhal/LPC17xx/DAC/main.c
new file mode 100644
index 000000000..68cf55659
--- /dev/null
+++ b/testhal/LPC17xx/DAC/main.c
@@ -0,0 +1,115 @@
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include "ch.h"
+#include "hal.h"
+
+#define NSAMPLES 255
+
+const uint32_t sine_wave[NSAMPLES] = {
+ 512 << 6, 524 << 6, 537 << 6, 549 << 6, 562 << 6, 574 << 6, 587 << 6, 599 << 6, 612 << 6, 624 << 6,
+ 636 << 6, 649 << 6, 661 << 6, 673 << 6, 685 << 6, 696 << 6, 708 << 6, 720 << 6, 731 << 6, 743 << 6,
+ 754 << 6, 765 << 6, 776 << 6, 786 << 6, 797 << 6, 807 << 6, 818 << 6, 828 << 6, 837 << 6, 847 << 6,
+ 856 << 6, 866 << 6, 875 << 6, 883 << 6, 892 << 6, 900 << 6, 908 << 6, 916 << 6, 924 << 6, 931 << 6,
+ 938 << 6, 945 << 6, 952 << 6, 958 << 6, 964 << 6, 970 << 6, 975 << 6, 981 << 6, 985 << 6, 990 << 6,
+ 994 << 6, 998 << 6, 1002 << 6, 1006 << 6, 1009 << 6, 1012 << 6, 1014 << 6, 1016 << 6, 1018 << 6, 1020 << 6,
+1021 << 6, 1022 << 6, 1023 << 6, 1023 << 6, 1023 << 6, 1023 << 6, 1023 << 6, 1022 << 6, 1021 << 6, 1019 << 6,
+1017 << 6, 1015 << 6, 1013 << 6, 1010 << 6, 1007 << 6, 1004 << 6, 1000 << 6, 996 << 6, 992 << 6, 988 << 6,
+ 983 << 6, 978 << 6, 973 << 6, 967 << 6, 961 << 6, 955 << 6, 948 << 6, 942 << 6, 935 << 6, 928 << 6,
+ 920 << 6, 912 << 6, 904 << 6, 896 << 6, 888 << 6, 879 << 6, 870 << 6, 861 << 6, 852 << 6, 842 << 6,
+ 832 << 6, 823 << 6, 812 << 6, 802 << 6, 792 << 6, 781 << 6, 770 << 6, 759 << 6, 748 << 6, 737 << 6,
+ 725 << 6, 714 << 6, 702 << 6, 691 << 6, 679 << 6, 667 << 6, 655 << 6, 642 << 6, 630 << 6, 618 << 6,
+ 606 << 6, 593 << 6, 581 << 6, 568 << 6, 556 << 6, 543 << 6, 530 << 6, 518 << 6, 505 << 6, 493 << 6,
+ 480 << 6, 467 << 6, 455 << 6, 442 << 6, 430 << 6, 417 << 6, 405 << 6, 393 << 6, 381 << 6, 368 << 6,
+ 356 << 6, 344 << 6, 332 << 6, 321 << 6, 309 << 6, 298 << 6, 286 << 6, 275 << 6, 264 << 6, 253 << 6,
+ 242 << 6, 231 << 6, 221 << 6, 211 << 6, 200 << 6, 191 << 6, 181 << 6, 171 << 6, 162 << 6, 153 << 6,
+ 144 << 6, 135 << 6, 127 << 6, 119 << 6, 111 << 6, 103 << 6, 95 << 6, 88 << 6, 81 << 6, 75 << 6,
+ 68 << 6, 62 << 6, 56 << 6, 50 << 6, 45 << 6, 40 << 6, 35 << 6, 31 << 6, 27 << 6, 23 << 6,
+ 19 << 6, 16 << 6, 13 << 6, 10 << 6, 8 << 6, 6 << 6, 4 << 6, 2 << 6, 1 << 6, 0 << 6,
+ 0 << 6, 0 << 6, 0 << 6, 0 << 6, 1 << 6, 2 << 6, 3 << 6, 5 << 6, 7 << 6, 9 << 6,
+ 11 << 6, 14 << 6, 17 << 6, 21 << 6, 25 << 6, 29 << 6, 33 << 6, 38 << 6, 42 << 6, 48 << 6,
+ 53 << 6, 59 << 6, 65 << 6, 71 << 6, 78 << 6, 85 << 6, 92 << 6, 99 << 6, 107 << 6, 115 << 6,
+ 123 << 6, 131 << 6, 140 << 6, 148 << 6, 157 << 6, 167 << 6, 176 << 6, 186 << 6, 195 << 6, 205 << 6,
+ 216 << 6, 226 << 6, 237 << 6, 247 << 6, 258 << 6, 269 << 6, 280 << 6, 292 << 6, 303 << 6, 315 << 6,
+ 327 << 6, 338 << 6, 350 << 6, 362 << 6, 374 << 6, 387 << 6, 399 << 6, 411 << 6, 424 << 6, 436 << 6,
+ 449 << 6, 461 << 6, 474 << 6, 486 << 6, 499 << 6};
+
+/*
+ * Red LEDs blinker thread, times are in milliseconds.
+ */
+static WORKING_AREA(waThread1, 128);
+static msg_t Thread1(void *arg) {
+
+ (void)arg;
+ chRegSetThreadName("blinker");
+ while (TRUE) {
+ palTogglePad(GPIO0, GPIO0_LED2_RED);
+ chThdSleepMilliseconds(500);
+ }
+}
+
+/*
+ * DAC conversion groups, with callbacks.
+ */
+static const DACConversionGroup dacconvgrp1 = {
+ 1, /* Channels */
+ NULL, /* End of transfer callback */
+ NULL, /* Error callback */
+ true /*circular mode */
+};
+
+/*
+ * DAC config
+ */
+static const DACConfig daccfg1 = {
+ 1000*NSAMPLES, /* Multiply the buffer size to the desired frequency in Hz */
+};
+
+/*
+ * Application entry point.
+ */
+int main(void) {
+ /*
+ * System initializations.
+ * - HAL initialization, this also initializes the configured device drivers
+ * and performs the board-specific initializations.
+ * - Kernel initialization, the main() function becomes a thread and the
+ * RTOS is active.
+ */
+ halInit();
+ chSysInit();
+
+ /*
+ * Creates the blinker thread.
+ */
+ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
+
+ /*
+ * Starting the DAC driver.
+ */
+ dacStart(&DACD1, &daccfg1);
+
+ /*
+ * Sending the dac_buffer
+ */
+ dacStartConversion(&DACD1, &dacconvgrp1, sine_wave, NSAMPLES);
+
+ while (TRUE) {
+
+ chThdSleepMilliseconds(1000);
+
+ }
+}
diff --git a/testhal/LPC17xx/DAC/mcuconf.h b/testhal/LPC17xx/DAC/mcuconf.h
new file mode 100644
index 000000000..756c89823
--- /dev/null
+++ b/testhal/LPC17xx/DAC/mcuconf.h
@@ -0,0 +1,96 @@
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/*
+ * LPC17xx drivers configuration.
+ * The following settings override the default settings present in
+ * the various device driver implementation headers.
+ * Note that the settings for each driver only have effect if the driver
+ * is enabled in halconf.h.
+ *
+ * IRQ priorities:
+ * 7...0 Lowest...highest.
+ */
+
+/*
+ * HAL driver system settings.
+ */
+#define LPC17xx_MAINOSC_ENABLE TRUE
+#define LPC17xx_SYSCLK_SELECT CLKSRCSEL_MAINOSC
+#define LPC17xx_MAINPLL_ENABLE TRUE
+#define LPC17xx_MAINPLL_MUL 30
+#define LPC17xx_MAINPLL_PREDIV 1
+#define LPC17xx_USBPLL_ENABLE FALSE
+#define LPC17xx_USBPLL_MUL 4
+#define LPC17xx_USBPLL_DIV 4
+#define LPC17xx_CCLK_DIV 3
+#define LPC17xx_PCLK_SELECT PCLKSEL_CCLK
+#define LPC17xx_CLKOUT_ENABLE FALSE
+#define LPC17xx_CLKOUT_DIV 4
+#define LPC17xx_CLKOUT_SELECT CLKOUTSEL_CCLK
+
+/*
+ * GPT driver system settings.
+ */
+#define LPC17xx_GPT_USE_TIM0 TRUE
+#define LPC17xx_GPT_USE_TIM1 TRUE
+#define LPC17xx_GPT_USE_TIM2 TRUE
+#define LPC17xx_GPT_USE_TIM3 TRUE
+#define LPC17xx_GPT_TIM0_IRQ_PRIORITY 2
+#define LPC17xx_GPT_TIM1_IRQ_PRIORITY 6
+#define LPC17xx_GPT_TIM2_IRQ_PRIORITY 2
+#define LPC17xx_GPT_TIM3_IRQ_PRIORITY 2
+
+/*
+ * SERIAL driver system settings.
+ */
+#define LPC17xx_SERIAL_USE_UART0 TRUE
+#define LPC17xx_SERIAL_USE_UART1 FALSE
+#define LPC17xx_SERIAL_USE_UART2 FALSE
+#define LPC17xx_SERIAL_USE_UART3 FALSE
+#define LPC17xx_SERIAL_FIFO_PRELOAD 16
+#define LPC17xx_SERIAL_UART0_IRQ_PRIORITY 3
+#define LPC17xx_SERIAL_UART1_IRQ_PRIORITY 3
+#define LPC17xx_SERIAL_UART2_IRQ_PRIORITY 3
+#define LPC17xx_SERIAL_UART3_IRQ_PRIORITY 3
+
+/*
+ * I2C driver system settings.
+ */
+#define LPC17xx_I2C_USE_I2C0 FALSE
+#define LPC17xx_I2C_USE_I2C1 TRUE
+#define LPC17xx_I2C_USE_I2C2 FALSE
+#define LPC17xx_I2C_I2C0_IRQ_PRIORITY 3
+#define LPC17xx_I2C_I2C1_IRQ_PRIORITY 3
+#define LPC17xx_I2C_I2C2_IRQ_PRIORITY 3
+
+/*
+ * SPI driver system settings.
+ */
+#define LPC17xx_SPI_USE_SSP0 FALSE
+#define LPC17xx_SPI_USE_SSP1 FALSE
+#define LPC17xx_SPI_SSP0CLKDIV 1
+#define LPC17xx_SPI_SSP1CLKDIV 1
+#define LPC17xx_SPI_SSP0_IRQ_PRIORITY 5
+#define LPC17xx_SPI_SSP1_IRQ_PRIORITY 5
+
+/*
+ * RTC driver system settings.
+ */
+#define LPC17xx_RTC_IS_CALENDAR TRUE
+#define LPC17xx_RTC_USE_ALARM TRUE
+#define LPC17xx_RTC_IRQ_PRIORITY 3
+