8b/10b tx/rx works

This commit is contained in:
jaseg 2023-09-30 18:25:10 +02:00
parent ee1d1bd0c2
commit 67e30fa91e
4 changed files with 126 additions and 10 deletions

View file

@ -202,6 +202,9 @@ void dma_tx_constant(size_t table_size, uint16_t constant) {
DMA1_Channel1->CCR |= DMA_CCR_EN;
}
int8_t bit_arr[4096];
size_t bit_pos = 0;
void DMA1_Channel1_IRQHandler() {
static int transfer_errors = 0;
static int current_symbol = 0x2aa;
@ -213,6 +216,10 @@ void DMA1_Channel1_IRQHandler() {
DMA1->IFCR = DMA_IFCR_CGIF1;
int bit = !!(current_symbol & (1<<tx_bitpos));
bit_arr[bit_pos++] = bit;
if (bit_pos == COUNT_OF(bit_arr)) {
bit_pos = 0;
}
if (tx_last_bit == bit) {
dma_tx_constant(COUNT_OF(waveform_zero_one), bit ? WAVEFORM_CONST_ONE : WAVEFORM_CONST_ZERO);
@ -224,14 +231,15 @@ void DMA1_Channel1_IRQHandler() {
tx_last_bit = bit;
tx_bitpos ++;
if (tx_bitpos >= 10) {
tx_bitpos = 0;
tx_sympos ++;
if (tx_bitpos == 0) {
tx_bitpos = 9;
current_symbol = xfr_8b10b_encode(&encoder_state_8b10b, tx_datagram[tx_sympos]);
tx_sympos ++;
if (tx_sympos >= COUNT_OF(tx_datagram)) {
tx_sympos = 0;
}
} else {
tx_bitpos --;
}
}