summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-01-13 11:10:35 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-01-13 11:10:35 -0600
commitca5d1c373f04fd70444ea6bf96123b6cbf40c234 (patch)
tree314ce01be8e912aac1b76908640e0326d8085708
parent6e90f62f5be07d7464336da2e79ca3d18dda04fa (diff)
downloadnuttx-ca5d1c373f04fd70444ea6bf96123b6cbf40c234.tar.gz
nuttx-ca5d1c373f04fd70444ea6bf96123b6cbf40c234.tar.bz2
nuttx-ca5d1c373f04fd70444ea6bf96123b6cbf40c234.zip
DK-TM3C129X Timer: Add timer initialization logic to the board bring-up
-rw-r--r--nuttx/arch/arm/src/tiva/tiva_timer.h2
-rw-r--r--nuttx/configs/dk-tm4c129x/Kconfig73
-rw-r--r--nuttx/configs/dk-tm4c129x/src/Makefile4
-rw-r--r--nuttx/configs/dk-tm4c129x/src/dk-tm4c129x.h12
-rw-r--r--nuttx/configs/dk-tm4c129x/src/tm4c_bringup.c22
-rw-r--r--nuttx/configs/dk-tm4c129x/src/tm4c_nsh.c1
-rw-r--r--nuttx/configs/dk-tm4c129x/src/tm4c_timer.c122
7 files changed, 232 insertions, 4 deletions
diff --git a/nuttx/arch/arm/src/tiva/tiva_timer.h b/nuttx/arch/arm/src/tiva/tiva_timer.h
index 2b16dfb2a..d1261e9e1 100644
--- a/nuttx/arch/arm/src/tiva/tiva_timer.h
+++ b/nuttx/arch/arm/src/tiva/tiva_timer.h
@@ -892,7 +892,7 @@ static inline void tiva_gptm0_synchronize(uint32_t sync)
* devpath - The full path to the timer device. This should be of the form
* /dev/timer0
* gptm - General purpose timer number
- * timeout - Timeout interval in milliseconds. Set to a non-zero value
+ * timeout - Timeout interval in microseconds. Set to a non-zero value
* to enable timeout interrupts
* altlck - True: Use alternate clock source.
*
diff --git a/nuttx/configs/dk-tm4c129x/Kconfig b/nuttx/configs/dk-tm4c129x/Kconfig
index d1a89968a..1c2cd6be7 100644
--- a/nuttx/configs/dk-tm4c129x/Kconfig
+++ b/nuttx/configs/dk-tm4c129x/Kconfig
@@ -4,5 +4,76 @@
#
if ARCH_BOARD_DK_TM4C129X
+if TIMER && TIVA_TIMER32_PERIODIC
-endif
+config DK_TM4C129X_TIMER
+ bool
+ default n
+
+choice
+ prompt "Timer driver selection"
+ default DK_TM4C129X_TIMER_NONE
+
+config DK_TM4C129X_TIMER_NONE
+ bool "None"
+
+config DK_TM4C129X_TIMER0
+ bool "Timer 0"
+ depends on TIVA_TIMER0
+ select DK_TM4C129X_TIMER
+
+config DK_TM4C129X_TIMER1
+ bool "Timer 1"
+ depends on TIVA_TIMER1
+ select DK_TM4C129X_TIMER
+
+config DK_TM4C129X_TIMER2
+ bool "Timer 2"
+ depends on TIVA_TIMER2
+ select DK_TM4C129X_TIMER
+
+config DK_TM4C129X_TIMER3
+ bool "Timer 3"
+ depends on TIVA_TIMER3
+ select DK_TM4C129X_TIMER
+
+config DK_TM4C129X_TIMER4
+ bool "Timer 4"
+ depends on TIVA_TIMER4
+ select DK_TM4C129X_TIMER
+
+config DK_TM4C129X_TIMER5
+ bool "Timer 5"
+ depends on TIVA_TIMER5
+ select DK_TM4C129X_TIMER
+
+config DK_TM4C129X_TIMER6
+ bool "Timer 6"
+ depends on TIVA_TIMER6
+ select DK_TM4C129X_TIMER
+
+config DK_TM4C129X_TIMER7
+ bool "Timer 7"
+ depends on TIVA_TIMER7
+ select DK_TM4C129X_TIMER
+
+endchoice # Timer driver selection
+
+if DK_TM4C129X_TIMER
+
+config DK_TM4C129X_TIMER_DEVNAME
+ string "Timer device name"
+ default "/dev/timer0"
+
+config DK_TM4C129X_TIMER_TIMEOUT
+ int "Timer interval (microseconds)"
+ default 10000
+
+config DK_TM4C129X_TIMER_ALTCLK
+ bool "Use alternate clock source"
+ default n
+ depends on EXPERIMENTAL
+
+endif # DK_TM4C129X_TIMER
+endif # TIVA_TIMER32_PERIODIC
+endif # ARCH_BOARD_DK_TM4C129X
diff --git a/nuttx/configs/dk-tm4c129x/src/Makefile b/nuttx/configs/dk-tm4c129x/src/Makefile
index 7b6eaf480..5ce6c83d2 100644
--- a/nuttx/configs/dk-tm4c129x/src/Makefile
+++ b/nuttx/configs/dk-tm4c129x/src/Makefile
@@ -55,6 +55,10 @@ ifeq ($(CONFIG_TIVA_ETHERNET),y)
CSRCS += tm4c_ethernet.c
endif
+ifeq ($(CONFIG_DK_TM4C129X_TIMER),y)
+CSRCS += tm4c_timer.c
+endif
+
ifeq ($(CONFIG_NSH_ARCHINIT),y)
CSRCS += tm4c_nsh.c
endif
diff --git a/nuttx/configs/dk-tm4c129x/src/dk-tm4c129x.h b/nuttx/configs/dk-tm4c129x/src/dk-tm4c129x.h
index b51e70418..717bea0cb 100644
--- a/nuttx/configs/dk-tm4c129x/src/dk-tm4c129x.h
+++ b/nuttx/configs/dk-tm4c129x/src/dk-tm4c129x.h
@@ -169,6 +169,18 @@ void tm4c_ledinit(void);
int tm4c_bringup(void);
+/****************************************************************************
+ * Name: tiva_timer_initialize
+ *
+ * Description:
+ * Configure the timer driver
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_DK_TM4C129X_TIMER
+int tiva_timer_initialize(void);
+#endif
+
#endif /* __ASSEMBLY__ */
#endif /* __CONFIGS_DK_TM4C129X_DK_TM4C129X_H */
diff --git a/nuttx/configs/dk-tm4c129x/src/tm4c_bringup.c b/nuttx/configs/dk-tm4c129x/src/tm4c_bringup.c
index b2b2d457e..f5b5f3a7c 100644
--- a/nuttx/configs/dk-tm4c129x/src/tm4c_bringup.c
+++ b/nuttx/configs/dk-tm4c129x/src/tm4c_bringup.c
@@ -49,6 +49,14 @@
* Pre-Processor Definitions
****************************************************************************/
+#if defined(CONFIG_I2C) && defined(CONFIG_I2C_LM75) && defined(CONFIG_TIVA_I2C6)
+# define HAVE_TMP100
+#endif
+
+#ifdef CONFIG_DK_TM4C129X_TIMER
+# define HAVE_TIMER
+#endif
+
#ifdef CONFIG_SYSTEM_LM75_DEVNAME
# define TMP100_DEVNAME CONFIG_SYSTEM_LM75_DEVNAME
#else
@@ -69,9 +77,11 @@
int tm4c_bringup(void)
{
-#if defined(CONFIG_I2C) && defined(CONFIG_I2C_LM75) && defined(CONFIG_TIVA_I2C6)
+#if defined(HAVE_TMP100) || defined(HAVE_TIMER)
int ret;
+#endif
+#ifdef HAVE_TMP100
/* Initialize and register the TMP-100 Temperature Sensor driver. */
ret = tiva_tmp100_initialize(TMP100_DEVNAME);
@@ -81,5 +91,15 @@ int tm4c_bringup(void)
}
#endif
+#ifdef HAVE_TIMER
+ /* Initialize the timer driver */
+
+ ret = tiva_timer_initialize();
+ if (ret < 0)
+ {
+ dbg("ERROR: Failed to initialize timer driver: %d\n", ret);
+ }
+#endif
+
return OK;
}
diff --git a/nuttx/configs/dk-tm4c129x/src/tm4c_nsh.c b/nuttx/configs/dk-tm4c129x/src/tm4c_nsh.c
index ddbc12626..c78cf57e4 100644
--- a/nuttx/configs/dk-tm4c129x/src/tm4c_nsh.c
+++ b/nuttx/configs/dk-tm4c129x/src/tm4c_nsh.c
@@ -45,7 +45,6 @@
* Pre-Processor Definitions
****************************************************************************/
-
/****************************************************************************
* Public Functions
****************************************************************************/
diff --git a/nuttx/configs/dk-tm4c129x/src/tm4c_timer.c b/nuttx/configs/dk-tm4c129x/src/tm4c_timer.c
new file mode 100644
index 000000000..c9a5d51c8
--- /dev/null
+++ b/nuttx/configs/dk-tm4c129x/src/tm4c_timer.c
@@ -0,0 +1,122 @@
+/****************************************************************************
+ * config/dk-tm4c129x/src/tm4c_timer.c
+ *
+ * Copyright (C) 2015 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <debug.h>
+
+#include "tiva_timer.h"
+#include "dk-tm4c129x.h"
+
+#ifdef CONFIG_DK_TM4C129X_TIMER
+
+/****************************************************************************
+ * Pre-Processor Definitions
+ ****************************************************************************/
+/* Configuration ************************************************************/
+
+#ifndef CONFIG_TIMER
+# error CONFIG_TIMER is not defined
+#endif
+
+#ifndef CONFIG_TIVA_TIMER32_PERIODIC
+# error CONFIG_TIVA_TIMER32_PERIODIC is not defined
+#endif
+
+#if defined(CONFIG_DK_TM4C129X_TIMER0)
+# define GPTM 0
+#elif defined(CONFIG_DK_TM4C129X_TIMER1)
+# define GPTM 1
+#elif defined(CONFIG_DK_TM4C129X_TIMER2)
+# define GPTM 2
+#elif defined(CONFIG_DK_TM4C129X_TIMER3)
+# define GPTM 3
+#elif defined(CONFIG_DK_TM4C129X_TIMER4)
+# define GPTM 4
+#elif defined(CONFIG_DK_TM4C129X_TIMER5)
+# define GPTM 5
+#elif defined(CONFIG_DK_TM4C129X_TIMER6)
+# define GPTM 6
+#elif defined(CONFIG_DK_TM4C129X_TIMER7)
+# define GPTM 7
+#else
+# error No CONFIG_DK_TM4C129X_TIMERn definition
+#endif
+
+#ifndef CONFIG_DK_TM4C129X_TIMER_DEVNAME
+# define CONFIG_DK_TM4C129X_TIMER_DEVNAME "/dev/timer0"
+#endif
+
+#ifndef CONFIG_DK_TM4C129X_TIMER_TIMEOUT
+# define CONFIG_DK_TM4C129X_TIMER_TIMEOUT 10000
+#endif
+
+#undef CONFIG_DK_TM4C129X_TIMER_ALTCLK
+#define ALTCLK false
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: tiva_timer_initialize
+ *
+ * Description:
+ * Configure the timer driver
+ *
+ ****************************************************************************/
+
+int tiva_timer_initialize(void)
+{
+ int ret;
+
+ timvdbg("Registering TIMER%d at %s\n", GPTM, CONFIG_DK_TM4C129X_TIMER_DEVNAME);
+ timvdbg("Initial timer period: %d uS\n", CONFIG_DK_TM4C129X_TIMER_TIMEOUT);
+
+ ret = tiva_timer_register(CONFIG_DK_TM4C129X_TIMER_DEVNAME, GPTM,
+ CONFIG_DK_TM4C129X_TIMER_TIMEOUT, ALTCLK);
+ if (ret < 0)
+ {
+ timdbg("ERROR: Failed to register timer driver: %d\n", ret);
+ }
+
+ return ret;
+}
+
+#endif /* CONFIG_DK_TM4C129X_TIMER */ \ No newline at end of file