; ***************************************************************************
; 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_DEFS_H
#define AVR_MODULES_COM2W_DEFS_H


.equ COM2W_WAITTIME1 = 25000
.equ COM2W_WAITTIME2 = 15000

.equ COM2W_SKIPPING_MAXREADCOUNTER = 1
.equ COM2W_SKIPPING_MAXMODECOUNTER = 20  ; stay max 2s in skipping mode

.equ COM2W_READING_MAXREADCOUNTER  = 1
.equ COM2W_READING_MAXMODECOUNTER  = 20  ; stay max 2s in reading mode


;
; .equ COM2W_DATA0_DDR     = DDRA
; .equ COM2W_DATA0_INPUT   = PINA
; .equ COM2W_DATA0_OUTPUT  = PORTA
; .equ COM2W_DATA0_PUE     = PUEA
; .equ COM2W_DATA0_PIN     = PORTA2
;
; .equ COM2W_CLK0_DDR      = DDRA
; .equ COM2W_CLK0_INPUT    = PINA
; .equ COM2W_CLK0_OUTPUT   = PORTA
; .equ COM2W_CLK0_PUE      = PUEA
; .equ COM2W_CLK0_PIN      = PORTA0

; .equ COM2W_IRQ_ADDR_CLK0  = PCMSK0
; .equ COM2W_IRQ_BIT_CLK0   = PCINT0        ; bit 0 in PCMSK0
; .equ COM2W_IRQ_GIFR_CLK0  = PCIF0
; .equ COM2W_IRQ_GIMSK_CLK0 = PCIE0




.equ COM2W_BUFFER_SIZE = NET_BUFFERS_SIZE-1

.equ COM2W_IO_RINGBUFFER_SIZE = 128
.equ COM2W_IO_FLAGS_BIT_OVR   = 7

.equ COM2W_MODE_IDLE            = 0
.equ COM2W_MODE_READING         = 1
.equ COM2W_MODE_SKIPPING        = 2
.equ COM2W_MODE_WRITING         = 3
.equ COM2W_MODE_NUM             = 4


.equ COM2W_IFACE_OFFS_BEGIN        = NET_IFACE_SIZE
.equ COM2W_IFACE_OFFS_PINMASK_CLK  = COM2W_IFACE_OFFS_BEGIN
.equ COM2W_IFACE_OFFS_PINMASK_DATA = COM2W_IFACE_OFFS_BEGIN+1
.equ COM2W_IFACE_OFFS_PINMASK_IRQ  = COM2W_IFACE_OFFS_BEGIN+2
.equ COM2W_IFACE_OFFS_CURRBYTE     = COM2W_IFACE_OFFS_BEGIN+3
.equ COM2W_IFACE_OFFS_BITCOUNTER   = COM2W_IFACE_OFFS_BEGIN+4
.equ COM2W_IFACE_OFFS_MODE         = COM2W_IFACE_OFFS_BEGIN+5
.equ COM2W_IFACE_OFFS_MODECOUNTER  = COM2W_IFACE_OFFS_BEGIN+6
.equ COM2W_IFACE_OFFS_BUFPOS_LOW   = COM2W_IFACE_OFFS_BEGIN+7
.equ COM2W_IFACE_OFFS_BUFPOS_HIGH  = COM2W_IFACE_OFFS_BEGIN+8
.equ COM2W_IFACE_OFFS_BUFUSED      = COM2W_IFACE_OFFS_BEGIN+9
.equ COM2W_IFACE_OFFS_BUFLEFT      = COM2W_IFACE_OFFS_BEGIN+10
.equ COM2W_IFACE_OFFS_BUFFER       = COM2W_IFACE_OFFS_BEGIN+11

.equ COM2W_IFACE_SIZE              = COM2W_IFACE_OFFS_BUFFER+COM2W_BUFFER_SIZE




#endif ; AVR_MODULES_COM2W_DEFS_H


