diff --git a/avr/devices/all/includes.asm b/avr/devices/all/includes.asm index 41039f9..83a040b 100644 --- a/avr/devices/all/includes.asm +++ b/avr/devices/all/includes.asm @@ -104,6 +104,14 @@ +#ifdef MODULES_COM2W0 +.include "modules/com2w/defs.asm" +.include "modules/com2w/common.asm" +.include "modules/com2w/com2w0.asm" +#endif + + + #ifdef MODULES_COM2W1 .include "modules/com2w/defs.asm" .include "modules/com2w/common.asm" diff --git a/avr/modules/com2w/com2w.asm b/avr/modules/com2w/com2w.asm index 00c38b4..d888f15 100644 --- a/avr/modules/com2w/com2w.asm +++ b/avr/modules/com2w/com2w.asm @@ -98,10 +98,6 @@ COM2W_Every100ms: ; @clobbers R16, R17, R18, R19, R20, R22, R24, R25, X com2wReceiveNextPkg: -; ldi r20, 3 ; make sure clock remains low for at least 15us -; rcall com2wWaitForClockHighMulti5Us ; (R20, R22) -; brcs com2wReceiveNextPkg_end ; clock got high quite soon, maybe just flaky line - rcall NET_Buffer_Alloc ; R16=buffer num (R16, R17, X) brcs com2wReceiveNextPkg_gotBuffer ldi r16, NET_IFACE_OFFS_ERR_NOBUF_LOW @@ -119,13 +115,6 @@ com2wReceiveNextPkg_gotBuffer: rcall NET_AddIncomingMsgNum ; (R17, R18, X) brcs com2wReceiveNextPkg_end -; debug -push r18 - push r19 - rcall LedSimple_SetFastTiming - pop r19 -pop r18 - push r16 ldi r16, NET_IFACE_OFFS_ERR_MISSED_LOW rcall NET_Interface_IncCounter16 ; (R24, R25) diff --git a/avr/modules/com2w/com2w0.asm b/avr/modules/com2w/com2w0.asm new file mode 100644 index 0000000..8d0589e --- /dev/null +++ b/avr/modules/com2w/com2w0.asm @@ -0,0 +1,643 @@ +; *************************************************************************** +; 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_COM2W_COM2W0_H +#define AVR_MODULES_COM2W_COM2W0_H + + +.dseg + +com2w0_iface: .byte COM2W_IFACE_SIZE + + + +.cseg + + + + +; --------------------------------------------------------------------------- +; @routine COM2W0_Init +; +; @clobbers + +COM2W0_Init: + ldi yl, LOW(com2w0_iface) + ldi yh, HIGH(com2w0_iface) + rcall NET_Interface_Init ; (R16, R17, X) + ldi r16, COM2W_MODE_IDLE + rcall com2wSetMode ; (R17) + + ; setup CLK line (as input, disable internal pull-up resistor) + cbi COM_CLK0_DDR, COM_CLK0_PIN ; set CLK as input +.ifdef COM_CLK0_PUE + inr r16, COM_CLK0_PUE + cbr r16, (1<