Driver C++ source code for MAX5216/MAX5214 16-bit/14-bit DAC SPI (50MHz) bus ICs. Low power Digital-to_Analog Converter chips which accept supply voltages of 2.7V to 5.5V. Features Rail-to-Rail Buffered Output Operation and Safe Power-On Reset (POR) to Zero DAC Output.
Dependents: MAX5216_16_Bit_DAC_Hello_Code
Fork of MAX5487_Digital_Pot_Potentiometer_Rheostat_Resistor_Wiper by
MAX5487.cpp@1:bc368afe2ec8, 2018-07-14 (annotated)
- Committer:
- jungkeviny
- Date:
- Sat Jul 14 04:25:25 2018 +0000
- Revision:
- 1:bc368afe2ec8
- Parent:
- 0:3d525ab09933
header file now has 2 method declarations to writeCommands
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jungkeviny | 1:bc368afe2ec8 | 1 | #include "MAX5487.h" |
jungkeviny | 1:bc368afe2ec8 | 2 | |
jungkeviny | 1:bc368afe2ec8 | 3 | MAX5487::MAX5487(SPI &spi, DigitalOut &pin) : m_spi(spi), m_pin(pin) |
jungkeviny | 1:bc368afe2ec8 | 4 | { |
jungkeviny | 1:bc368afe2ec8 | 5 | m_pin = 1; |
jungkeviny | 1:bc368afe2ec8 | 6 | } |
jungkeviny | 1:bc368afe2ec8 | 7 | |
jungkeviny | 1:bc368afe2ec8 | 8 | |
jungkeviny | 1:bc368afe2ec8 | 9 | void MAX5487::writeCommand(MAX5487::setting_t setting, int value) |
jungkeviny | 1:bc368afe2ec8 | 10 | { |
jungkeviny | 1:bc368afe2ec8 | 11 | if((value >> 8) > 0) { |
jungkeviny | 1:bc368afe2ec8 | 12 | printf("value in writeCommand > 8 bits!\r\n"); |
jungkeviny | 1:bc368afe2ec8 | 13 | return; |
jungkeviny | 1:bc368afe2ec8 | 14 | } |
jungkeviny | 1:bc368afe2ec8 | 15 | m_pin = 0; |
jungkeviny | 1:bc368afe2ec8 | 16 | m_spi.write(setting); |
jungkeviny | 1:bc368afe2ec8 | 17 | m_spi.write(value); |
jungkeviny | 1:bc368afe2ec8 | 18 | m_pin = 1; |
jungkeviny | 1:bc368afe2ec8 | 19 | } |
jungkeviny | 1:bc368afe2ec8 | 20 | |
jungkeviny | 1:bc368afe2ec8 | 21 | |
jungkeviny | 1:bc368afe2ec8 | 22 | void MAX5487::writeCommand(MAX5487::setting_t setting) |
jungkeviny | 1:bc368afe2ec8 | 23 | { |
jungkeviny | 1:bc368afe2ec8 | 24 | m_pin = 0; |
jungkeviny | 1:bc368afe2ec8 | 25 | m_spi.write(setting); |
jungkeviny | 1:bc368afe2ec8 | 26 | m_pin = 1; |
jungkeviny | 1:bc368afe2ec8 | 27 | } |
jungkeviny | 1:bc368afe2ec8 | 28 |