Lizzy project
Dependencies: aconno_I2C Lis2dh12 adc52832_common aconno_SEGGER_RTT
source/main.cpp@22:7dae8496b97c, 2018-09-13 (annotated)
- Committer:
- jurica238814
- Date:
- Thu Sep 13 15:14:14 2018 +0200
- Branch:
- SimpleGATTExample
- Revision:
- 22:7dae8496b97c
- Parent:
- 19:2681edc2f2b9
LAUT example program
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jurica238814 | 19:2681edc2f2b9 | 1 | /* |
jurica238814 | 0:fc77522f4d28 | 2 | * aconno.de |
jurica238814 | 0:fc77522f4d28 | 3 | * Made by Jurica Resetar |
jurica238814 | 19:2681edc2f2b9 | 4 | * All right reserved |
jurica238814 | 0:fc77522f4d28 | 5 | * |
jurica238814 | 0:fc77522f4d28 | 6 | */ |
jurica238814 | 0:fc77522f4d28 | 7 | |
dbartolovic | 8:7ba4f82de9b6 | 8 | #include "bsp.h" |
jurica238814 | 19:2681edc2f2b9 | 9 | #include "bspLed.h" |
dbartolovic | 8:7ba4f82de9b6 | 10 | #include "tasks.h" |
jurica238814 | 19:2681edc2f2b9 | 11 | #include <events/mbed_events.h> |
jurica238814 | 19:2681edc2f2b9 | 12 | #include "aconnoConfig.h" |
jurica238814 | 19:2681edc2f2b9 | 13 | #include "aconno_ble.h" |
jurica238814 | 0:fc77522f4d28 | 14 | |
jurica238814 | 22:7dae8496b97c | 15 | #if !defined(MBED_CPU_STATS_ENABLED) || !defined(DEVICE_LPTICKER) || \ |
jurica238814 | 22:7dae8496b97c | 16 | !defined(DEVICE_SLEEP) |
jurica238814 | 19:2681edc2f2b9 | 17 | #error [NOT_SUPPORTED] Test not supported for statistics |
jurica238814 | 19:2681edc2f2b9 | 18 | #endif |
dbartolovic | 8:7ba4f82de9b6 | 19 | |
jurica238814 | 19:2681edc2f2b9 | 20 | EventQueue queue(32 * EVENTS_EVENT_SIZE); |
jurica238814 | 19:2681edc2f2b9 | 21 | |
dbartolovic | 8:7ba4f82de9b6 | 22 | Thread bleT; |
dbartolovic | 8:7ba4f82de9b6 | 23 | Thread updateServiceT; |
dbartolovic | 8:7ba4f82de9b6 | 24 | Thread updateBuzzLedsT; |
jurica238814 | 19:2681edc2f2b9 | 25 | Thread updateStatisticsT; |
jurica238814 | 0:fc77522f4d28 | 26 | |
jurica238814 | 19:2681edc2f2b9 | 27 | void printStatsF() |
jurica238814 | 19:2681edc2f2b9 | 28 | { |
jurica238814 | 19:2681edc2f2b9 | 29 | mbed_stats_cpu_t stats; |
jurica238814 | 19:2681edc2f2b9 | 30 | |
jurica238814 | 19:2681edc2f2b9 | 31 | mbed_stats_cpu_get(&stats); |
jurica238814 | 19:2681edc2f2b9 | 32 | printf("%-20lld", stats.uptime/1000); |
jurica238814 | 19:2681edc2f2b9 | 33 | printf("%-20lld", stats.idle_time/1000); |
jurica238814 | 19:2681edc2f2b9 | 34 | printf("%-20lld", stats.sleep_time/1000); |
jurica238814 | 19:2681edc2f2b9 | 35 | printf("%-20lld\n", stats.deep_sleep_time/1000); |
jurica238814 | 19:2681edc2f2b9 | 36 | } |
jurica238814 | 19:2681edc2f2b9 | 37 | |
jurica238814 | 19:2681edc2f2b9 | 38 | void bleEventsProcessing(BLE::OnEventsToProcessCallbackContext* context) { |
jurica238814 | 19:2681edc2f2b9 | 39 | BLE &ble = BLE::Instance(); |
jurica238814 | 19:2681edc2f2b9 | 40 | queue.call(Callback<void()>(&ble, &BLE::processEvents)); |
jurica238814 | 19:2681edc2f2b9 | 41 | } |
jurica238814 | 19:2681edc2f2b9 | 42 | |
jurica238814 | 19:2681edc2f2b9 | 43 | int main() |
jurica238814 | 19:2681edc2f2b9 | 44 | { |
jurica238814 | 19:2681edc2f2b9 | 45 | printf("Main program started.\r\n"); |
jurica238814 | 22:7dae8496b97c | 46 | bspInit(); |
jurica238814 | 19:2681edc2f2b9 | 47 | |
jurica238814 | 0:fc77522f4d28 | 48 | BLE &ble = BLE::Instance(); |
jurica238814 | 19:2681edc2f2b9 | 49 | ble.onEventsToProcess(bleEventsProcessing); |
jurica238814 | 0:fc77522f4d28 | 50 | ble.init(bleInitComplete); |
jurica238814 | 19:2681edc2f2b9 | 51 | |
jurica238814 | 19:2681edc2f2b9 | 52 | #if PRINT_ON_RTT |
jurica238814 | 19:2681edc2f2b9 | 53 | queue.call_every(2000, printStatsF); |
jurica238814 | 19:2681edc2f2b9 | 54 | #endif |
jurica238814 | 19:2681edc2f2b9 | 55 | |
jurica238814 | 22:7dae8496b97c | 56 | updateBuzzLedsT.start(updateBuzzLedsF); |
jurica238814 | 19:2681edc2f2b9 | 57 | queue.dispatch_forever(); |
jurica238814 | 19:2681edc2f2b9 | 58 | |
jurica238814 | 0:fc77522f4d28 | 59 | } |