From 92063410329e8480609d188ecff05dce3dec2b37 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 30 Jun 2025 21:29:05 +0200 Subject: [PATCH] started working on improved UART_HW module. --- avr/devices/all/includes.asm | 8 +- avr/modules/uart_hw2/0BUILD | 12 + avr/modules/uart_hw2/comonuart1.asm | 816 ++++++++++++++++++++++++++++ avr/modules/uart_hw2/defs.asm | 43 ++ 4 files changed, 873 insertions(+), 6 deletions(-) create mode 100644 avr/modules/uart_hw2/0BUILD create mode 100644 avr/modules/uart_hw2/comonuart1.asm create mode 100644 avr/modules/uart_hw2/defs.asm diff --git a/avr/devices/all/includes.asm b/avr/devices/all/includes.asm index d28721b..37d6646 100644 --- a/avr/devices/all/includes.asm +++ b/avr/devices/all/includes.asm @@ -75,12 +75,8 @@ #endif #ifdef MODULES_COMONUART1 -#ifndef MODULES_COMONUART0 -.include "modules/uart_hw/defs.asm" -.include "modules/uart_hw/lowlevel.asm" -.include "modules/uart_hw/m_lowlevel_uart.asm" -#endif -.include "modules/uart_hw/comonuart1.asm" +.include "modules/uart_hw2/defs.asm" +.include "modules/uart_hw2/comonuart1.asm" #endif diff --git a/avr/modules/uart_hw2/0BUILD b/avr/modules/uart_hw2/0BUILD new file mode 100644 index 0000000..aecc13e --- /dev/null +++ b/avr/modules/uart_hw2/0BUILD @@ -0,0 +1,12 @@ + + + + + + comonuart1.asm + defs.asm + + + + + diff --git a/avr/modules/uart_hw2/comonuart1.asm b/avr/modules/uart_hw2/comonuart1.asm new file mode 100644 index 0000000..3df179b --- /dev/null +++ b/avr/modules/uart_hw2/comonuart1.asm @@ -0,0 +1,816 @@ +; *************************************************************************** +; copyright : (C) 2025 by Martin Preuss +; email : martin@libchipcard.de +; +; *************************************************************************** +; * This file is part of the project "AqHome". * +; * Please see toplevel file COPYING of that project for license details. * +; *************************************************************************** + +#ifndef AVR_MODULES_UART_HW2_COMONUART1_H +#define AVR_MODULES_UART_HW2_COMONUART1_H + + +.dseg + +comOnUart1_iface: .byte UART_HW2_IFACE_SIZE + + + +.cseg + + + +; --------------------------------------------------------------------------- +; @routine ComOnUart1_Init @global +; +; @clobbers R16, R17, Y (X) + +ComOnUart1_Init: + ldi yl, LOW(comOnUart1_iface) + ldi yh, HIGH(comOnUart1_iface) + rcall NET_Interface_Init ; (R16, R17, X) + ldi r16, 0xff + std Y+UART_HW_IFACE_OFFS_WRITEBUFNUM, r16 + ldi r16, UART_HW2_MODE_IDLE + std Y+UART_HW2_IFACE_OFFS_MODE, r16 + clr r16 + std Y+NET_IFACE_OFFS_IFACENUM, r16 + rcall comOnUart1SetAttnInput + + ; set baudrate +.if clock == 8000000 + ldi r16, 25 ; (19.2Kb/s at 8MHz) + ldi r17, 0 +.endif + +.if clock == 1000000 + ldi r16, 2 ; (19.2Kb/s at 1MHz) + ldi r17, 0 +.endif + + sts UBRR1H, r17 + sts UBRR1L, r16 + + ; set character format + ldi r16, (1<