aboutsummaryrefslogtreecommitdiff
path: root/driver_fw/src
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2023-09-30 18:25:10 +0200
committerjaseg <git@jaseg.de>2023-09-30 18:25:10 +0200
commit67e30fa91e12b452c1a18f6c5eb8a33cdb9ec625 (patch)
tree583a3e944cb266248a6011d33bebe58cc55ee23c /driver_fw/src
parentee1d1bd0c2c944643596af85b935a128db847117 (diff)
download8seg-67e30fa91e12b452c1a18f6c5eb8a33cdb9ec625.tar.gz
8seg-67e30fa91e12b452c1a18f6c5eb8a33cdb9ec625.tar.bz2
8seg-67e30fa91e12b452c1a18f6c5eb8a33cdb9ec625.zip
8b/10b tx/rx works
Diffstat (limited to 'driver_fw/src')
-rw-r--r--driver_fw/src/main.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/driver_fw/src/main.c b/driver_fw/src/main.c
index 52b4a4d..0b3c869 100644
--- a/driver_fw/src/main.c
+++ b/driver_fw/src/main.c
@@ -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 --;
}
}