; *************************************************************************** ; copyright : (C) 2023 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. * ; *************************************************************************** ; *************************************************************************** ; data .dseg com2DataBegin: com2Address: .byte 1 com2Interrupts: .byte 2 com2RecvStatsBegin: ; 12 bytes com2StatsPacketsIn: .byte 2 com2StatsContentError: .byte 2 com2StatsIoError: .byte 2 com2StatsNoBufferError: .byte 2 com2StatsHandled: .byte 2 com2StatsMissed: .byte 2 ; currently not used com2RecvStatsEnd: com2SendStatsBegin: ; 6 bytes com2StatsPacketsOut: .byte 2 com2StatsCollisions: .byte 2 com2StatsBusyError: .byte 2 com2SendStatsEnd: com2StatsIgnored: .byte 2 com2RecvBuffersUsed: .byte 1 com2MaxBuffersUsed: .byte 1 com2RecvBuffersWritePos: .byte 1 com2RecvBuffersReadPos: .byte 1 com2RecvBuffers: .byte COM2_BUFFER_SIZE*COM2_BUFFER_NUM com2SendBuffer: .byte COM2_BUFFER_SIZE com2DataEnd: ; *************************************************************************** ; code .cseg COM2_BEGIN: ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ; Module interface ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ; --------------------------------------------------------------------------- ; Com2_Init ; ; IN: ; OUT: ; - CFLAG: set if okay, clear on error ; USED: R16, R17, X, Y Com2_Init: ; preset SRAM data area ldi xh, HIGH(com2DataBegin) ldi xl, LOW(com2DataBegin) clr r16 ldi r17, (com2DataEnd-com2DataBegin) rcall Utils_FillSram ; set address to 0 (will be updated later) 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<