Compare commits

..

2 commits

Author SHA1 Message Date
Stephan I. Böttcher
c2823eded9 Add send_cks()
The ADC readings were not covered by the checksum.  Send a second 'Q'
line for those.
2024-09-21 12:43:39 +02:00
Stephan I. Böttcher
71f57d2f06 Add 'Q' uart_cks
When POWER_LINE is set, send a one byte checksum of the characters
from after the preamble up to including the Q.
2024-09-21 12:20:51 +02:00
4 changed files with 25 additions and 0 deletions

View file

@ -496,6 +496,9 @@ int main()
send_calib_adc(i);
send_eol();
}
if (config.send & (SEND_ADC_VOLT|SEND_ADC_HEX))
if (config.power & POWER_LINE)
send_cks();
}
command();
@ -560,6 +563,8 @@ int main()
continue;
}
uart_cks = 0;
if (config.send & SEND_CONFIG && !config_clock--) {
send_config = 1;
config_clock = config.confp;
@ -618,6 +623,11 @@ int main()
DEBUG_PRINT(0x77, trigger);
}
if (config.power & POWER_LINE) {
send_cks();
uart_cks = 0;
}
uart_tick();
trigger = TRIGGER_CONT;
send_config = 0;

View file

@ -72,6 +72,7 @@ uint8_t uart_tx[256];
volatile uint8_t uart_tx_w;
volatile uint8_t uart_tx_r;
volatile uint8_t uart_tx_busy;
uint8_t uart_cks;
#if 0

View file

@ -35,3 +35,6 @@ void send_hex_long(uint32_t b)
send_hex_word(b >> 16);
send_hex_word(b);
}
extern uint8_t uart_cks;
void send_cks();

View file

@ -9,6 +9,7 @@
.global send_str
.global uart_busy
.global send_hex
.global send_cks
.global send_eol
.global command
@ -34,6 +35,9 @@ put_char:
sbci r31, hi8(-(uart_tx))
st Z, r22
sts uart_tx_w, r19
lds r19, uart_cks
add r19, r22
sts uart_cks, r19
1:
// r22 preserved
// r23 full when zero
@ -89,6 +93,13 @@ uart_busy:
9:
ret
; send_hex('Q', &uart_cks, 1, 0);
send_cks:
ldi r24, 'Q'
ldi r18, 0
ldi r20, 1
ldi r22, lo8(uart_cks)
ldi r23, hi8(uart_cks)
send_hex:
movw r26, r22
rcall send_char