Rev Author Line No. Line
2116 paro 1 #include <avr/io.h>
2 #include "mcp4922.h"
3 #include "spi.h"
4  
5  
6 void DAC_write(unsigned char data) {
7 unsigned char first, second;
8 first=(0b10110000 | data>>4); // DACB, unbuffered, 1x, ON, 12 data bites
9 second=(data<<4);
10  
11 DAC_CS_PORT &= ~(1 << DAC_CS_PIN);
12 SPI_MasterTransmit(first);
13 SPI_MasterTransmit(second);
14 DAC_CS_PORT |= 1 << DAC_CS_PIN;
15 }