Rohm RPR0521 proximity-als-ir -sensor driver

Dependents:   rohm-rpr0521-hello rohm-tileshield-6sensor-demo rohm-SensorShield-example

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers rpr0521.h Source File

rpr0521.h

00001 /*   Copyright 2016 Rohm Semiconductor
00002 
00003    Licensed under the Apache License, Version 2.0 (the "License");
00004    you may not use this file except in compliance with the License.
00005    You may obtain a copy of the License at
00006 
00007        http://www.apache.org/licenses/LICENSE-2.0
00008 
00009    Unless required by applicable law or agreed to in writing, software
00010    distributed under the License is distributed on an "AS IS" BASIS,
00011    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00012    See the License for the specific language governing permissions and
00013    limitations under the License.
00014 */
00015 #ifndef RPR0521_H
00016 #define RPR0521_H
00017 
00018 /* registers */
00019 #define RPR0521_REGISTER_DUMP_START 0x40
00020 #define RPR0521_SYSTEM_CONTROL 0x40
00021 #define RPR0521_MODE_CONTROL 0x41
00022 #define RPR0521_ALS_PS_CONTROL 0x42
00023 #define RPR0521_PS_CONTROL 0x43
00024 // low 8bit
00025 #define RPR0521_PS_DATA_LSBS 0x44
00026 // high 4bit
00027 #define RPR0521_PS_DATA_MSBS 0x45
00028 // low 8bit
00029 #define RPR0521_ALS_DATA0_LSBS 0x46
00030 // high 8bit
00031 #define RPR0521_ALS_DATA0_MSBS 0x47
00032 // low 8bit
00033 #define RPR0521_ALS_DATA1_LSBS 0x48
00034 // high 8bit
00035 #define RPR0521_ALS_DATA1_MSBS 0x49
00036 #define RPR0521_INTERRUPT 0x4A
00037 // low 8bit
00038 #define RPR0521_PS_TH_LSBS 0x4B
00039 // high 4bit
00040 #define RPR0521_PS_TH_MSBS 0x4C
00041 // low 8bit
00042 #define RPR0521_PS_TL_LSBS 0x4D
00043 // high 4bit
00044 #define RPR0521_PS_TL_MSBS 0x4E
00045 // low 8bit
00046 #define RPR0521_ALS_DATA0_TH_LSBS 0x4F
00047 // high 8bit
00048 #define RPR0521_ALS_DATA0_TH_MSBS 0x50
00049 // low 8bit
00050 #define RPR0521_ALS_DATA0_TL_LSBS 0x51
00051 // high 8bit
00052 #define RPR0521_ALS_DATA0_TL_MSBS 0x52
00053 // low 8bit
00054 #define RPR0521_PS_OFFSET_LSBS 0x53
00055 // high 2bit
00056 #define RPR0521_PS_OFFSET_MSBS 0x54
00057 #define RPR0521_MANUFACT 0x92
00058 #define RPR0521_MANUFACT_VALUE 0xE0
00059 #define RPR0521_REGISTER_DUMP_END 0x54
00060 /* registers bits */
00061 #define RPR0521_SYSTEM_CONTROL_SW_RESET_NOT_STARTED (0x00 << 7)
00062 #define RPR0521_SYSTEM_CONTROL_SW_RESET_START (0x01 << 7)
00063 #define RPR0521_SYSTEM_CONTROL_INT_PIN_NO_INIT (0x00 << 6)
00064 #define RPR0521_SYSTEM_CONTROL_INT_PIN_HI_Z (0x01 << 6)
00065 #define RPR0521_SYSTEM_CONTROL_PART_ID (0x0A << 0)
00066 #define RPR0521_MODE_CONTROL_ALS_EN_FALSE (0x00 << 7)
00067 #define RPR0521_MODE_CONTROL_ALS_EN_TRUE (0x01 << 7)
00068 #define RPR0521_MODE_CONTROL_PS_EN_FALSE (0x00 << 6)
00069 #define RPR0521_MODE_CONTROL_PS_EN_TRUE (0x01 << 6)
00070 #define RPR0521_MODE_CONTROL_PS_PULSE_200US (0x00 << 5)
00071 #define RPR0521_MODE_CONTROL_PS_PULSE_330US (0x01 << 5)
00072 #define RPR0521_MODE_CONTROL_PS_OPERATING_MODE_NORMAL (0x00 << 4)
00073 #define RPR0521_MODE_CONTROL_PS_OPERATING_MODE_DOUBLE_MEASUREMENT (0x01 << 4)
00074 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_OFF_OFF (0x00 << 0)
00075 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_OFF_10MS (0x01 << 0)
00076 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_OFF_40MS (0x02 << 0)
00077 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_OFF_100MS (0x03 << 0)
00078 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_OFF_400MS (0x04 << 0)
00079 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_100MS_50MS (0x05 << 0)
00080 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_100MS_100MS (0x06 << 0)
00081 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_100MS_400MS (0x07 << 0)
00082 // ALS measurement time is 100ms, sleep time is 300ms
00083 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_400MS_50MS (0x08 << 0)
00084 // ALS measurement time is 100ms, sleep time is 300ms
00085 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_400MS_100MS (0x09 << 0)
00086 // Measurement time 400ms, high sensitivity mode.
00087 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_400MS_OFF (0x0A << 0)
00088 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_400MS_400MS (0x0B << 0)
00089 // Additional sw process is necessary. Check P.18
00090 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_50MS_50MS (0x0C << 0)
00091 #define RPR0521_ALS_PS_CONTROL_RESERVED67_WRITE_00 (0x00 << 6)
00092 #define RPR0521_ALS_PS_CONTROL_ALS_DATA0_GAIN_X1 (0x00 << 4)
00093 #define RPR0521_ALS_PS_CONTROL_ALS_DATA0_GAIN_X2 (0x01 << 4)
00094 #define RPR0521_ALS_PS_CONTROL_ALS_DATA0_GAIN_X64 (0x02 << 4)
00095 #define RPR0521_ALS_PS_CONTROL_ALS_DATA0_GAIN_X128 (0x03 << 4)
00096 #define RPR0521_ALS_PS_CONTROL_ALS_DATA1_GAIN_X1 (0x00 << 2)
00097 #define RPR0521_ALS_PS_CONTROL_ALS_DATA1_GAIN_X2 (0x01 << 2)
00098 #define RPR0521_ALS_PS_CONTROL_ALS_DATA1_GAIN_X64 (0x02 << 2)
00099 #define RPR0521_ALS_PS_CONTROL_ALS_DATA1_GAIN_X128 (0x03 << 2)
00100 #define RPR0521_ALS_PS_CONTROL_LED_CURRENT_25MA (0x00 << 0)
00101 #define RPR0521_ALS_PS_CONTROL_LED_CURRENT_50MA (0x01 << 0)
00102 #define RPR0521_ALS_PS_CONTROL_LED_CURRENT_100MA (0x02 << 0)
00103 #define RPR0521_ALS_PS_CONTROL_LED_CURRENT_200MA (0x03 << 0)
00104 #define RPR0521_PS_CONTROL_AMBIENT_IR_FLAG_LOW (0x00 << 6)
00105 #define RPR0521_PS_CONTROL_AMBIENT_IR_FLAG_HIGH (0x01 << 6)
00106 #define RPR0521_PS_CONTROL_AMBIENT_IR_FLAG_TOO_HIGH (0x02 << 6)
00107 #define RPR0521_PS_CONTROL_PS_GAIN_X1 (0x00 << 4)
00108 #define RPR0521_PS_CONTROL_PS_GAIN_X2 (0x01 << 4)
00109 #define RPR0521_PS_CONTROL_PS_GAIN_X4 (0x02 << 4)
00110 #define RPR0521_PS_CONTROL_PERSISTENCE_DRDY (0x00 << 0)
00111 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_1 (0x01 << 0)
00112 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_2 (0x02 << 0)
00113 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_3 (0x03 << 0)
00114 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_4 (0x04 << 0)
00115 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_5 (0x05 << 0)
00116 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_6 (0x06 << 0)
00117 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_7 (0x07 << 0)
00118 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_8 (0x08 << 0)
00119 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_9 (0x09 << 0)
00120 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_10 (0x0A << 0)
00121 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_11 (0x0B << 0)
00122 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_12 (0x0C << 0)
00123 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_13 (0x0D << 0)
00124 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_14 (0x0E << 0)
00125 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_15 (0x0F << 0)
00126 #define RPR0521_INTERRUPT_PS_INT_STATUS_INACTIVE (0x00 << 7)
00127 #define RPR0521_INTERRUPT_PS_INT_STATUS_ACTIVE (0x01 << 7)
00128 #define RPR0521_INTERRUPT_ALS_INT_STATUS_INACTIVE (0x00 << 6)
00129 #define RPR0521_INTERRUPT_ALS_INT_STATUS_ACTIVE (0x01 << 6)
00130 #define RPR0521_INTERRUPT_INT_MODE_PS_TH_H_ACTIVE (0x00 << 4)
00131 #define RPR0521_INTERRUPT_INT_MODE_PS_TH_HYSTERESIS (0x01 << 4)
00132 #define RPR0521_INTERRUPT_INT_MODE_PS_TH_OUTSIDE_DETECTION (0x02 << 4)
00133 #define RPR0521_INTERRUPT_INT_ASSERT_STABLE (0x00 << 3)
00134 #define RPR0521_INTERRUPT_INT_ASSERT_REINT (0x01 << 3)
00135 #define RPR0521_INTERRUPT_INT_LATCH_ENABLED (0x00 << 2)
00136 #define RPR0521_INTERRUPT_INT_LATCH_DISABLED (0x01 << 2)
00137 #define RPR0521_INTERRUPT_INT_TRIG_INACTIVE (0x00 << 0)
00138 #define RPR0521_INTERRUPT_INT_TRIG_BY_PS (0x01 << 0)
00139 #define RPR0521_INTERRUPT_INT_TRIG_BY_ALS (0x02 << 0)
00140 #define RPR0521_INTERRUPT_INT_TRIG_BY_BOTH (0x03 << 0)
00141 #define RPR0521_MANUFACT_ID_E0H (0xE0 << 0)
00142  /*registers bit masks */
00143 #define RPR0521_SYSTEM_CONTROL_SW_RESET_MASK 0x80
00144 #define RPR0521_SYSTEM_CONTROL_INT_PIN_MASK 0x40
00145 #define RPR0521_SYSTEM_CONTROL_PART_MASK 0x3F
00146 #define RPR0521_MODE_CONTROL_ALS_EN_MASK 0x80
00147 #define RPR0521_MODE_CONTROL_PS_EN_MASK 0x40
00148 #define RPR0521_MODE_CONTROL_PS_PULSE_MASK 0x20
00149 #define RPR0521_MODE_CONTROL_PS_OPERATING_MODE_MASK 0x10
00150 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_MASK 0x0F
00151 
00152 #define RPR0521_ALS_PS_CONTROL_RESERVED67_MASK 0xC0
00153 #define RPR0521_ALS_PS_CONTROL_ALS_DATA0_GAIN_MASK 0x30
00154 #define RPR0521_ALS_PS_CONTROL_ALS_DATA1_GAIN_MASK 0x0C
00155 #define RPR0521_ALS_PS_CONTROL_LED_CURRENT_MASK 0x03
00156 #define RPR0521_PS_CONTROL_AMBIENT_IR_FLAG_MASK 0xC0
00157 #define RPR0521_PS_CONTROL_PS_GAIN_MASK 0x30
00158 #define RPR0521_PS_CONTROL_PERSISTENCE_MASK 0x0F
00159 #define RPR0521_INTERRUPT_PS_INT_STATUS_MASK 0x80
00160 #define RPR0521_INTERRUPT_ALS_INT_STATUS_MASK 0x40
00161 #define RPR0521_INTERRUPT_INT_MODE_MASK 0x30
00162 #define RPR0521_INTERRUPT_INT_ASSERT_MASK 0x08
00163 #define RPR0521_INTERRUPT_INT_LATCH_MASK 0x04
00164 #define RPR0521_INTERRUPT_INT_TRIG_MASK 0x03
00165 #define RPR0521_MANUFACT_ID_MASK 0xFF
00166 
00167 #endif /* RPR0521_H */