/*
 * mcp42x6.c
 *
 * Created: 20.02.2019 20:44:16
 *  Author: jens
 */ 

#include "mcp42x6.h"

size_t MCP47x6_write_volatile_dac(uint16_t dac_value, uint8_t *buffer, size_t size)
{
	*(buffer++) = ~mask & (uint8_t)(dac_value >> 8);
	*(buffer++) = (uint8_t)(dac_value >> 0);
	
	return 2;
}

size_t MCP47x6_write_volatile_mem(uint16_t dac_value, uint8_t *buffer, size_t size)
{
	*(buffer++) = mask & 0x40;
	dac_value <<= 4;
	*(buffer++) = (uint8_t)(dac_value >> 8);
	*(buffer++) = (uint8_t)(dac_value >> 0);
	
	return 3;
}
