summaryrefslogtreecommitdiff
path: root/nuttx/configs/dk-tm4c129x
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/configs/dk-tm4c129x')
-rw-r--r--nuttx/configs/dk-tm4c129x/README.txt32
-rw-r--r--nuttx/configs/dk-tm4c129x/include/board.h30
-rw-r--r--nuttx/configs/dk-tm4c129x/src/Makefile4
-rw-r--r--nuttx/configs/dk-tm4c129x/src/dk-tm4c129x.h1
-rw-r--r--nuttx/configs/dk-tm4c129x/src/tm4c_tmp100.c103
5 files changed, 164 insertions, 6 deletions
diff --git a/nuttx/configs/dk-tm4c129x/README.txt b/nuttx/configs/dk-tm4c129x/README.txt
index 49f356340..720a522bf 100644
--- a/nuttx/configs/dk-tm4c129x/README.txt
+++ b/nuttx/configs/dk-tm4c129x/README.txt
@@ -36,6 +36,7 @@ Contents
- Buttons and LEDs
- Serial Console
- Networking Support
+ - Temperature Sensor
- DK-TM4129X Configuration Options
- Configurations
@@ -648,6 +649,37 @@ f Application Configuration -> Network Utilities
CONFIG_NSH_NETINIT_RETRYMSEC=2000 : Configure the network monitor as you like
CONFIG_NSH_NETINIT_SIGNO=18
+Temperature Sensor
+==================
+
+ Support for the on-board TMP-100 temperature sensor is available. This
+ uses the driver for the compatible LM-75 part. To set up the temperature
+ sensor, add the following to the NuttX configuration file:
+
+ System Type -> Tiva/Stellaris Peripheral Selection
+ CONFIG_TIVA_I2C6=y
+
+ Drivers -> I2C Support
+ CONFIG_I2C=y
+
+ Drivers -> Sensors
+ CONFIG_I2C_LM75=y
+
+ Then you can implement logic like the following to use the temperature sensor:
+
+ #include <nuttx/sensors/lm75.h>
+ #include <arch/board/board.h>
+
+ ret = tiva_tmp100_initialize("/dev/temp"); /* Register the temperature sensor */
+ fd = open("/dev/temp", O_RDONLY); /* Open the temperature sensor device */
+ ret = ioctl(fd, SNIOC_FAHRENHEIT, 0); /* Select Fahrenheit */
+ bytesread = read(fd, buffer, 8*sizeof(b16_t)); /* Read temperature samples */
+
+ More complex temperature sensor operations are also available. See the IOCTL
+ commands enumerated in include/nuttx/sensors/lm75.h. Also read the descriptions
+ of the tiva_tmp100_initialize() and tiva_tmp100_attach() interfaces in the
+ arch/board/board.h file (sames as configs/dk-tm4c129x/include/board.h).
+
DK-TM4129X Configuration Options
================================
diff --git a/nuttx/configs/dk-tm4c129x/include/board.h b/nuttx/configs/dk-tm4c129x/include/board.h
index 7df3b08eb..aacdda3b2 100644
--- a/nuttx/configs/dk-tm4c129x/include/board.h
+++ b/nuttx/configs/dk-tm4c129x/include/board.h
@@ -108,14 +108,14 @@
* --- ------------ -----------------
*/
-/* LED index values for use with tm4c_setled() */
+/* LED index values for use with tiva_setled() */
#define BOARD_LED_R 0
#define BOARD_LED_G 1
#define BOARD_LED_B 2
#define BOARD_NLEDS 3
-/* LED bits for use with tm4c_setleds() */
+/* LED bits for use with tiva_setleds() */
#define BOARD_LED_R_BIT (1 << BOARD_LED_R)
#define BOARD_LED_G_BIT (1 << BOARD_LED_G)
@@ -244,7 +244,7 @@
void tiva_boardinitialize(void);
/************************************************************************************
- * Name: tm4c_ledinit, tm4c_setled, and tm4c_setleds
+ * Name: tiva_ledinit, tiva_setled, and tiva_setleds
*
* Description:
* If CONFIG_ARCH_LEDS is defined, then NuttX will control the on-board LED. If
@@ -254,9 +254,27 @@ void tiva_boardinitialize(void);
************************************************************************************/
#ifndef CONFIG_ARCH_LEDS
-void tm4c_ledinit(void);
-void tm4c_setled(int led, bool ledon);
-void tm4c_setleds(uint8_t ledset);
+void tiva_ledinit(void);
+void tiva_setled(int led, bool ledon);
+void tiva_setleds(uint8_t ledset);
+#endif
+
+/************************************************************************************
+ * Name: tiva_tmp100_initialize
+ *
+ * Description:
+ * Initialize and register the TMP-100 Temperature Sensor driver.
+ *
+ * Input parameters:
+ * devpath - The full path to the driver to register. E.g., "/dev/temp0"
+ *
+ * Returned Value:
+ * Zero (OK) on success; a negated errno value on failure.
+ *
+ ************************************************************************************/
+
+#if defined(CONFIG_I2C) && defined(CONFIG_I2C_LM75) && defined(CONFIG_STM32_I2C1)
+int tiva_tmp100_initialize(FAR const char *devpath);
#endif
#endif /* __ASSEMBLY__ */
diff --git a/nuttx/configs/dk-tm4c129x/src/Makefile b/nuttx/configs/dk-tm4c129x/src/Makefile
index 99739fa76..3f624142b 100644
--- a/nuttx/configs/dk-tm4c129x/src/Makefile
+++ b/nuttx/configs/dk-tm4c129x/src/Makefile
@@ -59,6 +59,10 @@ ifeq ($(CONFIG_NSH_ARCHINIT),y)
CSRCS += tm4c_nsh.c
endif
+ifeq ($(CONFIG_I2C_LM75),y)
+CSRCS += tm4c_tmp100.c
+endif
+
COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)
diff --git a/nuttx/configs/dk-tm4c129x/src/dk-tm4c129x.h b/nuttx/configs/dk-tm4c129x/src/dk-tm4c129x.h
index 6935752e3..b51e70418 100644
--- a/nuttx/configs/dk-tm4c129x/src/dk-tm4c129x.h
+++ b/nuttx/configs/dk-tm4c129x/src/dk-tm4c129x.h
@@ -122,6 +122,7 @@
* I2C address is 0x4A
*/
+#define TMP100_I2CBUS 6
#define TMP100_I2CADDR 0x4a
/* Speaker outputs *****************************************************************/
diff --git a/nuttx/configs/dk-tm4c129x/src/tm4c_tmp100.c b/nuttx/configs/dk-tm4c129x/src/tm4c_tmp100.c
new file mode 100644
index 000000000..1b179610c
--- /dev/null
+++ b/nuttx/configs/dk-tm4c129x/src/tm4c_tmp100.c
@@ -0,0 +1,103 @@
+/****************************************************************************
+ * configs/dk-tm4c129x/src/tiva_tmp100.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 <errno.h>
+
+#include <nuttx/i2c.h>
+#include <nuttx/sensors/lm75.h>
+
+#include "tiva_i2c.h"
+#include "dk-tm4c129x.h"
+
+#if defined(CONFIG_I2C) && defined(CONFIG_I2C_LM75) && \
+ defined(CONFIG_TIVA_I2C6)
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: tiva_tmp100_initialize
+ *
+ * Description:
+ * Initialize and register the LM-75 Temperature Sensor driver.
+ *
+ * Input parameters:
+ * devpath - The full path to the driver to register. E.g., "/dev/temp0"
+ *
+ * Returned Value:
+ * Zero (OK) on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+int tiva_tmp100_initialize(FAR const char *devpath)
+{
+ FAR struct i2c_dev_s *i2c;
+ int ret;
+
+ /* Get an instance of the I2C6 interface */
+
+ i2c = up_i2cinitialize(TMP100_I2CBUS);
+ if (!i2c)
+ {
+ return -ENODEV;
+ }
+
+ /* Then register the temperature sensor */
+
+ ret = lm75_register(devpath, i2c, TMP100_I2CADDR);
+ if (ret < 0)
+ {
+ (void)up_i2cuninitialize(i2c);
+ }
+
+ return ret;
+}
+
+#endif /* CONFIG_I2C && CONFIG_I2C_LM75 && CONFIG_TIVA_I2C6 */