From 69420d9c7d1c982a23e199dc3c99fc4334fe8c3f Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 1 Mar 2026 01:09:04 +0100 Subject: [PATCH] added device n30. --- avr/devices/0BUILD | 1 + avr/devices/n30/.gitignore | 3 + avr/devices/n30/0BUILD | 18 +++ avr/devices/n30/README | 18 +++ avr/devices/n30/boot/0BUILD | 32 +++++ avr/devices/n30/boot/boot.asm | 130 ++++++++++++++++++ avr/devices/n30/defs.asm | 100 ++++++++++++++ avr/devices/n30/eeprom.asm | 13 ++ avr/devices/n30/enclosure.scad | 242 +++++++++++++++++++++++++++++++++ avr/devices/n30/main/0BUILD | 33 +++++ avr/devices/n30/main/main.asm | 221 ++++++++++++++++++++++++++++++ 11 files changed, 811 insertions(+) create mode 100644 avr/devices/n30/.gitignore create mode 100644 avr/devices/n30/0BUILD create mode 100644 avr/devices/n30/README create mode 100644 avr/devices/n30/boot/0BUILD create mode 100644 avr/devices/n30/boot/boot.asm create mode 100644 avr/devices/n30/defs.asm create mode 100644 avr/devices/n30/eeprom.asm create mode 100644 avr/devices/n30/enclosure.scad create mode 100644 avr/devices/n30/main/0BUILD create mode 100644 avr/devices/n30/main/main.asm diff --git a/avr/devices/0BUILD b/avr/devices/0BUILD index 0ea9557..86d1fa2 100644 --- a/avr/devices/0BUILD +++ b/avr/devices/0BUILD @@ -20,6 +20,7 @@ n27 n28 n29 + n30 r06 s03 t03 diff --git a/avr/devices/n30/.gitignore b/avr/devices/n30/.gitignore new file mode 100644 index 0000000..ebbb4c0 --- /dev/null +++ b/avr/devices/n30/.gitignore @@ -0,0 +1,3 @@ +*.eep.hex +*.obj +n30-enclosure.stl diff --git a/avr/devices/n30/0BUILD b/avr/devices/n30/0BUILD new file mode 100644 index 0000000..343465e --- /dev/null +++ b/avr/devices/n30/0BUILD @@ -0,0 +1,18 @@ + + + + + + boot + main + + + + defs.asm + eeprom.asm + README + + + + + diff --git a/avr/devices/n30/README b/avr/devices/n30/README new file mode 100644 index 0000000..cbfb5e9 --- /dev/null +++ b/avr/devices/n30/README @@ -0,0 +1,18 @@ + +N25 +=== + +- Role: LED strip controller +- MCU: AtTiny84 +- Connection: RJ45 +- Predecessor: N22, N16 +- UART: uart_bitbang2 +- Periphery: + - LED strip connection (SK6812) + - OWI interface + - DS18B20 temperature sensor +- Apps: + - NETWORK: Basic network functionality (address setup etc.) + - REPORTSENSORS: report sensor data from temperature sensor etc. + - STATS : periodically send stats data + - MA_LIGHT : motion activated light diff --git a/avr/devices/n30/boot/0BUILD b/avr/devices/n30/boot/0BUILD new file mode 100644 index 0000000..b465c3d --- /dev/null +++ b/avr/devices/n30/boot/0BUILD @@ -0,0 +1,32 @@ + + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + boot.asm + + + + + + + + + + + + + + + + diff --git a/avr/devices/n30/boot/boot.asm b/avr/devices/n30/boot/boot.asm new file mode 100644 index 0000000..df06de6 --- /dev/null +++ b/avr/devices/n30/boot/boot.asm @@ -0,0 +1,130 @@ +; *************************************************************************** +; 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 "devices/all/defs.asm" + +.include "common/calls.asm" +.include "common/utils_io.asm" +.include "common/utils_wait.asm" + + + +; *************************************************************************** +; defines + +; --------------------------------------------------------------------------- +; 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 main ; 1: Reset vector + reti ; 2: EXT_INT0 + reti ; 3: PCI0 + reti ; 4: PCI1 + reti ; 5: WDT + reti ; 6: TIM1_CAPT + reti ; 7: TIM1_COMPA + reti ; 8: TIM1_COMPB + reti ; 9: TIM1_OVF + reti ; 10: TIM0_COMPA + reti ; 11: TIM0_COMPB + reti ; 12: TIM0_OVF + reti ; 13: ANA_COMP + reti ; 14: ADC + reti ; 15: EE_RDY + reti ; 16: USI_STR + reti ; 17: 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_com2w.asm" +.include "modules/flash/flashxp.asm" +.include "modules/flash/flash1p.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" + + + +systemSetSpeed: +.if clock == 8000000 + ldi r16, (1< + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + main.asm + + + + + + + + + + + + + + + + + diff --git a/avr/devices/n30/main/main.asm b/avr/devices/n30/main/main.asm new file mode 100644 index 0000000..1d28bbb --- /dev/null +++ b/avr/devices/n30/main/main.asm @@ -0,0 +1,221 @@ +; *************************************************************************** +; 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 LED controller node on AtTiny 84 +; +; This is for the full system (i.e. not the boot loader). +; *************************************************************************** + +.equ clock=8000000 ; Define the clock frequency + + + +.nolist +.include "include/tn84def.inc" ; Define device ATtiny84 +.list + +.include "version.asm" +.include "../defs.asm" +.include "../eeprom.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_MAL_STATE = 0x07 + + +;.equ VALUE_ID_REED_CONF = 0x81 +.equ VALUE_ID_LED_STATE = 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_MAL_BSOURCE = 0x89 +.equ VALUE_ID_MAL_BVALUE = 0x8a +.equ VALUE_ID_LED_MODE = 0x8b + +.equ VALUE_ID_LEDSIMPLE_TIMING = 0x88 + + + +; *************************************************************************** +; code segment + +.cseg +.org 000000 + + + +; --------------------------------------------------------------------------- +; Reset and interrupt vectors + + rjmp BOOTLOADER_ADDR ; 1: Reset vector ; use this for flashed system + reti ; 2: EXT_INT0 + rjmp com2wPcintIsr ; 3: PCI0 + reti ; 4: PCI1 + reti ; 5: WDT + reti ; 6: TIM1_CAPT + reti ; 7: TIM1_COMPA + reti ; 8: TIM1_COMPB + reti ; 9: TIM1_OVF + rjmp baseTimerIrqOC0A ; 10: TIM0_COMPA + reti ; 11: TIM0_COMPB + reti ; 12: TIM0_OVF + reti ; 13: ANA_COMP + reti ; 14: ADC + reti ; 15: EE_RDY + reti ; 16: USI_STR + reti ; 17: 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 +#if 0 + ; debug + ldi r19, 0x00 ; G + ldi r18, 0xff ; R + ldi r20, 0x55 ; B + ldi r21, 0xaa ; W + rcall SK6812_SetAllColor ; r23 (r16, r17) +#endif + ret + + + +; --------------------------------------------------------------------------- +; @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" +;.include "common/debug.asm" + + + +; --------------------------------------------------------------------------- +; defines for network interface + +.equ netInterfaceData = com2w_iface + + + +