source: firmware/FSC/src/output.c@ 10676

Last change on this file since 10676 was 10674, checked in by neise, 14 years ago
ethernet with user interface test
File size: 4.1 KB
Line 
1#include "output.h"
2#include "usart.h"
3#include "application.h"
4#include "timer.h"
5
6void print_status() {
7 usart_write_str((pU08)"adc status:\n");
8 for (U08 i=0; i< V_BITMAP + I_BITMAP + H_BITMAP;++i) {
9 usart_write_U08_bin(adc_enables[i]);
10 usart_write_char(' ');
11 }
12 usart_write_char('\n');
13 for (U08 i=0; i< V_BITMAP + I_BITMAP + H_BITMAP;++i){
14 usart_write_U08_bin(adc_channels_ready[i]);
15 usart_write_char(' ');
16 }
17 usart_write_char('\n');
18
19 usart_write_str((pU08)"ad7719 status:\n");
20 for (U08 i=0; i< CHANNEL_BITMAP;++i) {
21 usart_write_U08_bin(ad7719_enables[i]);
22 usart_write_char(' ');
23 }
24 usart_write_char('\n');
25 for (U08 i=0; i< CHANNEL_BITMAP;++i){
26 usart_write_U08_bin(ad7719_channels_ready[i]);
27 usart_write_char(' ');
28 }
29 usart_write_char('\n');
30
31 usart_write_str((pU08)"time:");
32 usart_write_U32(sec,10);
33 usart_write_str((pU08)" sec.\n");
34
35 usart_write_str((pU08)"adc measured all: ");
36 if (adc_measured_all)
37 usart_write_str((pU08)" true\n");
38 else
39 usart_write_str((pU08)"false\n");
40
41 usart_write_str((pU08)"ad7719 measured all: ");
42 if (ad7719_measured_all)
43 usart_write_str((pU08)" true\n");
44 else
45 usart_write_str((pU08)"false\n");
46
47 usart_write_str((pU08)"adc current channel:");
48 usart_write_U08(adc_current_channel,2);
49 usart_write_char('\n');
50
51 usart_write_str((pU08)"ad7719 current channel:");
52 usart_write_U08(ad7719_current_channel,2);
53 usart_write_char('\n');
54
55}
56void print_adc_nicely() {
57 usart_write_str((pU08)"\n printing voltages in mV:\n");
58 // output: U08 adc_values[V_CHANNELS + I_CHANNELS + H_CHANNELS];
59 for (U08 i=0; i< V_CHANNELS + I_CHANNELS + H_CHANNELS;++i) {
60 if (i%8 == 0) usart_write_char('\n');
61 adc_output(i, adc_values[i]);
62 usart_write_str((pU08)" ");
63 }
64 usart_write_char('\n');
65}
66
67
68void print_ad7719_nicely()
69{
70 float value;
71
72 usart_write_str((pU08)"\n printing measured resistance in kohms:\n");
73
74 for (U08 i=0; i< TEMP_CHANNELS;++i) {
75 if (i%8 == 0) usart_write_char('\n');
76
77 // print channel name:
78 usart_write_str((pU08)"R:"); //R for resistance
79 usart_write_char('A'+i/8); // Letters A,B,C,D,E,F,G,H
80 //usart_write_char(' ');
81 usart_write_U08(i%8+1,1); // Numbers 1...8
82 usart_write_char(':');
83
84 // check if this channel is enabled in the bitmap
85 if (ad7719_enables[i/8] & (1<<i%8))
86 {
87 value = (6.25 * 1.024 * ad7719_values[i]) / ((U32)1 << 25);
88 usart_write_float(value, 3,6);
89 //usart_write_U32(ad7719_values[i],8);
90 //usart_write_U32_hex(data); //data
91 usart_write_str((pU08)" ");
92 } else {
93 usart_write_str((pU08)" ");
94 }
95 //usart_write_char('\n');
96 }
97}
98
99void ad7719_output(U08 channel, U32 data) {
100float value = 0;
101 usart_write_str((pU08)"R:"); //R for resistance
102 usart_write_char('A'+channel/8); // Letters A,B,C,D,E,F,G,H
103 //usart_write_char(' ');
104 usart_write_U08(channel%8+1,1); // Numbers 1...8
105 usart_write_char(':');
106
107
108 value = (6.25 * data) / ((U32)1 << 25);
109 usart_write_float(value, 3,6);
110 //usart_write_U32_hex(data); //data
111
112
113}
114
115void adc_output(U08 channel, U08 data) {
116
117// if (channel < 40)
118// usart_write_str((pU08)"V:");
119// else if (channel < 80)
120// usart_write_str((pU08)"I:");
121// else if (channel < 84)
122// usart_write_str((pU08)"H:");
123
124 if (channel <80)
125 {
126 switch ((channel%40)/4) {
127 case 0:
128 case 1:
129 usart_write_char('A');
130 break;
131 case 2:
132 case 3:
133 usart_write_char('B');
134 break;
135 case 4:
136 case 5:
137 usart_write_char('C');
138 break;
139 case 6:
140 case 7:
141 usart_write_char('D');
142 break;
143 case 8:
144 usart_write_char('E');
145 break;
146 case 9:
147 usart_write_char('F');
148 break;
149 default:
150 usart_write_char('?');
151 break;
152 }
153 }
154 else // channel 80..83
155 {
156 usart_write_char('H');
157 }
158 //usart_write_char(' ');
159
160 if ( (channel%40)/4 == 9)
161 usart_write_U08((channel)%4+1,1); // Numbers 1...4
162 else
163 usart_write_U08((channel)%8+1,1); // Numbers 1...8
164
165
166 //usart_write_U08(channel,2); // Numbers 1...8
167 usart_write_char(':');
168 usart_write_U16((U16)data*16, 4); //data
169}
170
171
172void adc_output_all() {
173 print_adc_nicely();
174 print_ad7719_nicely();
175}
Note: See TracBrowser for help on using the repository browser.