From cd6413e7a66ff5718ead92ffe17279293d1550fa Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Thu, 5 Sep 2024 03:16:27 +0200 Subject: [PATCH] avr: added device n11. --- avr/devices/0BUILD | 1 + avr/devices/n11/.gitignore | 2 + avr/devices/n11/0BUILD | 52 ++++ avr/devices/n11/n11_boot.asm | 161 ++++++++++++ avr/devices/n11/n11_defs.asm | 13 + avr/devices/n11/n11_main.asm | 483 +++++++++++++++++++++++++++++++++++ 6 files changed, 712 insertions(+) create mode 100644 avr/devices/n11/.gitignore create mode 100644 avr/devices/n11/0BUILD create mode 100644 avr/devices/n11/n11_boot.asm create mode 100644 avr/devices/n11/n11_defs.asm create mode 100644 avr/devices/n11/n11_main.asm diff --git a/avr/devices/0BUILD b/avr/devices/0BUILD index 4c4f364..cd4f84b 100644 --- a/avr/devices/0BUILD +++ b/avr/devices/0BUILD @@ -3,6 +3,7 @@ + n11 n12 diff --git a/avr/devices/n11/.gitignore b/avr/devices/n11/.gitignore new file mode 100644 index 0000000..8e0618c --- /dev/null +++ b/avr/devices/n11/.gitignore @@ -0,0 +1,2 @@ +*.eep.hex +*.obj diff --git a/avr/devices/n11/0BUILD b/avr/devices/n11/0BUILD new file mode 100644 index 0000000..e1153f3 --- /dev/null +++ b/avr/devices/n11/0BUILD @@ -0,0 +1,52 @@ + + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + n11_main.asm + + + + + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + n11_boot.asm + + + + + + + + + + + n11_defs.asm + + + + + + diff --git a/avr/devices/n11/n11_boot.asm b/avr/devices/n11/n11_boot.asm new file mode 100644 index 0000000..b4e5df9 --- /dev/null +++ b/avr/devices/n11/n11_boot.asm @@ -0,0 +1,161 @@ +; *************************************************************************** +; 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. +; +; +; AtTiny84 +; -------- +; VCC 1 14 GND +; PB0 2 13 PA0 +; PB1 3 12 PA1 COM-DATA +; /RESET PB3 4 11 PA2 +; KEY1 PB2 5 10 PA3 LED +; COM_ATTN PA7 6 9 PA4 +; PA6 7 8 PA5 +; -------- +; +; *************************************************************************** + + + +.nolist +.include "include/tn84def.inc" ; Define device ATtiny84 +.list + +.include "n11_defs.asm" +.include "defs.asm" + + + +; *************************************************************************** +; defines + +; --------------------------------------------------------------------------- +; generic + +.equ clock=1000000 ; Define the clock frequency + + +.include "common/utils_wait.asm" +.include "modules/com2/defs.asm" +.include "modules/comproto/defs.asm" + + + +; --------------------------------------------------------------------------- +; firmware settings + +#define FW_TYPE AQHOME_FW_TYPE_ATT84_BASE +#define FW_VERSION 0x0001 + + +#define BASE_SYSTEM +#define WITH_FLASH + + + +; --------------------------------------------------------------------------- +; COM module + +.equ COM_BIT_LENGTH = 52000 ; 104000=9600, 52000=19200, 26000=38400 + +.equ COM_DDR_DATA = DDRA +.equ COM_PORT_DATA = PORTA +.equ COM_PIN_DATA = PINA +.equ COM_PINNUM_DATA = PORTA1 + +.equ COM_DDR_ATTN = DDRA +.equ COM_PORT_ATTN = PORTA +.equ COM_PIN_ATTN = PINA +.equ COM_PINNUM_ATTN = PORTA7 + +.equ COM_IRQ_ADDR_ATTN = PCMSK0 +.equ COM_IRQ_BIT_ATTN = 7 ; bit 7 in PCMSK0 +.equ COM_IRQ_GIFR_ATTN = PCIF0 +.equ COM_IRQ_GIMSK_ATTN = PCIE0 + + +.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: +devInfoManufacturer: .db 'A', 'Q', 'U', 'A' +devInfoId: .db 'N', 0 +devInfoVersion: .db 1, 0 ; version, revision + +firmwareStart: rjmp main ; will be overwritten when flashing + + + +; *************************************************************************** +; main code + + +.org BOOTLOADER_ADDR + + +main: + rjmp bootLoader ; this routine is in modules/flash/proto.asm + + + + +; *************************************************************************** +; includes + +.include "modules/com2/lowlevel.asm" +.include "modules/com2/crc.asm" +.include "modules/com2/packets.asm" +.include "common/crc8.asm" +.include "common/utils_wait_fixed.asm" +.include "common/utils_copy.asm" +.include "modules/flash/bootloader.asm" +.include "modules/flash/flash.asm" +.include "modules/flash/recv.asm" +.include "modules/flash/send.asm" +.include "modules/flash/wait.asm" +.include "modules/flash/hdl_flash_start.asm" +.include "modules/flash/hdl_flash_data.asm" +.include "modules/flash/hdl_flash_end.asm" +.include "modules/flash/flash_rsp.asm" +.include "modules/flash/flash_ready.asm" + + + + diff --git a/avr/devices/n11/n11_defs.asm b/avr/devices/n11/n11_defs.asm new file mode 100644 index 0000000..7404c12 --- /dev/null +++ b/avr/devices/n11/n11_defs.asm @@ -0,0 +1,13 @@ +; *************************************************************************** +; 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 BOOTLOADER_ADDR = 0xd00 + diff --git a/avr/devices/n11/n11_main.asm b/avr/devices/n11/n11_main.asm new file mode 100644 index 0000000..a37dad2 --- /dev/null +++ b/avr/devices/n11/n11_main.asm @@ -0,0 +1,483 @@ +; *************************************************************************** +; 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 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. +; +; +; AtTiny84 +; -------- +; VCC 1 14 GND +; PB0 2 13 PA0 REED_OUT +; PB1 3 12 PA1 COM-DATA +; /RESET PB3 4 11 PA2 REED_IN1 +; [KEY1] PB2 5 10 PA3 LED +; COM_ATTN PA7 6 9 PA4 TWI-SCL +; TWI-SDA PA6 7 8 PA5 REED_IN2 +; -------- +; +; *************************************************************************** + + + +.nolist +.include "include/tn84def.inc" ; Define device ATtiny84 +.list + +.include "n11_defs.asm" +.include "defs.asm" + + + +; *************************************************************************** +; defines + +; --------------------------------------------------------------------------- +; generic + +.equ clock=1000000 ; Define the clock frequency + +.include "common/utils_wait.asm" + + +; --------------------------------------------------------------------------- +; firmware settings including list of modules used + +#define FW_TYPE AQHOME_FW_TYPE_ATT84_TEMP1 +#define FW_VERSION 0x0001 + + +#define MODULES_TIMER +#define MODULES_COM +#define MODULES_COM_WITH_ADDR_PROTO +#define MODULES_LED +#define MODULES_TWI_MASTER +;#define MODULES_LCD +#define MODULES_SI7021 +#define MODULES_STATS +;#define MODULES_CNY70 +#define MODULES_REED + + +.set MODULES_MASK = 0 +#ifdef MODULES_TIMER +.set MODULES_MASK = MODULES_MASK | (1<