Complete sensor demo.

Dependencies:   modem_ref_helper X_NUCLEO_IKS01A1 DebouncedInterrupt

Committer:
Jeej
Date:
Wed Oct 10 16:50:00 2018 +0000
Revision:
12:7a56e0705c9d
Parent:
11:9683d014dece
Child:
13:da8c0fa4de44
v3.0.2 Updated API.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jeej 0:87c57e1b1e1c 1 #include "files.h"
Jeej 0:87c57e1b1e1c 2 #include "hwcfg.h"
Jeej 0:87c57e1b1e1c 3
Jeej 0:87c57e1b1e1c 4 #include "kal_fs.h"
Jeej 0:87c57e1b1e1c 5
Jeej 0:87c57e1b1e1c 6 #define __DEVICE_ID__ 0x00000010
Jeej 0:87c57e1b1e1c 7
Jeej 0:87c57e1b1e1c 8 alp_file_header_t h_rev = {
Jeej 0:87c57e1b1e1c 9 .perm = RW_R,
Jeej 0:87c57e1b1e1c 10 .prop = FS_PERMANENT_NOTIF,
Jeej 0:87c57e1b1e1c 11 .afid = FID_ACTP_RPT_FULL,
Jeej 0:87c57e1b1e1c 12 .ifid = IFID_REPORT,
Jeej 0:87c57e1b1e1c 13 .size = HAL_U32_BYTE_SWAP((uint32_t)sizeof(revision_t)),
Jeej 0:87c57e1b1e1c 14 .alloc= HAL_U32_BYTE_SWAP((uint32_t)sizeof(revision_t))
Jeej 0:87c57e1b1e1c 15 };
Jeej 0:87c57e1b1e1c 16
Jeej 0:87c57e1b1e1c 17 revision_t f_rev = {
Jeej 0:87c57e1b1e1c 18 .manufacturer_id = __MANUFACTURER_ID__,
Jeej 0:87c57e1b1e1c 19 /// Device ID: Arbitrary number, at user/customer choice
Jeej 0:87c57e1b1e1c 20 .device_id = __DEVICE_ID__,
Jeej 0:87c57e1b1e1c 21 /// Hardware Board ID:
Jeej 0:87c57e1b1e1c 22 .hw_version = __HW_VERSION__,
Jeej 0:87c57e1b1e1c 23 /// Firmware Version: made of
Jeej 0:87c57e1b1e1c 24 /// - major,minor and patch indexes
Jeej 0:87c57e1b1e1c 25 /// - fw_id : "build-flavour"
Jeej 0:87c57e1b1e1c 26 /// FW_ID | MAJOR | MINOR | PATCH | HASH |
Jeej 0:87c57e1b1e1c 27 // 1B | 1B | 1B | 2B | 4B |
Jeej 0:87c57e1b1e1c 28 .fw_version.id = 2,
Jeej 0:87c57e1b1e1c 29 .fw_version.major = 3,
Jeej 0:87c57e1b1e1c 30 .fw_version.minor = 0,
Jeej 12:7a56e0705c9d 31 .fw_version.patch = 2,
Jeej 0:87c57e1b1e1c 32 .fw_version.hash = 0x00000000,
Jeej 5:e27f8429166a 33 /// Not used
Jeej 5:e27f8429166a 34 .cup_max_size = 0x00000000
Jeej 0:87c57e1b1e1c 35 };
Jeej 0:87c57e1b1e1c 36
Jeej 0:87c57e1b1e1c 37 alp_file_header_t h_alarm = {
Jeej 0:87c57e1b1e1c 38 .perm = RW_R,
Jeej 0:87c57e1b1e1c 39 .prop = FS_VOLATILE,
Jeej 0:87c57e1b1e1c 40 .afid = 0,
Jeej 0:87c57e1b1e1c 41 .ifid = 0,
Jeej 0:87c57e1b1e1c 42 .size = HAL_U32_BYTE_SWAP((uint32_t)sizeof(uint8_t)),
Jeej 0:87c57e1b1e1c 43 .alloc= HAL_U32_BYTE_SWAP((uint32_t)sizeof(uint8_t))
Jeej 0:87c57e1b1e1c 44 };
Jeej 0:87c57e1b1e1c 45
Jeej 0:87c57e1b1e1c 46 uint8_t f_alarm = 255;
Jeej 0:87c57e1b1e1c 47
Jeej 0:87c57e1b1e1c 48 #define HEADER_FILE_SENSOR_CONFIG(name) const alp_file_header_t h_sensor_config_##name = {\
Jeej 0:87c57e1b1e1c 49 .perm = RW_R,\
Jeej 0:87c57e1b1e1c 50 .prop = FS_VOLATILE,\
Jeej 0:87c57e1b1e1c 51 .afid = 0,\
Jeej 0:87c57e1b1e1c 52 .ifid = 0,\
Jeej 0:87c57e1b1e1c 53 .size = HAL_U32_BYTE_SWAP((uint32_t)sizeof(sensor_config_t)),\
Jeej 0:87c57e1b1e1c 54 .alloc= HAL_U32_BYTE_SWAP((uint32_t)sizeof(sensor_config_t))\
Jeej 0:87c57e1b1e1c 55 }
Jeej 0:87c57e1b1e1c 56
Jeej 0:87c57e1b1e1c 57 #define HEADER_FILE_SENSOR_VALUE(name,_size) const alp_file_header_t h_sensor_value_##name = {\
Jeej 0:87c57e1b1e1c 58 .perm = RW_R,\
Jeej 0:87c57e1b1e1c 59 .prop = FS_VOLATILE_NOTIF,\
Jeej 0:87c57e1b1e1c 60 .afid = FID_ACTP_RPT_FULL,\
Jeej 0:87c57e1b1e1c 61 .ifid = IFID_REPORT,\
Jeej 0:87c57e1b1e1c 62 .size = HAL_U32_BYTE_SWAP((uint32_t)(_size)),\
Jeej 0:87c57e1b1e1c 63 .alloc= HAL_U32_BYTE_SWAP((uint32_t)(_size))\
Jeej 0:87c57e1b1e1c 64 }
Jeej 0:87c57e1b1e1c 65
Jeej 0:87c57e1b1e1c 66 HEADER_FILE_SENSOR_CONFIG(mag);
Jeej 0:87c57e1b1e1c 67 HEADER_FILE_SENSOR_CONFIG(acc);
Jeej 0:87c57e1b1e1c 68 HEADER_FILE_SENSOR_CONFIG(gyr);
Jeej 0:87c57e1b1e1c 69 HEADER_FILE_SENSOR_CONFIG(pre);
Jeej 0:87c57e1b1e1c 70 HEADER_FILE_SENSOR_CONFIG(hum);
Jeej 0:87c57e1b1e1c 71 HEADER_FILE_SENSOR_CONFIG(tem1);
Jeej 0:87c57e1b1e1c 72 HEADER_FILE_SENSOR_CONFIG(tem2);
Jeej 0:87c57e1b1e1c 73 HEADER_FILE_SENSOR_CONFIG(light);
Jeej 0:87c57e1b1e1c 74
Jeej 0:87c57e1b1e1c 75 HEADER_FILE_SENSOR_VALUE(mag, 3*sizeof(int32_t));
Jeej 0:87c57e1b1e1c 76 HEADER_FILE_SENSOR_VALUE(acc, 3*sizeof(int32_t));
Jeej 0:87c57e1b1e1c 77 HEADER_FILE_SENSOR_VALUE(gyr, 3*sizeof(int32_t));
Jeej 0:87c57e1b1e1c 78 HEADER_FILE_SENSOR_VALUE(pre, 1*sizeof(int32_t));
Jeej 0:87c57e1b1e1c 79 HEADER_FILE_SENSOR_VALUE(hum, 1*sizeof(int32_t));
Jeej 0:87c57e1b1e1c 80 HEADER_FILE_SENSOR_VALUE(tem1, 1*sizeof(int32_t));
Jeej 0:87c57e1b1e1c 81 HEADER_FILE_SENSOR_VALUE(tem2, 1*sizeof(int32_t));
Jeej 0:87c57e1b1e1c 82 HEADER_FILE_SENSOR_VALUE(light, 1*sizeof(int32_t));
Jeej 0:87c57e1b1e1c 83
Jeej 0:87c57e1b1e1c 84 sensor_config_t f_sensor_config_mag = {
Jeej 0:87c57e1b1e1c 85 .report_type = REPORT_ON_DIFFERENCE,
Jeej 0:87c57e1b1e1c 86 .read_period = 1000,
Jeej 0:87c57e1b1e1c 87 .max_period = 3600,
Jeej 0:87c57e1b1e1c 88 .max_diff = 500,
Jeej 0:87c57e1b1e1c 89 .threshold_high = 1000,
Jeej 0:87c57e1b1e1c 90 .threshold_low = -1000,
Jeej 0:87c57e1b1e1c 91 };
Jeej 0:87c57e1b1e1c 92
Jeej 0:87c57e1b1e1c 93 sensor_config_t f_sensor_config_acc = {
Jeej 0:87c57e1b1e1c 94 .report_type = REPORT_ON_DIFFERENCE,
Jeej 0:87c57e1b1e1c 95 .read_period = 1000,
Jeej 0:87c57e1b1e1c 96 .max_period = 3600,
Jeej 0:87c57e1b1e1c 97 .max_diff = 100,
Jeej 0:87c57e1b1e1c 98 .threshold_high = 500,
Jeej 0:87c57e1b1e1c 99 .threshold_low = -500,
Jeej 0:87c57e1b1e1c 100 };
Jeej 0:87c57e1b1e1c 101
Jeej 0:87c57e1b1e1c 102 sensor_config_t f_sensor_config_gyr = {
Jeej 0:87c57e1b1e1c 103 .report_type = REPORT_ON_DIFFERENCE,
Jeej 0:87c57e1b1e1c 104 .read_period = 1000,
Jeej 0:87c57e1b1e1c 105 .max_period = 3600,
Jeej 0:87c57e1b1e1c 106 .max_diff = 1000,
Jeej 0:87c57e1b1e1c 107 .threshold_high = 10000,
Jeej 0:87c57e1b1e1c 108 .threshold_low = -10000,
Jeej 0:87c57e1b1e1c 109 };
Jeej 0:87c57e1b1e1c 110
Jeej 0:87c57e1b1e1c 111 sensor_config_t f_sensor_config_pre = {
Jeej 0:87c57e1b1e1c 112 .report_type = REPORT_ON_DIFFERENCE,
Jeej 0:87c57e1b1e1c 113 .read_period = 1000,
Jeej 0:87c57e1b1e1c 114 .max_period = 3600,
Jeej 0:87c57e1b1e1c 115 .max_diff = 100,
Jeej 0:87c57e1b1e1c 116 .threshold_high = 120000,
Jeej 0:87c57e1b1e1c 117 .threshold_low = 90000,
Jeej 0:87c57e1b1e1c 118 };
Jeej 0:87c57e1b1e1c 119
Jeej 0:87c57e1b1e1c 120 sensor_config_t f_sensor_config_hum = {
Jeej 0:87c57e1b1e1c 121 .report_type = REPORT_ON_DIFFERENCE,
Jeej 0:87c57e1b1e1c 122 .read_period = 1000,
Jeej 0:87c57e1b1e1c 123 .max_period = 3600,
Jeej 0:87c57e1b1e1c 124 .max_diff = 100,
Jeej 0:87c57e1b1e1c 125 .threshold_high = 7000,
Jeej 0:87c57e1b1e1c 126 .threshold_low = 3000,
Jeej 0:87c57e1b1e1c 127 };
Jeej 0:87c57e1b1e1c 128
Jeej 0:87c57e1b1e1c 129 sensor_config_t f_sensor_config_tem1 = {
Jeej 0:87c57e1b1e1c 130 .report_type = REPORT_ON_DIFFERENCE,
Jeej 0:87c57e1b1e1c 131 .read_period = 1000,
Jeej 0:87c57e1b1e1c 132 .max_period = 3600,
Jeej 0:87c57e1b1e1c 133 .max_diff = 100,
Jeej 0:87c57e1b1e1c 134 .threshold_high = 3500,
Jeej 0:87c57e1b1e1c 135 .threshold_low = 2000,
Jeej 0:87c57e1b1e1c 136 };
Jeej 0:87c57e1b1e1c 137
Jeej 0:87c57e1b1e1c 138 sensor_config_t f_sensor_config_tem2 = {
Jeej 0:87c57e1b1e1c 139 .report_type = REPORT_ON_DIFFERENCE,
Jeej 0:87c57e1b1e1c 140 .read_period = 1000,
Jeej 0:87c57e1b1e1c 141 .max_period = 3600,
Jeej 0:87c57e1b1e1c 142 .max_diff = 100,
Jeej 0:87c57e1b1e1c 143 .threshold_high = 9000,
Jeej 0:87c57e1b1e1c 144 .threshold_low = 7000,
Jeej 0:87c57e1b1e1c 145 };
Jeej 0:87c57e1b1e1c 146
Jeej 0:87c57e1b1e1c 147 sensor_config_t f_sensor_config_light = {
Jeej 0:87c57e1b1e1c 148 .report_type = REPORT_ON_DIFFERENCE,
Jeej 0:87c57e1b1e1c 149 .read_period = 1000, // ms
Jeej 0:87c57e1b1e1c 150 .max_period = 3600, // sec
Jeej 6:c17f7cbdeb1a 151 .max_diff = 100,
Jeej 0:87c57e1b1e1c 152 .threshold_high = 0, // disabled
Jeej 6:c17f7cbdeb1a 153 .threshold_low = 1000, // disabled
Jeej 0:87c57e1b1e1c 154 };