summaryrefslogtreecommitdiffhomepage
path: root/digital/zigbit/bitcloud/stack/Components/BSP/MESHBEAN/src/fakeBSP.c
blob: 77aa9c512a78a555e4d012619fd7fc549d923b66 (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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
/***************************************************************************//**
\file  fakeBSP.c

\brief Implementation of fake board-specific periphery.

\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:
    28/04/11 A. Malkin - Created
*******************************************************************************/

/******************************************************************************
                   Includes section
******************************************************************************/
#include <types.h>
#include <joystick.h>
#include <bspTaskManager.h>

/******************************************************************************
                   Global variables section
******************************************************************************/
#if (APP_DISABLE_BSP == 1) || (BSP_MNZB_EVB_SUPPORT != 1)
void(* readBatteryDataCallback)(int16_t data);
#endif //(APP_DISABLE_BSP == 1) || (BSP_MNZB_EVB_SUPPORT != 1)
#if APP_DISABLE_BSP == 1
void(* readTemperatureDataCallback)(bool error, int16_t data);
void(* readLightDataCallback)(bool error, int16_t data);

/******************************************************************************
                   Implementations section
******************************************************************************/
/******************************************************************************
                             Buttons
******************************************************************************/
/**************************************************************************//**
\brief Registers handlers for button events.

\param[in]
    pressed - the handler to process pressing the button
\param[in]
    released - the handler to process releasing the button
\param[in]
    bn - button number.

\return
  BC_SUCCESS - always.
******************************************************************************/
result_t BSP_OpenButtons(void (*pressed)(uint8_t bn), void (*released)(uint8_t bn))
{
  (void)pressed;
  (void)released;

  return BC_SUCCESS;
}

/**************************************************************************//**
\brief Cancel buttons handlers.

\return
  BC_SUCCESS - always.
******************************************************************************/
result_t BSP_CloseButtons(void)
{
  return BC_SUCCESS;
}

/**************************************************************************//**
\brief Reads state of buttons.

\return
    Current buttons state in a binary way. \n
    Bit 0 defines state of the button 1, \n
    bit 1 defines state of the button 2.
******************************************************************************/
uint8_t BSP_ReadButtonsState(void)
{
  return 0;
}

/******************************************************************************
                             Sensors
******************************************************************************/
/***************************************************************************//**
\brief Opens temperature sensor.

\return
  BC_SUCCESS - always.
*******************************************************************************/
result_t BSP_OpenTemperatureSensor(void)
{
  return BC_SUCCESS;
}

/***************************************************************************//**
\brief Closes the temperature sensor.

\return
  BC_SUCCESS - always.
*******************************************************************************/
result_t BSP_CloseTemperatureSensor(void)
{
  return BC_SUCCESS;
}

/**************************************************************************//**
\brief Reads data from the temperature sensor.
\param[in]
    result - the result of the requested operation.
             true - operation finished successfully, false - some error has
             occured.
\param[in]
    data - sensor data.

\return
  BC_SUCCESS - always.
******************************************************************************/
result_t BSP_ReadTemperatureData(void (*f)(bool result, int16_t data))
{
  readTemperatureDataCallback = f;

  bspPostTask(BSP_TEMPERATURE);

  return BC_SUCCESS;
}

/**************************************************************************//**
\brief BSP task handler for temperature sensor.
******************************************************************************/
void bspTemperatureSensorHandler(void)
{
  readTemperatureDataCallback(true, 0);
}

/***************************************************************************//**
\brief Opens the light sensor.

\return
  BC_SUCCESS - always.
*******************************************************************************/
result_t BSP_OpenLightSensor(void)
{
  return BC_SUCCESS;
}

/***************************************************************************//**
\brief Closes the light sensor.

\return
  BC_SUCCESS - always.
*******************************************************************************/
result_t BSP_CloseLightSensor(void)
{
  return BC_SUCCESS;
}

/**************************************************************************//**
\brief Reads data from the light sensor.
\param[in]
    result - the result of the requested operation.
             true - operation finished successfully, false - some error has
             occured.
\param[in]
    data - sensor data.

\return
  BC_SUCCESS - always.
******************************************************************************/
result_t BSP_ReadLightData(void (*f)(bool result, int16_t data))
{
  readLightDataCallback = f;

  bspPostTask(BSP_LIGHT);

  return BC_SUCCESS;
}

/**************************************************************************//**
\brief BSP task handler for light sensor.
******************************************************************************/
void bspLightSensorHandler(void)
{
  readLightDataCallback(true, 0);
}

/******************************************************************************
                             Leds
******************************************************************************/
/**************************************************************************//**
\brief Opens leds module to use.

\return
    operation state
******************************************************************************/
result_t BSP_OpenLeds(void)
{
  return BC_SUCCESS;
}

/**************************************************************************//**
\brief Closes leds module.

\return
    operation state
******************************************************************************/
result_t BSP_CloseLeds(void)
{
  return BC_SUCCESS;
}

/**************************************************************************//**
\brief Turns on the LED.

\param[in]
    id - number of led
******************************************************************************/
void BSP_OnLed(uint8_t id)
{
  (void)id;
}

/**************************************************************************//**
\brief Turns off the LED.

\param[in]
      id - number of led
******************************************************************************/
void BSP_OffLed(uint8_t id)
{
  (void)id;
}

/**************************************************************************//**
\brief Changes the´┐ŻLED state to opposite.

\param[in]
      id - number of led
******************************************************************************/
void BSP_ToggleLed(uint8_t id)
{
  (void)id;
}

/******************************************************************************
                             Sliders
******************************************************************************/
/**************************************************************************//**
\brief Reads the sliders.

\return
   state of 3 on-board DIP-switches.User can uses SLIDER0, SLIDER1, SLIDER2
   defines to test state. Value 1 indicates that slider is on.
******************************************************************************/
uint8_t BSP_ReadSliders(void)
{
  return 0;
}

#endif // APP_DISABLE_BSP == 1

/******************************************************************************
                             Joystick
******************************************************************************/
/******************************************************************************
\brief Registers handler for joystick events.

\param[in]
    state - joystick state.

\return
  BC_FAIL - joystick module is busy, 
  BC_SUCCESS in other cases.
******************************************************************************/
result_t BSP_OpenJoystick(void (*generalHandler)(BSP_JoystickState_t state))
{
  (void)generalHandler;

  return BC_SUCCESS;
}

/******************************************************************************
\brief Cancel joystick handlers.

\return
  BC_FAIL - joystick module was not opened,
  BC_SUCCESS in other cases.
******************************************************************************/
result_t BSP_CloseJoystick(void)
{
  return BC_SUCCESS;
}

/******************************************************************************
\brief Reads state of joystick.

\return
    Current joystick state.
******************************************************************************/
BSP_JoystickState_t BSP_ReadJoystickState(void)
{
  return 0;
}

#if (APP_DISABLE_BSP == 1) || (BSP_MNZB_EVB_SUPPORT != 1)
/***************************************************************************//**
\brief Opens the battery sensor.

\return
  BC_SUCCESS - always.
*******************************************************************************/
result_t BSP_OpenBatterySensor(void)
{
  return BC_SUCCESS;
}

/***************************************************************************//**
\brief Closes the battery sensor.

\return
  BC_SUCCESS - always.
*******************************************************************************/
result_t BSP_CloseBatterySensor(void)
{
  return BC_SUCCESS;
}

/**************************************************************************//**
\brief Reads data from battery sensor.

\param[in]
    data - sensor data.

\return
  BC_SUCCESS - always.
******************************************************************************/
result_t BSP_ReadBatteryData(void (*f)(int16_t data))
{
  readBatteryDataCallback = f;

  bspPostTask(BSP_BATTERY);

  return BC_SUCCESS;
}

/**************************************************************************//**
\brief BSP task handler for battery sensor.
******************************************************************************/
void bspEmptyBatteryHandler(void)
{
  readBatteryDataCallback(0); 
}
#endif //(APP_DISABLE_BSP == 1) || (BSP_MNZB_EVB_SUPPORT != 1)

// eof fakeBSP.c