Simple driver for the 12-bit DAC DAC7311 from TI

DAC7311.cpp

Committer:
macgyveremir
Date:
2012-10-23
Revision:
1:5497575badba
Parent:
0:ca49770e05b5

File content as of revision 1:5497575badba:

#include "DAC7311.h"

void DAC7311::set_mode (unsigned short mode)
{
    this->mode = mode;
    
    spi->format (16, DAC7311_SPI_MODE);
    wait_us (5);
    
    *sync = 0;
    spi->write (mode | conf_data_12(value));
    *sync = 1;
}

void DAC7311::set_value (unsigned short value)
{
    this->value = value;
    
    spi->format (16, DAC7311_SPI_MODE);
    wait_us (5);
    
    *sync = 0;
    spi->write (mode | conf_data_12(value));
    *sync = 1;
}