DK-TM4C129X: Add logic to initialize the TMP-100 temperature sensor driver at startup
This commit is contained in:
parent
383a47fb28
commit
beaf4afdd4
@ -652,6 +652,8 @@ f Application Configuration -> Network Utilities
|
|||||||
Temperature Sensor
|
Temperature Sensor
|
||||||
==================
|
==================
|
||||||
|
|
||||||
|
TMP-1000 Temperature Sensor Driver
|
||||||
|
----------------------------------
|
||||||
Support for the on-board TMP-100 temperature sensor is available. This
|
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
|
uses the driver for the compatible LM-75 part. To set up the temperature
|
||||||
sensor, add the following to the NuttX configuration file:
|
sensor, add the following to the NuttX configuration file:
|
||||||
@ -663,8 +665,12 @@ Temperature Sensor
|
|||||||
CONFIG_I2C=y
|
CONFIG_I2C=y
|
||||||
|
|
||||||
Drivers -> Sensors
|
Drivers -> Sensors
|
||||||
|
CONFIG_LM75=y
|
||||||
CONFIG_I2C_LM75=y
|
CONFIG_I2C_LM75=y
|
||||||
|
|
||||||
|
Applications -> NSH Library
|
||||||
|
CONFIG_NSH_ARCHINIT=y
|
||||||
|
|
||||||
Then you can implement logic like the following to use the temperature sensor:
|
Then you can implement logic like the following to use the temperature sensor:
|
||||||
|
|
||||||
#include <nuttx/sensors/lm75.h>
|
#include <nuttx/sensors/lm75.h>
|
||||||
@ -673,13 +679,35 @@ Temperature Sensor
|
|||||||
ret = tiva_tmp100_initialize("/dev/temp"); /* Register the temperature sensor */
|
ret = tiva_tmp100_initialize("/dev/temp"); /* Register the temperature sensor */
|
||||||
fd = open("/dev/temp", O_RDONLY); /* Open the temperature sensor device */
|
fd = open("/dev/temp", O_RDONLY); /* Open the temperature sensor device */
|
||||||
ret = ioctl(fd, SNIOC_FAHRENHEIT, 0); /* Select Fahrenheit */
|
ret = ioctl(fd, SNIOC_FAHRENHEIT, 0); /* Select Fahrenheit */
|
||||||
bytesread = read(fd, buffer, 8*sizeof(b16_t)); /* Read temperature samples */
|
bytesread = read(fd, buffer, 8*sizeof(b16_t)); /* Read (8) temperature samples */
|
||||||
|
|
||||||
More complex temperature sensor operations are also available. See the IOCTL
|
More complex temperature sensor operations are also available. See the IOCTL
|
||||||
commands enumerated in include/nuttx/sensors/lm75.h. Also read the descriptions
|
commands enumerated in include/nuttx/sensors/lm75.h. Also read the descriptions
|
||||||
of the tiva_tmp100_initialize() and tiva_tmp100_attach() interfaces in the
|
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).
|
arch/board/board.h file (sames as configs/dk-tm4c129x/include/board.h).
|
||||||
|
|
||||||
|
NSH Command Line Application
|
||||||
|
----------------------------
|
||||||
|
There is a tiny NSH command line application at examples/system/lm75 that
|
||||||
|
will read the current temperature from an LM75 compatible temperature sensor
|
||||||
|
and print the temperature on stdout in either units of degrees Fahrenheit or
|
||||||
|
Centigrade. This tiny command line application is enabled with the following
|
||||||
|
configuratin options:
|
||||||
|
|
||||||
|
Library
|
||||||
|
CONFIG_LIBM=y
|
||||||
|
CONFIG_LIBC_FLOATINGPOINT=y
|
||||||
|
|
||||||
|
Applications -> NSH Library
|
||||||
|
CONFIG_NSH_ARCHINIT=y
|
||||||
|
|
||||||
|
Applications -> System Add-Ons
|
||||||
|
CONFIG_SYSTEM_LM75=y
|
||||||
|
CONFIG_SYSTEM_LM75_DEVNAME="/dev/temp"
|
||||||
|
CONFIG_SYSTEM_LM75_FAHRENHEIT=y (or CENTIGRADE)
|
||||||
|
CONFIG_SYSTEM_LM75_STACKSIZE=1024
|
||||||
|
CONFIG_SYSTEM_LM75_PRIORITY=100
|
||||||
|
|
||||||
DK-TM4129X Configuration Options
|
DK-TM4129X Configuration Options
|
||||||
================================
|
================================
|
||||||
|
|
||||||
@ -868,3 +896,16 @@ Where <subdir> is one of the following:
|
|||||||
network back up when the link becomes available again (for example,
|
network back up when the link becomes available again (for example,
|
||||||
if the cable is reconnected. The paragraph "Network Monitor" above
|
if the cable is reconnected. The paragraph "Network Monitor" above
|
||||||
for additional information.
|
for additional information.
|
||||||
|
|
||||||
|
5. I2C6 and support for the on-board TMP-100 temperature sensor are
|
||||||
|
enabled. Also enabled is the NSH 'temp' command that will show the
|
||||||
|
current temperature on the command line like:
|
||||||
|
|
||||||
|
nsh> temp
|
||||||
|
80.60 degrees Fahrenheit
|
||||||
|
|
||||||
|
[80.6 F in January. I love living in Costa Rica1]
|
||||||
|
|
||||||
|
The default units is degrees Fahrenheit, but that is easily
|
||||||
|
reconfigured. See the discussin above in the paragraph entitled
|
||||||
|
"Temperature Sensor".
|
||||||
|
@ -273,7 +273,7 @@ void tiva_setleds(uint8_t ledset);
|
|||||||
*
|
*
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_I2C) && defined(CONFIG_I2C_LM75) && defined(CONFIG_STM32_I2C1)
|
#if defined(CONFIG_I2C) && defined(CONFIG_I2C_LM75) && defined(CONFIG_TIVA_I2C6)
|
||||||
int tiva_tmp100_initialize(FAR const char *devpath);
|
int tiva_tmp100_initialize(FAR const char *devpath);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -60,8 +60,10 @@ CSRCS += tm4c_nsh.c
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_I2C_LM75),y)
|
ifeq ($(CONFIG_I2C_LM75),y)
|
||||||
|
ifeq ($(CONFIG_TIVA_I2C6),y)
|
||||||
CSRCS += tm4c_tmp100.c
|
CSRCS += tm4c_tmp100.c
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||||
|
|
||||||
|
@ -39,7 +39,9 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <syslog.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "dk-tm4c129x.h"
|
#include "dk-tm4c129x.h"
|
||||||
|
|
||||||
@ -47,6 +49,11 @@
|
|||||||
* Pre-Processor Definitions
|
* Pre-Processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_SYSTEM_LM75_DEVNAME
|
||||||
|
# define TMP100_DEVNAME CONFIG_SYSTEM_LM75_DEVNAME
|
||||||
|
#else
|
||||||
|
# define TMP100_DEVNAME "/dev/temp"
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
@ -62,5 +69,17 @@
|
|||||||
|
|
||||||
int tm4c_bringup(void)
|
int tm4c_bringup(void)
|
||||||
{
|
{
|
||||||
|
#if defined(CONFIG_I2C) && defined(CONFIG_I2C_LM75) && defined(CONFIG_TIVA_I2C6)
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* Initialize and register the TMP-100 Temperature Sensor driver. */
|
||||||
|
|
||||||
|
ret = tiva_tmp100_initialize(TMP100_DEVNAME);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
dbg("ERROR: Failed to initialize TMP100 driver: %d\n", ret);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user