#include <avr/io.h>
#include "mcp4922.h"
#include "spi.h"
void DAC_write(unsigned char data) {
unsigned char first, second;
first=(0b10110000 | data>>4); // DACB, unbuffered, 1x, ON, 12 data bites
second=(data<<4);
DAC_CS_PORT &= ~(1 << DAC_CS_PIN);
SPI_MasterTransmit(first);
SPI_MasterTransmit(second);
DAC_CS_PORT |= 1 << DAC_CS_PIN;
}