From b498a445b2ba2d334de20da47292989822c9d820 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 16 Jun 2025 23:31:28 +0200 Subject: [PATCH] added missing files, n26, increased firmware version. --- 0BUILD | 3 +- avr/devices/c01/main/main.asm | 1 + avr/devices/n19/README | 13 ++ avr/devices/n21/0BUILD | 6 +- .../nodes => avr/devices/n21}/aqua_n21.xml | 5 +- avr/devices/n22/README | 2 + avr/devices/n23/README | 1 + avr/devices/n23/aqua_n23.xml | 4 - avr/devices/n24/README | 1 + avr/devices/n24/aqua_n24.xml | 5 +- avr/devices/n24/defs.asm | 2 +- avr/devices/n25/aqua_n25.xml | 4 - avr/devices/n26/.gitignore | 2 + avr/devices/n26/0BUILD | 22 ++ avr/devices/n26/README | 11 + avr/devices/n26/aqua_n26.xml | 22 ++ avr/devices/n26/boot/0BUILD | 32 +++ avr/devices/n26/boot/boot.asm | 157 +++++++++++++ avr/devices/n26/defs.asm | 98 ++++++++ avr/devices/n26/main/0BUILD | 34 +++ avr/devices/n26/main/data.asm | 14 ++ avr/devices/n26/main/main.asm | 210 ++++++++++++++++++ avr/version.asm | 2 +- devices/nodes/0BUILD | 2 - devices/nodes/aqua_n14.xml | 19 -- flashnode.sh | 7 + 26 files changed, 638 insertions(+), 41 deletions(-) create mode 100644 avr/devices/n19/README rename {devices/nodes => avr/devices/n21}/aqua_n21.xml (83%) create mode 100644 avr/devices/n26/.gitignore create mode 100644 avr/devices/n26/0BUILD create mode 100644 avr/devices/n26/README create mode 100644 avr/devices/n26/aqua_n26.xml create mode 100644 avr/devices/n26/boot/0BUILD create mode 100644 avr/devices/n26/boot/boot.asm create mode 100644 avr/devices/n26/defs.asm create mode 100644 avr/devices/n26/main/0BUILD create mode 100644 avr/devices/n26/main/data.asm create mode 100644 avr/devices/n26/main/main.asm delete mode 100644 devices/nodes/aqua_n14.xml diff --git a/0BUILD b/0BUILD index 2e817b5..fe14b3a 100644 --- a/0BUILD +++ b/0BUILD @@ -2,7 +2,7 @@ - + $(project_name) $(project_vmajor).$(project_vminor).$(project_vpatchlevel) @@ -128,6 +128,7 @@ + signal.h sys/stat.h diff --git a/avr/devices/c01/main/main.asm b/avr/devices/c01/main/main.asm index e902a03..06f527f 100644 --- a/avr/devices/c01/main/main.asm +++ b/avr/devices/c01/main/main.asm @@ -21,6 +21,7 @@ .include "./data.asm" .include "devices/all/defs.asm" +.include "common/calls.asm" .include "common/utils_wait.asm" .include "common/utils_io.asm" diff --git a/avr/devices/n19/README b/avr/devices/n19/README new file mode 100644 index 0000000..4b8fb4d --- /dev/null +++ b/avr/devices/n19/README @@ -0,0 +1,13 @@ + +N19 +=== + +- Role: Air quality and climate sensors +- MCU: AtTiny84 +- Connection: RJ45 +- Periphery: + - PIR sensor (AMN31112) + - TWI interface + - SI7021 temperature and humidity sensor + - CCS811 air quality sensor + diff --git a/avr/devices/n21/0BUILD b/avr/devices/n21/0BUILD index be449f6..8416b5b 100644 --- a/avr/devices/n21/0BUILD +++ b/avr/devices/n21/0BUILD @@ -11,7 +11,11 @@ defs.asm README - + + + aqua_n21.xml + + diff --git a/devices/nodes/aqua_n21.xml b/avr/devices/n21/aqua_n21.xml similarity index 83% rename from devices/nodes/aqua_n21.xml rename to avr/devices/n21/aqua_n21.xml index 13c1c52..5a59b8c 100644 --- a/devices/nodes/aqua_n21.xml +++ b/avr/devices/n21/aqua_n21.xml @@ -7,6 +7,7 @@ + @@ -18,10 +19,6 @@ - - - - diff --git a/avr/devices/n22/README b/avr/devices/n22/README index 131998f..95d68e6 100644 --- a/avr/devices/n22/README +++ b/avr/devices/n22/README @@ -5,6 +5,8 @@ N22 - Role: LED strip controller - MCU: AtTiny85 - Connection: RJ45 +- Predecessor: N16 +- UART: uart_bitbang2 - Periphery: - LED strip connection (SK6812) - OWI interface diff --git a/avr/devices/n23/README b/avr/devices/n23/README index b1a7c94..be29416 100644 --- a/avr/devices/n23/README +++ b/avr/devices/n23/README @@ -5,6 +5,7 @@ N23 - Role: Air quality and climate sensors - MCU: AtTiny84 - Connection: RJ45 +- Predecessor: N19 - Periphery: - PIR sensor (AMN31112) - TWI interface diff --git a/avr/devices/n23/aqua_n23.xml b/avr/devices/n23/aqua_n23.xml index 0f049f9..a4de1bd 100644 --- a/avr/devices/n23/aqua_n23.xml +++ b/avr/devices/n23/aqua_n23.xml @@ -20,10 +20,6 @@ - - - - diff --git a/avr/devices/n24/README b/avr/devices/n24/README index 1fc1534..10328b6 100644 --- a/avr/devices/n24/README +++ b/avr/devices/n24/README @@ -5,6 +5,7 @@ N24 - Role: Air quality and climate sensors - MCU: AtTiny84 - Connection: RJ45 +- Predecessor: N23, N19 - Periphery: - PIR sensor (AMN31112) - TWI interface diff --git a/avr/devices/n24/aqua_n24.xml b/avr/devices/n24/aqua_n24.xml index 7552f11..207c53e 100644 --- a/avr/devices/n24/aqua_n24.xml +++ b/avr/devices/n24/aqua_n24.xml @@ -11,6 +11,7 @@ + @@ -20,10 +21,6 @@ - - - - diff --git a/avr/devices/n24/defs.asm b/avr/devices/n24/defs.asm index 6c82232..34ceb17 100644 --- a/avr/devices/n24/defs.asm +++ b/avr/devices/n24/defs.asm @@ -13,7 +13,7 @@ ; AtTiny84 ; -------- ; VCC 1 14 GND -; AUX-PB0 PB0 2 13 PA0 AUX-PA0 +; AUX-PB0 PB0 2 13 PA0 LUM ; PIR PB1 3 12 PA1 COM-DATA ; /RESET PB3 4 11 PA2 AUX-PA2 ; PB2 5 10 PA3 LED diff --git a/avr/devices/n25/aqua_n25.xml b/avr/devices/n25/aqua_n25.xml index 27a2a63..5eea16c 100644 --- a/avr/devices/n25/aqua_n25.xml +++ b/avr/devices/n25/aqua_n25.xml @@ -23,10 +23,6 @@ - - - - diff --git a/avr/devices/n26/.gitignore b/avr/devices/n26/.gitignore new file mode 100644 index 0000000..8e0618c --- /dev/null +++ b/avr/devices/n26/.gitignore @@ -0,0 +1,2 @@ +*.eep.hex +*.obj diff --git a/avr/devices/n26/0BUILD b/avr/devices/n26/0BUILD new file mode 100644 index 0000000..8736df4 --- /dev/null +++ b/avr/devices/n26/0BUILD @@ -0,0 +1,22 @@ + + + + + + boot + main + + + + aqua_n26.xml + + + + defs.asm + README + + + + + + diff --git a/avr/devices/n26/README b/avr/devices/n26/README new file mode 100644 index 0000000..b39e95d --- /dev/null +++ b/avr/devices/n26/README @@ -0,0 +1,11 @@ + +N26 +=== + +- Role: Air quality sensors +- MCU: AtTiny84 +- Connection: RJ45 +- Periphery: + - TWI interface + - SGP-30/40 air quality sensor + diff --git a/avr/devices/n26/aqua_n26.xml b/avr/devices/n26/aqua_n26.xml new file mode 100644 index 0000000..b7a38e2 --- /dev/null +++ b/avr/devices/n26/aqua_n26.xml @@ -0,0 +1,22 @@ + + + AQUA + N + 26 + + + + + + + + + + + + + + + + + diff --git a/avr/devices/n26/boot/0BUILD b/avr/devices/n26/boot/0BUILD new file mode 100644 index 0000000..db6350e --- /dev/null +++ b/avr/devices/n26/boot/0BUILD @@ -0,0 +1,32 @@ + + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + boot.asm + + + + + + + + + + + + + + + + diff --git a/avr/devices/n26/boot/boot.asm b/avr/devices/n26/boot/boot.asm new file mode 100644 index 0000000..767f207 --- /dev/null +++ b/avr/devices/n26/boot/boot.asm @@ -0,0 +1,157 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + +; *************************************************************************** +; Source file for base system node on AtTiny 84 +; +; This is for the maintenance system (i.e. the flash loader). +; +; All definitions and changes should go into this file. +; *************************************************************************** + +.equ clock=1000000 ; Define the clock frequency + +.nolist +.include "include/tn84def.inc" ; Define device ATtiny84 +.list + +.include "version.asm" +.include "../defs.asm" + +.include "common/calls.asm" +.include "devices/all/defs.asm" + + +#define COM_ACCEPT_ALL_DEST + + + +; *************************************************************************** +; defines + +; --------------------------------------------------------------------------- +; generic + +.include "common/utils_wait.asm" +.include "modules/com2/defs.asm" +.include "modules/comproto/defs.asm" + + + +; --------------------------------------------------------------------------- +; firmware settings + + + +; --------------------------------------------------------------------------- +; LED + +.equ LED_DDR = DDRA +.equ LED_PORT = PORTA +.equ LED_PIN = PINA +.equ LED_PINNUM = PORTA3 + + +; *************************************************************************** +; code segment + +.cseg +.org 0x0000 + + + +; --------------------------------------------------------------------------- +; Reset and interrupt vectors +; rjmp start ; Reset vector + rjmp main ; Reset vector + reti ; EXT_INT0 + reti ; PCI0 + reti ; PCI1 + reti ; WATCHDOG + reti ; ICP1 + reti ; OC1A + reti ; OC1B + reti ; OVF1 + reti ; OC0A + reti ; OC0B + reti ; OVF0 + reti ; ACI + reti ; ADCC + reti ; ERDY + 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_BOOT, FIRMWARE_VERSION_MAJOR + .db FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCHLEVEL + +firmwareStart: rjmp main ; will be overwritten when flashing + + + +; *************************************************************************** +; main code + + +.org BOOTLOADER_ADDR + + +main: + rjmp bootLoader ; this routine is in modules/bootloader/main.asm + + + +; *************************************************************************** +; includes + +.include "common/utils_wait_fixed.asm" +.include "common/utils_copy_from_flash.asm" +.include "common/utils_copy_sdram.asm" + +.include "modules/flash/defs.asm" +.include "modules/flash/eeprom.asm" +.include "modules/flash/io.asm" +.include "modules/flash/io_attn.asm" +.include "modules/flash/io_bitbang.asm" +.include "modules/flash/flash1p.asm" +.include "modules/flash/flashxp.asm" +.include "modules/flash/flashprocess.asm" +.include "modules/flash/wait.asm" +.include "modules/bootloader/main.asm" +.include "modules/network/msg/defs.asm" +.include "modules/network/msg/crc.asm" + +;.include "common/debug.asm" + + + +systemSetSpeed: +.if clock == 8000000 + ldi r16, (1< + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + main.asm + + + + + + + + + + + + data.asm + + + + + + diff --git a/avr/devices/n26/main/data.asm b/avr/devices/n26/main/data.asm new file mode 100644 index 0000000..31ccc2f --- /dev/null +++ b/avr/devices/n26/main/data.asm @@ -0,0 +1,14 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + + +.dseg + + diff --git a/avr/devices/n26/main/main.asm b/avr/devices/n26/main/main.asm new file mode 100644 index 0000000..9fd683b --- /dev/null +++ b/avr/devices/n26/main/main.asm @@ -0,0 +1,210 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + + + +; *************************************************************************** +; Source file for temperature sensor node on AtTiny 84 +; +; This is for the full system (i.e. not the boot loader). +; +; All definitions and changes should go into this file. +; +; +; *************************************************************************** + + +.equ clock=1000000 ; Define the clock frequency +;.equ clock=8000000 ; Define the clock frequency + + + +.nolist +.include "include/tn84def.inc" ; Define device ATtiny84 +.list + +.include "../defs.asm" +.include "./data.asm" + +.include "version.asm" +.include "devices/all/defs.asm" +.include "common/calls.asm" +.include "common/utils_wait.asm" + + + +; *************************************************************************** +; defines + +; --------------------------------------------------------------------------- +; generic + +.equ NET_BUFFERS_NUM = 6 +.equ NET_BUFFERS_SIZE = 32 + +.equ PROGRAM_SENSOR_INTERVAL_SECS = 60 +.equ PROGRAM_STATS_INTERVAL_MINS = 10 + + + +; --------------------------------------------------------------------------- +; firmware settings including list of modules used + +; #define MODULES_TIMER +#define MODULES_CLOCK +#define MODULES_LED_SIMPLE +#define MODULES_NETWORK +#define MODULES_UART_BITBANG +#define MODULES_TWI_MASTER +;#define MODULES_LCD +;#define LCD_MINIMAL_FONT +;#define MODULES_SI7021 +#define MODULES_SGP30 +;#define MODULES_SGP40 +;#define MODULES_STATS +;#define MODULES_OWI_MASTER +;#define MODULES_DS18B20 +;#define MODULES_MOTION +;#define MODULES_CCS811 + +#define APPS_NETWORK +;#define APPS_MOTION +#define APPS_REPORTSENSORS +#define APPS_STATS + + + +; --------------------------------------------------------------------------- +; defines for values + +.equ VALUE_ID_SGP30_TVOC = 0x09 +.equ VALUE_ID_SGP30_CO2 = 0x0a + +.equ VALUE_ID_DEBUG = 0x7f + +.equ VALUE_ID_LEDSIMPLE_TIMING = 0x88 + + + + + +; *************************************************************************** +; code segment + +.cseg +.org 000000 + + + +; --------------------------------------------------------------------------- +; Reset and interrupt vectors (will be removed as soon as we can flash data over COM) + +; rjmp main ; Reset vector + rjmp BOOTLOADER_ADDR ; Reset vector ; use this for flashed system + reti ; EXT_INT0 + rjmp UART_BitBang_PcintIsr ; PCI0 + reti ; PCI1 + reti ; WATCHDOG + reti ; ICP1 + reti ; OC1A + reti ; OC1B + reti ; OVF1 + rjmp baseTimerIrqOC0A ; OC0A + reti ; OC0B + reti ; OVF0 + reti ; ACI + reti ; ADCC + reti ; ERDY + 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_TEMP_WINDOW, 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: +onEverySecond: +onEveryMinute: +onEveryHour: +onEveryDay: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine onEveryLoop +; +; Called on every loop (i.e. after awakening from sleep). +; +onEveryLoop: + ret +; @end + + + + + +; *************************************************************************** +; includes + +.include "devices/all/hw_tn84.asm" +.include "devices/all/includes.asm" + + + +; --------------------------------------------------------------------------- +; defines for network interface + +.equ netInterfaceData = uart_bitbang_iface + + + diff --git a/avr/version.asm b/avr/version.asm index e1a50ba..7a4e7ac 100644 --- a/avr/version.asm +++ b/avr/version.asm @@ -11,5 +11,5 @@ .equ FIRMWARE_VERSION_MAJOR = 1 .equ FIRMWARE_VERSION_MINOR = 0 -.equ FIRMWARE_VERSION_PATCHLEVEL = 3 +.equ FIRMWARE_VERSION_PATCHLEVEL = 4 diff --git a/devices/nodes/0BUILD b/devices/nodes/0BUILD index 8ac8966..4c7b1e3 100644 --- a/devices/nodes/0BUILD +++ b/devices/nodes/0BUILD @@ -5,14 +5,12 @@ aqua_n06.xml aqua_n11.xml aqua_n12.xml - aqua_n14.xml aqua_n15.xml aqua_n16.xml aqua_n17.xml aqua_n18.xml aqua_n19.xml aqua_n20.xml - aqua_n21.xml aqua_n22.xml aqua_t03.xml diff --git a/devices/nodes/aqua_n14.xml b/devices/nodes/aqua_n14.xml deleted file mode 100644 index 827e291..0000000 --- a/devices/nodes/aqua_n14.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - AQUA - N - 14 - - - - - - - - - - - - - - diff --git a/flashnode.sh b/flashnode.sh index e881362..acb6aef 100755 --- a/flashnode.sh +++ b/flashnode.sh @@ -23,6 +23,13 @@ case $NODE in EFUSE_ARG="-U efuse:w:0xFF:m" FILE_ARG="-U flash:w:./0-build/avr/devices/c02/boot/c02_boot.hex" ;; + n14) + DEVICE_ARG="-p t85" + HFUSE_ARG="-U hfuse:w:0xD7:m" + LFUSE_ARG="" + EFUSE_ARG="-U efuse:w:0xFE:m" + FILE_ARG="-U flash:w:./0-build/avr/devices/n14/boot/n14_boot.hex" + ;; n16) DEVICE_ARG="-p t84" HFUSE_ARG="-U hfuse:w:0xD7:m"