1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef HUB_DEFS_H_ 18 #define HUB_DEFS_H_ 19 20 #include <hardware/sensors.h> 21 22 #define MAX_SPI_PAYLOAD_SIZE 256 23 24 namespace android { 25 26 #define CONTEXTHUB_SETTINGS_PATH "/persist/sensorcal.json" 27 #define CONTEXTHUB_SAVED_SETTINGS_PATH "/data/vendor/sensor/sensorcal_saved.json" 28 #define MAG_BIAS_FILE_PATH "/sys/class/power_supply/battery/compass_compensation" 29 30 static const uint32_t kMinClockRateHz = 960000; 31 static const uint32_t kClockRateHz = kMinClockRateHz * 5; // 4.8MHz 32 33 enum comms_sensor_t { 34 COMMS_SENSOR_INVALID = 0, 35 COMMS_SENSOR_ACCEL = 1, 36 COMMS_SENSOR_GYRO = 2, 37 COMMS_SENSOR_MAG = 3, 38 COMMS_SENSOR_PRESSURE = 4, 39 COMMS_SENSOR_TEMPERATURE = 5, 40 COMMS_SENSOR_PROXIMITY = 6, 41 COMMS_SENSOR_LIGHT = 7, 42 COMMS_SENSOR_ORIENTATION = 8, 43 COMMS_SENSOR_STEP_DETECTOR = 9, 44 COMMS_SENSOR_ANY_MOTION = 10, 45 COMMS_SENSOR_NO_MOTION = 11, 46 COMMS_SENSOR_SIGNIFICANT_MOTION = 12, 47 COMMS_SENSOR_FLAT = 13, 48 COMMS_SENSOR_GRAVITY = 14, 49 COMMS_SENSOR_LINEAR_ACCEL = 15, 50 COMMS_SENSOR_ROTATION_VECTOR = 16, 51 COMMS_SENSOR_HALL = 17, 52 COMMS_SENSOR_GEO_MAG = 18, 53 COMMS_SENSOR_GAME_ROTATION_VECTOR = 19, 54 COMMS_SENSOR_GESTURE = 20, 55 COMMS_SENSOR_TILT = 21, 56 COMMS_SENSOR_MAG_BIAS = 22, 57 COMMS_SENSOR_STEP_COUNTER = 23, 58 COMMS_SENSOR_MAG_UNCALIBRATED = 24, 59 COMMS_SENSOR_GYRO_UNCALIBRATED = 25, 60 COMMS_SENSOR_GYRO_BIAS = 26, 61 COMMS_SENSOR_SYNC = 27, 62 COMMS_SENSOR_DOUBLE_TWIST = 28, 63 COMMS_SENSOR_DOUBLE_TAP = 29, 64 COMMS_SENSOR_WINDOW_ORIENTATION = 30, 65 COMMS_SENSOR_WRIST_TILT = 31, 66 67 // The order of the activity sensors must be sequential. It is used in 68 // various places to iterate over the list of sensors that are associated 69 // with an activity. 70 COMMS_SENSOR_ACTIVITY_IN_VEHICLE_START = 32, 71 COMMS_SENSOR_ACTIVITY_IN_VEHICLE_STOP = 33, 72 COMMS_SENSOR_ACTIVITY_ON_BICYCLE_START = 34, 73 COMMS_SENSOR_ACTIVITY_ON_BICYCLE_STOP = 35, 74 COMMS_SENSOR_ACTIVITY_WALKING_START = 36, 75 COMMS_SENSOR_ACTIVITY_WALKING_STOP = 37, 76 COMMS_SENSOR_ACTIVITY_RUNNING_START = 38, 77 COMMS_SENSOR_ACTIVITY_RUNNING_STOP = 39, 78 COMMS_SENSOR_ACTIVITY_STILL_START = 40, 79 COMMS_SENSOR_ACTIVITY_STILL_STOP = 41, 80 COMMS_SENSOR_ACTIVITY_TILTING = 42, 81 COMMS_SENSOR_ACCEL_BIAS = 43, 82 COMMS_SENSOR_DOUBLE_TOUCH = 44, 83 COMMS_SENSOR_GAZE = 45, 84 COMMS_SENSOR_UNGAZE = 46, 85 COMMS_SENSOR_ACCEL_UNCALIBRATED = 47, 86 COMMS_SENSOR_HUMIDITY = 48, 87 88 NUM_COMMS_SENSORS_PLUS_1, 89 90 COMMS_SENSOR_DEBUG = 0x99, 91 }; 92 93 #define COMMS_SENSOR_ACTIVITY_FIRST COMMS_SENSOR_ACTIVITY_IN_VEHICLE_START 94 #define COMMS_SENSOR_ACTIVITY_LAST COMMS_SENSOR_ACTIVITY_TILTING 95 96 enum { 97 SPI_COMMS_CMD_SYNC = 0, 98 SPI_COMMS_CMD_SWITCH_SENSOR = 1, 99 SPI_COMMS_CMD_ABSOLUTE_TIME = 2, 100 SPI_COMMS_SENSOR_DATA_SCALAR = 3, 101 SPI_COMMS_SENSOR_DATA_VEC3 = 4, 102 SPI_COMMS_SENSOR_DATA_VEC4 = 5, 103 SPI_COMMS_SENSOR_DATA_FLUSH = 6, 104 SPI_COMMS_CMD_UPDATE_MAG_BIAS = 7, 105 SPI_COMMS_CMD_UPDATE_MAG_ACCURACY = 8, 106 SPI_COMMS_CMD_UPDATE_GYRO_BIAS = 9, 107 SPI_COMMS_CMD_ACK_SUSPEND_STATE = 10, 108 SPI_COMMS_DEBUG_OUTPUT = 0xff, 109 }; 110 111 // Please keep existing values unchanged when adding or removing SENSOR_TYPE 112 enum { 113 SENSOR_TYPE_INTERNAL_TEMPERATURE = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 0, 114 SENSOR_TYPE_SYNC = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 1, 115 SENSOR_TYPE_DOUBLE_TWIST = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 2, 116 SENSOR_TYPE_DOUBLE_TAP = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 3, 117 SENSOR_TYPE_DOUBLE_TOUCH = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 4, 118 SENSOR_TYPE_GAZE = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 5, 119 SENSOR_TYPE_UNGAZE = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 6, 120 }; 121 122 } // namespace android 123 124 #endif // HUB_DEFS_H_ 125