summaryrefslogtreecommitdiffhomepage
path: root/digital/beacon/src/Bitcloud_stack/Components/BSP/MESHBEAN/src/bspTaskManager.c
blob: d63f62da0e50676d70804b7b4557ced6ecde6dee (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
/**************************************************************************//**
\file  bspTaskManager.c

\brief Implemenattion of BSP task manager.

\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
******************************************************************************/
/******************************************************************************
                   Includes section
******************************************************************************/
#include <bspTaskManager.h>
#include <atomic.h>

/******************************************************************************
                   Prototypes section
******************************************************************************/
/**************************************************************************//**
\brief BSP button handler.
******************************************************************************/
void bspButtonsHandler(void);

/**************************************************************************//**
\brief BSP lm73 handler.
******************************************************************************/
void bspLM73Handler(void);
void bspTemperatureSensorHandler(void);

/**************************************************************************//**
\brief BSP tsl2550 handler.
******************************************************************************/
void bspTsl2550Handler(void);
void bspLightSensorHandler(void);

/**************************************************************************//**
\brief BSP battery handler.
******************************************************************************/
void bspBatteryHandler(void);
void bspEmptyBatteryHandler(void);

/******************************************************************************
                   Global variables section
******************************************************************************/
volatile uint8_t bspTaskFlags = 0;

/******************************************************************************
                   Implementations section
******************************************************************************/
/**************************************************************************//**
\brief BSP task handler.
******************************************************************************/
#if APP_DISABLE_BSP != 1

void BSP_TaskHandler(void)
{
  if (bspTaskFlags & BSP_BUTTONS)
  {
    bspTaskFlags &= (~BSP_BUTTONS);
    bspButtonsHandler();
  }
  if (bspTaskFlags & BSP_TEMPERATURE)
  {
    bspTaskFlags &= (~BSP_TEMPERATURE);
    bspLM73Handler();
  }
  if (bspTaskFlags & BSP_LIGHT)
  {
    bspTaskFlags &= (~BSP_LIGHT);
    bspTsl2550Handler();
  }
  if (bspTaskFlags & BSP_BATTERY)
  {
    bspTaskFlags &= (~BSP_BATTERY);
#if BSP_MNZB_EVB_SUPPORT == 1
    bspBatteryHandler();
#else
    bspEmptyBatteryHandler();
#endif // BSP_MNZB_EVB_SUPPORT == 1
  }
  if (bspTaskFlags)
  {
    SYS_PostTask(BSP_TASK_ID);
  }
}

#else  // APP_DISABLE_BSP != 1

void BSP_TaskHandler(void)
{
  if (bspTaskFlags & BSP_TEMPERATURE)
  {
    bspTaskFlags &= (~BSP_TEMPERATURE);
    bspTemperatureSensorHandler();
  }
  if (bspTaskFlags & BSP_LIGHT)
  {
    bspTaskFlags &= (~BSP_LIGHT);
    bspLightSensorHandler();
  }
  if (bspTaskFlags & BSP_BATTERY)
  {
    bspTaskFlags &= (~BSP_BATTERY);
    bspEmptyBatteryHandler();
  }
  if (bspTaskFlags)
  {
    SYS_PostTask(BSP_TASK_ID);
  }
} 

#endif // APP_DISABLE_BSP != 1

// eof bspTaskManager.c