diff --git a/communication protocol.txt b/communication protocol.txt index c0d215ba725cc43f1956fbadd980868bb0bbfaf0..8ae74096d9439010f8575896154810b7d16e7ee6 100644 --- a/communication protocol.txt +++ b/communication protocol.txt @@ -6,10 +6,10 @@ Initialization (can be done again even after initialized, if needed): Send 'k' Command protocol: - Send '!' - Other characters sent first will be rejected with reply 'C\r\n' + Send '!' - Other characters sent first will be rejected with reply 'C\n' Send command and arguments (see below) Lines replied starting with '#' are human-readable info messages that should be logged - All commands terminate by replying "no\n\r" + All commands terminate by replying "no\n" Commands - single letter command with arguments in C scanf format : ADC setting @@ -37,9 +37,9 @@ Commands - single letter command with arguments in C scanf format : Each point: "B\n" followed by uint16 voltage and int32 current, then "\n" End of each scan: - "S\n\r" + "S\n" End of experiment: - "D\n\r" + "D\n" Square Wave Voltammetry Send 'S' @@ -51,9 +51,9 @@ Commands - single letter command with arguments in C scanf format : "B\n" followed by uint16 voltage, int32 forward_current, int32 reverse_current, then "\n" End of each scan: - "S\n\r" + "S\n" End of experiment: - "D\n\r" + "D\n" Differential Pulse Voltammetry Send 'S' @@ -65,6 +65,6 @@ Commands - single letter command with arguments in C scanf format : "B\n" followed by uint16 voltage, int32 forward_current, int32 reverse_current, then "\n" End of each scan: - "S\n\r" + "S\n" End of experiment: - "D\n\r" \ No newline at end of file + "D\n" diff --git a/src/ads1255.c b/src/ads1255.c index 3c92ba9575914de99e5dd029af3e26e198884aa6..377c913642f78c40c38c326bbf1bd06f6679d86f 100644 --- a/src/ads1255.c +++ b/src/ads1255.c @@ -53,7 +53,7 @@ void ads1255_reg_read(uint8_t address){ usart_spi_deselect_device(&USARTE1, &spi_device_conf); for (int i=0;i<5;i++) - printf("ADS1255: Register %u=%.2x\n\r",i+1,input_buffer[i]); + printf("ADS1255: Register %u=%.2x\n",i+1,input_buffer[i]); return; } @@ -65,8 +65,8 @@ void ads1255_reset(){ usart_spi_transmit(&USARTE1, ADS_RESET); #ifdef ADS1255_DBG - printf("ADS1255: Sending RESET\n\r"); - printf("ADS1255: Waiting for calibration\n\r"); + printf("ADS1255: Sending RESET\n"); + printf("ADS1255: Waiting for calibration\n"); #endif while (arch_ioport_get_pin_level(IOPORT_CREATE_PIN(PORTD, 5))); @@ -137,7 +137,7 @@ void ads1255_setup(uint8_t buff, uint8_t rate, uint8_t pga){ sample_delay_ms_100div = 25; break; default: - printf("#ERR: Invalid ADC data rate specified.\n\r"); + printf("#ERR: Invalid ADC data rate specified.\n"); break; } @@ -252,7 +252,7 @@ int16_t ads1255_read_fast_single(void){ ads1255_standby(); #ifdef ADS1255_DBG - printf("ADS1255 result=%li\n\r", input_buffer.int16); + printf("ADS1255 result=%li\n", input_buffer.int16); #endif return input_buffer.int16; @@ -331,4 +331,4 @@ int32_t ads1255_read_single24(void){ cpu_irq_restore(flags); return input_buffer.int32; -} \ No newline at end of file +} diff --git a/src/experiment.c b/src/experiment.c index 4ce4a482f8309f100067fd26aff33fbcd27cf564..635a17a6335382142ad2386184623c9c7476ac41 100644 --- a/src/experiment.c +++ b/src/experiment.c @@ -70,13 +70,13 @@ void experiment_handler(char command){ switch (command){ case 'A': //ADS Buffer/rate/PGA values from ads1255.h scanf("%hhx%hhx%hhx",&o1,&o2,&o3); - printf("#A: %x %x %x\r\n",o1,o2,o3); + printf("#A: %x %x %x\n",o1,o2,o3); ads1255_setup(o1, o2, o3); break; case 'G': //Gain scanf("%u%hhu",&g_gain, &g_short); - printf("#G: %u %u\r\n", g_gain, g_short); + printf("#G: %u %u\n", g_gain, g_short); pot_set_gain(); //uses global g_gain, so no params break; @@ -117,7 +117,7 @@ void experiment_handler(char command){ case 'R': //CA - steps, step_dac[], step_seconds[] scanf("%hhu",&p5); //get number of steps - printf("#INFO: Steps: %u\n\r", p5); + printf("#INFO: Steps: %u\n", p5); //allocate arrays for steps uint16_t * step_dac = malloc(p5*sizeof(uint16_t)); @@ -125,7 +125,7 @@ void experiment_handler(char command){ //check for successful allocation if (!step_dac || !step_seconds){ - printf("#ERR: Could not allocate memory\n\r"); + printf("#ERR: Could not allocate memory\n"); break; } @@ -133,36 +133,36 @@ void experiment_handler(char command){ for (i=0; i<p5; i++){ scanf("%u", &step_dac[i]); // get voltage steps (dac units) - printf("#INFO: DAC: %u\n\r", step_dac[i]); + printf("#INFO: DAC: %u\n", step_dac[i]); } for (i=0; i<p5; i++){ scanf("%u", &step_seconds[i]); //get step durations (seconds) - printf("#INFO: Time: %u\n\r", step_seconds[i]); + printf("#INFO: Time: %u\n", step_seconds[i]); } scanf("%hhu", &o1); - printf("#INFO: TCS_check: %hhu\n\r", o1); + printf("#INFO: TCS_check: %hhu\n", o1); if (o1 > 0) { if (settings.settings.tcs_enabled > 0){ tcs_readvalues(tcs_data); tcs_readvalues(tcs_data1); // If sensor disconnected, second measurement should be exactly the same (unless 0 or saturated) - printf("#INFO: TCS0—%u %u %u %u\n\r", tcs_data[0], tcs_data[1], tcs_data[2], tcs_data[3]); - printf("#INFO: TCS1—%u %u %u %u\n\r", tcs_data1[0], tcs_data1[1], tcs_data1[2], tcs_data1[3]); + printf("#INFO: TCS0—%u %u %u %u\n", tcs_data[0], tcs_data[1], tcs_data[2], tcs_data[3]); + printf("#INFO: TCS1—%u %u %u %u\n", tcs_data1[0], tcs_data1[1], tcs_data1[2], tcs_data1[3]); if (tcs_data[0] == tcs_data1[0]){ if (!(tcs_data[0] == 0 || tcs_data[0] == 65535)) { - printf("#ERR: Ambient light sensor seems to be disconnected \n\r"); + printf("#ERR: Ambient light sensor seems to be disconnected \n"); return; } } if (tcs_data[0] > settings.settings.tcs_clear_threshold){ - printf("#ERR: Ambient light exceeds threshold %u\n\r", tcs_data[0]); - printf("#INFO: TCS—%u %u %u %u\n\r", tcs_data[0], tcs_data[1], tcs_data[2], tcs_data[3]); + printf("#ERR: Ambient light exceeds threshold %u\n", tcs_data[0]); + printf("#INFO: TCS—%u %u %u %u\n", tcs_data[0], tcs_data[1], tcs_data[2], tcs_data[3]); return; } } else { - printf("#ERR: Ambient light sensor disabled.\n\r"); + printf("#ERR: Ambient light sensor disabled.\n"); return; } } @@ -193,7 +193,7 @@ void experiment_handler(char command){ break; default: - printf("#ERR: Command %c not recognized\n\r", command); + printf("#ERR: Experiment command %c not recognized\n", command[0]); } } @@ -237,7 +237,7 @@ uint16_t set_timer_period(uint32_t period, volatile void *tc) divider = 1024; } else{ - printf("#Frequency/ADC rate is too low\n\r"); + printf("#Frequency/ADC rate is too low\n"); return 0; } @@ -278,49 +278,49 @@ void pot_set_gain(void){ 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"); + printf("#INFO: 500M\n"); break; case POT_GAIN_30M: 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"); + printf("#INFO: 30M\n"); break; case POT_GAIN_3M: 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"); + printf("#INFO: 3M\n"); break; case POT_GAIN_300k: 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"); + printf("#INFO: 300k\n"); break; case POT_GAIN_30k: 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"); + printf("#INFO: 30k\n"); break; case POT_GAIN_3k: 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"); + printf("#INFO: 3k\n"); break; case POT_GAIN_300: 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"); + printf("#INFO: 300\n"); break; case POT_GAIN_100: 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"); + printf("#INFO: 100\n"); break; #endif @@ -328,54 +328,54 @@ void pot_set_gain(void){ case POT_GAIN_100M: 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"); + printf("#INFO: 100M\n"); break; case POT_GAIN_30M: 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"); + printf("#INFO: 30M\n"); break; case POT_GAIN_3M: 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"); + printf("#INFO: 3M\n"); break; case POT_GAIN_300k: 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"); + printf("#INFO: 300k\n"); break; case POT_GAIN_30k: 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"); + printf("#INFO: 30k\n"); break; case POT_GAIN_3k: 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"); + printf("#INFO: 3k\n"); break; case POT_GAIN_0: 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"); + printf("#INFO: 0\n"); break; case POT_GAIN_100: 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"); + printf("#INFO: 100\n"); break; #endif default: - printf("#WAR: Invalid pot gain.\n\r"); + printf("#WAR: Invalid pot gain.\n"); break; return; @@ -467,13 +467,13 @@ void precond(int16_t v1, uint16_t t1, int16_t v2, uint16_t t2){ //assumes potent if (udi_cdc_is_rx_ready()){ if (getchar() == 'a'){ precond_rtc_callback(t1); - printf("##ABORT\n\r"); + printf("##ABORT\n"); goto aborting; } } if (time_old != RTC.CNT){ time_old = RTC.CNT; - printf("#%u\n\r",time_old); + printf("#%u\n",time_old); } } } @@ -490,13 +490,13 @@ void precond(int16_t v1, uint16_t t1, int16_t v2, uint16_t t2){ //assumes potent if (udi_cdc_is_rx_ready()){ if (getchar() == 'a'){ precond_rtc_callback(t2); - printf("##ABORT\n\r"); + printf("##ABORT\n"); goto aborting; } } if (time_old != RTC.CNT){ time_old = RTC.CNT; - printf("#%u\n\r",time_old); + printf("#%u\n",time_old); } } } @@ -527,7 +527,7 @@ void cv_experiment(int16_t v1, int16_t v2, int16_t start, uint8_t scans, uint16_ int8_t firstrun = 1; if((start < v1 && start < v2) || (start > v1 && start > v2)){ - printf("#ERR: Start must be within [v1, v2]\n\r"); + printf("#ERR: Start must be within [v1, v2]\n"); return; } @@ -554,10 +554,10 @@ void cv_experiment(int16_t v1, int16_t v2, int16_t start, uint8_t scans, uint16_ --scans; firstrun = 0; - printf("S\n\r"); //signal end of scan + printf("S\n"); //signal end of scan } - printf("D\n\r"); //signal end of experiment + printf("D\n"); //signal end of experiment return; } @@ -578,7 +578,7 @@ uint8_t lsv_experiment(int16_t start, int16_t stop, uint16_t slope, int8_t first //check experiment limits if(start<-1500 || start>=1500 ||start==stop|| stop<-1500 || stop>=1500 || slope>7000) { - printf("#ERR: Experiment parameters outside limits\n\r"); + printf("#ERR: Experiment parameters outside limits\n"); return ret; } @@ -636,7 +636,7 @@ uint8_t lsv_experiment(int16_t start, int16_t stop, uint16_t slope, int8_t first timer_period /= 1024; } else{ - printf("ERR: Frequency/ADC rate is too low\n\r"); + printf("ERR: Frequency/ADC rate is too low\n"); return ret; } @@ -794,7 +794,7 @@ void pot_experiment(uint16_t time_seconds, uint8_t exp_type){ if (udi_cdc_is_rx_ready()){ if (getchar() == 'a'){ ca_cca_callback(); - printf("##ABORT\n\r"); + printf("##ABORT\n"); goto aborting; } } @@ -820,7 +820,7 @@ void pmt_idle(void){ while (1){ if (udi_cdc_is_rx_ready()){ if (getchar() == 'a'){ - printf("##ABORT\n\r"); + printf("##ABORT\n"); // Doesn't disconnect control line to minimize time this is floating return; } @@ -869,13 +869,13 @@ void ca_experiment(uint16_t steps, uint16_t step_dac[], uint16_t step_seconds[]) tc_write_cc(&EXP_TC0_0, TC_CCA, EXP_TC0_0.CNT+step_seconds[i]-1); RTC.CNT=0; max5443_set_voltage1(step_dac[i]); - printf("#DAC: %u\n\r", step_dac[i]); + printf("#DAC: %u\n", step_dac[i]); PORTD.INTCTRL = PORT_INT0LVL_LO_gc; while (up !=0){ if (udi_cdc_is_rx_ready()){ if (getchar() == 'a'){ ca_cca_callback(); - printf("##ABORT\n\r"); + printf("##ABORT\n"); goto aborting; } } @@ -973,11 +973,11 @@ void swv_experiment(int16_t start, int16_t stop, uint16_t step, uint16_t pulse_h goto aborting; } - printf("S\n\r"); //signal end of scan + printf("S\n"); //signal end of scan } while (scans-- > 1); //will underflow after comparison for scans = 0 , but shouldn't matter - printf("D\n\r"); //signal end of experiment + printf("D\n"); //signal end of experiment aborting: volt_exp_stop(); @@ -1138,7 +1138,7 @@ void dpv_experiment(int16_t start, int16_t stop, uint16_t step, uint16_t pulse_h if (_dpv_singledir(dacindex_start, dacindex_stop, dacindex_pulse_height, dacindex_step, direction)) goto aborting; //function will return non-zero if abort called over USB - printf("D\n\r"); //signal end of experiment + printf("D\n"); //signal end of experiment aborting: volt_exp_stop(); diff --git a/src/ext_twi.c b/src/ext_twi.c index ff0d0997c632b51d2e1571ca23713b7862d3940d..5c4274d8cc2c767c932cb709abb3c3decbddc4bd 100644 --- a/src/ext_twi.c +++ b/src/ext_twi.c @@ -26,5 +26,5 @@ void ext_twi_init(void){ }; twi_master_setup(&EXT_TWI0, &opt); - printf("#INFO: TWI master enabled\n\r"); + printf("#INFO: TWI master enabled\n"); } diff --git a/src/main.c b/src/main.c index 49ef95b719a7e169cc4bd4d00008ed679da8c65a..d447e5c3f61d555d8ecfac6ed22a1c19b2ab163e 100644 --- a/src/main.c +++ b/src/main.c @@ -39,12 +39,12 @@ int8_t command_handler(char command){ case 'T': ; uint16_t tcs_data[] = {0,0,0,0}; if (settings.settings.tcs_enabled == 0){ - printf("T-1.-1.-1.-1\n\r"); + printf("T-1.-1.-1.-1\n"); } else{ tcs_readvalues(tcs_data); - printf("#INFO: TCS—%u %u %u %u\n\r", tcs_data[0], tcs_data[1], tcs_data[2], tcs_data[3]); - printf("T%u.%u.%u.%u\n\r", tcs_data[0], tcs_data[1], tcs_data[2], tcs_data[3]); + printf("#INFO: TCS—%u %u %u %u\n", tcs_data[0], tcs_data[1], tcs_data[2], tcs_data[3]); + printf("T%u.%u.%u.%u\n", tcs_data[0], tcs_data[1], tcs_data[2], tcs_data[3]); } break; @@ -55,12 +55,12 @@ int8_t command_handler(char command){ break; case 'V': //check version - printf("V%u.%u\n\r", BOARD_VER_MAJOR, BOARD_VER_MINOR); + printf("V%u.%u\n", BOARD_VER_MAJOR, BOARD_VER_MINOR); break; default: - printf("#ERR: Command %c not recognized\n\r", command); - return 1; + printf("@ERR Command %c not recognized\n", command); + return; } printf("no\n\r"); return 0; diff --git a/src/settings.c b/src/settings.c index 50f48cfa0185c4a71bf4f0af2a6340bd7bc8136d..d2ee0645fd4b7a83b0b78f8ac3535acf9e3a02ac 100644 --- a/src/settings.c +++ b/src/settings.c @@ -48,7 +48,7 @@ void settings_handler(char command){ break; default: - printf("#ERR: Command %c not recognized\n\r", command); + printf("@ERR: Command %c not recognized\n", command[0]); } } @@ -66,25 +66,25 @@ void update_firmware(void){ } void settings_read_eeprom(void){ - printf("#INFO: SETTINGS\n\r"); + printf("#INFO: SETTINGS\n"); nvm_eeprom_read_buffer(SETTINGS_EEPROM_OFFSET_ADDR, &settings, EEPROM_PAGE_SIZE); if (settings.settings.programmed != 1) { - printf("#INFO: EEPROM not programmed\n\r"); + printf("#INFO: EEPROM not programmed\n"); settings_restore_defaults(); } - printf("#INFO: max5443_offset = %u\n\r", settings.settings.max5443_offset); - printf("#INFO: tcs_enabled = %u\n\r", settings.settings.tcs_enabled); - printf("#INFO: tcs_clear_threshold = %u\n\r", settings.settings.tcs_clear_threshold); - printf("#INFO: r100_trim = %i\n\r", settings.settings.r100_trim); - printf("#INFO: r3k_trim = %i\n\r", settings.settings.r3k_trim); - printf("#INFO: r30k_trim = %i\n\r", settings.settings.r30k_trim); - printf("#INFO: r300k_trim = %i\n\r", settings.settings.r300k_trim); - printf("#INFO: r3M_trim = %i\n\r", settings.settings.r3M_trim); - printf("#INFO: r30M_trim = %i\n\r", settings.settings.r30M_trim); - printf("#INFO: r100M_trim = %i\n\r", settings.settings.r100M_trim); - printf("#INFO: eis_cal1 = %lu\n\r", settings.settings.eis_cal1); - printf("#INFO: eis_cal2 = %lu\n\r", settings.settings.eis_cal2); - printf("Smax5443_offset.%u:tcs_enabled.%u:tcs_clear_threshold.%u:r100_trim.%i:r3k_trim.%i:r30k_trim.%i:r300k_trim.%i:r3M_trim.%i:r30M_trim.%i:r100M_trim.%i:eit_cal1.%lu:eis_cal2.%lu\n\r", + printf("#INFO: max5443_offset = %u\n", settings.settings.max5443_offset); + printf("#INFO: tcs_enabled = %u\n", settings.settings.tcs_enabled); + printf("#INFO: tcs_clear_threshold = %u\n", settings.settings.tcs_clear_threshold); + printf("#INFO: r100_trim = %i\n", settings.settings.r100_trim); + printf("#INFO: r3k_trim = %i\n", settings.settings.r3k_trim); + printf("#INFO: r30k_trim = %i\n", settings.settings.r30k_trim); + printf("#INFO: r300k_trim = %i\n", settings.settings.r300k_trim); + printf("#INFO: r3M_trim = %i\n", settings.settings.r3M_trim); + printf("#INFO: r30M_trim = %i\n", settings.settings.r30M_trim); + printf("#INFO: r100M_trim = %i\n", settings.settings.r100M_trim); + printf("#INFO: eis_cal1 = %lu\n", settings.settings.eis_cal1); + printf("#INFO: eis_cal2 = %lu\n", settings.settings.eis_cal2); + printf("Smax5443_offset.%u:tcs_enabled.%u:tcs_clear_threshold.%u:r100_trim.%i:r3k_trim.%i:r30k_trim.%i:r300k_trim.%i:r3M_trim.%i:r30M_trim.%i:r100M_trim.%i:eit_cal1.%lu:eis_cal2.%lu\n", settings.settings.max5443_offset, settings.settings.tcs_enabled, settings.settings.tcs_clear_threshold, @@ -105,7 +105,7 @@ void settings_write_eeprom(void){ } void settings_restore_defaults(void){ - printf("#INFO: Restoring EEPROM Defaults\n\r"); + printf("#INFO: Restoring EEPROM Defaults\n"); settings.settings.programmed = 1; settings.settings.max5443_offset = SETTINGS_MAX5443_OFFSET; settings.settings.tcs_enabled = SETTINGS_TCS_ENABLED; diff --git a/src/shutter.c b/src/shutter.c index 87ebea7529c2c1036d9ea81287c2d02fae935048..9ac05b44c128093eb7422077977daf9611f9ba3d 100644 --- a/src/shutter.c +++ b/src/shutter.c @@ -53,7 +53,7 @@ uint8_t shutter_cont(double freq){ divider = 1024; } else{ - printf("#ERR: Frequency/ADC rate is too low\n\r"); + printf("#ERR: Frequency/ADC rate is too low\n"); return 0; }