Added a GPIO to power on/off for external I2C sensor(s) (with LEDs)

Dependencies:   UniGraphic mbed vt100

18-Jun-2018 外部センサの電源オン・オフ機能は下位互換の為に無効になっていました。 この版で再度有効にしました。

Committer:
Rhyme
Date:
Fri Apr 13 04:19:23 2018 +0000
Revision:
0:846e2321c637
power to color sensor on/off test OK. Currently the function is disabled.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rhyme 0:846e2321c637 1 #ifndef _AF_ATTRIBUTES_H_
Rhyme 0:846e2321c637 2 #define _AF_ATTRIBUTES_H_
Rhyme 0:846e2321c637 3
Rhyme 0:846e2321c637 4 #include "mbed.h"
Rhyme 0:846e2321c637 5 #include "afLib.h"
Rhyme 0:846e2321c637 6
Rhyme 0:846e2321c637 7 /**
Rhyme 0:846e2321c637 8 * af_attributes.h
Rhyme 0:846e2321c637 9 *
Rhyme 0:846e2321c637 10 */
Rhyme 0:846e2321c637 11
Rhyme 0:846e2321c637 12 #define ATTRIBUTE_TYPE_SINT8 2
Rhyme 0:846e2321c637 13 #define ATTRIBUTE_TYPE_SINT16 3
Rhyme 0:846e2321c637 14 #define ATTRIBUTE_TYPE_SINT32 4
Rhyme 0:846e2321c637 15 #define ATTRIBUTE_TYPE_SINT64 5
Rhyme 0:846e2321c637 16 #define ATTRIBUTE_TYPE_BOOLEAN 1
Rhyme 0:846e2321c637 17 #define ATTRIBUTE_TYPE_UTF8S 20
Rhyme 0:846e2321c637 18 #define ATTRIBUTE_TYPE_BYTES 21
Rhyme 0:846e2321c637 19 #define ATTRIBUTE_TYPE_FIXED_15_16 6
Rhyme 0:846e2321c637 20
Rhyme 0:846e2321c637 21 #define afSUCCESS 0 // Operation completed successfully
Rhyme 0:846e2321c637 22 #define afERROR_NO_SUCH_ATTRIBUTE -1 // Request was made for unknown attribute id
Rhyme 0:846e2321c637 23 #define afERROR_BUSY -2 // Request already in progress, try again
Rhyme 0:846e2321c637 24 #define afERROR_INVALID_COMMAND -3 // Command could not be parsed
Rhyme 0:846e2321c637 25 #define afERROR_QUEUE_OVERFLOW -4 // Queue is full
Rhyme 0:846e2321c637 26 #define afERROR_QUEUE_UNDERFLOW -5 // Queue is empty
Rhyme 0:846e2321c637 27 #define afERROR_INVALID_PARAM -6 // Bad input parameter
Rhyme 0:846e2321c637 28
Rhyme 0:846e2321c637 29 #define AF_SYSTEM_COMMAND 65012
Rhyme 0:846e2321c637 30 #define AF_SYSTEM_ASR_STATE 65013
Rhyme 0:846e2321c637 31 #define AF_SYSTEM_LINKED_TIMESTAMP 65015
Rhyme 0:846e2321c637 32
Rhyme 0:846e2321c637 33 #define MODULE_STATE_REBOOTED 0
Rhyme 0:846e2321c637 34 #define MODULE_STATE_LINKED 1
Rhyme 0:846e2321c637 35 #define MODULE_STATE_UPDATING 2
Rhyme 0:846e2321c637 36 #define MOUDLE_STATE_UPDATE_READY 3
Rhyme 0:846e2321c637 37
Rhyme 0:846e2321c637 38 #define MODULE_COMMAND_NONE 0
Rhyme 0:846e2321c637 39 #define MODULE_COMMAND_REBOOT 1
Rhyme 0:846e2321c637 40
Rhyme 0:846e2321c637 41 #define ATTR_SENSE_VAL 1
Rhyme 0:846e2321c637 42 #define ATTR_ACCEL_PRESENT 100
Rhyme 0:846e2321c637 43 #define ATTR_ACCEL_ENABLE 101
Rhyme 0:846e2321c637 44 #define ATTR_ACCEL_INTERVAL 102
Rhyme 0:846e2321c637 45 #define ATTR_ACCEL_VALUE 103
Rhyme 0:846e2321c637 46
Rhyme 0:846e2321c637 47 #define ATTR_COLOR0_PRESENT 200
Rhyme 0:846e2321c637 48 #define ATTR_COLOR0_ENABLE 201
Rhyme 0:846e2321c637 49 #define ATTR_COLOR0_INTERVAL 202
Rhyme 0:846e2321c637 50 #define ATTR_COLOR0_TRIGMODE 203
Rhyme 0:846e2321c637 51 #define ATTR_COLOR0_ITIME 204
Rhyme 0:846e2321c637 52 #define ATTR_COLOR0_CALIBRATE 205
Rhyme 0:846e2321c637 53 #define ATTR_COLOR0_PWM_R 206
Rhyme 0:846e2321c637 54 #define ATTR_COLOR0_PWM_G 207
Rhyme 0:846e2321c637 55 #define ATTR_COLOR0_PWM_B 208
Rhyme 0:846e2321c637 56 #define ATTR_COLOR0_PWM_PERIOD 209
Rhyme 0:846e2321c637 57 #define ATTR_COLOR0_PWM_TARGET 210
Rhyme 0:846e2321c637 58 #define ATTR_COLOR0_R_VALUE 211
Rhyme 0:846e2321c637 59 #define ATTR_COLOR0_G_VALUE 212
Rhyme 0:846e2321c637 60 #define ATTR_COLOR0_B_VALUE 213
Rhyme 0:846e2321c637 61
Rhyme 0:846e2321c637 62 #define ATTR_COLOR1_PRESENT 220
Rhyme 0:846e2321c637 63 #define ATTR_COLOR1_ENABLE 221
Rhyme 0:846e2321c637 64 #define ATTR_COLOR1_INTERVAL 222
Rhyme 0:846e2321c637 65 #define ATTR_COLOR1_TRIGMODE 223
Rhyme 0:846e2321c637 66 #define ATTR_COLOR1_ITIME 224
Rhyme 0:846e2321c637 67 #define ATTR_COLOR1_CALIBRATE 225
Rhyme 0:846e2321c637 68 #define ATTR_COLOR1_PWM_R 226
Rhyme 0:846e2321c637 69 #define ATTR_COLOR1_PWM_G 227
Rhyme 0:846e2321c637 70 #define ATTR_COLOR1_PWM_B 228
Rhyme 0:846e2321c637 71 #define ATTR_COLOR1_PWM_PERIOD 229
Rhyme 0:846e2321c637 72 #define ATTR_COLOR1_PWM_TARGET 230
Rhyme 0:846e2321c637 73 #define ATTR_COLOR1_R_VALUE 231
Rhyme 0:846e2321c637 74 #define ATTR_COLOR1_G_VALUE 232
Rhyme 0:846e2321c637 75 #define ATTR_COLOR1_B_VALUE 233
Rhyme 0:846e2321c637 76
Rhyme 0:846e2321c637 77 /* temperature sensor LM75B with color0 */
Rhyme 0:846e2321c637 78 #define ATTR_TEMP0_PRESENT 300
Rhyme 0:846e2321c637 79 #define ATTR_TEMP0_ENABLE 301
Rhyme 0:846e2321c637 80 #define ATTR_TEMP0_INTERVAL 302
Rhyme 0:846e2321c637 81 #define ATTR_TEMP0_VALUE 303
Rhyme 0:846e2321c637 82
Rhyme 0:846e2321c637 83 /* temperature sensor AT502-11 (before) */
Rhyme 0:846e2321c637 84 #define ATTR_TEMP1_PRESENT 310
Rhyme 0:846e2321c637 85 #define ATTR_TEMP1_ENABLE 311
Rhyme 0:846e2321c637 86 #define ATTR_TEMP1_INTERVAL 312
Rhyme 0:846e2321c637 87 #define ATTR_TEMP1_VALUE 313
Rhyme 0:846e2321c637 88
Rhyme 0:846e2321c637 89 /* temperature sensor AT502-11 (after) */
Rhyme 0:846e2321c637 90 #define ATTR_TEMP2_PRESENT 320
Rhyme 0:846e2321c637 91 #define ATTR_TEMP2_ENABLE 321
Rhyme 0:846e2321c637 92 #define ATTR_TEMP2_INTERVAL 322
Rhyme 0:846e2321c637 93 #define ATTR_TEMP2_VALUE 323
Rhyme 0:846e2321c637 94
Rhyme 0:846e2321c637 95 /* temperature sensor LM75B with color1 */
Rhyme 0:846e2321c637 96 #define ATTR_TEMP3_PRESENT 330
Rhyme 0:846e2321c637 97 #define ATTR_TEMP3_ENABLE 331
Rhyme 0:846e2321c637 98 #define ATTR_TEMP3_INTERVAL 332
Rhyme 0:846e2321c637 99 #define ATTR_TEMP3_VALUE 333
Rhyme 0:846e2321c637 100
Rhyme 0:846e2321c637 101 /* gas pressure sensor */
Rhyme 0:846e2321c637 102 /* gas pressure sensor */
Rhyme 0:846e2321c637 103 #define ATTR_GAS_PRESENT 400
Rhyme 0:846e2321c637 104 #define ATTR_GAS_ENABLE 401
Rhyme 0:846e2321c637 105 #define ATTR_GAS_INTERVAL 402
Rhyme 0:846e2321c637 106 #define ATTR_GAS_VALUE 403
Rhyme 0:846e2321c637 107 #define ATTR_GAS_THR_MODE 404
Rhyme 0:846e2321c637 108 #define ATTR_GAS_THR_HIGH 405
Rhyme 0:846e2321c637 109 #define ATTR_GAS_THR_LOW 406
Rhyme 0:846e2321c637 110
Rhyme 0:846e2321c637 111 /* current trans sensor */
Rhyme 0:846e2321c637 112 #define ATTR_CURRENT_PRESENT 500
Rhyme 0:846e2321c637 113 #define ATTR_CURRENT_ENABLE 501
Rhyme 0:846e2321c637 114 #define ATTR_CURRENT_INTERVAL 502
Rhyme 0:846e2321c637 115 #define ATTR_CURRENT_VALUE 503
Rhyme 0:846e2321c637 116
Rhyme 0:846e2321c637 117 #define ATTR_SOFTWARE_RESET 666
Rhyme 0:846e2321c637 118 #define ATTR_DISPLAY_MODE 777
Rhyme 0:846e2321c637 119 #define ATTR_MCU_RESET_REASON 999
Rhyme 0:846e2321c637 120
Rhyme 0:846e2321c637 121 #define ATTR_LED 1024
Rhyme 0:846e2321c637 122 #define ATTR_IO0 1025
Rhyme 0:846e2321c637 123 #define ATTR_IO1 1026
Rhyme 0:846e2321c637 124 #define ATTR_IO2 1028
Rhyme 0:846e2321c637 125 #define ATTR_BUTTON 1030
Rhyme 0:846e2321c637 126 #define ATTR_IO3 1031
Rhyme 0:846e2321c637 127
Rhyme 0:846e2321c637 128 #define ATTR_BOOT_LOADER_VER 2001
Rhyme 0:846e2321c637 129 #define ATTR_BLE_STACK_VER 2002
Rhyme 0:846e2321c637 130 #define ATTR_FW_APP_VER 2003
Rhyme 0:846e2321c637 131 #define ATTR_DEVICE_DESC 2004
Rhyme 0:846e2321c637 132 #define ATTR_WIFI_VER 2006
Rhyme 0:846e2321c637 133
Rhyme 0:846e2321c637 134 #define ATTR_OFFLINE_SCHED 59001
Rhyme 0:846e2321c637 135 #define ATTR_SECURITY_ENABLED 60000
Rhyme 0:846e2321c637 136 #define ATTR_UTC_OFFSET 65001
Rhyme 0:846e2321c637 137 #define ATTR_CONFIGURES_SSID 65004
Rhyme 0:846e2321c637 138 #define ATTR_WIFI_BARS 65005
Rhyme 0:846e2321c637 139 #define ATTR_WIFI_STDY_STATE 65006
Rhyme 0:846e2321c637 140
Rhyme 0:846e2321c637 141 #define ATTR_COMMAND 65012
Rhyme 0:846e2321c637 142 #define ATTR_ASR_STATE 65013
Rhyme 0:846e2321c637 143 #define ATTR_LOW_BATTERY 65014
Rhyme 0:846e2321c637 144 #define ATTR_LINKED_TIMESTAMP 65015
Rhyme 0:846e2321c637 145 #define ATTR_ATTR_ACK 65018
Rhyme 0:846e2321c637 146 #define ATTR_REBOOT_REASON 65019
Rhyme 0:846e2321c637 147 #define ATTR_BLE_COMMS 65020
Rhyme 0:846e2321c637 148 #define ATTR_MCU_INTERFACE 65021
Rhyme 0:846e2321c637 149
Rhyme 0:846e2321c637 150 #define DISPLAY_MODE_OFF 0
Rhyme 0:846e2321c637 151 #define DISPLAY_MODE_GAS 1
Rhyme 0:846e2321c637 152 #define DISPLAY_MODE_SUMMARY 2
Rhyme 0:846e2321c637 153 #define DISPLAY_MODE_CHART 3
Rhyme 0:846e2321c637 154
Rhyme 0:846e2321c637 155 typedef struct {
Rhyme 0:846e2321c637 156 uint16_t id ;
Rhyme 0:846e2321c637 157 char *description ;
Rhyme 0:846e2321c637 158 int attribute_type ;
Rhyme 0:846e2321c637 159 int size ;
Rhyme 0:846e2321c637 160 } af_attribute_type ;
Rhyme 0:846e2321c637 161
Rhyme 0:846e2321c637 162 /**
Rhyme 0:846e2321c637 163 * get_af_attr
Rhyme 0:846e2321c637 164 * @param id attribute id value to look up
Rhyme 0:846e2321c637 165 * @returns index of the attribute in the af_attribute_type af_attr[]
Rhyme 0:846e2321c637 166 */
Rhyme 0:846e2321c637 167 int get_af_attr(uint16_t id) ;
Rhyme 0:846e2321c637 168
Rhyme 0:846e2321c637 169 /**
Rhyme 0:846e2321c637 170 * print_af_error
Rhyme 0:846e2321c637 171 * @param resultCode return value from afLib function(s)
Rhyme 0:846e2321c637 172 */
Rhyme 0:846e2321c637 173 void print_af_error(int resultCode) ;
Rhyme 0:846e2321c637 174
Rhyme 0:846e2321c637 175 /**
Rhyme 0:846e2321c637 176 * Callback that allows ASR to request an MCU attribute be changed.
Rhyme 0:846e2321c637 177 * You should define this function in your MCU firmware to perform application-specific actions
Rhyme 0:846e2321c637 178 * your code must take (e.g., updating the state of the hardware),
Rhyme 0:846e2321c637 179 * in light of the attribute value change.
Rhyme 0:846e2321c637 180 */
Rhyme 0:846e2321c637 181 void attributeChangeRequest(
Rhyme 0:846e2321c637 182 const uint8_t requestId,
Rhyme 0:846e2321c637 183 const uint16_t attributeId,
Rhyme 0:846e2321c637 184 const uint16_t valueLen,
Rhyme 0:846e2321c637 185 const uint8_t *value
Rhyme 0:846e2321c637 186 ) ;
Rhyme 0:846e2321c637 187
Rhyme 0:846e2321c637 188 /*
Rhyme 0:846e2321c637 189 * Application callback that allows afLib to notify that an attribute has changed.
Rhyme 0:846e2321c637 190 * This method will be called in response to a getAttribute call from the application
Rhyme 0:846e2321c637 191 * and whenever a ASR module attribute changes.
Rhyme 0:846e2321c637 192 */
Rhyme 0:846e2321c637 193 void attributeUpdatedReport(
Rhyme 0:846e2321c637 194 const uint8_t requestId,
Rhyme 0:846e2321c637 195 const uint16_t attributeId,
Rhyme 0:846e2321c637 196 const uint16_t valueLen,
Rhyme 0:846e2321c637 197 const uint8_t *value
Rhyme 0:846e2321c637 198 ) ;
Rhyme 0:846e2321c637 199
Rhyme 0:846e2321c637 200 extern afLib *afero ;
Rhyme 0:846e2321c637 201 #endif /* _AF_ATTRIBUTES_H */