Files
aqhomecontrol/avr/devices/n14/main/main.asm
2025-08-18 18:47:13 +02:00

211 lines
4.8 KiB
NASM

; ***************************************************************************
; copyright : (C) 2024 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. *
; ***************************************************************************
; ***************************************************************************
; Source file for LED controller node on AtTiny 85
;
; This is for the full system (i.e. not the boot loader).
; ***************************************************************************
.equ clock=8000000 ; Define the clock frequency
.nolist
.include "include/tn85def.inc" ; Define device ATtiny85
.list
.include "version.asm"
.include "../defs.asm"
;.include "./data.asm"
.include "devices/all/defs.asm"
.include "common/calls.asm"
.include "common/utils_io.asm"
.include "common/utils_wait.asm"
; ***************************************************************************
; defines
; ---------------------------------------------------------------------------
; generic
.equ NET_BUFFERS_NUM = 6
.equ NET_MSGNUMINBUF_SIZE = 8 ; max buffer nums in ringbuffer (global incoming)
.equ NET_IFACE_OUTMSGBUF_SIZE = 8 ; max buffer nums in ringbuffer (per interface outbound)
; ---------------------------------------------------------------------------
; firmware settings including list of modules used
#define MODULES_CLOCK
#define MODULES_LED_SIMPLE
#define MODULES_NETWORK
#define MODULES_COM2W
#define MODULES_OWI_MASTER
#define MODULES_DS18B20
#define MODULES_SK6812
;#define MODULES_MOTION_LIGHT
#define APPS_NETWORK
#define APPS_REPORTSENSORS
#define APPS_STATS
#define APPS_MA_LIGHT
; ---------------------------------------------------------------------------
; defines for modules
;.equ VALUE_ID_SI7021_TEMP = 0x01
;.equ VALUE_ID_SI7021_HUM = 0x02
;.equ VALUE_ID_ADC = 0x03
;.equ VALUE_ID_REED1 = 0x04
;.equ VALUE_ID_REED2 = 0x05
.equ VALUE_ID_DS18B20_TEMP = 0x06
;.equ VALUE_ID_REED_CONF = 0x81
.equ VALUE_ID_LED_NUMLEDS = 0x82
.equ VALUE_ID_LED_RGBW_VALUE = 0x83
.equ VALUE_ID_MAL_RGBW_VALUE = 0x84
.equ VALUE_ID_MAL_ONTIME = 0x85
.equ VALUE_ID_MAL_SOURCE1 = 0x86
.equ VALUE_ID_MAL_SOURCE2 = 0x87
.equ VALUE_ID_LEDSIMPLE_TIMING = 0x88
; ***************************************************************************
; code segment
.cseg
.org 000000
; ---------------------------------------------------------------------------
; Reset and interrupt vectors
rjmp BOOTLOADER_ADDR ; Reset vector ; use this for flashed system
reti ; EXT_INT0
rjmp com2wPcintIsr ; PCI0
reti ; OC1A
reti ; OVF1
reti ; OVF0
reti ; ERDY
reti ; ACI
reti ; ADCC
reti ; OC1B
rjmp baseTimerIrqOC0A ; OC0A
reti ; OC0B
reti ; WATCHDOG
reti ; USI_STR
reti ; USI_OVF
devInfoBlock: ; 12 bytes
devInfoManufacturer: .db 'A', 'Q', 'U', 'A'
devInfoId: .db DEVICEINFO_ID, 0
devInfoVersion: .db DEVICEINFO_VERSION, DEVICEINFO_REVISION ; version, revision
firmwareVersion: .db FIRMWARE_VARIANT_LEDSTRIPS, FIRMWARE_VERSION_MAJOR
.db FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCHLEVEL
; ---------------------------------------------------------------------------
; @routine firmwareStart @global
firmwareStart:
rjmp main
; @end
; ---------------------------------------------------------------------------
; @routine onSystemStart
onSystemStart:
ret
; @end
; ---------------------------------------------------------------------------
; @routine onMessageReceived
;
; Called on every message received
onMessageReceived:
clc
ret
; @end
; ---------------------------------------------------------------------------
; @routine onEvery100ms
;
; Called every 100ms. Add your routine calls here. No arguments, no results.
onEvery100ms:
onEveryMinute:
onEveryHour:
onEveryDay:
ret
; @end
onEverySecond:
ret
; debug
ldi r19, 0x00 ; G
ldi r18, 0xff ; R
ldi r20, 0x55 ; B
ldi r21, 0xaa ; W
rcall SK6812_SetAllColor ; r23 (r16, r17)
ret
; ---------------------------------------------------------------------------
; @routine onEveryLoop
;
; Called on every loop (i.e. after awakening from sleep).
;
onEveryLoop:
ret
; @end
; ***************************************************************************
; includes
.include "devices/all/hw_tn85.asm"
.include "devices/all/includes.asm"
.include "common/debug.asm"
; ---------------------------------------------------------------------------
; defines for network interface
.equ netInterfaceData = com2w_iface