Prusa MINI Firmware overview
dac_mcp4728.h
Go to the documentation of this file.
1 /**
2  * Marlin 3D Printer Firmware
3  * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4  *
5  * Based on Sprinter and grbl.
6  * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 #pragma once
23 
24 /**
25  * Arduino library for MicroChip MCP4728 I2C D/A converter.
26  */
27 
28 #include "../../core/types.h"
29 
30 #include <Wire.h>
31 
32 #define defaultVDD DAC_STEPPER_MAX //was 5000 but differs with internal Vref
33 #define BASE_ADDR 0x60
34 #define RESET 0b00000110
35 #define WAKE 0b00001001
36 #define UPDATE 0b00001000
37 #define MULTIWRITE 0b01000000
38 #define SINGLEWRITE 0b01011000
39 #define SEQWRITE 0b01010000
40 #define VREFWRITE 0b10000000
41 #define GAINWRITE 0b11000000
42 #define POWERDOWNWRITE 0b10100000
43 #define GENERALCALL 0b00000000
44 #define GAINWRITE 0b11000000
45 
46 // This is taken from the original lib, makes it easy to edit if needed
47 // DAC_OR_ADDRESS defined in pins_BOARD.h file
48 #define DAC_DEV_ADDRESS (BASE_ADDR | DAC_OR_ADDRESS)
49 
50 void mcp4728_init();
51 uint8_t mcp4728_analogWrite(const uint8_t channel, const uint16_t value);
55 uint16_t mcp4728_getValue(const uint8_t channel);
57 uint8_t mcp4728_simpleCommand(const byte simpleCommand);
58 uint8_t mcp4728_getDrvPct(const uint8_t channel);
XYZEval
Definition: types.h:101
mcp4728_setDrvPct
void mcp4728_setDrvPct(xyze_uint8_t &pct)
TwoWire::beginTransmission
void beginTransmission(uint8_t)
Definition: Wire.cpp:16
I2C_ADDRESS
#define I2C_ADDRESS(A)
Definition: macros.h:292
GAINWRITE
#define GAINWRITE
Definition: dac_mcp4728.h:44
mcp4728_getDrvPct
uint8_t mcp4728_getDrvPct(const uint8_t channel)
mcp4728_setVref_all
uint8_t mcp4728_setVref_all(const uint8_t value)
TwoWire::requestFrom
uint8_t requestFrom(uint8_t, uint8_t)
Definition: Wire.cpp:24
i
uint8_t i
Definition: screen_test_graph.c:72
_MIN
#define _MIN(V...)
Definition: macros.h:333
DAC_STEPPER_VREF
#define DAC_STEPPER_VREF
Definition: pins_RIGIDBOARD_V2.h:45
DAC_STEPPER_GAIN
#define DAC_STEPPER_GAIN
Definition: pins_RIGIDBOARD_V2.h:46
mcp4728_eepromWrite
uint8_t mcp4728_eepromWrite()
highByte
#define highByte(w)
Definition: wiring_constants.h:89
mcp4728_setGain_all
uint8_t mcp4728_setGain_all(const uint8_t value)
Wire.h
SEQWRITE
#define SEQWRITE
Definition: dac_mcp4728.h:39
lowByte
#define lowByte(w)
Definition: wiring_constants.h:88
TwoWire::write
virtual size_t write(uint8_t)
Definition: Wire.cpp:32
GENERALCALL
#define GENERALCALL
Definition: dac_mcp4728.h:43
Wire
TwoWire Wire
Definition: Wire.cpp:60
TwoWire::read
virtual int read(void)
Definition: Wire.cpp:49
TwoWire::begin
void begin(void)
Definition: Wire.cpp:13
mcp4728_analogWrite
uint8_t mcp4728_analogWrite(const uint8_t channel, const uint16_t value)
uint8_t
const uint8_t[]
Definition: 404_html.c:3
word
unsigned int word
Definition: wiring_constants.h:108
defaultVDD
#define defaultVDD
Definition: dac_mcp4728.h:32
mcp4728_getValue
uint16_t mcp4728_getValue(const uint8_t channel)
mcp4728_init
void mcp4728_init()
TwoWire::endTransmission
uint8_t endTransmission(void)
Definition: Wire.cpp:20
TwoWire::available
virtual int available(void)
Definition: Wire.cpp:45
mcp4728_fastWrite
uint8_t mcp4728_fastWrite()
dac_mcp4728.h
DAC_STEPPER_MAX
#define DAC_STEPPER_MAX
Definition: pins_RIGIDBOARD_V2.h:44
LOOP_XYZE
#define LOOP_XYZE(VAR)
Definition: types.h:61
DAC_DEV_ADDRESS
#define DAC_DEV_ADDRESS
Definition: dac_mcp4728.h:48
mcp4728_simpleCommand
uint8_t mcp4728_simpleCommand(const byte simpleCommand)
VREFWRITE
#define VREFWRITE
Definition: dac_mcp4728.h:40