; ***************************************************************************
; copyright   : (C) 2026 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.   *
; ***************************************************************************


; ***************************************************************************
;
;                                 AtTiny861
;                                 --------
;        (PCINT8)            PB0  1     20  PA0   COM_DATA (PCINT0)
;        (PCINT9)    PWM1    PB1  2     19  PA1            (PCINT1)
;        (PCINT10) Tacho1    PB2  3     18  PA2   COM_CLK  (PCINT2, INT1)
;        (PCINT11)   PWM2    PB3  4     17  PA3   LED      (PCINT3)
;                            VCC  5     16  AGND
;                            GND  6     15  AVCC
;        (PCINT12) Tacho2    PB4  7     14  PA4            (PCINT4)
;        (PCINT13)   PWM3    PB5  8     13  PA5            (PCINT5)
;        (PCINT14) Tacho3    PB6  9     12  PA6            (PCINT6)
;        (PCINT15)  Reset    PB7 10     11  PA7            (PCINT7)

;                                 --------
;
; ***************************************************************************



.equ BOOTLOADER_ADDR = 0xd00

.equ FIRMWARE_VARIANT_BOOT        = 0
.equ FIRMWARE_VARIANT_TEMP_WINDOW = 1

.equ DEVICEINFO_ID       = 'N'
.equ DEVICEINFO_VERSION  = 32
.equ DEVICEINFO_REVISION = 0



; ---------------------------------------------------------------------------
; LED module

; green LED
.equ LED1_DEFAULT_ONTIME  = 1     ; shorter
.equ LED1_DEFAULT_OFFTIME = 49    ; longer
.equ LED1_DEFAULT_REPEATS = 0     ; continous
.equ LED1_DDR     = DDRA
.equ LED1_PORT    = PORTA
.equ LED1_PORTIN  = PINA
.equ LED1_PINNUM  = PORTA3

; ---------------------------------------------------------------------------
; COM module

.equ COM_BIT_LENGTH      = 52000 ; 104000ns=9600, 52000ns=19200, 26000ns=38400
.equ COM_HALFBIT_LENGTH  = 26000 ; see https://de.wikipedia.org/wiki/Universal_Asynchronous_Receiver_Transmitter

.equ COM_DATA_DDR       = DDRA
.equ COM_DATA_INPUT     = PINA
.equ COM_DATA_OUTPUT    = PORTA
.equ COM_DATA_PIN       = PORTA0

.equ COM_CLK_DDR        = DDRA
.equ COM_CLK_INPUT      = PINA
.equ COM_CLK_OUTPUT     = PORTA
.equ COM_CLK_PIN        = PORTA2

.equ COM_IRQ_ADDR_CLK   = PCMSK0
.equ COM_IRQ_BIT_CLK    = PCINT2        ; bit 2 in PCMSK0
.equ COM_IRQ_GIFR_CLK   = PCIF
.equ COM_IRQ_GIMSK_CLK  = PCIE0



; MultiFan module (definitions for new IO module)
.equ MULTIFAN_FANS         = 3
.equ MULTIFAN_PWM_DDR      = DDRB
.equ MULTIFAN_PWM_OUTPUT   = PORTB

.equ MULTIFAN_TACHO_DDR    = DDRB
.equ MULTIFAN_TACHO_INPUT  = PINB

.equ MULTIFAN_PWM1_PIN     = PORTB1
.equ MULTIFAN_TACHO1_PIN   = PORTB2

.equ MULTIFAN_PWM2_PIN     = PORTB3
.equ MULTIFAN_TACHO2_PIN   = PORTB4

.equ MULTIFAN_PWM3_PIN     = PORTB5
.equ MULTIFAN_TACHO3_PIN   = PORTB6



; EEPROM TLV ids

.equ APP_FANCONTROL_EEID  = 0x30


