avr: more work on hardware based uart module.

This commit is contained in:
Martin Preuss
2025-01-27 00:20:45 +01:00
parent a96bd7fc07
commit 52bbfcfb15
11 changed files with 650 additions and 71 deletions

View File

@@ -70,6 +70,12 @@
;#define MODULES_MOTION
.equ UART_HW_FIXEDBUFFERS_NUM = 32
.equ UART_HW_FIXEDBUFFERS_SIZE = 6
.equ UART_HW_MSGNUMINBUF_SIZE = 6
.equ UART_HW_MSGNUMOUTBUF_SIZE = 6
; ***************************************************************************
; code segment
@@ -134,36 +140,13 @@ firmwareStart:
ldi r16, Low(RAMEND)
out SPL, r16 ; init LSB stack pointer
#if 0
; start by setting all ports as inputs and enable internal pull-up resistors
ldi r16, 0xff
clr r17
.ifdef PORTA
out DDRA, r17 ; all input
sts PUEA, r16 ; enable pull-up on all
.endif
.ifdef PORTB
out DDRB, r17 ; all input
sts PUEB, r16 ; enable pull-up on all
.endif
.ifdef PORTC
out DDRC, r17 ; all input
sts PUEC, r16 ; enable pull-up on all
.endif
#endif
rcall systemSetSpeed
rcall initHardware
; rcall watchdogOff ; turn off watchdog timer (sometimes it stays on after reboot)
rcall Utils_Init
rcall BaseTimer_Init
rcall LedSimple_Init
rcall initModules
rcall Utils_SetupUid
sbi LED_SIMPLE_DDR, LED_SIMPLE_PINNUM ; out
sbi LED_SIMPLE_PORT, LED_SIMPLE_PINNUM ; off
@@ -217,6 +200,40 @@ onSystemTimerTick:
initHardware:
; set all ports as inputs and enable internal pull-up resistors
ldi r16, 0xff
clr r17
.ifdef PORTA
out DDRA, r17 ; all input
sts PUEA, r16 ; enable pull-up on all
.endif
.ifdef PORTB
out DDRB, r17 ; all input
sts PUEB, r16 ; enable pull-up on all
.endif
.ifdef PORTC
out DDRC, r17 ; all input
sts PUEC, r16 ; enable pull-up on all
.endif
ret
; @end
initModules:
rcall Utils_Init
rcall BaseTimer_Init
rcall LedSimple_Init
rcall UART_HW_Init
ret
; @end
; ***************************************************************************
@@ -226,10 +243,19 @@ onSystemTimerTick:
.include "common/utils_wait_fixed.asm"
.include "common/utils_copy_from_flash.asm"
.include "common/utils_copy_sdram.asm"
.include "common/m_ringbuffer_y.asm"
.include "common/ringbuffer_y.asm"
.include "common/m_fixedbuffers.asm"
.include "common/crc8.asm"
.include "modules/flash/wait.asm"
.include "modules/basetimer/main.asm"
.include "modules/led_simple/main.asm"
.include "modules/uart_hw/defs.asm"
.include "modules/uart_hw/buffers.asm"
.include "modules/uart_hw/lowlevel.asm"
.include "modules/uart_hw/lowlevel_uart1.asm"
.include "modules/uart_hw/msglevel_recv.asm"
.include "modules/uart_hw/msglevel_send.asm"