1 |
ron |
1 |
/**
|
|
|
2 |
* Marlin 3D Printer Firmware
|
|
|
3 |
* Copyright (C) 2016 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 |
|
|
|
23 |
/**
|
|
|
24 |
* Arduino library for MicroChip MCP4728 I2C D/A converter.
|
|
|
25 |
*/
|
|
|
26 |
|
|
|
27 |
#ifndef DAC_MCP4728_H
|
|
|
28 |
#define DAC_MCP4728_H
|
|
|
29 |
|
|
|
30 |
#include "MarlinConfig.h"
|
|
|
31 |
|
|
|
32 |
#if ENABLED(DAC_STEPPER_CURRENT)
|
|
|
33 |
#include "Wire.h"
|
|
|
34 |
|
|
|
35 |
#define defaultVDD DAC_STEPPER_MAX //was 5000 but differs with internal Vref
|
|
|
36 |
#define BASE_ADDR 0x60
|
|
|
37 |
#define RESET 0B00000110
|
|
|
38 |
#define WAKE 0B00001001
|
|
|
39 |
#define UPDATE 0B00001000
|
|
|
40 |
#define MULTIWRITE 0B01000000
|
|
|
41 |
#define SINGLEWRITE 0B01011000
|
|
|
42 |
#define SEQWRITE 0B01010000
|
|
|
43 |
#define VREFWRITE 0B10000000
|
|
|
44 |
#define GAINWRITE 0B11000000
|
|
|
45 |
#define POWERDOWNWRITE 0B10100000
|
|
|
46 |
#define GENERALCALL 0B00000000
|
|
|
47 |
#define GAINWRITE 0B11000000
|
|
|
48 |
|
|
|
49 |
// This is taken from the original lib, makes it easy to edit if needed
|
|
|
50 |
// DAC_OR_ADDRESS defined in pins_BOARD.h file
|
|
|
51 |
#define DAC_DEV_ADDRESS (BASE_ADDR | DAC_OR_ADDRESS)
|
|
|
52 |
|
|
|
53 |
|
|
|
54 |
void mcp4728_init();
|
|
|
55 |
uint8_t mcp4728_analogWrite(uint8_t channel, uint16_t value);
|
|
|
56 |
uint8_t mcp4728_eepromWrite();
|
|
|
57 |
uint8_t mcp4728_setVref_all(uint8_t value);
|
|
|
58 |
uint8_t mcp4728_setGain_all(uint8_t value);
|
|
|
59 |
uint16_t mcp4728_getValue(uint8_t channel);
|
|
|
60 |
uint8_t mcp4728_fastWrite();
|
|
|
61 |
uint8_t mcp4728_simpleCommand(byte simpleCommand);
|
|
|
62 |
uint8_t mcp4728_getDrvPct(uint8_t channel);
|
|
|
63 |
void mcp4728_setDrvPct(uint8_t pct[XYZE]);
|
|
|
64 |
|
|
|
65 |
#endif
|
|
|
66 |
#endif // DAC_MCP4728_H
|