-/* Copyright (C) 2012-2013 Czech Technical University in Prague
+/* Copyright (C) 2012-2015 Czech Technical University in Prague
*
* Authors:
* - Michal Horn
#define DAC_PIN_NUM 4
-// See mcp4922.pdf p. 24
-// Options:
-// Bit 13: Output Gain Selection bit set = 1x (VOUT = VREF * D/4096)
-// Bit 15: DACA (0) or DACB (1) Selection bit.
-#define DAC1_INIT_VAL (_BV(13) )
-#define DAC2_INIT_VAL (_BV(13) | _BV(15))
-#define DAC3_INIT_VAL (_BV(13) )
-#define DAC4_INIT_VAL (_BV(13) | _BV(15))
/**
* Pin status for each DAC pin, the structure of each field is defined
* as spi command structure.
+ *
+ * See mcp4922.pdf p. 24
+ * Options:
+ * Bit 13: Output Gain Selection bit set = 1x (VOUT = VREF * D/4096)
+ * Bit 15: DACA (0) or DACB (1) Selection bit.
+ *
*/
-uint16_t dac_pin_stat[DAC_PIN_NUM] = {
- DAC1_INIT_VAL,
- DAC2_INIT_VAL,
- DAC3_INIT_VAL,
- DAC4_INIT_VAL
+static uint16_t dac_pin_status[DAC_PIN_NUM] = {
+ (_BV(13) ),
+ (_BV(13) | _BV(15)),
+ (_BV(13) ),
+ (_BV(13) | _BV(15))
};
/**
* Port names for each DAC port, to be easily accessible by indexing
*/
const char *dac_port_names[DAC_PIN_NUM] = {
- PORT_NAME_DAC1_2,
- PORT_NAME_DAC1_2,
- PORT_NAME_DAC3_4,
- PORT_NAME_DAC3_4
+ DIO_PORT_NAME_DAC1_2,
+ DIO_PORT_NAME_DAC1_2,
+ DIO_PORT_NAME_DAC3_4,
+ DIO_PORT_NAME_DAC3_4
};
/**
// Prepare command
if (enabled)
- bit_set(dac_pin_stat[pin], 12);
+ bit_set(dac_pin_status[pin], 12);
else
- bit_clear(dac_pin_stat[pin], 12);
+ bit_clear(dac_pin_status[pin], 12);
- dac_pin_stat[pin] = dac_pin_stat[pin] & 0xF000;
- dac_pin_stat[pin] |= (value & 0xFFF);
+ dac_pin_status[pin] = dac_pin_status[pin] & 0xF000;
+ dac_pin_status[pin] |= (value & 0xFFF);
uint32_t commands[2];
// Warning!!! Can be "optimized" by compiler
- dac_spi_cmd = dac_pin_stat[pin];
+ dac_spi_cmd = dac_pin_status[pin];
dac_spi_cmd_sh = dac_spi_cmd;
//--
- port_desc_t *desc;
- desc = hal_port_get_dsc(dac_port_names[pin], -1);
+ dio_port_desc_t *desc;
+ desc = dio_port_get_dsc(dac_port_names[pin], -1);
commands[0] = (dac_spi_cmd_sh & 0xFF00) >> 8;
commands[1] = (dac_spi_cmd_sh & 0xFF);