Contiki-NG
Loading...
Searching...
No Matches
zonik.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016, Zolertia <http://www.zolertia.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 Institute nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * This file is part of the Contiki operating system.
30 *
31 */
32/* -------------------------------------------------------------------------- */
33/**
34 * \addtogroup zoul-sensors
35 * @{
36 *
37 * \defgroup remote-zonik Zonik sound sensor
38 * @{
39 *
40 * \file
41 * Header file for the Zolertia Zonik sound sensor
42 */
43/* -------------------------------------------------------------------------- */
44#ifndef ZONIK_H_
45#define ZONIK_H_
46/* -------------------------------------------------------------------------- */
47#include <stdio.h>
48#include "lib/sensors.h"
49#include "dev/zoul-sensors.h"
50#include "i2c.h"
51#include "sys/rtimer.h"
52/* -------------------------------------------------------------------------- */
53/** \name ZONIK address and definitions
54 * @{
55 */
56#define ZONIK_ADDR 0x68
57#define ZONIK_SENSOR "Zonik Sound Sensor"
58
59#define ZONIK_INITIAL_WAIT_DELAY 11000L
60#define ZONIK_FINAL_WAIT_DELAY 22000L
61
62#ifndef ZONIK_INT_CONF_PORT
63#define ZONIK_INT_PORT I2C_INT_PORT
64#else
65#define ZONIK_INT_PORT ZONIK_INT_CONF_PORT
66#endif
67
68#ifndef ZONIK_INT_CONF_PIN
69#define ZONIK_INT_PIN I2C_INT_PIN
70#else
71#define ZONIK_INT_PIN ZONIK_INT_CONF_PIN
72#endif
73
74#define ZONIK_FRAME_SIZE 4
75
76#define ZONIK_WAIT_ACQ (CLOCK_SECOND / 5)
77
78/* Zonik wait sensor delay: ~800ms */
79#define ZONIK_SECOND_INTERVAL 106
80
81/** @} */
82/* -------------------------------------------------------------------------- */
83/** \name ZONIK error values and definitions
84 * @{
85 */
86#define ZONIK_ACTIVE SENSORS_ACTIVE
87#define ZONIK_HW_INIT SENSORS_HW_INIT
88#define ZONIK_ENABLED 1
89#define ZONIK_VALUE_DEACTIVATE 0
90#define ZONIK_DISABLED 0xD1ED
91#define ZONIK_ERROR (-1)
92#define ZONIK_DBA_LEQ_VALUE 0x00
93#define ZONIK_COUNT_VALUE 0x01
94/** @} */
95/* -------------------------------------------------------------------------- */
96/** \name ZONIK command definitions
97 * @{
98 */
99#define ZONIK_CMD_READ 0x01
100/** @} */
101/* -------------------------------------------------------------------------- */
102/** \name ZONIK sensor type
103 * @{
104 */
105extern const struct sensors_sensor zonik;
106/** @} */
107/* -------------------------------------------------------------------------- */
108#endif
109/* -------------------------------------------------------------------------- */
110/**
111 * @}
112 * @}
113 */
Header file with declarations for the I2C Control module.
Header file for the real-time timer module.
Implementation of a generic module controlling Zoul sensors.