-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.con.tsl2591.spin
114 lines (91 loc) · 3.49 KB
/
core.con.tsl2591.spin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
{
----------------------------------------------------------------------------------------------------
Filename: core.con.tsl2591.spin
Description: TSL2591-specific constants
Author: Jesse Burt
Started: Feb 17, 2018
Updated: Jun 2, 2024
Copyright (c) 2024 - See end of file for terms of use.
----------------------------------------------------------------------------------------------------
}
CON
I2C_MAX_FREQ = 400_000
SLAVE_ADDR = $29 << 1
DEV_ID_RESP = $50
T_POR = 100_000 ' usec
' Registers (fields within registers are indented)
ENABLE = $00
ENABLE_MASK = $D3
NPIEN = 7
SAI = 6
AIEN = 4
AEN = 1
PON = 0
NPIEN_MASK = (1 << NPIEN) ^ ENABLE_MASK
SAI_MASK = (1 << SAI) ^ ENABLE_MASK
AIEN_MASK = (1 << AIEN) ^ ENABLE_MASK
AEN_MASK = (1 << AEN) ^ ENABLE_MASK
PON_MASK = (1 << PON) ^ ENABLE_MASK
CONTROL = $01
CONTROL_MASK = $B7
SRESET = 7
AGAIN = 4
ATIME = 0
AGAIN_BITS = %11
ATIME_BITS = %111
AGAIN_MASK = (AGAIN_BITS << AGAIN) ^ CONTROL_MASK
ATIME_MASK = (ATIME_BITS << ATIME) ^ CONTROL_MASK
AILTL = $04
AILTH = $05
AIHTL = $06
AIHTH = $07
NPAILTL = $08
NPAILTH = $09
NPAIHTL = $0A
NPAIHTH = $0B
PERSIST = $0C
PERSIST_MASK = $0F
APERS = 0
APERS_BITS = %1111
PID = $11
PID_MASK = $30
P_ID = 4
P_ID_BITS = %11
ID = $12
STATUS = $13
STATUS_MASK = $31
NPINTR = 5
AINT = 4
AVALID = 0
NPINTR_MASK = (1 << NPINTR) ^ STATUS_MASK
AINT_MASK = (1 << AINT) ^ STATUS_MASK
AVALID_MASK = (1 << AVALID) ^ STATUS_MASK
C0DATAL = $14
C0DATAH = $15
C1DATAL = $16
C1DATAH = $17
CMD_NORMAL = %1_01_00000
CMD_SPECIAL = %1_11_00000
' Special functions (used with TRANS_SPECIAL)
SF_FORCEINT = CMD_SPECIAL | %00100
SF_CLRALSINT = CMD_SPECIAL | %00110
SF_CLRALS_NP_INT= CMD_SPECIAL | %00111
SF_CLR_NP_INT = CMD_SPECIAL | %01010
PUB null()
' This is not a top-level object
DAT
{
Copyright 2024 Jesse Burt
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
}