aboutsummaryrefslogtreecommitdiff
path: root/driver_fw/mcp9801.h
blob: 6060c980a159fadd19b8596a7e9fbfbe7044d58d (plain)
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
/* 8seg LED display driver firmware
 * Copyright (C) 2018 Sebastian Götte <code@jaseg.net>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __MCP9801_H__
#define __MCP9801_H__

#define MCP9801_I2C_ADDR 0x90
#define MCP9801_I2C_PERIPH I2C1

#include <stdint.h>

enum mcp9801_regmap {
    MCP9801_REG_TEMP    = 0,
    MCP9801_REG_CONFIG  = 1,
    MCP9801_REG_HYST    = 2,
    MCP9801_REG_LIMIT   = 3
};

enum mcp9801_config {
    MCP9801_ONESHOT_ON  = 1<<7,
    MCP9801_ONESHOT_OFF = 0<<7,
    MCP9801_ONESHOT_Msk = 1<<7,

    MCP9801_RES_9BIT  = 0<<5,
    MCP9801_RES_10BIT = 1<<5,
    MCP9801_RES_11BIT = 2<<5,
    MCP9801_RES_12BIT = 3<<5,
    MCP9801_RES_Msk   = 3<<5,

    MCP9801_FAULT_QUEUE_1   = 0<<3,
    MCP9801_FAULT_QUEUE_2   = 1<<3,
    MCP9801_FAULT_QUEUE_4   = 2<<3,
    MCP9801_FAULT_QUEUE_6   = 3<<3,
    MCP9801_FAULT_QUEUE_Msk = 3<<3,

    MCP9801_ALERT_HIGH = 1<<2,
    MCP9801_ALERT_LOW  = 0<<2,
    MCP9801_ALERT_Msk  = 1<<2,

    MCP9801_MODE_INT  = 1<<1,
    MCP9801_MODE_COMP = 0<<1,
    MCP9801_MODE_Msk  = 1<<1,

    MCP9801_SHUTDOWN_ON  = 1<<0,
    MCP9801_SHUTDOWN_OFF = 0<<0,
    MCP9801_SHUTDOWN_Msk = 1<<0,
};

void mcp9801_init(void);
int32_t mcp9801_read_mdegC(void);

#endif /* __MCP9801_H__ */