Fix the nasty 8b/10b bug

This commit is contained in:
jaseg 2023-10-02 01:42:34 +02:00
parent c8623eb4c6
commit 72cffd586a
3 changed files with 31 additions and 26 deletions

File diff suppressed because one or more lines are too long

View file

@ -195,7 +195,9 @@ size_t adc_dump_pos = 0;
uint8_t bit_dump[4096];
size_t bit_dump_pos = 0;
bool armed = false;
void gdb_dump(void) {
armed = false;
}
void ADC1_IRQHandler(void) {
@ -237,10 +239,15 @@ void ADC1_IRQHandler(void) {
bit_dump_pos++;
if (bit_dump_pos == COUNT_OF(bit_dump)) {
bit_dump_pos = 0;
gdb_dump();
armed = true;
}
int rc = xfr_8b10b_feed_bit((struct state_8b10b_dec *)&st_8b10b_dec, bit);
if (rc == 0xfb) {
if (armed)
gdb_dump();
}
if (rc > -K_CODES_LAST) {
sym_dump[sym_dump_pos++] = rc;
if (sym_dump_pos == COUNT_OF(sym_dump)) {
@ -279,7 +286,7 @@ void ADC1_IRQHandler(void) {
}
}
}
} else {
} else if (rc == -DECODING_ERROR) {
errors.decoding_errors++;
}
}

View file

@ -174,7 +174,7 @@ int xfr_8b10b_feed_bit(struct state_8b10b_dec *st, int bit) {
st->bit_ctr = 1;
for (int i=1; i<sizeof(k_sym_map)/sizeof(k_sym_map[0]); i++) {
if (pattern == k_sym_map[i])
if (pattern == k_sym_map[i] || ((~pattern)&0x3ff) == k_sym_map[i])
return -i;
}