| 1 | #include "parser.h"
|
|---|
| 2 | #include "output.h"
|
|---|
| 3 | #include "application.h"
|
|---|
| 4 | #include "usart.h"
|
|---|
| 5 | #include "w5100_spi_interface.h"
|
|---|
| 6 | #include "timer.h"
|
|---|
| 7 | // this method parses the data,
|
|---|
| 8 | // which came in via USART
|
|---|
| 9 | // later it might as well parse the data from ethernet.
|
|---|
| 10 | void parse_ascii() {
|
|---|
| 11 | usart_rx_buffer[USART_RX_BUFFER_SIZE-1] = 0;
|
|---|
| 12 | usart_write_str((pU08)"got:");
|
|---|
| 13 | usart_write_str(usart_rx_buffer);
|
|---|
| 14 |
|
|---|
| 15 | // look at first byte
|
|---|
| 16 | // I hope, I can manage to use one byte commands
|
|---|
| 17 | switch (usart_rx_buffer[0]) {
|
|---|
| 18 | case 'E': // AD7719 enable bitmaps may be set
|
|---|
| 19 | set_ad7719_enable_register();
|
|---|
| 20 | break;
|
|---|
| 21 | case 'e': // ATmega internal ADC enable bitmaps may be set
|
|---|
| 22 | // not supported yet.
|
|---|
| 23 | set_adc_enable_register();
|
|---|
| 24 | break;
|
|---|
| 25 | case 'h':
|
|---|
| 26 | usart_write_str((pU08)"\nheartbeat ");
|
|---|
| 27 | heartbeat_enable = true;
|
|---|
| 28 | if (usart_rx_buffer[1] == '0'){
|
|---|
| 29 | heartbeat_enable = false;
|
|---|
| 30 | usart_write_str((pU08)"off\n");
|
|---|
| 31 | } else {
|
|---|
| 32 | usart_write_str((pU08)"on\n");
|
|---|
| 33 | }
|
|---|
| 34 | break;
|
|---|
| 35 | case 'G': // GET the Temperature channels, which are enabled
|
|---|
| 36 | once_told_you = false;
|
|---|
| 37 | for ( U08 i=0; i<RESISTANCE_CHANNELS/8; ++i ) {
|
|---|
| 38 | ad7719_channels_ready[i]=0;
|
|---|
| 39 | }
|
|---|
| 40 | break;
|
|---|
| 41 |
|
|---|
| 42 | case 'g': // GET the voltage/current/humidity channels, which are enabled
|
|---|
| 43 | once_told_you = false;
|
|---|
| 44 | for ( U08 i=0; i<VOLTAGE_REGS; ++i ) {
|
|---|
| 45 | adc_channels_ready[i]=0;
|
|---|
| 46 | }
|
|---|
| 47 | break;
|
|---|
| 48 |
|
|---|
| 49 | case 'P':
|
|---|
| 50 | print_ad7719_nicely();
|
|---|
| 51 | break;
|
|---|
| 52 |
|
|---|
| 53 | case 'p':
|
|---|
| 54 | print_adc_nicely();
|
|---|
| 55 | break;
|
|---|
| 56 |
|
|---|
| 57 | case 's':
|
|---|
| 58 | print_status();
|
|---|
| 59 | break;
|
|---|
| 60 |
|
|---|
| 61 | case 'd':
|
|---|
| 62 | usart_write_str((pU08)"\ndebug mode ");
|
|---|
| 63 | debug_mode = true;
|
|---|
| 64 | if (usart_rx_buffer[1] == '0'){
|
|---|
| 65 | debug_mode = false;
|
|---|
| 66 | usart_write_str((pU08)"off\n");
|
|---|
| 67 | } else {
|
|---|
| 68 | usart_write_str((pU08)"on\n");
|
|---|
| 69 | }
|
|---|
| 70 | break;
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 | usart_write_str((pU08)"\nready?");
|
|---|
| 75 | for (U08 i=0; i<USART_RX_BUFFER_SIZE; ++i)
|
|---|
| 76 | usart_rx_buffer[i] = 0;
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | void parse_non_human_readable_input() {
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 | }
|
|---|
| 83 |
|
|---|
| 84 | // this guy checks, if an incoming byte is:
|
|---|
| 85 | // to be stored, because it belongs to a command
|
|---|
| 86 | // to be discarded, because something went wrong, and the bytemade no sense...
|
|---|
| 87 | // the end of a commmand, and so the 'real parser' may do his work.
|
|---|
| 88 | /*
|
|---|
| 89 | void incoming_byte_parser() {
|
|---|
| 90 | static bool receiving_command = false;
|
|---|
| 91 | U08 current_byte = UDR;
|
|---|
| 92 |
|
|---|
| 93 | if (!receiving_command) {
|
|---|
| 94 | switch (current_byte) {
|
|---|
| 95 | case 0x01:
|
|---|
| 96 | receiving_command = true;
|
|---|
| 97 | break;
|
|---|
| 98 | }
|
|---|
| 99 | }
|
|---|
| 100 |
|
|---|
| 101 | if (receiving_command)
|
|---|
| 102 | {
|
|---|
| 103 | usart_rx_buffer[usart_received_chars] = usart_last_char;
|
|---|
| 104 | usart_received_chars++;
|
|---|
| 105 | }
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 | }
|
|---|
| 109 | */
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 | // this is the recent MSR parser
|
|---|
| 113 | /////////////////////////////////////////////////////////////////////////////////////////////////////
|
|---|
| 114 | /////////////// P A R S E R /////////////////////////////////////////////////////////////////////////
|
|---|
| 115 | /////////////////////////////////////////////////////////////////////////////////////////////////////
|
|---|
| 116 | // this method parses the data,
|
|---|
| 117 | // which came in via USART
|
|---|
| 118 | // later it might as well parse the data from ethernet.
|
|---|
| 119 | void MSR_parser() {
|
|---|
| 120 |
|
|---|
| 121 | U08 input_number = 0;
|
|---|
| 122 | bool enable = false;
|
|---|
| 123 | // look at first byte
|
|---|
| 124 | // I hope, I can manage to use one byte commands
|
|---|
| 125 | usart_rx_buffer[USART_RX_BUFFER_SIZE-1] = 0;
|
|---|
| 126 | usart_write_char(' ');
|
|---|
| 127 | usart_write_str(usart_rx_buffer);
|
|---|
| 128 | usart_write_char('\n');
|
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 | if (usart_received_chars >0) {
|
|---|
| 132 | switch (usart_rx_buffer[0]) {
|
|---|
| 133 | case 'E': // user wants to enable/disable something
|
|---|
| 134 | case 'e':
|
|---|
| 135 | enable = true;
|
|---|
| 136 | case 'D':
|
|---|
| 137 | case 'd':
|
|---|
| 138 |
|
|---|
| 139 | if (usart_received_chars>=1) { // let's see what.
|
|---|
| 140 | if ( usart_rx_buffer[1] != 'r' &&
|
|---|
| 141 | usart_rx_buffer[1] != 'v' &&
|
|---|
| 142 | usart_rx_buffer[1] != 'h' &&
|
|---|
| 143 | usart_rx_buffer[1] != 'p' )
|
|---|
| 144 | {
|
|---|
| 145 | //print_invalid_enable_statement();
|
|---|
| 146 | break;
|
|---|
| 147 | }
|
|---|
| 148 | }
|
|---|
| 149 |
|
|---|
| 150 | input_number = 0;
|
|---|
| 151 | if (usart_received_chars >2) { // lets check the first digit
|
|---|
| 152 | if ( usart_rx_buffer[2] >= '0' && usart_rx_buffer[2] <= '9' ) {
|
|---|
| 153 | input_number = usart_rx_buffer[2] - '0';
|
|---|
| 154 | } else {
|
|---|
| 155 | //print_invalid_enable_statement();
|
|---|
| 156 | break;
|
|---|
| 157 | }
|
|---|
| 158 | }
|
|---|
| 159 | if (usart_received_chars >3) { // lets check the 2nd digit
|
|---|
| 160 | if ( usart_rx_buffer[3] >= '0' && usart_rx_buffer[3] <= '9' ) {
|
|---|
| 161 | input_number = 10*input_number + usart_rx_buffer[3] - '0';
|
|---|
| 162 | } else {
|
|---|
| 163 | // okay as well ... if the second digit is missing ..
|
|---|
| 164 | // we might have trailing spaces
|
|---|
| 165 | // that's okay .. we just accept the first number.
|
|---|
| 166 | }
|
|---|
| 167 | }
|
|---|
| 168 | if (usart_received_chars>2) {
|
|---|
| 169 | usart_write_str((pU08)"\n I will switch ");
|
|---|
| 170 | if (enable)
|
|---|
| 171 | usart_write_str((pU08)"on ");
|
|---|
| 172 | else
|
|---|
| 173 | usart_write_str((pU08)"off ");
|
|---|
| 174 |
|
|---|
| 175 | // now we know, what the user wanted ... and we need to do it.
|
|---|
| 176 | switch (usart_rx_buffer[1]) {
|
|---|
| 177 | case 'r':
|
|---|
| 178 | if (enable)
|
|---|
| 179 | ad7719_enables[input_number/8] |= (1<<(input_number%8));
|
|---|
| 180 | else {
|
|---|
| 181 | ad7719_enables[input_number/8] &= ~(1<<(input_number%8));
|
|---|
| 182 | ad7719_channels_ready[input_number/8] &= ~(1<<(input_number%8));
|
|---|
| 183 | }
|
|---|
| 184 | usart_write_str((pU08)" resistance channel ");
|
|---|
| 185 | usart_write_U08(input_number,2);
|
|---|
| 186 | usart_write_char('\n');
|
|---|
| 187 | break;
|
|---|
| 188 | case 'v':
|
|---|
| 189 | if (enable)
|
|---|
| 190 | adc_enables[input_number/8] |= (1<<(input_number%8));
|
|---|
| 191 | else {
|
|---|
| 192 | adc_enables[input_number/8] &= ~(1<<(input_number%8));
|
|---|
| 193 | adc_channels_ready[input_number/8] &= ~(1<<(input_number%8));
|
|---|
| 194 | }
|
|---|
| 195 | usart_write_str((pU08)" voltage channel ");
|
|---|
| 196 | usart_write_U08(input_number,2);
|
|---|
| 197 | usart_write_char('\n');
|
|---|
| 198 | break;
|
|---|
| 199 |
|
|---|
| 200 | case 'h':
|
|---|
| 201 | if (enable)
|
|---|
| 202 | adc_enables[1] |= (1<<(input_number%4));
|
|---|
| 203 | else {
|
|---|
| 204 | adc_enables[1] &= ~(1<<(input_number%4));
|
|---|
| 205 | adc_channels_ready[1] &= ~(1<<(input_number%4));
|
|---|
| 206 | }
|
|---|
| 207 | usart_write_str((pU08)" humidity channel ");
|
|---|
| 208 | usart_write_U08(input_number,2);
|
|---|
| 209 | usart_write_char('\n');
|
|---|
| 210 | break;
|
|---|
| 211 | case 'p':
|
|---|
| 212 | if (enable)
|
|---|
| 213 | adc_enables[1] |= (1<<((input_number%4) + 4));
|
|---|
| 214 | else {
|
|---|
| 215 | adc_enables[1] &= ~(1<<((input_number%4) + 4));
|
|---|
| 216 | adc_channels_ready[1] &= ~(1<<((input_number%4) + 4));
|
|---|
| 217 | }
|
|---|
| 218 | usart_write_str((pU08)" pressure channel ");
|
|---|
| 219 | usart_write_U08(input_number,2);
|
|---|
| 220 | usart_write_char('\n');
|
|---|
| 221 | break;
|
|---|
| 222 | default:
|
|---|
| 223 | usart_write_str((pU08)"\n DAMN! this should never happen"
|
|---|
| 224 | "- enable/disable switch-case!\n");
|
|---|
| 225 | break;
|
|---|
| 226 | }
|
|---|
| 227 |
|
|---|
| 228 |
|
|---|
| 229 |
|
|---|
| 230 | }// end of if usart_received_chars>2 --> this should not be necessary at all
|
|---|
| 231 | break;
|
|---|
| 232 |
|
|---|
| 233 | case 'b':
|
|---|
| 234 | usart_write_str((pU08)"\nheartbeat ");
|
|---|
| 235 | heartbeat_enable = true;
|
|---|
| 236 | if (usart_rx_buffer[1] == '0'){
|
|---|
| 237 | heartbeat_enable = false;
|
|---|
| 238 | usart_write_str((pU08)"off\n");
|
|---|
| 239 | } else {
|
|---|
| 240 | usart_write_str((pU08)"on\n");
|
|---|
| 241 | }
|
|---|
| 242 | break;
|
|---|
| 243 | case 'G': // GET the Temperature channels, which are enabled
|
|---|
| 244 | ad7719_values_printed = false;
|
|---|
| 245 | reset_resistance_done();
|
|---|
| 246 | reset_resistance_values();
|
|---|
| 247 | break;
|
|---|
| 248 |
|
|---|
| 249 | case 'g': // GET the voltage/current/humidity channels, which are enabled
|
|---|
| 250 | adc_values_printed = false;
|
|---|
| 251 | reset_voltage_done();
|
|---|
| 252 | reset_voltage_values();
|
|---|
| 253 | break;
|
|---|
| 254 |
|
|---|
| 255 | case 'p':
|
|---|
| 256 | adc_print_endless = true;
|
|---|
| 257 | if (usart_rx_buffer[1] == '0')
|
|---|
| 258 | adc_print_endless = false;
|
|---|
| 259 | break;
|
|---|
| 260 |
|
|---|
| 261 | case 'P':
|
|---|
| 262 | ad7719_print_endless = true;
|
|---|
| 263 | if (usart_rx_buffer[1] == '0')
|
|---|
| 264 | ad7719_print_endless = false;
|
|---|
| 265 | break;
|
|---|
| 266 |
|
|---|
| 267 | case 's':
|
|---|
| 268 | print_status();
|
|---|
| 269 | //print_adc_enable_status(true);
|
|---|
| 270 | //usart_write_char('\n');
|
|---|
| 271 |
|
|---|
| 272 | //print_ad7719_enable_status(true);
|
|---|
| 273 | //usart_write_char('\n');
|
|---|
| 274 |
|
|---|
| 275 | //usart_write_str((pU08)"time:");
|
|---|
| 276 | //usart_write_float((float)local_ms/1000 , 1,7);
|
|---|
| 277 | //usart_write_str((pU08)" sec.\n");
|
|---|
| 278 | break;
|
|---|
| 279 |
|
|---|
| 280 | case 'S':
|
|---|
| 281 | write_status_via_eth();
|
|---|
| 282 | break;
|
|---|
| 283 |
|
|---|
| 284 | case '!':
|
|---|
| 285 | usart_write_str((pU08)"\ndebug mode ");
|
|---|
| 286 | debug_mode = true;
|
|---|
| 287 | if (usart_rx_buffer[1] == '0'){
|
|---|
| 288 | debug_mode = false;
|
|---|
| 289 | usart_write_str((pU08)"off\n");
|
|---|
| 290 | } else {
|
|---|
| 291 | usart_write_str((pU08)"on\n");
|
|---|
| 292 | }
|
|---|
| 293 | break;
|
|---|
| 294 |
|
|---|
| 295 | case 'h':
|
|---|
| 296 | case 'H':
|
|---|
| 297 | print_help();
|
|---|
| 298 | break;
|
|---|
| 299 | }
|
|---|
| 300 | } else
|
|---|
| 301 | {
|
|---|
| 302 | // zero bytes received
|
|---|
| 303 | }
|
|---|
| 304 |
|
|---|
| 305 |
|
|---|
| 306 | for (U08 i=0; i<USART_RX_BUFFER_SIZE; ++i)
|
|---|
| 307 | usart_rx_buffer[i] = 0;
|
|---|
| 308 | usart_received_chars = 0;
|
|---|
| 309 | usart_rx_ready = false;
|
|---|
| 310 | } // END of MSR_parser();
|
|---|
| 311 |
|
|---|
| 312 |
|
|---|
| 313 |
|
|---|
| 314 | ///////////////////////////////////////////////////////////////////////////////////////
|
|---|
| 315 | // W5300 incoming commands parser
|
|---|
| 316 | void parse_w5300_incoming( U08 bytes_in_w5100_rx_buffer ) {
|
|---|
| 317 |
|
|---|
| 318 | usart_writeln_str((pU08)"parsget:");
|
|---|
| 319 | for (U08 i =0; i< ETH_READ_BUFFER_SIZE ; i++) {
|
|---|
| 320 | usart_write_U08_hex(eth_read_buffer[i]);
|
|---|
| 321 | usart_write_char((U08)eth_read_buffer[i]);
|
|---|
| 322 |
|
|---|
| 323 | }
|
|---|
| 324 | usart_write_crlf();
|
|---|
| 325 |
|
|---|
| 326 | if (bytes_in_w5100_rx_buffer == 0) // it was stupid to call this parser without having any bytes downloaded
|
|---|
| 327 | return;
|
|---|
| 328 |
|
|---|
| 329 | switch (eth_read_buffer[0]) {
|
|---|
| 330 | case 'w': // *w*rite to register command
|
|---|
| 331 | write_FSC_register();
|
|---|
| 332 | read_FSC_register();
|
|---|
| 333 | break;
|
|---|
| 334 |
|
|---|
| 335 | case 'r': // *r*ead from register command
|
|---|
| 336 | read_FSC_register();
|
|---|
| 337 | break;
|
|---|
| 338 |
|
|---|
| 339 | case 't': // measure *t*emperature (resistance) channels only
|
|---|
| 340 | ad7719_values_printed = false;
|
|---|
| 341 | reset_resistance_done();
|
|---|
| 342 | simple_acknowledge();
|
|---|
| 343 | break;
|
|---|
| 344 |
|
|---|
| 345 | case 'v': // measure *v*oltage channels only
|
|---|
| 346 | adc_values_printed = false;
|
|---|
| 347 | reset_voltage_done();
|
|---|
| 348 | simple_acknowledge();
|
|---|
| 349 | break;
|
|---|
| 350 |
|
|---|
| 351 | case 'm': // *m*easure active channels commands
|
|---|
| 352 | reset_done();
|
|---|
| 353 | ad7719_print_endless = true;
|
|---|
| 354 | //simple_acknowledge();
|
|---|
| 355 | break;
|
|---|
| 356 |
|
|---|
| 357 | case 's': // return *s*tatus information
|
|---|
| 358 | // this might take a lot of time... about... 25us per byte .. --> less than 25ms
|
|---|
| 359 | write_status_via_eth();
|
|---|
| 360 | //w5100_set_TX(FSCregister, FSC_REGISTER_LENGTH);
|
|---|
| 361 | break;
|
|---|
| 362 |
|
|---|
| 363 | case 'k':
|
|---|
| 364 | eth_write_stuff();
|
|---|
| 365 | break;
|
|---|
| 366 |
|
|---|
| 367 | case 'z': // re*z*et ATmega32 and peripherals
|
|---|
| 368 | eth_write_buffer[0]='!';
|
|---|
| 369 | eth_write_buffer[1]='!';
|
|---|
| 370 | w5100_set_TX(eth_write_buffer, 2);
|
|---|
| 371 | // let watchdog occur!
|
|---|
| 372 | // gotta read, how this works...
|
|---|
| 373 | break;
|
|---|
| 374 | }
|
|---|
| 375 | }
|
|---|
| 376 |
|
|---|
| 377 | void write_FSC_register() {
|
|---|
| 378 | FSCregister[eth_read_buffer[2]]=eth_read_buffer[3];
|
|---|
| 379 | }
|
|---|
| 380 |
|
|---|
| 381 | void read_FSC_register() {
|
|---|
| 382 | eth_write_buffer[0]=eth_read_buffer[0];
|
|---|
| 383 | eth_write_buffer[1]=eth_read_buffer[1];
|
|---|
| 384 | eth_write_buffer[2]=eth_read_buffer[2];
|
|---|
| 385 | eth_write_buffer[3]=FSCregister[eth_read_buffer[2]];
|
|---|
| 386 | w5100_set_TX(eth_write_buffer, 4);
|
|---|
| 387 | }
|
|---|
| 388 |
|
|---|
| 389 | void reset_resistance_done(){
|
|---|
| 390 | for (U08 i=0; i < (RESISTANCE_CHANNELS/8); i++){
|
|---|
| 391 | ad7719_channels_ready[i] = 0;
|
|---|
| 392 | }
|
|---|
| 393 | }
|
|---|
| 394 | void reset_resistance_values(){
|
|---|
| 395 | for (U08 i=0; i < RESISTANCE_CHANNELS; i++){
|
|---|
| 396 | ad7719_values[i] = 0;
|
|---|
| 397 | }
|
|---|
| 398 | }
|
|---|
| 399 |
|
|---|
| 400 |
|
|---|
| 401 | void reset_voltage_done(){
|
|---|
| 402 | for (U08 i=0; i < (VOLTAGE_REGS); i++){
|
|---|
| 403 | adc_channels_ready[i] = 0;
|
|---|
| 404 | }
|
|---|
| 405 | }
|
|---|
| 406 | void reset_voltage_values(){
|
|---|
| 407 | for (U08 i=0; i < VOLTAGE_CHANNELS; i++){
|
|---|
| 408 | adc_values[i] = 0;
|
|---|
| 409 | }
|
|---|
| 410 | }
|
|---|
| 411 |
|
|---|
| 412 | void reset_done(){
|
|---|
| 413 | reset_resistance_done();
|
|---|
| 414 | reset_voltage_done();
|
|---|
| 415 | }
|
|---|
| 416 |
|
|---|
| 417 | void simple_acknowledge(){
|
|---|
| 418 | eth_write_buffer[0]=eth_read_buffer[0];
|
|---|
| 419 | eth_write_buffer[1]=eth_read_buffer[1];
|
|---|
| 420 | w5100_set_TX(eth_write_buffer, 2);
|
|---|
| 421 | }
|
|---|
| 422 |
|
|---|
| 423 | void write_status_via_eth() {
|
|---|
| 424 | float resistance;
|
|---|
| 425 |
|
|---|
| 426 | // take care: ethernet write buffer is just 32 bytes long.
|
|---|
| 427 | eth_write_str("status: "); eth_writeln_str(nc_U32_to_hex(status));
|
|---|
| 428 | // better switch off interrupts here:
|
|---|
| 429 | // otherwise the numbers in time_sec and time_ms might get corrupt during output.
|
|---|
| 430 | cli();
|
|---|
| 431 | eth_write_str("time_s: "); eth_write_str(nc_U32_to_str(sec, 1));
|
|---|
| 432 | eth_write_str(".");eth_writeln_str(nc_U16_to_str(milisec, 1));
|
|---|
| 433 | //eth_write_str("mili_s: "); eth_writeln_str(nc_U16_to_str(milisec, 1));
|
|---|
| 434 | sei();
|
|---|
| 435 |
|
|---|
| 436 | //eth_write_str("R_ref : "); eth_writeln_str(nc_U16_to_str(ref_resistor, 6));
|
|---|
| 437 |
|
|---|
| 438 | eth_writeln_str("VOLTAGES\n");
|
|---|
| 439 | eth_write_str("enable:");
|
|---|
| 440 | for (U08 i=0; i<VOLTAGE_REGS ; i++){
|
|---|
| 441 | eth_write_str(nc_U08_to_bin(adc_enables[i]));
|
|---|
| 442 | // need to tweak here in order to get some nice spaces...
|
|---|
| 443 | eth_write_buffer[eth_write_index] = ' ';
|
|---|
| 444 | eth_write_index++;
|
|---|
| 445 | }
|
|---|
| 446 | eth_write_buffer[eth_write_index++] = '\n';
|
|---|
| 447 |
|
|---|
| 448 | eth_write_str(" done:");
|
|---|
| 449 | for (U08 i=0; i<VOLTAGE_REGS ; i++){
|
|---|
| 450 | eth_write_str(nc_U08_to_bin(adc_channels_ready[i]));
|
|---|
| 451 | // need to tweak here in order to get some nice spaces...
|
|---|
| 452 | eth_write_buffer[eth_write_index] = ' ';
|
|---|
| 453 | eth_write_index++;
|
|---|
| 454 | }
|
|---|
| 455 | eth_write_buffer[eth_write_index++] = '\n';
|
|---|
| 456 |
|
|---|
| 457 | eth_write_str("values:");
|
|---|
| 458 | for (U08 i=0; i<VOLTAGE_CHANNELS ; i++){
|
|---|
| 459 | eth_write_str(nc_U16_to_str(adc_values[i]/10, 1) );
|
|---|
| 460 | // need to tweak here in order to get some nice spaces...
|
|---|
| 461 | eth_write_buffer[eth_write_index] = ' ';
|
|---|
| 462 | eth_write_index++;
|
|---|
| 463 | }
|
|---|
| 464 | eth_write_buffer[eth_write_index++] = '\n';
|
|---|
| 465 |
|
|---|
| 466 | eth_writeln_str("RESISTANCES\n");
|
|---|
| 467 | eth_write_str("enable:");
|
|---|
| 468 | for (U08 i=0; i<(RESISTANCE_CHANNELS/8) ; i++){
|
|---|
| 469 | eth_write_str(nc_U08_to_bin(ad7719_enables[i]));
|
|---|
| 470 | // need to tweak here in order to get some nice spaces...
|
|---|
| 471 | eth_write_buffer[eth_write_index] = ' ';
|
|---|
| 472 | eth_write_index++;
|
|---|
| 473 | }
|
|---|
| 474 | eth_write_buffer[eth_write_index++] = '\n';
|
|---|
| 475 |
|
|---|
| 476 | eth_write_str(" done:");
|
|---|
| 477 | for (U08 i=0; i<(RESISTANCE_CHANNELS/8) ; i++){
|
|---|
| 478 | eth_write_str(nc_U08_to_bin(ad7719_channels_ready[i]));
|
|---|
| 479 | // need to tweak here in order to get some nice spaces...
|
|---|
| 480 | eth_write_buffer[eth_write_index] = ' ';
|
|---|
| 481 | eth_write_index++;
|
|---|
| 482 | }
|
|---|
| 483 | eth_write_buffer[eth_write_index++] = '\n';
|
|---|
| 484 |
|
|---|
| 485 | eth_write_str("values:\n");
|
|---|
| 486 | for (U08 i=0; i<RESISTANCE_CHANNELS ; i++){
|
|---|
| 487 | //eth_write_str(nc_U32_to_str(ad7719_values[i], 10) );
|
|---|
| 488 |
|
|---|
| 489 | resistance = (6.25 * 1024 * ad7719_values[i]) / ((U32)1 << 25);
|
|---|
| 490 | eth_write_str(nc_float_to_str(resistance , 2, 2) );
|
|---|
| 491 | // need to tweak here in order to get some nice spaces...
|
|---|
| 492 | if (i%8 == 7)
|
|---|
| 493 | eth_write_buffer[eth_write_index] = '\n';
|
|---|
| 494 | else
|
|---|
| 495 | eth_write_buffer[eth_write_index] = ' ';
|
|---|
| 496 |
|
|---|
| 497 | eth_write_index++;
|
|---|
| 498 | }
|
|---|
| 499 | eth_writeln_str("\nend.\n");
|
|---|
| 500 |
|
|---|
| 501 |
|
|---|
| 502 | }
|
|---|
| 503 |
|
|---|
| 504 | void eth_write_stuff(void) {
|
|---|
| 505 | S08 buf []="Test Ah A!!\n";
|
|---|
| 506 | for (U08 i =0 ; i<255 ; i++) {
|
|---|
| 507 | eth_write_str(nc_U08_to_str(i,4));
|
|---|
| 508 | eth_write_str(buf);
|
|---|
| 509 | }
|
|---|
| 510 | }
|
|---|