Pathfindr / Mbed OS mbed-os-PF-UWBBEACON_v1_dev

Dependencies:   aconno_I2C Lis2dh12 WatchdogTimer

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers app_data.h Source File

app_data.h

00001 /*
00002 ================================================================================
00003 Project:    MTU Tracker
00004 Module:     app data
00005 Status:     Development
00006 Type:       .h header file
00007 Copyright (c) 2018 Pathfindr Ltd
00008 All Rights Reserved.
00009 ================================================================================
00010 Notes:
00011 
00012 ================================================================================
00013 */
00014 #ifndef APP_DATA_H_
00015 #define APP_DATA_H_
00016 
00017 //------------------------------------------------------------------------------
00018 //Dependencies
00019 //------------------------------------------------------------------------------
00020 #include "main.h"
00021 
00022 //------------------------------------------------------------------------------
00023 //GLOBAL function macros
00024 //------------------------------------------------------------------------------
00025 //NONE
00026 //------------------------------------------------------------------------------
00027 //GLOBAL constants - STATUS BIT FLAG DEFINITIONS
00028 //------------------------------------------------------------------------------
00029 //status flag - bit positions
00030 const uint32_t rollback_flag      = 0x00000001  ; //flag - load from bank 2 to bank 1.
00031 const uint32_t app_execution_flag = 0x00000002  ; //flag - set in bootloader, clear on app ran successfully.
00032 const uint32_t registered_flag    = 0x00000004  ; //flag - set when connected to database and registered board data.
00033 const uint32_t first_run_flag     = 0x00000008  ; //flag - placeholder - how do we detect if the formware is run for  the first time?
00034 const uint32_t sleep_pending      = 0x00000010  ; //flag - on reset check this flag and enter deep sleep if set
00035 const uint32_t get_status_flag    = 0x00000020  ; //flag - on button press set this flag
00036 const uint32_t wakeup_flag        = 0x00000040  ; //flag - on wakeup set this flag
00037 //status led - states
00038 const uint32_t blinky_ok                  = 0x00000001 ;
00039 const uint32_t blinky_update_failed       = 0x00000002 ;
00040 const uint32_t blinky_stuck_in_bootloader = 0x00000003 ;
00041 //------------------------------------------------------------------------------
00042 //GLOBAL data structures - APP DATA
00043 //------------------------------------------------------------------------------
00044 typedef struct{
00045     uint32_t current_firmware_version;      
00046     uint32_t target_firmware_version;       // 0 = get latest firmware
00047     uint32_t app_execution_fail_counter; 
00048     uint32_t blinky_state;                  // status of led on periodic wake
00049     uint32_t sleep_counter;                 // tracks the period between update attempts 
00050     uint32_t sleep_duration;                // 
00051     uint32_t update_duration;
00052     uint32_t reset_counter;
00053     uint32_t wd_counter;
00054     uint32_t status_flags;                  // status flag register
00055 } app_data_t;    
00056 #define N_SETTINGS 10
00057 //------------------------------------------------------------------------------
00058 //GLOBAL variables
00059 //------------------------------------------------------------------------------
00060 extern app_data_t app_data; 
00061 //------------------------------------------------------------------------------
00062 //GLOBAL function prototypes
00063 //------------------------------------------------------------------------------
00064 //Read/write app data to Flash memory
00065 //extern bool flash_test(app_data_t *ptr);
00066 //extern void print_app_data(app_data_t *ptr);
00067 extern bool write_app_data_to_flash(app_data_t *ptr);
00068 extern bool read_app_data_from_flash(app_data_t *ptr);
00069 extern void clear_app_data(app_data_t *ptr);
00070 extern void set_app_data(app_data_t *ptr);
00071 
00072 //Flag operations
00073 extern bool set_flag(app_data_t *ptr, uint32_t flag);
00074 extern bool get_flag(app_data_t *ptr, uint32_t flag);
00075 extern bool clr_flag(app_data_t *ptr, uint32_t flag);
00076 extern bool tgl_flag(app_data_t *ptr, uint32_t flag);
00077 extern bool rst_flag_buffer(app_data_t *ptr);
00078 
00079 #endif 
00080 
00081 
00082