summaryrefslogtreecommitdiff
path: root/firmware/inc/driver/mcp4725.h
blob: 06f6281de63f4967e1ce0fb88bad1d33d5accf34 (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
/**
 * 
 * Author: Dylan Muller
 * Copyright (c) 2025 
 * All rights reserved.
 * 
 * - Commercial/IP use prohibited.
 * - Attribution required.
 * See License.txt
 *
 */

#ifndef MCP4725_H_
#define MCP4725_H_

#define MCP4725_BIT_PD0(x) (x << 4)
#define MCP4725_BIT_PD1(x) (x << 5)

#define MCP4725_ID_GATE_VOLT 0xB1
#define MCP4725_ID_DRAIN_VOLT 0xB2

#define MCP4725_DEV_0 0
#define MCP4725_DEV_1 1

#define MCP4725_DEV_GATE_VOLT MCP4725_DEV_0
#define MCP4725_DEV_DRAIN_VOLT MCP4725_DEV_1

#define MCP4725_DEV_GATE_VOLT_ADDR 0x60
#define MCP4725_DEV_DRAIN_VOLT_ADDR 0x61

#define MCP4725_DRAIN_GAIN 23

void dac_init(
    uint16_t init_value
);

void dac_write(
    uint8_t id,
    uint16_t value,
    uint8_t conv_bypass
);

uint16_t dac_read(
    uint8_t id,
    uint8_t conv_bypass
);

#endif