summaryrefslogtreecommitdiffhomepage
path: root/digital/zigbit/bitcloud/stack/Components/BSP/include/sensors.h
blob: 740c6a0517e622587fdc5a0d35d1344741ff0b9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/**************************************************************************//**
  \file  sensors.h

  \brief The header file describes the sensors interface.

  \author
    Atmel Corporation: http://www.atmel.com \n
    Support email: avr@atmel.com

  Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
  Licensed under Atmel's Limited License Agreement (BitCloudTM).

  \internal
  History:
    29/05/07 E. Ivanov - Created
*******************************************************************************/

#ifndef _SENSORS_H
#define _SENSORS_H

/******************************************************************************
                   Includes section
******************************************************************************/
// \cond
#include <types.h>
// \endcond

/******************************************************************************
                   Define(s) section
******************************************************************************/
// \cond
#define SENSOR_LIGHT       1
#define SENSOR_TEMPERATURE 2
#define SENSOR_BATTERY     3
#define SENSOR_LED         4
// \endcond

typedef void (*BspTemperatureCb_t)(bool result, int16_t data);
typedef void (*BspBatteryCb_t)(int16_t data);

/******************************************************************************
                   Prototypes section
******************************************************************************/
/***************************************************************************//**
\brief Opens temperature sensor.
\return
  BC_FAIL - sensor has been already open. \n
  BC_SUCCESS - otherwise.
*******************************************************************************/
result_t BSP_OpenTemperatureSensor(void);

/***************************************************************************//**
\brief Closes the temperature sensor.
\return
  BC_FAIL - if a hardware error has occured or
            there is uncompleted ReadData request. \n
  BC_SUCCESS - otherwise.
*******************************************************************************/
result_t BSP_CloseTemperatureSensor(void);

/**************************************************************************//**
\brief Reads data from the temperature sensor.
\param[in]
    f - callback.
    result - the result of the requested operation.
             true - operation finished successfully, false - some error has
             occured.
    data - sensor data.
\return
  BC_FAIL - previous request was not completed. \n
  BC_SUCCESS - otherwise.
******************************************************************************/
result_t BSP_ReadTemperatureData(BspTemperatureCb_t f);

/***************************************************************************//**
\brief Opens the light sensor.
\return
  BC_FAIL - sensor has been already open. \n
  BC_SUCCESS - otherwise.
*******************************************************************************/
result_t BSP_OpenLightSensor(void);

/***************************************************************************//**
\brief Closes the light sensor.
\return
  BC_FAIL - if a hardware error has occured or
         there is uncompleted ReadData request. \n
  BC_SUCCESS  - otherwise.
*******************************************************************************/
result_t BSP_CloseLightSensor(void);

/**************************************************************************//**
\brief Reads data from the light sensor.
\param[in]
    f - callback.
    result - the result of the requested operation.
             true - operation finished successfully, false - some error has
             occured.
    data - sensor data.
\return
  BC_FAIL - previous request was not completed. \n
  BC_SUCCESS - otherwise.
******************************************************************************/
result_t BSP_ReadLightData(void (*f)(bool result, int16_t data));

/***************************************************************************//**
\brief Opens the battery sensor.
\return
  BC_FAIL - sensor has been already open. \n
  BC_SUCCESS - otherwise.
*******************************************************************************/
result_t BSP_OpenBatterySensor(void);

/***************************************************************************//**
\brief Closes the battery sensor.
\return
  BC_FAIL - sensor was not opened. \n
  BC_SUCCESS  - otherwise.
*******************************************************************************/
result_t BSP_CloseBatterySensor(void);

/**************************************************************************//**
\brief Reads data from battery sensor.
\param[in]
    callback - callback function.
    data - sensor data.
    Can use (4ul * data * 125ul * 3ul) / (1024ul * 100ul) formula to count \n
    battery data in Volts (for avr).
\return
  BC_FAIL - previous request was not completed, or sensor was not opened. \n
  BC_SUCCESS - otherwise.
******************************************************************************/
result_t BSP_ReadBatteryData(BspBatteryCb_t cb);

#endif/* _SENSORS_H */
// eof sensors.h