; ***************************************************************************
; 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.   *
; ***************************************************************************





.equ COM2_BUFFER_SIZE = 24        ; CAVE: must change code in COM2_BufferPosToX when changing this!
.equ COM2_BUFFER_NUM  = 4

.equ COM2_MAINTENANCE_ADDR = 0xc1


; flags for variable payload enqueue function
.equ COM2_PAYLOAD_FLAGS_SECONDS    = 0x01
.equ COM2_PAYLOAD_FLAGS_UID        = 0x02
.equ COM2_PAYLOAD_FLAGS_RESERVED1  = 0x04
.equ COM2_PAYLOAD_FLAGS_NUM0       = 0x08
.equ COM2_PAYLOAD_FLAGS_NUM1       = 0x10
.equ COM2_PAYLOAD_FLAGS_NUM2       = 0x20
.equ COM2_PAYLOAD_FLAGS_NUM3       = 0x40
.equ COM2_PAYLOAD_FLAGS_NUM4       = 0x80
.equ COM2_PAYLOAD_FLAGS_SHIFT_NUM  = 3



.equ COM2_MSG_OFFS_DESTADDR        = 0
.equ COM2_MSG_OFFS_MSGLEN          = 1
.equ COM2_MSG_OFFS_MSGDATA         = 2
.equ COM2_MSG_OFFS_CMD             = 2 ; first at COM2_MSG_OFFS_MSGDATA
.equ COM2_MSG_OFFS_SRCADDR         = 3
.equ COM2_MSG_OFFS_PAYLOAD         = 4 ; payload for the cmd follows here


.equ COM2_ERROR_NOTFORME           = 1 ; receiption errors
.equ COM2_ERROR_IOERROR            = 2
.equ COM2_ERROR_DATAERROR          = 3
.equ COM2_ERROR_BUSY               = 4 ; send errors
.equ COM2_ERROR_COLLISION          = 5


.equ COM2_CRC8_POLYNOMIAL          = 0x97 ; HD=4 up to 119 bytes, e.g. detects all 1 to 3 bit errors
