init
Dependencies: aconno_I2C Lis2dh12 WatchdogTimer
app_data.h@58:8d4a354816b1, 2020-02-17 (annotated)
- Committer:
- pathfindr
- Date:
- Mon Feb 17 23:24:52 2020 +0000
- Revision:
- 58:8d4a354816b1
- Parent:
- 34:4493c9f6d707
usb
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pathfindr | 34:4493c9f6d707 | 1 | /* |
pathfindr | 34:4493c9f6d707 | 2 | ================================================================================ |
pathfindr | 34:4493c9f6d707 | 3 | Project: MTU Tracker |
pathfindr | 34:4493c9f6d707 | 4 | Module: app data |
pathfindr | 34:4493c9f6d707 | 5 | Status: Development |
pathfindr | 34:4493c9f6d707 | 6 | Type: .h header file |
pathfindr | 34:4493c9f6d707 | 7 | Copyright (c) 2018 Pathfindr Ltd |
pathfindr | 34:4493c9f6d707 | 8 | All Rights Reserved. |
pathfindr | 34:4493c9f6d707 | 9 | ================================================================================ |
pathfindr | 34:4493c9f6d707 | 10 | Notes: |
pathfindr | 34:4493c9f6d707 | 11 | |
pathfindr | 34:4493c9f6d707 | 12 | ================================================================================ |
pathfindr | 34:4493c9f6d707 | 13 | */ |
pathfindr | 34:4493c9f6d707 | 14 | #ifndef APP_DATA_H_ |
pathfindr | 34:4493c9f6d707 | 15 | #define APP_DATA_H_ |
pathfindr | 34:4493c9f6d707 | 16 | |
pathfindr | 34:4493c9f6d707 | 17 | //------------------------------------------------------------------------------ |
pathfindr | 34:4493c9f6d707 | 18 | //Dependencies |
pathfindr | 34:4493c9f6d707 | 19 | //------------------------------------------------------------------------------ |
pathfindr | 34:4493c9f6d707 | 20 | #include "main.h" |
pathfindr | 34:4493c9f6d707 | 21 | |
pathfindr | 34:4493c9f6d707 | 22 | //------------------------------------------------------------------------------ |
pathfindr | 34:4493c9f6d707 | 23 | //GLOBAL function macros |
pathfindr | 34:4493c9f6d707 | 24 | //------------------------------------------------------------------------------ |
pathfindr | 34:4493c9f6d707 | 25 | //NONE |
pathfindr | 34:4493c9f6d707 | 26 | //------------------------------------------------------------------------------ |
pathfindr | 34:4493c9f6d707 | 27 | //GLOBAL constants - STATUS BIT FLAG DEFINITIONS |
pathfindr | 34:4493c9f6d707 | 28 | //------------------------------------------------------------------------------ |
pathfindr | 34:4493c9f6d707 | 29 | //status flag - bit positions |
pathfindr | 34:4493c9f6d707 | 30 | const uint32_t rollback_flag = 0x00000001 ; //flag - load from bank 2 to bank 1. |
pathfindr | 34:4493c9f6d707 | 31 | const uint32_t app_execution_flag = 0x00000002 ; //flag - set in bootloader, clear on app ran successfully. |
pathfindr | 34:4493c9f6d707 | 32 | const uint32_t registered_flag = 0x00000004 ; //flag - set when connected to database and registered board data. |
pathfindr | 34:4493c9f6d707 | 33 | const uint32_t first_run_flag = 0x00000008 ; //flag - placeholder - how do we detect if the formware is run for the first time? |
pathfindr | 34:4493c9f6d707 | 34 | const uint32_t sleep_pending = 0x00000010 ; //flag - on reset check this flag and enter deep sleep if set |
pathfindr | 34:4493c9f6d707 | 35 | const uint32_t get_status_flag = 0x00000020 ; //flag - on button press set this flag |
pathfindr | 34:4493c9f6d707 | 36 | const uint32_t wakeup_flag = 0x00000040 ; //flag - on wakeup set this flag |
pathfindr | 34:4493c9f6d707 | 37 | //status led - states |
pathfindr | 34:4493c9f6d707 | 38 | const uint32_t blinky_ok = 0x00000001 ; |
pathfindr | 34:4493c9f6d707 | 39 | const uint32_t blinky_update_failed = 0x00000002 ; |
pathfindr | 34:4493c9f6d707 | 40 | const uint32_t blinky_stuck_in_bootloader = 0x00000003 ; |
pathfindr | 34:4493c9f6d707 | 41 | //------------------------------------------------------------------------------ |
pathfindr | 34:4493c9f6d707 | 42 | //GLOBAL data structures - APP DATA |
pathfindr | 34:4493c9f6d707 | 43 | //------------------------------------------------------------------------------ |
pathfindr | 34:4493c9f6d707 | 44 | typedef struct{ |
pathfindr | 34:4493c9f6d707 | 45 | uint32_t current_firmware_version; |
pathfindr | 34:4493c9f6d707 | 46 | uint32_t target_firmware_version; // 0 = get latest firmware |
pathfindr | 34:4493c9f6d707 | 47 | uint32_t app_execution_fail_counter; |
pathfindr | 34:4493c9f6d707 | 48 | uint32_t blinky_state; // status of led on periodic wake |
pathfindr | 34:4493c9f6d707 | 49 | uint32_t sleep_counter; // tracks the period between update attempts |
pathfindr | 34:4493c9f6d707 | 50 | uint32_t sleep_duration; // |
pathfindr | 34:4493c9f6d707 | 51 | uint32_t update_duration; |
pathfindr | 34:4493c9f6d707 | 52 | uint32_t reset_counter; |
pathfindr | 34:4493c9f6d707 | 53 | uint32_t wd_counter; |
pathfindr | 34:4493c9f6d707 | 54 | uint32_t status_flags; // status flag register |
pathfindr | 34:4493c9f6d707 | 55 | } app_data_t; |
pathfindr | 34:4493c9f6d707 | 56 | #define N_SETTINGS 10 |
pathfindr | 34:4493c9f6d707 | 57 | //------------------------------------------------------------------------------ |
pathfindr | 34:4493c9f6d707 | 58 | //GLOBAL variables |
pathfindr | 34:4493c9f6d707 | 59 | //------------------------------------------------------------------------------ |
pathfindr | 34:4493c9f6d707 | 60 | extern app_data_t app_data; |
pathfindr | 34:4493c9f6d707 | 61 | //------------------------------------------------------------------------------ |
pathfindr | 34:4493c9f6d707 | 62 | //GLOBAL function prototypes |
pathfindr | 34:4493c9f6d707 | 63 | //------------------------------------------------------------------------------ |
pathfindr | 34:4493c9f6d707 | 64 | //Read/write app data to Flash memory |
pathfindr | 34:4493c9f6d707 | 65 | //extern bool flash_test(app_data_t *ptr); |
pathfindr | 34:4493c9f6d707 | 66 | //extern void print_app_data(app_data_t *ptr); |
pathfindr | 34:4493c9f6d707 | 67 | extern bool write_app_data_to_flash(app_data_t *ptr); |
pathfindr | 34:4493c9f6d707 | 68 | extern bool read_app_data_from_flash(app_data_t *ptr); |
pathfindr | 34:4493c9f6d707 | 69 | extern void clear_app_data(app_data_t *ptr); |
pathfindr | 34:4493c9f6d707 | 70 | extern void set_app_data(app_data_t *ptr); |
pathfindr | 34:4493c9f6d707 | 71 | |
pathfindr | 34:4493c9f6d707 | 72 | //Flag operations |
pathfindr | 34:4493c9f6d707 | 73 | extern bool set_flag(app_data_t *ptr, uint32_t flag); |
pathfindr | 34:4493c9f6d707 | 74 | extern bool get_flag(app_data_t *ptr, uint32_t flag); |
pathfindr | 34:4493c9f6d707 | 75 | extern bool clr_flag(app_data_t *ptr, uint32_t flag); |
pathfindr | 34:4493c9f6d707 | 76 | extern bool tgl_flag(app_data_t *ptr, uint32_t flag); |
pathfindr | 34:4493c9f6d707 | 77 | extern bool rst_flag_buffer(app_data_t *ptr); |
pathfindr | 34:4493c9f6d707 | 78 | |
pathfindr | 34:4493c9f6d707 | 79 | #endif |
pathfindr | 34:4493c9f6d707 | 80 | |
pathfindr | 34:4493c9f6d707 | 81 | |
pathfindr | 34:4493c9f6d707 | 82 |