Complete sensor demo.

Dependencies:   modem_ref_helper CRC X_NUCLEO_IKS01A1 DebouncedInterrupt

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers files.cpp Source File

files.cpp

00001 #include "files.h"
00002 #include "hwcfg.h"
00003 
00004 #include "kal_fs.h"
00005 
00006 #define __DEVICE_ID__               0x00000010
00007 
00008 alp_file_header_t h_rev = {
00009     .perm = RWR_R_,
00010     .prop = FS_PERMANENT_NOTIF,
00011     .afid = FID_ACTP_RPT_FULL,
00012     .ifid = IFID_REPORT,
00013     .size = HAL_U32_BYTE_SWAP((uint32_t)sizeof(revision_t)),
00014     .alloc= HAL_U32_BYTE_SWAP((uint32_t)sizeof(revision_t))
00015 };
00016 
00017 revision_t f_rev = {
00018     .manufacturer_id     = __MANUFACTURER_ID__,
00019     /// Device ID: Arbitrary number, at user/customer choice
00020     .device_id           = __DEVICE_ID__,
00021     /// Hardware Board ID:
00022     .hw_version          = __HW_VERSION__,
00023     /// Firmware Version: made of
00024     ///  - major,minor and patch indexes
00025     ///  - fw_id : "build-flavour"
00026     ///  FW_ID | MAJOR | MINOR | PATCH | HASH |
00027     //     1B  |  1B   |  1B   |   2B  |  4B  |
00028     .fw_version.id       = 2,
00029     .fw_version.major    = 3,
00030     .fw_version.minor    = 0,
00031     .fw_version.patch    = 5,
00032     .fw_version.hash     = 0x20200528,
00033     /// Not used
00034     .cup_max_size        = 0x00000000
00035 };
00036 
00037 alp_file_header_t h_alarm = {
00038     .perm = RWRWR_,
00039     .prop = FS_VOLATILE,
00040     .afid = 0,
00041     .ifid = 0,
00042     .size = HAL_U32_BYTE_SWAP((uint32_t)sizeof(uint8_t)),
00043     .alloc= HAL_U32_BYTE_SWAP((uint32_t)sizeof(uint8_t))
00044 };
00045 
00046 uint8_t f_alarm = 255;
00047 
00048 #define HEADER_FILE_SENSOR_CONFIG(name) const alp_file_header_t h_sensor_config_##name = {\
00049     .perm = RWRWR_,\
00050     .prop = FS_VOLATILE,\
00051     .afid = 0,\
00052     .ifid = 0,\
00053     .size = HAL_U32_BYTE_SWAP((uint32_t)sizeof(sensor_config_t)),\
00054     .alloc= HAL_U32_BYTE_SWAP((uint32_t)sizeof(sensor_config_t))\
00055 }
00056 
00057 #define HEADER_FILE_SENSOR_VALUE(name,_size) const alp_file_header_t h_sensor_value_##name = {\
00058     .perm = RWRWR_,\
00059     .prop = FS_VOLATILE_NOTIF,\
00060     .afid = FID_ACTP_RPT_FULL,\
00061     .ifid = IFID_REPORT,\
00062     .size = HAL_U32_BYTE_SWAP((uint32_t)(_size)),\
00063     .alloc= HAL_U32_BYTE_SWAP((uint32_t)(_size))\
00064 }
00065 
00066 
00067 #define DATA_FILE_SENSOR_VALUE(name,_size) int32_t f_sensor_value_##name[_size] = {0}
00068 
00069 HEADER_FILE_SENSOR_CONFIG(mag);
00070 HEADER_FILE_SENSOR_CONFIG(acc);
00071 HEADER_FILE_SENSOR_CONFIG(gyr);
00072 HEADER_FILE_SENSOR_CONFIG(pre);
00073 HEADER_FILE_SENSOR_CONFIG(hum);
00074 HEADER_FILE_SENSOR_CONFIG(tem1);
00075 HEADER_FILE_SENSOR_CONFIG(tem2);
00076 HEADER_FILE_SENSOR_CONFIG(light);
00077 
00078 HEADER_FILE_SENSOR_VALUE(mag, 3*sizeof(int32_t));
00079 HEADER_FILE_SENSOR_VALUE(acc, 3*sizeof(int32_t));
00080 HEADER_FILE_SENSOR_VALUE(gyr, 3*sizeof(int32_t));
00081 HEADER_FILE_SENSOR_VALUE(pre, 1*sizeof(int32_t));
00082 HEADER_FILE_SENSOR_VALUE(hum, 1*sizeof(int32_t));
00083 HEADER_FILE_SENSOR_VALUE(tem1, 1*sizeof(int32_t));
00084 HEADER_FILE_SENSOR_VALUE(tem2, 1*sizeof(int32_t));
00085 HEADER_FILE_SENSOR_VALUE(light, 1*sizeof(int32_t));
00086 
00087 DATA_FILE_SENSOR_VALUE(mag, 3);
00088 DATA_FILE_SENSOR_VALUE(acc, 3);
00089 DATA_FILE_SENSOR_VALUE(gyr, 3);
00090 DATA_FILE_SENSOR_VALUE(pre, 1);
00091 DATA_FILE_SENSOR_VALUE(hum, 1);
00092 DATA_FILE_SENSOR_VALUE(tem1, 1);
00093 DATA_FILE_SENSOR_VALUE(tem2, 1);
00094 DATA_FILE_SENSOR_VALUE(light, 1);
00095 
00096 sensor_config_t f_sensor_config_mag = {
00097     .report_type = REPORT_ON_DIFFERENCE,
00098     .read_period = 1000,
00099     .max_period = 3600,
00100     .max_diff = 500,
00101     .threshold_high = 1000,
00102     .threshold_low = -1000,
00103 };
00104     
00105 sensor_config_t f_sensor_config_acc = {
00106     .report_type = REPORT_ON_DIFFERENCE,
00107     .read_period = 1000,
00108     .max_period = 3600,
00109     .max_diff = 100,
00110     .threshold_high = 500,
00111     .threshold_low = -500,
00112 };
00113 
00114 sensor_config_t f_sensor_config_gyr = {
00115     .report_type = REPORT_ON_DIFFERENCE,
00116     .read_period = 1000,
00117     .max_period = 3600,
00118     .max_diff = 1000,
00119     .threshold_high = 10000,
00120     .threshold_low = -10000,
00121 };
00122 
00123 sensor_config_t f_sensor_config_pre = {
00124     .report_type = REPORT_ON_DIFFERENCE,
00125     .read_period = 1000,
00126     .max_period = 3600,
00127     .max_diff = 100,
00128     .threshold_high = 120000,
00129     .threshold_low = 90000,
00130 };
00131 
00132 sensor_config_t f_sensor_config_hum = {
00133     .report_type = REPORT_ON_DIFFERENCE,
00134     .read_period = 1000,
00135     .max_period = 3600,
00136     .max_diff = 100,
00137     .threshold_high = 7000,
00138     .threshold_low = 3000,
00139 };
00140 
00141 sensor_config_t f_sensor_config_tem1 = {
00142     .report_type = REPORT_ON_DIFFERENCE,
00143     .read_period = 1000,
00144     .max_period = 3600,
00145     .max_diff = 100,
00146     .threshold_high = 3500,
00147     .threshold_low = 2000,
00148 };
00149 
00150 sensor_config_t f_sensor_config_tem2 = {
00151     .report_type = REPORT_ON_DIFFERENCE,
00152     .read_period = 1000,
00153     .max_period = 3600,
00154     .max_diff = 100,
00155     .threshold_high = 9000,
00156     .threshold_low = 7000,
00157 };
00158 
00159 sensor_config_t f_sensor_config_light = {
00160     .report_type = REPORT_ON_DIFFERENCE,
00161     .read_period = 1000, // ms
00162     .max_period = 3600, // sec
00163     .max_diff = 100,
00164     .threshold_high = 0, // disabled
00165     .threshold_low = 1000, // disabled
00166 };