Decoding and comma triggering works

This commit is contained in:
jaseg 2019-01-10 14:31:20 +09:00
parent 0161d6665c
commit 528d653bde
4 changed files with 92 additions and 32 deletions

View file

@ -82,40 +82,52 @@ int main(void) {
uint8_t txbuf[128];
int txpos = -1;
/* FIXME test code */
for (int i=0; i<sizeof(txbuf); i++)
for (int i=0; i<sizeof(txbuf)/sizeof(txbuf[0]); i++)
txbuf[i] = i;
/* FIXME end test code */
while (42) {
if (txstate.next_symbol == -NO_SYMBOL) {
txstate.next_symbol = xfr_8b10b_encode(&txstate.st, K28_1);
//if (txpos == -1)
// txstate.next_symbol = xfr_8b10b_encode(&txstate.st, K28_1);
//else
// txstate.next_symbol = xfr_8b10b_encode(&txstate.st, txbuf[txpos]);
if (txpos == -1)
txstate.next_symbol = xfr_8b10b_encode(&txstate.st, -K28_1);
else
txstate.next_symbol = xfr_8b10b_encode(&txstate.st, txbuf[txpos]);
txpos++;
if (txpos == sizeof(txbuf))
if (txpos >= sizeof(txbuf)/sizeof(txbuf[0]))
txpos = -1;
}
}
}
void TIM1_UP_IRQHandler() {
// FIXME debug code
static int debug_bit = 0;
debug_bit = !debug_bit;
int flipbits(int in) {
return
(in&0x200)>>9 |
(in&0x100)>>7 |
(in&0x080)>>5 |
(in&0x040)>>3 |
(in&0x020)>>1 |
(in&0x010)<<1 |
(in&0x008)<<3 |
(in&0x004)<<5 |
(in&0x002)<<7 |
(in&0x001)<<9;
}
void TIM1_UP_IRQHandler() {
TIM1->SR &= ~TIM_SR_UIF;
int sym = txstate.current_symbol;
int bit = sym&1;
sym >>= 1;
if (sym == 1) { /* last bit shifted out */
sym = txstate.next_symbol | 1<<10;
if (txstate.next_symbol == -NO_SYMBOL) /*FIXME debug code*/
asm volatile("bkpt");
sym = flipbits(txstate.next_symbol) | 1<<10;
txstate.next_symbol = -NO_SYMBOL;
}
txstate.current_symbol = sym;
TIM1->CCR1 = debug_bit ? 0xffff : 0x0000;
TIM1->CCR1 = bit ? 0xffff : 0x0000;
}
void NMI_Handler(void) {

File diff suppressed because one or more lines are too long

View file

@ -258,14 +258,16 @@ void DMA1_Channel1_IRQHandler(void) {
// st.detector.debounce_ctr--;
//}
/*
if (debug_buf_pos < NCH || debug_buf_pos >= sizeof(adc_buf)/sizeof(adc_buf[0])) {
debug_buf_pos = NCH;
gdb_dump();
}
adc_buf[debug_buf_pos++] = st.detector.len_ctr;
adc_buf[debug_buf_pos++] = st.detector.committed_len_ctr;
adc_buf[debug_buf_pos++] = st.detector.bit;
adc_buf[debug_buf_pos++] = diff;
int foo = 0;
*/
if (st.detector.len_ctr >= st.detector.committed_len_ctr) {
/*
@ -274,8 +276,41 @@ void DMA1_Channel1_IRQHandler(void) {
gdb_dump();
}
adc_buf[debug_buf_pos++] = st.detector.bit;
int foo = st.detector.symbol;
if (foo < 0 && foo != K28_1)
foo = 0;
adc_buf[debug_buf_pos++] = foo;
*/
if (st.detector.symbol != -DECODING_IN_PROGRESS) {
static int trig = 0;
if (st.detector.symbol == -K28_1) {
if (trig == 10) {
gdb_dump();
for (int i=0; i<sizeof(adc_buf)/sizeof(adc_buf[0]); i++)
adc_buf[i] = -255;
trig = 0;
} else if (trig == 1) {
debug_buf_pos = NCH;
}
trig++;
}
if (debug_buf_pos >= sizeof(adc_buf)/sizeof(adc_buf[0])) {
debug_buf_pos = 0;
}
if (debug_buf_pos >= NCH) {
adc_buf[debug_buf_pos++] = st.detector.symbol;
}
}
/*
if (debug_buf_pos < NCH || debug_buf_pos >= sizeof(adc_buf)/sizeof(adc_buf[0])) {
debug_buf_pos = NCH;
gdb_dump();
}
adc_buf[debug_buf_pos++] = st.detector.bit;
*/
//foo = st.detector.bit ? 1 : -1;
st.detector.committed_len_ctr += st.detector.base_interval_cycles;
st.detector.symbol = xfr_8b10b_feed_bit((struct state_8b10b_dec *)&st.detector.rx8b10b, st.detector.bit);
/*
@ -285,9 +320,14 @@ void DMA1_Channel1_IRQHandler(void) {
gdb_dump();
}
adc_buf[debug_buf_pos++] = st.detector.symbol;
adc_buf[debug_buf_pos++] = st.detector.symbol == -DECODING_ERROR;
adc_buf[debug_buf_pos++] = st.detector.symbol == -K28_1;
adc_buf[debug_buf_pos++] = 0;
}
*/
}
//adc_buf[debug_buf_pos++] = foo;
st.detector.len_ctr++;
st.ovs_count = 0;

12
fw/scope.gdb Normal file
View file

@ -0,0 +1,12 @@
target remote localhost:3334
set pagination off
file main.elf
load
break DMA1_Channel1_IRQHandler
command 1
dump binary value /tmp/scope_dump.bin adc_buf
continue
end
continue