Simon Hawe / D7_MLX_AND_BAT

Dependencies:   X_NUCLEO_IKS01A1 MLX90614 d7a_1x wizzi-utils

Fork of D7A_1x_demo_sensors_OS5 by WizziLab

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers files.h Source File

files.h

00001 #ifndef _FILES_H_
00002 #define _FILES_H_
00003 
00004 #include "mbed.h"
00005 #include "d7a.h"
00006 
00007 enum {
00008     // Alarm
00009     ALARM_FILE_ID       = 224,
00010     SIMUL_FILE_ID,
00011     
00012     // RFU
00013     RFU_FILE_ID_226, 
00014     RFU_FILE_ID_227, 
00015     RFU_FILE_ID_228, 
00016     RFU_FILE_ID_229, 
00017 
00018     // New cfg
00019     LIGHT_CFG_FILE_ID   = 230,
00020     VOLT_CFG_FILE_ID,
00021     RFU_CFG_FILE_ID_232, 
00022     RFU_CFG_FILE_ID_233, 
00023     RFU_CFG_FILE_ID_234, 
00024 
00025     // New value
00026     LIGHT_VALUE_FILE_ID = 235,
00027     VOLT_VALUE_FILE_ID, 
00028     RFU_VALUE_FILE_ID_237, 
00029     RFU_VALUE_FILE_ID_238, 
00030     RFU_VALUE_FILE_ID_239, 
00031 
00032     // Nucleo-64 default list
00033     MAG_CFG_FILE_ID     = 240,
00034     ACC_CFG_FILE_ID,
00035     GYR_CFG_FILE_ID,
00036     PRE_CFG_FILE_ID,   // 243
00037     HUM_CFG_FILE_ID,
00038     TEM1_CFG_FILE_ID,
00039     TEM2_CFG_FILE_ID,
00040     MAG_VALUE_FILE_ID, // 247
00041     ACC_VALUE_FILE_ID,
00042     GYR_VALUE_FILE_ID,
00043     PRE_VALUE_FILE_ID, // 250
00044     HUM_VALUE_FILE_ID,
00045     TEM1_VALUE_FILE_ID,
00046     TEM2_VALUE_FILE_ID,// 253
00047 };
00048 
00049 #define GENERIC_FILE(name,data)         TYPEDEF_STRUCT_PACKED{\
00050                                             data\
00051                                         } name##_t;\
00052                                         extern name##_t f_##name;
00053                                     
00054 #define GENERIC_FILE_INIT(name,...)     name##_t f_##name = {\
00055                                             __VA_ARGS__\
00056                                         }
00057                                         
00058 #define GENERIC_FILE_MAP(fid,name)      { (void*)fid, (void*)&f_##name }
00059 
00060 // Types of reporting
00061 typedef enum 
00062 {
00063     REPORT_ALWAYS,
00064     REPORT_ON_DIFFERENCE,
00065     REPORT_ON_THRESHOLD,
00066     
00067 } report_type_t;
00068 
00069 // Sensor reporting configuration
00070 TYPEDEF_STRUCT_PACKED 
00071 {
00072     uint8_t  report_type;       // Type of report asked
00073     uint32_t period;            // Measure period (ms)
00074     uint32_t max_period;        // Maximum time between reports (s)
00075     uint32_t max_diff;          // Maximum difference allowed between two reported values
00076     int32_t  threshold_high;    // High threshold value triggering a report
00077     int32_t  threshold_low;     // Low threshold value triggering a report
00078     
00079 } sensor_config_t;
00080 
00081 // Firmware revision for the Dash7board
00082 GENERIC_FILE(dev_rev, d7a_revision_t rev;);
00083 GENERIC_FILE(simul, uint32_t divider;);
00084 GENERIC_FILE(tem1_cfg, sensor_config_t cfg;);
00085 GENERIC_FILE(volt_cfg, sensor_config_t cfg;);
00086 
00087 uint32_t fs_write_file(const uint8_t file_id,
00088                         const uint16_t offset,
00089                         const uint16_t size,
00090                         const uint8_t* const content);
00091                         
00092 uint32_t fs_read_file( const uint8_t file_id,
00093                         const uint16_t offset,
00094                         const uint16_t size,
00095                         uint8_t* buf);
00096 
00097 #endif // _FILE_SYS_H_