diff --git a/src/eis_shield/ad5933.c b/src/eis_shield/ad5933.c index 467a45b9d62a5a56169e53f9e7da7516abea17b0..ac8c225be2a6df4fac59883268f531d804d5f4cd 100644 --- a/src/eis_shield/ad5933.c +++ b/src/eis_shield/ad5933.c @@ -108,7 +108,6 @@ static uint8_t read_byte(uint8_t address); static void read_block(uint8_t address, uint8_t length, uint8_t* buffer); static void write_byte(uint8_t address, uint8_t value); static void write_block(uint8_t address, uint8_t length, uint8_t* buffer); -static void reset(void); static void internal_clock_set(bool); static bool set_start_frequency(uint32_t); static bool set_increment_frequency(uint32_t); @@ -222,7 +221,7 @@ static void write_block(uint8_t address, uint8_t length, uint8_t* buffer) { } void ad5933_set_params(uint32_t start, uint32_t increment, uint16_t n_increments, - uint16_t settle_cycles, uint8_t gain) { + uint16_t settle_cycles, uint8_t gain, uint8_t output_range) { /** * Set EIS sweep parameters. * @@ -233,21 +232,19 @@ void ad5933_set_params(uint32_t start, uint32_t increment, uint16_t n_increments * @param gain PGA gain */ internal_clock_set(1); - reset(); + ad5933_reset(); set_start_frequency(start); set_increment_frequency(increment); set_num_increments(n_increments); - set_gain(gain, 1); + set_gain(gain, output_range); set_settling_cycles(settle_cycles); - printf("Initializing of AD5933 Complete\r\n"); - return; } -static void reset(void) { +void ad5933_reset(void) { uint8_t current = read_byte(CTRL_REG2); write_byte(CTRL_REG2, current | CTRL_RESET); } @@ -264,16 +261,6 @@ static void internal_clock_set(bool internal) { write_byte(CTRL_REG2, current); } -void ad5933_test(void){ - ad5933_set_params(0x0f5c28, 0x9f4f, 10, 2000, 1); - - cint16_t result[10]; - ad5933_sweep(result, 10); - - for (uint8_t n = 0; n < 10; n++) { - printf("%i + %ii\r\n", result[n].real, result[n].imag); - } -} static bool set_start_frequency(uint32_t start) { if (start > 0xFFFFFF) { @@ -379,7 +366,7 @@ static void set_control_mode(uint8_t mode) { } void ad5933_sweep(cint16_t imp[], int n) { - reset(); + ad5933_reset(); set_control_mode(CTRL_STANDBY_MODE); set_control_mode(CTRL_INIT_START_FREQ); delay_ms(400); @@ -403,18 +390,11 @@ void ad5933_sweep(cint16_t imp[], int n) { cint16_t ad5933_measure_one(uint8_t measure_type) { cint16_t data; - - if ((read_byte(STATUS_REG) & STATUS_SWEEP_DONE) == STATUS_SWEEP_DONE) { - data.real = 0; - data.imag = 0; - printf("#INFO: AD5933: Reached end of sweep.\r\n"); - set_control_mode(CTRL_POWER_DOWN_MODE); - return data; - } + switch (measure_type) { case AD5933_MEASURE_FIRST: - reset(); + ad5933_reset(); set_control_mode(CTRL_STANDBY_MODE); set_control_mode(CTRL_INIT_START_FREQ); delay_ms(400); @@ -436,6 +416,13 @@ cint16_t ad5933_measure_one(uint8_t measure_type) { return data; } + if ((read_byte(STATUS_REG) & STATUS_SWEEP_DONE) == STATUS_SWEEP_DONE) { + data.real = 0; + data.imag = 0; + printf("#INFO: AD5933: Reached end of sweep.\r\n"); + set_control_mode(CTRL_POWER_DOWN_MODE); + return data; + } return(ad5993_get_complex_data()); } @@ -461,3 +448,5 @@ cint16_t ad5993_get_complex_data(void) { return result; } + + diff --git a/src/eis_shield/ad5933.h b/src/eis_shield/ad5933.h index 24ba4d422d512e277eb1a652f380f70d028c1ece..03a5b1978f42837d526af52224228cca90311d79 100644 --- a/src/eis_shield/ad5933.h +++ b/src/eis_shield/ad5933.h @@ -22,12 +22,11 @@ typedef struct c_int16_t { int16_t imag; } cint16_t; +void ad5933_reset(void); void ad5933_set_params(uint32_t start, uint32_t increment, uint16_t n_increments, - uint16_t settle_cycles, uint8_t gain); + uint16_t settle_cycles, uint8_t gain, uint8_t output_range); void ad5933_sweep(cint16_t imp[], int n); cint16_t ad5993_get_complex_data(void); cint16_t ad5933_measure_one(uint8_t measure_type); -void ad5933_test(void); - #endif /* ad5933_h */ diff --git a/src/eis_shield/ds4550.c b/src/eis_shield/ds4550.c index 52e4982303ccec35d54e04f74421c84f79affd48..3b060b0a8d2e0eac5ff320bebf61da6d408f550a 100644 --- a/src/eis_shield/ds4550.c +++ b/src/eis_shield/ds4550.c @@ -8,6 +8,7 @@ #include #include +#include #include "ds4550.h" #include "../config/dstat_config.h" @@ -100,7 +101,7 @@ static void write_block(uint8_t address, uint8_t length, uint8_t* buffer) { twi_pack.length = length; if(twi_master_write(&DS4550_TWI, &twi_pack) != TWI_SUCCESS) - printf("#ERR: DS4550: TWI write fail\r\n"); + printf("#ERR: DS4550: TWI write fail %hhu\r\n", length); } void ds4550_set_pin(uint8_t pin, uint8_t state) { @@ -117,6 +118,7 @@ void ds4550_set_pin(uint8_t pin, uint8_t state) { } write_block(PULLUP_0, 2, (uint8_t*)¤t); + delay_ms(50); } void ds4550_set_pins(uint16_t pins, uint16_t pin_mask) { @@ -128,6 +130,7 @@ void ds4550_set_pins(uint16_t pins, uint16_t pin_mask) { current |= pins; write_block(PULLUP_0, 2, (uint8_t*)¤t); + delay_ms(50); } uint16_t ds4550_get_pins(void) { diff --git a/src/eis_shield/eis.c b/src/eis_shield/eis.c new file mode 100644 index 0000000000000000000000000000000000000000..9850cff927506a452facd0effe7159bc5fa2eff5 --- /dev/null +++ b/src/eis_shield/eis.c @@ -0,0 +1,92 @@ +// +// eis.c +// dstat-firmware +// +// Created by Michael Dryden on 2017-03-20. +// Copyright © 2017 Michael Dryden. All rights reserved. +// + +#include + +#include "eis.h" +#include "eis_misc.h" +#include "ds4550.h" +#include "ad5272.h" +#include "max5443.h" + +uint8_t eis_status = EIS_STATUS_DONE; + +void eis_init(void){ + ad5272_init(); + ds4550_init(); +} + +void eis_measure_auto(uint32_t start, uint32_t increment, uint16_t n_increments, + uint16_t settle_cycles, uint8_t pga_gain, uint8_t output_range, + uint8_t iv_gain, uint16_t attenuation, uint16_t offset, + uint8_t reference, cint16_t* result_buffer){ + /** + Runs eis experiment in auto mode and writes result to buffer. + + @param start Start frequency in DDS units + @param increment Frequency increment in DDS units + @param n_increments Number of increments + @param settle_cycles Number of settling cycles + @param pga_gain PGA gain setting + @param output_range Excitation voltage setting + @param iv_gain IV converter gain setting + @param attenuation gain setting + @param offset offset voltage in max5443 units + @param reference Reference connection setting + @param result_buffer Buffer to store results + */ + + ad5933_set_params(start, increment, n_increments, settle_cycles, pga_gain, output_range); + eis_set_ref(reference); + eis_set_gain(iv_gain); + ad5272_write_rdac(attenuation); + max5443_set_voltage1(offset); + + delay_ms(300); + + ad5933_sweep(result_buffer, n_increments); + + return; +} + +void eis_set_params(uint32_t start, uint32_t increment, uint16_t n_increments, + uint16_t settle_cycles, uint8_t pga_gain, uint8_t output_range, + uint8_t iv_gain, uint16_t attenuation, uint16_t offset, + uint8_t reference){ + + ad5933_set_params(start, increment, n_increments, settle_cycles, pga_gain, output_range); + eis_set_ref(reference); + eis_set_gain(iv_gain); + ad5272_write_rdac(attenuation); + max5443_set_voltage1(offset); + + eis_status = EIS_STATUS_READY; +} + +cint16_t eis_measure_one(void){ + cint16_t result; + + switch (eis_status) { + case EIS_STATUS_READY: + eis_status = EIS_STATUS_MEASURE; + result = ad5933_measure_one(AD5933_MEASURE_FIRST); + break; + case EIS_STATUS_MEASURE: + result = ad5933_measure_one(AD5933_MEASURE_NEXT); + break; + default: + result = ad5933_measure_one(AD5933_MEASURE_NEXT); + break; + } + + if (result.real == 0 && result.imag == 0){ + eis_status = EIS_STATUS_DONE; + } + + return result; +} diff --git a/src/eis_shield/eis.h b/src/eis_shield/eis.h new file mode 100644 index 0000000000000000000000000000000000000000..ddd717a65956cb3cd3800f8a76895a0359be1773 --- /dev/null +++ b/src/eis_shield/eis.h @@ -0,0 +1,33 @@ +// +// eis.h +// dstat-firmware +// +// Created by Michael Dryden on 2017-03-20. +// Copyright © 2017 Michael Dryden. All rights reserved. +// + +#ifndef eis_h +#define eis_h + +#define EIS_STATUS_READY 0 +#define EIS_STATUS_MEASURE 1 +#define EIS_STATUS_DONE 2 + +#include +#include "ad5933.h" + +void eis_init(void); + +void eis_measure_auto(uint32_t start, uint32_t increment, uint16_t n_increments, + uint16_t settle_cycles, uint8_t pga_gain, uint8_t output_range, + uint8_t iv_gain, uint16_t attenuation, uint16_t offset, + uint8_t reference, cint16_t* result_buffer); +void eis_set_params(uint32_t start, uint32_t increment, uint16_t n_increments, + uint16_t settle_cycles, uint8_t pga_gain, uint8_t output_range, + uint8_t iv_gain, uint16_t attenuation, uint16_t offset, + uint8_t reference); +cint16_t eis_measure_one(void); + +extern uint8_t eis_status; + +#endif /* eis_h */ diff --git a/src/eis_shield/eis_misc.c b/src/eis_shield/eis_misc.c index cb8d3e9d90204f2c1f5aa9f667634042b1ab46cb..8f2e60ca9489fd477fe8257b75de685e1f30a9e8 100644 --- a/src/eis_shield/eis_misc.c +++ b/src/eis_shield/eis_misc.c @@ -8,6 +8,7 @@ #include "eis_misc.h" #include "ds4550.h" +#include void eis_set_gain(uint8_t gain){ /** @@ -15,30 +16,40 @@ void eis_set_gain(uint8_t gain){ * * @param gain Gain setting defined in eis_misc.h */ + + delay_ms(30); switch (gain) { case EIS_IV_GAIN_0: ds4550_set_pins(0b110000110, 0b111000000); + printf("#INFO: EIS gain 0\r\n"); break; case EIS_IV_GAIN_100: ds4550_set_pins(0b111000110, 0b111000000); + printf("#INFO: EIS gain 100\r\n"); break; case EIS_IV_GAIN_3k: ds4550_set_pins(0b101000110, 0b111000000); + printf("#INFO: EIS gain 3k\r\n"); break; case EIS_IV_GAIN_30k: ds4550_set_pins(0b100000110, 0b111000000); + printf("#INFO: EIS gain 30k\r\n"); break; case EIS_IV_GAIN_300k: ds4550_set_pins(0b011000110, 0b111000000); + printf("#INFO: EIS gain 300k\r\n"); break; case EIS_IV_GAIN_3M: ds4550_set_pins(0b010000110, 0b111000000); + printf("#INFO: EIS gain 3M\r\n"); break; case EIS_IV_GAIN_30M: ds4550_set_pins(0b001000110, 0b111000000); + printf("#INFO: EIS gain 30M\r\n"); break; case EIS_IV_GAIN_100M: ds4550_set_pins(0b000000110, 0b111000000); + printf("#INFO: EIS gain 100M\r\n"); break; default: printf("#WAR: EIS: No gain provided\r\n"); @@ -54,25 +65,31 @@ void eis_set_ref(uint8_t ref){ * * @param ref Reference setting defined in eis_misc.h */ + + delay_ms(30); switch (ref) { case EIS_REF_CELL: ds4550_set_pins(0b000000000, 0b000110000); + printf("#INFO: EIS REF RE\r\n"); break; case EIS_REF_R1: ds4550_set_pins(0b000010000, 0b000110000); + printf("#INFO: EIS REF R1\r\n"); break; case EIS_REF_R2: ds4550_set_pins(0b000100000, 0b000110000); + printf("#INFO: EIS REF R2\r\n"); break; case EIS_REF_PARALLEL: ds4550_set_pins(0b000110000, 0b000110000); + printf("#INFO: EIS REF R1+2\r\n"); break; default: printf("#WAR: EIS: No reference set.\r\n"); break; } - + return; } diff --git a/src/experiment.c b/src/experiment.c index ea2b10bdfecdcbe9ba9fbb8311aa64d93a719bf2..e7b39a9eff2d5522089c859b65dc7a0cbe0efe00 100644 --- a/src/experiment.c +++ b/src/experiment.c @@ -23,16 +23,8 @@ #include "eis_shield/ad5933.h" #include "eis_shield/ds4550.h" #include "eis_shield/ad5272.h" - -// setting the digital outputs for the mux, relay, and chip select. -#define MUX0 IOPORT_CREATE_PIN (PORTF, 0) -#define MUX1 IOPORT_CREATE_PIN (PORTF, 1) -#define MUX2 IOPORT_CREATE_PIN (PORTF, 2) -#define RELAY IOPORT_CREATE_PIN (PORTF, 3) - -// we had some troubles using the default CS with the MCP4131, used digital outs as substitute -#define SPI_CS1 IOPORT_CREATE_PIN (PORTF, 4) -#define SPI_CS2 IOPORT_CREATE_PIN (PORTF, 5) +#include "eis_shield/eis_misc.h" +#include "eis_shield/eis.h" //Public variable definitions uint16_t g_gain = POT_GAIN_30k; @@ -65,14 +57,7 @@ static uint8_t _swv_singledir(uint16_t dacindex, uint16_t dacindex_stop, uint16_ static uint8_t _dpv_singledir(uint16_t dacindex, uint16_t dacindex_stop, uint16_t dacindex_pulse_height, uint16_t dacindex_step, uint8_t direction); static void pmt_idle(void); -//there may be a small set of errors in these calls -void mux_control(uint16_t); -void pga_init_pins(void); -void pga_set(uint8_t index, struct usart_spi_device); -void pga_init_module(struct usart_spi_device); -void frequency_sweep(uint32_t, uint32_t, uint16_t); -uint16_t division(uint32_t, uint32_t); //interrupt callback setup typedef void (*port_callback_t) (void); static port_callback_t portd_int0_callback; @@ -89,14 +74,9 @@ void experiment_handler(char command){ static uint16_t pct1, pct2; uint16_t tcs_data[] = {0,0,0,0}; uint16_t tcs_data1[] = {0,0,0,0}; - uint32_t test1, start_f, stop_f, step_f; - uint16_t spi_sig1, spi_sig2, mux_sig, calib; + + double p6; - struct - { uint32_t high; - uint16_t middle; - uint16_t low; - } transition; switch (command){ case 'A': //ADS Buffer/rate/PGA values from ads1255.h @@ -134,106 +114,58 @@ void experiment_handler(char command){ precond(pcv1,pct1,pcv2,pct2); dpv_experiment(p1,p2,u1,u2,u3,u4); break; - - case 'T': - scanf("%lx", &test1); - test(test1); - break; case 'I': + { + uint32_t start_f, increment_f; + uint16_t n_increments, settle_cycles, attenuation, offset; + uint8_t pga_gain, output_range, iv_gain, reference; - //Initiate bits to send transition between calibration and normal run - transition.high = 0xFFFFFFFF; - transition.middle = 0xFFFF; - transition.low = 0xFFFF; - if (eis_initialized == 0){ - eis_init(); - eis_initialized = 1; - printf("#INFO: TWI initialized"); - } - - // collect the necessary parameters: you need the mux control value (0-7), two SPI values - // for the control of PGA (set with the MCP4131, at values of 0-127), a start frequency, - // a stop frequency, the step frequency, and whether or not you are interested in performing - // a calibration run. - - // in addition, there may be minor pin disagreement between the drawn out circuitry and what signals - // are being used. + scanf("%lu%lu%u%u%hhu%hhu%hhu%u%u%hhu", &start_f, &increment_f, &n_increments, &settle_cycles, + &pga_gain, &output_range, &iv_gain, &attenuation, &offset, &reference); - // there is likely to be some disagreement between this and the GUI: this version of the code - // was never fully put into full system integration, so a check needs to be made for what is being - // sent from the GUI - - scanf("%u%u%lu%lu%lu%u%u",&spi_sig1, &spi_sig2, &start_f, &stop_f, &step_f, &mux_sig, &calib); - printf("#not stuck\n\r"); - test1 = stop_f - start_f; + struct result { + uint16_t increment; + cint16_t imp; + } result; - //divde to calculate the number of frequency components (this probably could've been done in the GUI) - uint16_t num_inc = floor(test1/step_f); - // num_inc = division(test1, step_f); - - //set the relay condition - // ioport_set_pin_dir(RELAY, IOPORT_DIR_OUTPUT); - // ioport_set_pin_mode(RELAY, IOPORT_MODE_PULLDOWN); - - //set the mux value - // mux_control(mux_sig); - - //set the two SPI values - //more debugging may be required: we noticed that the SPI module was only working - //the second time we tried to use it (repeating the case twice). - //Not sure in particular why this was a problem. - - pga_init_pins(); - pga_init_module(spi_device_conf_d); - - ioport_set_pin_dir(SPI_CS1, IOPORT_DIR_OUTPUT); - ioport_set_pin_mode(SPI_CS1, IOPORT_MODE_PULLDOWN); - - ioport_set_pin_dir(SPI_CS1, IOPORT_DIR_OUTPUT); - ioport_set_pin_mode(SPI_CS1, IOPORT_MODE_PULLDOWN); - ioport_set_pin_level(SPI_CS1, false); - ioport_set_pin_level(SPI_CS2, true); - - pga_set(spi_sig1, spi_device_conf_d); - - ioport_set_pin_level(SPI_CS1, true); - ioport_set_pin_level(SPI_CS2, false); - - pga_set(spi_sig2, spi_device_conf_d); - - //if we want to run a calibration set - if (calib != 0) - { - printf("B\n"); - udi_cdc_write_buf(&transition, 8); - printf("\r\n"); - - //sends the digital high to the relay pin - ioport_set_pin_level(RELAY, true); - frequency_sweep(start_f, step_f, num_inc); - ioport_set_pin_level(RELAY, false); + result.increment = 0; + + pot_exp_start(); //Disconnect DStat from shield + eis_set_params(start_f, increment_f, n_increments-1, settle_cycles, pga_gain, output_range, + iv_gain, attenuation, offset, reference); + + while (eis_status != EIS_STATUS_DONE){ + if (udi_cdc_is_rx_ready()){ + if (getchar()=='a'){ + eis_status = EIS_STATUS_DONE; + ad5933_reset(); + } + } - printf("B\n"); - udi_cdc_write_buf(&transition, 8); - printf("\r\n"); + result.imp = eis_measure_one(); + if (result.imp.real != 0 && result.imp.imag != 0) { + printf("B\n"); + udi_cdc_write_buf(&result, 6); + printf("\r\n"); + result.increment++; + } } - printf("#Sweeping\n\r"); - frequency_sweep(start_f, step_f, num_inc); - + break; + } case 'M': //PMT idle mode - holds voltage at 0 V with no data output pmt_idle(); break; - #if BOARD_VER_MAJOR == 1 && BOARD_VER_MINOR >= 2 + #if BOARD_VER_MAJOR == 1 && BOARD_VER_MINOR >= 2 case 'P': //potentiometry - time, OCP/poteniometry scanf("%u%hhu",&pct1, &o1); pot_experiment(pct1, o1); break; - #endif + #endif case 'R': //CA - steps, step_dac[], step_seconds[] scanf("%hhu",&p5); //get number of steps @@ -546,6 +478,7 @@ void ocp_exp_start(void){ */ ioport_set_port_level(IOPORT_PORTB, PIN2_bm|PIN3_bm|PIN4_bm|PIN5_bm, PIN4_bm); } + #endif void precond(int16_t v1, uint16_t t1, int16_t v2, uint16_t t2){ //assumes potentiostat switches are already set /** @@ -613,7 +546,7 @@ void precond(int16_t v1, uint16_t t1, int16_t v2, uint16_t t2){ //assumes potent aborting: volt_exp_stop(); - return; + return; } static void precond_rtc_callback(uint32_t time){ up = 0; @@ -794,6 +727,7 @@ uint8_t lsv_experiment(int16_t start, int16_t stop, uint16_t slope, int8_t first return ret; } + static void porte_int0_lsv(void){ /** * ISR for taking LSV measurements. @@ -1321,160 +1255,6 @@ uint8_t _dpv_singledir (uint16_t dacindex, uint16_t dacindex_stop, uint16_t daci return 0; } -void frequency_sweep(uint32_t START_FREQ, uint32_t FREQ_INCR, uint16_t NUM_INCR) { - - // create an array to hold the data - // + 1 is added because the sweep will also perform the first value - int real[NUM_INCR+1], imag[NUM_INCR+1]; - uint32_t current_freq; - uint16_t increments; - // perform the frequency sweep; - for (int j = 0; ; j++) - { - // break up the sweep into smaller values - if (NUM_INCR - (301*j) < 301) - { - - // final condition - delay_ms(5000); -// eis_set_params(START_FREQ+301*j*FREQ_INCR, FREQ_INCR, NUM_INCR - (301*j), 1); -// ad_sweep(&real[j*301], &imag[j*301], NUM_INCR - (300*j) + 1); - break; - } - else - { - // non final condition -// eis_set_params(START_FREQ+301*j*FREQ_INCR, FREQ_INCR, 300, 1); -// ad_sweep(&real[j*301], &imag[j*301], 301); - } - - } - - - for (int i = 0; i < NUM_INCR+1; i++) { - // transfer all the raw data - current_freq = START_FREQ + i * FREQ_INCR; - - // creating the data transfer structure - struct - { - uint32_t freq_part; - uint16_t real_part; - uint16_t img_part; - } data; - - data.freq_part = START_FREQ + i*FREQ_INCR; - data.real_part = real[i]; - data.img_part = imag[i]; - - // sending the data over - printf("B\n"); - udi_cdc_write_buf(&data, 8); - printf("\n"); - - } -} - -uint16_t division(uint32_t start, uint32_t denomenator) { - // simple divison algorithm meant to compensate for lack of division. - - uint32_t current = start; - uint16_t num_incre = 0; - while (current >= denomenator) - { - current = current - denomenator; - num_incre++; - } - - return num_incre; -} - -void pga_init_pins(void){ - //spi communications to initialize pins - - ioport_set_port_dir(IOPORT_PORTC, PIN0_bm|PIN1_bm|PIN3_bm, IOPORT_DIR_OUTPUT); - ioport_set_port_level(IOPORT_PORTC, PIN0_bm|PIN1_bm|PIN3_bm, PIN0_bm|PIN1_bm|PIN3_bm); -} - -void pga_init_module(struct usart_spi_device spi_device_conf_d){ - //spi communications to init modules - - usart_spi_init(&USARTD0); - usart_spi_setup_device(&USARTD0, &spi_device_conf_d, SPI_MODE_0, 9600, 0); -} - -void pga_set(uint8_t index, struct usart_spi_device spi_device_conf_c){ - - //spi communications to send: note, it feels like this isn't working on the first try - usart_spi_select_device(&USARTC0, &spi_device_conf_c); - - //need to send 0 for the MCP4131. - usart_spi_write_single(&USARTC0, 0x00); - usart_spi_write_single(&USARTC0, index); - usart_spi_deselect_device(&USARTC0, &spi_device_conf_c); - return; -} - -void mux_control(uint16_t setting) { - - //simple script to control the IO. Takes in numbers and changes - //the pins on digital highs/lows - ioport_set_pin_dir(MUX0, IOPORT_DIR_OUTPUT); - ioport_set_pin_mode(MUX0, IOPORT_MODE_PULLDOWN); - ioport_set_pin_dir(MUX1, IOPORT_DIR_OUTPUT); - ioport_set_pin_mode(MUX1, IOPORT_MODE_PULLDOWN); - ioport_set_pin_dir(MUX2, IOPORT_DIR_OUTPUT); - ioport_set_pin_mode(MUX2, IOPORT_MODE_PULLDOWN); - - if (setting == 0) { - ioport_set_pin_level(MUX0, false); - ioport_set_pin_level(MUX1, false); - ioport_set_pin_level(MUX2, false); - } - if (setting == 1) - { - ioport_set_pin_level(MUX0, true); - ioport_set_pin_level(MUX1, false); - ioport_set_pin_level(MUX2, false); - } - if (setting == 2) - { - ioport_set_pin_level(MUX0, false); - ioport_set_pin_level(MUX1, true); - ioport_set_pin_level(MUX2, false); - } - if (setting == 3) - { - ioport_set_pin_level(MUX0, true); - ioport_set_pin_level(MUX1, true); - ioport_set_pin_level(MUX2, false); - } - if (setting == 4) - { - ioport_set_pin_level(MUX0, false); - ioport_set_pin_level(MUX1, false); - ioport_set_pin_level(MUX2, true); - } - if (setting == 5) - { - ioport_set_pin_level(MUX0, true); - ioport_set_pin_level(MUX1, false); - ioport_set_pin_level(MUX2, true); - } - if (setting == 6) - { - ioport_set_pin_level(MUX0, false); - ioport_set_pin_level(MUX1, true); - ioport_set_pin_level(MUX2, true); - } - if (setting == 7) - { - ioport_set_pin_level(MUX0, true); - ioport_set_pin_level(MUX1, true); - ioport_set_pin_level(MUX2, true); - } - return; -} ISR(PORTD_INT0_vect){ if (portd_int0_callback) { diff --git a/src/main.c b/src/main.c index 8eeab7cedbaeba78a545aaf9511d1b23232268ee..a8936d89c9630ef513221e9d5ecce2979cf42143 100644 --- a/src/main.c +++ b/src/main.c @@ -15,7 +15,7 @@ #include #include "conf_board.h" #include "ext_twi.h" -#include "eis_shield/ds4550.h" +#include "eis_shield/eis.h" //Internal function declarations int8_t command_handler(char command); @@ -122,7 +122,7 @@ int main(void){ udc_attach(); stdio_usb_enable(); - ds4550_init(); + eis_init(); program_loop: #if BOARD_VER_MAJOR >= 1 && BOARD_VER_MINOR >= 2 && BOARD_VER_MICRO >=3