Changeset 10697 for firmware/FSC/src/parser.c
- Timestamp:
- 05/13/11 11:48:49 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
firmware/FSC/src/parser.c
r10677 r10697 3 3 #include "application.h" 4 4 #include "usart.h" 5 #include "w5100_spi_interface.h" 5 6 // this method parses the data, 6 7 // which came in via USART … … 306 307 307 308 */ 309 310 /////////////////////////////////////////////////////////////////////////////////////// 311 // W5300 incoming commands parser 312 void parse_w5300_incoming( U08 bytes_in_w5100_rx_buffer ) { 313 314 if (bytes_in_w5100_rx_buffer == 0) // it was stupid to call this parser without having any bytes downloaded 315 return; 316 317 switch (eth_read_buffer[0]) { 318 case 'w': // *w*rite to register command 319 write_FSC_register(); 320 read_FSC_register(); 321 break; 322 323 case 'r': // *r*ead from register command 324 read_FSC_register(); 325 break; 326 327 case 't': // measure *t*emperature (resistance) channels only 328 reset_resistance_done(); 329 simple_acknowledge(); 330 break; 331 332 case 'v': // measure *v*oltage channels only 333 reset_voltage_done(); 334 simple_acknowledge(); 335 break; 336 337 case 'm': // *m*easure active channels commands 338 reset_done(); 339 simple_acknowledge(); 340 break; 341 342 case 's': // return *s*tatus information 343 // this might take a lot of time... about... 25us per byte .. --> less than 25ms 344 w5100_set_TX(FSCregister, FSC_REGISTER_LENGTH); 345 break; 346 347 case 'z': // re*z*et ATmega32 and peripherals 348 eth_write_buffer[0]='!'; 349 eth_write_buffer[1]='!'; 350 w5100_set_TX(eth_write_buffer, 2); 351 // let watchdog occur! 352 // gotta read, how this works... 353 break; 354 } 355 } 356 357 void write_FSC_register() { 358 FSCregister[eth_read_buffer[2]]=eth_read_buffer[3]; 359 } 360 361 void read_FSC_register() { 362 eth_write_buffer[0]=eth_read_buffer[0]; 363 eth_write_buffer[1]=eth_read_buffer[1]; 364 eth_write_buffer[2]=eth_read_buffer[2]; 365 eth_write_buffer[3]=FSCregister[eth_read_buffer[2]]; 366 w5100_set_TX(eth_write_buffer, 4); 367 } 368 369 void reset_resistance_done(){ 370 for (U08 i=0; i < (RESISTANCE_CHANNELS/8); i++){ 371 ad7719_channels_ready[i] = 0; 372 } 373 } 374 void reset_voltage_done(){ 375 for (U08 i=0; i < (VOLTAGE_CHANNELS/8); i++){ 376 adc_channels_ready[i] = 0; 377 } 378 } 379 void reset_done(){ 380 reset_resistance_done(); 381 reset_voltage_done(); 382 } 383 384 void simple_acknowledge(){ 385 eth_write_buffer[0]=eth_read_buffer[0]; 386 eth_write_buffer[1]=eth_read_buffer[1]; 387 w5100_set_TX(eth_write_buffer, 2); 388 }
Note:
See TracChangeset
for help on using the changeset viewer.