Degree Computation

Dependencies:   aconno_SEGGER_RTT LSM9DS1 Si7006A20 adc52832_common aconnoMPL115A1 aconno_bsp

Committer:
jurica238814
Date:
Wed Dec 12 19:28:16 2018 +0100
Revision:
0:442d98af8cc7
Init commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jurica238814 0:442d98af8cc7 1 /**
jurica238814 0:442d98af8cc7 2 * Made by Jurica @ aconno
jurica238814 0:442d98af8cc7 3 * jurica@aconno.de
jurica238814 0:442d98af8cc7 4 * More info @ aconno.de
jurica238814 0:442d98af8cc7 5 */
jurica238814 0:442d98af8cc7 6
jurica238814 0:442d98af8cc7 7 #include "mbed.h"
jurica238814 0:442d98af8cc7 8 #include "aconnoHelpers.h"
jurica238814 0:442d98af8cc7 9 #include "ble/BLE.h"
jurica238814 0:442d98af8cc7 10 #include "aconnoConfig.h"
jurica238814 0:442d98af8cc7 11
jurica238814 0:442d98af8cc7 12 #define UPDATE_SENSORS_SIGNAL (0x10001000)
jurica238814 0:442d98af8cc7 13 #define SEND_DATA_SIGNAL (0x10001001)
jurica238814 0:442d98af8cc7 14 extern Thread updateDataThread;
jurica238814 0:442d98af8cc7 15 extern Thread sendDataThread;
jurica238814 0:442d98af8cc7 16
jurica238814 0:442d98af8cc7 17 void updateDataTask()
jurica238814 0:442d98af8cc7 18 {
jurica238814 0:442d98af8cc7 19 //printf("updateDataTask started.\r\n");
jurica238814 0:442d98af8cc7 20 while(1)
jurica238814 0:442d98af8cc7 21 {
jurica238814 0:442d98af8cc7 22
jurica238814 0:442d98af8cc7 23 ThisThread::flags_wait_any(UPDATE_SENSORS_SIGNAL);
jurica238814 0:442d98af8cc7 24 //printf("Ulazim\r\n");
jurica238814 0:442d98af8cc7 25 updateData();
jurica238814 0:442d98af8cc7 26 sendDataThread.flags_set(SEND_DATA_SIGNAL);
jurica238814 0:442d98af8cc7 27 //printf("Vrtim se.\r\n");
jurica238814 0:442d98af8cc7 28 }
jurica238814 0:442d98af8cc7 29 }
jurica238814 0:442d98af8cc7 30
jurica238814 0:442d98af8cc7 31 void sendDataTask()
jurica238814 0:442d98af8cc7 32 {
jurica238814 0:442d98af8cc7 33 //printf("sendDataTask started.\r\n");
jurica238814 0:442d98af8cc7 34 BLE &ble = BLE::Instance();
jurica238814 0:442d98af8cc7 35 while(1)
jurica238814 0:442d98af8cc7 36 {
jurica238814 0:442d98af8cc7 37 updateDataThread.flags_set(UPDATE_SENSORS_SIGNAL);
jurica238814 0:442d98af8cc7 38 ThisThread::flags_wait_any(SEND_DATA_SIGNAL);
jurica238814 0:442d98af8cc7 39 //printf("Turning BLE radion on.\r\n");
jurica238814 0:442d98af8cc7 40 ble.gap().startAdvertising();
jurica238814 0:442d98af8cc7 41 ThisThread::sleep_for(RADIO_ACTIVE_TIME_MS);
jurica238814 0:442d98af8cc7 42 //printf("Turining BLE radio off.\r\n");
jurica238814 0:442d98af8cc7 43 ble.gap().stopAdvertising();
jurica238814 0:442d98af8cc7 44 MBED_ASSERT((ADV_PERIOD_TIME_MS-RADIO_ACTIVE_TIME_MS) > 0);
jurica238814 0:442d98af8cc7 45 ThisThread::sleep_for(ADV_PERIOD_TIME_MS-RADIO_ACTIVE_TIME_MS);
jurica238814 0:442d98af8cc7 46
jurica238814 0:442d98af8cc7 47 }
jurica238814 0:442d98af8cc7 48 }