-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
49 lines (38 loc) · 1014 Bytes
/
main.cpp
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
#include <miosix.h>
#include <pthread.h>
#include "lis3dsh.h"
using namespace miosix;
const float MIN_DURATION = 100;
const float THRESHOLD = 300;
/* ============================= LEDS UTILITY =============================== */
typedef Gpio<GPIOD_BASE, 12> greenLed;
void blinkMainLed()
{
greenLed::high();
usleep(1000000);
greenLed::low();
usleep(200000);
}
/* ============================ END LEDS UTILITY =============================*/
Lis3dsh accelerometer;
/**
* @brief free dall detection thread;
*/
void *freeFallDetection(void *arg)
{
miosix::Thread::getCurrentThread()->setPriority(PRIORITY_MAX-1);
accelerometer.freeFallDetectionInit();
return 0;
}
int main()
{
pthread_t freeFallDetectionThread;
accelerometer.freeFallConfig(MIN_DURATION, THRESHOLD);
pthread_create(&freeFallDetectionThread, NULL, &freeFallDetection, NULL);
for(;;)
{
blinkMainLed();
}
pthread_join(freeFallDetectionThread,NULL);
return 0;
}