Rohm RPR0521 proximity-als-ir -sensor driver

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

Committer:
Ren Boting
Date:
Mon Feb 18 16:41:56 2019 +0900
Revision:
2:56d144605997
Parent:
0:0bcc203c5c75
fix IAR toolchain compilation failure.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MikkoZ 0:0bcc203c5c75 1 /* Copyright 2016 Rohm Semiconductor
MikkoZ 0:0bcc203c5c75 2
MikkoZ 0:0bcc203c5c75 3 Licensed under the Apache License, Version 2.0 (the "License");
MikkoZ 0:0bcc203c5c75 4 you may not use this file except in compliance with the License.
MikkoZ 0:0bcc203c5c75 5 You may obtain a copy of the License at
MikkoZ 0:0bcc203c5c75 6
MikkoZ 0:0bcc203c5c75 7 http://www.apache.org/licenses/LICENSE-2.0
MikkoZ 0:0bcc203c5c75 8
MikkoZ 0:0bcc203c5c75 9 Unless required by applicable law or agreed to in writing, software
MikkoZ 0:0bcc203c5c75 10 distributed under the License is distributed on an "AS IS" BASIS,
MikkoZ 0:0bcc203c5c75 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
MikkoZ 0:0bcc203c5c75 12 See the License for the specific language governing permissions and
MikkoZ 0:0bcc203c5c75 13 limitations under the License.
MikkoZ 0:0bcc203c5c75 14 */
MikkoZ 0:0bcc203c5c75 15 #ifndef RPR0521_H
MikkoZ 0:0bcc203c5c75 16 #define RPR0521_H
MikkoZ 0:0bcc203c5c75 17
MikkoZ 0:0bcc203c5c75 18 /* registers */
MikkoZ 0:0bcc203c5c75 19 #define RPR0521_REGISTER_DUMP_START 0x40
MikkoZ 0:0bcc203c5c75 20 #define RPR0521_SYSTEM_CONTROL 0x40
MikkoZ 0:0bcc203c5c75 21 #define RPR0521_MODE_CONTROL 0x41
MikkoZ 0:0bcc203c5c75 22 #define RPR0521_ALS_PS_CONTROL 0x42
MikkoZ 0:0bcc203c5c75 23 #define RPR0521_PS_CONTROL 0x43
MikkoZ 0:0bcc203c5c75 24 // low 8bit
MikkoZ 0:0bcc203c5c75 25 #define RPR0521_PS_DATA_LSBS 0x44
MikkoZ 0:0bcc203c5c75 26 // high 4bit
MikkoZ 0:0bcc203c5c75 27 #define RPR0521_PS_DATA_MSBS 0x45
MikkoZ 0:0bcc203c5c75 28 // low 8bit
MikkoZ 0:0bcc203c5c75 29 #define RPR0521_ALS_DATA0_LSBS 0x46
MikkoZ 0:0bcc203c5c75 30 // high 8bit
MikkoZ 0:0bcc203c5c75 31 #define RPR0521_ALS_DATA0_MSBS 0x47
MikkoZ 0:0bcc203c5c75 32 // low 8bit
MikkoZ 0:0bcc203c5c75 33 #define RPR0521_ALS_DATA1_LSBS 0x48
MikkoZ 0:0bcc203c5c75 34 // high 8bit
MikkoZ 0:0bcc203c5c75 35 #define RPR0521_ALS_DATA1_MSBS 0x49
MikkoZ 0:0bcc203c5c75 36 #define RPR0521_INTERRUPT 0x4A
MikkoZ 0:0bcc203c5c75 37 // low 8bit
MikkoZ 0:0bcc203c5c75 38 #define RPR0521_PS_TH_LSBS 0x4B
MikkoZ 0:0bcc203c5c75 39 // high 4bit
MikkoZ 0:0bcc203c5c75 40 #define RPR0521_PS_TH_MSBS 0x4C
MikkoZ 0:0bcc203c5c75 41 // low 8bit
MikkoZ 0:0bcc203c5c75 42 #define RPR0521_PS_TL_LSBS 0x4D
MikkoZ 0:0bcc203c5c75 43 // high 4bit
MikkoZ 0:0bcc203c5c75 44 #define RPR0521_PS_TL_MSBS 0x4E
MikkoZ 0:0bcc203c5c75 45 // low 8bit
MikkoZ 0:0bcc203c5c75 46 #define RPR0521_ALS_DATA0_TH_LSBS 0x4F
MikkoZ 0:0bcc203c5c75 47 // high 8bit
MikkoZ 0:0bcc203c5c75 48 #define RPR0521_ALS_DATA0_TH_MSBS 0x50
MikkoZ 0:0bcc203c5c75 49 // low 8bit
MikkoZ 0:0bcc203c5c75 50 #define RPR0521_ALS_DATA0_TL_LSBS 0x51
MikkoZ 0:0bcc203c5c75 51 // high 8bit
MikkoZ 0:0bcc203c5c75 52 #define RPR0521_ALS_DATA0_TL_MSBS 0x52
MikkoZ 0:0bcc203c5c75 53 // low 8bit
MikkoZ 0:0bcc203c5c75 54 #define RPR0521_PS_OFFSET_LSBS 0x53
MikkoZ 0:0bcc203c5c75 55 // high 2bit
MikkoZ 0:0bcc203c5c75 56 #define RPR0521_PS_OFFSET_MSBS 0x54
MikkoZ 0:0bcc203c5c75 57 #define RPR0521_MANUFACT 0x92
MikkoZ 0:0bcc203c5c75 58 #define RPR0521_MANUFACT_VALUE 0xE0
MikkoZ 0:0bcc203c5c75 59 #define RPR0521_REGISTER_DUMP_END 0x54
MikkoZ 0:0bcc203c5c75 60 /* registers bits */
MikkoZ 0:0bcc203c5c75 61 #define RPR0521_SYSTEM_CONTROL_SW_RESET_NOT_STARTED (0x00 << 7)
MikkoZ 0:0bcc203c5c75 62 #define RPR0521_SYSTEM_CONTROL_SW_RESET_START (0x01 << 7)
MikkoZ 0:0bcc203c5c75 63 #define RPR0521_SYSTEM_CONTROL_INT_PIN_NO_INIT (0x00 << 6)
MikkoZ 0:0bcc203c5c75 64 #define RPR0521_SYSTEM_CONTROL_INT_PIN_HI_Z (0x01 << 6)
MikkoZ 0:0bcc203c5c75 65 #define RPR0521_SYSTEM_CONTROL_PART_ID (0x0A << 0)
MikkoZ 0:0bcc203c5c75 66 #define RPR0521_MODE_CONTROL_ALS_EN_FALSE (0x00 << 7)
MikkoZ 0:0bcc203c5c75 67 #define RPR0521_MODE_CONTROL_ALS_EN_TRUE (0x01 << 7)
MikkoZ 0:0bcc203c5c75 68 #define RPR0521_MODE_CONTROL_PS_EN_FALSE (0x00 << 6)
MikkoZ 0:0bcc203c5c75 69 #define RPR0521_MODE_CONTROL_PS_EN_TRUE (0x01 << 6)
MikkoZ 0:0bcc203c5c75 70 #define RPR0521_MODE_CONTROL_PS_PULSE_200US (0x00 << 5)
MikkoZ 0:0bcc203c5c75 71 #define RPR0521_MODE_CONTROL_PS_PULSE_330US (0x01 << 5)
MikkoZ 0:0bcc203c5c75 72 #define RPR0521_MODE_CONTROL_PS_OPERATING_MODE_NORMAL (0x00 << 4)
MikkoZ 0:0bcc203c5c75 73 #define RPR0521_MODE_CONTROL_PS_OPERATING_MODE_DOUBLE_MEASUREMENT (0x01 << 4)
MikkoZ 0:0bcc203c5c75 74 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_OFF_OFF (0x00 << 0)
MikkoZ 0:0bcc203c5c75 75 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_OFF_10MS (0x01 << 0)
MikkoZ 0:0bcc203c5c75 76 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_OFF_40MS (0x02 << 0)
MikkoZ 0:0bcc203c5c75 77 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_OFF_100MS (0x03 << 0)
MikkoZ 0:0bcc203c5c75 78 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_OFF_400MS (0x04 << 0)
MikkoZ 0:0bcc203c5c75 79 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_100MS_50MS (0x05 << 0)
MikkoZ 0:0bcc203c5c75 80 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_100MS_100MS (0x06 << 0)
MikkoZ 0:0bcc203c5c75 81 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_100MS_400MS (0x07 << 0)
MikkoZ 0:0bcc203c5c75 82 // ALS measurement time is 100ms, sleep time is 300ms
MikkoZ 0:0bcc203c5c75 83 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_400MS_50MS (0x08 << 0)
MikkoZ 0:0bcc203c5c75 84 // ALS measurement time is 100ms, sleep time is 300ms
MikkoZ 0:0bcc203c5c75 85 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_400MS_100MS (0x09 << 0)
MikkoZ 0:0bcc203c5c75 86 // Measurement time 400ms, high sensitivity mode.
MikkoZ 0:0bcc203c5c75 87 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_400MS_OFF (0x0A << 0)
MikkoZ 0:0bcc203c5c75 88 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_400MS_400MS (0x0B << 0)
MikkoZ 0:0bcc203c5c75 89 // Additional sw process is necessary. Check P.18
MikkoZ 0:0bcc203c5c75 90 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_50MS_50MS (0x0C << 0)
MikkoZ 0:0bcc203c5c75 91 #define RPR0521_ALS_PS_CONTROL_RESERVED67_WRITE_00 (0x00 << 6)
MikkoZ 0:0bcc203c5c75 92 #define RPR0521_ALS_PS_CONTROL_ALS_DATA0_GAIN_X1 (0x00 << 4)
MikkoZ 0:0bcc203c5c75 93 #define RPR0521_ALS_PS_CONTROL_ALS_DATA0_GAIN_X2 (0x01 << 4)
MikkoZ 0:0bcc203c5c75 94 #define RPR0521_ALS_PS_CONTROL_ALS_DATA0_GAIN_X64 (0x02 << 4)
MikkoZ 0:0bcc203c5c75 95 #define RPR0521_ALS_PS_CONTROL_ALS_DATA0_GAIN_X128 (0x03 << 4)
MikkoZ 0:0bcc203c5c75 96 #define RPR0521_ALS_PS_CONTROL_ALS_DATA1_GAIN_X1 (0x00 << 2)
MikkoZ 0:0bcc203c5c75 97 #define RPR0521_ALS_PS_CONTROL_ALS_DATA1_GAIN_X2 (0x01 << 2)
MikkoZ 0:0bcc203c5c75 98 #define RPR0521_ALS_PS_CONTROL_ALS_DATA1_GAIN_X64 (0x02 << 2)
MikkoZ 0:0bcc203c5c75 99 #define RPR0521_ALS_PS_CONTROL_ALS_DATA1_GAIN_X128 (0x03 << 2)
MikkoZ 0:0bcc203c5c75 100 #define RPR0521_ALS_PS_CONTROL_LED_CURRENT_25MA (0x00 << 0)
MikkoZ 0:0bcc203c5c75 101 #define RPR0521_ALS_PS_CONTROL_LED_CURRENT_50MA (0x01 << 0)
MikkoZ 0:0bcc203c5c75 102 #define RPR0521_ALS_PS_CONTROL_LED_CURRENT_100MA (0x02 << 0)
MikkoZ 0:0bcc203c5c75 103 #define RPR0521_ALS_PS_CONTROL_LED_CURRENT_200MA (0x03 << 0)
MikkoZ 0:0bcc203c5c75 104 #define RPR0521_PS_CONTROL_AMBIENT_IR_FLAG_LOW (0x00 << 6)
MikkoZ 0:0bcc203c5c75 105 #define RPR0521_PS_CONTROL_AMBIENT_IR_FLAG_HIGH (0x01 << 6)
MikkoZ 0:0bcc203c5c75 106 #define RPR0521_PS_CONTROL_AMBIENT_IR_FLAG_TOO_HIGH (0x02 << 6)
MikkoZ 0:0bcc203c5c75 107 #define RPR0521_PS_CONTROL_PS_GAIN_X1 (0x00 << 4)
MikkoZ 0:0bcc203c5c75 108 #define RPR0521_PS_CONTROL_PS_GAIN_X2 (0x01 << 4)
MikkoZ 0:0bcc203c5c75 109 #define RPR0521_PS_CONTROL_PS_GAIN_X4 (0x02 << 4)
MikkoZ 0:0bcc203c5c75 110 #define RPR0521_PS_CONTROL_PERSISTENCE_DRDY (0x00 << 0)
MikkoZ 0:0bcc203c5c75 111 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_1 (0x01 << 0)
MikkoZ 0:0bcc203c5c75 112 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_2 (0x02 << 0)
MikkoZ 0:0bcc203c5c75 113 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_3 (0x03 << 0)
MikkoZ 0:0bcc203c5c75 114 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_4 (0x04 << 0)
MikkoZ 0:0bcc203c5c75 115 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_5 (0x05 << 0)
MikkoZ 0:0bcc203c5c75 116 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_6 (0x06 << 0)
MikkoZ 0:0bcc203c5c75 117 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_7 (0x07 << 0)
MikkoZ 0:0bcc203c5c75 118 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_8 (0x08 << 0)
MikkoZ 0:0bcc203c5c75 119 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_9 (0x09 << 0)
MikkoZ 0:0bcc203c5c75 120 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_10 (0x0A << 0)
MikkoZ 0:0bcc203c5c75 121 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_11 (0x0B << 0)
MikkoZ 0:0bcc203c5c75 122 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_12 (0x0C << 0)
MikkoZ 0:0bcc203c5c75 123 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_13 (0x0D << 0)
MikkoZ 0:0bcc203c5c75 124 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_14 (0x0E << 0)
MikkoZ 0:0bcc203c5c75 125 #define RPR0521_PS_CONTROL_PERSISTENCE_CONSECUTIVE_15 (0x0F << 0)
MikkoZ 0:0bcc203c5c75 126 #define RPR0521_INTERRUPT_PS_INT_STATUS_INACTIVE (0x00 << 7)
MikkoZ 0:0bcc203c5c75 127 #define RPR0521_INTERRUPT_PS_INT_STATUS_ACTIVE (0x01 << 7)
MikkoZ 0:0bcc203c5c75 128 #define RPR0521_INTERRUPT_ALS_INT_STATUS_INACTIVE (0x00 << 6)
MikkoZ 0:0bcc203c5c75 129 #define RPR0521_INTERRUPT_ALS_INT_STATUS_ACTIVE (0x01 << 6)
MikkoZ 0:0bcc203c5c75 130 #define RPR0521_INTERRUPT_INT_MODE_PS_TH_H_ACTIVE (0x00 << 4)
MikkoZ 0:0bcc203c5c75 131 #define RPR0521_INTERRUPT_INT_MODE_PS_TH_HYSTERESIS (0x01 << 4)
MikkoZ 0:0bcc203c5c75 132 #define RPR0521_INTERRUPT_INT_MODE_PS_TH_OUTSIDE_DETECTION (0x02 << 4)
MikkoZ 0:0bcc203c5c75 133 #define RPR0521_INTERRUPT_INT_ASSERT_STABLE (0x00 << 3)
MikkoZ 0:0bcc203c5c75 134 #define RPR0521_INTERRUPT_INT_ASSERT_REINT (0x01 << 3)
MikkoZ 0:0bcc203c5c75 135 #define RPR0521_INTERRUPT_INT_LATCH_ENABLED (0x00 << 2)
MikkoZ 0:0bcc203c5c75 136 #define RPR0521_INTERRUPT_INT_LATCH_DISABLED (0x01 << 2)
MikkoZ 0:0bcc203c5c75 137 #define RPR0521_INTERRUPT_INT_TRIG_INACTIVE (0x00 << 0)
MikkoZ 0:0bcc203c5c75 138 #define RPR0521_INTERRUPT_INT_TRIG_BY_PS (0x01 << 0)
MikkoZ 0:0bcc203c5c75 139 #define RPR0521_INTERRUPT_INT_TRIG_BY_ALS (0x02 << 0)
MikkoZ 0:0bcc203c5c75 140 #define RPR0521_INTERRUPT_INT_TRIG_BY_BOTH (0x03 << 0)
MikkoZ 0:0bcc203c5c75 141 #define RPR0521_MANUFACT_ID_E0H (0xE0 << 0)
MikkoZ 0:0bcc203c5c75 142 /*registers bit masks */
MikkoZ 0:0bcc203c5c75 143 #define RPR0521_SYSTEM_CONTROL_SW_RESET_MASK 0x80
MikkoZ 0:0bcc203c5c75 144 #define RPR0521_SYSTEM_CONTROL_INT_PIN_MASK 0x40
MikkoZ 0:0bcc203c5c75 145 #define RPR0521_SYSTEM_CONTROL_PART_MASK 0x3F
MikkoZ 0:0bcc203c5c75 146 #define RPR0521_MODE_CONTROL_ALS_EN_MASK 0x80
MikkoZ 0:0bcc203c5c75 147 #define RPR0521_MODE_CONTROL_PS_EN_MASK 0x40
MikkoZ 0:0bcc203c5c75 148 #define RPR0521_MODE_CONTROL_PS_PULSE_MASK 0x20
MikkoZ 0:0bcc203c5c75 149 #define RPR0521_MODE_CONTROL_PS_OPERATING_MODE_MASK 0x10
MikkoZ 0:0bcc203c5c75 150 #define RPR0521_MODE_CONTROL_MEASUREMENT_TIME_MASK 0x0F
MikkoZ 0:0bcc203c5c75 151
MikkoZ 0:0bcc203c5c75 152 #define RPR0521_ALS_PS_CONTROL_RESERVED67_MASK 0xC0
MikkoZ 0:0bcc203c5c75 153 #define RPR0521_ALS_PS_CONTROL_ALS_DATA0_GAIN_MASK 0x30
MikkoZ 0:0bcc203c5c75 154 #define RPR0521_ALS_PS_CONTROL_ALS_DATA1_GAIN_MASK 0x0C
MikkoZ 0:0bcc203c5c75 155 #define RPR0521_ALS_PS_CONTROL_LED_CURRENT_MASK 0x03
MikkoZ 0:0bcc203c5c75 156 #define RPR0521_PS_CONTROL_AMBIENT_IR_FLAG_MASK 0xC0
MikkoZ 0:0bcc203c5c75 157 #define RPR0521_PS_CONTROL_PS_GAIN_MASK 0x30
MikkoZ 0:0bcc203c5c75 158 #define RPR0521_PS_CONTROL_PERSISTENCE_MASK 0x0F
MikkoZ 0:0bcc203c5c75 159 #define RPR0521_INTERRUPT_PS_INT_STATUS_MASK 0x80
MikkoZ 0:0bcc203c5c75 160 #define RPR0521_INTERRUPT_ALS_INT_STATUS_MASK 0x40
MikkoZ 0:0bcc203c5c75 161 #define RPR0521_INTERRUPT_INT_MODE_MASK 0x30
MikkoZ 0:0bcc203c5c75 162 #define RPR0521_INTERRUPT_INT_ASSERT_MASK 0x08
MikkoZ 0:0bcc203c5c75 163 #define RPR0521_INTERRUPT_INT_LATCH_MASK 0x04
MikkoZ 0:0bcc203c5c75 164 #define RPR0521_INTERRUPT_INT_TRIG_MASK 0x03
MikkoZ 0:0bcc203c5c75 165 #define RPR0521_MANUFACT_ID_MASK 0xFF
MikkoZ 0:0bcc203c5c75 166
MikkoZ 0:0bcc203c5c75 167 #endif /* RPR0521_H */