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 67 NUM_COMMS_SENSORS_PLUS_1, 68 69 COMMS_SENSOR_DEBUG = 0x99, 70 }; 71 72 enum { 73 SPI_COMMS_CMD_SYNC = 0, 74 SPI_COMMS_CMD_SWITCH_SENSOR = 1, 75 SPI_COMMS_CMD_ABSOLUTE_TIME = 2, 76 SPI_COMMS_SENSOR_DATA_SCALAR = 3, 77 SPI_COMMS_SENSOR_DATA_VEC3 = 4, 78 SPI_COMMS_SENSOR_DATA_VEC4 = 5, 79 SPI_COMMS_SENSOR_DATA_FLUSH = 6, 80 SPI_COMMS_CMD_UPDATE_MAG_BIAS = 7, 81 SPI_COMMS_CMD_UPDATE_MAG_ACCURACY = 8, 82 SPI_COMMS_CMD_UPDATE_GYRO_BIAS = 9, 83 SPI_COMMS_CMD_ACK_SUSPEND_STATE = 10, 84 SPI_COMMS_DEBUG_OUTPUT = 0xff, 85 }; 86 87 // Please keep existing values unchanged when adding or removing SENSOR_TYPE 88 enum { 89 SENSOR_TYPE_INTERNAL_TEMPERATURE = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 0, 90 SENSOR_TYPE_SYNC = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 1, 91 SENSOR_TYPE_DOUBLE_TWIST = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 2, 92 SENSOR_TYPE_DOUBLE_TAP = SENSOR_TYPE_DEVICE_PRIVATE_BASE + 3, 93 }; 94 95 } // namespace android 96 97 #endif // HUB_DEFS_H_ 98