Tema SCPI Negru Rares-Razvan
Dependencies: BLE_API mbed nRF51822
Fork of nRF51822_TemperatureEx by
myData.h
00001 #include "ble_flash.h" 00002 #include "mbed.h" 00003 00004 #define MAXBUFFER 99u //(((BLE_FLASH_PAGE_SIZE - 4 - sizeof(myData_t))/sizeof(myDataL_t)) 00005 #define MAX_WORD_PAGE_DATA 254u // to be computed as round_next_int(MAXBUFFER*sizeof(myDataL_t)+sizeof(myData_t)) 00006 00007 #define MAX_PAGE_NUM (NRF_FICR->CODESIZE - 1) // 255 00008 #define MIN_PAGE_NUM 180u 00009 00010 00011 typedef struct{ 00012 uint8_t year; // 20_XX, 2016 => 16; 00013 uint8_t month; // 1..12 00014 uint8_t day; // 1..31 00015 uint8_t hours; 00016 uint8_t minutes; 00017 uint8_t seconds; 00018 } mdate_time_t; 00019 00020 00021 typedef struct{ 00022 mdate_time_t currentDateTime; 00023 mdate_time_t newDateTime; 00024 bool updateDateTime; // true if currentTime needs to be updated with newTime; 00025 } mdatetime_manager_t; 00026 00027 00028 typedef enum { 00029 eStartAdvertising =0, 00030 eStopAdvertising =1, 00031 eDisconnect =2 00032 } connection_update_t; 00033 00034 typedef struct { 00035 int16_t x; 00036 int16_t y; 00037 int16_t z; 00038 uint16_t temp; 00039 } myPayload_t; 00040 00041 00042 typedef struct { 00043 myPayload_t data; 00044 uint8_t seconds; 00045 uint8_t minutes; 00046 } myDataL_t; 00047 00048 typedef struct { 00049 mdate_time_t datetime; // 6 bytes length 00050 myPayload_t data; // 8 bytes lenth 00051 } myData_t; 00052 00053 typedef struct { 00054 myData_t startData; 00055 myDataL_t myData[MAXBUFFER]; 00056 } myDataLog_t; 00057 00058 typedef struct { 00059 myData_t startData; 00060 myDataL_t myData; 00061 } myDataLogShort_t; 00062 00063 /* Return current page to be written in Flash */ 00064 uint8_t flash_currPage(); 00065 00066 /* Return next page to be written in Flash */ 00067 uint8_t flash_go_nextPage(); 00068 00069 /* Return page-N (thas has been written in Flash) */ 00070 uint8_t flash_prev_N_Page(uint8_t nr_of_pages); 00071 00072 /*search the latest page written and extract the page_nr, date, and time*/ 00073 void search_latest_in_flash(mdate_time_t * outDateTime); 00074 00075 /* Update current date and time with tseconds and also if there is a new date/time given */ 00076 void update_time(mdatetime_manager_t* myDateTimeVar, uint16_t tseconds); 00077 00078 /* Update buzzer with period in ms =0..9 and duty cycle = 0..9*/ 00079 int buzz_int(PwmOut* buzzer, uint8_t period, uint8_t duty_cycle); 00080 00081 /* Print on serial some error from main app*/ 00082 void assert_error_app(bool condition, Serial *pc, uint16_t error, uint16_t line, const char* file);
Generated on Wed Jul 27 2022 00:41:33 by
1.7.2
