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/misc/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_ACTIVITY = 14, 49 COMMS_SENSOR_GRAVITY = 15, 50 COMMS_SENSOR_LINEAR_ACCEL = 16, 51 COMMS_SENSOR_ROTATION_VECTOR = 17, 52 COMMS_SENSOR_HALL = 18, 53 COMMS_SENSOR_GEO_MAG = 19, 54 COMMS_SENSOR_GAME_ROTATION_VECTOR = 20, 55 COMMS_SENSOR_GESTURE = 21, 56 COMMS_SENSOR_TILT = 22, 57 COMMS_SENSOR_MAG_BIAS = 23, 58 COMMS_SENSOR_STEP_COUNTER = 24, 59 COMMS_SENSOR_MAG_UNCALIBRATED = 25, 60 COMMS_SENSOR_GYRO_UNCALIBRATED = 26, 61 COMMS_SENSOR_GYRO_BIAS = 27, 62 COMMS_SENSOR_SYNC = 28, 63 COMMS_SENSOR_DOUBLE_TWIST = 29, 64 COMMS_SENSOR_DOUBLE_TAP = 30, 65 COMMS_SENSOR_WINDOW_ORIENTATION = 31, 66 COMMS_SENSOR_WRIST_TILT = 32, 67 COMMS_SENSOR_ACTIVITY_IN_VEHICLE_START = 33, 68 COMMS_SENSOR_ACTIVITY_IN_VEHICLE_STOP = 34, 69 COMMS_SENSOR_ACTIVITY_ON_BICYCLE_START = 35, 70 COMMS_SENSOR_ACTIVITY_ON_BICYCLE_STOP = 36, 71 COMMS_SENSOR_ACTIVITY_WALKING_START = 37, 72 COMMS_SENSOR_ACTIVITY_WALKING_STOP = 38, 73 COMMS_SENSOR_ACTIVITY_RUNNING_START = 39, 74 COMMS_SENSOR_ACTIVITY_RUNNING_STOP = 40, 75 COMMS_SENSOR_ACTIVITY_STILL_START = 41, 76 COMMS_SENSOR_ACTIVITY_STILL_STOP = 42, 77 COMMS_SENSOR_ACTIVITY_TILTING = 43, 78 COMMS_SENSOR_ACCEL_BIAS = 44, 79 80 NUM_COMMS_SENSORS_PLUS_1, 81 82 COMMS_SENSOR_DEBUG = 0x99, 83 }; 84 85 enum { 86 SPI_COMMS_CMD_SYNC = 0, 87 SPI_COMMS_CMD_SWITCH_SENSOR = 1, 88 SPI_COMMS_CMD_ABSOLUTE_TIME = 2, 89 SPI_COMMS_SENSOR_DATA_SCALAR = 3, 90 SPI_COMMS_SENSOR_DATA_VEC3 = 4, 91 SPI_COMMS_SENSOR_DATA_VEC4 = 5, 92 SPI_COMMS_SENSOR_DATA_FLUSH = 6, 93 SPI_COMMS_CMD_UPDATE_MAG_BIAS = 7, 94 SPI_COMMS_CMD_UPDATE_MAG_ACCURACY = 8, 95 SPI_COMMS_CMD_UPDATE_GYRO_BIAS = 9, 96 SPI_COMMS_CMD_ACK_SUSPEND_STATE = 10, 97 SPI_COMMS_DEBUG_OUTPUT = 0xff, 98 }; 99 100 // Please keep existing values unchanged when adding or removing SENSOR_TYPE 101 enum { 102 SENSOR_TYPE_INTERNAL_TEMPERATURE = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 0, 103 SENSOR_TYPE_SYNC = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 1, 104 SENSOR_TYPE_DOUBLE_TWIST = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 2, 105 SENSOR_TYPE_DOUBLE_TAP = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 3, 106 }; 107 108 } // namespace android 109 110 #endif // HUB_DEFS_H_ 111