From efc91241d93abcb6d4eb8fec1924c4d0988cce4f Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 20 Oct 2024 23:09:24 +0200 Subject: [PATCH] avr: new uart_bitbang module works now. --- avr/devices/n14/n14_main.asm | 3 +- avr/modules/com2/buffer.asm | 3 +- avr/modules/com2/main.asm | 384 +++++++------------------ avr/modules/comproto/msg_device.asm | 1 - avr/modules/comproto/msg_memstats.asm | 4 +- avr/modules/comproto/msg_value.asm | 11 +- avr/modules/uart_bitbang/bytelevel.asm | 4 +- avr/modules/uart_bitbang/main.asm | 45 ++- 8 files changed, 137 insertions(+), 318 deletions(-) diff --git a/avr/devices/n14/n14_main.asm b/avr/devices/n14/n14_main.asm index 3a751f2..57ce67f 100644 --- a/avr/devices/n14/n14_main.asm +++ b/avr/devices/n14/n14_main.asm @@ -82,7 +82,7 @@ rjmp BOOTLOADER_ADDR ; Reset vector ; use this for flashed system reti ; EXT_INT0 - rjmp com2IsrPcint0 ; PCI0 + rjmp uartBitbangIsrPcint0 ; PCI0 reti ; OC1A reti ; OVF1 reti ; OVF0 @@ -127,6 +127,7 @@ firmwareStart: rjmp main #ifdef MODULES_COM .include "modules/com2/defs.asm" .include "modules/com2/main.asm" + .include "modules/com2/buffer.asm" .include "modules/uart_bitbang/defs.asm" .include "modules/uart_bitbang/main.asm" .include "modules/uart_bitbang/bytelevel.asm" diff --git a/avr/modules/com2/buffer.asm b/avr/modules/com2/buffer.asm index 2f93e33..876f624 100644 --- a/avr/modules/com2/buffer.asm +++ b/avr/modules/com2/buffer.asm @@ -37,6 +37,7 @@ ; @param %1 pointer to byte containing max number of buffers ever used ; @param %2 pointer to byte containing number of buffers currently in use ; @param %3 pointer to byte containing the write pointer +; @param %4 pointer to routine to calculate buffer pos (e.g. uartBitbang_BufferPosToX) ; @return CFLAG set if okay, clear otherwise ; @return X pos to allocated buffer ; @clobbers R16, R17, R21 @@ -62,7 +63,7 @@ l0: clr r17 ; wraparound l1: sts @3, r17 ; store new writepos for next caller - rcall COM2_BufferPosToX ; (R16, R17) + rcall @4 ; *_BufferPosToX(R16, R17) out SREG, r21 ; restore global interrupt enable bit in SREG sec rjmp l_end diff --git a/avr/modules/com2/main.asm b/avr/modules/com2/main.asm index 1b32d31..da9e6d9 100644 --- a/avr/modules/com2/main.asm +++ b/avr/modules/com2/main.asm @@ -42,12 +42,9 @@ com2SendStatsEnd: com2StatsNotForMe: .byte 2 com2StatsIgnored: .byte 2 - com2RecvBuffersUsed: .byte 1 - com2MaxBuffersUsed: .byte 1 - com2RecvBuffersWritePos: .byte 1 - com2RecvBuffersReadPos: .byte 1 + com2MaxSendBuffersUsed: .byte 1 + com2MaxRecvBuffersUsed: .byte 1 - com2RecvBuffers: .byte COM2_BUFFER_SIZE*COM2_BUFFER_NUM com2SendBuffer: .byte COM2_BUFFER_SIZE com2DataEnd: @@ -63,12 +60,6 @@ COM2_BEGIN: -; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -; Module interface -; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - - ; --------------------------------------------------------------------------- ; Com2_Init ; @@ -89,47 +80,48 @@ Com2_Init: clr r16 sts com2Address, r16 - ; setup pins and interrupts - cbi COM_PORT_DATA, COM_PINNUM_DATA ; disable internal pullup for DATA - cbi COM_DDR_DATA, COM_PINNUM_DATA ; set DATA port as input - - cbi COM_PORT_ATTN, COM_PINNUM_ATTN ; disable internal pullup for ATTN - cbi COM_DDR_ATTN, COM_PINNUM_ATTN ; set ATTN port as input - - sbi COM_IRQ_ADDR_ATTN, COM_IRQ_BIT_ATTN ; enable pin change irq for ATTN line - in r16, GIMSK ; enable pin change irq PCIE0 or PCIE1 - ori r16, (1<