read and push
Dependencies: X_NUCLEO_IKS01A1 MLX90614 d7a_1x wizzi-utils
Fork of D7A_1x_demo_sensors_OS5 by
files.h@7:8de29807f970, 2017-02-02 (annotated)
- Committer:
- yordan
- Date:
- Thu Feb 02 17:30:47 2017 +0000
- Revision:
- 7:8de29807f970
- Parent:
- 0:7e1fdc4d6e1c
- Child:
- 8:01f0225408cf
refactor
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jeej | 0:7e1fdc4d6e1c | 1 | #ifndef _FILES_H_ |
Jeej | 0:7e1fdc4d6e1c | 2 | #define _FILES_H_ |
Jeej | 0:7e1fdc4d6e1c | 3 | |
Jeej | 0:7e1fdc4d6e1c | 4 | #include "mbed.h" |
Jeej | 0:7e1fdc4d6e1c | 5 | #include "d7a.h" |
Jeej | 0:7e1fdc4d6e1c | 6 | |
Jeej | 0:7e1fdc4d6e1c | 7 | enum { |
Jeej | 0:7e1fdc4d6e1c | 8 | ALARM_FILE_ID = 224, |
Jeej | 0:7e1fdc4d6e1c | 9 | SIMUL_FILE_ID, |
Jeej | 0:7e1fdc4d6e1c | 10 | |
Jeej | 0:7e1fdc4d6e1c | 11 | MAG_CFG_FILE_ID = 240, |
Jeej | 0:7e1fdc4d6e1c | 12 | ACC_CFG_FILE_ID, |
Jeej | 0:7e1fdc4d6e1c | 13 | GYR_CFG_FILE_ID, |
Jeej | 0:7e1fdc4d6e1c | 14 | PRE_CFG_FILE_ID, // 243 |
Jeej | 0:7e1fdc4d6e1c | 15 | HUM_CFG_FILE_ID, |
Jeej | 0:7e1fdc4d6e1c | 16 | TEM1_CFG_FILE_ID, |
Jeej | 0:7e1fdc4d6e1c | 17 | TEM2_CFG_FILE_ID, |
Jeej | 0:7e1fdc4d6e1c | 18 | MAG_VALUE_FILE_ID, // 247 |
Jeej | 0:7e1fdc4d6e1c | 19 | ACC_VALUE_FILE_ID, |
Jeej | 0:7e1fdc4d6e1c | 20 | GYR_VALUE_FILE_ID, |
Jeej | 0:7e1fdc4d6e1c | 21 | PRE_VALUE_FILE_ID, // 250 |
Jeej | 0:7e1fdc4d6e1c | 22 | HUM_VALUE_FILE_ID, |
Jeej | 0:7e1fdc4d6e1c | 23 | TEM1_VALUE_FILE_ID, |
Jeej | 0:7e1fdc4d6e1c | 24 | TEM2_VALUE_FILE_ID, // 253 |
Jeej | 0:7e1fdc4d6e1c | 25 | }; |
Jeej | 0:7e1fdc4d6e1c | 26 | |
Jeej | 0:7e1fdc4d6e1c | 27 | #define GENERIC_FILE(name,data) TYPEDEF_STRUCT_PACKED{\ |
Jeej | 0:7e1fdc4d6e1c | 28 | data\ |
Jeej | 0:7e1fdc4d6e1c | 29 | } name##_t;\ |
Jeej | 0:7e1fdc4d6e1c | 30 | extern name##_t f_##name; |
Jeej | 0:7e1fdc4d6e1c | 31 | |
Jeej | 0:7e1fdc4d6e1c | 32 | #define GENERIC_FILE_INIT(name,...) name##_t f_##name = {\ |
Jeej | 0:7e1fdc4d6e1c | 33 | __VA_ARGS__\ |
Jeej | 0:7e1fdc4d6e1c | 34 | } |
Jeej | 0:7e1fdc4d6e1c | 35 | |
Jeej | 0:7e1fdc4d6e1c | 36 | #define GENERIC_FILE_MAP(fid,name) { (void*)fid, (void*)&f_##name } |
Jeej | 0:7e1fdc4d6e1c | 37 | |
yordan | 7:8de29807f970 | 38 | // Types of reporting |
yordan | 7:8de29807f970 | 39 | typedef enum |
yordan | 7:8de29807f970 | 40 | { |
yordan | 7:8de29807f970 | 41 | REPORT_ALWAYS, |
yordan | 7:8de29807f970 | 42 | REPORT_ON_DIFFERENCE, |
yordan | 7:8de29807f970 | 43 | REPORT_ON_THRESHOLD, |
yordan | 7:8de29807f970 | 44 | |
yordan | 7:8de29807f970 | 45 | } report_type_t; |
Jeej | 0:7e1fdc4d6e1c | 46 | |
yordan | 7:8de29807f970 | 47 | // Sensor reporting configuration |
yordan | 7:8de29807f970 | 48 | TYPEDEF_STRUCT_PACKED |
yordan | 7:8de29807f970 | 49 | { |
yordan | 7:8de29807f970 | 50 | uint8_t report_type; // Type of report asked |
yordan | 7:8de29807f970 | 51 | uint32_t period; // Measure period (ms) |
yordan | 7:8de29807f970 | 52 | uint32_t max_period; // Maximum time between reports (s) |
yordan | 7:8de29807f970 | 53 | uint32_t max_diff; // Maximum difference allowed between two reported values |
yordan | 7:8de29807f970 | 54 | int32_t threshold_high; // High threshold value triggering a report |
yordan | 7:8de29807f970 | 55 | int32_t threshold_low; // Low threshold value triggering a report |
yordan | 7:8de29807f970 | 56 | |
yordan | 7:8de29807f970 | 57 | } sensor_config_t; |
Jeej | 0:7e1fdc4d6e1c | 58 | |
Jeej | 0:7e1fdc4d6e1c | 59 | // Firmware revision for the Dash7board |
Jeej | 0:7e1fdc4d6e1c | 60 | GENERIC_FILE(dev_rev, d7a_revision_t rev;); |
Jeej | 0:7e1fdc4d6e1c | 61 | GENERIC_FILE(simul, uint32_t divider;); |
Jeej | 0:7e1fdc4d6e1c | 62 | GENERIC_FILE(mag_cfg, sensor_config_t cfg;); |
Jeej | 0:7e1fdc4d6e1c | 63 | GENERIC_FILE(acc_cfg, sensor_config_t cfg;); |
Jeej | 0:7e1fdc4d6e1c | 64 | GENERIC_FILE(gyr_cfg, sensor_config_t cfg;); |
Jeej | 0:7e1fdc4d6e1c | 65 | GENERIC_FILE(pre_cfg, sensor_config_t cfg;); |
Jeej | 0:7e1fdc4d6e1c | 66 | GENERIC_FILE(hum_cfg, sensor_config_t cfg;); |
Jeej | 0:7e1fdc4d6e1c | 67 | GENERIC_FILE(tem1_cfg, sensor_config_t cfg;); |
Jeej | 0:7e1fdc4d6e1c | 68 | GENERIC_FILE(tem2_cfg, sensor_config_t cfg;); |
Jeej | 0:7e1fdc4d6e1c | 69 | |
Jeej | 0:7e1fdc4d6e1c | 70 | uint32_t fs_write_file(const uint8_t file_id, |
Jeej | 0:7e1fdc4d6e1c | 71 | const uint16_t offset, |
Jeej | 0:7e1fdc4d6e1c | 72 | const uint16_t size, |
Jeej | 0:7e1fdc4d6e1c | 73 | const uint8_t* const content); |
Jeej | 0:7e1fdc4d6e1c | 74 | |
Jeej | 0:7e1fdc4d6e1c | 75 | uint32_t fs_read_file( const uint8_t file_id, |
Jeej | 0:7e1fdc4d6e1c | 76 | const uint16_t offset, |
Jeej | 0:7e1fdc4d6e1c | 77 | const uint16_t size, |
Jeej | 0:7e1fdc4d6e1c | 78 | uint8_t* buf); |
Jeej | 0:7e1fdc4d6e1c | 79 | |
Jeej | 0:7e1fdc4d6e1c | 80 | #endif // _FILE_SYS_H_ |