From 8925ce23e9ba69b45c5a43f85d1d3a46b9f46a16 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 26 Apr 2025 11:04:01 +0200 Subject: [PATCH] N23 basically works now. --- avr/devices/n23/main/data.asm | 18 +++ avr/devices/n23/main/main.asm | 240 +++++++++++++++++++++---------- avr/devices/n23/main/motion.asm | 62 +++++--- avr/devices/n23/main/network.asm | 40 +++++- 4 files changed, 258 insertions(+), 102 deletions(-) create mode 100644 avr/devices/n23/main/data.asm diff --git a/avr/devices/n23/main/data.asm b/avr/devices/n23/main/data.asm new file mode 100644 index 0000000..95b9d91 --- /dev/null +++ b/avr/devices/n23/main/data.asm @@ -0,0 +1,18 @@ +; *************************************************************************** +; 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 + + +programRamBegin: + programRamSensorTimer: .byte 1 +programRamEnd: + diff --git a/avr/devices/n23/main/main.asm b/avr/devices/n23/main/main.asm index da8ef4d..9c0f645 100644 --- a/avr/devices/n23/main/main.asm +++ b/avr/devices/n23/main/main.asm @@ -31,7 +31,10 @@ .list .include "../defs.asm" +.include "./data.asm" + .include "defs_all.asm" +.include "common/utils_wait.asm" @@ -41,6 +44,10 @@ ; --------------------------------------------------------------------------- ; generic +.equ NET_BUFFERS_NUM = 6 +.equ NET_BUFFERS_SIZE = 28 + +.equ PROGRAM_TIMER_VALUE = 60 ; --------------------------------------------------------------------------- @@ -98,7 +105,7 @@ ; rjmp main ; Reset vector rjmp BOOTLOADER_ADDR ; Reset vector ; use this for flashed system reti ; EXT_INT0 - rjmp uartBitbangIsrPcint0 ; PCI0 + rjmp UART_BitBang_PcintIsr ; PCI0 reti ; PCI1 reti ; WATCHDOG reti ; ICP1 @@ -139,6 +146,9 @@ firmwareStart: rcall Utils_Init rcall Utils_SetupUid + ldi r16, PROGRAM_TIMER_VALUE + sts programRamSensorTimer, r16 + rcall initModules sbi LED_SIMPLE_DDR, LED_SIMPLE_PINNUM ; out @@ -157,11 +167,10 @@ main_loop: sei ; make sure interrupts really are enabled sleep ; sleep, wait for interrupt - rcall BaseTimer_Run + rcall BaseTimer_Run ; let basetimer run + rcall handleMessages ; handle incoming messages ; rcall ComOnUart0_Run - ; TODO: read recved messages - rjmp main_loop @@ -172,19 +181,20 @@ main_loop: ; Called every 100ms. Add your routine calls here. No arguments, no results. systemSetSpeed: -.if clock == 1000000 - ldi r17, 0xd8 - ldi r16, (1<