Changeset 10910 for firmware/FSC/src/FSC_eth_with_user_interface.c
- Timestamp:
- 06/05/11 17:40:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
firmware/FSC/src/FSC_eth_with_user_interface.c
r10705 r10910 34 34 bool once_told_you = true; 35 35 bool debug_mode = false; 36 37 // ETHERNET VARS 38 U08 downloaded_bytes; 39 36 37 40 38 //----------------------------------------------------------------------------- 41 39 // M A I N --- M A I N --- M A I N --- M A I N --- M A I N … … 43 41 int main(void) 44 42 { 43 U08 highbyte; 44 U08 lowbyte; 45 45 46 app_init(); // Setup: Watchdog and I/Os 46 47 usart_init(); … … 59 60 60 61 for ( U08 i=0; i < (RESISTANCE_CHANNELS/8); ++i ) { 61 ad7719_enables[i]=0x FF;62 ad7719_enables[i]=0x00; 62 63 ad7719_channels_ready[i]=0; 63 64 } 64 for ( U08 i=0; i < (VOLTAGE_CHANNELS/8); ++i ) { 65 adc_enables[i]=0x00; 65 for ( U08 i=0; i < (VOLTAGE_REGS); ++i ) { 66 if (i < (VOLTAGE_REGS)-1) 67 adc_enables[i]=0xFF; 68 else 69 adc_enables[i]=0x0F; 66 70 adc_channels_ready[i]=0; 67 71 } 68 72 69 static U08 welcome[]=" welcome to:\n FSC command interface 0.1 \n build: ??.05.2010\n";73 static U08 welcome[]="FSC 0.2 \n build: 05.06.2010 - 12:57\n"; 70 74 usart_write_str(welcome); 71 75 /* … … 94 98 { 95 99 if (get_S0_RX_RSR() != 0) { // we have something to read 96 downloaded_bytes = w5100_get_RX(ETH_READ_BUFFER_SIZE, true);97 parse_w5300_incoming( downloaded_bytes);100 101 parse_w5300_incoming( w5100_get_RX(ETH_READ_BUFFER_SIZE, true) ); 98 102 } 99 103 } … … 107 111 usart_write_U32(sec ,8); 108 112 print_adc_nicely(false,true); 113 //print_adc_stupid(); 114 reset_voltage_done(); 115 reset_voltage_values(); 109 116 telegram_start(); 110 117 w5100_set_TX((U08*) adc_values, ADC_VALUES_LEN_BYTE); … … 115 122 adc_values_printed = true; 116 123 print_adc_nicely(true,true); 124 //print_adc_stupid(); 125 //reset_voltage_done(); 117 126 telegram_start(); 118 127 w5100_set_TX((U08*) adc_values, ADC_VALUES_LEN_BYTE); … … 135 144 ad7719_values_printed = true; 136 145 print_ad7719_nicely(true,true); 146 reset_resistance_done(); 137 147 telegram_start(); 138 148 w5100_set_TX((U08*) ad7719_values, AD7719_VALUES_LEN_BYTE); … … 187 197 // -It is not allowed to send more than one command between two '\n' 188 198 if (usart_rx_ready){ 189 void MSR_parser(); 199 //parse_ascii(); 200 MSR_parser(); 190 201 } 191 202 //---------------------------------------------------------------------------- … … 193 204 //IF ATmega internal ADC did finish a conversion --every 200us 194 205 if ( (ADCSRA & (1<<ADIF)) && !adc_measured_all) { 195 *adc_current_reading = (U16)ADCL; 196 *adc_current_reading += (U16)ADCH<<8; 206 lowbyte = ADCL; 207 highbyte = ADCH; 208 ADCSRA |= 1<<ADIF; 209 *adc_current_reading = ((U16)highbyte<<8) | ((U16)lowbyte); 210 if (debug_mode) { 211 usart_write_U16_hex(*adc_current_reading); 212 usart_write_crlf(); 213 } 214 197 215 if (*adc_readings_since_last_muxing == ADC_READINGS_UNTIL_SETTLED+adc_readings_until_mean-1) { 216 adc_values[*adc_current_channel] += *adc_current_reading; 198 217 adc_channels_ready[*adc_current_channel/8] |= (1<<(*adc_current_channel%8)); 199 218 *adc_current_channel = increase_adc (*adc_current_channel); … … 201 220 Set_V_Muxer(*adc_current_channel); 202 221 *adc_readings_since_last_muxing = 0; 203 _delay_ms(10); 222 _delay_ms(10); // this is a muxer delay 204 223 } 205 224 else if (adc_readings_since_last_muxing >= ADC_READINGS_UNTIL_SETTLED-1) { 206 225 adc_values[*adc_current_channel] += *adc_current_reading; 226 if (debug_mode) { 227 usart_write_str((pU08)"ch:"); 228 usart_write_U08(*adc_current_channel,4); 229 usart_write_str((pU08)" v:"); 230 usart_write_U16_hex(*adc_current_reading); 231 usart_write_str((pU08)" sum:"); 232 usart_write_U16(adc_values[*adc_current_channel],8); 233 usart_write_crlf(); 234 } 235 207 236 ++(*adc_readings_since_last_muxing); 208 237 } … … 212 241 213 242 } 243 214 244 //---------------------------------------------------------------------------- 215 245
Note:
See TracChangeset
for help on using the changeset viewer.