Rev 467 | Rev 471 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 467 | Rev 468 | ||
---|---|---|---|
Line 148... | Line 148... | ||
148 | //sei(); // we do it later |
148 | //sei(); // we do it later |
149 | } |
149 | } |
Line 150... | Line 150... | ||
150 | 150 | ||
151 | volatile size_t icnt = 0; |
151 | volatile size_t icnt = 0; |
152 | volatile unsigned char * iptr; |
152 | volatile unsigned char * iptr; |
153 | volatile unsigned char spi_cmd_buffer[5]; |
153 | volatile unsigned char spi_cmd_buffer[8]; |
154 | volatile uint8_t spi_ready = 1; |
154 | volatile uint8_t spi_ready = 1; |
- | 155 | int16_t ampere = 0, max_ampere = 0; |
|
Line 155... | Line 156... | ||
155 | int16_t ampere = 0, max_ampere = 0; |
156 | int32_t ampere_wasted = 0; |
156 | 157 | ||
157 | /** |
158 | /** |
158 | * SPI interrupt handler |
159 | * SPI interrupt handler |
Line 552... | Line 553... | ||
552 | if (!icnt && spi_ready) { |
553 | if (!icnt && spi_ready) { |
553 | // correct transfer ends with d (done) |
554 | // correct transfer ends with d (done) |
554 | if (spi_cmd_buffer[0] == 'd') { |
555 | if (spi_cmd_buffer[0] == 'd') { |
555 | ampere = spi_cmd_buffer[1] << 8; |
556 | ampere = spi_cmd_buffer[1] << 8; |
556 | ampere |= spi_cmd_buffer[2]; |
557 | ampere |= spi_cmd_buffer[2]; |
- | 558 | ampere_wasted = spi_cmd_buffer[3]; |
|
- | 559 | ampere_wasted = ampere_wasted << 8; |
|
- | 560 | ampere_wasted |= spi_cmd_buffer[4]; |
|
- | 561 | ampere_wasted = ampere_wasted << 8; |
|
- | 562 | ampere_wasted |= spi_cmd_buffer[5]; |
|
- | 563 | ampere_wasted = ampere_wasted << 8; |
|
- | 564 | ampere_wasted |= spi_cmd_buffer[6]; |
|
- | 565 | //ampere = *((int16_t *) spi_cmd_buffer + 1); |
|
- | 566 | //ampere_wasted = *((int32_t *) &spi_cmd_buffer + 3); |
|
557 | // if this is the first receival we should print the small A |
567 | // if this is the first receival we should print the small A |
558 | if (!(COSD_FLAGS2 & COSD_FLAG_STROMREC)) { |
568 | if (!(COSD_FLAGS2 & COSD_FLAG_STROMREC)) { |
559 | COSD_FLAGS &= ~COSD_ICONS_WRITTEN; |
569 | COSD_FLAGS &= ~COSD_ICONS_WRITTEN; |
560 | // update this flag |
570 | // update this flag |
561 | COSD_FLAGS2 |= COSD_FLAG_STROMREC; |
571 | COSD_FLAGS2 |= COSD_FLAG_STROMREC; |
Line 567... | Line 577... | ||
567 | //write_ascii_char(8+4*30, 'i'); // invalid |
577 | //write_ascii_char(8+4*30, 'i'); // invalid |
568 | } |
578 | } |
569 | spi_cmd_buffer[0] = 'A'; |
579 | spi_cmd_buffer[0] = 'A'; |
570 | spi_cmd_buffer[1] = 'B'; |
580 | spi_cmd_buffer[1] = 'B'; |
571 | spi_cmd_buffer[2] = 'C'; |
581 | spi_cmd_buffer[2] = 'C'; |
- | 582 | spi_cmd_buffer[3] = 'D'; |
|
- | 583 | spi_cmd_buffer[4] = 'E'; |
|
- | 584 | spi_cmd_buffer[5] = 'F'; |
|
- | 585 | spi_cmd_buffer[6] = 'G'; |
|
572 | StartTransfer((unsigned char*) spi_cmd_buffer, 3); |
586 | StartTransfer((unsigned char*) spi_cmd_buffer, 7); |
573 | } |
587 | } |
574 | if (rxd_buffer_locked) { |
588 | if (rxd_buffer_locked) { |
575 | if (COSD_FLAGS & COSD_FLAG_HUD) { |
589 | if (COSD_FLAGS & COSD_FLAG_HUD) { |
576 | #if FCONLY |
590 | #if FCONLY |
577 | if (rxd_buffer[2] == 'D') { // FC Data |
591 | if (rxd_buffer[2] == 'D') { // FC Data |