-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.con.max31856.spin
110 lines (88 loc) · 3.61 KB
/
core.con.max31856.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
{
----------------------------------------------------------------------------------------------------
Filename: core.con.max31856.spin
Description: MAX31856-specific constants
Author: Jesse Burt
Started: Sep 30, 2018
Updated: Sep 6, 2024
Copyright (c) 2024 - See end of file for terms of use.
----------------------------------------------------------------------------------------------------
}
CON
' SPI Clock Polarity/Mode
SCK_MAX_FREQ = 5_000_000
SPI_MODE = 3
' Read register addresses ORd with $80 to form Write Addresses
WRITE_REG = $80
CR0 = $00
CR0_MASK = $FF
CMODE = 7
ONESHOT = 6
OCFAULT = 4
CJ = 3
FAULT = 2
FAULTCLR = 1
NOTCHFILT = 0
OCFAULT_BITS = %11
CMODE_MASK = (1 << CMODE) ^ CR0_MASK
ONESHOT_MASK = (1 << ONESHOT) ^ CR0_MASK
OCFAULT_MASK = (OCFAULT_BITS << OCFAULT) ^ CR0_MASK
CJ_MASK = (1 << CJ) ^ CR0_MASK
FAULT_MASK = (1 << FAULT) ^ CR0_MASK
FAULTCLR_MASK = (1 << FAULTCLR) ^ CR0_MASK
NOTCHFILT_MASK = 1 ^ CR0_MASK
CR1 = $01
CR1_MASK = $7F
AVGSEL = 4
TC_TYPE = 0
AVGSEL_BITS = %111
TC_TYPE_BITS = %1111
AVGSEL_MASK = (AVGSEL_BITS << AVGSEL) ^ CR1_MASK
TC_TYPE_MASK = TC_TYPE_BITS ^ CR1_MASK
FAULTMASK = $02
FAULTMASK_MASK = $3F
RSVD = 6
CJ_HIGH = 5
CJ_LOW = 4
TC_HIGH = 3
TC_LOW = 2
OV_UV = 1
OPEN = 0
RSVD_BITS = %11
CJ_HIGH_MASK = (1 << CJ_HIGH) ^ FAULTMASK_MASK
CJ_LOW_MASK = (1 << CJ_LOW) ^ FAULTMASK_MASK
TC_HIGH_MASK = (1 << TC_HIGH) ^ FAULTMASK_MASK
TC_LOW_MASK = (1 << TC_LOW) ^ FAULTMASK_MASK
OV_UV_MASK = (1 << OV_UV) ^ FAULTMASK_MASK
OPEN_MASK = 1 ^ FAULTMASK_MASK
CJHF = $03
CJLF = $04
LTHFTH = $05
LTHFTL = $06
LTLFTH = $07
LTLFTL = $08
CJTO = $09
CJTH = $0A
CJTL = $0B
LTCBH = $0C
LTCBM = $0D
LTCBL = $0E
SR = $0F
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.
}