Skip to content
Snippets Groups Projects
Commit 85b2e478 authored by Michael DM Dryden's avatar Michael DM Dryden
Browse files

Support shorting CE/RE for 2-electrode measurements. Switch arch_ioport commands to just import.

parent 1eaee14d
Branches
Tags
No related merge requests found
......@@ -22,6 +22,7 @@
//Public variable definitions
uint16_t g_gain = POT_GAIN_30k;
uint8_t g_short = 0;
uint8_t autogain_enable = 1;
//Private variables
......@@ -71,8 +72,8 @@ void experiment_handler(char command){
break;
case 'G': //Gain
scanf("%u",&g_gain);
printf("#G: %u\r\n", g_gain);
scanf("%u%hhu",&g_gain, &g_short);
printf("#G: %u %u\r\n", g_gain, g_short);
pot_set_gain(); //uses global g_gain, so no params
break;
......@@ -225,16 +226,16 @@ void pot_init(void){
* @return Nothing.
*/
#if BOARD_VER_MAJOR == 1 && BOARD_VER_MINOR == 1
arch_ioport_set_port_dir(IOPORT_PORTB, PIN3_bm|PIN4_bm|PIN5_bm|PIN6_bm|PIN7_bm, IOPORT_DIR_OUTPUT);
arch_ioport_set_port_dir(IOPORT_PORTD, PIN4_bm, IOPORT_DIR_OUTPUT);
arch_ioport_set_port_level(IOPORT_PORTB, PIN3_bm|PIN4_bm|PIN5_bm|PIN6_bm|PIN7_bm, PIN6_bm|PIN7_bm);
arch_ioport_set_port_level(IOPORT_PORTD, PIN4_bm, PIN4_bm);
ioport_set_port_dir(IOPORT_PORTB, PIN3_bm|PIN4_bm|PIN5_bm|PIN6_bm|PIN7_bm, IOPORT_DIR_OUTPUT);
ioport_set_port_dir(IOPORT_PORTD, PIN4_bm, IOPORT_DIR_OUTPUT);
ioport_set_port_level(IOPORT_PORTB, PIN3_bm|PIN4_bm|PIN5_bm|PIN6_bm|PIN7_bm, PIN3_bm|PIN6_bm|PIN7_bm);
ioport_set_port_level(IOPORT_PORTD, PIN4_bm, PIN4_bm);
#endif
#if BOARD_VER_MAJOR == 1 && BOARD_VER_MINOR == 2
arch_ioport_set_port_dir(IOPORT_PORTB, PIN2_bm|PIN3_bm|PIN4_bm|PIN5_bm|PIN6_bm|PIN7_bm, IOPORT_DIR_OUTPUT);
arch_ioport_set_port_dir(IOPORT_PORTD, PIN4_bm, IOPORT_DIR_OUTPUT);
arch_ioport_set_port_level(IOPORT_PORTB, PIN2_bm|PIN3_bm|PIN4_bm|PIN5_bm|PIN6_bm|PIN7_bm, PIN3_bm|PIN6_bm|PIN7_bm);
arch_ioport_set_port_level(IOPORT_PORTD, PIN4_bm, PIN4_bm);
ioport_set_port_dir(IOPORT_PORTB, PIN2_bm|PIN3_bm|PIN4_bm|PIN5_bm|PIN6_bm|PIN7_bm, IOPORT_DIR_OUTPUT);
ioport_set_port_dir(IOPORT_PORTD, PIN4_bm, IOPORT_DIR_OUTPUT);
ioport_set_port_level(IOPORT_PORTB, PIN2_bm|PIN3_bm|PIN4_bm|PIN5_bm|PIN6_bm|PIN7_bm, PIN3_bm|PIN6_bm|PIN7_bm);
ioport_set_port_level(IOPORT_PORTD, PIN4_bm, PIN4_bm);
#endif
}
......@@ -247,101 +248,101 @@ void pot_set_gain(void){
switch (g_gain){
#if BOARD_VER_MAJOR == 1 && BOARD_VER_MINOR == 1
case POT_GAIN_500M:
arch_ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, 0);
arch_ioport_set_port_level(IOPORT_PORTD, PIN4_bm, 0);
ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, 0);
ioport_set_port_level(IOPORT_PORTD, PIN4_bm, 0);
printf("#INFO: 500M\n\r");
break;
case POT_GAIN_30M:
arch_ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN6_bm);
arch_ioport_set_port_level(IOPORT_PORTD, PIN4_bm, 0);
ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN6_bm);
ioport_set_port_level(IOPORT_PORTD, PIN4_bm, 0);
printf("#INFO: 30M\n\r");
break;
case POT_GAIN_3M:
arch_ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN7_bm);
arch_ioport_set_port_level(IOPORT_PORTD, PIN4_bm, 0);
ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN7_bm);
ioport_set_port_level(IOPORT_PORTD, PIN4_bm, 0);
printf("#INFO: 3M\n\r");
break;
case POT_GAIN_300k:
arch_ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN6_bm|PIN7_bm);
arch_ioport_set_port_level(IOPORT_PORTD, PIN4_bm, 0);
ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN6_bm|PIN7_bm);
ioport_set_port_level(IOPORT_PORTD, PIN4_bm, 0);
printf("#INFO: 300k\n\r");
break;
case POT_GAIN_30k:
arch_ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, 0);
arch_ioport_set_port_level(IOPORT_PORTD, PIN4_bm, PIN4_bm);
ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, 0);
ioport_set_port_level(IOPORT_PORTD, PIN4_bm, PIN4_bm);
printf("#INFO: 30k\n\r");
break;
case POT_GAIN_3k:
arch_ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN6_bm);
arch_ioport_set_port_level(IOPORT_PORTD, PIN4_bm, PIN4_bm);
ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN6_bm);
ioport_set_port_level(IOPORT_PORTD, PIN4_bm, PIN4_bm);
printf("#INFO: 3k\n\r");
break;
case POT_GAIN_300:
arch_ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN7_bm);
arch_ioport_set_port_level(IOPORT_PORTD, PIN4_bm, PIN4_bm);
ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN7_bm);
ioport_set_port_level(IOPORT_PORTD, PIN4_bm, PIN4_bm);
printf("#INFO: 300\n\r");
break;
case POT_GAIN_100:
arch_ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN6_bm|PIN7_bm);
arch_ioport_set_port_level(IOPORT_PORTD, PIN4_bm, PIN4_bm);
ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN6_bm|PIN7_bm);
ioport_set_port_level(IOPORT_PORTD, PIN4_bm, PIN4_bm);
printf("#INFO: 100\n\r");
break;
#endif
#if BOARD_VER_MAJOR == 1 && BOARD_VER_MINOR == 2
case POT_GAIN_100M:
arch_ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, 0);
arch_ioport_set_port_level(IOPORT_PORTD, PIN4_bm, 0);
ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, 0);
ioport_set_port_level(IOPORT_PORTD, PIN4_bm, 0);
printf("#INFO: 100M\n\r");
break;
case POT_GAIN_30M:
arch_ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN6_bm);
arch_ioport_set_port_level(IOPORT_PORTD, PIN4_bm, 0);
ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN6_bm);
ioport_set_port_level(IOPORT_PORTD, PIN4_bm, 0);
printf("#INFO: 30M\n\r");
break;
case POT_GAIN_3M:
arch_ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN7_bm);
arch_ioport_set_port_level(IOPORT_PORTD, PIN4_bm, 0);
ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN7_bm);
ioport_set_port_level(IOPORT_PORTD, PIN4_bm, 0);
printf("#INFO: 3M\n\r");
break;
case POT_GAIN_300k:
arch_ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN6_bm|PIN7_bm);
arch_ioport_set_port_level(IOPORT_PORTD, PIN4_bm, 0);
ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN6_bm|PIN7_bm);
ioport_set_port_level(IOPORT_PORTD, PIN4_bm, 0);
printf("#INFO: 300k\n\r");
break;
case POT_GAIN_30k:
arch_ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, 0);
arch_ioport_set_port_level(IOPORT_PORTD, PIN4_bm, PIN4_bm);
ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, 0);
ioport_set_port_level(IOPORT_PORTD, PIN4_bm, PIN4_bm);
printf("#INFO: 30k\n\r");
break;
case POT_GAIN_3k:
arch_ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN6_bm);
arch_ioport_set_port_level(IOPORT_PORTD, PIN4_bm, PIN4_bm);
ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN6_bm);
ioport_set_port_level(IOPORT_PORTD, PIN4_bm, PIN4_bm);
printf("#INFO: 3k\n\r");
break;
case POT_GAIN_0:
arch_ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN7_bm);
arch_ioport_set_port_level(IOPORT_PORTD, PIN4_bm, PIN4_bm);
ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN7_bm);
ioport_set_port_level(IOPORT_PORTD, PIN4_bm, PIN4_bm);
printf("#INFO: 0\n\r");
break;
case POT_GAIN_100:
arch_ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN6_bm|PIN7_bm);
arch_ioport_set_port_level(IOPORT_PORTD, PIN4_bm, PIN4_bm);
ioport_set_port_level(IOPORT_PORTB, PIN6_bm|PIN7_bm, PIN6_bm|PIN7_bm);
ioport_set_port_level(IOPORT_PORTD, PIN4_bm, PIN4_bm);
printf("#INFO: 100\n\r");
break;
#endif
......@@ -359,13 +360,17 @@ void volt_exp_start(void){
* Connects measurement cell to rest of circuit.
*/
#if BOARD_VER_MAJOR == 1 && BOARD_VER_MINOR == 1
arch_ioport_set_port_level(IOPORT_PORTB, PIN3_bm|PIN4_bm|PIN5_bm, PIN3_bm|PIN4_bm|PIN5_bm);
ioport_set_port_level(IOPORT_PORTB, PIN3_bm|PIN4_bm|PIN5_bm, PIN3_bm|PIN4_bm|PIN5_bm);
#endif
#if BOARD_VER_MAJOR == 1 && BOARD_VER_MINOR == 2
arch_ioport_set_port_level(IOPORT_PORTB, PIN2_bm|PIN3_bm|PIN4_bm|PIN5_bm, PIN2_bm|PIN4_bm|PIN5_bm);
ioport_set_port_level(IOPORT_PORTB, PIN2_bm|PIN3_bm|PIN4_bm|PIN5_bm, PIN2_bm|PIN4_bm|PIN5_bm);
#endif
if (g_short == 1)
ioport_set_port_level(IOPORT_PORTB, PIN3_bm, PIN3_bm);
else
ioport_set_port_level(IOPORT_PORTB, PIN3_bm, 0);
}
void volt_exp_stop(void){
......@@ -373,11 +378,13 @@ void volt_exp_stop(void){
* Disconnects measurement cell.
*/
#if BOARD_VER_MAJOR == 1 && BOARD_VER_MINOR == 1
arch_ioport_set_port_level(IOPORT_PORTB, PIN3_bm|PIN4_bm|PIN5_bm, 0);
ioport_set_port_level(IOPORT_PORTB, PIN3_bm|PIN4_bm|PIN5_bm, 0);
#endif
#if BOARD_VER_MAJOR == 1 && BOARD_VER_MINOR == 2
arch_ioport_set_port_level(IOPORT_PORTB, PIN2_bm|PIN3_bm|PIN4_bm|PIN5_bm, 0);
ioport_set_port_level(IOPORT_PORTB, PIN2_bm|PIN3_bm|PIN4_bm|PIN5_bm, 0);
#endif
ioport_set_port_level(IOPORT_PORTB, PIN3_bm, PIN3_bm);
}
#if BOARD_VER_MAJOR == 1 && BOARD_VER_MINOR >= 2
......@@ -385,7 +392,7 @@ void pot_exp_start(void){
/**
* All switches open.
*/
arch_ioport_set_port_level(IOPORT_PORTB, PIN2_bm|PIN3_bm|PIN4_bm|PIN5_bm, 0);
ioport_set_port_level(IOPORT_PORTB, PIN2_bm|PIN3_bm|PIN4_bm|PIN5_bm, 0);
}
......@@ -393,7 +400,7 @@ void ocp_exp_start(void){
/**
* U3C closed
*/
arch_ioport_set_port_level(IOPORT_PORTB, PIN2_bm|PIN3_bm|PIN4_bm|PIN5_bm, PIN4_bm);
ioport_set_port_level(IOPORT_PORTB, PIN2_bm|PIN3_bm|PIN4_bm|PIN5_bm, PIN4_bm);
}
#endif
......
......@@ -73,6 +73,7 @@
#define RTC_COMPARE_INT_LEVEL RTC_COMPINTLVL_HI_gc
extern uint16_t g_gain;
extern uint8_t g_short;
extern uint8_t autogain_enable;
void experiment_handler(char command);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment