samples: tmp112: various cleanups
Add a real README, convert the device getter to DEVICE_DT_GET_ANY, and enable assertions to make debugging easier on new users. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
parent
2c793f72ae
commit
aacab5e866
4 changed files with 29 additions and 7 deletions
26
samples/sensor/tmp112/README.rst
Normal file
26
samples/sensor/tmp112/README.rst
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
.. _tmp112_sample:
|
||||||
|
|
||||||
|
TMP112 sample
|
||||||
|
#############
|
||||||
|
|
||||||
|
Overview
|
||||||
|
********
|
||||||
|
|
||||||
|
A sample showing how to use the :dtcompatible:`ti,tmp112` sensor.
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
************
|
||||||
|
|
||||||
|
A board with this sensor built in to its :ref:`devicetree <dt-guide>`, or a
|
||||||
|
devicetree overlay with such a node added.
|
||||||
|
|
||||||
|
Building and Running
|
||||||
|
********************
|
||||||
|
|
||||||
|
To build and flash the sample for the :ref:`frdm_k64f`:
|
||||||
|
|
||||||
|
.. zephyr-app-commands::
|
||||||
|
:zephyr-app: samples/sensor/tmp112
|
||||||
|
:board: frdm_k64f
|
||||||
|
:goals: build flash
|
||||||
|
:compact:
|
|
@ -1,5 +0,0 @@
|
||||||
Title: tmp112
|
|
||||||
|
|
||||||
Description:
|
|
||||||
|
|
||||||
A simple example using the tmp112 temperature sensor.
|
|
|
@ -2,3 +2,4 @@ CONFIG_STDOUT_CONSOLE=y
|
||||||
CONFIG_I2C=y
|
CONFIG_I2C=y
|
||||||
CONFIG_SENSOR=y
|
CONFIG_SENSOR=y
|
||||||
CONFIG_TMP112=y
|
CONFIG_TMP112=y
|
||||||
|
CONFIG_ASSERT=y
|
||||||
|
|
|
@ -56,10 +56,10 @@ static void do_main(const struct device *dev)
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
const struct device *dev;
|
const struct device *dev = DEVICE_DT_GET_ANY(ti_tmp112);
|
||||||
|
|
||||||
dev = device_get_binding("TMP112");
|
|
||||||
__ASSERT(dev != NULL, "Failed to get device binding");
|
__ASSERT(dev != NULL, "Failed to get device binding");
|
||||||
|
__ASSERT(device_is_ready(dev), "Device %s is not ready", dev->name);
|
||||||
printk("device is %p, name is %s\n", dev, dev->name);
|
printk("device is %p, name is %s\n", dev, dev->name);
|
||||||
|
|
||||||
do_main(dev);
|
do_main(dev);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue