Contiki-NG
sensor-common.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014, Texas Instruments Incorporated - http://www.ti.com/
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the copyright holder nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28 * OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30/*---------------------------------------------------------------------------*/
31/**
32 * \addtogroup sensortag-cc26xx-peripherals
33 * @{
34 *
35 * \defgroup sensortag-cc26xx-sensor-common SensorTag 2.0 Sensors
36 * @{
37 *
38 * \file
39 * Header file for the Sensortag Common sensor utilities
40 */
41/*---------------------------------------------------------------------------*/
42#ifndef SENSOR_H
43#define SENSOR_H
44/*---------------------------------------------------------------------------*/
45#include "board-i2c.h"
46
47#include <stdbool.h>
48#include <stdint.h>
49/*---------------------------------------------------------------------------*/
50/**
51 * \brief Reads a sensor's register over I2C
52 * \param addr The address of the register to read
53 * \param buf Pointer to buffer to place data
54 * \param len Number of bytes to read
55 * \return TRUE if the required number of bytes are received
56 *
57 * The sensor must be selected before this routine is called.
58 */
59bool sensor_common_read_reg(uint8_t addr, uint8_t *buf, uint8_t len);
60
61/**
62 * \brief Write to a sensor's register over I2C
63 * \param addr The address of the register to read
64 * \param buf Pointer to buffer containing data to be written
65 * \param len Number of bytes to write
66 * \return TRUE if successful write
67 *
68 * The sensor must be selected before this routine is called.
69 */
70bool sensor_common_write_reg(uint8_t addr, uint8_t *buf, uint8_t len);
71
72/**
73 * \brief Fill a result buffer with dummy error data
74 * \param buf Pointer to the buffer where to write the data
75 * \param len Number of bytes to fill
76 */
77void sensor_common_set_error_data(uint8_t *buf, uint8_t len);
78/*---------------------------------------------------------------------------*/
79#endif /* SENSOR_H */
80/*---------------------------------------------------------------------------*/
81/**
82 * @}
83 * @}
84 */
Header file for the Sensortag I2C Driver.
void sensor_common_set_error_data(uint8_t *buf, uint8_t len)
Fill a result buffer with dummy error data.
Definition: sensor-common.c:71
bool sensor_common_read_reg(uint8_t addr, uint8_t *buf, uint8_t len)
Reads a sensor's register over I2C.
Definition: sensor-common.c:48
bool sensor_common_write_reg(uint8_t addr, uint8_t *buf, uint8_t len)
Write to a sensor's register over I2C.
Definition: sensor-common.c:54
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.
Definition: uip-nd6.c:107