From 07b2fe3c1bed5c77828972d3c567b129471a8742 Mon Sep 17 00:00:00 2001 From: Michael Dryden <mdryden@chem.utoronto.ca> Date: Wed, 4 Feb 2015 20:36:31 -0500 Subject: [PATCH] experiment: Removed send_data functions, replaced by calls to send whole buffers. --- DSTAT-temp/src/experiment.c | 82 ++++++++++++++++++++---------------- DSTAT-temp/src/experiment.h | 3 -- DSTAT1.atsuo | Bin 56832 -> 56832 bytes 3 files changed, 46 insertions(+), 39 deletions(-) diff --git a/DSTAT-temp/src/experiment.c b/DSTAT-temp/src/experiment.c index 8734444..5996432 100644 --- a/DSTAT-temp/src/experiment.c +++ b/DSTAT-temp/src/experiment.c @@ -34,6 +34,7 @@ volatile uint16_t tcf0period = 0; uint32_t skip_samples = 0; //Private function declarations +uint16_t set_timer_period(uint32_t period, volatile void *tc); static void precond_rtc_callback(uint32_t time); static void porte_int0_lsv(void); static void tcf0_ovf_callback(void); @@ -52,29 +53,6 @@ typedef void (*port_callback_t) (void); static port_callback_t portd_int0_callback; static port_callback_t portd_int1_callback; -void send_data_uint16(uint16_t data){ - /** - * Sends uint16 data over USB in order in memory (should be LSB first for AVR - little endian) - * - * @param data 16-bit data - * @return Nothing. - */ - udi_cdc_putc(((unsigned char *)(&data))[0]); - udi_cdc_putc(((unsigned char *)(&data))[1]); -} -void send_data_int32(int32_t data){ - /** - * Sends int32 data over USB in order in memory (should be LSB first for AVR - little endian) - * - * @param data 32-bit data - * @return Nothing. - */ - udi_cdc_putc(((unsigned char *)(&data))[0]); - udi_cdc_putc(((unsigned char *)(&data))[1]); - udi_cdc_putc(((unsigned char *)(&data))[2]); - udi_cdc_putc(((unsigned char *)(&data))[3]); -} - uint16_t set_timer_period(uint32_t period, volatile void *tc) { /** @@ -595,14 +573,20 @@ static void porte_int0_lsv(void){ /** * ISR for taking LSV measurements. */ + struct + { + uint16_t index; + int32_t result; + } data; - int32_t result = ads1255_read_fast24(); + data.result = ads1255_read_fast24(); static uint16_t last_value = 0; uint32_t current = TCC1.CNT; + data.index = (current+last_value)>>1; //DAC value is average of current and last timer - approximation of center of averaging window + printf("B\n"); - send_data_uint16((current+last_value)>>1); //DAC value is average of current and last timer - approximation of center of averaging window - send_data_int32(result); + udi_cdc_write_buf(&data, 6); last_value = (uint16_t)current; printf("\n"); @@ -766,11 +750,19 @@ void ca_experiment(uint16_t steps, uint16_t step_dac[], uint16_t step_seconds[]) } static void portd_int0_ca(void){ - int32_t data = ads1255_read_fast24(); + struct + { + uint16_t time1; + uint16_t time2; + int32_t current; + } data; + + data.time1 = TCC0.CNT; + data.time2 = RTC.CNT; + data.current = ads1255_read_fast24(); + printf("B\n"); - send_data_uint16(TCC0.CNT); - send_data_uint16(RTC.CNT); - send_data_int32(data); + udi_cdc_write_buf(&data, 8); printf("\n"); } @@ -932,10 +924,19 @@ uint8_t _swv_singledir (uint16_t dacindex, uint16_t dacindex_stop, uint16_t daci } //data output + struct + { + uint16_t lastindex; + int32_t forward; + int32_t reverse; + } data; + + data.lastindex = lastindex; + data.forward = forward; + data.reverse = reverse; + printf("B\n"); - send_data_uint16(lastindex); - send_data_int32(forward); - send_data_int32(reverse); + udi_cdc_write_buf(&data, 10); printf("\n"); } @@ -1080,10 +1081,19 @@ uint8_t _dpv_singledir (uint16_t dacindex, uint16_t dacindex_stop, uint16_t daci } //data output + struct + { + uint16_t lastindex; + int32_t forward; + int32_t reverse; + } data; + + data.lastindex = lastindex; + data.forward = forward; + data.reverse = reverse; + printf("B\n"); - send_data_uint16(lastindex); - send_data_int32(forward); - send_data_int32(reverse); + udi_cdc_write_buf(&data, 10); printf("\n"); } diff --git a/DSTAT-temp/src/experiment.h b/DSTAT-temp/src/experiment.h index 8b1ab53..6597f12 100644 --- a/DSTAT-temp/src/experiment.h +++ b/DSTAT-temp/src/experiment.h @@ -75,9 +75,6 @@ extern uint16_t g_gain; extern uint8_t autogain_enable; -void send_data_uint16(uint16_t data); -void send_data_int32(int32_t data); -uint16_t set_timer_period(uint32_t period, volatile void *tc); void pot_init(void); void pot_set_gain(void); void volt_exp_start(void); diff --git a/DSTAT1.atsuo b/DSTAT1.atsuo index c409dd7e0b88439dfd9d1cdd2b17f4b8fcedb73f..dfef140a11114d069f60d9ca34d5957f7bf3edfd 100644 GIT binary patch delta 222 zcmZqJ!`!fkc|#5h>w?>=UmkBRWO;1C`tLswY>u>56Rh99?yl3XsWLs$JM?DhDtO$m zW?*0d$%23*Hv_|DW(J1$d<+b_Kx`??z|h9Xz;IiRfx#6>A5mmrh+}17c&^UCpu)ny zkfOuDATGqfFyD@W;TBMSfdd1B8qmCtKzc8bzT(Khuo+1Ic4A=2V`E@A>dC;wAil}p zflV98`|r=d@EIs89>~D30!Z5iF)-+HFfjZ~VPLq%j&RlH?9kqLM(xc%x3Fsh06K|A ACIA2c delta 176 zcmZqJ!`!fkc|#5h>jSQB^UrTCWO;1CdX0gB;os&+TQxz?xagznvy@J-Nm*2RrD_)G zSplW~LqRJW0|PrF1H%S(28I+M9mvVR;KR(ou!V<#VKR_T5@2A^<zrx2BgeqdHu*rh zwCo8D1_m>r2~nC13@R)P4A*rT7{rAb7=#=c80K&CcVL_RAzfPFvoiz3I-uEqy@0Yn RdUJMYZ#<*(=AT>GH32g_G5r7l -- GitLab