source: firmware/FSC/usb_src/parser.c@ 17038

Last change on this file since 17038 was 10244, checked in by neise, 14 years ago
debugged resistance calculation for AD7719
File size: 1.8 KB
Line 
1#include "parser.h"
2#include "output.h"
3// this method parses the data,
4// which came in via USART
5// later it might as well parse the data from ethernet.
6void parse_ascii() {
7 usart_rx_buffer[USART_RX_BUFFER_SIZE-1] = 0;
8 usart_write_str((pU08)"got:");
9 usart_write_str(usart_rx_buffer);
10
11// look at first byte
12// I hope, I can manage to use one byte commands
13 switch (usart_rx_buffer[0]) {
14 case 'E': // AD7719 enable bitmaps may be set
15 set_ad7719_enable_register();
16 break;
17 case 'e': // ATmega internal ADC enable bitmaps may be set
18 // not supported yet.
19 set_adc_enable_register();
20 break;
21 case 'h':
22 usart_write_str((pU08)"\nheartbeat ");
23 heartbeat_enable = true;
24 if (usart_rx_buffer[1] == '0'){
25 heartbeat_enable = false;
26 usart_write_str((pU08)"off\n");
27 } else {
28 usart_write_str((pU08)"on\n");
29 }
30 break;
31 case 'G': // GET the Temperature channels, which are enabled
32 once_told_you = false;
33 for ( U08 i=0; i<CHANNEL_BITMAP; ++i ) {
34 ad7719_channels_ready[i]=0;
35 }
36 break;
37
38 case 'g': // GET the voltage/current/humidity channels, which are enabled
39 once_told_you = false;
40 for ( U08 i=0; i<V_BITMAP + I_BITMAP + H_BITMAP; ++i ) {
41 adc_channels_ready[i]=0;
42 }
43 break;
44
45 case 'P':
46 print_ad7719_nicely();
47 break;
48
49 case 'p':
50 print_adc_nicely();
51 break;
52
53 case 's':
54 print_status();
55 break;
56
57 case 'd':
58 usart_write_str((pU08)"\ndebug mode ");
59 debug_mode = true;
60 if (usart_rx_buffer[1] == '0'){
61 debug_mode = false;
62 usart_write_str((pU08)"off\n");
63 } else {
64 usart_write_str((pU08)"on\n");
65 }
66 break;
67 }
68
69
70 usart_write_str((pU08)"\nready?");
71 for (U08 i=0; i<USART_RX_BUFFER_SIZE; ++i)
72 usart_rx_buffer[i] = 0;
73}
Note: See TracBrowser for help on using the repository browser.