pwm period is now 200us instead of the default 20ms veml6040 config is now AF_BIT | TRIG_BIT
Dependencies: mbed MMA8451Q USBDevice WakeUp vt100
Fork of afero_node_suntory_2017_06_15 by
preferences/Preferences.hpp@2:dfe671e31221, 2017-01-24 (annotated)
- Committer:
- wataloh
- Date:
- Tue Jan 24 10:00:28 2017 +0000
- Revision:
- 2:dfe671e31221
- Parent:
- 1:b2a9a6f2c30e
- Child:
- 3:6dec44cbb664
latest
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wataloh | 1:b2a9a6f2c30e | 1 | #ifndef _PREFERENCES_HPP_ |
wataloh | 1:b2a9a6f2c30e | 2 | #define _PREFERENCES_HPP_ |
wataloh | 1:b2a9a6f2c30e | 3 | |
wataloh | 1:b2a9a6f2c30e | 4 | #include "mbed.h" |
wataloh | 1:b2a9a6f2c30e | 5 | |
wataloh | 1:b2a9a6f2c30e | 6 | namespace MaruSolSensorManager |
wataloh | 1:b2a9a6f2c30e | 7 | { |
wataloh | 1:b2a9a6f2c30e | 8 | |
wataloh | 1:b2a9a6f2c30e | 9 | typedef union |
wataloh | 1:b2a9a6f2c30e | 10 | { |
wataloh | 1:b2a9a6f2c30e | 11 | bool b; |
wataloh | 1:b2a9a6f2c30e | 12 | int16_t i_16; |
wataloh | 1:b2a9a6f2c30e | 13 | uint16_t ui_16; |
wataloh | 1:b2a9a6f2c30e | 14 | struct |
wataloh | 1:b2a9a6f2c30e | 15 | { |
wataloh | 1:b2a9a6f2c30e | 16 | short X, Y, Z; |
wataloh | 1:b2a9a6f2c30e | 17 | }; |
wataloh | 1:b2a9a6f2c30e | 18 | struct |
wataloh | 1:b2a9a6f2c30e | 19 | { |
wataloh | 1:b2a9a6f2c30e | 20 | uint16_t R, G, B; |
wataloh | 1:b2a9a6f2c30e | 21 | }; |
wataloh | 1:b2a9a6f2c30e | 22 | } VAR; |
wataloh | 1:b2a9a6f2c30e | 23 | |
wataloh | 1:b2a9a6f2c30e | 24 | template<typename A> struct SENSORS_BASE |
wataloh | 1:b2a9a6f2c30e | 25 | { |
wataloh | 1:b2a9a6f2c30e | 26 | enum INDEX |
wataloh | 1:b2a9a6f2c30e | 27 | { |
wataloh | 1:b2a9a6f2c30e | 28 | ACCELEROMETER = 0, |
wataloh | 1:b2a9a6f2c30e | 29 | COLOR, |
wataloh | 1:b2a9a6f2c30e | 30 | PRESSURE, |
wataloh | 1:b2a9a6f2c30e | 31 | CURRENT_TRANS, |
wataloh | 1:b2a9a6f2c30e | 32 | TEMPERATURE, |
wataloh | 1:b2a9a6f2c30e | 33 | SIZE, |
wataloh | 1:b2a9a6f2c30e | 34 | }; |
wataloh | 1:b2a9a6f2c30e | 35 | static bool ACTIVE[SIZE]; |
wataloh | 1:b2a9a6f2c30e | 36 | }; |
wataloh | 1:b2a9a6f2c30e | 37 | |
wataloh | 1:b2a9a6f2c30e | 38 | struct SENSORS : public SENSORS_BASE<SENSORS> |
wataloh | 1:b2a9a6f2c30e | 39 | { |
wataloh | 1:b2a9a6f2c30e | 40 | template<typename A> struct COMMONPARAMS; |
wataloh | 1:b2a9a6f2c30e | 41 | struct MAX44008; |
wataloh | 2:dfe671e31221 | 42 | struct VEML6040; |
wataloh | 1:b2a9a6f2c30e | 43 | struct MMA8451Q; |
wataloh | 1:b2a9a6f2c30e | 44 | template<typename A> struct SEMITEC_502AT_11_CALIB; |
wataloh | 1:b2a9a6f2c30e | 45 | struct SEMITEC_502AT_11; |
wataloh | 1:b2a9a6f2c30e | 46 | struct SR_3702_150N_14Z; |
wataloh | 1:b2a9a6f2c30e | 47 | template<typename A> struct KEYENCE_PRESSURE_COMMON_PARAMS; |
wataloh | 1:b2a9a6f2c30e | 48 | struct AP_53A_KEYENCE; //AP-53A KEYENCE gas |
wataloh | 1:b2a9a6f2c30e | 49 | struct GP_M010_KEYENCE; //"GP-M010 KEYENCE" liquid |
wataloh | 1:b2a9a6f2c30e | 50 | }; |
wataloh | 1:b2a9a6f2c30e | 51 | |
wataloh | 2:dfe671e31221 | 52 | template<typename A> struct SENSORS::COMMONPARAMS |
wataloh | 2:dfe671e31221 | 53 | { |
wataloh | 2:dfe671e31221 | 54 | static char* TYPE; |
wataloh | 2:dfe671e31221 | 55 | static char* PN; |
wataloh | 2:dfe671e31221 | 56 | static char* UNIT; |
wataloh | 2:dfe671e31221 | 57 | static char* JSON_FMT; |
wataloh | 2:dfe671e31221 | 58 | }; |
wataloh | 2:dfe671e31221 | 59 | |
wataloh | 1:b2a9a6f2c30e | 60 | template<typename A> struct SENSORS::KEYENCE_PRESSURE_COMMON_PARAMS |
wataloh | 1:b2a9a6f2c30e | 61 | { |
wataloh | 1:b2a9a6f2c30e | 62 | static float V_REF; |
wataloh | 1:b2a9a6f2c30e | 63 | static float PRESSURE_INTERVAL; |
wataloh | 1:b2a9a6f2c30e | 64 | static float SHUNT_R; |
wataloh | 1:b2a9a6f2c30e | 65 | static float LOWEST_CUR; |
wataloh | 1:b2a9a6f2c30e | 66 | static float PRESSURE_COEF; |
wataloh | 1:b2a9a6f2c30e | 67 | }; |
wataloh | 1:b2a9a6f2c30e | 68 | |
wataloh | 1:b2a9a6f2c30e | 69 | template<typename A> float SENSORS::KEYENCE_PRESSURE_COMMON_PARAMS<A>::V_REF = 3.3; |
wataloh | 1:b2a9a6f2c30e | 70 | template<typename A> float SENSORS::KEYENCE_PRESSURE_COMMON_PARAMS<A>::PRESSURE_INTERVAL = 1.0; |
wataloh | 1:b2a9a6f2c30e | 71 | template<typename A> float SENSORS::KEYENCE_PRESSURE_COMMON_PARAMS<A>::SHUNT_R = 165; |
wataloh | 1:b2a9a6f2c30e | 72 | template<typename A> float SENSORS::KEYENCE_PRESSURE_COMMON_PARAMS<A>::LOWEST_CUR = 0.004; |
wataloh | 1:b2a9a6f2c30e | 73 | template<typename A> float SENSORS::KEYENCE_PRESSURE_COMMON_PARAMS<A>::PRESSURE_COEF = 62500; |
wataloh | 1:b2a9a6f2c30e | 74 | |
wataloh | 2:dfe671e31221 | 75 | template<> bool SENSORS_BASE<SENSORS>::ACTIVE[SENSORS::SIZE] = { false, true, true, true, true }; |
wataloh | 1:b2a9a6f2c30e | 76 | |
wataloh | 1:b2a9a6f2c30e | 77 | |
wataloh | 1:b2a9a6f2c30e | 78 | struct SENSORS::MAX44008 : public SENSORS::COMMONPARAMS<SENSORS::MAX44008> |
wataloh | 1:b2a9a6f2c30e | 79 | { |
wataloh | 1:b2a9a6f2c30e | 80 | enum |
wataloh | 1:b2a9a6f2c30e | 81 | { |
wataloh | 1:b2a9a6f2c30e | 82 | ADDRESS = 0x41, |
wataloh | 1:b2a9a6f2c30e | 83 | AMB_CONFIG = 0x00, // most sensitive gain |
wataloh | 2:dfe671e31221 | 84 | RAW_MODE = 0x20, // MODE_CLEAR_RGB_IR |
wataloh | 2:dfe671e31221 | 85 | PWM_LED_B = 0x96 |
wataloh | 1:b2a9a6f2c30e | 86 | }; |
wataloh | 1:b2a9a6f2c30e | 87 | struct TRIM |
wataloh | 1:b2a9a6f2c30e | 88 | { |
wataloh | 1:b2a9a6f2c30e | 89 | enum |
wataloh | 1:b2a9a6f2c30e | 90 | { |
wataloh | 1:b2a9a6f2c30e | 91 | R = 0x50, |
wataloh | 1:b2a9a6f2c30e | 92 | G = 0x01, |
wataloh | 1:b2a9a6f2c30e | 93 | B = 0x20 |
wataloh | 1:b2a9a6f2c30e | 94 | }; |
wataloh | 1:b2a9a6f2c30e | 95 | }; |
wataloh | 1:b2a9a6f2c30e | 96 | }; |
wataloh | 1:b2a9a6f2c30e | 97 | |
wataloh | 1:b2a9a6f2c30e | 98 | template<> char* SENSORS::COMMONPARAMS<SENSORS::MAX44008>::TYPE = "COLOR"; |
wataloh | 1:b2a9a6f2c30e | 99 | template<> char* SENSORS::COMMONPARAMS<SENSORS::MAX44008>::PN = "MAX44008"; |
wataloh | 1:b2a9a6f2c30e | 100 | template<> char* SENSORS::COMMONPARAMS<SENSORS::MAX44008>::UNIT = "mW/cm2"; |
wataloh | 1:b2a9a6f2c30e | 101 | template<> char* SENSORS::COMMONPARAMS<SENSORS::MAX44008>::JSON_FMT( |
wataloh | 1:b2a9a6f2c30e | 102 | "{\"DEVICE\":\"%s\",\"PN\":\"%s\",\"DATA\":[{\"TIME\":\"%ld\",\"VAL\":\"%d\",\"UNIT\":\"%s\"}]}" |
wataloh | 1:b2a9a6f2c30e | 103 | ); |
wataloh | 1:b2a9a6f2c30e | 104 | |
wataloh | 2:dfe671e31221 | 105 | |
wataloh | 2:dfe671e31221 | 106 | struct SENSORS::VEML6040 : public SENSORS::COMMONPARAMS<SENSORS::VEML6040> |
wataloh | 2:dfe671e31221 | 107 | { |
wataloh | 2:dfe671e31221 | 108 | enum |
wataloh | 2:dfe671e31221 | 109 | { |
wataloh | 2:dfe671e31221 | 110 | ADDRESS = 0x10, |
wataloh | 2:dfe671e31221 | 111 | AMB_CONFIG = 0x00, // most sensitive gain |
wataloh | 2:dfe671e31221 | 112 | RAW_MODE = 0x20, // MODE_CLEAR_RGB_IR |
wataloh | 2:dfe671e31221 | 113 | PWM_LED_B = 0xFA |
wataloh | 2:dfe671e31221 | 114 | }; |
wataloh | 2:dfe671e31221 | 115 | struct TRIM |
wataloh | 2:dfe671e31221 | 116 | { |
wataloh | 2:dfe671e31221 | 117 | enum |
wataloh | 2:dfe671e31221 | 118 | { |
wataloh | 2:dfe671e31221 | 119 | R = 0x50, |
wataloh | 2:dfe671e31221 | 120 | G = 0x01, |
wataloh | 2:dfe671e31221 | 121 | B = 0x20 |
wataloh | 2:dfe671e31221 | 122 | }; |
wataloh | 2:dfe671e31221 | 123 | }; |
wataloh | 2:dfe671e31221 | 124 | }; |
wataloh | 2:dfe671e31221 | 125 | |
wataloh | 2:dfe671e31221 | 126 | template<> char* SENSORS::COMMONPARAMS<SENSORS::VEML6040>::TYPE = "COLOR"; |
wataloh | 2:dfe671e31221 | 127 | template<> char* SENSORS::COMMONPARAMS<SENSORS::VEML6040>::PN = "VEML6040"; |
wataloh | 2:dfe671e31221 | 128 | template<> char* SENSORS::COMMONPARAMS<SENSORS::VEML6040>::UNIT = "mW/cm2"; |
wataloh | 2:dfe671e31221 | 129 | template<> char* SENSORS::COMMONPARAMS<SENSORS::VEML6040>::JSON_FMT( |
wataloh | 2:dfe671e31221 | 130 | "{\"DEVICE\":\"%s\",\"PN\":\"%s\",\"DATA\":[{\"TIME\":\"%ld\",\"VAL\":\"%d\",\"UNIT\":\"%s\"}]}" |
wataloh | 2:dfe671e31221 | 131 | ); |
wataloh | 2:dfe671e31221 | 132 | |
wataloh | 2:dfe671e31221 | 133 | |
wataloh | 2:dfe671e31221 | 134 | |
wataloh | 2:dfe671e31221 | 135 | struct SENSORS::MMA8451Q : public SENSORS::COMMONPARAMS<SENSORS::MMA8451Q> |
wataloh | 1:b2a9a6f2c30e | 136 | { |
wataloh | 1:b2a9a6f2c30e | 137 | enum |
wataloh | 1:b2a9a6f2c30e | 138 | { |
wataloh | 1:b2a9a6f2c30e | 139 | #if defined (TARGET_KL25Z) |
wataloh | 1:b2a9a6f2c30e | 140 | ADDRESS = 0x1D |
wataloh | 1:b2a9a6f2c30e | 141 | #elif defined (TARGET_TEENSY3_1) |
wataloh | 1:b2a9a6f2c30e | 142 | ADDRESS = 0x1C |
wataloh | 1:b2a9a6f2c30e | 143 | #endif |
wataloh | 1:b2a9a6f2c30e | 144 | }; |
wataloh | 1:b2a9a6f2c30e | 145 | }; |
wataloh | 1:b2a9a6f2c30e | 146 | template<> char* SENSORS::COMMONPARAMS<SENSORS::MMA8451Q>::TYPE = "ACCELEROMETER"; |
wataloh | 1:b2a9a6f2c30e | 147 | template<> char* SENSORS::COMMONPARAMS<SENSORS::MMA8451Q>::PN = "MMA8451Q"; |
wataloh | 1:b2a9a6f2c30e | 148 | template<> char* SENSORS::COMMONPARAMS<SENSORS::MMA8451Q>::UNIT = "g"; |
wataloh | 1:b2a9a6f2c30e | 149 | template<> char* SENSORS::COMMONPARAMS<SENSORS::MMA8451Q>::JSON_FMT = |
wataloh | 1:b2a9a6f2c30e | 150 | "{\"DEVICE\":\"%s\",\"PN\":\"%s\",\"DATA\":[{\"TIME\":\"%ld\",\"VAL\":[\"%.1f\",\"%.1f\",\"%.1f\"],\"UNIT\":\"%s\"}]}"; |
wataloh | 1:b2a9a6f2c30e | 151 | |
wataloh | 1:b2a9a6f2c30e | 152 | template<typename A> struct SENSORS::SEMITEC_502AT_11_CALIB |
wataloh | 1:b2a9a6f2c30e | 153 | { |
wataloh | 1:b2a9a6f2c30e | 154 | static float B; |
wataloh | 1:b2a9a6f2c30e | 155 | static float T0; |
wataloh | 1:b2a9a6f2c30e | 156 | static float R0; |
wataloh | 1:b2a9a6f2c30e | 157 | static float R1; |
wataloh | 1:b2a9a6f2c30e | 158 | }; |
wataloh | 1:b2a9a6f2c30e | 159 | |
wataloh | 1:b2a9a6f2c30e | 160 | struct SENSORS::SEMITEC_502AT_11 : |
wataloh | 1:b2a9a6f2c30e | 161 | public SENSORS::COMMONPARAMS<SENSORS::SEMITEC_502AT_11>, |
wataloh | 1:b2a9a6f2c30e | 162 | public SENSORS::SEMITEC_502AT_11_CALIB<SENSORS::SEMITEC_502AT_11>{}; |
wataloh | 1:b2a9a6f2c30e | 163 | template<> float SENSORS::SEMITEC_502AT_11_CALIB<SENSORS::SEMITEC_502AT_11>::B = 3324; |
wataloh | 1:b2a9a6f2c30e | 164 | template<> float SENSORS::SEMITEC_502AT_11_CALIB<SENSORS::SEMITEC_502AT_11>::T0 = 298.15; |
wataloh | 1:b2a9a6f2c30e | 165 | template<> float SENSORS::SEMITEC_502AT_11_CALIB<SENSORS::SEMITEC_502AT_11>::R0 = 5.0; //kOhm |
wataloh | 1:b2a9a6f2c30e | 166 | template<> float SENSORS::SEMITEC_502AT_11_CALIB<SENSORS::SEMITEC_502AT_11>::R1 = 4.95; //kOhm |
wataloh | 1:b2a9a6f2c30e | 167 | |
wataloh | 1:b2a9a6f2c30e | 168 | template<> char* SENSORS::COMMONPARAMS<SENSORS::SEMITEC_502AT_11>::TYPE = "TEMP"; |
wataloh | 1:b2a9a6f2c30e | 169 | template<> char* SENSORS::COMMONPARAMS<SENSORS::SEMITEC_502AT_11>::PN = "SEMITEC 502AT-11"; |
wataloh | 1:b2a9a6f2c30e | 170 | template<> char* SENSORS::COMMONPARAMS<SENSORS::SEMITEC_502AT_11>::UNIT = "degC"; |
wataloh | 1:b2a9a6f2c30e | 171 | template<> char* SENSORS::COMMONPARAMS<SENSORS::SEMITEC_502AT_11>::JSON_FMT( |
wataloh | 1:b2a9a6f2c30e | 172 | "{\"DEVICE\":\"%s\",\"PN\":\"%s\",\"DATA\":[{\"TIME\":\"%ld\",\"VAL\":\"%0.1f\",\"UNIT\":\"%s\"}]}" |
wataloh | 1:b2a9a6f2c30e | 173 | ); |
wataloh | 1:b2a9a6f2c30e | 174 | |
wataloh | 1:b2a9a6f2c30e | 175 | struct SENSORS::SR_3702_150N_14Z : public SENSORS::COMMONPARAMS<SENSORS::SR_3702_150N_14Z>{}; |
wataloh | 1:b2a9a6f2c30e | 176 | template<> char* SENSORS::COMMONPARAMS<SENSORS::SR_3702_150N_14Z>::TYPE = "CURRENT_TRANS";; |
wataloh | 1:b2a9a6f2c30e | 177 | template<> char* SENSORS::COMMONPARAMS<SENSORS::SR_3702_150N_14Z>::PN = "SR-3702-150N/14Z"; |
wataloh | 1:b2a9a6f2c30e | 178 | template<> char* SENSORS::COMMONPARAMS<SENSORS::SR_3702_150N_14Z>::UNIT = "V"; |
wataloh | 1:b2a9a6f2c30e | 179 | template<> char* SENSORS::COMMONPARAMS<SENSORS::SR_3702_150N_14Z>::JSON_FMT( |
wataloh | 1:b2a9a6f2c30e | 180 | "{\"DEVICE\":\"%s\",\"PN\":\"%s\",\"DATA\":[{\"TIME\":\"%ld\",\"VAL\":\"%0.1f\",\"UNIT\":\"%s\"}]}" |
wataloh | 1:b2a9a6f2c30e | 181 | ); |
wataloh | 1:b2a9a6f2c30e | 182 | struct SENSORS::AP_53A_KEYENCE : |
wataloh | 1:b2a9a6f2c30e | 183 | public SENSORS::COMMONPARAMS<SENSORS::AP_53A_KEYENCE>, |
wataloh | 1:b2a9a6f2c30e | 184 | public SENSORS::KEYENCE_PRESSURE_COMMON_PARAMS<SENSORS::AP_53A_KEYENCE> {}; |
wataloh | 1:b2a9a6f2c30e | 185 | template<> char *SENSORS::COMMONPARAMS<SENSORS::AP_53A_KEYENCE>::TYPE = "GAS PRESSURE"; |
wataloh | 1:b2a9a6f2c30e | 186 | template<> char *SENSORS::COMMONPARAMS<SENSORS::AP_53A_KEYENCE>::PN = "AP-53A KEYENCE"; |
wataloh | 1:b2a9a6f2c30e | 187 | template<> char *SENSORS::COMMONPARAMS<SENSORS::AP_53A_KEYENCE>::UNIT = "KPa"; |
wataloh | 1:b2a9a6f2c30e | 188 | template<> char* SENSORS::COMMONPARAMS<SENSORS::AP_53A_KEYENCE>::JSON_FMT( |
wataloh | 1:b2a9a6f2c30e | 189 | "{\"DEVICE\":\"%s\",\"PN\":\"%s\",\"DATA\":[{\"TIME\":\"%ld\",\"VAL\":\"%0.1f\",\"UNIT\":\"%s\"}]}" |
wataloh | 1:b2a9a6f2c30e | 190 | ); |
wataloh | 1:b2a9a6f2c30e | 191 | |
wataloh | 1:b2a9a6f2c30e | 192 | struct SENSORS::GP_M010_KEYENCE : |
wataloh | 1:b2a9a6f2c30e | 193 | public SENSORS::COMMONPARAMS<SENSORS::GP_M010_KEYENCE>, |
wataloh | 1:b2a9a6f2c30e | 194 | public SENSORS::KEYENCE_PRESSURE_COMMON_PARAMS<SENSORS::GP_M010_KEYENCE> {}; |
wataloh | 1:b2a9a6f2c30e | 195 | template<> char *SENSORS::COMMONPARAMS<SENSORS::GP_M010_KEYENCE>::TYPE = "LIQUID PRESSURE"; |
wataloh | 1:b2a9a6f2c30e | 196 | template<> char *SENSORS::COMMONPARAMS<SENSORS::GP_M010_KEYENCE>::PN = "AGP-M010 KEYENCE"; |
wataloh | 1:b2a9a6f2c30e | 197 | template<> char *SENSORS::COMMONPARAMS<SENSORS::GP_M010_KEYENCE>::UNIT = "KPa"; |
wataloh | 1:b2a9a6f2c30e | 198 | template<> char* SENSORS::COMMONPARAMS<SENSORS::GP_M010_KEYENCE>::JSON_FMT( |
wataloh | 1:b2a9a6f2c30e | 199 | "{\"DEVICE\":\"%s\",\"PN\":\"%s\",\"DATA\":[{\"TIME\":\"%ld\",\"VAL\":\"%0.1f\",\"UNIT\":\"%s\"}]}" |
wataloh | 1:b2a9a6f2c30e | 200 | ); |
wataloh | 1:b2a9a6f2c30e | 201 | |
wataloh | 1:b2a9a6f2c30e | 202 | struct PINS |
wataloh | 1:b2a9a6f2c30e | 203 | { |
wataloh | 1:b2a9a6f2c30e | 204 | struct LED_4_COLOR; |
wataloh | 1:b2a9a6f2c30e | 205 | struct COLOR; |
wataloh | 1:b2a9a6f2c30e | 206 | struct ACCELEROMETER; |
wataloh | 1:b2a9a6f2c30e | 207 | struct CURRENT_TRANS; |
wataloh | 1:b2a9a6f2c30e | 208 | struct TEMPERATURE; |
wataloh | 1:b2a9a6f2c30e | 209 | struct UART; |
wataloh | 1:b2a9a6f2c30e | 210 | struct ASR_1; |
wataloh | 1:b2a9a6f2c30e | 211 | struct GAS; |
wataloh | 1:b2a9a6f2c30e | 212 | struct LIQUID; |
wataloh | 1:b2a9a6f2c30e | 213 | }; |
wataloh | 1:b2a9a6f2c30e | 214 | |
wataloh | 1:b2a9a6f2c30e | 215 | struct PINS::LED_4_COLOR |
wataloh | 1:b2a9a6f2c30e | 216 | { |
wataloh | 1:b2a9a6f2c30e | 217 | enum |
wataloh | 1:b2a9a6f2c30e | 218 | { |
wataloh | 1:b2a9a6f2c30e | 219 | R = PTA5, |
wataloh | 1:b2a9a6f2c30e | 220 | G = PTA4, |
wataloh | 1:b2a9a6f2c30e | 221 | B = PTA12 |
wataloh | 1:b2a9a6f2c30e | 222 | }; |
wataloh | 1:b2a9a6f2c30e | 223 | }; |
wataloh | 1:b2a9a6f2c30e | 224 | |
wataloh | 1:b2a9a6f2c30e | 225 | struct PINS::COLOR |
wataloh | 1:b2a9a6f2c30e | 226 | { |
wataloh | 1:b2a9a6f2c30e | 227 | enum |
wataloh | 1:b2a9a6f2c30e | 228 | { |
wataloh | 1:b2a9a6f2c30e | 229 | SDA = PTE0, |
wataloh | 1:b2a9a6f2c30e | 230 | SCL = PTE1 |
wataloh | 1:b2a9a6f2c30e | 231 | }; |
wataloh | 1:b2a9a6f2c30e | 232 | }; |
wataloh | 1:b2a9a6f2c30e | 233 | |
wataloh | 1:b2a9a6f2c30e | 234 | struct PINS::ACCELEROMETER |
wataloh | 1:b2a9a6f2c30e | 235 | { |
wataloh | 1:b2a9a6f2c30e | 236 | enum |
wataloh | 1:b2a9a6f2c30e | 237 | { |
wataloh | 1:b2a9a6f2c30e | 238 | #if defined (TARGET_KL25Z) |
wataloh | 1:b2a9a6f2c30e | 239 | SDA = PTE25, |
wataloh | 1:b2a9a6f2c30e | 240 | SCL = PTE24 |
wataloh | 1:b2a9a6f2c30e | 241 | #elif defined (TARGET_TEENSY3_1) |
wataloh | 1:b2a9a6f2c30e | 242 | SDA = PTB3, |
wataloh | 1:b2a9a6f2c30e | 243 | SCL = PTB2 |
wataloh | 1:b2a9a6f2c30e | 244 | #endif |
wataloh | 1:b2a9a6f2c30e | 245 | }; |
wataloh | 1:b2a9a6f2c30e | 246 | }; |
wataloh | 1:b2a9a6f2c30e | 247 | |
wataloh | 1:b2a9a6f2c30e | 248 | struct PINS::CURRENT_TRANS |
wataloh | 1:b2a9a6f2c30e | 249 | { |
wataloh | 1:b2a9a6f2c30e | 250 | enum |
wataloh | 1:b2a9a6f2c30e | 251 | { |
wataloh | 1:b2a9a6f2c30e | 252 | AIN = PTB0 |
wataloh | 1:b2a9a6f2c30e | 253 | }; |
wataloh | 1:b2a9a6f2c30e | 254 | }; |
wataloh | 1:b2a9a6f2c30e | 255 | |
wataloh | 1:b2a9a6f2c30e | 256 | struct PINS::TEMPERATURE |
wataloh | 1:b2a9a6f2c30e | 257 | { |
wataloh | 1:b2a9a6f2c30e | 258 | enum |
wataloh | 1:b2a9a6f2c30e | 259 | { |
wataloh | 1:b2a9a6f2c30e | 260 | AIN = PTB1 |
wataloh | 1:b2a9a6f2c30e | 261 | }; |
wataloh | 1:b2a9a6f2c30e | 262 | }; |
wataloh | 1:b2a9a6f2c30e | 263 | |
wataloh | 1:b2a9a6f2c30e | 264 | struct PINS::GAS |
wataloh | 1:b2a9a6f2c30e | 265 | { |
wataloh | 1:b2a9a6f2c30e | 266 | enum |
wataloh | 1:b2a9a6f2c30e | 267 | { |
wataloh | 1:b2a9a6f2c30e | 268 | AIN = PTB2 |
wataloh | 1:b2a9a6f2c30e | 269 | }; |
wataloh | 1:b2a9a6f2c30e | 270 | }; |
wataloh | 1:b2a9a6f2c30e | 271 | |
wataloh | 1:b2a9a6f2c30e | 272 | struct PINS::LIQUID |
wataloh | 1:b2a9a6f2c30e | 273 | { |
wataloh | 1:b2a9a6f2c30e | 274 | enum |
wataloh | 1:b2a9a6f2c30e | 275 | { |
wataloh | 1:b2a9a6f2c30e | 276 | AIN = PTB3 |
wataloh | 1:b2a9a6f2c30e | 277 | }; |
wataloh | 1:b2a9a6f2c30e | 278 | }; |
wataloh | 1:b2a9a6f2c30e | 279 | |
wataloh | 1:b2a9a6f2c30e | 280 | struct PINS::ASR_1 |
wataloh | 1:b2a9a6f2c30e | 281 | { |
wataloh | 1:b2a9a6f2c30e | 282 | struct SPI; |
wataloh | 1:b2a9a6f2c30e | 283 | enum |
wataloh | 1:b2a9a6f2c30e | 284 | { |
wataloh | 1:b2a9a6f2c30e | 285 | #if defined (TARGET_KL25Z) |
wataloh | 1:b2a9a6f2c30e | 286 | RESET = PTC9 //PSOC //PTA20 |
wataloh | 1:b2a9a6f2c30e | 287 | #elif defined (TARGET_TEENSY3_1) |
wataloh | 1:b2a9a6f2c30e | 288 | RESET = PTD6 |
wataloh | 1:b2a9a6f2c30e | 289 | #endif |
wataloh | 1:b2a9a6f2c30e | 290 | }; |
wataloh | 1:b2a9a6f2c30e | 291 | struct SIG |
wataloh | 1:b2a9a6f2c30e | 292 | { |
wataloh | 1:b2a9a6f2c30e | 293 | template<typename A> struct RESET_BASE |
wataloh | 1:b2a9a6f2c30e | 294 | { |
wataloh | 1:b2a9a6f2c30e | 295 | static time_t INTERVAL; |
wataloh | 1:b2a9a6f2c30e | 296 | }; |
wataloh | 1:b2a9a6f2c30e | 297 | struct RESET : public RESET_BASE<RESET> |
wataloh | 1:b2a9a6f2c30e | 298 | { |
wataloh | 1:b2a9a6f2c30e | 299 | enum |
wataloh | 1:b2a9a6f2c30e | 300 | { |
wataloh | 1:b2a9a6f2c30e | 301 | ASSERT = 0, |
wataloh | 1:b2a9a6f2c30e | 302 | DEASSERT = 1 |
wataloh | 1:b2a9a6f2c30e | 303 | }; |
wataloh | 1:b2a9a6f2c30e | 304 | }; |
wataloh | 1:b2a9a6f2c30e | 305 | }; |
wataloh | 1:b2a9a6f2c30e | 306 | }; |
wataloh | 1:b2a9a6f2c30e | 307 | |
wataloh | 1:b2a9a6f2c30e | 308 | template<> time_t PINS::ASR_1::SIG::RESET_BASE<PINS::ASR_1::SIG::RESET>::INTERVAL = 60*5; |
wataloh | 1:b2a9a6f2c30e | 309 | |
wataloh | 1:b2a9a6f2c30e | 310 | struct PINS::ASR_1::SPI |
wataloh | 1:b2a9a6f2c30e | 311 | { |
wataloh | 1:b2a9a6f2c30e | 312 | enum |
wataloh | 1:b2a9a6f2c30e | 313 | { |
wataloh | 1:b2a9a6f2c30e | 314 | #if defined (TARGET_KL25Z) |
wataloh | 1:b2a9a6f2c30e | 315 | MOSI = PTD2, |
wataloh | 1:b2a9a6f2c30e | 316 | MISO = PTD3, |
wataloh | 1:b2a9a6f2c30e | 317 | SCK = PTD1, |
wataloh | 1:b2a9a6f2c30e | 318 | CS = PTD0, |
wataloh | 1:b2a9a6f2c30e | 319 | SR = PTD4 // request from slave |
wataloh | 1:b2a9a6f2c30e | 320 | #elif defined (TARGET_TEENSY3_1) |
wataloh | 1:b2a9a6f2c30e | 321 | MOSI = PTC6, |
wataloh | 1:b2a9a6f2c30e | 322 | MISO = PTC7, |
wataloh | 1:b2a9a6f2c30e | 323 | SCK = PTC5, |
wataloh | 1:b2a9a6f2c30e | 324 | CS = PTC4, |
wataloh | 1:b2a9a6f2c30e | 325 | SR = PTD1 // request from slave |
wataloh | 1:b2a9a6f2c30e | 326 | #endif |
wataloh | 1:b2a9a6f2c30e | 327 | }; |
wataloh | 1:b2a9a6f2c30e | 328 | struct SIG |
wataloh | 1:b2a9a6f2c30e | 329 | { |
wataloh | 1:b2a9a6f2c30e | 330 | struct CS |
wataloh | 1:b2a9a6f2c30e | 331 | { |
wataloh | 1:b2a9a6f2c30e | 332 | enum |
wataloh | 1:b2a9a6f2c30e | 333 | { |
wataloh | 1:b2a9a6f2c30e | 334 | ASSERT = 0, |
wataloh | 1:b2a9a6f2c30e | 335 | DEASSERT = 1 |
wataloh | 1:b2a9a6f2c30e | 336 | }; |
wataloh | 1:b2a9a6f2c30e | 337 | }; |
wataloh | 1:b2a9a6f2c30e | 338 | }; |
wataloh | 1:b2a9a6f2c30e | 339 | enum |
wataloh | 1:b2a9a6f2c30e | 340 | { |
wataloh | 1:b2a9a6f2c30e | 341 | NUM_BITS_PER_FRAME = 8, |
wataloh | 1:b2a9a6f2c30e | 342 | MODE_0 = 0, |
wataloh | 1:b2a9a6f2c30e | 343 | FREQUENCY = 1*1000*1000 |
wataloh | 1:b2a9a6f2c30e | 344 | }; |
wataloh | 1:b2a9a6f2c30e | 345 | }; |
wataloh | 1:b2a9a6f2c30e | 346 | |
wataloh | 1:b2a9a6f2c30e | 347 | struct PINS::UART |
wataloh | 1:b2a9a6f2c30e | 348 | { |
wataloh | 2:dfe671e31221 | 349 | enum |
wataloh | 2:dfe671e31221 | 350 | { |
wataloh | 2:dfe671e31221 | 351 | BAUD_RATE = 115200 |
wataloh | 2:dfe671e31221 | 352 | }; |
wataloh | 1:b2a9a6f2c30e | 353 | #if defined (TARGET_TEENSY3_1) |
wataloh | 1:b2a9a6f2c30e | 354 | enum |
wataloh | 1:b2a9a6f2c30e | 355 | { |
wataloh | 1:b2a9a6f2c30e | 356 | uart0_tx = PTA2, |
wataloh | 1:b2a9a6f2c30e | 357 | uart0_rx = PTA1 |
wataloh | 1:b2a9a6f2c30e | 358 | }; |
wataloh | 1:b2a9a6f2c30e | 359 | #endif |
wataloh | 1:b2a9a6f2c30e | 360 | #if defined (TARGET_KL25Z) && (WICED_SMART_UART_CONNECTION) |
wataloh | 1:b2a9a6f2c30e | 361 | struct WICED |
wataloh | 1:b2a9a6f2c30e | 362 | { |
wataloh | 1:b2a9a6f2c30e | 363 | struct TAG3 |
wataloh | 1:b2a9a6f2c30e | 364 | { |
wataloh | 1:b2a9a6f2c30e | 365 | enum |
wataloh | 1:b2a9a6f2c30e | 366 | { |
wataloh | 1:b2a9a6f2c30e | 367 | TO_RX = PTE22 // -> TAG3 J7-1 |
wataloh | 1:b2a9a6f2c30e | 368 | ,TO_TX = PTE23 // -> TAG3 J8-5 |
wataloh | 1:b2a9a6f2c30e | 369 | //power 3v3 -> TAG J9-1 |
wataloh | 1:b2a9a6f2c30e | 370 | //GND -> TAGJ9-4 |
wataloh | 1:b2a9a6f2c30e | 371 | }; |
wataloh | 1:b2a9a6f2c30e | 372 | }; |
wataloh | 1:b2a9a6f2c30e | 373 | }; |
wataloh | 1:b2a9a6f2c30e | 374 | #endif |
wataloh | 1:b2a9a6f2c30e | 375 | }; |
wataloh | 1:b2a9a6f2c30e | 376 | |
wataloh | 1:b2a9a6f2c30e | 377 | template<typename A> struct PREFERENCES_BASE |
wataloh | 1:b2a9a6f2c30e | 378 | { |
wataloh | 2:dfe671e31221 | 379 | static int32_t SENSING_INTERVAL[SENSORS::SIZE]; |
wataloh | 1:b2a9a6f2c30e | 380 | static time_t EPOCH_UTC; |
wataloh | 1:b2a9a6f2c30e | 381 | typedef union |
wataloh | 1:b2a9a6f2c30e | 382 | { |
wataloh | 1:b2a9a6f2c30e | 383 | uint32_t ui32; |
wataloh | 1:b2a9a6f2c30e | 384 | uint8_t ui8[sizeof(uint32_t)]; |
wataloh | 1:b2a9a6f2c30e | 385 | } _crc32; |
wataloh | 1:b2a9a6f2c30e | 386 | static _crc32 CRC32; |
wataloh | 2:dfe671e31221 | 387 | static bool FLOW_CONTROL; |
wataloh | 2:dfe671e31221 | 388 | static bool DBG_ENABLED; |
wataloh | 2:dfe671e31221 | 389 | static bool DBG_ASR_ENABLED; |
wataloh | 2:dfe671e31221 | 390 | struct AFERO_ATTRIBUTE |
wataloh | 2:dfe671e31221 | 391 | { |
wataloh | 2:dfe671e31221 | 392 | uint32_t ATTR_CRC32; |
wataloh | 2:dfe671e31221 | 393 | }; |
wataloh | 1:b2a9a6f2c30e | 394 | }; |
wataloh | 1:b2a9a6f2c30e | 395 | |
wataloh | 1:b2a9a6f2c30e | 396 | struct PREFERENCES : PREFERENCES_BASE<PREFERENCES> |
wataloh | 1:b2a9a6f2c30e | 397 | { |
wataloh | 1:b2a9a6f2c30e | 398 | struct NOTIFICATION; |
wataloh | 1:b2a9a6f2c30e | 399 | struct DATA_TRANSFER_MODE |
wataloh | 1:b2a9a6f2c30e | 400 | { |
wataloh | 1:b2a9a6f2c30e | 401 | enum |
wataloh | 1:b2a9a6f2c30e | 402 | { |
wataloh | 1:b2a9a6f2c30e | 403 | JSON = 0, |
wataloh | 1:b2a9a6f2c30e | 404 | BASE64 = 1 |
wataloh | 1:b2a9a6f2c30e | 405 | }; |
wataloh | 1:b2a9a6f2c30e | 406 | }; |
wataloh | 1:b2a9a6f2c30e | 407 | struct THRESHOLD |
wataloh | 1:b2a9a6f2c30e | 408 | { |
wataloh | 1:b2a9a6f2c30e | 409 | struct RANGE |
wataloh | 1:b2a9a6f2c30e | 410 | { |
wataloh | 1:b2a9a6f2c30e | 411 | enum |
wataloh | 1:b2a9a6f2c30e | 412 | { |
wataloh | 1:b2a9a6f2c30e | 413 | MIN = 0, |
wataloh | 1:b2a9a6f2c30e | 414 | MAX, |
wataloh | 1:b2a9a6f2c30e | 415 | DELTA, |
wataloh | 1:b2a9a6f2c30e | 416 | SIZE |
wataloh | 1:b2a9a6f2c30e | 417 | }; |
wataloh | 1:b2a9a6f2c30e | 418 | }; |
wataloh | 1:b2a9a6f2c30e | 419 | }; |
wataloh | 1:b2a9a6f2c30e | 420 | template<typename A> struct NOTIFICATION_BASE |
wataloh | 1:b2a9a6f2c30e | 421 | { |
wataloh | 1:b2a9a6f2c30e | 422 | static bool ENABLED[SENSORS::SIZE][THRESHOLD::RANGE::SIZE]; |
wataloh | 1:b2a9a6f2c30e | 423 | static VAR THRESHOLD[SENSORS::SIZE][THRESHOLD::RANGE::SIZE]; // not used ... for now. |
wataloh | 1:b2a9a6f2c30e | 424 | }; |
wataloh | 1:b2a9a6f2c30e | 425 | }; |
wataloh | 1:b2a9a6f2c30e | 426 | |
wataloh | 2:dfe671e31221 | 427 | template<> int32_t PREFERENCES_BASE<PREFERENCES>::SENSING_INTERVAL[SENSORS::SIZE] = { 30, 30, 30, 30, 30 }; |
wataloh | 1:b2a9a6f2c30e | 428 | template<> time_t PREFERENCES_BASE<PREFERENCES>::EPOCH_UTC = 0; |
wataloh | 2:dfe671e31221 | 429 | template<> PREFERENCES_BASE<PREFERENCES>::_crc32 PREFERENCES_BASE<PREFERENCES>::CRC32 = { 0 }; |
wataloh | 2:dfe671e31221 | 430 | |
wataloh | 2:dfe671e31221 | 431 | template<> bool PREFERENCES_BASE<PREFERENCES>::FLOW_CONTROL = false; |
wataloh | 2:dfe671e31221 | 432 | |
wataloh | 2:dfe671e31221 | 433 | template<> bool PREFERENCES_BASE<PREFERENCES>::DBG_ENABLED = true; |
wataloh | 2:dfe671e31221 | 434 | template<> bool PREFERENCES_BASE<PREFERENCES>::DBG_ASR_ENABLED = true; |
wataloh | 1:b2a9a6f2c30e | 435 | |
wataloh | 1:b2a9a6f2c30e | 436 | struct PREFERENCES::NOTIFICATION : public PREFERENCES::NOTIFICATION_BASE<PREFERENCES::NOTIFICATION> |
wataloh | 1:b2a9a6f2c30e | 437 | { |
wataloh | 1:b2a9a6f2c30e | 438 | }; |
wataloh | 1:b2a9a6f2c30e | 439 | |
wataloh | 1:b2a9a6f2c30e | 440 | template<> bool PREFERENCES::NOTIFICATION_BASE<PREFERENCES::NOTIFICATION>::ENABLED[SENSORS::SIZE][THRESHOLD::RANGE::SIZE]; |
wataloh | 1:b2a9a6f2c30e | 441 | template<> VAR PREFERENCES::NOTIFICATION_BASE<PREFERENCES::NOTIFICATION>::THRESHOLD[SENSORS::SIZE][THRESHOLD::RANGE::SIZE]; |
wataloh | 1:b2a9a6f2c30e | 442 | |
wataloh | 1:b2a9a6f2c30e | 443 | typedef union |
wataloh | 1:b2a9a6f2c30e | 444 | { |
wataloh | 1:b2a9a6f2c30e | 445 | typedef struct |
wataloh | 1:b2a9a6f2c30e | 446 | { |
wataloh | 1:b2a9a6f2c30e | 447 | time_t timeStamp; |
wataloh | 1:b2a9a6f2c30e | 448 | SENSORS::INDEX index; |
wataloh | 1:b2a9a6f2c30e | 449 | } PACKET_BASE; |
wataloh | 1:b2a9a6f2c30e | 450 | struct : PACKET_BASE |
wataloh | 1:b2a9a6f2c30e | 451 | { |
wataloh | 1:b2a9a6f2c30e | 452 | short x,y,z; |
wataloh | 1:b2a9a6f2c30e | 453 | } accelerometer; |
wataloh | 1:b2a9a6f2c30e | 454 | struct : PACKET_BASE |
wataloh | 1:b2a9a6f2c30e | 455 | { |
wataloh | 1:b2a9a6f2c30e | 456 | uint16_t R, G, B; |
wataloh | 1:b2a9a6f2c30e | 457 | } color; |
wataloh | 1:b2a9a6f2c30e | 458 | struct : PACKET_BASE |
wataloh | 1:b2a9a6f2c30e | 459 | { |
wataloh | 1:b2a9a6f2c30e | 460 | float val; |
wataloh | 1:b2a9a6f2c30e | 461 | } temperature; |
wataloh | 1:b2a9a6f2c30e | 462 | struct : PACKET_BASE |
wataloh | 1:b2a9a6f2c30e | 463 | { |
wataloh | 1:b2a9a6f2c30e | 464 | float val; |
wataloh | 1:b2a9a6f2c30e | 465 | } current_trans; |
wataloh | 1:b2a9a6f2c30e | 466 | struct : PACKET_BASE |
wataloh | 1:b2a9a6f2c30e | 467 | { |
wataloh | 1:b2a9a6f2c30e | 468 | float val; |
wataloh | 1:b2a9a6f2c30e | 469 | } pressure; |
wataloh | 1:b2a9a6f2c30e | 470 | } PACKET; |
wataloh | 1:b2a9a6f2c30e | 471 | |
wataloh | 1:b2a9a6f2c30e | 472 | }; |
wataloh | 1:b2a9a6f2c30e | 473 | |
wataloh | 1:b2a9a6f2c30e | 474 | #endif //_PREFERENCES_HPP_ |