From 3582659018aae5320b43900fb08e457e56cbda29 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 2 Jun 2025 01:02:06 +0200 Subject: [PATCH 001/196] added more bigcall/bigjmp as we go along with larger code. --- avr/apps/network/main.asm | 24 ++++++++++++------------ avr/apps/network/stats.asm | 24 ++++++++++++------------ avr/modules/network/msg/device-w.asm | 4 ++-- avr/modules/network/msg/memstats-w.asm | 6 +++--- avr/modules/network/msg/pong-w.asm | 14 +++++++------- avr/modules/network/msg/reboot-r.asm | 2 +- avr/modules/network/msg/recvstats-w.asm | 4 ++-- avr/modules/network/msg/sendstats-w.asm | 4 ++-- 8 files changed, 41 insertions(+), 41 deletions(-) diff --git a/avr/apps/network/main.asm b/avr/apps/network/main.asm index d440e20..54c43b8 100644 --- a/avr/apps/network/main.asm +++ b/avr/apps/network/main.asm @@ -124,7 +124,7 @@ AppNetwork_HandleMsg_handleRangeMsg: rjmp AppNetwork_HandleMsg_clcRet AppNetwork_HandleMsg_handleAddrMsg: - rcall NETMSG_Address_Read ; R18=cmd, R19=addr(R18, R19) + bigcall NETMSG_Address_Read ; R18=cmd, R19=addr(R18, R19) mov r16, r18 subi r16, NETMSG_CMD_NEED_ADDRESS ldi zl, LOW(appNetworkMsgTable) @@ -175,18 +175,18 @@ appNetworkHandlePingRequest: adiw xh:xl, NETMSG_OFFS_SRCADDR ld r17, X push r17 - rcall NET_Buffer_Alloc ; (R16, R17, X) + bigcall NET_Buffer_Alloc ; (R16, R17, X) pop r17 - brcc appNetworkHandlePingRequest_end ; jmp on error - push r16 ; buffer num - mov r16, r17 ; DEST addr + brcc appNetworkHandlePingRequest_end ; jmp on error + push r16 ; buffer num + mov r16, r17 ; DEST addr adiw xh:xl, 1 ldi yl, LOW(netInterfaceData) ldi yh, HIGH(netInterfaceData) - rcall NETMSG_Pong_Write ; (R16, R17, R18, R19, R20, X) + bigcall NETMSG_Pong_Write ; (R16, R17, R18, R19, R20, X) sbiw xh:xl, 1 - pop r16 ; buffer num - rcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) + pop r16 ; buffer num + bigcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) appNetworkHandlePingRequest_end: ret @@ -393,16 +393,16 @@ appNetworkHandleMsgDenyAddr_end: ; @clobbers R16 (R17, R18, R19, R20, R21, X) appNetworkSendAddrMsg: - rcall NET_Buffer_Alloc ; (R16, R17, X) + bigcall NET_Buffer_Alloc ; (R16, R17, X) brcc appNetworkSendAddrMsg_end adiw xh:xl, 1 push r16 - rcall NETMSG_Address_Write ; (R16, R17, R18, R19, R20, R21) + bigcall NETMSG_Address_Write ; (R16, R17, R18, R19, R20, R21) pop r16 sbiw xh:xl, 1 - rcall NET_Interface_AddOutgoingMsgNum ; (R17, R18, X) + bigcall NET_Interface_AddOutgoingMsgNum ; (R17, R18, X) brcs appNetworkSendAddrMsg_end - rcall NET_Buffer_ReleaseByNum ; (R16, X) + bigcall NET_Buffer_ReleaseByNum ; (R16, X) clc appNetworkSendAddrMsg_end: ret diff --git a/avr/apps/network/stats.asm b/avr/apps/network/stats.asm index 2b2d6bb..c50f7f1 100644 --- a/avr/apps/network/stats.asm +++ b/avr/apps/network/stats.asm @@ -18,14 +18,14 @@ ; @clobbers R16, X (R17, R18, R19, R20, R21, Z) AppNetwork_SendTxdStats: - rcall NET_Buffer_Alloc ; (R16, R17, X) + bigcall NET_Buffer_Alloc ; (R16, R17, X) brcc AppNetwork_SendTxdStats_end push r16 adiw xh:xl, 1 - rcall NETMSG_SendStats_Write ; (R16, R17, R18, R19, R20, R21, Z) + bigcall NETMSG_SendStats_Write ; (R16, R17, R18, R19, R20, R21, Z) sbiw xh:xl, 1 pop r16 - rcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) + bigcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) AppNetwork_SendTxdStats_end: ret ; @end @@ -39,14 +39,14 @@ AppNetwork_SendTxdStats_end: ; @clobbers R16, X (R17, R18, R19, R20, R21, Z) AppNetwork_SendRxdStats: - rcall NET_Buffer_Alloc ; (R16, R17, X) + bigcall NET_Buffer_Alloc ; (R16, R17, X) brcc AppNetwork_SendRxdStats_end push r16 adiw xh:xl, 1 - rcall NETMSG_RecvStats_Write ; (R16, R17, R18, R19, R20, R21, Z) + bigcall NETMSG_RecvStats_Write ; (R16, R17, R18, R19, R20, R21, Z) sbiw xh:xl, 1 pop r16 - rcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) + bigcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) AppNetwork_SendRxdStats_end: ret ; @end @@ -60,14 +60,14 @@ AppNetwork_SendRxdStats_end: ; @clobbers R16, X (R17, R18, R19, R20, R21, Z) AppNetwork_SendMemStats: - rcall NET_Buffer_Alloc ; (R16, R17, X) + bigcall NET_Buffer_Alloc ; (R16, R17, X) brcc AppNetwork_SendMemStats_end push r16 adiw xh:xl, 1 - rcall NETMSG_MemStats_Write ; (R16, R17, R18, R19, R20, R21) + bigcall NETMSG_MemStats_Write ; (R16, R17, R18, R19, R20, R21) sbiw xh:xl, 1 pop r16 - rcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) + bigcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) AppNetwork_SendMemStats_end: ret ; @end @@ -81,14 +81,14 @@ AppNetwork_SendMemStats_end: ; @clobbers R16, X (R17, R18, R19, R20, R21, Z) AppNetwork_SendDevice: - rcall NET_Buffer_Alloc ; (R16, R17, X) + bigcall NET_Buffer_Alloc ; (R16, R17, X) brcc AppNetwork_SendDevice_end push r16 adiw xh:xl, 1 - rcall NETMSG_Device_Write ; (R16, R17, R18, R19, R20, R21, Z) + bigcall NETMSG_Device_Write ; (R16, R17, R18, R19, R20, R21, Z) sbiw xh:xl, 1 pop r16 - rcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) + bigcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) AppNetwork_SendDevice_end: ret ; @end diff --git a/avr/modules/network/msg/device-w.asm b/avr/modules/network/msg/device-w.asm index a1e7ec2..c173d0b 100644 --- a/avr/modules/network/msg/device-w.asm +++ b/avr/modules/network/msg/device-w.asm @@ -25,13 +25,13 @@ NETMSG_Device_Write: st X+, r16 ; msg code ldd r16, Y+NET_IFACE_OFFS_ADDRESS st X+, r16 ; src address - rcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21) + bigcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21) ldi zh, HIGH(devInfoBlock*2) ; 6-17: devInfoBlock ldi zl, LOW(devInfoBlock*2) ldi r18, 12 bigcall Utils_CopyFromFlash ; (R17, R18, X, Z) sbiw xh:xl, 20 ; go back to beginning of message (1 byte dst addr, 1 byte length, 18 bytes payload) - rcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X) + bigcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X) sbiw xh:xl, 21 ; go back to beginning of message (1 byte dst addr, 1 byte length, 18 bytes payload, 1 byte crc) ret ; @end diff --git a/avr/modules/network/msg/memstats-w.asm b/avr/modules/network/msg/memstats-w.asm index 7317936..2bbfa66 100644 --- a/avr/modules/network/msg/memstats-w.asm +++ b/avr/modules/network/msg/memstats-w.asm @@ -27,7 +27,7 @@ NETMSG_MemStats_Write: st X+, r16 ; src address ; uid - rcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21) + bigcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21) ; timestamp (0 for now) clr r16 st X+, r16 @@ -53,7 +53,7 @@ NETMSG_MemStats_Write: ; current buffers used push xl push xh - rcall NET_Buffer_CountUsed ; (r16, r17, r18, X) + bigcall NET_Buffer_CountUsed ; (r16, r17, r18, X) pop xh pop xl st X+, r16 @@ -67,7 +67,7 @@ NETMSG_MemStats_Write: st X+, r16 sbiw xh:xl, 18 ; go back to beginning of message (1 byte dst addr, 1 byte length, 16 bytes payload) - rcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X) + bigcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X) sbiw xh:xl, 19 ; go back to beginning of message (1 byte dst addr, 1 byte length, 16 bytes payload, 1 byte crc) ret ; @end diff --git a/avr/modules/network/msg/pong-w.asm b/avr/modules/network/msg/pong-w.asm index 650bece..5a70f9b 100644 --- a/avr/modules/network/msg/pong-w.asm +++ b/avr/modules/network/msg/pong-w.asm @@ -18,17 +18,17 @@ ; @clobbers R16 (R17, R18, R19, R20, R21, Z) NETMSG_Pong_Write: - st X+, r16 ; dest address - ldi r16, 6 ; msg code+src address+4 payload bytes - st X+, r16 ; msg len + st X+, r16 ; dest address + ldi r16, 6 ; msg code+src address+4 payload bytes + st X+, r16 ; msg len ldi r16, NETMSG_CMD_PONG - st X+, r16 ; msg code + st X+, r16 ; msg code ldd r16, Y+NET_IFACE_OFFS_ADDRESS - st X+, r16 ; src address - rcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21) + st X+, r16 ; src address + bigcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21) sbiw xh:xl, 8 ; go back to beginning of message (1 byte dst addr, 1 byte length, 6 bytes payload) - rcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X) + bigcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X) sbiw xh:xl, 9 ; go back to beginning of message (1 byte dst addr, 1 byte length, 6 bytes payload, 1 byte crc) ret ; @end diff --git a/avr/modules/network/msg/reboot-r.asm b/avr/modules/network/msg/reboot-r.asm index a99bcf9..29af0f2 100644 --- a/avr/modules/network/msg/reboot-r.asm +++ b/avr/modules/network/msg/reboot-r.asm @@ -31,7 +31,7 @@ NETMSG_RebootRequestRead: push xl push xh adiw xh:xl, NETMSG_REBOOTREQ_OFFS_UID - rcall NETMSG_CheckUidInMsg ; (r16, r18, r19, r20, r21, X) + bigcall NETMSG_CheckUidInMsg ; (r16, r18, r19, r20, r21, X) pop xh pop xl pop r16 diff --git a/avr/modules/network/msg/recvstats-w.asm b/avr/modules/network/msg/recvstats-w.asm index d170d74..451c3c0 100644 --- a/avr/modules/network/msg/recvstats-w.asm +++ b/avr/modules/network/msg/recvstats-w.asm @@ -25,14 +25,14 @@ NETMSG_RecvStats_Write: st X+, r16 ; msg code ldd r16, Y+NET_IFACE_OFFS_ADDRESS st X+, r16 ; src address - rcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21) + bigcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21) adiw yh:yl, NET_IFACE_OFFS_PACKETSIN_LOW ldi r18, 12 bigcall Utils_Copy_SDRAM ; (R17, R18, X, Y) sbiw yh:yl, NET_IFACE_OFFS_PACKETSIN_LOW+12 sbiw xh:xl, 20 ; go back to beginning of message (1 byte dst addr, 1 byte length, 18 bytes payload) - rcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X) + bigcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X) sbiw xh:xl, 21 ; go back to beginning of message (1 byte dst addr, 1 byte length, 18 bytes payload, 1 byte crc) ret ; @end diff --git a/avr/modules/network/msg/sendstats-w.asm b/avr/modules/network/msg/sendstats-w.asm index f33d612..594b9ad 100644 --- a/avr/modules/network/msg/sendstats-w.asm +++ b/avr/modules/network/msg/sendstats-w.asm @@ -25,14 +25,14 @@ NETMSG_SendStats_Write: st X+, r16 ; msg code ldd r16, Y+NET_IFACE_OFFS_ADDRESS st X+, r16 ; src address - rcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21) + bigcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21) adiw yh:yl, NET_IFACE_OFFS_PACKETSOUT_LOW ldi r18, 6 bigcall Utils_Copy_SDRAM ; (R17, R18, X, Y) sbiw yh:yl, NET_IFACE_OFFS_PACKETSOUT_LOW+6 sbiw xh:xl, 14 ; go back to beginning of message (1 byte dst addr, 1 byte length, 12 bytes payload) - rcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X) + bigcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X) sbiw xh:xl, 15 ; go back to beginning of message (1 byte dst addr, 1 byte length, 12 bytes payload, 1 byte crc) ret ; @end From 4f610c68a2b9f334bb9707399574a3fad4b7f9cb Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 2 Jun 2025 01:03:03 +0200 Subject: [PATCH 002/196] added more fonts and corresponding code. disabled test code in ili9341 module. --- avr/devices/c02/main/main.asm | 116 ++++++++++++- avr/modules/lcd2/font/0BUILD | 3 + avr/modules/lcd2/font/font16x26.asm | 109 ++++++++++++ avr/modules/lcd2/font/font2.asm | 242 +++++++++++++++++--------- avr/modules/lcd2/font/font3.asm | 257 +++++++++++++++++++++++++++ avr/modules/lcd2/font/font4.asm | 258 ++++++++++++++++++++++++++++ avr/modules/lcd2/ili9341/main.asm | 4 +- 7 files changed, 904 insertions(+), 85 deletions(-) create mode 100644 avr/modules/lcd2/font/font16x26.asm create mode 100644 avr/modules/lcd2/font/font3.asm create mode 100644 avr/modules/lcd2/font/font4.asm diff --git a/avr/devices/c02/main/main.asm b/avr/devices/c02/main/main.asm index 94a7317..3d96af3 100644 --- a/avr/devices/c02/main/main.asm +++ b/avr/devices/c02/main/main.asm @@ -175,6 +175,7 @@ irqNotSet: ; @routine onSystemStart onSystemStart: + bigcall test ret ; @end @@ -226,7 +227,10 @@ onEveryLoop: .include "devices/all/hw_m644p.asm" .include "devices/all/includes.asm" -.include "common/debug.asm" +;.include "common/debug.asm" + +.include "modules/lcd2/font/font3.asm" +.include "modules/lcd2/font/font16x26.asm" @@ -238,3 +242,113 @@ onEveryLoop: + + +; @param %0 X +; @param %1 Y +; @param %2 W +; @param %3 H +.macro M_FILL_RECT + ldi r16, LOW(@0) ; X0 + mov r4, r16 + ldi r16, HIGH(@0) + mov r5, r16 + + ldi r16, LOW(@1) ; Y0 + mov r6, r16 + ldi r16, HIGH(@1) + mov r7, r16 + + ldi r16, LOW(@2) ; W + mov r8, r16 + ldi r16, HIGH(@2) + mov r9, r16 + + ldi r16, LOW(@3) ; H + mov r10, r16 + ldi r16, HIGH(@3) + mov r11, r16 + + bigcall ILI9341_FillRect +.endmacro + + + + +test: + ; set foreground (r3:r2) +; 0bRRRRRGGGGGGBBBBB + ldi r16, 0b11111111 + mov r3, r16 + ldi r16, 0b11111111 ; white + mov r2, r16 + M_FILL_RECT 0, 0, 319, 239 + + ; set foreground (r3:r2) + ldi r16, 0b00000000 + mov r3, r16 + ldi r16, 0b00011111 ; blue + mov r2, r16 + M_FILL_RECT 0, 0, 319, 32 + + ; set background (r1:r0) + mov r0, r2 + mov r1, r3 + + ; set foreground (r3:r2) + ldi r16, 0b11111111 + mov r3, r16 + ldi r16, 0b11111111 ; white + mov r2, r16 + +; set Xpos + ldi r16, LOW(10) + mov r4, r16 + ldi r16, HIGH(10) + mov r5, r16 + +; setYpos + ldi r16, LOW(3) + mov r6, r16 + ldi r16, HIGH(3) + mov r7, r16 + +; set font + ldi zl, LOW(font3_16x26*2) + ldi zh, HIGH(font3_16x26*2) + +; set buffer + ldi xl, LOW(glyphBuffer) + ldi xh, HIGH(glyphBuffer) + +; write characters + ldi r16, 'A' + bigcall ili9341_WriteCharacterX1At + + ldi r16, 'Q' + bigcall ili9341_WriteCharacterX1At + + ldi r16, 'H' + bigcall ili9341_WriteCharacterX1At + + ldi r16, 'O' + bigcall ili9341_WriteCharacterX1At + + ldi r16, 'M' + bigcall ili9341_WriteCharacterX1At + + ldi r16, 'E' + bigcall ili9341_WriteCharacterX1At + + ret + + + + + + +.dseg + +glyphBuffer: .byte 1024 + + diff --git a/avr/modules/lcd2/font/0BUILD b/avr/modules/lcd2/font/0BUILD index e7879ab..bfdc146 100644 --- a/avr/modules/lcd2/font/0BUILD +++ b/avr/modules/lcd2/font/0BUILD @@ -6,8 +6,11 @@ defs.asm font8x8.asm font6x8.asm + font16x26.asm font1.asm font2.asm + font3.asm + font4.asm diff --git a/avr/modules/lcd2/font/font16x26.asm b/avr/modules/lcd2/font/font16x26.asm new file mode 100644 index 0000000..7e1582f --- /dev/null +++ b/avr/modules/lcd2/font/font16x26.asm @@ -0,0 +1,109 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + +; *************************************************************************** +; code + +.cseg + + + + +; --------------------------------------------------------------------------- +; @routine font16x26RenderCharacter + +; @param R16 character to write +; @param R1:R0 background color +; @param R3:R2 foreground color +; @param Z pointer to font +; @param X pointer to RAM to store data to +; @param r18 char width in pixel +; @param r19 char height in pixel +; @clobbers r17, r18, r24, r25, x + +font16x26MonoRenderCharacter: + push zl + push zh + rcall font16x26GetCharPosInFont ; (r17, r24, r25, z) + ldi r25, 26 ; 26 bytes height +font16x26MonoRenderCharacter_loop1: + ldi r24, 16 ; 16 bits +font16x26MonoRenderCharacter_loop2: + mov r23, r24 + andi r23, 7 + brne font16x26MonoRenderCharacter_haveByte + lpm r17, Z+ +font16x26MonoRenderCharacter_haveByte: + lsr r17 + brcs font16x26MonoRenderCharacter_writeForeground + st X+, r0 + st X+, r1 + rjmp font16x26MonoRenderCharacter_loop2end +font16x26MonoRenderCharacter_writeForeground: + st X+, r2 + st X+, r3 +font16x26MonoRenderCharacter_loop2end: + dec r24 + brne font16x26MonoRenderCharacter_loop2 + dec r25 + brne font16x26MonoRenderCharacter_loop1 + ldi r18, 16 + ldi r19, 26 + pop zh + pop zl + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine font16x26GetCharPosInFont + +; @param R16 character to write +; @param Z pointer to font +; @return Z pointer to begin of char data +; @clobbers r17, r24, r25, z + +font16x26GetCharPosInFont: + mov r24, r16 + adiw zh:zl, FONT_OFFS_FIRSTCHAR + lpm r24, Z+ ; first char num + lpm r25, Z+ ; num of chars + sub r16, r24 + brcs font16x26GetCharPosInFont_ret + cp r16, r25 + brcc font16x26GetCharPosInFont_ret + mov r24, r16 + clr r25 + lsl r24 ; x2 + rol r25 + add r24, r16 ; x3 + adc r25, r16 + sub r25, r16 + lsl r24 ; x6 + rol r25 + lsl r24 ; x12 + rol r25 + add r24, r16 ; x13 + adc r25, r16 + sub r25, r16 + lsl r24 ; x26 + rol r25 + lsl r24 ; x52 + rol r25 + + add zl, r24 + adc zh, r25 +font16x26GetCharPosInFont_ret: + ret +; @end + + + diff --git a/avr/modules/lcd2/font/font2.asm b/avr/modules/lcd2/font/font2.asm index 6c6ec79..d277dd3 100644 --- a/avr/modules/lcd2/font/font2.asm +++ b/avr/modules/lcd2/font/font2.asm @@ -29,9 +29,8 @@ font2_6x8: .dw font6x8MonoRenderCharacter ; renderFn .db 96, 0 ; needed buffer size .db 6, 8 ; width, height of chars - .db 32, 65 ; first char, num of chars in font + .db 32, 224 ; first char, num of chars in font ; data (6x8_horizontal_LSB_2) -font: .db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x20 .db 0x08,0x1C,0x1C,0x08,0x08,0x00,0x08,0x00, ; 0x21 .db 0x36,0x36,0x12,0x00,0x00,0x00,0x00,0x00, ; 0x22 @@ -97,83 +96,162 @@ font: .db 0x08,0x14,0x22,0x00,0x00,0x00,0x00,0x00, ; 0x5E .db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F, ; 0x5F .db 0x0C,0x0C,0x08,0x00,0x00,0x00,0x00,0x00, ; 0x60 - - - - - - - - - - - -#if 0 -.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x20 -.db 0x20,0x70,0x70,0x20,0x20,0x00,0x20,0x00, ; 0x21 -.db 0xD8,0xD8,0x48,0x00,0x00,0x00,0x00,0x00, ; 0x22 -.db 0x00,0x50,0xF8,0x50,0x50,0xF8,0x50,0x00, ; 0x23 -.db 0x10,0x70,0x08,0x30,0x40,0x38,0x20,0x00, ; 0x24 -.db 0x98,0x98,0x40,0x20,0x10,0xC8,0xC8,0x00, ; 0x25 -.db 0x10,0x28,0x28,0x10,0xA8,0x48,0xB0,0x00, ; 0x26 -.db 0x30,0x30,0x10,0x00,0x00,0x00,0x00,0x00, ; 0x27 -.db 0x20,0x10,0x10,0x10,0x10,0x10,0x20,0x00, ; 0x28 -.db 0x10,0x20,0x20,0x20,0x20,0x20,0x10,0x00, ; 0x29 -.db 0x00,0x50,0x70,0xF8,0x70,0x50,0x00,0x00, ; 0x2A -.db 0x00,0x20,0x20,0xF8,0x20,0x20,0x00,0x00, ; 0x2B -.db 0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x10, ; 0x2C -.db 0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00, ; 0x2D -.db 0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00, ; 0x2E -.db 0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00, ; 0x2F -.db 0x70,0x88,0xC8,0xA8,0x98,0x88,0x70,0x00, ; 0x30 -.db 0x20,0x30,0x20,0x20,0x20,0x20,0x70,0x00, ; 0x31 -.db 0x70,0x88,0x80,0x60,0x10,0x08,0xF8,0x00, ; 0x32 -.db 0x70,0x88,0x80,0x70,0x80,0x88,0x70,0x00, ; 0x33 -.db 0x40,0x60,0x50,0x48,0xF8,0x40,0x40,0x00, ; 0x34 -.db 0xF8,0x08,0x08,0x78,0x80,0x88,0x70,0x00, ; 0x35 -.db 0x60,0x10,0x08,0x78,0x88,0x88,0x70,0x00, ; 0x36 -.db 0xF8,0x80,0x40,0x20,0x10,0x10,0x10,0x00, ; 0x37 -.db 0x70,0x88,0x88,0x70,0x88,0x88,0x70,0x00, ; 0x38 -.db 0x70,0x88,0x88,0xF0,0x80,0x40,0x30,0x00, ; 0x39 -.db 0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x00, ; 0x3A -.db 0x00,0x00,0x30,0x30,0x00,0x30,0x30,0x10, ; 0x3B -.db 0x40,0x20,0x10,0x08,0x10,0x20,0x40,0x00, ; 0x3C -.db 0x00,0x00,0xF8,0x00,0x00,0xF8,0x00,0x00, ; 0x3D -.db 0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x00, ; 0x3E -.db 0x70,0x88,0x80,0x60,0x20,0x00,0x20,0x00, ; 0x3F -.db 0x70,0x88,0xE8,0xA8,0xE8,0x08,0x70,0x00, ; 0x40 -.db 0x70,0x88,0x88,0x88,0xF8,0x88,0x88,0x00, ; 0x41 -.db 0x78,0x88,0x88,0x78,0x88,0x88,0x78,0x00, ; 0x42 -.db 0x70,0x88,0x08,0x08,0x08,0x88,0x70,0x00, ; 0x43 -.db 0x78,0x88,0x88,0x88,0x88,0x88,0x78,0x00, ; 0x44 -.db 0xF8,0x08,0x08,0x78,0x08,0x08,0xF8,0x00, ; 0x45 -.db 0xF8,0x08,0x08,0x78,0x08,0x08,0x08,0x00, ; 0x46 -.db 0x70,0x88,0x08,0xE8,0x88,0x88,0xF0,0x00, ; 0x47 -.db 0x88,0x88,0x88,0xF8,0x88,0x88,0x88,0x00, ; 0x48 -.db 0x70,0x20,0x20,0x20,0x20,0x20,0x70,0x00, ; 0x49 -.db 0x80,0x80,0x80,0x80,0x88,0x88,0x70,0x00, ; 0x4A -.db 0x88,0x48,0x28,0x18,0x28,0x48,0x88,0x00, ; 0x4B -.db 0x08,0x08,0x08,0x08,0x08,0x08,0xF8,0x00, ; 0x4C -.db 0x88,0xD8,0xA8,0x88,0x88,0x88,0x88,0x00, ; 0x4D -.db 0x88,0x98,0xA8,0xC8,0x88,0x88,0x88,0x00, ; 0x4E -.db 0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x00, ; 0x4F -.db 0x78,0x88,0x88,0x78,0x08,0x08,0x08,0x00, ; 0x50 -.db 0x70,0x88,0x88,0x88,0xA8,0x48,0xB0,0x00, ; 0x51 -.db 0x78,0x88,0x88,0x78,0x48,0x88,0x88,0x00, ; 0x52 -.db 0x70,0x88,0x08,0x70,0x80,0x88,0x70,0x00, ; 0x53 -.db 0xF8,0x20,0x20,0x20,0x20,0x20,0x20,0x00, ; 0x54 -.db 0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00, ; 0x55 -.db 0x88,0x88,0x88,0x88,0x88,0x50,0x20,0x00, ; 0x56 -.db 0x88,0x88,0xA8,0xA8,0xA8,0xA8,0x50,0x00, ; 0x57 -.db 0x88,0x88,0x50,0x20,0x50,0x88,0x88,0x00, ; 0x58 -.db 0x88,0x88,0x88,0x50,0x20,0x20,0x20,0x00, ; 0x59 -.db 0x78,0x40,0x20,0x10,0x08,0x08,0x78,0x00, ; 0x5A -.db 0x70,0x10,0x10,0x10,0x10,0x10,0x70,0x00, ; 0x5B -.db 0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00, ; 0x5C -.db 0x70,0x40,0x40,0x40,0x40,0x40,0x70,0x00, ; 0x5D -.db 0x20,0x50,0x88,0x00,0x00,0x00,0x00,0x00, ; 0x5E -.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC, ; 0x5F -.db 0x30,0x30,0x20,0x00,0x00,0x00,0x00,0x00, ; 0x60 -#endif - - +.db 0x00,0x00,0x1C,0x20,0x3C,0x22,0x3C,0x00, ; 0x61 +.db 0x02,0x02,0x1E,0x22,0x22,0x22,0x1E,0x00, ; 0x62 +.db 0x00,0x00,0x1C,0x22,0x02,0x22,0x1C,0x00, ; 0x63 +.db 0x20,0x20,0x3C,0x22,0x22,0x22,0x3C,0x00, ; 0x64 +.db 0x00,0x00,0x1C,0x22,0x1E,0x02,0x1C,0x00, ; 0x65 +.db 0x18,0x04,0x04,0x1E,0x04,0x04,0x04,0x00, ; 0x66 +.db 0x00,0x00,0x3C,0x22,0x22,0x3C,0x20,0x1C, ; 0x67 +.db 0x02,0x02,0x0E,0x12,0x12,0x12,0x12,0x00, ; 0x68 +.db 0x08,0x00,0x08,0x08,0x08,0x08,0x18,0x00, ; 0x69 +.db 0x10,0x00,0x18,0x10,0x10,0x10,0x12,0x0C, ; 0x6A +.db 0x02,0x02,0x12,0x0A,0x06,0x0A,0x12,0x00, ; 0x6B +.db 0x08,0x08,0x08,0x08,0x08,0x08,0x18,0x00, ; 0x6C +.db 0x00,0x00,0x16,0x2A,0x2A,0x22,0x22,0x00, ; 0x6D +.db 0x00,0x00,0x0E,0x12,0x12,0x12,0x12,0x00, ; 0x6E +.db 0x00,0x00,0x1C,0x22,0x22,0x22,0x1C,0x00, ; 0x6F +.db 0x00,0x00,0x1E,0x22,0x22,0x22,0x1E,0x02, ; 0x70 +.db 0x00,0x00,0x3C,0x22,0x22,0x22,0x3C,0x20, ; 0x71 +.db 0x00,0x00,0x1A,0x24,0x04,0x04,0x0E,0x00, ; 0x72 +.db 0x00,0x00,0x1C,0x02,0x1C,0x20,0x1C,0x00, ; 0x73 +.db 0x00,0x04,0x1E,0x04,0x04,0x14,0x08,0x00, ; 0x74 +.db 0x00,0x00,0x12,0x12,0x12,0x1A,0x14,0x00, ; 0x75 +.db 0x00,0x00,0x22,0x22,0x22,0x14,0x08,0x00, ; 0x76 +.db 0x00,0x00,0x22,0x22,0x2A,0x3E,0x14,0x00, ; 0x77 +.db 0x00,0x00,0x12,0x12,0x0C,0x12,0x12,0x00, ; 0x78 +.db 0x00,0x00,0x12,0x12,0x12,0x1C,0x08,0x06, ; 0x79 +.db 0x00,0x00,0x1E,0x10,0x0C,0x02,0x1E,0x00, ; 0x7A +.db 0x18,0x04,0x04,0x06,0x04,0x04,0x18,0x00, ; 0x7B +.db 0x08,0x08,0x08,0x00,0x08,0x08,0x08,0x00, ; 0x7C +.db 0x0C,0x10,0x10,0x30,0x10,0x10,0x0C,0x00, ; 0x7D +.db 0x14,0x0A,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x7E +.db 0x08,0x1C,0x36,0x22,0x22,0x3E,0x00,0x00, ; 0x7F +.db 0x1C,0x22,0x02,0x02,0x22,0x1C,0x08,0x0C, ; 0x80 +.db 0x12,0x00,0x12,0x12,0x12,0x1A,0x14,0x00, ; 0x81 +.db 0x30,0x00,0x1C,0x22,0x1E,0x02,0x1C,0x00, ; 0x82 +.db 0x1C,0x00,0x1C,0x20,0x3C,0x22,0x3C,0x00, ; 0x83 +.db 0x14,0x00,0x1C,0x20,0x3C,0x22,0x3C,0x00, ; 0x84 +.db 0x0C,0x00,0x1C,0x20,0x3C,0x22,0x3C,0x00, ; 0x85 +.db 0x1C,0x14,0x1C,0x20,0x3C,0x22,0x3C,0x00, ; 0x86 +.db 0x00,0x1C,0x22,0x02,0x22,0x1C,0x08,0x0C, ; 0x87 +.db 0x1C,0x00,0x1C,0x22,0x1E,0x02,0x1C,0x00, ; 0x88 +.db 0x14,0x00,0x1C,0x22,0x1E,0x02,0x1C,0x00, ; 0x89 +.db 0x0C,0x00,0x1C,0x22,0x1E,0x02,0x1C,0x00, ; 0x8A +.db 0x14,0x00,0x08,0x08,0x08,0x08,0x18,0x00, ; 0x8B +.db 0x1C,0x00,0x08,0x08,0x08,0x08,0x18,0x00, ; 0x8C +.db 0x04,0x00,0x08,0x08,0x08,0x08,0x18,0x00, ; 0x8D +.db 0x14,0x00,0x08,0x14,0x22,0x3E,0x22,0x00, ; 0x8E +.db 0x1C,0x14,0x1C,0x36,0x22,0x3E,0x22,0x00, ; 0x8F +.db 0x30,0x00,0x3E,0x02,0x1E,0x02,0x3E,0x00, ; 0x90 +.db 0x00,0x00,0x1E,0x28,0x3E,0x0A,0x3C,0x00, ; 0x91 +.db 0x3C,0x0A,0x0A,0x3E,0x0A,0x0A,0x3A,0x00, ; 0x92 +.db 0x1C,0x00,0x0C,0x12,0x12,0x12,0x0C,0x00, ; 0x93 +.db 0x14,0x00,0x0C,0x12,0x12,0x12,0x0C,0x00, ; 0x94 +.db 0x06,0x00,0x0C,0x12,0x12,0x12,0x0C,0x00, ; 0x95 +.db 0x1C,0x00,0x12,0x12,0x12,0x1A,0x14,0x00, ; 0x96 +.db 0x06,0x00,0x12,0x12,0x12,0x1A,0x14,0x00, ; 0x97 +.db 0x14,0x00,0x12,0x12,0x12,0x1C,0x08,0x06, ; 0x98 +.db 0x12,0x0C,0x12,0x12,0x12,0x12,0x0C,0x00, ; 0x99 +.db 0x14,0x00,0x12,0x12,0x12,0x12,0x0C,0x00, ; 0x9A +.db 0x00,0x00,0x20,0x1C,0x1A,0x16,0x0E,0x01, ; 0x9B +.db 0x18,0x24,0x04,0x1E,0x04,0x24,0x3A,0x00, ; 0x9C +.db 0x3C,0x32,0x2A,0x2A,0x2A,0x26,0x1E,0x00, ; 0x9D +.db 0x00,0x22,0x14,0x08,0x14,0x22,0x00,0x00, ; 0x9E +.db 0x10,0x28,0x08,0x1C,0x08,0x08,0x0A,0x04, ; 0x9F +.db 0x18,0x00,0x1C,0x20,0x3C,0x22,0x3C,0x00, ; 0xA0 +.db 0x18,0x00,0x08,0x08,0x08,0x08,0x18,0x00, ; 0xA1 +.db 0x18,0x00,0x0C,0x12,0x12,0x12,0x0C,0x00, ; 0xA2 +.db 0x18,0x00,0x12,0x12,0x12,0x1A,0x14,0x00, ; 0xA3 +.db 0x14,0x0A,0x00,0x0E,0x12,0x12,0x12,0x00, ; 0xA4 +.db 0x14,0x0A,0x00,0x12,0x16,0x1A,0x12,0x00, ; 0xA5 +.db 0x1C,0x20,0x3C,0x22,0x3C,0x00,0x3C,0x00, ; 0xA6 +.db 0x0C,0x12,0x12,0x12,0x0C,0x00,0x1E,0x00, ; 0xA7 +.db 0x08,0x00,0x08,0x0C,0x02,0x22,0x1C,0x00, ; 0xA8 +.db 0x1E,0x29,0x35,0x2D,0x35,0x21,0x1E,0x00, ; 0xA9 +.db 0x00,0x00,0x3F,0x20,0x20,0x00,0x00,0x00, ; 0xAA +.db 0x02,0x12,0x0A,0x1C,0x22,0x10,0x38,0x00, ; 0xAB +.db 0x02,0x12,0x0A,0x34,0x2A,0x38,0x20,0x00, ; 0xAC +.db 0x08,0x00,0x08,0x08,0x1C,0x1C,0x08,0x00, ; 0xAD +.db 0x00,0x00,0x24,0x12,0x24,0x00,0x00,0x00, ; 0xAE +.db 0x00,0x00,0x12,0x24,0x12,0x00,0x00,0x00, ; 0xAF +.db 0x2A,0x00,0x15,0x00,0x2A,0x00,0x15,0x00, ; 0xB0 +.db 0x2A,0x15,0x2A,0x15,0x2A,0x15,0x2A,0x15, ; 0xB1 +.db 0x15,0x3F,0x2A,0x3F,0x15,0x3F,0x2A,0x3F, ; 0xB2 +.db 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08, ; 0xB3 +.db 0x08,0x08,0x08,0x0F,0x08,0x08,0x08,0x08, ; 0xB4 +.db 0x18,0x00,0x08,0x14,0x22,0x3E,0x22,0x00, ; 0xB5 +.db 0x1C,0x00,0x08,0x14,0x22,0x3E,0x22,0x00, ; 0xB6 +.db 0x0C,0x00,0x08,0x14,0x22,0x3E,0x22,0x00, ; 0xB7 +.db 0x1E,0x21,0x2D,0x25,0x2D,0x21,0x1E,0x00, ; 0xB8 +.db 0x0A,0x0B,0x08,0x0B,0x0A,0x0A,0x0A,0x0A, ; 0xB9 +.db 0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A, ; 0xBA +.db 0x00,0x0F,0x08,0x0B,0x0A,0x0A,0x0A,0x0A, ; 0xBB +.db 0x0A,0x0B,0x08,0x0F,0x00,0x00,0x00,0x00, ; 0xBC +.db 0x00,0x08,0x1C,0x02,0x02,0x1C,0x08,0x00, ; 0xBD +.db 0x22,0x14,0x08,0x3E,0x08,0x3E,0x08,0x00, ; 0xBE +.db 0x00,0x00,0x00,0x0F,0x08,0x08,0x08,0x08, ; 0xBF +.db 0x08,0x08,0x08,0x38,0x00,0x00,0x00,0x00, ; 0xC0 +.db 0x08,0x08,0x08,0x3F,0x00,0x00,0x00,0x00, ; 0xC1 +.db 0x00,0x00,0x00,0x3F,0x08,0x08,0x08,0x08, ; 0xC2 +.db 0x08,0x08,0x08,0x38,0x08,0x08,0x08,0x08, ; 0xC3 +.db 0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00, ; 0xC4 +.db 0x08,0x08,0x08,0x3F,0x08,0x08,0x08,0x08, ; 0xC5 +.db 0x28,0x14,0x1C,0x20,0x3C,0x22,0x3C,0x00, ; 0xC6 +.db 0x28,0x14,0x08,0x14,0x22,0x3E,0x22,0x00, ; 0xC7 +.db 0x0A,0x3A,0x02,0x3E,0x00,0x00,0x00,0x00, ; 0xC8 +.db 0x00,0x3E,0x02,0x3A,0x0A,0x0A,0x0A,0x0A, ; 0xC9 +.db 0x0A,0x3B,0x00,0x3F,0x00,0x00,0x00,0x00, ; 0xCA +.db 0x00,0x3F,0x00,0x3B,0x0A,0x0A,0x0A,0x0A, ; 0xCB +.db 0x0A,0x3A,0x02,0x3A,0x0A,0x0A,0x0A,0x0A, ; 0xCC +.db 0x00,0x3F,0x00,0x3F,0x00,0x00,0x00,0x00, ; 0xCD +.db 0x0A,0x3B,0x00,0x3B,0x0A,0x0A,0x0A,0x0A, ; 0xCE +.db 0x22,0x1C,0x22,0x22,0x22,0x1C,0x22,0x00, ; 0xCF +.db 0x0C,0x02,0x04,0x08,0x1C,0x12,0x0C,0x00, ; 0xD0 +.db 0x1C,0x24,0x24,0x2E,0x24,0x24,0x1C,0x00, ; 0xD1 +.db 0x1C,0x00,0x3E,0x02,0x1E,0x02,0x3E,0x00, ; 0xD2 +.db 0x14,0x00,0x3E,0x02,0x1E,0x02,0x3E,0x00, ; 0xD3 +.db 0x0C,0x00,0x3E,0x02,0x1E,0x02,0x3E,0x00, ; 0xD4 +.db 0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00, ; 0xD5 +.db 0x18,0x00,0x1C,0x08,0x08,0x08,0x1C,0x00, ; 0xD6 +.db 0x1C,0x00,0x1C,0x08,0x08,0x08,0x1C,0x00, ; 0xD7 +.db 0x14,0x00,0x1C,0x08,0x08,0x08,0x1C,0x00, ; 0xD8 +.db 0x08,0x08,0x08,0x0F,0x00,0x00,0x00,0x00, ; 0xD9 +.db 0x00,0x00,0x00,0x38,0x08,0x08,0x08,0x08, ; 0xDA +.db 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F, ; 0xDB +.db 0x00,0x00,0x00,0x00,0x3F,0x3F,0x3F,0x3F, ; 0xDC +.db 0x08,0x08,0x08,0x00,0x08,0x08,0x08,0x00, ; 0xDD +.db 0x0C,0x00,0x1C,0x08,0x08,0x08,0x1C,0x00, ; 0xDE +.db 0x3F,0x3F,0x3F,0x3F,0x00,0x00,0x00,0x00, ; 0xDF +.db 0x18,0x0C,0x12,0x12,0x12,0x12,0x0C,0x00, ; 0xE0 +.db 0x00,0x0E,0x12,0x0E,0x12,0x12,0x0E,0x02, ; 0xE1 +.db 0x1C,0x0C,0x12,0x12,0x12,0x12,0x0C,0x00, ; 0xE2 +.db 0x06,0x0C,0x12,0x12,0x12,0x12,0x0C,0x00, ; 0xE3 +.db 0x14,0x0A,0x00,0x0C,0x12,0x12,0x0C,0x00, ; 0xE4 +.db 0x14,0x0A,0x0C,0x12,0x12,0x12,0x0C,0x00, ; 0xE5 +.db 0x00,0x00,0x12,0x12,0x12,0x0E,0x02,0x02, ; 0xE6 +.db 0x00,0x06,0x02,0x0E,0x12,0x0E,0x02,0x06, ; 0xE7 +.db 0x06,0x02,0x0E,0x12,0x12,0x0E,0x02,0x06, ; 0xE8 +.db 0x18,0x00,0x12,0x12,0x12,0x12,0x0C,0x00, ; 0xE9 +.db 0x1C,0x00,0x12,0x12,0x12,0x12,0x0C,0x00, ; 0xEA +.db 0x06,0x00,0x12,0x12,0x12,0x12,0x0C,0x00, ; 0xEB +.db 0x18,0x00,0x12,0x12,0x12,0x1C,0x08,0x06, ; 0xEC +.db 0x18,0x00,0x22,0x14,0x08,0x08,0x08,0x00, ; 0xED +.db 0x00,0x1C,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xEE +.db 0x0C,0x0C,0x04,0x00,0x00,0x00,0x00,0x00, ; 0xEF +.db 0x00,0x00,0x00,0x1C,0x00,0x00,0x00,0x00, ; 0xF0 +.db 0x00,0x08,0x1C,0x08,0x00,0x1C,0x00,0x00, ; 0xF1 +.db 0x00,0x00,0x3E,0x00,0x00,0x3E,0x00,0x00, ; 0xF2 +.db 0x03,0x16,0x0B,0x34,0x2A,0x38,0x20,0x00, ; 0xF3 +.db 0x3C,0x2A,0x2A,0x2C,0x28,0x28,0x28,0x00, ; 0xF4 +.db 0x1C,0x22,0x0C,0x14,0x18,0x22,0x1C,0x00, ; 0xF5 +.db 0x00,0x08,0x00,0x3E,0x00,0x08,0x00,0x00, ; 0xF6 +.db 0x00,0x00,0x00,0x1C,0x18,0x00,0x00,0x00, ; 0xF7 +.db 0x0C,0x12,0x12,0x0C,0x00,0x00,0x00,0x00, ; 0xF8 +.db 0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x00, ; 0xF9 +.db 0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00, ; 0xFA +.db 0x04,0x06,0x04,0x04,0x00,0x00,0x00,0x00, ; 0xFB +.db 0x0E,0x04,0x0C,0x06,0x00,0x00,0x00,0x00, ; 0xFC +.db 0x06,0x08,0x04,0x0E,0x00,0x00,0x00,0x00, ; 0xFD +.db 0x00,0x00,0x1E,0x1E,0x1E,0x1E,0x00,0x00, ; 0xFE +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ; 0xFF diff --git a/avr/modules/lcd2/font/font3.asm b/avr/modules/lcd2/font/font3.asm new file mode 100644 index 0000000..8a816d3 --- /dev/null +++ b/avr/modules/lcd2/font/font3.asm @@ -0,0 +1,257 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + +; *************************************************************************** +; This is a font from the project LCD_fonts at +; https://github.com/basti79/LCD-fonts.git +; which in turn is based on a post by Benedikt K. in a forum post on +; https://www.mikrocontroller.net/topic/54860 +; *************************************************************************** + + + +; *************************************************************************** +; code + +.cseg + + + +font3_16x26: +; header + .dw font16x26MonoRenderCharacter ; renderFn + .dw 832 ; needed buffer size + .db 16, 26 ; width, height of chars + .db 32, 224 ; first char, num of chars in font +; data (16x26_horizontal_LSB_2) +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x20 +.db 0x00,0x00,0x00,0x00,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x00,0x00,0x00,0x00,0x80,0x03,0x80,0x03,0x80,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x21 +.db 0x00,0x00,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x10,0x04,0x10,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x22 +.db 0x00,0x00,0x00,0x00,0x80,0x31,0x80,0x31,0xC0,0x18,0xC0,0x18,0xC0,0x18,0xC0,0x18,0xFC,0x7F,0xFC,0x7F,0x60,0x0C,0x60,0x06,0x30,0x06,0xFE,0x3F,0xFE,0x3F,0x18,0x03,0x18,0x03,0x18,0x03,0x18,0x03,0x8C,0x01,0x8C,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x23 +.db 0x00,0x03,0x00,0x03,0xC0,0x1F,0xF0,0x3F,0x70,0x23,0x38,0x03,0x38,0x03,0x38,0x03,0x78,0x03,0xF0,0x03,0xE0,0x03,0x80,0x07,0x00,0x1F,0x00,0x1F,0x00,0x3B,0x00,0x3B,0x00,0x3B,0x00,0x3B,0x18,0x1B,0xF8,0x1F,0xE0,0x0F,0x00,0x03,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x24 +.db 0x00,0x00,0x00,0x00,0x3C,0xC0,0x66,0x60,0xC3,0x30,0xC3,0x18,0xC3,0x18,0xC3,0x0C,0xC3,0x06,0x66,0x03,0x3C,0x03,0x80,0x01,0xC0,0x3C,0xC0,0x66,0x60,0xC3,0x30,0xC3,0x18,0xC3,0x18,0xC3,0x0C,0xC3,0x06,0x66,0x03,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x25 +.db 0x00,0x00,0x00,0x00,0xE0,0x03,0xF0,0x07,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x06,0x70,0x07,0xF0,0x01,0xF8,0x00,0xFC,0xE0,0xCE,0xE1,0xC7,0xE3,0x87,0x63,0x07,0x67,0x07,0x7E,0x0F,0x3E,0x1E,0x3C,0xFC,0x7F,0xF0,0xF3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x26 +.db 0x00,0x00,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0x80,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x27 +.db 0x00,0x00,0x00,0x18,0x00,0x1E,0x00,0x0F,0x80,0x03,0xC0,0x01,0xE0,0x00,0xE0,0x00,0xE0,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xC0,0x01,0x80,0x03,0x00,0x0F,0x00,0x1E,0x00,0x18,0x00,0x00, ; 0x28 +.db 0x00,0x00,0x0C,0x00,0x3C,0x00,0x78,0x00,0xE0,0x00,0xC0,0x01,0x80,0x03,0x80,0x03,0x80,0x03,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x80,0x03,0x80,0x03,0x80,0x03,0xC0,0x01,0xE0,0x00,0x78,0x00,0x3C,0x00,0x0C,0x00,0x00,0x00, ; 0x29 +.db 0x00,0x00,0x00,0x00,0x80,0x03,0x80,0x03,0x80,0x03,0x98,0x1B,0x7C,0x3E,0x30,0x0C,0x40,0x02,0xE0,0x07,0x70,0x0E,0x38,0x1C,0x20,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x2A +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0xFE,0x7F,0xFE,0x7F,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x2B +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0x00,0x03,0x80,0x03,0x80,0x01,0xC0,0x00,0x00,0x00, ; 0x2C +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x1F,0xF8,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x2D +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x2E +.db 0x00,0x00,0x00,0x60,0x00,0x30,0x00,0x30,0x00,0x18,0x00,0x18,0x00,0x0C,0x00,0x0C,0x00,0x06,0x00,0x06,0x00,0x03,0x00,0x03,0x80,0x01,0x80,0x01,0xC0,0x00,0xC0,0x00,0x60,0x00,0x60,0x00,0x30,0x00,0x30,0x00,0x18,0x00,0x18,0x00,0x0C,0x00,0x0C,0x00,0x06,0x00,0x00,0x00, ; 0x2F +.db 0x00,0x00,0x00,0x00,0xE0,0x03,0xF0,0x07,0x38,0x0E,0x1C,0x1C,0x1C,0x1C,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x1C,0x1C,0x1C,0x1C,0x38,0x0E,0xF0,0x07,0xE0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x30 +.db 0x00,0x00,0x00,0x00,0x00,0x03,0xE0,0x03,0xFC,0x03,0x8C,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0xFC,0x7F,0xFC,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x31 +.db 0x00,0x00,0x00,0x00,0xF0,0x03,0xFC,0x07,0x0C,0x0E,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x0E,0x00,0x0E,0x00,0x07,0x80,0x03,0xC0,0x01,0xE0,0x00,0x70,0x00,0x30,0x00,0x38,0x00,0x1C,0x00,0xFC,0x1F,0xFC,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x32 +.db 0x00,0x00,0x00,0x00,0xF0,0x03,0xF8,0x0F,0x08,0x1E,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x0C,0x00,0x06,0xE0,0x03,0xE0,0x07,0x00,0x0F,0x00,0x1E,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1E,0x08,0x0F,0xF8,0x07,0xF8,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x33 +.db 0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x0F,0x80,0x0F,0x80,0x0F,0xC0,0x0E,0xE0,0x0E,0x60,0x0E,0x30,0x0E,0x18,0x0E,0x18,0x0E,0x0C,0x0E,0x06,0x0E,0xFE,0x7F,0xFE,0x7F,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x34 +.db 0x00,0x00,0x00,0x00,0xF0,0x3F,0xF0,0x3F,0xF0,0x3F,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0xF0,0x03,0xF0,0x0F,0x00,0x1E,0x00,0x3C,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x3C,0x10,0x1E,0xF0,0x0F,0xF0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x35 +.db 0x00,0x00,0x00,0x00,0x80,0x1F,0xE0,0x3F,0xF0,0x20,0x70,0x00,0x38,0x00,0x38,0x00,0x1C,0x00,0x9C,0x0F,0xDC,0x1F,0x7C,0x3C,0x3C,0x78,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x38,0x70,0x38,0x38,0x70,0x38,0xF0,0x1F,0xC0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x36 +.db 0x00,0x00,0x00,0x00,0xF8,0x3F,0xF8,0x3F,0xF8,0x3F,0x00,0x18,0x00,0x18,0x00,0x0C,0x00,0x0C,0x00,0x06,0x00,0x02,0x00,0x03,0x80,0x01,0x80,0x01,0xC0,0x00,0xC0,0x00,0x60,0x00,0x60,0x00,0x70,0x00,0x30,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x37 +.db 0x00,0x00,0x00,0x00,0xC0,0x07,0xF0,0x0F,0x78,0x1E,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x78,0x0C,0xF0,0x0F,0xE0,0x03,0xF0,0x0F,0x38,0x1F,0x18,0x1E,0x1C,0x3C,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x38,0x1C,0xF0,0x0F,0xE0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x38 +.db 0x00,0x00,0x00,0x00,0xC0,0x07,0xF0,0x1F,0x38,0x1C,0x38,0x38,0x1C,0x38,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x3C,0x78,0x78,0x7C,0xF0,0x77,0xE0,0x73,0x00,0x70,0x00,0x38,0x00,0x38,0x00,0x1C,0x08,0x1E,0xF8,0x0F,0xF0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x39 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x3A +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0xC0,0x03,0xC0,0x03,0xC0,0x03,0x00,0x03,0x80,0x03,0x80,0x01,0xC0,0x00,0x00,0x00, ; 0x3B +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x70,0x00,0x3C,0x00,0x0F,0xC0,0x03,0xF0,0x00,0x3C,0x00,0x3C,0x00,0xF0,0x00,0xC0,0x03,0x00,0x0F,0x00,0x3C,0x00,0x70,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x3C +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x7F,0xFE,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x7F,0xFE,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x3D +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x0E,0x00,0x3C,0x00,0xF0,0x00,0xC0,0x03,0x00,0x0F,0x00,0x3C,0x00,0x3C,0x00,0x0F,0xC0,0x03,0xF0,0x00,0x3C,0x00,0x0E,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x3E +.db 0x00,0x00,0x00,0x00,0xF8,0x07,0xFC,0x1F,0x0C,0x3C,0x0C,0x38,0x00,0x38,0x00,0x38,0x00,0x1C,0x00,0x1E,0x00,0x0F,0x80,0x07,0x80,0x03,0xC0,0x01,0xC0,0x01,0xC0,0x01,0x00,0x00,0x00,0x00,0xC0,0x01,0xC0,0x01,0xC0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x3F +.db 0x00,0x00,0x00,0x00,0xC0,0x0F,0xE0,0x1F,0x70,0x38,0x18,0x30,0x1C,0x3E,0x0C,0x31,0x8E,0x31,0xC6,0x30,0xC6,0x30,0xC6,0x38,0xC6,0x38,0xC6,0x3C,0xC6,0x34,0x8E,0xF7,0x8C,0xF3,0x1C,0x00,0x38,0x08,0xF0,0x0F,0xC0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x40 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x01,0xC0,0x03,0xE0,0x03,0x60,0x07,0x60,0x07,0x70,0x06,0x30,0x0E,0x38,0x0E,0x38,0x1C,0x18,0x1C,0xFC,0x3F,0xFC,0x3F,0x0E,0x38,0x0E,0x70,0x0E,0x70,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x41 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x07,0xFC,0x0F,0x1C,0x1E,0x1C,0x1C,0x1C,0x1C,0x1C,0x0E,0xFC,0x07,0xFC,0x07,0x1C,0x1E,0x1C,0x3C,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x3C,0xFC,0x1F,0xFC,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x42 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x1F,0xF0,0x3F,0x78,0x30,0x3C,0x00,0x1C,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x1C,0x00,0x3C,0x00,0x78,0x20,0xF0,0x3F,0xC0,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x43 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x07,0xFC,0x0F,0x1C,0x3C,0x1C,0x38,0x1C,0x78,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x38,0x1C,0x38,0x1C,0x1E,0xFC,0x0F,0xFC,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x44 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x3F,0xF8,0x3F,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0xF8,0x1F,0xF8,0x1F,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0xF8,0x7F,0xF8,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x45 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x7F,0xF8,0x7F,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0xF8,0x3F,0xF8,0x3F,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x46 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x1F,0xF0,0x3F,0x78,0x30,0x3C,0x00,0x1C,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x3F,0x0E,0x3F,0x0E,0x38,0x1C,0x38,0x3C,0x38,0x78,0x38,0xF0,0x3F,0xC0,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x47 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0xFC,0x3F,0xFC,0x3F,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x48 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x1F,0xFC,0x1F,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xFC,0x1F,0xFC,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x49 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x0F,0xF8,0x0F,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x04,0x07,0xFC,0x03,0xFC,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x4A +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x78,0x1C,0x3C,0x1C,0x1E,0x1C,0x0F,0x1C,0x07,0x9C,0x03,0xDC,0x01,0xFC,0x00,0xDC,0x01,0xDC,0x03,0x9C,0x07,0x1C,0x0F,0x1C,0x1E,0x1C,0x3C,0x1C,0x78,0x1C,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x4B +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0xF8,0x3F,0xF8,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x4C +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x38,0x1E,0x3C,0x1E,0x3C,0x1E,0x3C,0x36,0x36,0x36,0x36,0x36,0x36,0x66,0x32,0x66,0x33,0x66,0x33,0xC6,0x31,0xC6,0x31,0xC6,0x31,0x06,0x30,0x06,0x30,0x06,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x4D +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x30,0x1C,0x30,0x3C,0x30,0x7C,0x30,0x7C,0x30,0xFC,0x30,0xEC,0x31,0xCC,0x31,0xCC,0x33,0x8C,0x37,0x0C,0x3F,0x0C,0x3E,0x0C,0x3E,0x0C,0x3C,0x0C,0x38,0x0C,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x4E +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x07,0xF0,0x0F,0x38,0x1C,0x1C,0x38,0x1C,0x38,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x1C,0x38,0x1C,0x38,0x38,0x1C,0xF0,0x0F,0xE0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x4F +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x1F,0xF8,0x3F,0x38,0x78,0x38,0x70,0x38,0x70,0x38,0x70,0x38,0x78,0x38,0x3C,0xF8,0x1F,0xF8,0x07,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x50 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x07,0xF0,0x0F,0x38,0x1C,0x1C,0x38,0x1C,0x38,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x1C,0x38,0x1C,0x38,0x38,0x1C,0xF0,0x0F,0xE0,0x07,0x00,0x1E,0x00,0x78,0x00,0xF0,0x00,0x40,0x00,0x00, ; 0x51 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x07,0xFC,0x0F,0x1C,0x1E,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x0E,0xFC,0x07,0xFC,0x03,0x9C,0x07,0x1C,0x07,0x1C,0x0F,0x1C,0x1E,0x1C,0x3C,0x1C,0x38,0x1C,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x52 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x0F,0xF8,0x1F,0x3C,0x18,0x1C,0x00,0x1C,0x00,0x3C,0x00,0xF8,0x00,0xF0,0x07,0xC0,0x1F,0x00,0x3E,0x00,0x38,0x00,0x38,0x00,0x38,0x0C,0x1C,0xFC,0x1F,0xF0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x53 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x7F,0xFF,0x7F,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x54 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x3C,0x78,0x38,0x38,0xF0,0x1F,0xE0,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x55 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xE0,0x0E,0x70,0x0E,0x70,0x1C,0x70,0x1C,0x38,0x3C,0x38,0x38,0x38,0x38,0x1C,0x70,0x1C,0x70,0x0C,0xE0,0x0E,0xE0,0x0E,0xE0,0x07,0xC0,0x07,0xC0,0x07,0x80,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x56 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x03,0xC0,0x07,0xC0,0x86,0x61,0xC6,0x63,0xC6,0x63,0xC6,0x63,0xC6,0x63,0x4E,0x76,0x6C,0x36,0x6C,0x36,0x6C,0x36,0x2C,0x3E,0x3C,0x3C,0x3C,0x1C,0x3C,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x57 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0xE0,0x3C,0x70,0x78,0x38,0x78,0x1C,0xF0,0x0E,0xE0,0x07,0xC0,0x03,0xC0,0x03,0xC0,0x07,0xE0,0x07,0x60,0x0F,0x30,0x1E,0x18,0x3C,0x1C,0x38,0x0E,0x78,0x07,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x58 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xE0,0x0E,0x70,0x1C,0x30,0x1C,0x18,0x38,0x1C,0x78,0x0E,0x70,0x07,0xE0,0x03,0xE0,0x03,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x59 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x3F,0xFC,0x3F,0x00,0x38,0x00,0x1C,0x00,0x0E,0x00,0x07,0x80,0x03,0x80,0x01,0xC0,0x00,0xE0,0x00,0x70,0x00,0x38,0x00,0x1C,0x00,0x0E,0x00,0xFE,0x3F,0xFE,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x5A +.db 0x00,0x00,0xC0,0x3F,0xC0,0x3F,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x3F,0xC0,0x3F,0x00,0x00, ; 0x5B +.db 0x00,0x00,0x06,0x00,0x0C,0x00,0x0C,0x00,0x18,0x00,0x18,0x00,0x30,0x00,0x30,0x00,0x60,0x00,0x60,0x00,0xC0,0x00,0xC0,0x00,0x80,0x01,0x80,0x01,0x00,0x03,0x00,0x03,0x00,0x06,0x00,0x06,0x00,0x0C,0x00,0x0C,0x00,0x18,0x00,0x18,0x00,0x30,0x00,0x30,0x00,0x60,0x00,0x00, ; 0x5C +.db 0x00,0x00,0xFC,0x03,0xFC,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0xFC,0x03,0xFC,0x03,0x00,0x00, ; 0x5D +.db 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x80,0x03,0x80,0x03,0xC0,0x03,0xC0,0x06,0xE0,0x06,0x60,0x0C,0x30,0x0C,0x30,0x18,0x18,0x18,0x18,0x18,0x0C,0x30,0x0C,0x30,0x06,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x5E +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x5F +.db 0xC0,0x01,0x80,0x03,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x60 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x07,0xF8,0x0F,0x18,0x1E,0x00,0x1C,0x00,0x1C,0xE0,0x1F,0xF0,0x1F,0x38,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x3C,0x1E,0xF8,0x7B,0xF0,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x61 +.db 0x00,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x9C,0x07,0xDC,0x1F,0x7C,0x1C,0x3C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x1C,0x3C,0x1E,0xFC,0x0F,0xCC,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x62 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x1F,0xF0,0x3F,0x78,0x20,0x38,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x3C,0x00,0x38,0x00,0xF8,0x20,0xF0,0x3F,0xC0,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x63 +.db 0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0xC0,0x73,0xF0,0x7F,0x78,0x7C,0x38,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x3C,0x78,0x38,0x7C,0xF0,0x77,0xE0,0x73,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x64 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x07,0xF0,0x0F,0x78,0x1C,0x38,0x38,0x1C,0x38,0x1C,0x38,0xFC,0x3F,0xFC,0x3F,0x1C,0x00,0x1C,0x00,0x38,0x00,0x78,0x20,0xF0,0x3F,0xC0,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x65 +.db 0x00,0x00,0x00,0xFF,0x80,0xFF,0xC0,0x03,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xFC,0x7F,0xFC,0x7F,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x66 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x73,0xF0,0x7F,0x78,0x7C,0x38,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x3C,0x78,0x38,0x7C,0xF0,0x77,0xE0,0x73,0x00,0x70,0x00,0x38,0x18,0x3C,0xF8,0x1F,0xF0,0x07, ; 0x67 +.db 0x00,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x0F,0xDC,0x1F,0x7C,0x3C,0x3C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x68 +.db 0x00,0x00,0x80,0x03,0x80,0x03,0x80,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x03,0xFC,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x69 +.db 0x00,0x00,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x0F,0xF8,0x0F,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x04,0x07,0xFC,0x07,0xF8,0x01, ; 0x6A +.db 0x00,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x3C,0x38,0x1E,0x38,0x0E,0x38,0x0F,0xB8,0x07,0xB8,0x03,0xF8,0x03,0xB8,0x03,0xB8,0x07,0x38,0x0F,0x38,0x0E,0x38,0x1E,0x38,0x3C,0x38,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x6B +.db 0x00,0x00,0xF8,0x07,0xF8,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x6C +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCE,0x31,0xEE,0x79,0xFE,0x7F,0x9E,0x77,0x9E,0x73,0x8E,0x73,0x8E,0x73,0x8E,0x73,0x8E,0x73,0x8E,0x73,0x8E,0x73,0x8E,0x73,0x8E,0x73,0x8E,0x73,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x6D +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x0F,0xDC,0x1F,0x7C,0x3C,0x3C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x6E +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x03,0xF8,0x0F,0x3C,0x1E,0x1C,0x1C,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x1C,0x1C,0x3C,0x1E,0xF8,0x0F,0xE0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x6F +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9C,0x07,0xDC,0x1F,0x7C,0x1C,0x3C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x1C,0x3C,0x1E,0xFC,0x0F,0x9C,0x07,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00, ; 0x70 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x39,0xF8,0x3F,0x3C,0x3E,0x1C,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x1E,0x3C,0x1C,0x3E,0xF8,0x3B,0xF0,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38, ; 0x71 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x3E,0x70,0x3F,0xF0,0x31,0xF0,0x30,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x72 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x0F,0xF0,0x1F,0x78,0x10,0x38,0x00,0x38,0x00,0xF8,0x01,0xF0,0x07,0x80,0x1F,0x00,0x3C,0x00,0x38,0x00,0x38,0x18,0x3C,0xF8,0x1F,0xF0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x73 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0xE0,0x00,0xFC,0x3F,0xFC,0x3F,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x01,0xC0,0x3F,0x80,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x74 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x3C,0x3C,0x3E,0xF8,0x3B,0xF0,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x75 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x70,0x1C,0x38,0x1C,0x38,0x3C,0x38,0x38,0x18,0x38,0x1C,0x70,0x1C,0x70,0x0C,0xE0,0x0E,0xE0,0x0E,0xE0,0x06,0xC0,0x07,0xC0,0x07,0x80,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x76 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x87,0xC3,0x87,0x43,0xC6,0x63,0xC6,0x63,0x46,0x62,0x6E,0x66,0x6E,0x26,0x6C,0x36,0x2C,0x36,0x3C,0x3C,0x3C,0x3C,0x3C,0x1C,0x18,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x77 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x30,0x3C,0x18,0x78,0x0C,0x70,0x0E,0xF0,0x06,0xE0,0x03,0xC0,0x03,0xC0,0x03,0xE0,0x07,0x70,0x0F,0x30,0x0E,0x38,0x1E,0x1C,0x3C,0x0E,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x78 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x70,0x1C,0x30,0x1C,0x38,0x38,0x18,0x38,0x1C,0x78,0x1C,0x70,0x0E,0xF0,0x0E,0xE0,0x07,0xE0,0x07,0xC0,0x03,0xC0,0x03,0xC0,0x01,0x80,0x01,0xC0,0x01,0xC0,0x00,0xE0,0x00,0x7C,0x00,0x3C,0x00, ; 0x79 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x3F,0xFC,0x3F,0x00,0x38,0x00,0x1C,0x00,0x0E,0x00,0x07,0x80,0x03,0xC0,0x01,0xE0,0x00,0x70,0x00,0x38,0x00,0x1C,0x00,0xFC,0x3F,0xFC,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x7A +.db 0x00,0x00,0x00,0x1F,0x80,0x1F,0xC0,0x03,0xC0,0x01,0xC0,0x01,0xC0,0x01,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0xC0,0x01,0xF8,0x00,0xF8,0x00,0xC0,0x01,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x03,0x80,0x1F,0x00,0x1F,0x00,0x00, ; 0x7B +.db 0x00,0x00,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x00,0x00, ; 0x7C +.db 0x00,0x00,0x7C,0x00,0xFC,0x00,0xE0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xC0,0x01,0x80,0x0F,0x80,0x0F,0xC0,0x01,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xE0,0x01,0xFC,0x00,0x7C,0x00,0x00,0x00, ; 0x7D +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x60,0xFC,0x63,0xC6,0x3F,0x06,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x7E +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x0F,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0xF8,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x7F +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x1F,0xF0,0x3F,0x78,0x30,0x3C,0x00,0x1C,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x1C,0x00,0x3C,0x00,0x78,0x20,0xF0,0x3F,0xC0,0x1F,0x00,0x02,0x00,0x07,0x00,0x0C,0x00,0x0C,0x80,0x07, ; 0x80 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x06,0x30,0x06,0x00,0x00,0x00,0x00,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x3C,0x3C,0x3E,0xF8,0x3B,0xF0,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x81 +.db 0x00,0x00,0x00,0x0C,0x00,0x06,0x00,0x03,0x80,0x01,0x00,0x00,0x00,0x00,0xC0,0x07,0xF0,0x0F,0x78,0x1C,0x38,0x38,0x1C,0x38,0x1C,0x38,0xFC,0x3F,0xFC,0x3F,0x1C,0x00,0x1C,0x00,0x38,0x00,0x78,0x20,0xF0,0x3F,0xC0,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x82 +.db 0x00,0x00,0xC0,0x01,0x60,0x03,0x30,0x06,0x18,0x0C,0x00,0x00,0x00,0x00,0xE0,0x07,0xF8,0x0F,0x18,0x1E,0x00,0x1C,0x00,0x1C,0xE0,0x1F,0xF0,0x1F,0x38,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x3C,0x1E,0xF8,0x7B,0xF0,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x83 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x0C,0x60,0x0C,0x00,0x00,0x00,0x00,0xE0,0x07,0xF8,0x0F,0x18,0x1E,0x00,0x1C,0x00,0x1C,0xE0,0x1F,0xF0,0x1F,0x38,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x3C,0x1E,0xF8,0x7B,0xF0,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x84 +.db 0x00,0x00,0x30,0x00,0x60,0x00,0xC0,0x00,0x80,0x01,0x00,0x00,0x00,0x00,0xE0,0x07,0xF8,0x0F,0x18,0x1E,0x00,0x1C,0x00,0x1C,0xE0,0x1F,0xF0,0x1F,0x38,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x3C,0x1E,0xF8,0x7B,0xF0,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x85 +.db 0xC0,0x01,0x20,0x02,0x20,0x02,0x20,0x02,0xC0,0x01,0x00,0x00,0x00,0x00,0xE0,0x07,0xF8,0x0F,0x18,0x1E,0x00,0x1C,0x00,0x1C,0xE0,0x1F,0xF0,0x1F,0x38,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x3C,0x1E,0xF8,0x7B,0xF0,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x86 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x1F,0xF0,0x3F,0x78,0x20,0x38,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x3C,0x00,0x38,0x00,0xF8,0x20,0xF0,0x3F,0xC0,0x1F,0x00,0x01,0x80,0x03,0x00,0x06,0x00,0x06,0xC0,0x03, ; 0x87 +.db 0x00,0x00,0xC0,0x01,0x60,0x03,0x30,0x06,0x18,0x0C,0x00,0x00,0x00,0x00,0xC0,0x07,0xF0,0x0F,0x78,0x1C,0x38,0x38,0x1C,0x38,0x1C,0x38,0xFC,0x3F,0xFC,0x3F,0x1C,0x00,0x1C,0x00,0x38,0x00,0x78,0x20,0xF0,0x3F,0xC0,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x88 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x0C,0x60,0x0C,0x00,0x00,0x00,0x00,0xC0,0x07,0xF0,0x0F,0x78,0x1C,0x38,0x38,0x1C,0x38,0x1C,0x38,0xFC,0x3F,0xFC,0x3F,0x1C,0x00,0x1C,0x00,0x38,0x00,0x78,0x20,0xF0,0x3F,0xC0,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x89 +.db 0x00,0x00,0x30,0x00,0x60,0x00,0xC0,0x00,0x80,0x01,0x00,0x00,0x00,0x00,0xC0,0x07,0xF0,0x0F,0x78,0x1C,0x38,0x38,0x1C,0x38,0x1C,0x38,0xFC,0x3F,0xFC,0x3F,0x1C,0x00,0x1C,0x00,0x38,0x00,0x78,0x20,0xF0,0x3F,0xC0,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x8A +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x06,0x30,0x06,0x00,0x00,0x00,0x00,0xFC,0x03,0xFC,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x8B +.db 0x00,0x00,0x80,0x03,0xC0,0x06,0x60,0x0C,0x30,0x18,0x00,0x00,0x00,0x00,0xFC,0x03,0xFC,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x8C +.db 0x00,0x00,0x60,0x00,0xC0,0x00,0x80,0x01,0x00,0x03,0x00,0x00,0x00,0x00,0xFC,0x03,0xFC,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x8D +.db 0x30,0x0C,0x30,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x01,0xC0,0x03,0xE0,0x03,0x60,0x07,0x60,0x07,0x70,0x06,0x30,0x0E,0x38,0x0E,0x38,0x1C,0x18,0x1C,0xFC,0x3F,0xFC,0x3F,0x0E,0x38,0x0E,0x70,0x0E,0x70,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x8E +.db 0x80,0x03,0x40,0x04,0x40,0x04,0x40,0x04,0x80,0x03,0x80,0x03,0xC0,0x07,0xC0,0x07,0xE0,0x06,0x60,0x0E,0x60,0x0E,0x70,0x0C,0x30,0x1C,0x38,0x1C,0x38,0x38,0xFC,0x3F,0xFC,0x3F,0x1C,0x70,0x0E,0x70,0x0E,0x70,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x8F +.db 0x00,0x0E,0x00,0x07,0x80,0x03,0x00,0x00,0x00,0x00,0xF8,0x3F,0xF8,0x3F,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0xF8,0x1F,0xF8,0x1F,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0xF8,0x7F,0xF8,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x90 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x3C,0xFC,0x7F,0x80,0x67,0x80,0xE3,0x80,0xE3,0xF0,0xFF,0xFC,0xFF,0x9C,0x03,0x8E,0x03,0x8E,0x03,0x8E,0x03,0x9E,0x87,0xFC,0xFF,0x78,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x91 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x3F,0xC0,0x3F,0xC0,0x07,0xE0,0x07,0x60,0x07,0x60,0x07,0x70,0x07,0x30,0x3F,0x38,0x3F,0x18,0x07,0x1C,0x07,0xFC,0x07,0xFC,0x07,0x06,0x07,0x06,0x7F,0x03,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x92 +.db 0x00,0x00,0xC0,0x01,0x60,0x03,0x30,0x06,0x18,0x0C,0x00,0x00,0x00,0x00,0xE0,0x03,0xF8,0x0F,0x3C,0x1E,0x1C,0x1C,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x1C,0x1C,0x3C,0x1E,0xF8,0x0F,0xE0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x93 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x06,0x30,0x06,0x00,0x00,0x00,0x00,0xE0,0x03,0xF8,0x0F,0x3C,0x1E,0x1C,0x1C,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x1C,0x1C,0x3C,0x1E,0xF8,0x0F,0xE0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x94 +.db 0x00,0x00,0x30,0x00,0x60,0x00,0xC0,0x00,0x80,0x01,0x00,0x00,0x00,0x00,0xE0,0x03,0xF8,0x0F,0x3C,0x1E,0x1C,0x1C,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x1C,0x1C,0x3C,0x1E,0xF8,0x0F,0xE0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x95 +.db 0x00,0x00,0xC0,0x01,0x60,0x03,0x30,0x06,0x18,0x0C,0x00,0x00,0x00,0x00,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x3C,0x3C,0x3E,0xF8,0x3B,0xF0,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x96 +.db 0x00,0x00,0x30,0x00,0x60,0x00,0xC0,0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x3C,0x3C,0x3E,0xF8,0x3B,0xF0,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x97 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x06,0x30,0x06,0x00,0x00,0x00,0x00,0x1E,0x70,0x1C,0x30,0x1C,0x38,0x38,0x18,0x38,0x1C,0x78,0x1C,0x70,0x0E,0xF0,0x0E,0xE0,0x07,0xE0,0x07,0xC0,0x03,0xC0,0x03,0xC0,0x01,0x80,0x01,0xC0,0x01,0xC0,0x00,0xE0,0x00,0x7C,0x00,0x3C,0x00, ; 0x98 +.db 0x30,0x0C,0x30,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x07,0xF0,0x0F,0x38,0x1C,0x1C,0x38,0x1C,0x38,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x1C,0x38,0x1C,0x38,0x38,0x1C,0xF0,0x0F,0xE0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x99 +.db 0x60,0x18,0x60,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x3C,0x78,0x38,0x38,0xF0,0x1F,0xE0,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x9A +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x33,0xF8,0x1F,0x3C,0x1E,0x1C,0x1E,0x0E,0x3B,0x0E,0x39,0x8E,0x39,0xCE,0x38,0x6E,0x38,0x6E,0x38,0x3C,0x1C,0x3C,0x1E,0xFC,0x0F,0xE6,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x9B +.db 0x00,0x00,0x00,0x00,0x00,0x3E,0x80,0x3F,0x80,0x03,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xF0,0x0F,0xF0,0x0F,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xE0,0x00,0x70,0x00,0xF8,0x3F,0xF8,0x3F,0xF8,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x9C +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x67,0xF0,0x3F,0x38,0x1C,0x1C,0x3C,0x1C,0x3C,0x0E,0x76,0x0E,0x73,0x8E,0x71,0x8E,0x71,0xCE,0x70,0x6E,0x70,0x3C,0x38,0x3C,0x38,0x38,0x1C,0xFC,0x0F,0xE6,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x9D +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x20,0x0E,0x70,0x1C,0x38,0x38,0x1C,0x70,0x0E,0xE0,0x07,0xC0,0x03,0xC0,0x03,0xE0,0x07,0x70,0x0E,0x38,0x1C,0x1C,0x38,0x0E,0x70,0x04,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x9E +.db 0x00,0x00,0x00,0x3F,0x80,0x3F,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xF8,0x1F,0xF8,0x1F,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xFE,0x00,0x7E,0x00, ; 0x9F +.db 0x00,0x00,0x00,0x06,0x00,0x03,0x80,0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0xE0,0x07,0xF8,0x0F,0x18,0x1E,0x00,0x1C,0x00,0x1C,0xE0,0x1F,0xF0,0x1F,0x38,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x3C,0x1E,0xF8,0x7B,0xF0,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xA0 +.db 0x00,0x00,0x00,0x06,0x00,0x03,0x80,0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0xFC,0x03,0xFC,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xA1 +.db 0x00,0x00,0x00,0x06,0x00,0x03,0x80,0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0xE0,0x03,0xF8,0x0F,0x3C,0x1E,0x1C,0x1C,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x1C,0x1C,0x3C,0x1E,0xF8,0x0F,0xE0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xA2 +.db 0x00,0x00,0x00,0x06,0x00,0x03,0x80,0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x3C,0x3C,0x3E,0xF8,0x3B,0xF0,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xA3 +.db 0x00,0x00,0x00,0x00,0xE0,0x0C,0xF0,0x0F,0x30,0x07,0x00,0x00,0x00,0x00,0x1C,0x0F,0xDC,0x1F,0x7C,0x3C,0x3C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xA4 +.db 0xE0,0x0C,0xF0,0x0F,0x30,0x07,0x00,0x00,0x00,0x00,0x1C,0x30,0x1C,0x30,0x3C,0x30,0x7C,0x30,0x7C,0x30,0xFC,0x30,0xEC,0x31,0xCC,0x31,0xCC,0x33,0x8C,0x37,0x0C,0x3F,0x0C,0x3E,0x0C,0x3E,0x0C,0x3C,0x0C,0x38,0x0C,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xA5 +.db 0x00,0x00,0x00,0x00,0xE0,0x03,0xF0,0x07,0x10,0x06,0xE0,0x07,0xF0,0x07,0x38,0x06,0x18,0x06,0x18,0x07,0xF8,0x1F,0xF0,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xA6 +.db 0x00,0x00,0x00,0x00,0xE0,0x07,0xF0,0x0F,0x38,0x1C,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x38,0x1C,0xF0,0x0F,0xE0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xA7 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x03,0x80,0x03,0x80,0x03,0x00,0x00,0x00,0x00,0x80,0x03,0x80,0x03,0x80,0x03,0xC0,0x01,0xE0,0x01,0xF0,0x00,0x78,0x00,0x38,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x30,0x3C,0x30,0xF8,0x3F,0xE0,0x1F, ; 0xA8 +.db 0x00,0x00,0x00,0x00,0xE0,0x03,0x10,0x04,0xE8,0x09,0x24,0x12,0x24,0x12,0xE4,0x11,0x24,0x11,0x24,0x11,0x28,0x0B,0x10,0x04,0xE0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xA9 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x7F,0xFE,0x7F,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xAA +.db 0x00,0x00,0x00,0x00,0x1F,0x0C,0x1F,0x06,0x1C,0x06,0x1C,0x03,0x1C,0x03,0x9C,0x01,0x9C,0x01,0xDC,0x00,0xDC,0x00,0x7C,0x3C,0x30,0xFE,0x30,0xE0,0x18,0xE0,0x18,0x70,0x0C,0x38,0x0C,0x0C,0x06,0x06,0x06,0xFE,0x03,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xAB +.db 0x00,0x00,0x00,0x00,0x1F,0x18,0x1F,0x0C,0x1C,0x0C,0x1C,0x06,0x1C,0x06,0x1C,0x03,0x1C,0x03,0x9C,0x01,0x9C,0x01,0xDC,0x38,0x60,0x3C,0x60,0x3A,0x30,0x39,0xB0,0x39,0xD8,0x38,0xD8,0xFF,0x0C,0x38,0x0C,0x38,0x06,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xAC +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x01,0xC0,0x01,0xC0,0x01,0x00,0x00,0x00,0x00,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01, ; 0xAD +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x10,0xE0,0x38,0x70,0x1C,0x38,0x0E,0x1C,0x07,0x0C,0x03,0x8E,0x03,0x1C,0x07,0x38,0x0E,0x70,0x1C,0xE0,0x38,0x40,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xAE +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x01,0x9C,0x03,0x38,0x07,0x70,0x0E,0xE0,0x1C,0xC0,0x39,0xC0,0x18,0xE0,0x1C,0x70,0x0E,0x38,0x07,0x9C,0x03,0x08,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xAF +.db 0xE7,0x1C,0xE7,0x1C,0xE7,0x1C,0x00,0x00,0x00,0x00,0xE7,0x1C,0xE7,0x1C,0xE7,0x1C,0x00,0x00,0x00,0x00,0xE7,0x1C,0xE7,0x1C,0xE7,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x1C,0xE7,0x1C,0xE7,0x1C,0x00,0x00,0x00,0x00,0xE7,0x1C,0xE7,0x1C,0xE7,0x1C,0x00,0x00,0x00,0x00, ; 0xB0 +.db 0x38,0xE7,0x38,0xE7,0x38,0xE7,0xE7,0x1C,0xE7,0x1C,0xFF,0xFF,0x38,0xE7,0x38,0xE7,0xE7,0x1C,0xE7,0x1C,0xFF,0xFF,0x38,0xE7,0x38,0xE7,0xE7,0x1C,0xE7,0x1C,0xE7,0x1C,0x38,0xE7,0x38,0xE7,0xFF,0xFF,0xE7,0x1C,0xE7,0x1C,0x38,0xE7,0x38,0xE7,0xFF,0xFF,0xE7,0x1C,0xE7,0x1C, ; 0xB1 +.db 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE7,0x1C,0xE7,0x1C,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE7,0x1C,0xE7,0x1C,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE7,0x1C,0xE7,0x1C,0xE7,0x1C,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE7,0x1C,0xE7,0x1C,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE7,0x1C,0xE7,0x1C, ; 0xB2 +.db 0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01, ; 0xB3 +.db 0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0xFF,0x01,0xFF,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01, ; 0xB4 +.db 0x00,0x07,0x80,0x03,0xC0,0x01,0x00,0x00,0x00,0x00,0xC0,0x01,0xC0,0x03,0xE0,0x03,0x60,0x07,0x60,0x07,0x70,0x06,0x30,0x0E,0x38,0x0E,0x38,0x1C,0x18,0x1C,0xFC,0x3F,0xFC,0x3F,0x0E,0x38,0x0E,0x70,0x0E,0x70,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xB5 +.db 0xE0,0x03,0x70,0x07,0x38,0x0E,0x00,0x00,0x00,0x00,0xC0,0x01,0xC0,0x03,0xE0,0x03,0x60,0x07,0x60,0x07,0x70,0x06,0x30,0x0E,0x38,0x0E,0x38,0x1C,0x18,0x1C,0xFC,0x3F,0xFC,0x3F,0x0E,0x38,0x0E,0x70,0x0E,0x70,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xB6 +.db 0xE0,0x00,0xC0,0x01,0x80,0x03,0x00,0x00,0x00,0x00,0xC0,0x01,0xC0,0x03,0xE0,0x03,0x60,0x07,0x60,0x07,0x70,0x06,0x30,0x0E,0x38,0x0E,0x38,0x1C,0x18,0x1C,0xFC,0x3F,0xFC,0x3F,0x0E,0x38,0x0E,0x70,0x0E,0x70,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xB7 +.db 0x00,0x00,0x00,0x00,0xE0,0x0F,0xF0,0x1F,0x38,0x38,0x1C,0x70,0x8C,0x6F,0xEE,0xEF,0x66,0xC8,0x36,0xC0,0x36,0xC0,0x36,0xC0,0x36,0xC0,0x36,0xC0,0x66,0xC8,0xEE,0xEF,0x8C,0x67,0x1C,0x70,0x38,0x38,0xF0,0x1F,0xE0,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xB8 +.db 0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x7F,0x06,0x7F,0x06,0x00,0x06,0x00,0x06,0x7F,0x06,0x7F,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06, ; 0xB9 +.db 0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06, ; 0xBA +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x07,0xFF,0x07,0x00,0x06,0x00,0x06,0x7F,0x06,0x7F,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06, ; 0xBB +.db 0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x7F,0x06,0x7F,0x06,0x00,0x06,0x00,0x06,0xFF,0x07,0xFF,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xBC +.db 0x00,0x00,0x00,0x00,0x80,0x01,0x80,0x01,0xC0,0x0F,0xF0,0x0F,0xB8,0x09,0xB8,0x01,0x9C,0x01,0x9C,0x01,0x9C,0x01,0x9C,0x01,0x9C,0x01,0x9C,0x01,0x9C,0x01,0xB8,0x01,0xF8,0x09,0xF0,0x0F,0xE0,0x07,0x80,0x01,0x80,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xBD +.db 0x00,0x00,0x00,0x00,0x0E,0xE0,0x1C,0x60,0x38,0x30,0x38,0x30,0x70,0x18,0xE0,0x0C,0xE0,0x0C,0xC0,0x07,0x80,0x03,0xF8,0x3F,0xF8,0x3F,0x80,0x03,0x80,0x03,0x80,0x03,0xF8,0x3F,0xF8,0x3F,0x80,0x03,0x80,0x03,0x80,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xBE +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x01,0xFF,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01, ; 0xBF +.db 0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0xFF,0x80,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xC0 +.db 0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xC1 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01, ; 0xC2 +.db 0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0xFF,0x80,0xFF,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01, ; 0xC3 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xC4 +.db 0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0xFF,0xFF,0xFF,0xFF,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01, ; 0xC5 +.db 0x00,0x00,0x00,0x00,0xE0,0x0C,0xF0,0x0F,0x30,0x07,0x00,0x00,0x00,0x00,0xE0,0x07,0xF8,0x0F,0x18,0x1E,0x00,0x1C,0x00,0x1C,0xE0,0x1F,0xF0,0x1F,0x38,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x3C,0x1E,0xF8,0x7B,0xF0,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xC6 +.db 0xE0,0x0C,0xF0,0x0F,0x30,0x07,0x00,0x00,0x00,0x00,0xC0,0x01,0xC0,0x03,0xE0,0x03,0x60,0x07,0x60,0x07,0x70,0x06,0x30,0x0E,0x38,0x0E,0x38,0x1C,0x18,0x1C,0xFC,0x3F,0xFC,0x3F,0x0E,0x38,0x0E,0x70,0x0E,0x70,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xC7 +.db 0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0xFE,0x60,0xFE,0x60,0x00,0x60,0x00,0xE0,0xFF,0xE0,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xC8 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xFF,0xE0,0xFF,0x60,0x00,0x60,0x00,0x60,0xFE,0x60,0xFE,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06, ; 0xC9 +.db 0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x7F,0xFE,0x7F,0xFE,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xCA +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x7F,0xFE,0x7F,0xFE,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06, ; 0xCB +.db 0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0xFE,0x60,0xFE,0x60,0x00,0x60,0x00,0x60,0xFE,0x60,0xFE,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06, ; 0xCC +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xCD +.db 0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x7F,0xFE,0x7F,0xFE,0x00,0x00,0x00,0x00,0x7F,0xFE,0x7F,0xFE,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x06, ; 0xCE +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x20,0xCC,0x33,0xF8,0x1F,0x30,0x0C,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x30,0x0C,0xF8,0x1F,0xCC,0x33,0x04,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xCF +.db 0x00,0x00,0x1E,0x03,0xFE,0x03,0xF0,0x01,0xF0,0x03,0x18,0x07,0x00,0x0E,0xE0,0x0F,0xF8,0x1F,0x3C,0x1E,0x1C,0x3C,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x1C,0x1C,0x3C,0x1E,0xF8,0x0F,0xE0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xD0 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x07,0xFC,0x0F,0x1C,0x3C,0x1C,0x38,0x1C,0x78,0x1C,0x70,0x1C,0x70,0xFF,0x70,0xFF,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x38,0x1C,0x38,0x1C,0x1E,0xFC,0x0F,0xFC,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xD1 +.db 0xC0,0x07,0xE0,0x0E,0x70,0x1C,0x00,0x00,0x00,0x00,0xF8,0x3F,0xF8,0x3F,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0xF8,0x1F,0xF8,0x1F,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0xF8,0x7F,0xF8,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xD2 +.db 0x60,0x18,0x60,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x3F,0xF8,0x3F,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0xF8,0x1F,0xF8,0x1F,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0xF8,0x7F,0xF8,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xD3 +.db 0xC0,0x01,0x80,0x03,0x00,0x07,0x00,0x00,0x00,0x00,0xF8,0x3F,0xF8,0x3F,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0xF8,0x1F,0xF8,0x1F,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0xF8,0x7F,0xF8,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xD4 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x03,0xFC,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xD5 +.db 0x00,0x07,0x80,0x03,0xC0,0x01,0x00,0x00,0x00,0x00,0xFC,0x1F,0xFC,0x1F,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xFC,0x1F,0xFC,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xD6 +.db 0xE0,0x03,0x70,0x07,0x38,0x0E,0x00,0x00,0x00,0x00,0xFC,0x1F,0xFC,0x1F,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xFC,0x1F,0xFC,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xD7 +.db 0x30,0x0C,0x30,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x1F,0xFC,0x1F,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xFC,0x1F,0xFC,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xD8 +.db 0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0xFF,0x01,0xFF,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xD9 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xFF,0x80,0xFF,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01, ; 0xDA +.db 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, ; 0xDB +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, ; 0xDC +.db 0x00,0x00,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x00,0x00, ; 0xDD +.db 0xE0,0x00,0xC0,0x01,0x80,0x03,0x00,0x00,0x00,0x00,0xFC,0x1F,0xFC,0x1F,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xFC,0x1F,0xFC,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xDE +.db 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xDF +.db 0x00,0x07,0x80,0x03,0xC0,0x01,0x00,0x00,0x00,0x00,0xE0,0x07,0xF0,0x0F,0x38,0x1C,0x1C,0x38,0x1C,0x38,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x1C,0x38,0x1C,0x38,0x38,0x1C,0xF0,0x0F,0xE0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xE0 +.db 0x00,0x00,0xF0,0x03,0xF8,0x07,0x3C,0x0E,0x1C,0x0E,0x1C,0x0E,0x1C,0x06,0x1C,0x07,0x9C,0x03,0x9C,0x03,0x9C,0x03,0x9C,0x07,0x1C,0x0F,0x1C,0x1E,0x1C,0x3C,0x1C,0x78,0x1C,0x70,0x1C,0x70,0x9C,0x70,0x9C,0x3F,0x1C,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xE1 +.db 0xE0,0x03,0x70,0x07,0x38,0x0E,0x00,0x00,0x00,0x00,0xE0,0x07,0xF0,0x0F,0x38,0x1C,0x1C,0x38,0x1C,0x38,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x1C,0x38,0x1C,0x38,0x38,0x1C,0xF0,0x0F,0xE0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xE2 +.db 0xE0,0x00,0xC0,0x01,0x80,0x03,0x00,0x00,0x00,0x00,0xE0,0x07,0xF0,0x0F,0x38,0x1C,0x1C,0x38,0x1C,0x38,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x1C,0x38,0x1C,0x38,0x38,0x1C,0xF0,0x0F,0xE0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xE3 +.db 0x00,0x00,0x00,0x00,0xE0,0x0C,0xF0,0x0F,0x30,0x07,0x00,0x00,0x00,0x00,0xE0,0x03,0xF8,0x0F,0x3C,0x1E,0x1C,0x1C,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x1C,0x1C,0x3C,0x1E,0xF8,0x0F,0xE0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xE4 +.db 0xE0,0x0C,0xF0,0x0F,0x30,0x07,0x00,0x00,0x00,0x00,0xE0,0x07,0xF0,0x0F,0x38,0x1C,0x1C,0x38,0x1C,0x38,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x0E,0x70,0x1C,0x38,0x1C,0x38,0x38,0x1C,0xF0,0x0F,0xE0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xE5 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x3C,0x3C,0x7C,0x3E,0xFC,0x3B,0xDC,0x7B,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00, ; 0xE6 +.db 0x00,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x9C,0x07,0xDC,0x1F,0x7C,0x1C,0x3C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x1C,0x3C,0x1E,0xFC,0x0F,0x9C,0x07,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00, ; 0xE7 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0xF8,0x1F,0xF8,0x3F,0x38,0x78,0x38,0x70,0x38,0x70,0x38,0x70,0x38,0x78,0x38,0x3C,0xF8,0x1F,0xF8,0x07,0x38,0x00,0x38,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xE8 +.db 0x00,0x07,0x80,0x03,0xC0,0x01,0x00,0x00,0x00,0x00,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x3C,0x78,0x38,0x38,0xF0,0x1F,0xE0,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xE9 +.db 0xE0,0x03,0x70,0x07,0x38,0x0E,0x00,0x00,0x00,0x00,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x3C,0x78,0x38,0x38,0xF0,0x1F,0xE0,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xEA +.db 0xE0,0x00,0xC0,0x01,0x80,0x03,0x00,0x00,0x00,0x00,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x3C,0x78,0x38,0x38,0xF0,0x1F,0xE0,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xEB +.db 0x00,0x00,0x00,0x06,0x00,0x03,0x80,0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0x1E,0x70,0x1C,0x30,0x1C,0x38,0x38,0x18,0x38,0x1C,0x78,0x1C,0x70,0x0E,0xF0,0x0E,0xE0,0x07,0xE0,0x07,0xC0,0x03,0xC0,0x03,0xC0,0x01,0x80,0x01,0xC0,0x01,0xC0,0x00,0xE0,0x00,0x7C,0x00,0x3C,0x00, ; 0xEC +.db 0x00,0x07,0x80,0x03,0xC0,0x01,0x00,0x00,0x00,0x00,0x07,0xE0,0x0E,0x70,0x1C,0x30,0x1C,0x18,0x38,0x1C,0x78,0x0E,0x70,0x07,0xE0,0x03,0xE0,0x03,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xED +.db 0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xEE +.db 0x80,0x03,0xC0,0x01,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xEF +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x1F,0xF8,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xF0 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0xFE,0x7F,0xFE,0x7F,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x00,0x00,0x00,0x00,0xFE,0x7F,0xFE,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xF1 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0xFF,0xFF, ; 0xF2 +.db 0x00,0x00,0x00,0x00,0x7E,0xE0,0xFE,0x70,0xE0,0x38,0xE0,0x38,0x3C,0x1C,0x7C,0x1C,0xE0,0x0E,0xE0,0x07,0xFE,0x07,0xBE,0x3B,0xC0,0x3D,0xC0,0x3B,0xE0,0x39,0xF0,0x39,0xF0,0x38,0xF8,0xFF,0x38,0x38,0x1C,0x38,0x0E,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xF3 +.db 0x00,0x00,0x00,0x00,0xF8,0x1F,0xFC,0x1F,0xFE,0x18,0xFE,0x18,0xFE,0x18,0xFE,0x18,0xFE,0x18,0xFC,0x18,0xF8,0x18,0xF0,0x18,0xC0,0x18,0xC0,0x18,0xC0,0x18,0xC0,0x18,0xC0,0x18,0xC0,0x18,0xC0,0x18,0xC0,0x18,0xC0,0x18,0xC0,0x18,0xC0,0x18,0xC0,0x18,0xC0,0x18,0x00,0x00, ; 0xF4 +.db 0x00,0x00,0x00,0x00,0xC0,0x1F,0xF0,0x1F,0x78,0x10,0x38,0x00,0x38,0x00,0x78,0x00,0xF0,0x01,0xE0,0x07,0xF0,0x0F,0x30,0x1E,0x38,0x3C,0x38,0x38,0x78,0x38,0xF0,0x19,0xE0,0x0F,0x80,0x0F,0x00,0x1E,0x00,0x3C,0x00,0x38,0x00,0x38,0x18,0x3C,0xF8,0x1F,0xE0,0x07,0x00,0x00, ; 0xF5 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x01,0xC0,0x01,0xC0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x3F,0xFE,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x01,0xC0,0x01,0xC0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xF6 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x03,0x00,0x06,0x00,0x06,0xC0,0x03, ; 0xF7 +.db 0x00,0x00,0x00,0x00,0xE0,0x00,0x10,0x01,0x10,0x01,0x10,0x01,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xF8 +.db 0x30,0x0C,0x30,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xF9 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x01,0xC0,0x01,0xC0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xFA +.db 0x00,0x00,0x00,0x00,0xE0,0x03,0xE0,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xFB +.db 0x00,0x00,0x00,0x00,0xE0,0x0F,0xF0,0x1F,0x10,0x1C,0x00,0x1C,0xC0,0x07,0xC0,0x0F,0x00,0x1C,0x00,0x1C,0xF0,0x1F,0xF0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xFC +.db 0x00,0x00,0x00,0x00,0xE0,0x07,0xF0,0x1F,0x10,0x1C,0x00,0x1C,0x00,0x0E,0x80,0x07,0xC0,0x01,0x70,0x00,0xF0,0x1F,0xF0,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xFD +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x7F,0xFE,0x7F,0xFE,0x7F,0xFE,0x7F,0xFE,0x7F,0xFE,0x7F,0xFE,0x7F,0xFE,0x7F,0xFE,0x7F,0xFE,0x7F,0xFE,0x7F,0xFE,0x7F,0xFE,0x7F,0xFE,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xFE +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ; 0xFF diff --git a/avr/modules/lcd2/font/font4.asm b/avr/modules/lcd2/font/font4.asm new file mode 100644 index 0000000..212bff4 --- /dev/null +++ b/avr/modules/lcd2/font/font4.asm @@ -0,0 +1,258 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + +; *************************************************************************** +; This is a font from the project LCD_fonts at +; https://github.com/basti79/LCD-fonts.git +; which in turn is based on a post by Benedikt K. in a forum post on +; https://www.mikrocontroller.net/topic/54860 +; *************************************************************************** + + + +; *************************************************************************** +; code + +.cseg + + + +font4_12x16: +; header + .dw font12x16MonoRenderCharacter ; renderFn + .dw 384 ; needed buffer size + .db 12, 16 ; width, height of chars + .db 32, 224 ; first char, num of chars in font +; data (12x16_horizontal_LSB_2) +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x20 +.db 0x60,0x00,0x60,0x00,0xF0,0x00,0xF0,0x00,0xF0,0x00,0xF0,0x00,0xF0,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00, ; 0x21 +.db 0x00,0x00,0x00,0x00,0x98,0x01,0x98,0x01,0x98,0x01,0x98,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x22 +.db 0x00,0x00,0x60,0x06,0x60,0x06,0x60,0x06,0xFC,0x0F,0x30,0x03,0x30,0x03,0x98,0x01,0x98,0x01,0xFE,0x03,0xCC,0x00,0xCC,0x00,0xCC,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x23 +.db 0x60,0x00,0x60,0x00,0xF8,0x01,0xFC,0x03,0x6C,0x00,0x6C,0x00,0xFC,0x01,0xF8,0x03,0x60,0x03,0x60,0x03,0xFC,0x03,0xF8,0x01,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00, ; 0x24 +.db 0x00,0x00,0x00,0x00,0x00,0x08,0x1C,0x0C,0x1C,0x0E,0x1C,0x07,0x80,0x03,0xC0,0x01,0xE0,0x00,0x70,0x00,0x38,0x00,0x1C,0x07,0x0E,0x07,0x06,0x07,0x00,0x00,0x00,0x00, ; 0x25 +.db 0x00,0x00,0xE0,0x00,0xB0,0x01,0x98,0x01,0x98,0x01,0xD8,0x00,0x70,0x00,0x78,0x00,0x7C,0x00,0xCC,0x06,0xCC,0x03,0x8C,0x01,0xDC,0x03,0x78,0x06,0x00,0x00,0x00,0x00, ; 0x26 +.db 0x70,0x00,0x70,0x00,0x70,0x00,0x60,0x00,0x60,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x27 +.db 0xC0,0x01,0x60,0x00,0x70,0x00,0x30,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x30,0x00,0x70,0x00,0x60,0x00,0xC0,0x01,0x00,0x00,0x00,0x00, ; 0x28 +.db 0x38,0x00,0x60,0x00,0xE0,0x00,0xC0,0x00,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x00,0xE0,0x00,0x60,0x00,0x38,0x00,0x00,0x00,0x00,0x00, ; 0x29 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x6C,0x03,0x6C,0x03,0xF8,0x01,0xF0,0x00,0xFC,0x03,0xF0,0x00,0xF8,0x01,0x6C,0x03,0x6C,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x2A +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xFC,0x03,0xFC,0x03,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x2B +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x60,0x00,0x30,0x00, ; 0x2C +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x03,0xFC,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x2D +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x00,0x00,0x00,0x00, ; 0x2E +.db 0x00,0x00,0x00,0x08,0x00,0x0C,0x00,0x0E,0x00,0x07,0x80,0x03,0xC0,0x01,0xE0,0x00,0x70,0x00,0x38,0x00,0x1C,0x00,0x0E,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x2F +.db 0xF0,0x01,0xFC,0x07,0x0C,0x06,0x06,0x0E,0x06,0x0F,0x86,0x0D,0xC6,0x0C,0x66,0x0C,0x36,0x0C,0x1E,0x0C,0x0E,0x0C,0x0C,0x06,0xFC,0x07,0xF0,0x01,0x00,0x00,0x00,0x00, ; 0x30 +.db 0xC0,0x00,0xE0,0x00,0xF8,0x00,0xF8,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xF8,0x07,0xF8,0x07,0x00,0x00,0x00,0x00, ; 0x31 +.db 0xF8,0x03,0xFC,0x07,0x0E,0x0E,0x06,0x0C,0x06,0x0E,0x00,0x07,0x80,0x03,0xC0,0x01,0xE0,0x00,0x70,0x00,0x38,0x00,0x1C,0x00,0xFE,0x0F,0xFE,0x0F,0x00,0x00,0x00,0x00, ; 0x32 +.db 0xF8,0x03,0xFC,0x07,0x0E,0x0E,0x06,0x0C,0x00,0x0C,0x00,0x0E,0xF0,0x07,0xF0,0x03,0x00,0x06,0x00,0x0C,0x06,0x0C,0x0E,0x0E,0xFC,0x07,0xF8,0x03,0x00,0x00,0x00,0x00, ; 0x33 +.db 0x80,0x03,0xC0,0x03,0xE0,0x03,0x70,0x03,0x38,0x03,0x1C,0x03,0x0E,0x03,0x06,0x03,0xFE,0x0F,0xFE,0x0F,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x00,0x00,0x00, ; 0x34 +.db 0xFE,0x0F,0xFE,0x0F,0x06,0x00,0x06,0x00,0x06,0x00,0xFE,0x03,0xFC,0x07,0x00,0x0E,0x00,0x0C,0x00,0x0C,0x06,0x0C,0x0E,0x0E,0xFC,0x07,0xF8,0x03,0x00,0x00,0x00,0x00, ; 0x35 +.db 0xC0,0x03,0xE0,0x03,0x70,0x00,0x38,0x00,0x1C,0x00,0x0C,0x00,0xFE,0x03,0xFE,0x07,0x0E,0x0E,0x06,0x0C,0x06,0x0C,0x0E,0x0E,0xFC,0x07,0xF8,0x03,0x00,0x00,0x00,0x00, ; 0x36 +.db 0xFE,0x0F,0xFE,0x0F,0x00,0x06,0x00,0x06,0x00,0x03,0x00,0x03,0x80,0x01,0x80,0x01,0xC0,0x00,0xC0,0x00,0x60,0x00,0x60,0x00,0x30,0x00,0x30,0x00,0x00,0x00,0x00,0x00, ; 0x37 +.db 0xF0,0x01,0xF8,0x03,0x1C,0x07,0x0C,0x06,0x0C,0x06,0x1C,0x07,0xF8,0x03,0xFC,0x07,0x0E,0x0E,0x06,0x0C,0x06,0x0C,0x0E,0x0E,0xFC,0x07,0xF8,0x03,0x00,0x00,0x00,0x00, ; 0x38 +.db 0xF8,0x03,0xFC,0x07,0x0E,0x0E,0x06,0x0C,0x06,0x0C,0x0E,0x0E,0xFC,0x0F,0xF8,0x0F,0x00,0x06,0x00,0x07,0x80,0x03,0xC0,0x01,0xF8,0x00,0x78,0x00,0x00,0x00,0x00,0x00, ; 0x39 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x3A +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x60,0x00,0x60,0x00,0x30,0x00, ; 0x3B +.db 0x00,0x03,0x80,0x03,0xC0,0x01,0xE0,0x00,0x70,0x00,0x38,0x00,0x1C,0x00,0x1C,0x00,0x38,0x00,0x70,0x00,0xE0,0x00,0xC0,0x01,0x80,0x03,0x00,0x03,0x00,0x00,0x00,0x00, ; 0x3C +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x07,0xFC,0x07,0x00,0x00,0x00,0x00,0xFC,0x07,0xFC,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x3D +.db 0x0C,0x00,0x1C,0x00,0x38,0x00,0x70,0x00,0xE0,0x00,0xC0,0x01,0x80,0x03,0x80,0x03,0xC0,0x01,0xE0,0x00,0x70,0x00,0x38,0x00,0x1C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00, ; 0x3E +.db 0xF8,0x01,0xFC,0x03,0x0E,0x07,0x06,0x06,0x06,0x07,0x80,0x03,0xC0,0x01,0xE0,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00, ; 0x3F +.db 0xF8,0x03,0xFC,0x07,0x0C,0x06,0xE6,0x0D,0xF6,0x0D,0xB6,0x0D,0xB6,0x0D,0xB6,0x0D,0xB6,0x0D,0xF6,0x07,0xE6,0x03,0x0E,0x00,0xFC,0x03,0xF0,0x03,0x00,0x00,0x00,0x00, ; 0x40 +.db 0x60,0x00,0x60,0x00,0xF0,0x00,0xF0,0x00,0xF0,0x00,0x98,0x01,0x98,0x01,0x98,0x01,0x0C,0x03,0xFC,0x03,0xFC,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x00,0x00, ; 0x41 +.db 0xFE,0x00,0xFE,0x01,0x86,0x03,0x06,0x03,0x06,0x03,0x86,0x03,0xFE,0x01,0xFE,0x03,0x06,0x07,0x06,0x06,0x06,0x06,0x06,0x07,0xFE,0x03,0xFE,0x01,0x00,0x00,0x00,0x00, ; 0x42 +.db 0xF0,0x01,0xF8,0x03,0x1C,0x07,0x0C,0x06,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x0C,0x06,0x1C,0x07,0xF8,0x03,0xF0,0x01,0x00,0x00,0x00,0x00, ; 0x43 +.db 0xFE,0x00,0xFE,0x01,0x86,0x03,0x06,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x03,0x86,0x03,0xFE,0x01,0xFE,0x00,0x00,0x00,0x00,0x00, ; 0x44 +.db 0xFE,0x07,0xFE,0x07,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0xFE,0x01,0xFE,0x01,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0xFE,0x07,0xFE,0x07,0x00,0x00,0x00,0x00, ; 0x45 +.db 0xFE,0x07,0xFE,0x07,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0xFE,0x01,0xFE,0x01,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x00,0x00,0x00,0x00, ; 0x46 +.db 0xF0,0x03,0xF8,0x07,0x1C,0x06,0x0C,0x00,0x06,0x00,0x06,0x00,0xC6,0x07,0xC6,0x07,0x06,0x06,0x06,0x06,0x0C,0x06,0x1C,0x06,0xF8,0x07,0xF0,0x07,0x00,0x00,0x00,0x00, ; 0x47 +.db 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0xFE,0x07,0xFE,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x00,0x00, ; 0x48 +.db 0xF8,0x01,0xF8,0x01,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xF8,0x01,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0x49 +.db 0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x06,0x06,0x06,0x06,0x0E,0x03,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0x4A +.db 0x06,0x06,0x06,0x07,0x86,0x03,0xC6,0x01,0xE6,0x00,0x76,0x00,0x3E,0x00,0x3E,0x00,0x76,0x00,0xE6,0x00,0xC6,0x01,0x86,0x03,0x06,0x07,0x06,0x06,0x00,0x00,0x00,0x00, ; 0x4B +.db 0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0xFE,0x07,0xFE,0x07,0x00,0x00,0x00,0x00, ; 0x4C +.db 0x06,0x06,0x0E,0x07,0x0E,0x07,0x9E,0x07,0x9E,0x07,0xF6,0x06,0xF6,0x06,0x66,0x06,0x66,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x00,0x00, ; 0x4D +.db 0x06,0x06,0x0E,0x06,0x0E,0x06,0x1E,0x06,0x36,0x06,0x36,0x06,0x66,0x06,0x66,0x06,0xC6,0x06,0xC6,0x06,0x86,0x07,0x06,0x07,0x06,0x07,0x06,0x06,0x00,0x00,0x00,0x00, ; 0x4E +.db 0xF0,0x00,0xF8,0x01,0x9C,0x03,0x0C,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x03,0x9C,0x03,0xF8,0x01,0xF0,0x00,0x00,0x00,0x00,0x00, ; 0x4F +.db 0xFE,0x01,0xFE,0x03,0x06,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x07,0xFE,0x03,0xFE,0x01,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x00,0x00,0x00,0x00, ; 0x50 +.db 0xF0,0x00,0xF8,0x01,0x9C,0x03,0x0C,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0xC6,0x06,0xCC,0x03,0x9C,0x03,0xF8,0x07,0xF0,0x06,0x00,0x00,0x00,0x00, ; 0x51 +.db 0xFE,0x01,0xFE,0x03,0x06,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x07,0xFE,0x03,0xFE,0x01,0xE6,0x00,0xC6,0x01,0x86,0x03,0x06,0x07,0x06,0x06,0x00,0x00,0x00,0x00, ; 0x52 +.db 0xF8,0x01,0xFC,0x03,0x0E,0x07,0x06,0x06,0x06,0x00,0x0E,0x00,0xFC,0x01,0xF8,0x03,0x00,0x07,0x00,0x06,0x06,0x06,0x0E,0x07,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0x53 +.db 0xFC,0x03,0xFC,0x03,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00, ; 0x54 +.db 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x03,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0x55 +.db 0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x03,0x0C,0x03,0x0C,0x03,0x98,0x01,0x98,0x01,0x98,0x01,0xF0,0x00,0xF0,0x00,0xF0,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00, ; 0x56 +.db 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x66,0x06,0x66,0x06,0xF6,0x06,0x9E,0x07,0x0E,0x07,0x0E,0x07,0x06,0x06,0x00,0x00,0x00,0x00, ; 0x57 +.db 0x06,0x06,0x06,0x06,0x0C,0x03,0x0C,0x03,0x98,0x01,0xF0,0x00,0x60,0x00,0x60,0x00,0xF0,0x00,0x98,0x01,0x0C,0x03,0x0C,0x03,0x06,0x06,0x06,0x06,0x00,0x00,0x00,0x00, ; 0x58 +.db 0x06,0x06,0x06,0x06,0x0C,0x03,0x0C,0x03,0x98,0x01,0x98,0x01,0xF0,0x00,0xF0,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00, ; 0x59 +.db 0xFE,0x07,0xFE,0x07,0x00,0x03,0x00,0x03,0x80,0x01,0xC0,0x00,0x60,0x00,0x60,0x00,0x30,0x00,0x18,0x00,0x0C,0x00,0x0C,0x00,0xFE,0x07,0xFE,0x07,0x00,0x00,0x00,0x00, ; 0x5A +.db 0xF8,0x01,0xF8,0x01,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0xF8,0x01,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0x5B +.db 0x00,0x00,0x02,0x00,0x06,0x00,0x0E,0x00,0x1C,0x00,0x38,0x00,0x70,0x00,0xE0,0x00,0xC0,0x01,0x80,0x03,0x00,0x07,0x00,0x0E,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x5C +.db 0xF8,0x01,0xF8,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0xF8,0x01,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0x5D +.db 0x40,0x00,0xE0,0x00,0xF0,0x01,0xB8,0x03,0x1C,0x07,0x0E,0x0E,0x06,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x5E +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x0F,0xFE,0x0F, ; 0x5F +.db 0x00,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x00,0x60,0x00,0x60,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x60 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x03,0xFC,0x07,0x00,0x06,0xF8,0x07,0xFC,0x07,0x06,0x06,0x06,0x06,0xFE,0x07,0xFC,0x07,0x00,0x00,0x00,0x00, ; 0x61 +.db 0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0xF6,0x01,0xFE,0x03,0x0E,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x07,0xFE,0x03,0xFE,0x01,0x00,0x00,0x00,0x00, ; 0x62 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x01,0xFC,0x03,0x0E,0x06,0x06,0x00,0x06,0x00,0x06,0x00,0x0E,0x06,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0x63 +.db 0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0xF8,0x06,0xFC,0x07,0x8E,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x06,0xFC,0x07,0xF8,0x07,0x00,0x00,0x00,0x00, ; 0x64 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x01,0xFC,0x03,0x0E,0x06,0xFE,0x07,0xFE,0x03,0x06,0x00,0x0E,0x00,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0x65 +.db 0xE0,0x01,0xF0,0x01,0x38,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0xFE,0x00,0xFE,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x00,0x00,0x00,0x00, ; 0x66 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x07,0xFC,0x07,0x0E,0x06,0x06,0x06,0x0E,0x07,0xFC,0x07,0xF8,0x06,0x00,0x06,0x00,0x07,0xFC,0x03,0xFC,0x01, ; 0x67 +.db 0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0xF6,0x00,0xFE,0x01,0x8E,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x00,0x00,0x00,0x00, ; 0x68 +.db 0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xF8,0x01,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0x69 +.db 0x00,0x00,0x00,0x00,0x80,0x01,0x80,0x01,0x00,0x00,0xC0,0x01,0xC0,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x98,0x01,0xF8,0x01,0xF0,0x00, ; 0x6A +.db 0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x8C,0x01,0xCC,0x01,0xEC,0x00,0x7C,0x00,0x7C,0x00,0xEC,0x00,0xCC,0x01,0x8C,0x03,0x0C,0x03,0x00,0x00,0x00,0x00, ; 0x6B +.db 0x70,0x00,0x70,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xF8,0x01,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0x6C +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9A,0x01,0xFE,0x03,0xFE,0x07,0x66,0x06,0x66,0x06,0x66,0x06,0x66,0x06,0x66,0x06,0x66,0x06,0x00,0x00,0x00,0x00, ; 0x6D +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x01,0xFC,0x03,0x0C,0x07,0x0C,0x06,0x0C,0x06,0x0C,0x06,0x0C,0x06,0x0C,0x06,0x0C,0x06,0x00,0x00,0x00,0x00, ; 0x6E +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x01,0xFC,0x03,0x0E,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x07,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0x6F +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x01,0xFE,0x03,0x06,0x07,0x06,0x06,0x06,0x06,0x0E,0x07,0xFE,0x03,0xF6,0x01,0x06,0x00,0x06,0x00,0x06,0x00, ; 0x70 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x07,0xFC,0x07,0x0E,0x06,0x06,0x06,0x06,0x06,0x0E,0x07,0xFC,0x07,0xF8,0x06,0x00,0x06,0x00,0x06,0x00,0x06, ; 0x71 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xEC,0x03,0xFC,0x07,0x1C,0x06,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00, ; 0x72 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0xFE,0x01,0x06,0x00,0xFE,0x00,0xFC,0x01,0x80,0x01,0x80,0x01,0xFE,0x01,0xFC,0x00,0x00,0x00,0x00,0x00, ; 0x73 +.db 0x00,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0xFE,0x00,0xFE,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0xF8,0x01,0xF0,0x01,0x00,0x00,0x00,0x00, ; 0x74 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x07,0xFC,0x07,0xF8,0x06,0x00,0x00,0x00,0x00, ; 0x75 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x0C,0x03,0x0C,0x03,0x98,0x01,0x98,0x01,0xF0,0x00,0xF0,0x00,0x60,0x00,0x00,0x00,0x00,0x00, ; 0x76 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x06,0x66,0x06,0x66,0x06,0x66,0x06,0x66,0x06,0xF6,0x06,0xFC,0x03,0x9C,0x03,0x08,0x01,0x00,0x00,0x00,0x00, ; 0x77 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x03,0x8E,0x03,0xDC,0x01,0xF8,0x00,0x70,0x00,0xF8,0x00,0xDC,0x01,0x8E,0x03,0x06,0x03,0x00,0x00,0x00,0x00, ; 0x78 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x03,0x0C,0x03,0x98,0x01,0x98,0x01,0xF0,0x00,0xF0,0x00,0x60,0x00,0x60,0x00,0x30,0x00,0x30,0x00,0x18,0x00, ; 0x79 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x03,0xFE,0x01,0xC0,0x00,0x60,0x00,0x30,0x00,0x18,0x00,0x0C,0x00,0xFE,0x03,0xFE,0x03,0x00,0x00,0x00,0x00, ; 0x7A +.db 0xC0,0x03,0xE0,0x03,0x70,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x38,0x00,0x1C,0x00,0x38,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x70,0x00,0xE0,0x03,0xC0,0x03,0x00,0x00, ; 0x7B +.db 0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00, ; 0x7C +.db 0x3C,0x00,0x7C,0x00,0xE0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x01,0x80,0x03,0xC0,0x01,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xE0,0x00,0x7C,0x00,0x3C,0x00,0x00,0x00, ; 0x7D +.db 0x00,0x00,0x00,0x00,0x38,0x06,0x6C,0x03,0xC6,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x7E +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0xF0,0x00,0x98,0x01,0x0C,0x03,0x06,0x06,0x06,0x06,0xFE,0x07,0xFE,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x7F +.db 0xF0,0x01,0xF8,0x03,0x1C,0x07,0x0C,0x06,0x06,0x06,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x0C,0x06,0x1C,0x07,0xF8,0x03,0xF0,0x01,0x60,0x00,0x78,0x00,0x78,0x00, ; 0x80 +.db 0x00,0x00,0x00,0x00,0x98,0x01,0x98,0x01,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x07,0xFC,0x07,0xF8,0x06,0x00,0x00,0x00,0x00, ; 0x81 +.db 0x00,0x00,0x80,0x01,0xC0,0x00,0x60,0x00,0x00,0x00,0xF8,0x01,0xFC,0x03,0x0E,0x06,0xFE,0x07,0xFE,0x07,0x06,0x00,0x0E,0x00,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0x82 +.db 0x00,0x00,0x60,0x00,0xF0,0x00,0x98,0x01,0x00,0x00,0xF8,0x03,0xFC,0x07,0x00,0x06,0xF8,0x07,0xFC,0x07,0x06,0x06,0x06,0x06,0xFE,0x07,0xFC,0x07,0x00,0x00,0x00,0x00, ; 0x83 +.db 0x00,0x00,0x00,0x00,0x98,0x01,0x98,0x01,0x00,0x00,0xF8,0x03,0xFC,0x07,0x00,0x06,0xF8,0x07,0xFC,0x07,0x06,0x06,0x06,0x06,0xFE,0x07,0xFC,0x07,0x00,0x00,0x00,0x00, ; 0x84 +.db 0x00,0x00,0x30,0x00,0x60,0x00,0xC0,0x00,0x00,0x00,0xF8,0x03,0xFC,0x07,0x00,0x06,0xF8,0x07,0xFC,0x07,0x06,0x06,0x06,0x06,0xFE,0x07,0xFC,0x07,0x00,0x00,0x00,0x00, ; 0x85 +.db 0x00,0x00,0x60,0x00,0x90,0x00,0x60,0x00,0x00,0x00,0xF8,0x03,0xFC,0x07,0x00,0x06,0xF8,0x07,0xFC,0x07,0x06,0x06,0x06,0x06,0xFE,0x07,0xFC,0x07,0x00,0x00,0x00,0x00, ; 0x86 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x01,0xFC,0x03,0x0E,0x07,0x06,0x00,0x06,0x00,0x06,0x00,0x0E,0x07,0xFC,0x03,0xF8,0x01,0x60,0x00,0x78,0x00, ; 0x87 +.db 0x00,0x00,0x60,0x00,0xF0,0x00,0x98,0x01,0x00,0x00,0xF8,0x01,0xFC,0x03,0x0E,0x06,0xFE,0x07,0xFE,0x07,0x06,0x00,0x06,0x00,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0x88 +.db 0x00,0x00,0x00,0x00,0x98,0x01,0x98,0x01,0x00,0x00,0xF8,0x01,0xFC,0x03,0x0E,0x06,0xFE,0x07,0xFE,0x07,0x06,0x00,0x06,0x00,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0x89 +.db 0x00,0x00,0x30,0x00,0x60,0x00,0xC0,0x00,0x00,0x00,0xF8,0x01,0xFC,0x03,0x0E,0x06,0xFE,0x07,0xFE,0x07,0x06,0x00,0x06,0x00,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0x8A +.db 0x00,0x00,0x00,0x00,0xD8,0x00,0xD8,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xF8,0x01,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0x8B +.db 0x00,0x00,0x60,0x00,0xF0,0x00,0x98,0x01,0x00,0x00,0x70,0x00,0x70,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xF8,0x01,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0x8C +.db 0x00,0x00,0x30,0x00,0x60,0x00,0xC0,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xF8,0x01,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0x8D +.db 0x98,0x01,0x98,0x01,0x00,0x00,0x60,0x00,0x60,0x00,0xF0,0x00,0xF0,0x00,0x98,0x01,0x98,0x01,0x0C,0x03,0xFC,0x03,0xFE,0x07,0x06,0x06,0x06,0x06,0x00,0x00,0x00,0x00, ; 0x8E +.db 0x60,0x00,0x90,0x00,0x60,0x00,0x00,0x00,0x60,0x00,0xF0,0x00,0xF0,0x00,0x98,0x01,0x98,0x01,0x0C,0x03,0xFC,0x03,0xFE,0x07,0x06,0x06,0x06,0x06,0x00,0x00,0x00,0x00, ; 0x8F +.db 0x80,0x01,0xC0,0x00,0x60,0x00,0xFE,0x07,0xFE,0x07,0x06,0x00,0x06,0x00,0xFE,0x01,0xFE,0x01,0x06,0x00,0x06,0x00,0x06,0x00,0xFE,0x07,0xFE,0x07,0x00,0x00,0x00,0x00, ; 0x90 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xBC,0x03,0x66,0x06,0x60,0x06,0xFC,0x03,0x66,0x00,0x66,0x00,0x66,0x06,0xDC,0x03,0x00,0x00,0x00,0x00, ; 0x91 +.db 0xE0,0x07,0xE0,0x07,0xF0,0x00,0xF0,0x00,0xF8,0x00,0xD8,0x00,0xD8,0x03,0xCC,0x03,0xCC,0x00,0xFC,0x00,0xFE,0x00,0xC6,0x00,0xC6,0x07,0xC6,0x07,0x00,0x00,0x00,0x00, ; 0x92 +.db 0x00,0x00,0x60,0x00,0xF0,0x00,0x98,0x01,0x00,0x00,0xF8,0x01,0xFC,0x03,0x0E,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x07,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0x93 +.db 0x00,0x00,0x00,0x00,0x98,0x01,0x98,0x01,0x00,0x00,0xF8,0x01,0xFC,0x03,0x0E,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x07,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0x94 +.db 0x00,0x00,0x30,0x00,0x60,0x00,0xC0,0x00,0x00,0x00,0xF8,0x01,0xFC,0x03,0x0E,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x07,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0x95 +.db 0x00,0x00,0x60,0x00,0xF0,0x00,0x98,0x01,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x07,0xFC,0x07,0xF8,0x06,0x00,0x00,0x00,0x00, ; 0x96 +.db 0x00,0x00,0x30,0x00,0x60,0x00,0xC0,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x07,0xFC,0x07,0xF8,0x06,0x00,0x00,0x00,0x00, ; 0x97 +.db 0x00,0x00,0x00,0x00,0x98,0x01,0x98,0x01,0x00,0x00,0x0C,0x03,0x0C,0x03,0x98,0x01,0x98,0x01,0xF0,0x00,0xF0,0x00,0x60,0x00,0x60,0x00,0x30,0x00,0x30,0x00,0x18,0x00, ; 0x98 +.db 0x98,0x01,0x98,0x01,0x00,0x00,0xF8,0x01,0xFC,0x03,0x0E,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x07,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0x99 +.db 0x00,0x00,0x00,0x00,0x98,0x01,0x98,0x01,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x07,0xFC,0x07,0xF8,0x06,0x00,0x00,0x00,0x00, ; 0x9A +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x06,0xFC,0x03,0x8E,0x07,0xC6,0x06,0x66,0x06,0x36,0x06,0x1E,0x07,0xFC,0x03,0xF6,0x01,0x00,0x00,0x00,0x00, ; 0x9B +.db 0x00,0x00,0x00,0x00,0xE0,0x01,0xF0,0x03,0x30,0x03,0x30,0x00,0x30,0x00,0xF8,0x00,0x30,0x00,0x30,0x00,0x18,0x00,0xFC,0x07,0xDC,0x03,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x9C +.db 0x00,0x00,0x00,0x00,0xF8,0x06,0xFC,0x03,0x8E,0x07,0xC6,0x06,0xC6,0x06,0x66,0x06,0x66,0x06,0x36,0x06,0x36,0x06,0x1E,0x07,0xFC,0x03,0xF6,0x01,0x00,0x00,0x00,0x00, ; 0x9D +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x03,0x98,0x01,0xF0,0x00,0x60,0x00,0xF0,0x00,0x98,0x01,0x0C,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x9E +.db 0xC0,0x01,0xE0,0x03,0x60,0x03,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xF8,0x01,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x6C,0x00,0x7C,0x00,0x38,0x00,0x00,0x00, ; 0x9F +.db 0x00,0x00,0xC0,0x00,0x60,0x00,0x30,0x00,0x00,0x00,0xF8,0x03,0xFC,0x07,0x00,0x06,0xF8,0x07,0xFC,0x07,0x06,0x06,0x06,0x06,0xFE,0x07,0xFC,0x07,0x00,0x00,0x00,0x00, ; 0xA0 +.db 0x00,0x00,0xC0,0x00,0x60,0x00,0x30,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xF8,0x01,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0xA1 +.db 0x00,0x00,0xC0,0x00,0x60,0x00,0x30,0x00,0x00,0x00,0xF8,0x01,0xFC,0x03,0x0E,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x07,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0xA2 +.db 0x00,0x00,0xC0,0x00,0x60,0x00,0x30,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x07,0xFC,0x07,0xF8,0x06,0x00,0x00,0x00,0x00, ; 0xA3 +.db 0x00,0x00,0x00,0x00,0x70,0x03,0xD8,0x01,0x00,0x00,0xFC,0x01,0xFC,0x03,0x0C,0x07,0x0C,0x06,0x0C,0x06,0x0C,0x06,0x0C,0x06,0x0C,0x06,0x0C,0x06,0x00,0x00,0x00,0x00, ; 0xA4 +.db 0x70,0x03,0xD8,0x01,0x00,0x00,0x06,0x06,0x0E,0x06,0x1E,0x06,0x3E,0x06,0x76,0x06,0xE6,0x06,0xC6,0x07,0x86,0x07,0x06,0x07,0x06,0x06,0x06,0x06,0x00,0x00,0x00,0x00, ; 0xA5 +.db 0xF8,0x03,0xFC,0x07,0x00,0x06,0xFC,0x07,0xFE,0x07,0x06,0x06,0xFE,0x07,0xFC,0x07,0x00,0x00,0xFC,0x03,0xFC,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xA6 +.db 0xF8,0x01,0xFC,0x03,0x0E,0x07,0x06,0x06,0x06,0x06,0x0E,0x07,0xFC,0x03,0xF8,0x01,0x00,0x00,0xFC,0x03,0xFC,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xA7 +.db 0x60,0x00,0x60,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x70,0x00,0x38,0x00,0x1C,0x00,0x0E,0x06,0x06,0x06,0x0E,0x07,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0xA8 +.db 0x00,0x00,0x00,0x00,0xF8,0x03,0xFC,0x07,0x0E,0x0E,0xF6,0x0C,0xB6,0x0D,0xF6,0x0C,0xB6,0x0D,0xB6,0x0D,0x0E,0x0E,0xFC,0x07,0xF8,0x03,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xA9 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x07,0xFF,0x07,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xAA +.db 0x00,0x00,0x00,0x00,0x0C,0x00,0x0E,0x00,0x0C,0x03,0x8C,0x01,0xDE,0x00,0x60,0x00,0xB0,0x03,0x18,0x06,0x0C,0x03,0x80,0x01,0x80,0x07,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xAB +.db 0x00,0x00,0x00,0x00,0x0C,0x00,0x0E,0x00,0x0C,0x03,0x8C,0x01,0xDE,0x00,0x60,0x00,0xB0,0x06,0xD8,0x06,0xCC,0x07,0x00,0x06,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xAC +.db 0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xF0,0x00,0xF0,0x00,0xF0,0x00,0xF0,0x00,0xF0,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00, ; 0xAD +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x03,0x8C,0x01,0xC6,0x00,0x8C,0x01,0x18,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xAE +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC6,0x00,0x8C,0x01,0x18,0x03,0x8C,0x01,0xC6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xAF +.db 0x11,0x01,0x44,0x04,0x11,0x01,0x44,0x04,0x11,0x01,0x44,0x04,0x11,0x01,0x44,0x04,0x11,0x01,0x44,0x04,0x11,0x01,0x44,0x04,0x11,0x01,0x44,0x04,0x11,0x01,0x44,0x04, ; 0xB0 +.db 0xAA,0x0A,0x55,0x05,0xAA,0x0A,0x55,0x05,0xAA,0x0A,0x55,0x05,0xAA,0x0A,0x55,0x05,0xAA,0x0A,0x55,0x05,0xAA,0x0A,0x55,0x05,0xAA,0x0A,0x55,0x05,0xAA,0x0A,0x55,0x05, ; 0xB1 +.db 0xEE,0x0E,0xBB,0x0B,0xEE,0x0E,0xBB,0x0B,0xEE,0x0E,0xBB,0x0B,0xEE,0x0E,0xBB,0x0B,0xEE,0x0E,0xBB,0x0B,0xEE,0x0E,0xBB,0x0B,0xEE,0x0E,0xBB,0x0B,0xEE,0x0E,0xBB,0x0B, ; 0xB2 +.db 0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00, ; 0xB3 +.db 0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x7F,0x00,0x7F,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00, ; 0xB4 +.db 0xC0,0x00,0x60,0x00,0x30,0x00,0x60,0x00,0x60,0x00,0xF0,0x00,0xF0,0x00,0x98,0x01,0x98,0x01,0x0C,0x03,0xFC,0x03,0xFE,0x07,0x06,0x06,0x06,0x06,0x00,0x00,0x00,0x00, ; 0xB5 +.db 0x60,0x00,0xF0,0x00,0x98,0x01,0x60,0x00,0x60,0x00,0xF0,0x00,0xF0,0x00,0x98,0x01,0x98,0x01,0x0C,0x03,0xFC,0x03,0xFE,0x07,0x06,0x06,0x06,0x06,0x00,0x00,0x00,0x00, ; 0xB6 +.db 0x30,0x00,0x60,0x00,0xC0,0x00,0x60,0x00,0x60,0x00,0xF0,0x00,0xF0,0x00,0x98,0x01,0x98,0x01,0x0C,0x03,0xFC,0x03,0xFE,0x07,0x06,0x06,0x06,0x06,0x00,0x00,0x00,0x00, ; 0xB7 +.db 0x00,0x00,0x00,0x00,0xF8,0x03,0xFC,0x07,0x0E,0x0E,0xE6,0x0C,0xB6,0x0D,0x36,0x0C,0xB6,0x0D,0xE6,0x0C,0x0E,0x0E,0xFC,0x07,0xF8,0x03,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xB8 +.db 0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6F,0x00,0x6F,0x00,0x60,0x00,0x6F,0x00,0x6F,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00, ; 0xB9 +.db 0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00, ; 0xBA +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x7F,0x00,0x60,0x00,0x6F,0x00,0x6F,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00, ; 0xBB +.db 0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6F,0x00,0x6F,0x00,0x60,0x00,0x7F,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xBC +.db 0x00,0x00,0x60,0x00,0x60,0x00,0xF0,0x01,0xF8,0x03,0x7C,0x03,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x7C,0x03,0xF8,0x03,0xF0,0x01,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00, ; 0xBD +.db 0x06,0x06,0x06,0x06,0x0C,0x03,0x0C,0x03,0x98,0x01,0x98,0x01,0xF0,0x00,0xF0,0x00,0x60,0x00,0xFC,0x03,0x60,0x00,0xFC,0x03,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00, ; 0xBE +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x7F,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00, ; 0xBF +.db 0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xE0,0x0F,0xE0,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xC0 +.db 0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xFF,0x0F,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xC1 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x0F,0xFF,0x0F,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00, ; 0xC2 +.db 0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xE0,0x0F,0xE0,0x0F,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00, ; 0xC3 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x0F,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xC4 +.db 0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xFF,0x0F,0xFF,0x0F,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00, ; 0xC5 +.db 0x00,0x00,0x00,0x00,0x70,0x03,0xD8,0x01,0x00,0x00,0xF8,0x03,0xFC,0x07,0x00,0x06,0xF8,0x07,0xFC,0x07,0x06,0x06,0x06,0x06,0xFE,0x07,0xFC,0x07,0x00,0x00,0x00,0x00, ; 0xC6 +.db 0x70,0x03,0xD8,0x01,0x00,0x00,0x60,0x00,0x60,0x00,0xF0,0x00,0xF0,0x00,0x98,0x01,0x98,0x01,0x0C,0x03,0xFC,0x03,0xFE,0x07,0x06,0x06,0x06,0x06,0x00,0x00,0x00,0x00, ; 0xC7 +.db 0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0xEC,0x0F,0xEC,0x0F,0x0C,0x00,0xFC,0x0F,0xFC,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xC8 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x0F,0xFC,0x0F,0x0C,0x00,0xEC,0x0F,0xEC,0x0F,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00, ; 0xC9 +.db 0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0xEF,0x0F,0xEF,0x0F,0x00,0x00,0xFF,0x0F,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xCA +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x0F,0xFF,0x0F,0x00,0x00,0xEF,0x0F,0xEF,0x0F,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00, ; 0xCB +.db 0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0xEC,0x0F,0xEC,0x0F,0x0C,0x00,0xEC,0x0F,0xEC,0x0F,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00, ; 0xCC +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x0F,0xFF,0x0F,0x00,0x00,0xFF,0x0F,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xCD +.db 0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0xEF,0x0F,0xEF,0x0F,0x00,0x00,0xEF,0x0F,0xEF,0x0F,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00, ; 0xCE +.db 0x00,0x00,0x06,0x06,0xF6,0x06,0xFC,0x03,0x0E,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x07,0xFC,0x03,0xF6,0x06,0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xCF +.db 0x00,0x00,0x00,0x00,0xF0,0x00,0xF8,0x01,0x18,0x01,0x18,0x00,0x38,0x00,0x70,0x00,0xE0,0x00,0xF0,0x01,0x98,0x01,0x98,0x01,0xF8,0x01,0xF0,0x00,0x00,0x00,0x00,0x00, ; 0xD0 +.db 0xFC,0x00,0xFC,0x01,0x8C,0x03,0x0C,0x03,0x0C,0x06,0x0C,0x06,0x1E,0x06,0x1E,0x06,0x0C,0x06,0x0C,0x06,0x0C,0x03,0x8C,0x03,0xFC,0x01,0xFC,0x00,0x00,0x00,0x00,0x00, ; 0xD1 +.db 0x60,0x00,0xF0,0x00,0x98,0x01,0xFE,0x07,0xFE,0x07,0x06,0x00,0x06,0x00,0xFE,0x01,0xFE,0x01,0x06,0x00,0x06,0x00,0x06,0x00,0xFE,0x07,0xFE,0x07,0x00,0x00,0x00,0x00, ; 0xD2 +.db 0x98,0x01,0x98,0x01,0x00,0x00,0xFE,0x07,0xFE,0x07,0x06,0x00,0x06,0x00,0xFE,0x01,0xFE,0x01,0x06,0x00,0x06,0x00,0x06,0x00,0xFE,0x07,0xFE,0x07,0x00,0x00,0x00,0x00, ; 0xD3 +.db 0x18,0x00,0x30,0x00,0x60,0x00,0xFE,0x07,0xFE,0x07,0x06,0x00,0x06,0x00,0xFE,0x01,0xFE,0x01,0x06,0x00,0x06,0x00,0x06,0x00,0xFE,0x07,0xFE,0x07,0x00,0x00,0x00,0x00, ; 0xD4 +.db 0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xD5 +.db 0x80,0x01,0xC0,0x00,0x60,0x00,0xF8,0x01,0xF8,0x01,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xF8,0x01,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0xD6 +.db 0x60,0x00,0xF0,0x00,0x98,0x01,0xF8,0x01,0xF8,0x01,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xF8,0x01,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0xD7 +.db 0x98,0x01,0x98,0x01,0x00,0x00,0xF8,0x01,0xF8,0x01,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xF8,0x01,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0xD8 +.db 0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x7F,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xD9 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x0F,0xE0,0x0F,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00, ; 0xDA +.db 0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F, ; 0xDB +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F, ; 0xDC +.db 0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00, ; 0xDD +.db 0x18,0x00,0x30,0x00,0x60,0x00,0xF8,0x01,0xF8,0x01,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xF8,0x01,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0xDE +.db 0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xDF +.db 0x80,0x01,0xC0,0x00,0x60,0x00,0xF8,0x01,0xFC,0x03,0x0E,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x07,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0xE0 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x98,0x01,0x0C,0x03,0x0C,0x03,0xFC,0x01,0x8C,0x03,0x0C,0x03,0x0C,0x03,0x8C,0x03,0xFC,0x01,0x0C,0x00,0x0C,0x00, ; 0xE1 +.db 0x60,0x00,0xF0,0x00,0x98,0x01,0xF8,0x01,0xFC,0x03,0x0E,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x07,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0xE2 +.db 0x18,0x00,0x30,0x00,0x60,0x00,0xF8,0x01,0xFC,0x03,0x0E,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x07,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0xE3 +.db 0x00,0x00,0x00,0x00,0xB8,0x01,0xEC,0x00,0x00,0x00,0xF8,0x01,0xFC,0x03,0x0E,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x07,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0xE4 +.db 0x70,0x03,0xD8,0x01,0x00,0x00,0xF8,0x01,0xFC,0x03,0x0E,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x07,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0xE5 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x8E,0x03,0xFE,0x03,0x7E,0x03,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00, ; 0xE6 +.db 0x00,0x00,0x00,0x00,0x3C,0x00,0x3C,0x00,0x18,0x00,0xF8,0x01,0xF8,0x03,0x18,0x03,0x18,0x03,0xF8,0x03,0xF8,0x01,0x18,0x00,0x3C,0x00,0x3C,0x00,0x00,0x00,0x00,0x00, ; 0xE7 +.db 0x3C,0x00,0x3C,0x00,0x18,0x00,0xF8,0x01,0xF8,0x03,0x18,0x03,0x18,0x03,0x18,0x03,0x18,0x03,0xF8,0x03,0xF8,0x01,0x18,0x00,0x3C,0x00,0x3C,0x00,0x00,0x00,0x00,0x00, ; 0xE8 +.db 0x80,0x01,0xC0,0x00,0x60,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x03,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0xE9 +.db 0x60,0x00,0xF0,0x00,0x98,0x01,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x03,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0xEA +.db 0x18,0x00,0x30,0x00,0x60,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x03,0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00, ; 0xEB +.db 0x00,0x00,0x00,0x00,0x80,0x01,0xC0,0x00,0x60,0x00,0x0C,0x03,0x0C,0x03,0x98,0x01,0x98,0x01,0xF0,0x00,0xF0,0x00,0x60,0x00,0x60,0x00,0x30,0x00,0x30,0x00,0x18,0x00, ; 0xEC +.db 0x80,0x01,0xC0,0x00,0x60,0x00,0x06,0x06,0x0C,0x03,0x98,0x01,0xF0,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00, ; 0xED +.db 0x00,0x00,0x00,0x00,0xE0,0x01,0xE0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xEE +.db 0xC0,0x00,0x60,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xEF +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x01,0xF8,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xF0 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0xF8,0x01,0xF8,0x01,0x60,0x00,0x60,0x00,0x00,0x00,0xF8,0x01,0xF8,0x01,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xF1 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x01,0xF8,0x01,0x00,0x00,0xF8,0x01,0xF8,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xF2 +.db 0x00,0x00,0x00,0x00,0x0E,0x00,0x18,0x00,0x0C,0x03,0x98,0x01,0xCE,0x00,0x60,0x00,0xB0,0x06,0xD8,0x06,0xCC,0x07,0x00,0x06,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xF3 +.db 0x00,0x00,0xF8,0x07,0x6C,0x03,0x66,0x03,0x66,0x03,0x66,0x03,0x6C,0x03,0x78,0x03,0x60,0x03,0x60,0x03,0x60,0x03,0x60,0x03,0x60,0x03,0x60,0x03,0x00,0x00,0x00,0x00, ; 0xF4 +.db 0x00,0x00,0xF8,0x01,0x0C,0x03,0x0C,0x00,0x0C,0x00,0xF8,0x01,0x0C,0x03,0x0C,0x03,0xF8,0x01,0x00,0x03,0x00,0x03,0x0C,0x03,0xF8,0x01,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xF5 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0xFC,0x03,0xFC,0x03,0x00,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xF6 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC8,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xF7 +.db 0xF0,0x00,0xF8,0x01,0x98,0x01,0x98,0x01,0xF8,0x01,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xF8 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x01,0x9C,0x03,0x9C,0x03,0x08,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xF9 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0xE0,0x00,0xE0,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xFA +.db 0x18,0x00,0x1C,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xFB +.db 0x3C,0x00,0x60,0x00,0x38,0x00,0x60,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xFC +.db 0x3C,0x00,0x60,0x00,0x38,0x00,0x0C,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xFD +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0xF0,0x00,0xF0,0x00,0xF0,0x00,0xF0,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xFE +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ; 0xFF + diff --git a/avr/modules/lcd2/ili9341/main.asm b/avr/modules/lcd2/ili9341/main.asm index bbd6fb5..a0b355f 100644 --- a/avr/modules/lcd2/ili9341/main.asm +++ b/avr/modules/lcd2/ili9341/main.asm @@ -21,7 +21,7 @@ .dseg -ILI9341_buffer: .byte 128 +;ILI9341_buffer: .byte 128 ; *************************************************************************** @@ -45,6 +45,7 @@ ILI9341_Init: rcall ILI9341_SetBacklight +#if 0 ldi r16, 0xff mov r3, r16 ldi r16, 0xff @@ -84,7 +85,6 @@ ILI9341_Init: mov r0, r16 mov r1, r16 -#if 0 ; set Xpos ldi r16, LOW(100) mov r4, r16 From d4ad6844e3bd0cfdeff9c0312a0515fd379d5362 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 2 Jun 2025 01:03:23 +0200 Subject: [PATCH 003/196] ili9341: save X --- avr/modules/lcd2/ili9341/text.asm | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/avr/modules/lcd2/ili9341/text.asm b/avr/modules/lcd2/ili9341/text.asm index 5345247..5950906 100644 --- a/avr/modules/lcd2/ili9341/text.asm +++ b/avr/modules/lcd2/ili9341/text.asm @@ -29,11 +29,15 @@ ; @clobbers r16 (r17, r20, r21, r22, r23, r24, r25, X) ili9341_WriteCharacterX1At: - rcall ili9341FontRenderChar ; (r16, r17, r24, r25, z) - rcall ili9341BitBlit ; (r16, r17, r20, r21, r22, r23, r24, r25, X) - ; advance X (add char width to X) - add r4, r8 - adc r5, r9 + push xl + push xh + rcall ili9341FontRenderChar ; (r16, r17, r24, r25, z) + rcall ili9341BitBlit ; (r16, r17, r20, r21, r22, r23, r24, r25, X) + ; advance X (add char width to X) + add r4, r8 + adc r5, r9 + pop xh + pop xl ret ; @end @@ -111,7 +115,7 @@ ili9341FontRenderChar: push xl push xh ; call render function of the selected font (first word of font is jmp to render function) - rcall ili9341JumpToFontRenderFn ; (r17, r24, r25, x, z) + rcall ili9341JumpToFontRenderFn ; (r17, r24, r25, x) pop xh pop xl From 5153bd2f6960108088a5e017a15b5260a4127641 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 2 Jun 2025 01:04:49 +0200 Subject: [PATCH 004/196] removed signal "CREATED". unsure when this would be called: - when the basic object is called? - when the last derived object is called? better remove it to avoid complications... --- avr/modules/lcd2/win/defs.asm | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/avr/modules/lcd2/win/defs.asm b/avr/modules/lcd2/win/defs.asm index 50b50ef..1593358 100644 --- a/avr/modules/lcd2/win/defs.asm +++ b/avr/modules/lcd2/win/defs.asm @@ -65,21 +65,21 @@ ; Signals -.equ OBJ_SIGNAL_CREATED = 0 -.equ OBJ_SIGNAL_DESTROY = 1 -.equ OBJ_SIGNAL_GETVALUE = 2 -.equ OBJ_SIGNAL_SETVALUE = 3 -.equ OBJ_SIGNAL_TIMER = 4 -.equ OBJ_SIGNAL_NEXTFREE = 5 +.equ OBJ_SIGNAL_DESTROY = 0 +.equ OBJ_SIGNAL_GETVALUE = 1 +.equ OBJ_SIGNAL_SETVALUE = 2 +.equ OBJ_SIGNAL_TIMER = 3 +.equ OBJ_SIGNAL_NEXTFREE = 4 -.equ WID_SIGNAL_SHOW = OBJ_SIGNAL_NEXTFREE -.equ WID_SIGNAL_HIDE = OBJ_SIGNAL_NEXTFREE+1 -.equ WID_SIGNAL_UPDATE = OBJ_SIGNAL_NEXTFREE+2 -.equ WID_SIGNAL_LAYOUT = OBJ_SIGNAL_NEXTFREE+3 -.equ WID_SIGNAL_TOUCH = OBJ_SIGNAL_NEXTFREE+4 -.equ WID_SIGNAL_MOUSE = OBJ_SIGNAL_NEXTFREE+5 -.equ WID_SIGNAL_KEY = OBJ_SIGNAL_NEXTFREE+6 -.equ WID_SIGNAL_NEXTFREE = OBJ_SIGNAL_NEXTFREE+7 +.equ WID_SIGNAL_SHOW = OBJ_SIGNAL_NEXTFREE +.equ WID_SIGNAL_HIDE = OBJ_SIGNAL_NEXTFREE+1 +.equ WID_SIGNAL_UPDATE = OBJ_SIGNAL_NEXTFREE+2 +.equ WID_SIGNAL_LAYOUT = OBJ_SIGNAL_NEXTFREE+3 +.equ WID_SIGNAL_TOUCH = OBJ_SIGNAL_NEXTFREE+4 +.equ WID_SIGNAL_MOUSE = OBJ_SIGNAL_NEXTFREE+5 +.equ WID_SIGNAL_KEY = OBJ_SIGNAL_NEXTFREE+6 +.equ WID_SIGNAL_GETMINSIZE = OBJ_SIGNAL_NEXTFREE+7 +.equ WID_SIGNAL_NEXTFREE = OBJ_SIGNAL_NEXTFREE+8 @@ -92,9 +92,9 @@ .equ OBJ_LINK_OFFS_TARGET_HI = LIST_SIZE+3 .equ OBJ_LINK_SIZE = LIST_SIZE+4 ; fns: -; - removeLinksTo() -; - addLink() -; - removeLinks() +; - removeLinksTo(Y=win, r19:r18=target) +; - addLink(Y=win, r16=signal, r17=slot, r19:r18=target) +; - removeLinks(Y=win) From cd1fce313ec34219af75e9f1a36e33f13bb60fe3 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 2 Jun 2025 21:13:01 +0200 Subject: [PATCH 005/196] avr: added some unit tests for LIST and TREE. --- avr/common/list.asm | 95 ++++++++- avr/common/list_t.asm | 240 +++++++++++++++++++++ avr/common/tree.asm | 88 +++++--- avr/common/tree_t.asm | 381 ++++++++++++++++++++++++++++++++++ avr/devices/all/includes.asm | 14 ++ avr/devices/c02/main/main.asm | 127 ++++++++++-- avr/modules/heap/main.asm | 13 ++ 7 files changed, 909 insertions(+), 49 deletions(-) create mode 100644 avr/common/list_t.asm create mode 100644 avr/common/tree_t.asm diff --git a/avr/common/list.asm b/avr/common/list.asm index 93240ed..2afa294 100644 --- a/avr/common/list.asm +++ b/avr/common/list.asm @@ -54,11 +54,26 @@ List_InitObject: +; --------------------------------------------------------------------------- +; @routine List_FiniObject @global +; +; @param Y pointer to object +; @clobbers r16 + +List_FiniObject: + clr r16 ; set this->NEXT to NULL + std Y+LIST_OFFS_NEXT_LO, r16 + std Y+LIST_OFFS_NEXT_HI, r16 + ret +; @end + + + ; --------------------------------------------------------------------------- ; @routine List_GetNextObject @global ; @param Y pointer to object -; @return X pointer to parent object +; @return X pointer to successor object ; @clobbers none List_GetNextObject: @@ -101,13 +116,13 @@ List_GetPredecessorFor: cp r16, yl brne List_GetPredecessorFor_next cp r17, yh - breq List_GetLastObject_haveIt + breq List_GetPredecessorFor_haveIt List_GetPredecessorFor_next: mov xl, r16 mov xh, r17 rjmp List_GetPredecessorFor List_GetPredecessorFor_haveIt: - sbiw xh:xl, 1 + sbiw xh:xl, 2 List_GetPredecessorFor_ret: ret ; @end @@ -127,8 +142,14 @@ List_AddObject: rcall List_GetLastObject ; (r16, r17, X, Y) pop yh pop yl - st X+, yl ; WID_OFFS_WNEXT_LO - st X+, yh ; WID_OFFS_WNEXT_HI + mov r16, xl + or r16, xh + clc + breq List_AddObject_ret + st X+, yl ; LIST_OFFS_NEXT_LO + st X+, yh ; LIST_OFFS_NEXT_HI + sec +List_AddObject_ret: ret ; @end @@ -163,4 +184,68 @@ List_UnlinkObject_ret: +; --------------------------------------------------------------------------- +; @routine List_UnlinkAllObjects + +; @param Y pointer to first object in a list +; @clobbers r16, r17, r18, Y + +List_UnlinkAllObjects: + clr r18 +List_UnlinkAllObjects_loop: + ldd r16, Y+LIST_OFFS_NEXT_LO + ldd r17, Y+LIST_OFFS_NEXT_HI + std Y+LIST_OFFS_NEXT_LO, r18 + std Y+LIST_OFFS_NEXT_HI, r18 + mov yl, r16 + mov yh, r17 + or r16, r17 + brne List_UnlinkAllObjects_loop + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine List_ForEveryObject +; +; Calls the given function for every object until it +; returns with a set carry flag or until the full list +; is handled. +; Registers that can be used by the given function are all +; except R16, R18 and R19 (those are used by this routine). +; +; @param Y pointer to first object in a list +; @param Z routine to call for every object +; @clobbers r16, r17, r18, r19, X, Y (r24, r25) + +List_ForEveryObject: +List_ForEveryObject_loop: + ldd r18, Y+LIST_OFFS_NEXT_LO ; next + ldd r19, Y+LIST_OFFS_NEXT_HI ; next + clr r16 + std Y+LIST_OFFS_NEXT_LO, r16 + std Y+LIST_OFFS_NEXT_HI, r16 + push r18 ; next + push r19 ; next + rcall List_ForEveryObject_callZ + pop r19 ; next + pop r18 ; next + brcs List_ForEveryObject_ret + mov yl, r18 + mov yh, r19 + or r18, r19 + brne List_ForEveryObject_loop +List_ForEveryObject_ret: + ret +List_ForEveryObject_callZ: + ijmp +; @end + + + + + + + #endif ; AQH_AVR_COMMON_LIST_H diff --git a/avr/common/list_t.asm b/avr/common/list_t.asm new file mode 100644 index 0000000..5fa22cf --- /dev/null +++ b/avr/common/list_t.asm @@ -0,0 +1,240 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + +#ifndef AQH_AVR_COMMON_LIST_T_H +#define AQH_AVR_COMMON_LIST_T_H + + + +.equ LIST_TEST_OBJECT_OFFS_LIST = 0 +.equ LIST_TEST_OBJECT_OFFS_VALUE1 = LIST_SIZE +.equ LIST_TEST_OBJECT_OFFS_VALUE2 = LIST_SIZE+1 +.equ LIST_TEST_OBJECT_SIZE = LIST_SIZE+2 + + + + +.dseg + +listTest_list: .byte 2 +listTest_object1: .byte LIST_TEST_OBJECT_SIZE +listTest_object2: .byte LIST_TEST_OBJECT_SIZE +listTest_object3: .byte LIST_TEST_OBJECT_SIZE + + + +.cseg + + +; --------------------------------------------------------------------------- +; @routine listTest_Object_Init +; @param Y pointer to object to init +; @param r18 value 1 +; @param r19 value 2 + +listTest_Object_Init: + bigcall List_InitObject ; (R16) + std Y+LIST_TEST_OBJECT_OFFS_VALUE1, r18 + std Y+LIST_TEST_OBJECT_OFFS_VALUE2, r19 + ret +; @end + + + +listTest1: + ldi yl, LOW(listTest_object1) + ldi yh, HIGH(listTest_object1) + ldi r18, 1 + ldi r19, 2 + rcall listTest_Object_Init + sts listTest_list, yl + sts listTest_list+1, yh + mov xl, yl ; X=listTest_object1 + mov xh, yh + + ldi yl, LOW(listTest_object2) + ldi yh, HIGH(listTest_object2) + ldi r18, 3 + ldi r19, 4 + rcall listTest_Object_Init + + ; X=object 1, Y=object 2 + bigcall List_AddObject ; (r16, r17, x) + + lds yl, listTest_list + lds yh, listTest_list+1 + + ldd r16, Y+LIST_TEST_OBJECT_OFFS_VALUE1 + cpi r16, 1 + ldi r16, 1 + brne listTest1_error + ldd r16, Y+LIST_TEST_OBJECT_OFFS_VALUE2 + cpi r16, 2 + ldi r16, 2 + brne listTest1_error + + bigcall List_GetNextObject + ldi r16, 3 + cpi xl, LOW(listTest_object2) + brne listTest1_error + cpi xh, HIGH(listTest_object2) + brne listTest1_error + + mov yl, xl + mov yh, xh + ldd r16, Y+LIST_TEST_OBJECT_OFFS_VALUE1 + cpi r16, 3 + ldi r16, 4 + brne listTest1_error + ldd r16, Y+LIST_TEST_OBJECT_OFFS_VALUE2 + cpi r16, 4 + ldi r16, 5 + brne listTest1_error + + bigcall List_GetNextObject + mov r16, xh + or r16, xl + ldi r16, 6 + brne listTest1_error + sec + ret +listTest1_error: + clc + ret +; @end + + + +listTest2: + lds xl, listTest_list + lds xh, listTest_list+1 + + ldi yl, LOW(listTest_object3) + ldi yh, HIGH(listTest_object3) + ldi r18, 5 + ldi r19, 6 + rcall listTest_Object_Init + + ; X=object 1, Y=object 2 + bigcall List_AddObject ; (r16, r17, x) + + mov xl, yl + mov xh, yh + bigcall List_GetLastObject + ldi r16, 1 + cpi xl, LOW(listTest_object3) + brne listTest2_error + cpi xh, HIGH(listTest_object3) + brne listTest2_error + + mov yl, xl + mov yh, xh + ldd r16, Y+LIST_TEST_OBJECT_OFFS_VALUE1 + cpi r16, 5 + ldi r16, 2 + brne listTest2_error + ldd r16, Y+LIST_TEST_OBJECT_OFFS_VALUE2 + cpi r16, 6 + ldi r16, 3 + brne listTest2_error + + sec + ret +listTest2_error: + clc + ret +; @end + + + +listTest3: + lds xl, listTest_list + lds xh, listTest_list+1 + ldi yl, LOW(listTest_object2) + ldi yh, HIGH(listTest_object2) + bigcall List_UnlinkObject + + lds yl, listTest_list + lds yh, listTest_list+1 + + ldd r16, Y+LIST_TEST_OBJECT_OFFS_VALUE1 + cpi r16, 1 + ldi r16, 1 + brne listTest3_error + ldd r16, Y+LIST_TEST_OBJECT_OFFS_VALUE2 + cpi r16, 2 + ldi r16, 2 + brne listTest3_error + + bigcall List_GetNextObject + ldi r16, 3 + cpi xl, LOW(listTest_object3) + brne listTest3_error + cpi xh, HIGH(listTest_object3) + brne listTest3_error + + mov yl, xl + mov yh, xh + ldd r16, Y+LIST_TEST_OBJECT_OFFS_VALUE1 + cpi r16, 5 + ldi r16, 4 + brne listTest3_error + ldd r16, Y+LIST_TEST_OBJECT_OFFS_VALUE2 + cpi r16, 6 + ldi r16, 5 + brne listTest3_error + + bigcall List_GetNextObject + mov r16, xh + or r16, xl + ldi r16, 6 + brne listTest3_error + sec + ret +listTest3_error: + clc + ret +; @end + + + +listTest4: + lds xl, listTest_list + lds xh, listTest_list+1 + ldi yl, LOW(listTest_object3) + ldi yh, HIGH(listTest_object3) + bigcall List_UnlinkObject + + lds yl, listTest_list + lds yh, listTest_list+1 + + ldd r16, Y+LIST_TEST_OBJECT_OFFS_VALUE1 + cpi r16, 1 + ldi r16, 1 + brne listTest4_error + ldd r16, Y+LIST_TEST_OBJECT_OFFS_VALUE2 + cpi r16, 2 + ldi r16, 2 + brne listTest4_error + + bigcall List_GetNextObject + mov r16, xh + or r16, xl + ldi r16, 6 + brne listTest4_error + sec + ret +listTest4_error: + clc + ret +; @end + + + +#endif diff --git a/avr/common/tree.asm b/avr/common/tree.asm index 38e197a..d30465e 100644 --- a/avr/common/tree.asm +++ b/avr/common/tree.asm @@ -17,10 +17,10 @@ ; defs .equ TREE_OFFS_LIST = 0 -.equ TREE_OFFS_WPARENT_LO = TREE_OFFS_LIST+LIST_SIZE -.equ TREE_OFFS_WPARENT_HI = TREE_OFFS_LIST+LIST_SIZE+1 -.equ TREE_OFFS_WCHILD_LO = TREE_OFFS_LIST+LIST_SIZE+2 -.equ TREE_OFFS_WCHILD_HI = TREE_OFFS_LIST+LIST_SIZE+3 +.equ TREE_OFFS_PARENT_LO = TREE_OFFS_LIST+LIST_SIZE +.equ TREE_OFFS_PARENT_HI = TREE_OFFS_LIST+LIST_SIZE+1 +.equ TREE_OFFS_CHILD_LO = TREE_OFFS_LIST+LIST_SIZE+2 +.equ TREE_OFFS_CHILD_HI = TREE_OFFS_LIST+LIST_SIZE+3 .equ TREE_SIZE = TREE_OFFS_LIST+LIST_SIZE+4 @@ -42,10 +42,10 @@ Tree_InitObject: rcall List_InitObject ; (R16) clr r16 ; clear this->TREE data - std Y+TREE_OFFS_LIST+TREE_OFFS_WPARENT_LO, r16 - std Y+TREE_OFFS_LIST+TREE_OFFS_WPARENT_HI, r16 - std Y+TREE_OFFS_LIST+TREE_OFFS_WCHILD_LO, r16 - std Y+TREE_OFFS_LIST+TREE_OFFS_WCHILD_HI, r16 + std Y+TREE_OFFS_LIST+TREE_OFFS_PARENT_LO, r16 + std Y+TREE_OFFS_LIST+TREE_OFFS_PARENT_HI, r16 + std Y+TREE_OFFS_LIST+TREE_OFFS_CHILD_LO, r16 + std Y+TREE_OFFS_LIST+TREE_OFFS_CHILD_HI, r16 ret ; @end @@ -59,8 +59,8 @@ Tree_InitObject: ; @clobbers none Tree_GetParentObject: - ldd xl, Y+TREE_OFFS_WPARENT_LO - ldd xh, Y+TREE_OFFS_WPARENT_HI + ldd xl, Y+TREE_OFFS_PARENT_LO + ldd xh, Y+TREE_OFFS_PARENT_HI ret ; @end @@ -74,13 +74,46 @@ Tree_GetParentObject: ; @clobbers none Tree_GetFirstChildObject: - ldd xl, Y+TREE_OFFS_WCHILD_LO - ldd xh, Y+TREE_OFFS_WCHILD_HI + ldd xl, Y+TREE_OFFS_CHILD_LO + ldd xh, Y+TREE_OFFS_CHILD_HI ret ; @end +; --------------------------------------------------------------------------- +; @routine Tree_GetLastChildObject @global + +; @param Y pointer to object +; @return X pointer to last child object +; @clobbers none + +Tree_GetLastChildObject: + ldd xl, Y+TREE_OFFS_CHILD_LO + ldd xh, Y+TREE_OFFS_CHILD_HI + mov r16, xl + or r16, xh + breq Tree_GetLastChildObject_ret + rcall List_GetLastObject +Tree_GetLastChildObject_ret: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine Tree_GetNextSibling @global + +; @param Y pointer to object +; @return X pointer to successor object +; @clobbers none + +Tree_GetNextSibling: + rjmp List_GetNextObject +; @end + + + ; --------------------------------------------------------------------------- ; @routine Tree_GetObjectBelow @global @@ -101,7 +134,7 @@ treeGetObjectBelow: mov r16, xl or r16, xh brne treeGetObjectBelow_ret ; got one - rcall List_GetNextObject + rcall Tree_GetNextSibling mov r16, xl or r16, xh brne treeGetObjectBelow_ret ; got one @@ -122,27 +155,27 @@ treeGetObjectBelow_ret: ; --------------------------------------------------------------------------- ; @routine Tree_AddChildObject @global -; @param X pointer to parent to add to ; @param Y pointer to object to add +; @param X pointer to parent to add to ; @clobbers r16, r17, r18, x Tree_AddChildObject: - std Y+TREE_OFFS_WPARENT_LO, xl ; immediately store parent pointer - std Y+TREE_OFFS_WPARENT_HI, xh - adiw xh:xl, TREE_OFFS_WCHILD_LO + std Y+TREE_OFFS_PARENT_LO, xl ; immediately store parent pointer + std Y+TREE_OFFS_PARENT_HI, xh + adiw xh:xl, TREE_OFFS_CHILD_LO ; read pointer to first child ld r16, X+ ld r17, X mov r18, r16 or r18, r17 brne Tree_AddChildObject_addToChildList - st X, yh ; no child, set THIS as first + st X, yh ; no child, set THIS as first st -X, yl - sbiw xh:xl, WID_OFFS_TREE+TREE_OFFS_WCHILD_LO + sbiw xh:xl, TREE_OFFS_CHILD_LO ret Tree_AddChildObject_addToChildList: - mov xl, r16 + mov xl, r16 ; X=first child mov xh, r17 - rjmp List_AddObject + rjmp List_AddObject ; add Y as new object ; @end @@ -154,17 +187,17 @@ Tree_AddChildObject_addToChildList: ; @clobbers r16, r17, x Tree_UnlinkObject: - ldd xl, Y+TREE_OFFS_WPARENT_LO - ldd xh, Y+TREE_OFFS_WPARENT_HI + ldd xl, Y+TREE_OFFS_PARENT_LO + ldd xh, Y+TREE_OFFS_PARENT_HI mov r16, xl or r16, xh breq Tree_UnlinkObject_ret ; not part of a tree - adiw xh:xl, TREE_OFFS_WCHILD_LO ; get parent's first child to R17:R16 + adiw xh:xl, TREE_OFFS_CHILD_LO ; get parent's first child to R17:R16 ld r16, X+ ld r17, X cp r16, yl ; same as THIS? brne Tree_UnlinkObject_inList ; nope, need to check childList - cp r17, yh + cp r17, yh ; same as THIS? brne Tree_UnlinkObject_inList ; nope, need to check childList ldd r16, Y+TREE_OFFS_LIST+LIST_OFFS_NEXT_HI ; is first child, set this->NEXT as new first child st X, r16 @@ -177,8 +210,8 @@ Tree_UnlinkObject_inList: rcall List_UnlinkObject ; (R16, R17, X) Tree_UnlinkObject_clrParentAndSibling: clr r16 ; clear this->PARENT - std Y+TREE_OFFS_LIST+TREE_OFFS_WPARENT_LO, r16 - std Y+TREE_OFFS_LIST+TREE_OFFS_WPARENT_HI, r16 + std Y+TREE_OFFS_PARENT_LO, r16 + std Y+TREE_OFFS_PARENT_HI, r16 std Y+LIST_OFFS_NEXT_LO, r16 std Y+LIST_OFFS_NEXT_HI, r16 ; clear this->NEXT Tree_UnlinkObject_ret: @@ -188,5 +221,6 @@ Tree_UnlinkObject_ret: + #endif ; AQH_AVR_COMMON_TREE_H diff --git a/avr/common/tree_t.asm b/avr/common/tree_t.asm new file mode 100644 index 0000000..8bdfa51 --- /dev/null +++ b/avr/common/tree_t.asm @@ -0,0 +1,381 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + + +.equ TREE_TEST_OBJECT_OFFS_LIST = 0 +.equ TREE_TEST_OBJECT_OFFS_VALUE1 = TREE_SIZE +.equ TREE_TEST_OBJECT_OFFS_VALUE2 = TREE_SIZE+1 +.equ TREE_TEST_OBJECT_SIZE = TREE_SIZE+2 + + + +.dseg + +testTree_root: .byte TREE_TEST_OBJECT_SIZE +testTree_child1: .byte TREE_TEST_OBJECT_SIZE +testTree_child2: .byte TREE_TEST_OBJECT_SIZE +testTree_child3: .byte TREE_TEST_OBJECT_SIZE + + + + +.cseg + + +; --------------------------------------------------------------------------- +; @routine treeTest_Object_Init +; @param Y pointer to object to init +; @param r18 value 1 +; @param r19 value 2 + +treeTest_Object_Init: + bigcall Tree_InitObject ; (R16) + std Y+TREE_TEST_OBJECT_OFFS_VALUE1, r18 + std Y+TREE_TEST_OBJECT_OFFS_VALUE2, r19 + ret +; @end + + + +treeTest1: + ldi yl, LOW(testTree_root) + ldi yh, HIGH(testTree_root) + ldi r18, 1 + ldi r19, 2 + rcall treeTest_Object_Init + mov xl, yl + mov xh, yh + + rcall treeTestCreateAndAddChild1 + ldi r16, 1 ; error code + brcc treeTest1_error + + rcall treeTestCreateAndAddChild2 + ldi r16, 2 ; error code + brcc treeTest1_error + + rcall treeTestCreateAndAddChild3 + ldi r16, 3 ; error code + brcc treeTest1_error + + ldi yl, LOW(testTree_root) + ldi yh, HIGH(testTree_root) + bigcall Tree_GetFirstChildObject + ldi r16, 4 ; error code + cpi xl, LOW(testTree_child1) + brne treeTest1_error + cpi xh, HIGH(testTree_child1) + brne treeTest1_error + + mov yl, xl + mov yh, xh + ldd r16, Y+TREE_TEST_OBJECT_OFFS_VALUE1 + cpi r16, 3 + ldi r16, 5 ; error code + brne treeTest1_error + ldd r16, Y+TREE_TEST_OBJECT_OFFS_VALUE2 + cpi r16, 4 + ldi r16, 6 ; error code + brne treeTest1_error + + rcall treeTestNextSiblingIs2 + ldi r16, 7 ; error code + brcc treeTest1_error + + rcall treeTestNextSiblingIs3 + ldi r16, 8 ; error code + brcc treeTest1_error + + rcall treeTestNextSiblingIsNull + ldi r16, 9 ; error code + brcc treeTest1_error + + sec + ret + +treeTest1_error: + clc + ret +; @end + + + +treeTest2: + ldi yl, LOW(testTree_child2) + ldi yh, HIGH(testTree_child2) + bigcall Tree_UnlinkObject + + rcall treeTestCheckParentNull + ldi r16, 1 ; error code + brcc treeTest2_error + + bigcall Tree_GetNextSibling + mov r16, xl + or r16, xh + ldi r16, 2 ; error code + brne treeTest2_error + + ldi yl, LOW(testTree_root) + ldi yh, HIGH(testTree_root) + bigcall Tree_GetFirstChildObject + ldi r16, 3 ; error code + cpi xl, LOW(testTree_child1) + brne treeTest2_error + cpi xh, HIGH(testTree_child1) + brne treeTest2_error + mov yl, xl + mov yh, xh + + rcall treeTestNextSiblingIs3 + ldi r16, 4 ; error code + brcc treeTest2_error + + sec + ret +treeTest2_error: + clc + ret +; @end + + + +treeTest3: + ldi yl, LOW(testTree_child1) + ldi yh, HIGH(testTree_child1) + bigcall Tree_UnlinkObject + + rcall treeTestCheckParentNull + ldi r16, 1 ; error code + brcc treeTest3_error + + bigcall Tree_GetNextSibling + mov r16, xl + or r16, xh + ldi r16, 2 ; error code + brne treeTest3_error + + ldi yl, LOW(testTree_root) + ldi yh, HIGH(testTree_root) + bigcall Tree_GetFirstChildObject + ldi r16, 3 ; error code + cpi xl, LOW(testTree_child3) + brne treeTest3_error + cpi xh, HIGH(testTree_child3) + brne treeTest3_error + mov yl, xl + mov yh, xh + + rcall treeTestNextSiblingIsNull + ldi r16, 4 ; error code + brcc treeTest3_error + + sec + ret +treeTest3_error: + clc + ret +; @end + + + +treeTest4: + ldi yl, LOW(testTree_child1) + ldi yh, HIGH(testTree_child1) + ldi xl, LOW(testTree_root) + ldi xh, HIGH(testTree_root) + bigcall Tree_AddChildObject + + rcall treeTestCheckParentRoot + ldi r16, 1 ; error code + brcc treeTest4_error + + ldi yl, LOW(testTree_root) + ldi yh, HIGH(testTree_root) + bigcall Tree_GetFirstChildObject + ldi r16, 2 ; error code + cpi xl, LOW(testTree_child3) + brne treeTest4_error + cpi xh, HIGH(testTree_child3) + brne treeTest4_error + mov yl, xl + mov yh, xh + + rcall treeTestNextSiblingIs1 + ldi r16, 3 ; error code + brcc treeTest4_error + + rcall treeTestNextSiblingIsNull + ldi r16, 4 ; error code + brcc treeTest4_error + + sec + ret +treeTest4_error: + clc + ret +; @end + + + + + + +treeTestCreateAndAddChild1: + ldi yl, LOW(testTree_child1) + ldi yh, HIGH(testTree_child1) + ldi r18, 3 + ldi r19, 4 + rcall treeTest_Object_Init + + ldi xl, LOW(testTree_root) + ldi xh, HIGH(testTree_root) + bigcall Tree_AddChildObject + + rcall treeTestCheckParentRoot + brcc treeTestCreateAndAddChild1_error + sec + ret +treeTestCreateAndAddChild1_error: + clc + ret + + + +treeTestCreateAndAddChild2: + ldi yl, LOW(testTree_child2) + ldi yh, HIGH(testTree_child2) + ldi r18, 5 + ldi r19, 6 + rcall treeTest_Object_Init + + ldi xl, LOW(testTree_root) + ldi xh, HIGH(testTree_root) + bigcall Tree_AddChildObject + + rcall treeTestCheckParentRoot + brcc treeTestCreateAndAddChild2_error + sec + ret +treeTestCreateAndAddChild2_error: + clc + ret + + + +treeTestCreateAndAddChild3: + ldi yl, LOW(testTree_child3) + ldi yh, HIGH(testTree_child3) + ldi r18, 7 + ldi r19, 8 + rcall treeTest_Object_Init + + ldi xl, LOW(testTree_root) + ldi xh, HIGH(testTree_root) + bigcall Tree_AddChildObject + + rcall treeTestCheckParentRoot + brcc treeTestCreateAndAddChild3_error + sec + ret +treeTestCreateAndAddChild3_error: + clc + ret + + + + +treeTestCheckParentNull: + bigcall Tree_GetParentObject + mov r16, xl + or r16, xh + brne treeTestCheckParentNull_error + sec + ret +treeTestCheckParentNull_error: + clc + ret + + + +treeTestCheckParentRoot: + bigcall Tree_GetParentObject + cpi xl, LOW(testTree_root) + brne treeTestCheckParentRoot_error + cpi xh, HIGH(testTree_root) + brne treeTestCheckParentRoot_error + sec + ret +treeTestCheckParentRoot_error: + clc + ret + + + +treeTestNextSiblingIs1: + bigcall Tree_GetNextSibling + cpi xl, LOW(testTree_child1) + brne treeTestNextSiblingIs1_error + cpi xh, HIGH(testTree_child1) + brne treeTestNextSiblingIs1_error + mov yl, xl + mov yh, xh + sec + ret +treeTestNextSiblingIs1_error: + clc + ret + + + + +treeTestNextSiblingIs2: + bigcall Tree_GetNextSibling + cpi xl, LOW(testTree_child2) + brne treeTestNextSiblingIs2_error + cpi xh, HIGH(testTree_child2) + brne treeTestNextSiblingIs2_error + mov yl, xl + mov yh, xh + sec + ret +treeTestNextSiblingIs2_error: + clc + ret + + +treeTestNextSiblingIs3: + bigcall Tree_GetNextSibling + cpi xl, LOW(testTree_child3) + brne treeTestNextSiblingIs3_error + cpi xh, HIGH(testTree_child3) + brne treeTestNextSiblingIs3_error + mov yl, xl + mov yh, xh + sec + ret +treeTestNextSiblingIs3_error: + clc + ret + + + +treeTestNextSiblingIsNull: + bigcall Tree_GetNextSibling + mov r16, xl + or r16, xh + brne treeTestNextSiblingIsNull_error + sec + ret +treeTestNextSiblingIsNull_error: + clc + ret + + + diff --git a/avr/devices/all/includes.asm b/avr/devices/all/includes.asm index 297c3c0..d603918 100644 --- a/avr/devices/all/includes.asm +++ b/avr/devices/all/includes.asm @@ -165,6 +165,20 @@ .include "modules/lcd2/ili9341/text.asm" #endif +#ifdef MODULES_FONT +.include "modules/lcd2/font/defs.asm" +.include "modules/lcd2/font/main.asm" +#endif + +#ifdef MODULES_WIN +.include "common/list.asm" +.include "common/tree.asm" +.include "modules/lcd2/win/defs.asm" +.include "modules/lcd2/win/object.asm" +.include "modules/lcd2/win/widget.asm" +#endif + + #ifdef MODULES_FONT_8X8 .include "modules/lcd2/font/defs.asm" .include "modules/lcd2/font/font8x8.asm" diff --git a/avr/devices/c02/main/main.asm b/avr/devices/c02/main/main.asm index 3d96af3..ce136d1 100644 --- a/avr/devices/c02/main/main.asm +++ b/avr/devices/c02/main/main.asm @@ -38,15 +38,6 @@ -; --------------------------------------------------------------------------- -; heap - -.equ HEAP_START = SRAM_START+0x200 -.equ HEAP_SIZE = SRAM_SIZE-HEAP_START - - - - ; --------------------------------------------------------------------------- ; firmware settings including list of modules used @@ -61,9 +52,8 @@ #define MODULES_UART_BITBANG #define MODULES_SPI_HW #define MODULES_ILI9341 -;#define MODULES_FONT_8X8 -#define MODULES_FONT_6X8 -;#define MODULES_UART_BITBANG +#define MODULES_FONT +#define MODULES_WIN ;#define MODULES_TWI_MASTER ;#define MODULES_LCD ;#define LCD_MINIMAL_FONT @@ -229,9 +219,15 @@ onEveryLoop: ;.include "common/debug.asm" -.include "modules/lcd2/font/font3.asm" -.include "modules/lcd2/font/font16x26.asm" - +;.include "modules/lcd2/font/font2.asm" +;.include "modules/lcd2/font/font3.asm" +;.include "modules/lcd2/font/font16x26.asm" +;.include "modules/lcd2/font/font4.asm" +;.include "modules/lcd2/font/font12x16.asm" +.include "modules/lcd2/font/font5.asm" +.include "modules/lcd2/font/font12x20.asm" +;.include "common/list_t.asm" +.include "common/tree_t.asm" ; --------------------------------------------------------------------------- @@ -314,8 +310,10 @@ test: mov r7, r16 ; set font - ldi zl, LOW(font3_16x26*2) - ldi zh, HIGH(font3_16x26*2) +; ldi zl, LOW(font3_16x26*2) +; ldi zh, HIGH(font3_16x26*2) + ldi zl, LOW(font5_12x20*2) + ldi zh, HIGH(font5_12x20*2) ; set buffer ldi xl, LOW(glyphBuffer) @@ -340,15 +338,110 @@ test: ldi r16, 'E' bigcall ili9341_WriteCharacterX1At +#if 0 + push xl + push xh + rcall listTest1 + pop xh + pop xl + brcc test_error + ldi r16, '!' + bigcall ili9341_WriteCharacterX1At + + push xl + push xh + rcall listTest2 + pop xh + pop xl + brcc test_error + ldi r16, '!' + bigcall ili9341_WriteCharacterX1At + + push xl + push xh + rcall listTest3 + pop xh + pop xl + brcc test_error + ldi r16, '!' + bigcall ili9341_WriteCharacterX1At + + push xl + push xh + rcall listTest4 + pop xh + pop xl + brcc test_error + ldi r16, '!' + bigcall ili9341_WriteCharacterX1At +#endif + + +#if 1 + push xl + push xh + rcall treeTest1 + pop xh + pop xl + brcc test_error + ldi r16, '!' + bigcall ili9341_WriteCharacterX1At + + push xl + push xh + rcall treeTest2 + pop xh + pop xl + brcc test_error + ldi r16, '!' + bigcall ili9341_WriteCharacterX1At + + push xl + push xh + rcall treeTest3 + pop xh + pop xl + brcc test_error + ldi r16, '!' + bigcall ili9341_WriteCharacterX1At + + push xl + push xh + rcall treeTest4 + pop xh + pop xl + brcc test_error + ldi r16, '!' + bigcall ili9341_WriteCharacterX1At + + +#endif + + ret + +test_error: + ldi r17, '0' + add r16, r17 + bigcall ili9341_WriteCharacterX1At + + ret +helloWorld: .db "Hello World", 0 + + + .dseg glyphBuffer: .byte 1024 +heapStart: +.equ HEAP_START = heapStart +.equ HEAP_SIZE = SRAM_SIZE-HEAP_START + diff --git a/avr/modules/heap/main.asm b/avr/modules/heap/main.asm index 898e6ba..edf8028 100644 --- a/avr/modules/heap/main.asm +++ b/avr/modules/heap/main.asm @@ -72,6 +72,19 @@ Heap_Init: +; --------------------------------------------------------------------------- +; @routine Heap_Alloc +; +; @param r25:r24 number of bytes to alloc +; @return CFLAG set of okay, cleared otherwise +; @return X start of allocated memory + +Heap_Alloc: + rjmp heapAllocFirstFit +; @end + + + ; --------------------------------------------------------------------------- ; @routine heapAllocFirstFit From b82e0d02df56be99ae7d1fda7a4a710fcfd08a53 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 2 Jun 2025 21:13:44 +0200 Subject: [PATCH 006/196] avr: more general approach to fonts. --- avr/modules/lcd2/font/0BUILD | 4 + avr/modules/lcd2/font/defs.asm | 23 +- avr/modules/lcd2/font/font1.asm | 2 +- avr/modules/lcd2/font/font12x16.asm | 117 +++++++ avr/modules/lcd2/font/font12x20.asm | 129 ++++++++ avr/modules/lcd2/font/font16x26.asm | 14 + avr/modules/lcd2/font/font2.asm | 2 +- avr/modules/lcd2/font/font3.asm | 2 +- avr/modules/lcd2/font/font4.asm | 2 +- avr/modules/lcd2/font/font5.asm | 258 ++++++++++++++++ avr/modules/lcd2/font/font6x8.asm | 13 + avr/modules/lcd2/font/font8x8.asm | 14 + avr/modules/lcd2/font/main.asm | 167 ++++++++++ avr/modules/lcd2/ili9341/main.asm | 199 ------------ avr/modules/lcd2/ili9341/text.asm | 28 +- avr/modules/lcd2/win/defs.asm | 5 +- avr/modules/lcd2/win/object.asm | 464 ++++++++++++++++++++++++++++ avr/modules/lcd2/win/widget.asm | 9 +- 18 files changed, 1214 insertions(+), 238 deletions(-) create mode 100644 avr/modules/lcd2/font/font12x16.asm create mode 100644 avr/modules/lcd2/font/font12x20.asm create mode 100644 avr/modules/lcd2/font/font5.asm create mode 100644 avr/modules/lcd2/font/main.asm create mode 100644 avr/modules/lcd2/win/object.asm diff --git a/avr/modules/lcd2/font/0BUILD b/avr/modules/lcd2/font/0BUILD index bfdc146..de64eca 100644 --- a/avr/modules/lcd2/font/0BUILD +++ b/avr/modules/lcd2/font/0BUILD @@ -6,11 +6,15 @@ defs.asm font8x8.asm font6x8.asm + font12x16.asm + font12x20.asm font16x26.asm font1.asm font2.asm font3.asm font4.asm + font5.asm + main.asm diff --git a/avr/modules/lcd2/font/defs.asm b/avr/modules/lcd2/font/defs.asm index d2908c3..4a24aeb 100644 --- a/avr/modules/lcd2/font/defs.asm +++ b/avr/modules/lcd2/font/defs.asm @@ -11,13 +11,22 @@ #define AVR_MODULES_FONT_DEFS -.equ FONT_OFFS_RENDERFN_LOW = 0 -.equ FONT_OFFS_RENDERFN_HI = 1 -.equ FONT_OFFS_DATASIZE = 2 ; one byte used, one byte reserved -.equ FONT_OFFS_WIDTH = 4 -.equ FONT_OFFS_HEIGHT = 5 -.equ FONT_OFFS_FIRSTCHAR = 6 -.equ FONT_OFFS_NUMCHARS = 7 +.equ FONT_OFFS_HANDLERFN_LOW = 0 +.equ FONT_OFFS_HANDLERFN_HI = 1 +.equ FONT_OFFS_DATASIZE = 2 ; one byte used, one byte reserved +.equ FONT_OFFS_WIDTH = 4 +.equ FONT_OFFS_HEIGHT = 5 +.equ FONT_OFFS_FIRSTCHAR = 6 +.equ FONT_OFFS_NUMCHARS = 7 + + + +.equ FONT_FN_RENDER = 0 +.equ FONT_FN_GETCHARWIDTH = 1 +.equ FONT_FN_GETCHARHEIGHT = 2 +.equ FONT_FN_GETSTRINGWIDTH = 3 +.equ FONT_FN_GETSTRINGHEIGHT = 4 +.equ FONT_FN_NEXT = 5 diff --git a/avr/modules/lcd2/font/font1.asm b/avr/modules/lcd2/font/font1.asm index 7fd4710..908b2a0 100644 --- a/avr/modules/lcd2/font/font1.asm +++ b/avr/modules/lcd2/font/font1.asm @@ -26,7 +26,7 @@ font1_8x8: ; header - .dw font8x8MonoRenderCharacter ; renderFn + .dw font6x8MonoHandlerFn ; handlerFn .db 128, 0 ; needed buffer size .db 8, 8 ; width, height of chars .db 32, 64 ; first char, num of chars in font diff --git a/avr/modules/lcd2/font/font12x16.asm b/avr/modules/lcd2/font/font12x16.asm new file mode 100644 index 0000000..4e10f93 --- /dev/null +++ b/avr/modules/lcd2/font/font12x16.asm @@ -0,0 +1,117 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + +; *************************************************************************** +; code + +.cseg + + + +; --------------------------------------------------------------------------- +; @routine font12x16MonoHandlerFn +; +; Handler for 12x16 Mono Fonts +; + +font12x16MonoHandlerFn: + cpi r23, FONT_FN_RENDER + breq font12x16MonoRenderCharacter + rjmp FONT_GenericHandler +; @end + + + +; --------------------------------------------------------------------------- +; @routine font12x16RenderCharacter + +; @param R16 character to write +; @param R1:R0 background color +; @param R3:R2 foreground color +; @param Z pointer to font +; @param X pointer to RAM to store data to +; @param r18 char width in pixel +; @param r19 char height in pixel +; @clobbers r17, r18, r23, r24, r25, x + +font12x16MonoRenderCharacter: + push zl + push zh + rcall font12x16GetCharPosInFont ; (r17, r24, r25, z) + ldi r25, 16 ; 16 bytes height +font12x16MonoRenderCharacter_loop1: + ldi r24, 12 ; 16 bits + ldi r23, 8 + lpm r17, Z+ +font12x16MonoRenderCharacter_loop2: + dec r23 + brne font12x16MonoRenderCharacter_haveByte + lpm r17, Z+ + ldi r23, 8 +font12x16MonoRenderCharacter_haveByte: + lsr r17 + brcs font12x16MonoRenderCharacter_writeForeground + st X+, r0 + st X+, r1 + rjmp font12x16MonoRenderCharacter_loop2end +font12x16MonoRenderCharacter_writeForeground: + st X+, r2 + st X+, r3 +font12x16MonoRenderCharacter_loop2end: + dec r24 + brne font12x16MonoRenderCharacter_loop2 + dec r25 + brne font12x16MonoRenderCharacter_loop1 + ldi r18, 12 + ldi r19, 16 + pop zh + pop zl + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine font12x16GetCharPosInFont + +; @param R16 character to write +; @param Z pointer to font +; @return Z pointer to begin of char data +; @clobbers r17, r24, r25, z + +font12x16GetCharPosInFont: + mov r24, r16 + adiw zh:zl, FONT_OFFS_FIRSTCHAR + lpm r24, Z+ ; first char num + lpm r25, Z+ ; num of chars + sub r16, r24 + brcs font12x16GetCharPosInFont_ret + cp r16, r25 + brcc font12x16GetCharPosInFont_ret + mov r25, r16 ; x256 + clr r24 + + lsr r25 ; x128 + ror r24 + + lsr r25 ; x64 + ror r24 + + lsr r25 ; x32 + ror r24 + + add zl, r24 + adc zh, r25 +font12x16GetCharPosInFont_ret: + ret +; @end + + + diff --git a/avr/modules/lcd2/font/font12x20.asm b/avr/modules/lcd2/font/font12x20.asm new file mode 100644 index 0000000..73ac5bb --- /dev/null +++ b/avr/modules/lcd2/font/font12x20.asm @@ -0,0 +1,129 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + +; *************************************************************************** +; code + +.cseg + + + +; --------------------------------------------------------------------------- +; @routine font12x20MonoHandlerFn +; +; Handler for 12x20 Mono Fonts +; + +font12x20MonoHandlerFn: + cpi r23, FONT_FN_RENDER + breq font12x20MonoRenderCharacter + bigjmp FONT_GenericHandler +; @end + + + + +; --------------------------------------------------------------------------- +; @routine font12x20RenderCharacter + +; @param R16 character to write +; @param R1:R0 background color +; @param R3:R2 foreground color +; @param Z pointer to font +; @param X pointer to RAM to store data to +; @param r18 char width in pixel +; @param r19 char height in pixel +; @clobbers r17, r18, r23, r24, r25, x + +font12x20MonoRenderCharacter: + push zl + push zh + rcall font12x20GetCharPosInFont ; (r17, r24, r25, z) + ldi r25, 20 ; 20 bytes height +font12x20MonoRenderCharacter_loop1: + ldi r24, 12 ; 16 bits + ldi r23, 8 + lpm r17, Z+ +font12x20MonoRenderCharacter_loop2: + dec r23 + brne font12x20MonoRenderCharacter_haveByte + lpm r17, Z+ + ldi r23, 8 +font12x20MonoRenderCharacter_haveByte: + lsr r17 + brcs font12x20MonoRenderCharacter_writeForeground + st X+, r0 + st X+, r1 + rjmp font12x20MonoRenderCharacter_loop2end +font12x20MonoRenderCharacter_writeForeground: + st X+, r2 + st X+, r3 +font12x20MonoRenderCharacter_loop2end: + dec r24 + brne font12x20MonoRenderCharacter_loop2 + dec r25 + brne font12x20MonoRenderCharacter_loop1 + ldi r18, 12 + ldi r19, 20 + pop zh + pop zl + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine font12x20GetCharPosInFont + +; @param R16 character to write +; @param Z pointer to font +; @return Z pointer to begin of char data +; @clobbers r17, r24, r25, z + +font12x20GetCharPosInFont: + mov r24, r16 + adiw zh:zl, FONT_OFFS_FIRSTCHAR + lpm r24, Z+ ; first char num + lpm r25, Z+ ; num of chars + sub r16, r24 + brcs font12x20GetCharPosInFont_ret + cp r16, r25 + brcc font12x20GetCharPosInFont_ret + + mov r24, r16 + clr r25 + + lsl r24 ; x2 + rol r25 + + lsl r24 ; x4 + rol r25 + + add r24, r16 ; x5 + adc r25, r16 + sub r25, r16 + + lsl r24 ; x10 + rol r25 + + lsl r24 ; x20 + rol r25 + + lsl r24 ; x40 + rol r25 + + add zl, r24 + adc zh, r25 +font12x20GetCharPosInFont_ret: + ret +; @end + + + diff --git a/avr/modules/lcd2/font/font16x26.asm b/avr/modules/lcd2/font/font16x26.asm index 7e1582f..445e841 100644 --- a/avr/modules/lcd2/font/font16x26.asm +++ b/avr/modules/lcd2/font/font16x26.asm @@ -15,6 +15,20 @@ +; --------------------------------------------------------------------------- +; @routine font16x26MonoHandlerFn +; +; Handler for 16x26 Mono Fonts +; + +font16x26MonoHandlerFn: + cpi r23, FONT_FN_RENDER + breq font16x26MonoRenderCharacter + rjmp FONT_GenericHandler +; @end + + + ; --------------------------------------------------------------------------- ; @routine font16x26RenderCharacter diff --git a/avr/modules/lcd2/font/font2.asm b/avr/modules/lcd2/font/font2.asm index d277dd3..973b932 100644 --- a/avr/modules/lcd2/font/font2.asm +++ b/avr/modules/lcd2/font/font2.asm @@ -26,7 +26,7 @@ font2_6x8: ; header - .dw font6x8MonoRenderCharacter ; renderFn + .dw font6x8MonoHandlerFn ; handlerFn .db 96, 0 ; needed buffer size .db 6, 8 ; width, height of chars .db 32, 224 ; first char, num of chars in font diff --git a/avr/modules/lcd2/font/font3.asm b/avr/modules/lcd2/font/font3.asm index 8a816d3..92c1396 100644 --- a/avr/modules/lcd2/font/font3.asm +++ b/avr/modules/lcd2/font/font3.asm @@ -26,7 +26,7 @@ font3_16x26: ; header - .dw font16x26MonoRenderCharacter ; renderFn + .dw font16x26MonoHandlerFn ; handlerFn .dw 832 ; needed buffer size .db 16, 26 ; width, height of chars .db 32, 224 ; first char, num of chars in font diff --git a/avr/modules/lcd2/font/font4.asm b/avr/modules/lcd2/font/font4.asm index 212bff4..9c44a07 100644 --- a/avr/modules/lcd2/font/font4.asm +++ b/avr/modules/lcd2/font/font4.asm @@ -26,7 +26,7 @@ font4_12x16: ; header - .dw font12x16MonoRenderCharacter ; renderFn + .dw font12x16MonoHandlerFn ; handlerFn .dw 384 ; needed buffer size .db 12, 16 ; width, height of chars .db 32, 224 ; first char, num of chars in font diff --git a/avr/modules/lcd2/font/font5.asm b/avr/modules/lcd2/font/font5.asm new file mode 100644 index 0000000..afe78fc --- /dev/null +++ b/avr/modules/lcd2/font/font5.asm @@ -0,0 +1,258 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + +; *************************************************************************** +; This is a font from the project LCD_fonts at +; https://github.com/basti79/LCD-fonts.git +; which in turn is based on a post by Benedikt K. in a forum post on +; https://www.mikrocontroller.net/topic/54860 +; *************************************************************************** + + + +; *************************************************************************** +; code + +.cseg + + + +font5_12x20: +; header + .dw font12x20MonoHandlerFn ; handlerFn + .dw 480 ; needed buffer size + .db 12, 20 ; width, height of chars + .db 32, 224 ; first char, num of chars in font +; data (16x20_horizontal_LSB_2) +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x20 +.db 0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x21 +.db 0x00,0x00,0x8C,0x01,0x8C,0x01,0x8C,0x01,0x8C,0x01,0x8C,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x22 +.db 0x00,0x00,0x00,0x00,0x20,0x02,0x20,0x02,0x10,0x01,0x10,0x01,0x10,0x01,0xFE,0x0F,0x88,0x00,0x88,0x00,0x88,0x00,0xFE,0x07,0x44,0x00,0x44,0x00,0x22,0x00,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x23 +.db 0x00,0x00,0x40,0x00,0xF0,0x01,0xF8,0x03,0x4C,0x02,0x4C,0x00,0x4C,0x00,0x78,0x00,0x70,0x00,0xC0,0x01,0xC0,0x01,0x40,0x03,0x40,0x03,0x44,0x03,0xFC,0x01,0xF8,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x24 +.db 0x00,0x00,0x00,0x00,0x1E,0x08,0x33,0x04,0x33,0x02,0x33,0x01,0xB3,0x00,0xB3,0x00,0x5E,0x00,0xA0,0x07,0xD0,0x0C,0xD0,0x0C,0xC8,0x0C,0xC4,0x0C,0xC2,0x0C,0x81,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x25 +.db 0x00,0x00,0x00,0x00,0xF0,0x00,0xF8,0x01,0x98,0x01,0x98,0x01,0xD8,0x00,0x70,0x00,0x3C,0x00,0x66,0x0C,0xE3,0x0C,0xC3,0x0C,0x83,0x07,0x87,0x07,0xFE,0x07,0xFC,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x26 +.db 0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x27 +.db 0x00,0x00,0x00,0x03,0xC0,0x03,0xE0,0x00,0x60,0x00,0x30,0x00,0x30,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x30,0x00,0x30,0x00,0x60,0x00,0xE0,0x00,0xC0,0x03,0x00,0x03,0x00,0x00, ; 0x28 +.db 0x00,0x00,0x0C,0x00,0x3C,0x00,0x70,0x00,0x60,0x00,0xC0,0x00,0xC0,0x00,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0xC0,0x00,0xC0,0x00,0x60,0x00,0x70,0x00,0x3C,0x00,0x0C,0x00,0x00,0x00, ; 0x29 +.db 0x00,0x00,0x00,0x00,0x30,0x00,0x30,0x00,0x36,0x03,0xCE,0x03,0x00,0x00,0xD8,0x00,0x9C,0x01,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x2A +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xFE,0x07,0xFE,0x07,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x2B +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x60,0x00,0x20,0x00,0x30,0x00,0x00,0x00, ; 0x2C +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x03,0xFC,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x2D +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x2E +.db 0x00,0x00,0x00,0x06,0x00,0x03,0x00,0x03,0x80,0x01,0x80,0x01,0x80,0x01,0xC0,0x00,0xC0,0x00,0x60,0x00,0x60,0x00,0x30,0x00,0x30,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x0C,0x00,0x0C,0x00,0x06,0x00,0x00,0x00, ; 0x2F +.db 0x00,0x00,0x00,0x00,0xF0,0x00,0xF8,0x01,0x0C,0x03,0x0C,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x03,0x0C,0x03,0xF8,0x01,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x30 +.db 0x00,0x00,0x00,0x00,0x60,0x00,0x7C,0x00,0x66,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xFE,0x07,0xFE,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x31 +.db 0x00,0x00,0x00,0x00,0xF8,0x00,0xFC,0x01,0x84,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x80,0x01,0xC0,0x00,0x60,0x00,0x30,0x00,0x18,0x00,0x0C,0x00,0xFC,0x03,0xFC,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x32 +.db 0x00,0x00,0x00,0x00,0xF8,0x00,0xFC,0x03,0x04,0x03,0x00,0x03,0x80,0x01,0xF8,0x00,0xF8,0x00,0x80,0x01,0x00,0x03,0x00,0x03,0x00,0x03,0x84,0x03,0xFC,0x01,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x33 +.db 0x00,0x00,0x00,0x00,0x80,0x01,0xC0,0x01,0xE0,0x01,0xA0,0x01,0x90,0x01,0x98,0x01,0x8C,0x01,0x84,0x01,0xFE,0x07,0xFE,0x07,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x34 +.db 0x00,0x00,0x00,0x00,0xF8,0x03,0xF8,0x03,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0xF8,0x00,0xF8,0x01,0x80,0x03,0x00,0x03,0x00,0x03,0x80,0x03,0xF8,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x35 +.db 0x00,0x00,0x00,0x00,0xF0,0x00,0xF8,0x01,0x1C,0x01,0x0C,0x00,0x06,0x00,0xE6,0x00,0xF6,0x01,0x8E,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x8C,0x03,0xFC,0x01,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x36 +.db 0x00,0x00,0x00,0x00,0xFC,0x07,0xFC,0x07,0x00,0x06,0x00,0x03,0x00,0x01,0x80,0x01,0xC0,0x00,0x40,0x00,0x60,0x00,0x20,0x00,0x30,0x00,0x30,0x00,0x18,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x37 +.db 0x00,0x00,0x00,0x00,0xF0,0x00,0xFC,0x01,0x8C,0x01,0x8C,0x01,0x9C,0x01,0xF8,0x00,0x70,0x00,0xEC,0x01,0x86,0x03,0x06,0x03,0x06,0x03,0x8E,0x03,0xFC,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x38 +.db 0x00,0x00,0x00,0x00,0x78,0x00,0xFC,0x01,0x8E,0x01,0x06,0x03,0x06,0x03,0x06,0x03,0x8E,0x03,0x7C,0x03,0x38,0x03,0x00,0x03,0x80,0x01,0xC4,0x01,0xFC,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x39 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x3A +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x60,0x00,0x20,0x00,0x30,0x00,0x00,0x00, ; 0x3B +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x07,0xC0,0x03,0xE0,0x00,0x38,0x00,0x0E,0x00,0x38,0x00,0xE0,0x00,0xC0,0x03,0x00,0x07,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x3C +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x07,0xFE,0x07,0x00,0x00,0x00,0x00,0xFE,0x07,0xFE,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x3D +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x0E,0x00,0x3C,0x00,0x70,0x00,0xC0,0x01,0x00,0x07,0xC0,0x01,0x70,0x00,0x3C,0x00,0x0E,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x3E +.db 0x00,0x00,0x00,0x00,0xFE,0x00,0xFE,0x03,0x82,0x03,0x00,0x03,0x00,0x03,0x80,0x01,0xC0,0x00,0x60,0x00,0x30,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x3F +.db 0x00,0x00,0x00,0x00,0xF0,0x01,0x18,0x03,0x0C,0x06,0xC6,0x07,0x63,0x06,0x33,0x06,0x33,0x06,0x33,0x07,0x33,0x07,0xF3,0x06,0x66,0x0E,0x06,0x00,0x0C,0x00,0xF0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x40 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0xF0,0x00,0xF0,0x00,0xD0,0x00,0x98,0x01,0x98,0x01,0x8C,0x03,0x0C,0x03,0xFC,0x03,0xFE,0x07,0x06,0x06,0x06,0x06,0x03,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x41 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0xFE,0x01,0x86,0x01,0x86,0x01,0xC6,0x00,0x7E,0x00,0xFE,0x00,0x86,0x01,0x06,0x03,0x06,0x03,0x06,0x03,0xFE,0x01,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x42 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x03,0xF8,0x07,0x1C,0x04,0x0C,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x0C,0x00,0x3C,0x04,0xF8,0x07,0xE0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x43 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0xFE,0x01,0x86,0x03,0x06,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x03,0x86,0x03,0xFE,0x01,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x44 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x07,0xFC,0x07,0x0C,0x00,0x0C,0x00,0x0C,0x00,0xFC,0x03,0xFC,0x03,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0xFC,0x07,0xFC,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x45 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x07,0xFC,0x07,0x0C,0x00,0x0C,0x00,0x0C,0x00,0xFC,0x03,0xFC,0x03,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x46 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x03,0xF8,0x07,0x1C,0x04,0x0C,0x00,0x06,0x00,0x06,0x00,0x86,0x07,0x86,0x07,0x06,0x06,0x0C,0x06,0x1C,0x06,0xF8,0x07,0xE0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x47 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0xFE,0x03,0xFE,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x48 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x01,0xFE,0x01,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0xFE,0x01,0xFE,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x49 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x01,0xF8,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0xC0,0x01,0xFC,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x4A +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x07,0x86,0x03,0xC6,0x01,0xE6,0x00,0x66,0x00,0x36,0x00,0x3E,0x00,0x76,0x00,0xE6,0x00,0xC6,0x01,0x86,0x03,0x06,0x07,0x06,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x4B +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0xFC,0x07,0xFC,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x4C +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x8F,0x07,0x8B,0x06,0x8B,0x06,0xDB,0x06,0x53,0x06,0x53,0x06,0x73,0x06,0x23,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x4D +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x06,0x0E,0x06,0x1E,0x06,0x1E,0x06,0x36,0x06,0x76,0x06,0x66,0x06,0xE6,0x06,0xC6,0x06,0x86,0x07,0x86,0x07,0x06,0x07,0x06,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x4E +.db 0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0xFC,0x01,0x8E,0x03,0x07,0x07,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x07,0x07,0x8E,0x03,0xFC,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x4F +.db 0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x01,0xFC,0x03,0x0C,0x07,0x0C,0x06,0x0C,0x06,0x0C,0x07,0xFC,0x03,0xFC,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x50 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0xFC,0x01,0x8E,0x03,0x07,0x07,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x06,0x03,0x8E,0x03,0xFC,0x01,0xF8,0x00,0x80,0x03,0x00,0x0F,0x00,0x04,0x00,0x00, ; 0x51 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0xFE,0x01,0x86,0x01,0x86,0x01,0x86,0x01,0xC6,0x01,0xFE,0x00,0x7E,0x00,0xE6,0x00,0xC6,0x01,0x86,0x03,0x06,0x07,0x06,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x52 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0xFC,0x01,0x06,0x01,0x06,0x00,0x0E,0x00,0x3C,0x00,0xF8,0x00,0xC0,0x03,0x00,0x03,0x00,0x03,0x86,0x03,0xFE,0x01,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x53 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x0F,0xFF,0x0F,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x54 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x8E,0x03,0xFC,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x55 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x0C,0x06,0x06,0x06,0x06,0x0E,0x06,0x0C,0x03,0x0C,0x03,0x1C,0x03,0x98,0x01,0xB8,0x01,0xB0,0x00,0xF0,0x00,0xF0,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x56 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0C,0x03,0x0C,0x03,0x0C,0x62,0x04,0x62,0x04,0xE2,0x06,0xF6,0x06,0x96,0x06,0x96,0x06,0x96,0x03,0x9C,0x03,0x9C,0x03,0x0C,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x57 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x0E,0x0E,0x06,0x0C,0x03,0x98,0x01,0xF8,0x00,0xF0,0x00,0x60,0x00,0xF0,0x00,0xD8,0x01,0x98,0x01,0x0C,0x03,0x06,0x07,0x03,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x58 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x0C,0x06,0x06,0x0C,0x03,0x1C,0x03,0x98,0x01,0xF0,0x00,0xF0,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x59 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x07,0xFE,0x07,0x00,0x06,0x00,0x03,0x80,0x01,0xC0,0x00,0x60,0x00,0x30,0x00,0x18,0x00,0x0C,0x00,0x06,0x00,0xFE,0x07,0xFE,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x5A +.db 0x00,0x00,0xF0,0x03,0xF0,0x03,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0xF0,0x03,0xF0,0x03,0x00,0x00, ; 0x5B +.db 0x00,0x00,0x06,0x00,0x0C,0x00,0x0C,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x30,0x00,0x30,0x00,0x60,0x00,0x60,0x00,0xC0,0x00,0xC0,0x00,0x80,0x01,0x80,0x01,0x80,0x01,0x00,0x03,0x00,0x03,0x00,0x06,0x00,0x00, ; 0x5C +.db 0x00,0x00,0xFC,0x00,0xFC,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xFC,0x00,0xFC,0x00,0x00,0x00, ; 0x5D +.db 0x00,0x00,0x00,0x00,0x40,0x00,0x40,0x00,0xE0,0x00,0xA0,0x00,0xB0,0x00,0xB0,0x01,0x18,0x01,0x18,0x03,0x0C,0x03,0x0C,0x02,0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x5E +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x0F,0xFF,0x0F,0x00,0x00,0x00,0x00, ; 0x5F +.db 0x60,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x60 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x01,0xFC,0x03,0x04,0x03,0x00,0x03,0x00,0x03,0xF8,0x03,0x0C,0x03,0x06,0x03,0x86,0x03,0xFE,0x0F,0x7C,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x61 +.db 0x00,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0xE6,0x00,0xF6,0x01,0x9E,0x03,0x0E,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x8E,0x01,0xFE,0x01,0xF6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x62 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x01,0xFC,0x03,0x1C,0x02,0x0E,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x0E,0x00,0x1C,0x00,0xFC,0x03,0xF0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x63 +.db 0x00,0x00,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x78,0x03,0xFC,0x03,0x8C,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x8E,0x03,0xFC,0x03,0x38,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x64 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0xFC,0x01,0x8C,0x03,0x06,0x03,0xFE,0x03,0xFE,0x03,0x06,0x00,0x06,0x00,0x0C,0x02,0xFC,0x03,0xF0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x65 +.db 0x00,0x00,0xE0,0x07,0xF0,0x07,0x30,0x00,0x30,0x00,0xFE,0x07,0xFE,0x07,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x66 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x03,0xFC,0x03,0x8C,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x8E,0x03,0xFC,0x03,0x78,0x03,0x00,0x03,0x84,0x03,0xFC,0x01,0xF8,0x00, ; 0x67 +.db 0x00,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0xE6,0x01,0xF6,0x03,0x1E,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x68 +.db 0x00,0x00,0xC0,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0xFC,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x69 +.db 0x00,0x00,0x80,0x01,0x80,0x01,0x00,0x00,0x00,0x00,0xF8,0x01,0xF8,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0xC0,0x01,0xFC,0x00,0x7C,0x00, ; 0x6A +.db 0x00,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x07,0x8C,0x03,0xCC,0x01,0xEC,0x00,0x6C,0x00,0x7C,0x00,0xEC,0x00,0xCC,0x01,0x8C,0x03,0x0C,0x07,0x0C,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x6B +.db 0x00,0x00,0xFC,0x00,0xFC,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x6C +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9B,0x03,0xFF,0x07,0x77,0x06,0x33,0x06,0x33,0x06,0x33,0x06,0x33,0x06,0x33,0x06,0x33,0x06,0x33,0x06,0x33,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x6D +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE6,0x01,0xF6,0x03,0x1E,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x6E +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0xFC,0x03,0x0C,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x03,0xFC,0x03,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x6F +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF6,0x00,0xFE,0x01,0x8E,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x8E,0x01,0xFE,0x01,0xF6,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00, ; 0x70 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x03,0xFC,0x03,0x8C,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x8E,0x03,0x7C,0x03,0x38,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03, ; 0x71 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCC,0x03,0xEC,0x03,0x3C,0x02,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x72 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x01,0xFC,0x01,0x0C,0x00,0x0C,0x00,0x3C,0x00,0xF0,0x01,0x80,0x03,0x00,0x03,0x04,0x03,0xFC,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x73 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x30,0x00,0xFE,0x07,0xFE,0x07,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0xF0,0x07,0xE0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x74 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0xC6,0x03,0x7E,0x03,0x3C,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x75 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x0C,0x02,0x0C,0x03,0x0C,0x03,0x18,0x01,0x98,0x01,0x98,0x01,0xB0,0x00,0xF0,0x00,0xF0,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x76 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0C,0x63,0x0C,0x63,0x0C,0xE2,0x04,0xF6,0x04,0x96,0x04,0x96,0x06,0x96,0x07,0x9C,0x03,0x0C,0x03,0x0C,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x77 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x07,0x0C,0x03,0x98,0x01,0xB8,0x00,0xF0,0x00,0x60,0x00,0xF0,0x00,0xD8,0x01,0x98,0x01,0x0C,0x03,0x06,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x78 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x0C,0x02,0x0C,0x03,0x1C,0x03,0x98,0x01,0x98,0x01,0xB0,0x00,0xF0,0x00,0xF0,0x00,0x60,0x00,0x60,0x00,0x20,0x00,0x30,0x00,0x3C,0x00,0x1C,0x00, ; 0x79 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x03,0xFE,0x03,0x00,0x03,0x80,0x01,0xC0,0x00,0x60,0x00,0x30,0x00,0x18,0x00,0x0C,0x00,0xFE,0x03,0xFE,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x7A +.db 0x00,0x00,0xC0,0x03,0xE0,0x03,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x3C,0x00,0x3C,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xE0,0x03,0xC0,0x03,0x00,0x00, ; 0x7B +.db 0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00, ; 0x7C +.db 0x00,0x00,0x3C,0x00,0x7C,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xC0,0x03,0xC0,0x03,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x7C,0x00,0x3C,0x00,0x00,0x00, ; 0x7D +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x04,0xFE,0x07,0xC2,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x7E +.db 0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x03,0x04,0x02,0x04,0x02,0x04,0x02,0x04,0x02,0x04,0x02,0x04,0x02,0x04,0x02,0x04,0x02,0x04,0x02,0x04,0x02,0x04,0x02,0xFC,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x7F +.db 0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x03,0xF8,0x07,0x1C,0x04,0x0C,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x0C,0x00,0x3C,0x04,0xF8,0x07,0xE0,0x03,0x40,0x00,0xE0,0x00,0x80,0x01,0xE0,0x00, ; 0x80 +.db 0x00,0x00,0x98,0x01,0x98,0x01,0x00,0x00,0x00,0x00,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0xC6,0x03,0x7E,0x03,0x3C,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x81 +.db 0x80,0x01,0xC0,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0xFC,0x01,0x8C,0x03,0x06,0x03,0xFE,0x03,0xFE,0x03,0x06,0x00,0x06,0x00,0x0C,0x02,0xFC,0x03,0xF0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x82 +.db 0xE0,0x00,0xB0,0x01,0x18,0x03,0x00,0x00,0x00,0x00,0xF8,0x01,0xFC,0x03,0x04,0x03,0x00,0x03,0x00,0x03,0xF8,0x03,0x0C,0x03,0x06,0x03,0x86,0x03,0xFE,0x0F,0x7C,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x83 +.db 0x00,0x00,0x98,0x01,0x98,0x01,0x00,0x00,0x00,0x00,0xF8,0x01,0xFC,0x03,0x04,0x03,0x00,0x03,0x00,0x03,0xF8,0x03,0x0C,0x03,0x06,0x03,0x86,0x03,0xFE,0x0F,0x7C,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x84 +.db 0x18,0x00,0x30,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0xF8,0x01,0xFC,0x03,0x04,0x03,0x00,0x03,0x00,0x03,0xF8,0x03,0x0C,0x03,0x06,0x03,0x86,0x03,0xFE,0x0F,0x7C,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x85 +.db 0x90,0x00,0x90,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0xF8,0x01,0xFC,0x03,0x04,0x03,0x00,0x03,0x00,0x03,0xF8,0x03,0x0C,0x03,0x06,0x03,0x86,0x03,0xFE,0x0F,0x7C,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x86 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x01,0xFC,0x03,0x1C,0x02,0x0E,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x0E,0x00,0x1C,0x00,0xFC,0x03,0xF0,0x01,0x20,0x00,0x70,0x00,0xC0,0x00,0x70,0x00, ; 0x87 +.db 0xE0,0x00,0xB0,0x01,0x18,0x03,0x00,0x00,0x00,0x00,0xF0,0x00,0xFC,0x01,0x8C,0x03,0x06,0x03,0xFE,0x03,0xFE,0x03,0x06,0x00,0x06,0x00,0x0C,0x02,0xFC,0x03,0xF0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x88 +.db 0x00,0x00,0x30,0x03,0x30,0x03,0x00,0x00,0x00,0x00,0xF0,0x00,0xFC,0x01,0x8C,0x03,0x06,0x03,0xFE,0x03,0xFE,0x03,0x06,0x00,0x06,0x00,0x0C,0x02,0xFC,0x03,0xF0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x89 +.db 0x30,0x00,0x60,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0xFC,0x01,0x8C,0x03,0x06,0x03,0xFE,0x03,0xFE,0x03,0x06,0x00,0x06,0x00,0x0C,0x02,0xFC,0x03,0xF0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x8A +.db 0x00,0x00,0x98,0x01,0x98,0x01,0x00,0x00,0x00,0x00,0xFC,0x00,0xFC,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x8B +.db 0xC0,0x01,0x60,0x03,0x30,0x06,0x00,0x00,0x00,0x00,0xFC,0x00,0xFC,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x8C +.db 0x30,0x00,0x60,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0xFC,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x8D +.db 0x8C,0x01,0x8C,0x01,0x00,0x00,0x60,0x00,0xF0,0x00,0xF0,0x00,0xD0,0x00,0x98,0x01,0x98,0x01,0x8C,0x03,0x0C,0x03,0xFC,0x03,0xFE,0x07,0x06,0x06,0x06,0x06,0x03,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x8E +.db 0x60,0x00,0x90,0x00,0xF0,0x00,0x60,0x00,0xF0,0x00,0xF0,0x00,0xD0,0x00,0x98,0x01,0x98,0x01,0x8C,0x03,0x0C,0x03,0xFC,0x03,0xFE,0x07,0x06,0x06,0x06,0x06,0x03,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x8F +.db 0xC0,0x00,0x60,0x00,0x00,0x00,0xFC,0x07,0xFC,0x07,0x0C,0x00,0x0C,0x00,0x0C,0x00,0xFC,0x03,0xFC,0x03,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0xFC,0x07,0xFC,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x90 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xBE,0x03,0xFE,0x07,0xE0,0x0C,0x60,0x0C,0x60,0x0C,0xFC,0x0F,0xE6,0x0F,0x63,0x00,0x63,0x00,0xFF,0x0F,0x9E,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x91 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x0F,0xE0,0x0F,0xE0,0x00,0xF0,0x00,0xD0,0x00,0xD8,0x07,0xC8,0x07,0xCC,0x00,0xFC,0x00,0xFC,0x00,0xC6,0x00,0xC2,0x0F,0xC3,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x92 +.db 0xE0,0x00,0xB0,0x01,0x18,0x03,0x00,0x00,0x00,0x00,0xF0,0x00,0xFC,0x03,0x0C,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x03,0xFC,0x03,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x93 +.db 0x00,0x00,0x98,0x01,0x98,0x01,0x00,0x00,0x00,0x00,0xF0,0x00,0xFC,0x03,0x0C,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x03,0xFC,0x03,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x94 +.db 0x18,0x00,0x30,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0xFC,0x03,0x0C,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x03,0xFC,0x03,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x95 +.db 0xE0,0x00,0xB0,0x01,0x18,0x03,0x00,0x00,0x00,0x00,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0xC6,0x03,0x7E,0x03,0x3C,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x96 +.db 0x18,0x00,0x30,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0xC6,0x03,0x7E,0x03,0x3C,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x97 +.db 0x00,0x00,0x98,0x01,0x98,0x01,0x00,0x00,0x00,0x00,0x06,0x06,0x0C,0x02,0x0C,0x03,0x1C,0x03,0x98,0x01,0x98,0x01,0xB0,0x00,0xF0,0x00,0xF0,0x00,0x60,0x00,0x60,0x00,0x20,0x00,0x30,0x00,0x3C,0x00,0x1C,0x00, ; 0x98 +.db 0x8C,0x01,0x8C,0x01,0x00,0x00,0xF8,0x00,0xFC,0x01,0x8E,0x03,0x07,0x07,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x07,0x07,0x8E,0x03,0xFC,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x99 +.db 0x8C,0x01,0x8C,0x01,0x00,0x00,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x8E,0x03,0xFC,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x9A +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x06,0xFC,0x03,0x0C,0x03,0x86,0x07,0xC6,0x06,0x66,0x06,0x36,0x06,0x1E,0x06,0x0C,0x03,0xFC,0x03,0xF6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x9B +.db 0x00,0x00,0x00,0x00,0xE0,0x03,0xF0,0x03,0x30,0x00,0x30,0x00,0x30,0x00,0xFC,0x00,0xFC,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x18,0x00,0xFC,0x03,0xFC,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x9C +.db 0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x06,0xFC,0x03,0x8E,0x03,0x87,0x03,0xC3,0x06,0x43,0x06,0x23,0x06,0x13,0x06,0x1B,0x06,0x0E,0x07,0x8E,0x03,0xFE,0x01,0xFB,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x9D +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x07,0x07,0x8E,0x03,0xDC,0x01,0xF8,0x00,0x70,0x00,0xF8,0x00,0xDC,0x01,0x8E,0x03,0x07,0x07,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x9E +.db 0xC0,0x07,0xE0,0x07,0x60,0x00,0x60,0x00,0x60,0x00,0xF8,0x03,0xF8,0x03,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x7E,0x00,0x3E,0x00, ; 0x9F +.db 0x80,0x01,0xC0,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0xF8,0x01,0xFC,0x03,0x04,0x03,0x00,0x03,0x00,0x03,0xF8,0x03,0x0C,0x03,0x06,0x03,0x86,0x03,0xFE,0x0F,0x7C,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xA0 +.db 0x80,0x01,0xC0,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0xFC,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xA1 +.db 0x80,0x01,0xC0,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0xFC,0x03,0x0C,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x03,0xFC,0x03,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xA2 +.db 0x80,0x01,0xC0,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0xC6,0x03,0x7E,0x03,0x3C,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xA3 +.db 0x00,0x00,0x70,0x02,0xC8,0x01,0x00,0x00,0x00,0x00,0xE6,0x01,0xF6,0x03,0x1E,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xA4 +.db 0x70,0x02,0xC8,0x01,0x00,0x00,0x0E,0x06,0x0E,0x06,0x1E,0x06,0x1E,0x06,0x36,0x06,0x76,0x06,0x66,0x06,0xE6,0x06,0xC6,0x06,0x86,0x07,0x86,0x07,0x06,0x07,0x06,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xA5 +.db 0x00,0x00,0x00,0x00,0xFC,0x00,0x84,0x01,0x80,0x01,0xF8,0x01,0x8C,0x01,0x8C,0x01,0xF8,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xA6 +.db 0x00,0x00,0x00,0x00,0xF0,0x00,0x98,0x01,0x0C,0x03,0x0C,0x03,0x0C,0x03,0x98,0x01,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xA7 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x20,0x00,0x30,0x00,0x18,0x00,0x0C,0x00,0x06,0x00,0x06,0x00,0x0E,0x02,0xFC,0x03,0xF8,0x03, ; 0xA8 +.db 0x00,0x00,0x00,0x00,0xF8,0x00,0x8C,0x01,0x76,0x03,0x52,0x02,0x72,0x02,0x32,0x02,0x56,0x03,0x8C,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xA9 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x07,0xFF,0x07,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xAA +.db 0x00,0x00,0x00,0x00,0x07,0x03,0x86,0x01,0x86,0x01,0xC6,0x00,0x66,0x00,0x66,0x00,0xB6,0x07,0x30,0x0C,0x18,0x0C,0x18,0x0C,0x0C,0x06,0x06,0x03,0x86,0x01,0x83,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xAB +.db 0x00,0x00,0x00,0x00,0x07,0x03,0x86,0x01,0x86,0x01,0xC6,0x00,0x66,0x00,0x66,0x00,0x36,0x06,0x30,0x07,0x98,0x06,0x58,0x06,0x2C,0x06,0xE6,0x0F,0x06,0x06,0x03,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xAC +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00, ; 0xAD +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x06,0x18,0x03,0x8C,0x01,0xC6,0x00,0x63,0x00,0xC6,0x00,0x8C,0x01,0x18,0x03,0x30,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xAE +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x00,0xC6,0x00,0x8C,0x01,0x18,0x03,0x30,0x06,0x18,0x03,0x8C,0x01,0xC6,0x00,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xAF +.db 0x33,0x03,0x33,0x03,0x00,0x00,0x00,0x00,0x33,0x03,0x33,0x03,0x00,0x00,0x00,0x00,0x33,0x03,0x33,0x03,0x00,0x00,0x00,0x00,0x33,0x03,0x33,0x03,0x00,0x00,0x00,0x00,0x33,0x03,0x33,0x03,0x00,0x00,0x00,0x00, ; 0xB0 +.db 0xCC,0x0C,0xCC,0x0C,0x33,0x03,0x33,0x03,0xCC,0x0C,0xCC,0x0C,0x33,0x03,0x33,0x03,0xCC,0x0C,0xCC,0x0C,0x33,0x03,0x33,0x03,0xCC,0x0C,0xCC,0x0C,0x33,0x03,0x33,0x03,0xCC,0x0C,0xCC,0x0C,0x33,0x03,0x33,0x03, ; 0xB1 +.db 0xFF,0x0F,0xFF,0x0F,0x33,0x03,0x33,0x03,0xFF,0x0F,0xFF,0x0F,0x33,0x03,0x33,0x03,0xFF,0x0F,0xFF,0x0F,0x33,0x03,0x33,0x03,0xFF,0x0F,0xFF,0x0F,0x33,0x03,0x33,0x03,0xFF,0x0F,0xFF,0x0F,0x33,0x03,0x33,0x03, ; 0xB2 +.db 0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00, ; 0xB3 +.db 0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x7F,0x00,0x7F,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00, ; 0xB4 +.db 0xC0,0x00,0x60,0x00,0x00,0x00,0x60,0x00,0xF0,0x00,0xF0,0x00,0xD0,0x00,0x98,0x01,0x98,0x01,0x8C,0x03,0x0C,0x03,0xFC,0x03,0xFE,0x07,0x06,0x06,0x06,0x06,0x03,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xB5 +.db 0x70,0x00,0x88,0x00,0x00,0x00,0x60,0x00,0xF0,0x00,0xF0,0x00,0xD0,0x00,0x98,0x01,0x98,0x01,0x8C,0x03,0x0C,0x03,0xFC,0x03,0xFE,0x07,0x06,0x06,0x06,0x06,0x03,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xB6 +.db 0x30,0x00,0x60,0x00,0x00,0x00,0x60,0x00,0xF0,0x00,0xF0,0x00,0xD0,0x00,0x98,0x01,0x98,0x01,0x8C,0x03,0x0C,0x03,0xFC,0x03,0xFE,0x07,0x06,0x06,0x06,0x06,0x03,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xB7 +.db 0x00,0x00,0x00,0x00,0xF8,0x00,0x04,0x01,0x02,0x02,0xF3,0x06,0x09,0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x09,0x04,0xF3,0x06,0x02,0x02,0x04,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xB8 +.db 0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xBF,0x01,0xBF,0x01,0x80,0x01,0xBF,0x01,0xBF,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01, ; 0xB9 +.db 0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01, ; 0xBA +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x01,0xFF,0x01,0x80,0x01,0xBF,0x01,0xBF,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01, ; 0xBB +.db 0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xBF,0x01,0xBF,0x01,0x80,0x01,0xFF,0x01,0xFF,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xBC +.db 0x00,0x00,0x00,0x00,0x40,0x00,0x40,0x00,0xF0,0x03,0xF8,0x03,0x5C,0x02,0x4C,0x00,0x4C,0x00,0x4C,0x00,0x4C,0x00,0x5C,0x00,0xF8,0x03,0xF0,0x01,0x40,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xBD +.db 0x00,0x00,0x00,0x00,0x07,0x0C,0x0E,0x06,0x0C,0x03,0x1C,0x03,0xB8,0x01,0xF0,0x00,0x60,0x00,0xFC,0x03,0x60,0x00,0x60,0x00,0xFC,0x03,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xBE +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x7F,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00, ; 0xBF +.db 0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xE0,0x0F,0xE0,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xC0 +.db 0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xFF,0x0F,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xC1 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x0F,0xFF,0x0F,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00, ; 0xC2 +.db 0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xE0,0x0F,0xE0,0x0F,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00, ; 0xC3 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x0F,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xC4 +.db 0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xFF,0x0F,0xFF,0x0F,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00, ; 0xC5 +.db 0x00,0x00,0x70,0x02,0xC8,0x01,0x00,0x00,0x00,0x00,0xF8,0x01,0xFC,0x03,0x04,0x03,0x00,0x03,0x00,0x03,0xF8,0x03,0x0C,0x03,0x06,0x03,0x86,0x03,0xFE,0x0F,0x7C,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xC6 +.db 0x70,0x02,0xC8,0x01,0x00,0x00,0x60,0x00,0xF0,0x00,0xF0,0x00,0xD0,0x00,0x98,0x01,0x98,0x01,0x8C,0x03,0x0C,0x03,0xFC,0x03,0xFE,0x07,0x06,0x06,0x06,0x06,0x03,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xC7 +.db 0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x0F,0xB0,0x0F,0x30,0x00,0xF0,0x0F,0xF0,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xC8 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x0F,0xF0,0x0F,0x30,0x00,0xB0,0x0F,0xB0,0x0F,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01, ; 0xC9 +.db 0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xBF,0x0F,0xBF,0x0F,0x00,0x00,0xFF,0x0F,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xCA +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x0F,0xFF,0x0F,0x00,0x00,0xBF,0x0F,0xBF,0x0F,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01, ; 0xCB +.db 0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x0F,0xB0,0x0F,0x30,0x00,0xB0,0x0F,0xB0,0x0F,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01, ; 0xCC +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x0F,0xFF,0x0F,0x00,0x00,0xFF,0x0F,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xCD +.db 0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xBF,0x0F,0xBF,0x0F,0x00,0x00,0xBF,0x0F,0xBF,0x0F,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01,0xB0,0x01, ; 0xCE +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x04,0xF4,0x02,0xFC,0x03,0x9C,0x03,0x0C,0x03,0x0C,0x03,0x9C,0x03,0xFC,0x03,0xF4,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xCF +.db 0x00,0x00,0xDE,0x00,0x7E,0x00,0xF0,0x00,0xC8,0x01,0xF0,0x03,0xFC,0x03,0x0C,0x07,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x03,0xFC,0x03,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xD0 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0xFE,0x01,0x86,0x03,0x06,0x07,0x06,0x06,0x1F,0x06,0x1F,0x06,0x06,0x06,0x06,0x06,0x06,0x03,0x86,0x03,0xFE,0x01,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xD1 +.db 0xE0,0x00,0x10,0x01,0x00,0x00,0xFC,0x07,0xFC,0x07,0x0C,0x00,0x0C,0x00,0x0C,0x00,0xFC,0x03,0xFC,0x03,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0xFC,0x07,0xFC,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xD2 +.db 0x18,0x03,0x18,0x03,0x00,0x00,0xFC,0x07,0xFC,0x07,0x0C,0x00,0x0C,0x00,0x0C,0x00,0xFC,0x03,0xFC,0x03,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0xFC,0x07,0xFC,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xD3 +.db 0x60,0x00,0xC0,0x00,0x00,0x00,0xFC,0x07,0xFC,0x07,0x0C,0x00,0x0C,0x00,0x0C,0x00,0xFC,0x03,0xFC,0x03,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0xFC,0x07,0xFC,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xD4 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0xFC,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xD5 +.db 0xC0,0x00,0x60,0x00,0x00,0x00,0xFE,0x01,0xFE,0x01,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0xFE,0x01,0xFE,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xD6 +.db 0x70,0x00,0x88,0x00,0x00,0x00,0xFE,0x01,0xFE,0x01,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0xFE,0x01,0xFE,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xD7 +.db 0x8C,0x01,0x8C,0x01,0x00,0x00,0xFE,0x01,0xFE,0x01,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0xFE,0x01,0xFE,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xD8 +.db 0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x7F,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xD9 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x0F,0xE0,0x0F,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00, ; 0xDA +.db 0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F, ; 0xDB +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F, ; 0xDC +.db 0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00, ; 0xDD +.db 0x30,0x00,0x60,0x00,0x00,0x00,0xFE,0x01,0xFE,0x01,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0xFE,0x01,0xFE,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xDE +.db 0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xDF +.db 0xC0,0x00,0x60,0x00,0x00,0x00,0xF8,0x00,0xFC,0x01,0x8E,0x03,0x07,0x07,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x07,0x07,0x8E,0x03,0xFC,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xE0 +.db 0x00,0x00,0xFC,0x00,0xFE,0x01,0x86,0x01,0x86,0x01,0xC6,0x00,0xC6,0x00,0x66,0x00,0xE6,0x00,0xC6,0x01,0x86,0x03,0x06,0x07,0x06,0x06,0x26,0x06,0xE6,0x07,0xC6,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xE1 +.db 0x70,0x00,0x88,0x00,0x00,0x00,0xF8,0x00,0xFC,0x01,0x8E,0x03,0x07,0x07,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x07,0x07,0x8E,0x03,0xFC,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xE2 +.db 0x30,0x00,0x60,0x00,0x00,0x00,0xF8,0x00,0xFC,0x01,0x8E,0x03,0x07,0x07,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x07,0x07,0x8E,0x03,0xFC,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xE3 +.db 0x00,0x00,0x70,0x02,0xC8,0x01,0x00,0x00,0x00,0x00,0xF0,0x00,0xFC,0x03,0x0C,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x03,0xFC,0x03,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xE4 +.db 0x70,0x02,0xC8,0x01,0x00,0x00,0xF8,0x00,0xFC,0x01,0x8E,0x03,0x07,0x07,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x07,0x07,0x8E,0x03,0xFC,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xE5 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x8E,0x03,0xFE,0x03,0x76,0x03,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00, ; 0xE6 +.db 0x00,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0xE6,0x00,0xF6,0x01,0x8E,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x8E,0x01,0xFE,0x01,0xF6,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00, ; 0xE7 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0xFE,0x00,0xFE,0x01,0x86,0x03,0x06,0x03,0x06,0x03,0x86,0x03,0xFE,0x01,0x7E,0x00,0x06,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xE8 +.db 0xC0,0x00,0x60,0x00,0x00,0x00,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x8E,0x03,0xFC,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xE9 +.db 0x70,0x00,0x88,0x00,0x00,0x00,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x8E,0x03,0xFC,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xEA +.db 0x30,0x00,0x60,0x00,0x00,0x00,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x8E,0x03,0xFC,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xEB +.db 0x80,0x01,0xC0,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x0C,0x02,0x0C,0x03,0x1C,0x03,0x98,0x01,0x98,0x01,0xB0,0x00,0xF0,0x00,0xF0,0x00,0x60,0x00,0x60,0x00,0x20,0x00,0x30,0x00,0x3C,0x00,0x1C,0x00, ; 0xEC +.db 0xC0,0x00,0x60,0x00,0x00,0x00,0x07,0x0C,0x06,0x06,0x0C,0x03,0x1C,0x03,0x98,0x01,0xF0,0x00,0xF0,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xED +.db 0xFF,0x0F,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xEE +.db 0x60,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xEF +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x03,0xFC,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xF0 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0xFE,0x07,0xFE,0x07,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0xFE,0x07,0xFE,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xF1 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x0F,0x00,0x00,0xFF,0x0F,0x00,0x00, ; 0xF2 +.db 0x00,0x00,0x00,0x00,0x0F,0x0C,0x18,0x06,0x18,0x03,0x86,0x03,0x98,0x01,0xD8,0x00,0x6F,0x07,0x60,0x07,0xB0,0x06,0x58,0x06,0x3C,0x06,0xEC,0x0F,0x06,0x06,0x03,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xF3 +.db 0x00,0x00,0x00,0x00,0xFC,0x03,0x3E,0x02,0x3E,0x02,0x3E,0x02,0x3E,0x02,0x3C,0x02,0x38,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x00,0x00, ; 0xF4 +.db 0x00,0x00,0x00,0x00,0xF0,0x01,0xF8,0x01,0x0C,0x00,0x0C,0x00,0x1C,0x00,0xF0,0x00,0xC8,0x01,0x8C,0x03,0x0C,0x03,0x1C,0x03,0xF8,0x01,0xE0,0x01,0x80,0x03,0x00,0x03,0x04,0x03,0xFC,0x01,0xF8,0x00,0x00,0x00, ; 0xF5 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0xFE,0x07,0xFE,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xF6 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x70,0x00,0xC0,0x00,0x70,0x00, ; 0xF7 +.db 0x00,0x00,0x00,0x00,0x30,0x00,0x48,0x00,0x48,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xF8 +.db 0x8C,0x01,0x8C,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xF9 +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xFA +.db 0x00,0x00,0x00,0x00,0x78,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xFB +.db 0x00,0x00,0x00,0x00,0xF8,0x00,0x88,0x01,0x80,0x01,0xF0,0x00,0x80,0x01,0x80,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xFC +.db 0x00,0x00,0x00,0x00,0xF8,0x01,0x00,0x03,0x00,0x03,0x80,0x01,0x60,0x00,0x18,0x00,0xF8,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xFD +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x07,0xFE,0x07,0xFE,0x07,0xFE,0x07,0xFE,0x07,0xFE,0x07,0xFE,0x07,0xFE,0x07,0xFE,0x07,0xFE,0x07,0xFE,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0xFE +.db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ; 0xFF + diff --git a/avr/modules/lcd2/font/font6x8.asm b/avr/modules/lcd2/font/font6x8.asm index 50b5696..124d44a 100644 --- a/avr/modules/lcd2/font/font6x8.asm +++ b/avr/modules/lcd2/font/font6x8.asm @@ -15,6 +15,19 @@ +; --------------------------------------------------------------------------- +; @routine font6x8MonoHandlerFn +; +; Handler for 6x8 Mono Fonts +; + +font6x8MonoHandlerFn: + cpi r23, FONT_FN_RENDER + breq font6x8MonoRenderCharacter + rjmp FONT_GenericHandler +; @end + + ; --------------------------------------------------------------------------- ; @routine font6x8RenderCharacter diff --git a/avr/modules/lcd2/font/font8x8.asm b/avr/modules/lcd2/font/font8x8.asm index f33a2dc..2f2d40a 100644 --- a/avr/modules/lcd2/font/font8x8.asm +++ b/avr/modules/lcd2/font/font8x8.asm @@ -15,6 +15,20 @@ +; --------------------------------------------------------------------------- +; @routine font8x8MonoHandlerFn +; +; Handler for 8x8 Mono Fonts +; + +font8x8MonoHandlerFn: + cpi r23, FONT_FN_RENDER + breq font8x8MonoRenderCharacter + rjmp FONT_GenericHandler +; @end + + + ; --------------------------------------------------------------------------- ; @routine font8x8RenderCharacter diff --git a/avr/modules/lcd2/font/main.asm b/avr/modules/lcd2/font/main.asm new file mode 100644 index 0000000..d86a602 --- /dev/null +++ b/avr/modules/lcd2/font/main.asm @@ -0,0 +1,167 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + + +; *************************************************************************** +; code + +.cseg + + + +; --------------------------------------------------------------------------- +; @routine FONT_RenderChar + +; @param R16 character to write +; @param R1:R0 background color +; @param R3:R2 foreground color +; @param Z pointer to font +; @param X pointer to RAM to store data to +; @param r18 char width in pixel +; @param r19 char height in pixel +; @clobbers any, !Z + +FONT_RenderChar: + ldi r23, FONT_FN_RENDER + rjmp fontCallHandler +; @end + + + + +; --------------------------------------------------------------------------- +; @routine FONT_GetCharWidth + +; @param Z pointer to font +; @return R16 character width for given character set +; @clobbers any, !Z + +FONT_GetCharWidth: + ldi r23, FONT_FN_GETCHARWIDTH + rjmp fontCallHandler +; @end + + + +; --------------------------------------------------------------------------- +; @routine FONT_GetCharHeight + +; @param Z pointer to font +; @return R16 character height for given character set +; @clobbers any, !Z + +FONT_GetCharHeight: + ldi r23, FONT_FN_GETCHARHEIGHT + rjmp fontCallHandler +; @end + + + +; --------------------------------------------------------------------------- +; @routine FONT_GetStringWidth + +; @param Z pointer to font +; @param X pointer to null-terminated string in flash +; @return R16 character width for given character set +; @clobbers any, !Z + +FONT_GetStringWidthFlash: + ldi r23, FONT_FN_GETSTRINGWIDTH + rjmp fontCallHandler +; @end + + + +; --------------------------------------------------------------------------- +; @routine FONT_GetStringHeight + +; @param Z pointer to font +; @param X pointer to null-terminated string in flash +; @return R16 character width for given character set +; @clobbers any, !Z + +FONT_GetStringHeight: + ldi r23, FONT_FN_GETSTRINGHEIGHT + rjmp fontCallHandler +; @end + + + + + +; --------------------------------------------------------------------------- +; @routine fontCallHandler +; +; @param r23 function number +; @param Z pointer to font + +fontCallHandler: + lpm r17, Z+ + push r17 + lpm r17, Z + push r17 + sbiw zh:zl, 1 + ret +; @end + + + + +; --------------------------------------------------------------------------- +; @routine FONT_GenericHandler +; +; Generic handler for font functions. +; @param R23 function to call (see @ref FONT_FN_RENDER et al) + +FONT_GenericHandler: + cpi r23, FONT_FN_GETCHARWIDTH + breq fontGenericFnGetCharWidth + cpi r23, FONT_FN_GETCHARHEIGHT + breq fontGenericFnGetCharHeight + cpi r23, FONT_FN_GETSTRINGWIDTH + breq fontGenericFnGetStringWidth + cpi r23, FONT_FN_GETSTRINGHEIGHT + breq fontGenericFnGetStringHeight + ret +fontGenericFnGetCharWidth: + adiw zh:zl, FONT_OFFS_WIDTH + ld r16, X + sbiw zh:zl, FONT_OFFS_WIDTH + ret +fontGenericFnGetCharHeight: + adiw zh:zl, FONT_OFFS_HEIGHT + ld r16, X + sbiw zh:zl, FONT_OFFS_HEIGHT + ret +fontGenericFnGetStringWidth: + adiw zh:zl, FONT_OFFS_WIDTH + ld r17, X + sbiw zh:zl, FONT_OFFS_WIDTH + clr r16 + push zl + push zh + mov zl, xl + mov zh, xh +fontGenericFnGetStringWidth_loop: + lpm r18, Z+ + tst r18 + breq fontGenericFnGetStringWidth_loopEnd + add r16, r17 + rjmp fontGenericFnGetStringWidth_loop +fontGenericFnGetStringWidth_loopEnd: + pop zh + pop zl + ret +fontGenericFnGetStringHeight: + rjmp fontGenericFnGetCharHeight ; for now monospace fonts only +; @end + + + diff --git a/avr/modules/lcd2/ili9341/main.asm b/avr/modules/lcd2/ili9341/main.asm index a0b355f..f86b984 100644 --- a/avr/modules/lcd2/ili9341/main.asm +++ b/avr/modules/lcd2/ili9341/main.asm @@ -36,102 +36,12 @@ ILI9341_Init: rcall ILI9341IoInit - rcall ILI9341_Reset - rcall ILI9341_LeaveSleepMode ldi r16, 0xff rcall ILI9341_SetBacklight - -#if 0 - ldi r16, 0xff - mov r3, r16 - ldi r16, 0xff - mov r2, r16 - rcall ili9341Test5 - -; 0bRRRRRGGGGGGBBBBB - - ldi r16, 0b11111000 ; red - mov r3, r16 - ldi r16, 0b00000000 ; red - mov r2, r16 - rcall ili9341Test2 - -; 0bRRRRRGGGGGGBBBBB - ldi r16, 0b00000000 - mov r3, r16 - ldi r16, 0b00011111 ; blue - mov r2, r16 - rcall ili9341Test3 - -; 0bRRRRRGGGGGGBBBBB - ldi r16, 0b00000111 ; green - mov r3, r16 - ldi r16, 0b11100000 ; green - mov r2, r16 - rcall ili9341Test4 - -; set foreground color - ldi r16, 0b11100000 ; green - mov r2, r16 - ldi r16, 0b00000111 ; green - mov r3, r16 - -; set background color - ldi r16, 0b11111111 ; white - mov r0, r16 - mov r1, r16 - -; set Xpos - ldi r16, LOW(100) - mov r4, r16 - ldi r16, HIGH(100) - mov r5, r16 - -; setYpos - ldi r16, LOW(150) - mov r6, r16 - ldi r16, HIGH(150) - mov r7, r16 - -; set font pos - ldi zl, LOW(font2_6x8*2) - ldi zh, HIGH(font2_6x8*2) - -; set buffer pos -; ldi xl, LOW(ILI9341_buffer) -; ldi xh, HIGH(ILI9341_buffer) - ldi xl, LOW(0x260) - ldi xh, HIGH(0x260) - -; set foreground color - ldi r16, 0b00000000 ; black - mov r2, r16 - mov r3, r16 - -; set character - ldi r16, 'A' - rcall ili9341_WriteCharacterX4At - - ldi r16, 'Q' - rcall ili9341_WriteCharacterX4At - - ldi r16, 'H' - rcall ili9341_WriteCharacterX4At - - ldi r16, 'O' - rcall ili9341_WriteCharacterX4At - - ldi r16, 'M' - rcall ili9341_WriteCharacterX4At - - ldi r16, 'E' - rcall ili9341_WriteCharacterX4At -#endif - sec ret ; @end @@ -269,108 +179,6 @@ ILI9341_LeaveSleepMode: -; --------------------------------------------------------------------------- -; @routine ILI9341_FillScreen -; -; @param r17:r16 color - -ILI9341_FillScreen: -; TODO - ret -; @end - - - - - - - - - - - - - - - - - - -ili9341Test1: - rcall ili9341BeginSpi - ldi r16, 0x04 - cbi ILI9341_DC_OUTPUT, ILI9341_DC_PIN ; D low (send command) - rcall SPIHW_MasterTransfer ; (R16) - sbi ILI9341_DC_OUTPUT, ILI9341_DC_PIN ; D high (send data) - clr r16 - ; read byte 1 - rcall SPIHW_MasterTransfer ; (R16) - ; read byte 2 - rcall SPIHW_MasterTransfer ; (R16) - ; read byte 3 - rcall SPIHW_MasterTransfer ; (R16) - ; read byte 4 - rcall SPIHW_MasterTransfer ; (R16) - rcall ili9341EndSpi ; (R16) - ret - - - -; @param %0 X -; @param %1 Y -; @param %2 W -; @param %3 H -.macro M_ILI9341_FILL_RECT - ldi r16, LOW(@0) ; X0 - mov r4, r16 - ldi r16, HIGH(@0) - mov r5, r16 - - ldi r16, LOW(@1) ; Y0 - mov r6, r16 - ldi r16, HIGH(@1) - mov r7, r16 - - ldi r16, LOW(@2) ; W - mov r8, r16 - ldi r16, HIGH(@2) - mov r9, r16 - - ldi r16, LOW(@3) ; H - mov r10, r16 - ldi r16, HIGH(@3) - mov r11, r16 - - rcall ILI9341_FillRect -.endmacro - - - -ili9341Test2: - M_ILI9341_FILL_RECT 10, 20, 70, 100 - ret - - - -ili9341Test3: - M_ILI9341_FILL_RECT 90, 40, 70, 100 - ret - - - -ili9341Test4: - M_ILI9341_FILL_RECT 40, 30, 70, 100 - ret - - - -ili9341Test5: - M_ILI9341_FILL_RECT 0, 0, 319, 239 - ret - - - - ili9341InitCommands: ; display off .db 0x28, 0 @@ -421,10 +229,3 @@ ili9341InitCommands: .db 0xff, 0xff -helloWorld: .db "Hello World", 0 - - - -.include "modules/lcd2/font/font2.asm" - - diff --git a/avr/modules/lcd2/ili9341/text.asm b/avr/modules/lcd2/ili9341/text.asm index 5950906..389746b 100644 --- a/avr/modules/lcd2/ili9341/text.asm +++ b/avr/modules/lcd2/ili9341/text.asm @@ -31,7 +31,7 @@ ili9341_WriteCharacterX1At: push xl push xh - rcall ili9341FontRenderChar ; (r16, r17, r24, r25, z) + rcall ili9341FontRenderChar ; (r16, r17, r24, r25, z) rcall ili9341BitBlit ; (r16, r17, r20, r21, r22, r23, r24, r25, X) ; advance X (add char width to X) add r4, r8 @@ -58,7 +58,7 @@ ili9341_WriteCharacterX1At: ; @clobbers r16 (r17, r18, r19, r20, r21, r22, r23, r24, r25, X) ili9341_WriteCharacterX2At: - rcall ili9341FontRenderChar ; (r16, r17, r24, r25, z) + rcall ili9341FontRenderChar ; (r16, r17, r24, r25, z) rcall ili9341BitBlitStretch2 ; (r16, r17, r18, r19, r20, r21, r22, r23, r24, r25, X) ; advance X (add double char width to X) lsl r8 ; Wx2 @@ -114,8 +114,7 @@ ili9341FontRenderChar: ; render character push xl push xh - ; call render function of the selected font (first word of font is jmp to render function) - rcall ili9341JumpToFontRenderFn ; (r17, r24, r25, x) + rcall FONT_RenderChar pop xh pop xl @@ -129,24 +128,6 @@ ili9341FontRenderChar: -; --------------------------------------------------------------------------- -; @routine ili9341JumpToFontRenderFn -; -; helper function to call function at the beginning of the given font -; @clobbers r17 - -ili9341JumpToFontRenderFn: - lpm r17, Z+ - push r17 - lpm r17, Z - push r17 - sbiw zh:zl, 1 - ret -; @end - - - - ; --------------------------------------------------------------------------- ; @routine textNibbleToAscii ; @@ -169,7 +150,7 @@ textNibbleToAscii_l1: - +#if 0 ; --------------------------------------------------------------------------- ; @routine ili9341_WriteCharacterX4At @@ -272,6 +253,7 @@ Debug_WriteHexBuffer_loop: brne Debug_WriteHexBuffer_loop ret +#endif diff --git a/avr/modules/lcd2/win/defs.asm b/avr/modules/lcd2/win/defs.asm index 1593358..2b7cf2b 100644 --- a/avr/modules/lcd2/win/defs.asm +++ b/avr/modules/lcd2/win/defs.asm @@ -101,11 +101,12 @@ .equ TIMER_OFFS_LIST = 0 .equ TIMER_OFFS_TIMER = LIST_SIZE .equ TIMER_OFFS_VALUE_LO = TIMER_OFFS_TIMER -.equ TIMER_OFFS_VALUE_LO = TIMER_OFFS_TIMER+1 +.equ TIMER_OFFS_VALUE_HI = TIMER_OFFS_TIMER+1 .equ TIMER_OFFS_RELOAD_LO = TIMER_OFFS_TIMER+2 .equ TIMER_OFFS_RELOAD_HI = TIMER_OFFS_TIMER+3 .equ TIMER_OFFS_OPTIONS = TIMER_OFFS_TIMER+4 -.equ TIMER_SIZE = TIMER_OFFS_TIMER+5 +.equ TIMER_OFFS_SIGNAL = TIMER_OFFS_TIMER+5 +.equ TIMER_SIZE = TIMER_OFFS_TIMER+6 diff --git a/avr/modules/lcd2/win/object.asm b/avr/modules/lcd2/win/object.asm new file mode 100644 index 0000000..3b83ec9 --- /dev/null +++ b/avr/modules/lcd2/win/object.asm @@ -0,0 +1,464 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + +; --------------------------------------------------------------------------- +; @routine OBJ_Init @global +; +; @param Y pointer to object SRAM +; @param Z pointer to handler function (word address) +; @param r17 options +; @clobbers X + +OBJ_Init: + push r17 + mov xl, yl + mov xh, yh + clr r16 + ldi r17, OBJ_OFFS_SIZE + rcall Utils_FillSram ; (R17, X) + rcall Tree_InitObject ; (R16) + pop r17 + std Y+OBJ_OFFS_HANDLERFN_LO, zl + std Y+OBJ_OFFS_HANDLERFN_HI, zh + std Y+OBJ_OFFS_OPTIONS, r17 + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine OBJ_free @global +; +; @param Y pointer to object in SRAM +; @clobbers any + +OBJ_free: + ; free children + push yl + push yh + rcall Tree_GetFirstChildObject +OBJ_free_loop: + mov r16, xl + or r16, xh + breq OBJ_free_loopEnd + mov yl, xl + mov yh, xh + rcall List_GetNextObject + push xl ; next + push xh ; next + rcall OBJ_free + pop xh ; next + pop xl ; next + rjmp OBJ_free_loop +OBJ_free_loopEnd: + pop yh + pop yl + + rcall Tree_UnlinkObject + + push yl + push yh + ldi r16, OBJ_SIGNAL_DESTROY + rcall OBJ_Handler + pop yh + pop yl + rcall objFreeLinks + rcall objFreeTimers + mov xl, yl + mov xh, yh + rcall Heap_free + clc + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine OBJ_Handler +; +; Signal handler for an object. A signal can have up to 3 parameters +; conveyed in registers R18, R19 and X. +; +; @param Y pointer to object SRAM +; @param r16 signal +; @param R18 1st param +; @param R19 2nd param +; @param X 3rd param + +OBJ_Handler: + ldd r17, Y+OBJ_OFFS_HANDLERFN_LO + push r17 + ldd r17, Y+OBJ_OFFS_HANDLERFN_HI + push r17 + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine OBJ_EmitSignal +; +; @param Y pointer to object SRAM +; @param r16 signal to emit +; @param R18 1st param +; @param R19 2nd param +; @param X 3rd param + +OBJ_EmitSignal: + push yl + push yh + ldd r17, Y+OBJ_OFFS_LINKS_LO + ldd yh, Y+OBJ_OFFS_LINKS_HI + mov yl, r17 +OBJ_EmitSignal_loop: + push r16 + rcall objCheckEmitSignalForLink + pop r16 + push xl + push xh + rcall List_GetNextObject ; (any, !X, !Y, !R18, !R19) + mov yl, xl + mov yh, xh + pop xh + pop xl + mov r17, yl + or r17, yh + brne OBJ_EmitSignal_loop +OBJ_EmitSignal_popRet: + pop yh + pop yl + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine OBJ_AddLink @global +; +; @param Y pointer to object SRAM +; @param X pointer to link +; @clobbers R16, R17 + +OBJ_AddLink: + ldd r16, Y+OBJ_OFFS_LINKS_LO + ldd r17, Y+OBJ_OFFS_LINKS_HI + tst r16 + brne OBJ_AddLink_addToExisting + tst r17 + brne OBJ_AddLink_addToExisting + ; empty list, new link is first + std Y+OBJ_OFFS_LINKS_LO, xl + std Y+OBJ_OFFS_LINKS_HI, xh + rjmp OBJ_AddLink_end +OBJ_AddLink_addToExisting: + push xl + push xh + push yl + push yh + mov yl, xl + mov yh, xh + mov xl, r16 + mov xh, r17 + rcall List_AddObject ; (r16, r17, x) + pop yh + pop yl + pop xh + pop xl +OBJ_AddLink_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine OBJ_RemoveLink @global +; +; @param Y pointer to object SRAM +; @param X pointer to link +; @clobbers R16, R17 + +OBJ_RemoveLink: + ldd r16, Y+OBJ_OFFS_LINKS_LO + ldd r17, Y+OBJ_OFFS_LINKS_HI + cp r16, xl + brne OBJ_RemoveLink_notFirst + cp r17, xh + brne OBJ_RemoveLink_notFirst + clr r16 + std Y+OBJ_OFFS_LINKS_LO, r16 + std Y+OBJ_OFFS_LINKS_HI, r16 + rjmp OBJ_RemoveLink_end +OBJ_RemoveLink_notFirst: + push xl + push xh + push yl + push yh + mov yl, xl + mov yh, r17 + mov xl, r16 + mov xh, r17 + rcall List_UnlinkObject ; (r16, r17, x) + pop yh + pop yl + pop xh + pop xl +OBJ_RemoveLink_end: + ret +; @end + + + + + +; --------------------------------------------------------------------------- +; @routine OBJ_AddTimer @global +; +; @param Y pointer to object SRAM +; @param X pointer to timer +; @clobbers R16, R17 + +OBJ_AddTimer: + ldd r16, Y+OBJ_OFFS_TIMERS_LO + ldd r17, Y+OBJ_OFFS_TIMERS_HI + tst r16 + brne OBJ_AddTimer_addToExisting + tst r17 + brne OBJ_AddTimer_addToExisting + ; empty list, new timer is first + std Y+OBJ_OFFS_TIMERS_LO, xl + std Y+OBJ_OFFS_TIMERS_HI, xh + rjmp OBJ_AddTimer_end +OBJ_AddTimer_addToExisting: + push xl + push xh + push yl + push yh + mov yl, xl + mov yh, xh + mov xl, r16 + mov xh, r17 + rcall List_AddObject ; (r16, r17, x) + pop yh + pop yl + pop xh + pop xl +OBJ_AddTimer_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine OBJ_RemoveTimer @global +; +; @param Y pointer to object SRAM +; @param X pointer to timer +; @clobbers R16, R17 + +OBJ_RemoveTimer: + ldd r16, Y+OBJ_OFFS_TIMERS_LO + ldd r17, Y+OBJ_OFFS_TIMERS_HI + cp r16, xl + brne OBJ_RemoveTimer_notFirst + cp r17, xh + brne OBJ_RemoveTimer_notFirst + clr r16 + std Y+OBJ_OFFS_TIMERS_LO, r16 + std Y+OBJ_OFFS_TIMERS_HI, r16 + rjmp OBJ_RemoveTimer_end +OBJ_RemoveTimer_notFirst: + push xl + push xh + push yl + push yh + mov yl, xl + mov yh, r17 + mov xl, r16 + mov xh, r17 + rcall List_UnlinkObject ; (r16, r17, x) + pop yh + pop yl + pop xh + pop xl +OBJ_RemoveTimer_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @param r16 signal +; @param Y link +; @clobbers any, !X, !Y, !R18, !R19 + +objCheckEmitSignalForLink: + ldd r17, Y+OBJ_LINK_OFFS_SIGNAL + cp r16, r17 + brne objCheckEmitSignalForLink_ret + push yl + push yh + push xl + push xh + push r18 + push r19 + ldd r16, Y+OBJ_LINK_OFFS_SLOT + ldd r17, Y+OBJ_LINK_OFFS_TARGET_LO + ldd yh, Y+OBJ_LINK_OFFS_TARGET_HI + mov yl, r17 + rcall OBJ_Handler + pop r19 + pop r18 + pop xh + pop xl + pop yh + pop yl +objCheckEmitSignalForLink_ret: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine objFreeLinks +; +; @clobbers r16, r17, r18, r19, r24, r25, X + +objFreeLinks: + push yl + push yh + ldd r16, Y+OBJ_OFFS_LINKS_LO + ldd r17, Y+OBJ_OFFS_LINKS_HI + clr r18 + std Y+OBJ_OFFS_LINKS_LO, r18 + std Y+OBJ_OFFS_LINKS_HI, r18 + mov yl, r16 + mov yh, r17 + ldi zl, LOW(Obj_Link_free) + ldi zh, HIGH(Obj_Link_free) + rcall List_ForEveryObject ; (r16, r17, r18, r19, r24, r25, X, Y) + pop yh + pop yl + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine objFreeTimers +; +; @clobbers r16, r17, r18, r19, r24, r25, X + +objFreeTimers: + push yl + push yh + ldd r16, Y+OBJ_OFFS_TIMERS_LO + ldd r17, Y+OBJ_OFFS_TIMERS_HI + clr r18 + std Y+OBJ_OFFS_TIMERS_LO, r18 + std Y+OBJ_OFFS_TIMERS_HI, r18 + mov yl, r16 + mov yh, r17 + ldi zl, LOW(Obj_Timer_free) + ldi zh, HIGH(Obj_Timer_free) + rcall List_ForEveryObject ; (r16, r17, r18, r19, r24, r25, X, Y) + pop yh + pop yl + ret +; @end + + + + + + +; --------------------------------------------------------------------------- +; @routine OBJ_Link_new @global +; +; @return CF set if okay, cleared on error +; @return Y pointer to SRAM for link +; @clobbers r16, r17, X + +OBJ_Link_new: + ldi r24, LOW(OBJ_LINK_SIZE) + ldi r25, HIGH(OBJ_LINK_SIZE) + rcall Heap_Alloc + brcc OBJ_Link_new_end + mov yl, xl + mov yh, xh + clr r16 + ldi r17, OBJ_LINK_SIZE + bigcall Utils_FillSram ; (R17, X) + rcall List_InitObject ; (R16) + sec +OBJ_Link_new_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine OBJ_Link_free @global +; +; @param Y pointer to SRAM for link +; @clobbers r16, r17, r24, r25, X + +OBJ_Link_free: + rcall List_FiniObject ; (R16) + mov xl, yl + mov xh, yh + rcall Heap_free ; (r16, r17, r24, r25, X) + clc + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine OBJ_Timer_new @global +; +; @return CF set if okay, cleared on error +; @return Y pointer to SRAM for timer +; @clobbers r16, r17, X + +OBJ_Timer_new: + ldi r24, LOW(TIMER_SIZE) + ldi r25, HIGH(TIMER_SIZE) + rcall Heap_Alloc + brcc OBJ_Timer_new_end + mov yl, xl + mov yh, xh + clr r16 + ldi r17, TIMER_SIZE + bigcall Utils_FillSram ; (R17, X) + rcall List_InitObject ; (R16) + sec +OBJ_Timer_new_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine OBJ_Timer_free @global +; +; @param Y pointer to SRAM for timer +; @clobbers r16, r17, r24, r25, X + +OBJ_Timer_free: + rcall List_FiniObject ; (R16) + mov xl, yl + mov xh, yh + rcall Heap_free ; (r16, r17, r24, r25, X) + clc + ret +; @end + + + diff --git a/avr/modules/lcd2/win/widget.asm b/avr/modules/lcd2/win/widget.asm index 4a070d6..198d950 100644 --- a/avr/modules/lcd2/win/widget.asm +++ b/avr/modules/lcd2/win/widget.asm @@ -11,8 +11,11 @@ ; --------------------------------------------------------------------------- ; @routine WID_Widget_new @global - - -WID_Widget_new: +; +; @param Y pointer to window SRAM +; @param r18 WID_OFFS_OPTIONS1 +; @param r19 WID_OFFS_OPTIONS2 + +WID_Widget_Init: From 41867ed01a4935548d0dcb8759d63b771854c7ca Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 2 Jun 2025 23:29:06 +0200 Subject: [PATCH 007/196] added missing files. --- avr/common/0BUILD | 2 ++ 1 file changed, 2 insertions(+) diff --git a/avr/common/0BUILD b/avr/common/0BUILD index e39dfb6..7b2d918 100644 --- a/avr/common/0BUILD +++ b/avr/common/0BUILD @@ -27,7 +27,9 @@ wait_50us.asm watchdog.asm list.asm + list_t.asm tree.asm + tree_t.asm From 888792a2013dcd2bf70ebec94cd3a3ecd7b09326 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 2 Jun 2025 23:29:50 +0200 Subject: [PATCH 008/196] more work on gui code. --- avr/modules/lcd2/win/defs.asm | 19 +++-- avr/modules/lcd2/win/object.asm | 104 ++++++++++++++++++++++-- avr/modules/lcd2/win/widget.asm | 140 ++++++++++++++++++++++++++++++++ 3 files changed, 246 insertions(+), 17 deletions(-) diff --git a/avr/modules/lcd2/win/defs.asm b/avr/modules/lcd2/win/defs.asm index 2b7cf2b..467d19b 100644 --- a/avr/modules/lcd2/win/defs.asm +++ b/avr/modules/lcd2/win/defs.asm @@ -50,17 +50,18 @@ -.equ WID_OPTIONS1_BIT_DIRTY = 0 -.equ WID_OPTIONS1_BIT_LAYOUT = 1 +.equ WID_OPTIONS0_BIT_VISIBLE = 0 ; OBJ_OFFS_OPTIONS +.equ WID_OPTIONS0_BIT_DIRTY = 1 +.equ WID_OPTIONS0_BIT_LAYOUT = 2 -.equ WID_OPTIONS1_BIT_STRETCH_X = 2 -.equ WID_OPTIONS1_BIT_STRETCH_Y = 3 +.equ WID_OPTIONS1_BIT_STRETCH_X = 0 ; WID_OFFS_OPTIONS1 +.equ WID_OPTIONS1_BIT_STRETCH_Y = 1 -.equ WID_OPTIONS1_BIT_ALIGN_RIGHT = 4 -.equ WID_OPTIONS1_BIT_ALIGN_BOTTOM = 5 +.equ WID_OPTIONS1_BIT_ALIGN_RIGHT = 2 +.equ WID_OPTIONS1_BIT_ALIGN_BOTTOM = 3 -.equ WID_OPTIONS1_BIT_EQUAL_WIDTH = 6 -.equ WID_OPTIONS1_BIT_EQUAL_HEIGHT = 7 +.equ WID_OPTIONS1_BIT_EQUAL_WIDTH = 4 +.equ WID_OPTIONS1_BIT_EQUAL_HEIGHT = 5 ; Signals @@ -73,7 +74,7 @@ .equ WID_SIGNAL_SHOW = OBJ_SIGNAL_NEXTFREE .equ WID_SIGNAL_HIDE = OBJ_SIGNAL_NEXTFREE+1 -.equ WID_SIGNAL_UPDATE = OBJ_SIGNAL_NEXTFREE+2 +.equ WID_SIGNAL_DRAW = OBJ_SIGNAL_NEXTFREE+2 .equ WID_SIGNAL_LAYOUT = OBJ_SIGNAL_NEXTFREE+3 .equ WID_SIGNAL_TOUCH = OBJ_SIGNAL_NEXTFREE+4 .equ WID_SIGNAL_MOUSE = OBJ_SIGNAL_NEXTFREE+5 diff --git a/avr/modules/lcd2/win/object.asm b/avr/modules/lcd2/win/object.asm index 3b83ec9..2f5b57b 100644 --- a/avr/modules/lcd2/win/object.asm +++ b/avr/modules/lcd2/win/object.asm @@ -12,7 +12,6 @@ ; @routine OBJ_Init @global ; ; @param Y pointer to object SRAM -; @param Z pointer to handler function (word address) ; @param r17 options ; @clobbers X @@ -25,14 +24,54 @@ OBJ_Init: rcall Utils_FillSram ; (R17, X) rcall Tree_InitObject ; (R16) pop r17 - std Y+OBJ_OFFS_HANDLERFN_LO, zl - std Y+OBJ_OFFS_HANDLERFN_HI, zh std Y+OBJ_OFFS_OPTIONS, r17 + ldi r16, LOW(OBJ_DefaultHandler) + std Y+OBJ_OFFS_HANDLERFN_LO, r16 + ldi r16, HIGH(OBJ_DefaultHandler) + std Y+OBJ_OFFS_HANDLERFN_HI, r16 ret ; @end +; --------------------------------------------------------------------------- +; @routine OBJ_SetHandler @global +; +; @param Y pointer to object SRAM +; @param Z pointer to handler function (word address) +; @clobbers X + +OBJ_SetHandler: + std Y+OBJ_OFFS_HANDLERFN_LO, zl + std Y+OBJ_OFFS_HANDLERFN_HI, zh + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine OBJ_GetHandler @global +; +; @param Y pointer to object SRAM +; @return Z pointer to handler function (word address) +; @clobbers none + +OBJ_GetHandler: + ldd zl, Y+OBJ_OFFS_HANDLERFN_LO + ldd zh, Y+OBJ_OFFS_HANDLERFN_HI + ret +; @end + + + +OBJ_DefaultHandler: + ret +; @end + + + + + ; --------------------------------------------------------------------------- ; @routine OBJ_free @global ; @@ -43,14 +82,14 @@ OBJ_free: ; free children push yl push yh - rcall Tree_GetFirstChildObject + rcall Tree_GetFirstChildObject ; (none) OBJ_free_loop: mov r16, xl or r16, xh breq OBJ_free_loopEnd mov yl, xl mov yh, xh - rcall List_GetNextObject + rcall Tree_GetNextSibling push xl ; next push xh ; next rcall OBJ_free @@ -61,7 +100,7 @@ OBJ_free_loopEnd: pop yh pop yl - rcall Tree_UnlinkObject + rcall Tree_UnlinkObject ; (r16, r17, x) push yl push yh @@ -102,6 +141,55 @@ OBJ_Handler: +; --------------------------------------------------------------------------- +; @routine OBJ_ForwardSignalToChildren +; +; Signal handler for an object. A signal can have up to 3 parameters +; conveyed in registers R18, R19 and X. +; +; @param Y pointer to object SRAM +; @param r16 signal +; @param R18 1st param +; @param R19 2nd param +; @param X 3rd param +; @clobbers any, !r16, !r18, !r19, !Y + +OBJ_ForwardSignalToChildren: + push yl + push yh + rcall Tree_GetFirstChildObject ; (none) +OBJ_ForwardSignalToChildren_loop: + clc + mov r17, xl + or r17, xh + breq OBJ_ForwardSignalToChildren_loopEnd + mov yl, xl + mov yh, xh + push r16 + push r18 + push r19 + push xl + push xh + push yl + push yh + rcall OBJ_Handler + pop yh + pop yl + pop xh + pop xl + pop r19 + pop r18 + pop r16 + rcall Tree_GetNextSibling + rjmp OBJ_ForwardSignalToChildren_loop +OBJ_ForwardSignalToChildren_loopEnd: + pop yh + pop yl + ret +; @end + + + ; --------------------------------------------------------------------------- ; @routine OBJ_EmitSignal ; @@ -119,11 +207,11 @@ OBJ_EmitSignal: mov yl, r17 OBJ_EmitSignal_loop: push r16 - rcall objCheckEmitSignalForLink + rcall objCheckEmitSignalForLink ; (any, !X, !Y, !R18, !R19) pop r16 push xl push xh - rcall List_GetNextObject ; (any, !X, !Y, !R18, !R19) + rcall List_GetNextObject ; (none) mov yl, xl mov yh, xh pop xh diff --git a/avr/modules/lcd2/win/widget.asm b/avr/modules/lcd2/win/widget.asm index 198d950..4a17e05 100644 --- a/avr/modules/lcd2/win/widget.asm +++ b/avr/modules/lcd2/win/widget.asm @@ -8,14 +8,154 @@ ; *************************************************************************** +; *************************************************************************** +; defs + +.equ WID_WIDGET_INTER_BORDER = 1 + + + +; *************************************************************************** +; code + +.cseg + + ; --------------------------------------------------------------------------- ; @routine WID_Widget_new @global ; ; @param Y pointer to window SRAM +; @param X pointer to parent ; @param r18 WID_OFFS_OPTIONS1 ; @param r19 WID_OFFS_OPTIONS2 WID_Widget_Init: + push r18 + push r19 + push xl + push xh + ldi zl, LOW(WID_Widget_Handler) + ldi zh, HIGH(WID_Widget_Handler) + clr r17 + rcall OBJ_Init + pop xh + pop xl + pop r19 + pop r18 + std Y+WID_OFFS_OPTIONS1, r18 + std Y+WID_OFFS_OPTIONS2, r19 + mov r16, xl + or r16, xh + breq WID_Widget_noParent + ; copy defaults from parent + adiw xh:xl, WID_OFFS_BG_COL_LO + ld r16, X+ ; WID_OFFS_BG_COL_LO + std Y+WID_OFFS_BG_COL_LO, r16 + ld r16, X+ ; WID_OFFS_BG_COL_HI + std Y+WID_OFFS_BG_COL_HI, r16 + ld r16, X+ ; WID_OFFS_FG_COL_LO + std Y+WID_OFFS_FG_COL_LO, r16 + ld r16, X+ ; WID_OFFS_FG_COL_HI + std Y+WID_OFFS_FG_COL_HI, r16 + ld r16, X+ ; WID_OFFS_FONT_LO + std Y+WID_OFFS_FONT_LO, r16 + ld r16, X+ ; WID_OFFS_FONT_HI + std Y+WID_OFFS_FONT_HI, r16 + rjmp WID_Widget_end +WID_Widget_noParent: ; preset without parent + clr r16 + std Y+WID_OFFS_FONT_LO, r16 + std Y+WID_OFFS_FONT_HI, r16 + + std Y+WID_OFFS_FG_COL_LO, r16 ; foreground black + std Y+WID_OFFS_FG_COL_HI, r16 + dec r16 + std Y+WID_OFFS_BG_COL_LO, r16 ; background white + std Y+WID_OFFS_BG_COL_HI, r16 + + ldi r16, 2 ; default borders + std Y+WID_OFFS_BORDER_TOP, r16 + std Y+WID_OFFS_BORDER_BOT, r16 + std Y+WID_OFFS_BORDER_LEFT, r16 + std Y+WID_OFFS_BORDER_RIGHT, r16 +WID_Widget_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine WID_Widget_Handler +; +; Signal handler for an object. A signal can have up to 3 parameters +; conveyed in registers R18, R19 and X. +; +; @param Y pointer to object SRAM +; @param r16 signal +; @param R18 1st param +; @param R19 2nd param +; @param X 3rd param +; @clobbers any, !Y + +WID_Widget_Handler: + cpi r16, WID_SIGNAL_GETMINSIZE + breq WID_Widget_Handler_getMinSize + ; for now just forward signal to all children +WID_Widget_Handler_forward: + rcall OBJ_ForwardSignalToChildren + ret +WID_Widget_Handler_getMinSize: + rjmp widgetGetMinSize +; @end + + + + +; --------------------------------------------------------------------------- +; @routine widgetGetMinSize +; +; @return r18 minimum width of widget +; @return r19 minimum height of widget +; @clobbers any, !Y + +widgetGetMinSize: + push yl + push yh + rcall Tree_GetFirstChildObject ; (none) + clr r20 + clr r21 +widgetGetMinSize_loop: + mov r17, xl + or r17, xh + breq widgetGetMinSize_loopEnd + mov yl, xl + mov yh, yl + push r20 + push r21 + ldi r16, WID_SIGNAL_GETMINSIZE + ldi r18, 1 ; default value for when the signal is not handled + ldi r19, 1 ; default value for when the signal is not handled + rcall OBJ_Handler ; ask child for its minimum size + pop r21 + pop r20 + add r20, r18 ; TODO: handle carry later + subi r20, -WID_WIDGET_INTER_BORDER + add r21, r19 ; TODO: handle carry later + subi r21, -WID_WIDGET_INTER_BORDER + rcall Tree_GetNextSibling ; (none) + rjmp widgetGetMinSize_loop +widgetGetMinSize_loopEnd: + mov r18, r20 + mov r19, r21 + pop yh + pop yl + ret +; @end + + + + + From 56e222a97ed0beecf54aa6c04a47f38e7e73bcc5 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 2 Jun 2025 23:38:08 +0200 Subject: [PATCH 009/196] split WID_SIGNAL_GETMINSIZE into two signals. --- avr/modules/lcd2/win/defs.asm | 19 ++++--- avr/modules/lcd2/win/widget.asm | 97 ++++++++++++++++++++++++--------- 2 files changed, 80 insertions(+), 36 deletions(-) diff --git a/avr/modules/lcd2/win/defs.asm b/avr/modules/lcd2/win/defs.asm index 467d19b..5ced1b3 100644 --- a/avr/modules/lcd2/win/defs.asm +++ b/avr/modules/lcd2/win/defs.asm @@ -72,15 +72,16 @@ .equ OBJ_SIGNAL_TIMER = 3 .equ OBJ_SIGNAL_NEXTFREE = 4 -.equ WID_SIGNAL_SHOW = OBJ_SIGNAL_NEXTFREE -.equ WID_SIGNAL_HIDE = OBJ_SIGNAL_NEXTFREE+1 -.equ WID_SIGNAL_DRAW = OBJ_SIGNAL_NEXTFREE+2 -.equ WID_SIGNAL_LAYOUT = OBJ_SIGNAL_NEXTFREE+3 -.equ WID_SIGNAL_TOUCH = OBJ_SIGNAL_NEXTFREE+4 -.equ WID_SIGNAL_MOUSE = OBJ_SIGNAL_NEXTFREE+5 -.equ WID_SIGNAL_KEY = OBJ_SIGNAL_NEXTFREE+6 -.equ WID_SIGNAL_GETMINSIZE = OBJ_SIGNAL_NEXTFREE+7 -.equ WID_SIGNAL_NEXTFREE = OBJ_SIGNAL_NEXTFREE+8 +.equ WID_SIGNAL_SHOW = OBJ_SIGNAL_NEXTFREE +.equ WID_SIGNAL_HIDE = OBJ_SIGNAL_NEXTFREE+1 +.equ WID_SIGNAL_DRAW = OBJ_SIGNAL_NEXTFREE+2 +.equ WID_SIGNAL_LAYOUT = OBJ_SIGNAL_NEXTFREE+3 +.equ WID_SIGNAL_TOUCH = OBJ_SIGNAL_NEXTFREE+4 +.equ WID_SIGNAL_MOUSE = OBJ_SIGNAL_NEXTFREE+5 +.equ WID_SIGNAL_KEY = OBJ_SIGNAL_NEXTFREE+6 +.equ WID_SIGNAL_GETMINWIDTH = OBJ_SIGNAL_NEXTFREE+7 +.equ WID_SIGNAL_GETMINHEIGHT = OBJ_SIGNAL_NEXTFREE+8 +.equ WID_SIGNAL_NEXTFREE = OBJ_SIGNAL_NEXTFREE+9 diff --git a/avr/modules/lcd2/win/widget.asm b/avr/modules/lcd2/win/widget.asm index 4a17e05..820feeb 100644 --- a/avr/modules/lcd2/win/widget.asm +++ b/avr/modules/lcd2/win/widget.asm @@ -11,7 +11,7 @@ ; *************************************************************************** ; defs -.equ WID_WIDGET_INTER_BORDER = 1 +.equ WID_WIDGET_INTER_BORDER = 2 @@ -99,55 +99,98 @@ WID_Widget_end: ; @clobbers any, !Y WID_Widget_Handler: - cpi r16, WID_SIGNAL_GETMINSIZE - breq WID_Widget_Handler_getMinSize + cpi r16, WID_SIGNAL_GETMINWIDTH + breq WID_Widget_Handler_getMinWidth + cpi r16, WID_SIGNAL_GETMINHEIGHT + breq WID_Widget_Handler_getMinHeight ; for now just forward signal to all children WID_Widget_Handler_forward: rcall OBJ_ForwardSignalToChildren ret -WID_Widget_Handler_getMinSize: - rjmp widgetGetMinSize +WID_Widget_Handler_getMinWidth: + rjmp widgetGetMinWidth +WID_Widget_Handler_getMinHeight: + rjmp widgetGetMinHeight ; @end ; --------------------------------------------------------------------------- -; @routine widgetGetMinSize +; @routine widgetGetMinWidth ; -; @return r18 minimum width of widget -; @return r19 minimum height of widget +; @return r19:r18 minimum width of widget ; @clobbers any, !Y -widgetGetMinSize: +widgetGetMinWidth: push yl push yh rcall Tree_GetFirstChildObject ; (none) - clr r20 - clr r21 -widgetGetMinSize_loop: + clr r24 + clr r25 +widgetGetMinWidth_loop: mov r17, xl or r17, xh - breq widgetGetMinSize_loopEnd + breq widgetGetMinWidth_loopEnd mov yl, xl mov yh, yl - push r20 - push r21 - ldi r16, WID_SIGNAL_GETMINSIZE + push r24 + push r25 + ldi r16, WID_SIGNAL_GETMINWIDTH ldi r18, 1 ; default value for when the signal is not handled - ldi r19, 1 ; default value for when the signal is not handled + ldi r19, 0 ; default value for when the signal is not handled rcall OBJ_Handler ; ask child for its minimum size - pop r21 - pop r20 - add r20, r18 ; TODO: handle carry later - subi r20, -WID_WIDGET_INTER_BORDER - add r21, r19 ; TODO: handle carry later - subi r21, -WID_WIDGET_INTER_BORDER + pop r25 + pop r24 + add r24, r18 ; TODO: handle carry later + adc r25, r19 + adiw r25:r24, WID_WIDGET_INTER_BORDER rcall Tree_GetNextSibling ; (none) - rjmp widgetGetMinSize_loop -widgetGetMinSize_loopEnd: - mov r18, r20 - mov r19, r21 + rjmp widgetGetMinWidth_loop +widgetGetMinWidth_loopEnd: + mov r18, r24 + mov r19, r25 + pop yh + pop yl + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine widgetGetMinHeight +; +; @return r19:r18 minimum width of widget +; @clobbers any, !Y + +widgetGetMinHeight: + push yl + push yh + rcall Tree_GetFirstChildObject ; (none) + clr r24 + clr r25 +widgetGetMinHeight_loop: + mov r17, xl + or r17, xh + breq widgetGetMinHeight_loopEnd + mov yl, xl + mov yh, yl + push r24 + push r25 + ldi r16, WID_SIGNAL_GETMINHEIGHT + ldi r18, 1 ; default value for when the signal is not handled + ldi r19, 0 ; default value for when the signal is not handled + rcall OBJ_Handler ; ask child for its minimum size + pop r25 + pop r24 + add r24, r18 ; TODO: handle carry later + adc r25, r19 + adiw r25:r24, WID_WIDGET_INTER_BORDER + rcall Tree_GetNextSibling ; (none) + rjmp widgetGetMinHeight_loop +widgetGetMinHeight_loopEnd: + mov r18, r24 + mov r19, r25 pop yh pop yl ret From dbad237826144a346d76f14c8ece854cd8290372 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 2 Jun 2025 23:41:38 +0200 Subject: [PATCH 010/196] fixed a typo. --- avr/modules/lcd2/win/widget.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avr/modules/lcd2/win/widget.asm b/avr/modules/lcd2/win/widget.asm index 820feeb..3b3e297 100644 --- a/avr/modules/lcd2/win/widget.asm +++ b/avr/modules/lcd2/win/widget.asm @@ -160,7 +160,7 @@ widgetGetMinWidth_loopEnd: ; --------------------------------------------------------------------------- ; @routine widgetGetMinHeight ; -; @return r19:r18 minimum width of widget +; @return r19:r18 minimum height of widget ; @clobbers any, !Y widgetGetMinHeight: From ae1892f196b9525038e0996eeb7379984cbb659c Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Tue, 3 Jun 2025 00:00:14 +0200 Subject: [PATCH 011/196] share code. --- avr/modules/lcd2/win/widget.asm | 71 ++++++++++++++------------------- 1 file changed, 29 insertions(+), 42 deletions(-) diff --git a/avr/modules/lcd2/win/widget.asm b/avr/modules/lcd2/win/widget.asm index 3b3e297..40c2fef 100644 --- a/avr/modules/lcd2/win/widget.asm +++ b/avr/modules/lcd2/win/widget.asm @@ -123,36 +123,8 @@ WID_Widget_Handler_getMinHeight: ; @clobbers any, !Y widgetGetMinWidth: - push yl - push yh - rcall Tree_GetFirstChildObject ; (none) - clr r24 - clr r25 -widgetGetMinWidth_loop: - mov r17, xl - or r17, xh - breq widgetGetMinWidth_loopEnd - mov yl, xl - mov yh, yl - push r24 - push r25 - ldi r16, WID_SIGNAL_GETMINWIDTH - ldi r18, 1 ; default value for when the signal is not handled - ldi r19, 0 ; default value for when the signal is not handled - rcall OBJ_Handler ; ask child for its minimum size - pop r25 - pop r24 - add r24, r18 ; TODO: handle carry later - adc r25, r19 - adiw r25:r24, WID_WIDGET_INTER_BORDER - rcall Tree_GetNextSibling ; (none) - rjmp widgetGetMinWidth_loop -widgetGetMinWidth_loopEnd: - mov r18, r24 - mov r19, r25 - pop yh - pop yl - ret + ldi r16, WID_SIGNAL_GETMINWIDTH + rjmp widgetGetMinSize ; @end @@ -164,31 +136,46 @@ widgetGetMinWidth_loopEnd: ; @clobbers any, !Y widgetGetMinHeight: + ldi r16, WID_SIGNAL_GETMINHEIGHT + rjmp widgetGetMinSize +; @end + + + +; --------------------------------------------------------------------------- +; @routine widgetGetMinSize +; +; @param r16 signal to send (WID_SIGNAL_GETMINWIDTH, WID_SIGNAL_GETMINHEIGHT) +; @return r19:r18 minimum width or height of widget +; @clobbers any, !Y + +widgetGetMinSize: push yl push yh rcall Tree_GetFirstChildObject ; (none) clr r24 clr r25 -widgetGetMinHeight_loop: +widgetGetMinSize_loop: mov r17, xl or r17, xh - breq widgetGetMinHeight_loopEnd + breq widgetGetMinSize_loopEnd mov yl, xl mov yh, yl - push r24 - push r25 - ldi r16, WID_SIGNAL_GETMINHEIGHT - ldi r18, 1 ; default value for when the signal is not handled - ldi r19, 0 ; default value for when the signal is not handled - rcall OBJ_Handler ; ask child for its minimum size - pop r25 - pop r24 + push r16 + push r24 + push r25 + ldi r18, 1 ; default value for when the signal is not handled + ldi r19, 0 ; default value for when the signal is not handled + rcall OBJ_Handler ; ask child for its minimum size + pop r25 + pop r24 + pop r16 add r24, r18 ; TODO: handle carry later adc r25, r19 adiw r25:r24, WID_WIDGET_INTER_BORDER rcall Tree_GetNextSibling ; (none) - rjmp widgetGetMinHeight_loop -widgetGetMinHeight_loopEnd: + rjmp widgetGetMinSize_loop +widgetGetMinSize_loopEnd: mov r18, r24 mov r19, r25 pop yh From 12cfe2ff4b769d523a8e7598f334f78e107c8c44 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Wed, 4 Jun 2025 23:56:04 +0200 Subject: [PATCH 012/196] Fixed a bug. Need to make room for stack. --- avr/devices/c02/main/main.asm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/avr/devices/c02/main/main.asm b/avr/devices/c02/main/main.asm index ce136d1..b2ffe22 100644 --- a/avr/devices/c02/main/main.asm +++ b/avr/devices/c02/main/main.asm @@ -33,6 +33,8 @@ ; --------------------------------------------------------------------------- ; generic +.equ STACK_SIZE = 128 + .equ NET_BUFFERS_NUM = 8 .equ NET_BUFFERS_SIZE = 32 @@ -228,6 +230,7 @@ onEveryLoop: .include "modules/lcd2/font/font12x20.asm" ;.include "common/list_t.asm" .include "common/tree_t.asm" +.include "common/divide.asm" ; --------------------------------------------------------------------------- @@ -443,5 +446,5 @@ heapStart: .equ HEAP_START = heapStart -.equ HEAP_SIZE = SRAM_SIZE-HEAP_START +.equ HEAP_SIZE = (SRAM_SIZE-STACK_SIZE)-HEAP_START From 7349014bd6098420e6d7e721fe1d43ee04dad6c0 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Wed, 4 Jun 2025 23:56:29 +0200 Subject: [PATCH 013/196] Make coordinates 16 bit again. --- avr/modules/lcd2/win/defs.asm | 68 +++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 26 deletions(-) diff --git a/avr/modules/lcd2/win/defs.asm b/avr/modules/lcd2/win/defs.asm index 5ced1b3..c3c28e8 100644 --- a/avr/modules/lcd2/win/defs.asm +++ b/avr/modules/lcd2/win/defs.asm @@ -29,39 +29,55 @@ .equ WID_OFFS_WIDGET = OBJ_OFFS_SIZE .equ WID_OFFS_OPTIONS1 = WID_OFFS_WIDGET+0 .equ WID_OFFS_OPTIONS2 = WID_OFFS_WIDGET+1 -.equ WID_OFFS_ABS_X = WID_OFFS_WIDGET+2 -.equ WID_OFFS_ABS_Y = WID_OFFS_WIDGET+3 -.equ WID_OFFS_REL_X = WID_OFFS_WIDGET+4 -.equ WID_OFFS_REL_Y = WID_OFFS_WIDGET+5 -.equ WID_OFFS_WIDTH = WID_OFFS_WIDGET+6 -.equ WID_OFFS_HEIGHT = WID_OFFS_WIDGET+7 -.equ WID_OFFS_BG_COL_LO = WID_OFFS_WIDGET+8 -.equ WID_OFFS_BG_COL_HI = WID_OFFS_WIDGET+9 -.equ WID_OFFS_FG_COL_LO = WID_OFFS_WIDGET+10 -.equ WID_OFFS_FG_COL_HI = WID_OFFS_WIDGET+11 -.equ WID_OFFS_FONT_LO = WID_OFFS_WIDGET+12 -.equ WID_OFFS_FONT_HI = WID_OFFS_WIDGET+13 -.equ WID_OFFS_BORDER_TOP = WID_OFFS_WIDGET+14 -.equ WID_OFFS_BORDER_BOT = WID_OFFS_WIDGET+15 -.equ WID_OFFS_BORDER_LEFT = WID_OFFS_WIDGET+16 -.equ WID_OFFS_BORDER_RIGHT = WID_OFFS_WIDGET+17 +.equ WID_OFFS_ABS_X_LO = WID_OFFS_WIDGET+2 +.equ WID_OFFS_ABS_X_HI = WID_OFFS_WIDGET+3 +.equ WID_OFFS_ABS_Y_LO = WID_OFFS_WIDGET+4 +.equ WID_OFFS_ABS_Y_HI = WID_OFFS_WIDGET+5 +.equ WID_OFFS_REL_X_LO = WID_OFFS_WIDGET+6 +.equ WID_OFFS_REL_X_HI = WID_OFFS_WIDGET+7 +.equ WID_OFFS_REL_Y_LO = WID_OFFS_WIDGET+8 +.equ WID_OFFS_REL_Y_HI = WID_OFFS_WIDGET+9 +.equ WID_OFFS_WIDTH_LO = WID_OFFS_WIDGET+10 +.equ WID_OFFS_WIDTH_HI = WID_OFFS_WIDGET+11 +.equ WID_OFFS_HEIGHT_LO = WID_OFFS_WIDGET+12 +.equ WID_OFFS_HEIGHT_HI = WID_OFFS_WIDGET+13 +.equ WID_OFFS_BG_COL_LO = WID_OFFS_WIDGET+14 +.equ WID_OFFS_BG_COL_HI = WID_OFFS_WIDGET+15 +.equ WID_OFFS_FG_COL_LO = WID_OFFS_WIDGET+16 +.equ WID_OFFS_FG_COL_HI = WID_OFFS_WIDGET+17 +.equ WID_OFFS_FONT_LO = WID_OFFS_WIDGET+18 +.equ WID_OFFS_FONT_HI = WID_OFFS_WIDGET+19 +.equ WID_OFFS_BORDER_TOP = WID_OFFS_WIDGET+20 +.equ WID_OFFS_BORDER_BOT = WID_OFFS_WIDGET+21 +.equ WID_OFFS_BORDER_LEFT = WID_OFFS_WIDGET+22 +.equ WID_OFFS_BORDER_RIGHT = WID_OFFS_WIDGET+23 -.equ WID_SIZE = WID_OFFS_WIDGET+18 +.equ WID_SIZE = WID_OFFS_WIDGET+24 -.equ WID_OPTIONS0_BIT_VISIBLE = 0 ; OBJ_OFFS_OPTIONS -.equ WID_OPTIONS0_BIT_DIRTY = 1 -.equ WID_OPTIONS0_BIT_LAYOUT = 2 +.equ WID_OPTIONS0_BIT_VISIBLE = 0 ; OBJ_OFFS_OPTIONS +.equ WID_OPTIONS0_BIT_DIRTY = 1 +.equ WID_OPTIONS0_BIT_LAYOUT = 2 -.equ WID_OPTIONS1_BIT_STRETCH_X = 0 ; WID_OFFS_OPTIONS1 -.equ WID_OPTIONS1_BIT_STRETCH_Y = 1 +.equ WID_OPTIONS1_BIT_STRETCH_X = 0 ; WID_OFFS_OPTIONS1 +.equ WID_OPTIONS1_BIT_STRETCH_Y = 1 -.equ WID_OPTIONS1_BIT_ALIGN_RIGHT = 2 -.equ WID_OPTIONS1_BIT_ALIGN_BOTTOM = 3 +.equ WID_OPTIONS1_BIT_HALIGN0 = 2 ; 00: left, 01: right, 11: center +.equ WID_OPTIONS1_BIT_HALIGN1 = 3 -.equ WID_OPTIONS1_BIT_EQUAL_WIDTH = 4 -.equ WID_OPTIONS1_BIT_EQUAL_HEIGHT = 5 +.equ WID_OPTIONS1_BIT_VALIGN0 = 4 ; 00: top, 01: bottom, 11: center +.equ WID_OPTIONS1_BIT_VALIGN1 = 5 + +.equ WID_OPTIONS1_BIT_ALIGN_HCENTER = 4 +.equ WID_OPTIONS1_BIT_ALIGN_VCENTER = 5 + +.equ WID_OPTIONS1_BIT_FIXED_WIDTH = 6 +.equ WID_OPTIONS1_BIT_FIXED_HEIGHT = 7 + + +.equ WID_OPTIONS2_BIT_EQUAL_WIDTH = 0 +.equ WID_OPTIONS2_BIT_EQUAL_HEIGHT = 1 ; Signals From 08a1313ba590ba15d21fde763d7782fdac5db4dd Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Wed, 4 Jun 2025 23:56:42 +0200 Subject: [PATCH 014/196] More work on layout code. --- avr/modules/lcd2/win/widget.asm | 560 +++++++++++++++++++++++++++++--- 1 file changed, 520 insertions(+), 40 deletions(-) diff --git a/avr/modules/lcd2/win/widget.asm b/avr/modules/lcd2/win/widget.asm index 40c2fef..aee4957 100644 --- a/avr/modules/lcd2/win/widget.asm +++ b/avr/modules/lcd2/win/widget.asm @@ -103,6 +103,8 @@ WID_Widget_Handler: breq WID_Widget_Handler_getMinWidth cpi r16, WID_SIGNAL_GETMINHEIGHT breq WID_Widget_Handler_getMinHeight + cpi r16, WID_SIGNAL_LAYOUT + breq WID_Widget_Handler_layout ; for now just forward signal to all children WID_Widget_Handler_forward: rcall OBJ_ForwardSignalToChildren @@ -111,71 +113,182 @@ WID_Widget_Handler_getMinWidth: rjmp widgetGetMinWidth WID_Widget_Handler_getMinHeight: rjmp widgetGetMinHeight +WID_Widget_Handler_layout: + rjmp widgetLayout ; @end +widgetLayout: + rcall wSetChildrenWidthsFromMinWidths + rcall wSetChildrenHeightsFromMinHeights -; --------------------------------------------------------------------------- -; @routine widgetGetMinWidth -; -; @return r19:r18 minimum width of widget -; @clobbers any, !Y + ; count number of expandable children + ldi r16, WID_OPTIONS1_BIT_STRETCH_Y + ldi r17, WID_OPTIONS1_BIT_STRETCH_Y + rcall widgetCountVisibleChildrenWithOptions1 ; (r18, r24, r25, X) + tst r18 + breq widgetLayout_Ydone ; no expandable children, nothing to distribute + ; determine full height needed by all children + push r18 ; number of visible expandable child widgets + clr r17 ; mask=0 -> count all visible children + rcall wGetSumOfMatchingVisibleChildrenHeights ; r19:r18=sum of all children heights + pop r22 + clr r23 ; r23:r22=number of visible expandable children + ; calculate number of bytes to add to each expandable child widget + ldd r20, Y+WID_OFFS_HEIGHT_LO ; total height + ldd r21, Y+WID_OFFS_HEIGHT_HI + clr r16 + ldd r17, Y+WID_OFFS_BORDER_TOP ; subtract top border + sub r20, r17 + sbc r21, r16 + brcs widgetLayout_heightTooSmall ; jmp if too small + ldd r17, Y+WID_OFFS_BORDER_BOT ; subtract bottom border + sub r20, r17 + sbc r21, r16 + brcs widgetLayout_heightTooSmall ; jmp if too small + + sub r20, r18 ; r21:r20 = HEIGHT-SUM_OF_VIS_CHILDREN_HEIGHTS + sbc r21, r19 + brcc widgetLayout_heightTooSmall + breq widgetLayout_yDone ; nothing to distribute + bigcall Utils_Divu16_16_16 ; r17:r16 = r21:r20 / r23:r22 + ; add additional pixel to heights of expandable child widgets + rcall wAddToHeightsOfExpandableVisibleChildren -widgetGetMinWidth: - ldi r16, WID_SIGNAL_GETMINWIDTH - rjmp widgetGetMinSize +widgetLayout_yDone: + rcall wSetRelYFromHeightInVisibleChildren + rcall wAlignChildrenHorizontally +widgetLayout_heightTooSmall: + ; TODO: how to handle this case? + ret ; @end ; --------------------------------------------------------------------------- -; @routine widgetGetMinHeight +; @routine wAlignChildrenHorizontally ; -; @return r19:r18 minimum height of widget -; @clobbers any, !Y - -widgetGetMinHeight: - ldi r16, WID_SIGNAL_GETMINHEIGHT - rjmp widgetGetMinSize -; @end - - - -; --------------------------------------------------------------------------- -; @routine widgetGetMinSize +; Horizontally align children within the width of the parent widget. +; Only changes Y+WID_OFFS_REL_X_LO/HI. ; -; @param r16 signal to send (WID_SIGNAL_GETMINWIDTH, WID_SIGNAL_GETMINHEIGHT) -; @return r19:r18 minimum width or height of widget -; @clobbers any, !Y +; @param Y pointer to object SRAM +; @clobbers r16, r17, r18, r19, r24, r25 -widgetGetMinSize: +wAlignChildrenHorizontally: push yl push yh + ldd r24, Y+WID_OFFS_WIDTH_LO ; parent width + ldd r25, Y+WID_OFFS_WIDTH_HI + ldd r19, Y+WID_OFFS_BORDER_LEFT ; subtract left border + mov r16, r19 + clr r17 + sub r24, r16 + sbc r25, r17 + ldd r16, Y+WID_OFFS_BORDER_RIGHT ; subtract right border + sub r24, r16 + sbc r25, r17 ; r25:r24=parent width minus lateral borders, r19=left border rcall Tree_GetFirstChildObject ; (none) - clr r24 - clr r25 -widgetGetMinSize_loop: +wAlignChildrenHorizontally_loop: mov r17, xl or r17, xh - breq widgetGetMinSize_loopEnd + breq wAlignChildrenHorizontally_loopEnd mov yl, xl mov yh, yl - push r16 - push r24 - push r25 - ldi r18, 1 ; default value for when the signal is not handled - ldi r19, 0 ; default value for when the signal is not handled - rcall OBJ_Handler ; ask child for its minimum size - pop r25 - pop r24 - pop r16 + ldd r18, Y+OBJ_OFFS_OPTIONS + andi r18, WID_OPTIONS0_BIT_VISIBLE + breq wAlignChildrenHorizontally_loopNext + push r24 + push r25 + push r19 + rcall wAlignHorizontally + pop r19 + add r24, r19 + adc r25, r19 + sub r25, r19 + std Y+WID_OFFS_REL_X_LO, r24 + std Y+WID_OFFS_REL_X_HI, r25 + pop r25 + pop r24 +wAlignChildrenHorizontally_loopNext: + rcall Tree_GetNextSibling ; (none) + rjmp wAlignChildrenHorizontally_loop +wAlignChildrenHorizontally_loopEnd: + pop yh + pop yl + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine wAlignHorizontally +; +; @param r25:r24 parent width minus lateral borders +; @return r25:r24 proposed X position relative to parent +; @clobbers r16, r17 + +wAlignHorizontally: + ldd r16, Y+WID_OFFS_OPTIONS1 + andi r16, (WID_OPTIONS1_BIT_HALIGN0 | WID_OPTIONS1_BIT_HALIGN1) + cpi r16, (0< Date: Thu, 5 Jun 2025 22:44:27 +0200 Subject: [PATCH 015/196] re-enabled CCS811 module, adapted to latest changes. --- avr/devices/all/includes.asm | 3 + avr/devices/all/main.asm | 4 ++ avr/modules/ccs811/main.asm | 124 ++++++++++------------------------- avr/modules/ccs811/send.asm | 44 +++++++++++++ 4 files changed, 87 insertions(+), 88 deletions(-) create mode 100644 avr/modules/ccs811/send.asm diff --git a/avr/devices/all/includes.asm b/avr/devices/all/includes.asm index d603918..3dc46d6 100644 --- a/avr/devices/all/includes.asm +++ b/avr/devices/all/includes.asm @@ -144,6 +144,9 @@ #ifdef MODULES_CCS811 .include "modules/ccs811/main.asm" + #ifdef MODULES_NETWORK + .include "modules/ccs811/send.asm" + #endif #endif #ifdef MODULES_TCRT1000 diff --git a/avr/devices/all/main.asm b/avr/devices/all/main.asm index 6faf1a1..73c98fb 100644 --- a/avr/devices/all/main.asm +++ b/avr/devices/all/main.asm @@ -154,6 +154,10 @@ sysOnEveryMinute: bigcall AppStats_OnEveryMinute #endif +#ifdef MODULES_CCS811 + bigcall CCS811_OnEveryMinute +#endif + bigjmp onEveryMinute ; @end diff --git a/avr/modules/ccs811/main.asm b/avr/modules/ccs811/main.asm index afe5870..d2357d6 100644 --- a/avr/modules/ccs811/main.asm +++ b/avr/modules/ccs811/main.asm @@ -16,6 +16,8 @@ .equ CCS811_FLAGS_RESETTED = 0x40 .equ CCS811_FLAGS_VALIDDATA = 0x20 +.equ CCS811_VALUE_TVOC = 0x01 +.equ CCS811_VALUE_CO2 = 0x02 .equ CCS811_WAITMS_AFTER_RESET = 50 .equ CCS811_WAITMS_AFTER_START = 50 @@ -38,7 +40,6 @@ .equ CCS811_MEASUREMODE = (0< Date: Thu, 5 Jun 2025 22:45:25 +0200 Subject: [PATCH 016/196] re-enabled node n19. adapted n20. --- avr/devices/0BUILD | 1 + avr/devices/n19/0BUILD | 41 +-- avr/devices/n19/boot/0BUILD | 32 +++ avr/devices/n19/{ => boot}/boot.asm | 10 +- avr/devices/n19/defs.asm | 1 + avr/devices/n19/main.asm | 379 ---------------------------- avr/devices/n19/main/0BUILD | 33 +++ avr/devices/n19/main/main.asm | 176 +++++++++++++ avr/devices/n20/0BUILD | 40 +-- avr/devices/n20/boot/0BUILD | 32 +++ avr/devices/n20/{ => boot}/boot.asm | 2 +- avr/devices/n20/main/0BUILD | 33 +++ avr/devices/n20/{ => main}/main.asm | 4 +- 13 files changed, 320 insertions(+), 464 deletions(-) create mode 100644 avr/devices/n19/boot/0BUILD rename avr/devices/n19/{ => boot}/boot.asm (96%) delete mode 100644 avr/devices/n19/main.asm create mode 100644 avr/devices/n19/main/0BUILD create mode 100644 avr/devices/n19/main/main.asm create mode 100644 avr/devices/n20/boot/0BUILD rename avr/devices/n20/{ => boot}/boot.asm (99%) create mode 100644 avr/devices/n20/main/0BUILD rename avr/devices/n20/{ => main}/main.asm (99%) diff --git a/avr/devices/0BUILD b/avr/devices/0BUILD index c8e68b1..1b89129 100644 --- a/avr/devices/0BUILD +++ b/avr/devices/0BUILD @@ -27,6 +27,7 @@ c01 c02 n16 + n19 n20 n21 n22 diff --git a/avr/devices/n19/0BUILD b/avr/devices/n19/0BUILD index 6329fc6..be449f6 100644 --- a/avr/devices/n19/0BUILD +++ b/avr/devices/n19/0BUILD @@ -2,51 +2,16 @@ - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - main.asm - - - - - - - - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - boot.asm - - - - - - + boot + main defs.asm + README - diff --git a/avr/devices/n19/boot/0BUILD b/avr/devices/n19/boot/0BUILD new file mode 100644 index 0000000..c0e7053 --- /dev/null +++ b/avr/devices/n19/boot/0BUILD @@ -0,0 +1,32 @@ + + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + boot.asm + + + + + + + + + + + + + + + + diff --git a/avr/devices/n19/boot.asm b/avr/devices/n19/boot/boot.asm similarity index 96% rename from avr/devices/n19/boot.asm rename to avr/devices/n19/boot/boot.asm index d201486..eb13227 100644 --- a/avr/devices/n19/boot.asm +++ b/avr/devices/n19/boot/boot.asm @@ -14,8 +14,10 @@ .include "include/tn85def.inc" ; Define device ATtiny85 .list -.include "./defs.asm" -.include "defs_all.asm" +.include "../defs.asm" +.include "devices/all/defs.asm" +.include "common/calls.asm" +.include "common/utils_wait.asm" @@ -25,10 +27,6 @@ ; --------------------------------------------------------------------------- ; generic -.include "common/utils_wait.asm" -.include "modules/com2/defs.asm" -.include "modules/comproto/defs.asm" - ; --------------------------------------------------------------------------- ; firmware settings diff --git a/avr/devices/n19/defs.asm b/avr/devices/n19/defs.asm index 4249624..f40698e 100644 --- a/avr/devices/n19/defs.asm +++ b/avr/devices/n19/defs.asm @@ -40,6 +40,7 @@ .equ LED_SIMPLE_OFFTIME = 50 .equ LED_SIMPLE_DDR = DDRB .equ LED_SIMPLE_PORT = PORTB +.equ LED_SIMPLE_PORTIN = PINB .equ LED_SIMPLE_PINNUM = PORTB3 diff --git a/avr/devices/n19/main.asm b/avr/devices/n19/main.asm deleted file mode 100644 index e544eb4..0000000 --- a/avr/devices/n19/main.asm +++ /dev/null @@ -1,379 +0,0 @@ -; *************************************************************************** -; 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=1000000 ; Define the clock frequency - - - -.nolist -.include "include/tn85def.inc" ; Define device ATtiny85 -.list - -.include "./defs.asm" -.include "defs_all.asm" -.include "common/utils_wait.asm" ; wait macro - - - -; *************************************************************************** -; defines - -; --------------------------------------------------------------------------- -; firmware settings including list of modules used - -.equ FIRMWARE_VERSION_MAJOR = 0 -.equ FIRMWARE_VERSION_MINOR = 0 -.equ FIRMWARE_VERSION_PATCHLEVEL = 1 - - -#define MODULES_TIMER -#define MODULES_COM -#define MODULES_COM_WITH_ADDR_PROTO -#define MODULES_LED_SIMPLE -#define MODULES_TWI_MASTER -#define MODULES_SI7021 -#define MODULES_STATS -; #define MODULES_OWI_MASTER -; #define MODULES_DS18B20 -; #define MODULES_SK6812 -; #define MODULES_MOTION_LIGHT - -; #define COM_ACCEPT_ALL_DEST -#define MODULES_CCS811 - - - -; --------------------------------------------------------------------------- -; defines for modules - -.equ VALUE_ID_SI7021_TEMP = 0x01 -.equ VALUE_ID_SI7021_HUM = 0x02 - -.equ VALUE_ID_CO2 = 0x07 -.equ VALUE_ID_TVOC = 0x08 - -.equ VALUE_ID_DEBUG = 0x7f - - -; *************************************************************************** -; code segment - -.cseg -.org 000000 - - - -; --------------------------------------------------------------------------- -; Reset and interrupt vectors - - rjmp BOOTLOADER_ADDR ; Reset vector ; use this for flashed system - reti ; EXT_INT0 - rjmp uartBitbangIsrPcint0 ; 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_MAIN, FIRMWARE_VERSION_MAJOR - .db FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCHLEVEL - -firmwareStart: rjmp main - - -; *************************************************************************** -; includes - -.include "common/utils.asm" -.include "common/utils_wait_fixed.asm" -.include "common/utils_copy_from_flash.asm" -.include "common/utils_copy_sdram.asm" -.include "common/crc8.asm" - -.include "modules/basetimer/main.asm" - -#ifdef MODULES_TIMER - .include "modules/timer/main.asm" -#endif -#ifdef MODULES_LED_SIMPLE -.include "modules/led_simple/main.asm" -#endif -#ifdef MODULES_COM - .include "modules/com2/defs.asm" - .include "modules/com2/main.asm" - .include "modules/com2/buffer.asm" - #ifdef MODULES_STATS - .include "modules/comproto/msg_recvstats.asm" - .include "modules/comproto/msg_sendstats.asm" - .include "modules/comproto/msg_sysstats.asm" - .include "modules/comproto/msg_memstats.asm" - #endif - .include "modules/comproto/msg_pong.asm" - .include "modules/comproto/msg_value.asm" - .include "modules/comproto/msg_device.asm" - .include "modules/comproto/msg_reboot.asm" - .include "modules/uart_bitbang/defs.asm" - .include "modules/uart_bitbang/main.asm" - .include "modules/uart_bitbang/bytelevel.asm" - .include "modules/uart_bitbang/packetlevel.asm" - #ifdef MODULES_COM_WITH_ADDR_PROTO - .include "modules/comproto/defs.asm" - .include "modules/comproto/main.asm" - .include "modules/comproto/addr.asm" - #endif -#endif -#ifdef MODULES_STATS - .include "modules/stats/main.asm" -#endif -#ifdef MODULES_TWI_MASTER - .include "modules/twimaster/main.asm" -#endif -#ifdef MODULES_OWI_MASTER - .include "modules/owimaster/main.asm" -#endif -#ifdef MODULES_SI7021 - .include "modules/si7021/main.asm" -#endif -#ifdef MODULES_DS18B20 - .include "modules/ds18b20/main.asm" -#endif -#ifdef MODULES_SK6812 - .include "modules/sk6812/main.asm" -#endif -#ifdef MODULES_MOTION_LIGHT - .include "modules/ma_light/main.asm" -#endif - -#ifdef MODULES_CCS811 - .include "modules/ccs811/main.asm" -#endif - - -; *************************************************************************** -; data in SRAM - -.dseg - - -#ifdef MODULES_SI7021 - sramTimerSI7021Measure: .byte 2 - sramTimerSI7021SendTemp: .byte 2 - sramTimerSI7021SendHumidity: .byte 2 -#endif -#ifdef MODULES_DS18B20 - sramDs18b20Timer: .byte 2 - sramSendDs18b20TempTimer: .byte 2 -#endif - -#ifdef MODULES_CCS811 - sramCcs811Timer: .byte 2 -#endif - - -; *************************************************************************** -; data in FLASH - -.cseg - - - -; --------------------------------------------------------------------------- -; timer list - - -timerList: -; SRAM variable/counter routine flags secs (0=don't start or restart) -#ifdef MODULES_COM_WITH_ADDR_PROTO - .dw cproAddresModeTimer, CPRO_Address_OnTimer, 0, 0 ; (no restart) -#endif -#ifdef MODULES_STATS - .dw statsSendTimer, Stats_Timer, TIMER_FLAGS_IF_ADDR, 9000 ; every 15m -#endif -#ifdef MODULES_DS18B20 - .dw sramDs18b20Timer, Ds18b20_OnTimer, 0, 300 ; every 30s - .dw sramSendDs18b20TempTimer, sendDs18b20Temp, TIMER_FLAGS_IF_ADDR, 600 ; every 60s -#endif -#ifdef MODULES_SI7021 - .dw sramTimerSI7021Measure, SI7021_OnTimer, 0, 300 ; every 30s - .dw sramTimerSI7021SendTemp, sendSI7021Temp, TIMER_FLAGS_IF_ADDR, 600 ; every 60s - .dw sramTimerSI7021SendHumidity, sendSI7021Humidity, TIMER_FLAGS_IF_ADDR, 600 ; every 60s -#endif -#ifdef MODULES_CCS811 - .dw sramCcs811Timer, CCS811_OnTimer, 0, 10 ; every 1s -#endif - .dw 0 ; end of list - - - - - -.include "main_all.asm" - - -; --------------------------------------------------------------------------- -; Called early on system startup. No arguments, no results. - -systemSetSpeed: -.if clock == 1000000 - ldi r16, (1< + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + main.asm + + + + + + + + + + + + + + + + + diff --git a/avr/devices/n19/main/main.asm b/avr/devices/n19/main/main.asm new file mode 100644 index 0000000..aed7831 --- /dev/null +++ b/avr/devices/n19/main/main.asm @@ -0,0 +1,176 @@ +; *************************************************************************** +; 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 85 +; +; This is for the full system (i.e. not the boot loader). +; *************************************************************************** + +.equ clock=1000000 ; Define the clock frequency + + + +.nolist +.include "include/tn85def.inc" ; Define device ATtiny85 +.list + +.include "../defs.asm" +.include "devices/all/defs.asm" +.include "common/calls.asm" +.include "common/utils_wait.asm" ; wait macro + + + +; *************************************************************************** +; defines + + +.equ NET_BUFFERS_NUM = 6 +.equ NET_BUFFERS_SIZE = 32 + + +; --------------------------------------------------------------------------- +; firmware settings including list of modules used + +.equ FIRMWARE_VERSION_MAJOR = 0 +.equ FIRMWARE_VERSION_MINOR = 0 +.equ FIRMWARE_VERSION_PATCHLEVEL = 1 + +#define MODULES_CLOCK +#define MODULES_LED_SIMPLE +#define MODULES_NETWORK +#define MODULES_UART_BITBANG +#define MODULES_TWI_MASTER +#define MODULES_SI7021 +#define MODULES_CCS811 + +#define APPS_NETWORK +#define APPS_REPORTSENSORS +#define APPS_STATS + + + +; --------------------------------------------------------------------------- +; defines for modules + +.equ VALUE_ID_SI7021_TEMP = 0x01 +.equ VALUE_ID_SI7021_HUM = 0x02 + +.equ VALUE_ID_CO2 = 0x07 +.equ VALUE_ID_TVOC = 0x08 + +.equ VALUE_ID_DEBUG = 0x7f + +.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 UART_BitBang_PcintIsr ; 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_MAIN, FIRMWARE_VERSION_MAJOR + .db FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCHLEVEL + +firmwareStart: + rjmp main + + + +; --------------------------------------------------------------------------- +; @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_tn85.asm" +.include "devices/all/includes.asm" + + + +; --------------------------------------------------------------------------- +; defines for network interface + +.equ netInterfaceData = uart_bitbang_iface + + + diff --git a/avr/devices/n20/0BUILD b/avr/devices/n20/0BUILD index 23f5a51..be449f6 100644 --- a/avr/devices/n20/0BUILD +++ b/avr/devices/n20/0BUILD @@ -2,44 +2,9 @@ - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - main.asm - - - - - - - - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - boot.asm - - - - - - + boot + main @@ -50,4 +15,3 @@ - diff --git a/avr/devices/n20/boot/0BUILD b/avr/devices/n20/boot/0BUILD new file mode 100644 index 0000000..dec3837 --- /dev/null +++ b/avr/devices/n20/boot/0BUILD @@ -0,0 +1,32 @@ + + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + boot.asm + + + + + + + + + + + + + + + + diff --git a/avr/devices/n20/boot.asm b/avr/devices/n20/boot/boot.asm similarity index 99% rename from avr/devices/n20/boot.asm rename to avr/devices/n20/boot/boot.asm index 919d3d2..df58b6f 100644 --- a/avr/devices/n20/boot.asm +++ b/avr/devices/n20/boot/boot.asm @@ -13,7 +13,7 @@ .list .include "version.asm" -.include "./defs.asm" +.include "../defs.asm" .include "devices/all/defs.asm" .include "common/calls.asm" diff --git a/avr/devices/n20/main/0BUILD b/avr/devices/n20/main/0BUILD new file mode 100644 index 0000000..8450a6c --- /dev/null +++ b/avr/devices/n20/main/0BUILD @@ -0,0 +1,33 @@ + + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + main.asm + + + + + + + + + + + + + + + + + diff --git a/avr/devices/n20/main.asm b/avr/devices/n20/main/main.asm similarity index 99% rename from avr/devices/n20/main.asm rename to avr/devices/n20/main/main.asm index 1f720e8..eb7c165 100644 --- a/avr/devices/n20/main.asm +++ b/avr/devices/n20/main/main.asm @@ -31,7 +31,7 @@ .list .include "version.asm" -.include "./defs.asm" +.include "../defs.asm" .include "devices/all/defs.asm" .include "common/calls.asm" @@ -67,7 +67,7 @@ ;#define MODULES_DS18B20 ;#define MODULES_MOTION ;#define MODULES_TCRT1000 -;#define MODULES_CCS811 +#define MODULES_CCS811 #define APPS_NETWORK ;#define APPS_MOTION From b9ac7c65fa19af279ac0981a9793b553db6c59cb Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Thu, 5 Jun 2025 22:46:55 +0200 Subject: [PATCH 017/196] include CCS811 in reportsensors app. --- avr/apps/reportsensors/main.asm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/avr/apps/reportsensors/main.asm b/avr/apps/reportsensors/main.asm index 6f4751e..a01bac5 100644 --- a/avr/apps/reportsensors/main.asm +++ b/avr/apps/reportsensors/main.asm @@ -107,6 +107,13 @@ AppReportSensors_OnEverySecond_store: breq AppReportSensors_OnEverySecond_sendValue3 #endif +#ifdef MODULES_CCS811 + cpi r16, 31 + breq AppReportSensors_OnEverySecond_sendCCS811_TVOC + cpi r16, 35 + breq AppReportSensors_OnEverySecond_sendCCS811_CO2 +#endif + ret #ifdef MODULES_SI7021 @@ -142,6 +149,13 @@ AppReportSensors_OnEverySecond_sendValue3: rjmp SGP30_SendCO2 #endif +#ifdef MODULES_CCS811 +AppReportSensors_OnEverySecond_sendCCS811_TVOC: + rjmp CCS811_SendTVOC +AppReportSensors_OnEverySecond_sendCCS811_CO2: + rjmp CCS811_SendCO2 +#endif + ; @end From 4f30623f2d731af05e9cb722a86054fc9835a511 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Thu, 5 Jun 2025 22:47:54 +0200 Subject: [PATCH 018/196] increased stacksize. --- avr/devices/c02/main/main.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avr/devices/c02/main/main.asm b/avr/devices/c02/main/main.asm index b2ffe22..dd1c8fc 100644 --- a/avr/devices/c02/main/main.asm +++ b/avr/devices/c02/main/main.asm @@ -33,7 +33,7 @@ ; --------------------------------------------------------------------------- ; generic -.equ STACK_SIZE = 128 +.equ STACK_SIZE = 256 .equ NET_BUFFERS_NUM = 8 .equ NET_BUFFERS_SIZE = 32 From 2cb534df85a15c0c9bdc32bf905bb128147ffe6d Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Thu, 5 Jun 2025 22:48:22 +0200 Subject: [PATCH 019/196] more work on GUI module. --- avr/modules/lcd2/win/widget.asm | 113 ++++++++++++++++++++++++++++++-- 1 file changed, 106 insertions(+), 7 deletions(-) diff --git a/avr/modules/lcd2/win/widget.asm b/avr/modules/lcd2/win/widget.asm index aee4957..d9d083b 100644 --- a/avr/modules/lcd2/win/widget.asm +++ b/avr/modules/lcd2/win/widget.asm @@ -105,6 +105,8 @@ WID_Widget_Handler: breq WID_Widget_Handler_getMinHeight cpi r16, WID_SIGNAL_LAYOUT breq WID_Widget_Handler_layout + cpi r16, WID_SIGNAL_DRAW + breq WID_Widget_Handler_draw ; for now just forward signal to all children WID_Widget_Handler_forward: rcall OBJ_ForwardSignalToChildren @@ -115,11 +117,45 @@ WID_Widget_Handler_getMinHeight: rjmp widgetGetMinHeight WID_Widget_Handler_layout: rjmp widgetLayout +WID_Widget_Handler_draw: + rjmp wDraw ; @end + +wDraw: + ldd r16, Y+OBJ_OFFS_OPTIONS + sbrs r16, WID_OPTIONS0_BIT_VISIBLE ; only draw visible widgets + rjmp wDraw_ret + cbr r16, (1< count all visible children @@ -142,30 +178,90 @@ widgetLayout: ldd r17, Y+WID_OFFS_BORDER_TOP ; subtract top border sub r20, r17 sbc r21, r16 - brcs widgetLayout_heightTooSmall ; jmp if too small + brcs wVLayout_heightTooSmall ; jmp if too small ldd r17, Y+WID_OFFS_BORDER_BOT ; subtract bottom border sub r20, r17 sbc r21, r16 - brcs widgetLayout_heightTooSmall ; jmp if too small + brcs wVLayout_heightTooSmall ; jmp if too small sub r20, r18 ; r21:r20 = HEIGHT-SUM_OF_VIS_CHILDREN_HEIGHTS sbc r21, r19 - brcc widgetLayout_heightTooSmall - breq widgetLayout_yDone ; nothing to distribute + brcc wVLayout_heightTooSmall + breq wVLayout_yDone ; nothing to distribute bigcall Utils_Divu16_16_16 ; r17:r16 = r21:r20 / r23:r22 ; add additional pixel to heights of expandable child widgets rcall wAddToHeightsOfExpandableVisibleChildren -widgetLayout_yDone: +wVLayout_yDone: rcall wSetRelYFromHeightInVisibleChildren rcall wAlignChildrenHorizontally -widgetLayout_heightTooSmall: +; rcall wSetAbsoluteCoords call in GUI loop after calling layout on all widgets +wVLayout_heightTooSmall: ; TODO: how to handle this case? ret ; @end +wSetAbsoluteCoords: + push yl + push yh +wSetAbsoluteCoords_loop: + ldd r18, Y+OBJ_OFFS_OPTIONS + andi r18, WID_OPTIONS0_BIT_VISIBLE + breq wSetAbsoluteCoords_nextSibling + push yl + push yh + bigcall Tree_GetParentObject + clr r18 + clr r19 + clr r20 + clr r21 + mov r17, xl + or r17, xh + breq wSetAbsoluteCoords_r1820set + mov yl, xl + mov yh, xh + ldd r18, Y+WID_OFFS_ABS_X_LO + ldd r19, Y+WID_OFFS_ABS_X_HI + ldd r20, Y+WID_OFFS_ABS_Y_LO + ldd r21, Y+WID_OFFS_ABS_Y_HI +wSetAbsoluteCoords_r1820set: + pop yh + pop yl + ; handle X + ldd r16, Y+WID_OFFS_REL_X_LO + ldd r17, Y+WID_OFFS_REL_X_HI + add r16, r18 + adc r17, r19 + std Y+WID_OFFS_ABS_X_LO, r16 + std Y+WID_OFFS_ABS_X_HI, r17 + ; handle Y + ldd r16, Y+WID_OFFS_REL_Y_LO + ldd r17, Y+WID_OFFS_REL_Y_HI + add r16, r20 + adc r17, r21 + std Y+WID_OFFS_ABS_Y_LO, r16 + std Y+WID_OFFS_ABS_Y_HI, r17 + bigcall Tree_GetObjectBelow + rjmp wSetAbsoluteCoords_loopEnd +wSetAbsoluteCoords_nextSibling: + bigcall Tree_GetNextSibling +wSetAbsoluteCoords_loopEnd: + mov r17, xl + or r17, xh + breq wSetAbsoluteCoords_end + mov yl, xl + mov yh, xh + rjmp wSetAbsoluteCoords_loop +wSetAbsoluteCoords_end: + pop yh + pop yl + ret +; @end + + + ; --------------------------------------------------------------------------- ; @routine wAlignChildrenHorizontally ; @@ -230,6 +326,8 @@ wAlignChildrenHorizontally_loopEnd: wAlignHorizontally: ldd r16, Y+WID_OFFS_OPTIONS1 + sbrc r16, WID_OPTIONS1_BIT_STRETCH_X + rjmp wAlignHorizontally_stretch andi r16, (WID_OPTIONS1_BIT_HALIGN0 | WID_OPTIONS1_BIT_HALIGN1) cpi r16, (0< Date: Thu, 12 Jun 2025 23:30:08 +0200 Subject: [PATCH 020/196] more work on aqhome-cgi. --- 0BUILD | 2 + apps/aqhome-cgi/0BUILD | 5 +- apps/aqhome-cgi/README | 14 + apps/aqhome-cgi/main.c | 156 ++++++++++ apps/aqhome-cgi/modules/0BUILD | 84 ++++++ apps/aqhome-cgi/modules/mroot.c | 109 +++++++ apps/aqhome-cgi/modules/mroot.h | 27 ++ apps/aqhome-cgi/modules/mroot_p.h | 18 ++ apps/aqhome-cgi/modules/mservice.c | 284 ++++++++++++++++++ apps/aqhome-cgi/modules/mservice.h | 46 +++ apps/aqhome-cgi/modules/mservice_p.h | 27 ++ apps/aqhome-cgi/modules/static/0BUILD | 7 + apps/aqhome-cgi/modules/static/en/0BUILD | 13 + apps/aqhome-cgi/modules/static/en/footer.html | 4 + apps/aqhome-cgi/modules/static/en/header.html | 17 ++ apps/aqhome-cgi/modules/static/en/login.html | 25 ++ apps/aqhome-cgi/service_file.h | 1 + aqhome-cgi.sh | 14 + 18 files changed, 852 insertions(+), 1 deletion(-) create mode 100644 apps/aqhome-cgi/README create mode 100644 apps/aqhome-cgi/modules/0BUILD create mode 100644 apps/aqhome-cgi/modules/mroot.c create mode 100644 apps/aqhome-cgi/modules/mroot.h create mode 100644 apps/aqhome-cgi/modules/mroot_p.h create mode 100644 apps/aqhome-cgi/modules/mservice.c create mode 100644 apps/aqhome-cgi/modules/mservice.h create mode 100644 apps/aqhome-cgi/modules/mservice_p.h create mode 100644 apps/aqhome-cgi/modules/static/0BUILD create mode 100644 apps/aqhome-cgi/modules/static/en/0BUILD create mode 100644 apps/aqhome-cgi/modules/static/en/footer.html create mode 100644 apps/aqhome-cgi/modules/static/en/header.html create mode 100644 apps/aqhome-cgi/modules/static/en/login.html create mode 100644 aqhome-cgi.sh diff --git a/0BUILD b/0BUILD index c6780a5..2e817b5 100644 --- a/0BUILD +++ b/0BUILD @@ -51,6 +51,8 @@ $(includedir)/aqhome/$(package) $(datadir)/$(package) + /var/www + + 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" From 06886e009469374565705f9f64162de26592df83 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 16 Jun 2025 23:31:53 +0200 Subject: [PATCH 029/196] aqhome-cgi: more work --- apps/aqhome-cgi/README | 11 +- apps/aqhome-cgi/main.c | 22 ++- apps/aqhome-cgi/modules/mroot.c | 163 +++++++++++++++++-- apps/aqhome-cgi/modules/mservice.c | 33 ++-- apps/aqhome-cgi/modules/mservice.h | 8 +- apps/aqhome-cgi/modules/static/en/login.html | 4 +- apps/aqhome-cgi/service/user.t2d | 4 + apps/aqhome-cgi/service_file.c | 40 ++++- 8 files changed, 244 insertions(+), 41 deletions(-) diff --git a/apps/aqhome-cgi/README b/apps/aqhome-cgi/README index 6dbd1b1..9a1da88 100644 --- a/apps/aqhome-cgi/README +++ b/apps/aqhome-cgi/README @@ -2,13 +2,22 @@ Modules: - login +- signup +- main - devices - list - - show?id="nodes/12345678" + - show?name="nodes/12345678" - add - edit - delete - values - rooms +- users + - list + - show?alias="admin" + - add + - edit + - delete + - dashboards diff --git a/apps/aqhome-cgi/main.c b/apps/aqhome-cgi/main.c index a868688..b02433b 100644 --- a/apps/aqhome-cgi/main.c +++ b/apps/aqhome-cgi/main.c @@ -7,6 +7,8 @@ #include #include +#include +#include #include #include #include @@ -32,18 +34,33 @@ static void logStart(void); int main(int argc, char **argv) { + GWEN_GUI *gui; AQCGI_REQUEST *rq; + GWEN_Init(); + gui=GWEN_NoGui_new(); + GWEN_Gui_SetGui(gui); + logStart(); GWEN_Logger_Open(GWEN_LOGDOMAIN, "gwenhywfar", AQHOME_CGI_LOGFILE, GWEN_LoggerType_File, GWEN_LoggerFacility_Daemon); GWEN_Logger_Open(AQH_LOGDOMAIN, "aqhome", AQHOME_CGI_LOGFILE, GWEN_LoggerType_File, GWEN_LoggerFacility_Daemon); GWEN_Logger_Open(AQCGI_LOGDOMAIN, "aqcgi", AQHOME_CGI_LOGFILE, GWEN_LoggerType_File, GWEN_LoggerFacility_Daemon); - GWEN_Logger_SetLevel(AQCGI_LOGDOMAIN, GWEN_LoggerLevel_Debug); GWEN_Logger_Open(NULL, "aqhome-cgi", AQHOME_CGI_LOGFILE, GWEN_LoggerType_File, GWEN_LoggerFacility_Daemon); + GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, GWEN_LoggerLevel_Debug); + GWEN_Logger_SetLevel(AQCGI_LOGDOMAIN, GWEN_LoggerLevel_Debug); + GWEN_Logger_SetLevel(NULL, GWEN_LoggerLevel_Debug); + DBG_ERROR(NULL, "Init CGI"); AQCGI_Init(); + GWEN_Logger_Close(GWEN_LOGDOMAIN); + GWEN_Logger_Open(GWEN_LOGDOMAIN, "gwenhywfar", AQHOME_CGI_LOGFILE, GWEN_LoggerType_File, GWEN_LoggerFacility_Daemon); + + GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, GWEN_LoggerLevel_Debug); + GWEN_Logger_SetLevel(AQCGI_LOGDOMAIN, GWEN_LoggerLevel_Debug); + GWEN_Logger_SetLevel(NULL, GWEN_LoggerLevel_Debug); + rq=AQCGI_ReadRequest(); if (rq) { const char *sPathStaticFiles; @@ -67,9 +84,6 @@ int main(int argc, char **argv) AQCGI_Fini(); - fprintf(stdout, "Content-type: text/plain\n\n"); - fprintf(stdout, "Request handled\n"); - return 0; } diff --git a/apps/aqhome-cgi/modules/mroot.c b/apps/aqhome-cgi/modules/mroot.c index 751f6b0..24e4375 100644 --- a/apps/aqhome-cgi/modules/mroot.c +++ b/apps/aqhome-cgi/modules/mroot.c @@ -16,6 +16,7 @@ #include "aqhome-cgi/service/module.h" #include +#include @@ -37,6 +38,8 @@ static AQH_MODULE *_loadSubModule(AQH_MODULE *m, AQCGI_REQUEST *rq, const char *sModuleName); static int _handleRequest(AQH_MODULE *m, AQCGI_REQUEST *rq, const char *sLastPathElem); static int _handleRqLogin(AQH_MODULE *m, AQCGI_REQUEST *rq); +static int _handleRqLoginPost(AQH_MODULE *m, AQCGI_REQUEST *rq); +static AQH_USER *_getAndCheckUser(AQH_MODULE *m, AQCGI_REQUEST *rq); /* ------------------------------------------------------------------------------------------------ @@ -69,8 +72,16 @@ int _handleRequest(AQH_MODULE *m, AQCGI_REQUEST *rq, const char *sLastPathElem) if (strcasecmp(sLastPathElem, "login")==0) return _handleRqLogin(m, rq); else if (strcasecmp(sLastPathElem, "signup")==0) { + AQCGI_SendResponseWithStatus(rq, 501, "Not Implemented"); + return GWEN_ERROR_NOT_IMPLEMENTED; } else if (strcasecmp(sLastPathElem, "confirm")==0) { + AQCGI_SendResponseWithStatus(rq, 501, "Not Implemented"); + return GWEN_ERROR_NOT_IMPLEMENTED; + } + else { + AQCGI_SendResponseWithStatus(rq, 404, "Not Found"); + return GWEN_ERROR_NOT_IMPLEMENTED; } } @@ -78,25 +89,152 @@ int _handleRequest(AQH_MODULE *m, AQCGI_REQUEST *rq, const char *sLastPathElem) int _handleRqLogin(AQH_MODULE *m, AQCGI_REQUEST *rq) { - if (AQCGI_Request_GetRequestMethod(rq)==AQCGI_REQUEST_METHOD_GET) { - int rv; + int rv; - rv=AQH_ModService_RespondWithFile(m, rq, "login.html"); - if (rv<0) { - DBG_INFO(NULL, "here (%d)", rv); - return rv; - } - return 0; + if (AQCGI_Request_GetRequestMethod(rq)==AQCGI_REQUEST_METHOD_GET) + rv=AQH_ModService_RespondWithFile(m, rq, "en", "login.html"); + else if (AQCGI_Request_GetRequestMethod(rq)==AQCGI_REQUEST_METHOD_POST) + rv=_handleRqLoginPost(m, rq); + else { + DBG_ERROR(NULL, "Invalid request method %d", AQCGI_Request_GetRequestMethod(rq)); + AQCGI_SendResponseWithStatus(rq, 405, "Method No Allowed"); + return GWEN_ERROR_INVALID; } - else if (AQCGI_Request_GetRequestMethod(rq)==AQCGI_REQUEST_METHOD_POST) { - GWEN_DB_NODE *dbPost; + if (rv<0) { + DBG_INFO(NULL, "here (%d)", rv); + return rv; + } + return 0; +} - dbPost=AQCGI_Request_GetDbPostBody(rq); - if (dbPost) { + +int _handleRqLoginPost(AQH_MODULE *m, AQCGI_REQUEST *rq) +{ + AQH_SERVICE *sv; + AQH_USER *user; + AQH_SESSION *session; + GWEN_BUFFER *dbuf; + GWEN_TIMESTAMP *ts; + int rv; + + DBG_ERROR(NULL, "Handling request"); + sv=AQH_ModService_GetService(m); + user=_getAndCheckUser(m, rq); + if (user==NULL) { + DBG_INFO(NULL, "here"); + return GWEN_ERROR_GENERIC; + } + + ts=GWEN_Timestamp_NowInLocalTime(); + AQH_User_SetTimestampLastLogin(user, ts); + DBG_ERROR(NULL, "Saving user"); + rv=AQH_Service_SaveUser(sv, user); + if (rv<0) { + DBG_ERROR(NULL, "Error saving user \"%s\"", AQH_User_GetAlias(user)); + AQCGI_SendResponseWithStatus(rq, 500, "Internal Error"); + AQH_User_free(user); + return rv; + } + + /* generate session */ + DBG_ERROR(NULL, "Generating session"); + dbuf=GWEN_Buffer_new(0, 64, 0, 1); + AQCGI_GenerateSessionId(dbuf); + session=AQH_Session_new(); + AQH_Session_SetTimestampCreation(session, ts); + AQH_Session_SetTimestampLastAccess(session, ts); + AQH_Session_SetUid(session, GWEN_Buffer_GetStart(dbuf)); + GWEN_Buffer_free(dbuf); + AQH_Session_SetUserAlias(session, AQH_User_GetAlias(user)); + rv=AQH_Service_AddSession(sv, session); + if (rv<0) { + DBG_ERROR(NULL, "Error adding session for user \"%s\"", AQH_User_GetAlias(user)); + AQCGI_SendResponseWithStatus(rq, 500, "Internal Error"); + AQH_Session_free(session); + AQH_User_free(user); + return GWEN_ERROR_INTERNAL; + } + + /* add Set-Cookie header */ + dbuf=GWEN_Buffer_new(0, 256, 0, 1); + GWEN_Buffer_AppendArgs(dbuf, "Set-Cookie: session=%s; max-age=3600", AQH_Session_GetUid(session)); + AQCGI_Request_AddResponseHeaderData(rq, GWEN_Buffer_GetStart(dbuf)); + + /* finish */ + AQCGI_SendResponseWithStatus(rq, 200, "Ok"); + AQH_Session_free(session); + AQH_User_free(user); + + return 0; +} + + + +AQH_USER *_getAndCheckUser(AQH_MODULE *m, AQCGI_REQUEST *rq) +{ + GWEN_DB_NODE *dbPost; + + dbPost=AQCGI_Request_GetDbPostBody(rq); + if (dbPost) { + AQH_SERVICE *sv; + const char *sUserName; + const char *sPasswd; + AQH_USER *user; + const char *hashedPaswd; + GWEN_BUFFER *buf; + + sv=AQH_ModService_GetService(m); + sUserName=GWEN_DB_GetCharValue(dbPost, "userid", 0, NULL); + sPasswd=GWEN_DB_GetCharValue(dbPost, "password", 0, NULL); + if (!(sUserName && *sUserName && sPasswd && *sPasswd)) { + DBG_ERROR(NULL, "Either user name or password missing"); + AQCGI_SendResponseWithStatus(rq, 400, "Bad Request"); + return NULL; } + + DBG_ERROR(NULL, "Loading user \"%s\" (%p)", sUserName, sv); + user=AQH_Service_LoadUser(sv, sUserName); + if (user==NULL) { + DBG_ERROR(NULL, "User \"%s\" not found", sUserName); + AQCGI_SendResponseWithStatus(rq, 403, "Forbidden"); + return NULL; + } + DBG_ERROR(NULL, "Loaded user \"%s\"", sUserName); + + if (AQH_User_GetState(user)!=AQH_UserState_Active) { + DBG_ERROR(NULL, "User \"%s\" not active", sUserName); + AQCGI_SendResponseWithStatus(rq, 403, "Forbidden"); + AQH_User_free(user); + return NULL; + } + + hashedPaswd=AQH_User_GetHashedPassword(user); + if (!(hashedPaswd && *hashedPaswd)) { + DBG_ERROR(NULL, "User \"%s\" has no hashed password", sUserName); + AQCGI_SendResponseWithStatus(rq, 403, "Forbidden"); + AQH_User_free(user); + return NULL; + } + buf=GWEN_Buffer_new(0, 256, 0, 1); + AQCGI_HashMd256ToBuffer(sPasswd, buf); + DBG_ERROR(NULL, "Hashed password: [%s]", GWEN_Buffer_GetStart(buf)); + if (strcasecmp(GWEN_Buffer_GetStart(buf), hashedPaswd)!=0) { + DBG_ERROR(NULL, "Bad password for user \"%s\"", sUserName); + AQCGI_SendResponseWithStatus(rq, 403, "Forbidden"); + GWEN_Buffer_free(buf); + AQH_User_free(user); + return NULL; + } + GWEN_Buffer_free(buf); + + DBG_ERROR(NULL, "User \"%s\" accepted", sUserName); + return user; } else { + DBG_ERROR(NULL, "No POST data"); + AQCGI_SendResponseWithStatus(rq, 400, "Bad Request"); + return NULL; } } @@ -106,4 +244,3 @@ int _handleRqLogin(AQH_MODULE *m, AQCGI_REQUEST *rq) - diff --git a/apps/aqhome-cgi/modules/mservice.c b/apps/aqhome-cgi/modules/mservice.c index a40bb17..7d1c9dd 100644 --- a/apps/aqhome-cgi/modules/mservice.c +++ b/apps/aqhome-cgi/modules/mservice.c @@ -138,7 +138,7 @@ void AQH_ModService_SetLoadSubModuleFn(AQH_MODULE *m, AQH_MODSERVICE_LOADSUBMODU -int AQH_ModService_AddHeader(AQH_MODULE *m, GWEN_BUFFER *dbuf) +int AQH_ModService_AddHeader(AQH_MODULE *m, const char *lang, GWEN_BUFFER *dbuf) { if (m && dbuf) { AQH_MODULE *mParent; @@ -147,13 +147,13 @@ int AQH_ModService_AddHeader(AQH_MODULE *m, GWEN_BUFFER *dbuf) if (mParent) { int rv; - rv=AQH_ModService_AddHeader(mParent, dbuf); + rv=AQH_ModService_AddHeader(mParent, lang, dbuf); if (rv<0) { DBG_INFO(NULL, "here (%d)", rv); return rv; } } - return AQH_ModService_ReadStaticFile(m, AQH_MOD_SERVICE_HEADERFILE, dbuf); + return AQH_ModService_ReadStaticFile(m, lang, AQH_MOD_SERVICE_HEADERFILE, dbuf); } DBG_ERROR(NULL, "Argument missing"); return GWEN_ERROR_INVALID; @@ -161,13 +161,13 @@ int AQH_ModService_AddHeader(AQH_MODULE *m, GWEN_BUFFER *dbuf) -int AQH_ModService_AddFooter(AQH_MODULE *m, GWEN_BUFFER *dbuf) +int AQH_ModService_AddFooter(AQH_MODULE *m, const char *lang, GWEN_BUFFER *dbuf) { if (m && dbuf) { AQH_MODULE *mParent; int rv; - rv=AQH_ModService_ReadStaticFile(m, AQH_MOD_SERVICE_FOOTERFILE, dbuf); + rv=AQH_ModService_ReadStaticFile(m, lang, AQH_MOD_SERVICE_FOOTERFILE, dbuf); if (rv<0) { DBG_INFO(NULL, "here (%d)", rv); return rv; @@ -177,38 +177,41 @@ int AQH_ModService_AddFooter(AQH_MODULE *m, GWEN_BUFFER *dbuf) if (mParent) { int rv; - rv=AQH_ModService_AddFooter(mParent, dbuf); + rv=AQH_ModService_AddFooter(mParent, lang, dbuf); if (rv<0) { DBG_INFO(NULL, "here (%d)", rv); return rv; } } + return 0; + } + else { + DBG_ERROR(NULL, "Argument missing"); + return GWEN_ERROR_INVALID; } - DBG_ERROR(NULL, "Argument missing"); - return GWEN_ERROR_INVALID; } -int AQH_ModService_RespondWithFile(AQH_MODULE *m, AQCGI_REQUEST *rq, const char *sFilename) +int AQH_ModService_RespondWithFile(AQH_MODULE *m, AQCGI_REQUEST *rq, const char *lang, const char *sFilename) { GWEN_BUFFER *buf; int rv; buf=GWEN_Buffer_new(0, 256, 0, 1); - rv=AQH_ModService_AddHeader(m, buf); + rv=AQH_ModService_AddHeader(m, lang, buf); if (rv<0) { AQCGI_SendResponseWithStatus(rq, 500, "Internal error"); GWEN_Buffer_free(buf); return GWEN_ERROR_INTERNAL; } - rv=AQH_ModService_ReadStaticFile(m, sFilename, buf); + rv=AQH_ModService_ReadStaticFile(m, lang, sFilename, buf); if (rv<0) { AQCGI_SendResponseWithStatus(rq, 500, "Internal error"); GWEN_Buffer_free(buf); return GWEN_ERROR_INTERNAL; } - rv=AQH_ModService_AddFooter(m, buf); + rv=AQH_ModService_AddFooter(m, lang, buf); if (rv<0) { AQCGI_SendResponseWithStatus(rq, 500, "Internal error"); GWEN_Buffer_free(buf); @@ -216,6 +219,8 @@ int AQH_ModService_RespondWithFile(AQH_MODULE *m, AQCGI_REQUEST *rq, const char } AQCGI_Request_SetBufferResponseBody(rq, buf); AQCGI_Request_AddResponseHeaderData(rq, "Content-type: text/html"); + AQCGI_SendResponseWithStatus(rq, 200, "Ok"); + return 0; } @@ -249,7 +254,7 @@ AQH_MODULE *AQH_ModService_LoadSubModule(AQH_MODULE *m, AQCGI_REQUEST *rq, const -int AQH_ModService_ReadStaticFile(AQH_MODULE *m, const char *filename, GWEN_BUFFER *dbuf) +int AQH_ModService_ReadStaticFile(AQH_MODULE *m, const char *lang, const char *filename, GWEN_BUFFER *dbuf) { if (m && filename && dbuf) { AQH_MOD_SERVICE *xm; @@ -262,6 +267,8 @@ int AQH_ModService_ReadStaticFile(AQH_MODULE *m, const char *filename, GWEN_BUFF fbuf=GWEN_Buffer_new(0, 256, 0, 1); GWEN_Buffer_AppendString(fbuf, xm->baseFolder); GWEN_Buffer_AppendString(fbuf, GWEN_DIR_SEPARATOR_S); + GWEN_Buffer_AppendString(fbuf, (lang && *lang)?lang:"en"); + GWEN_Buffer_AppendString(fbuf, GWEN_DIR_SEPARATOR_S); GWEN_Buffer_AppendString(fbuf, filename); DBG_ERROR(NULL, "Reading file \"%s\"", GWEN_Buffer_GetStart(fbuf)); rv=GWEN_SyncIo_Helper_ReadFile(GWEN_Buffer_GetStart(fbuf), dbuf); diff --git a/apps/aqhome-cgi/modules/mservice.h b/apps/aqhome-cgi/modules/mservice.h index f263c71..6bc7024 100644 --- a/apps/aqhome-cgi/modules/mservice.h +++ b/apps/aqhome-cgi/modules/mservice.h @@ -28,14 +28,14 @@ AQH_SERVICE *AQH_ModService_GetService(const AQH_MODULE *m); const char *AQH_ModService_GetBaseFolder(const AQH_MODULE *m); -int AQH_ModService_AddHeader(AQH_MODULE *m, GWEN_BUFFER *dbuf); -int AQH_ModService_AddFooter(AQH_MODULE *m, GWEN_BUFFER *dbuf); +int AQH_ModService_AddHeader(AQH_MODULE *m, const char *lang, GWEN_BUFFER *dbuf); +int AQH_ModService_AddFooter(AQH_MODULE *m, const char *lang, GWEN_BUFFER *dbuf); AQH_MODULE *AQH_ModService_LoadSubModule(AQH_MODULE *m, AQCGI_REQUEST *rq, const char *sModuleName); int AQH_ModService_HandleRequest(AQH_MODULE *m, AQCGI_REQUEST *rq, const char *sLastPathElem); -int AQH_ModService_RespondWithFile(AQH_MODULE *m, AQCGI_REQUEST *rq, const char *sFilename); -int AQH_ModService_ReadStaticFile(AQH_MODULE *m, const char *filename, GWEN_BUFFER *dbuf); +int AQH_ModService_RespondWithFile(AQH_MODULE *m, AQCGI_REQUEST *rq, const char *lang, const char *sFilename); +int AQH_ModService_ReadStaticFile(AQH_MODULE *m, const char *lang, const char *filename, GWEN_BUFFER *dbuf); void AQH_ModService_SetHandleRequestFn(AQH_MODULE *m, AQH_MODSERVICE_HANDLEREQUEST_FN fn); diff --git a/apps/aqhome-cgi/modules/static/en/login.html b/apps/aqhome-cgi/modules/static/en/login.html index 6fbbe8a..1927e5b 100644 --- a/apps/aqhome-cgi/modules/static/en/login.html +++ b/apps/aqhome-cgi/modules/static/en/login.html @@ -4,8 +4,8 @@

Enter your login credentials

- - + + diff --git a/apps/aqhome-cgi/service/user.t2d b/apps/aqhome-cgi/service/user.t2d index a9ff05a..946dad2 100644 --- a/apps/aqhome-cgi/service/user.t2d +++ b/apps/aqhome-cgi/service/user.t2d @@ -54,6 +54,10 @@ Waiting for approval by admin + + User active + + diff --git a/apps/aqhome-cgi/service_file.c b/apps/aqhome-cgi/service_file.c index b91ac87..371900e 100644 --- a/apps/aqhome-cgi/service_file.c +++ b/apps/aqhome-cgi/service_file.c @@ -70,6 +70,8 @@ static int _addGroupLocked(AQH_SERVICE *sv, const char *groupName, const char *s static int _deleteGroup(AQH_SERVICE *sv, const char *groupName, const char *subGroupName); static GWEN_STRINGLIST *_listGroup(AQH_SERVICE *sv, const char *groupName); +//static void _logGroup(const char *groupName, const char *subGroupName, GWEN_DB_NODE *db); + /* ------------------------------------------------------------------------------------------------ @@ -169,6 +171,9 @@ int _saveUser(AQH_SERVICE *sv, AQH_USER *user) GWEN_DB_Group_free(db); return rv; } + + //_logGroup(AQH_SERVICE_FILE_GROUP_USERS, s, db); + rv=_saveGroupLocked(sv, AQH_SERVICE_FILE_GROUP_USERS, s, db); if (rv<0) { DBG_ERROR(NULL, "here (%d)", rv); @@ -414,6 +419,7 @@ GWEN_STRINGLIST *_listSessions(AQH_SERVICE *sv) GWEN_DB_NODE *_loadGroupLocked(AQH_SERVICE *sv, const char *groupName, const char *subGroupName) { + DBG_ERROR(NULL, "Lock and load group %s/%s", groupName, subGroupName); if (sv && groupName && subGroupName) { AQH_SERVICE_FILE *xs; @@ -422,17 +428,20 @@ GWEN_DB_NODE *_loadGroupLocked(AQH_SERVICE *sv, const char *groupName, const cha GWEN_DB_NODE *db=NULL; int rv; + DBG_ERROR(NULL, "Locking group %s/%s", groupName, subGroupName); rv=GWEN_ConfigMgr_LockGroup(xs->configMgr, groupName, subGroupName); if (rv<0) { DBG_ERROR(NULL, "Error locking group \"%s/%s\": %d", groupName, subGroupName, rv); return NULL; } + DBG_ERROR(NULL, "Loading group %s/%s", groupName, subGroupName); rv=GWEN_ConfigMgr_GetGroup(xs->configMgr, groupName, subGroupName, &db); if (rv<0) { DBG_ERROR(NULL, "Error reading group \"%s/%s\": %d", groupName, subGroupName, rv); GWEN_ConfigMgr_UnlockGroup(xs->configMgr, groupName, subGroupName); return NULL; } + DBG_ERROR(NULL, "Unlocking group %s/%s", groupName, subGroupName); rv=GWEN_ConfigMgr_UnlockGroup(xs->configMgr, groupName, subGroupName); if (rv<0) { DBG_ERROR(NULL, "Error unlocking group \"%s/%s\": %d", groupName, subGroupName, rv); @@ -442,6 +451,9 @@ GWEN_DB_NODE *_loadGroupLocked(AQH_SERVICE *sv, const char *groupName, const cha return db; } } + else { + DBG_ERROR(NULL, "Missing argument"); + } return NULL; } @@ -454,25 +466,26 @@ int _saveGroupLocked(AQH_SERVICE *sv, const char *groupName, const char *subGrou xs=GWEN_INHERIT_GETDATA(AQH_SERVICE, AQH_SERVICE_FILE, sv); if (xs) { - GWEN_DB_NODE *db=NULL; int rv; + DBG_ERROR(NULL, "Locking group %s/%s", groupName, subGroupName); rv=GWEN_ConfigMgr_LockGroup(xs->configMgr, groupName, subGroupName); if (rv<0) { DBG_ERROR(NULL, "Error locking group \"%s/%s\": %d", groupName, subGroupName, rv); return rv; } + DBG_ERROR(NULL, "Writing group %s/%s", groupName, subGroupName); rv=GWEN_ConfigMgr_SetGroup(xs->configMgr, groupName, subGroupName, db); if (rv<0) { DBG_ERROR(NULL, "Error writing group \"%s/%s\": %d", groupName, subGroupName, rv); return rv; } + DBG_ERROR(NULL, "Unlocking group %s/%s", groupName, subGroupName); rv=GWEN_ConfigMgr_UnlockGroup(xs->configMgr, groupName, subGroupName); if (rv<0) { DBG_ERROR(NULL, "Error unlocking group \"%s/%s\": %d", groupName, subGroupName, rv); - GWEN_DB_Group_free(db); return rv; } @@ -491,7 +504,6 @@ int _addGroupLocked(AQH_SERVICE *sv, const char *groupName, const char *subGroup xs=GWEN_INHERIT_GETDATA(AQH_SERVICE, AQH_SERVICE_FILE, sv); if (xs) { - GWEN_DB_NODE *db=NULL; int rv; rv=GWEN_ConfigMgr_HasGroup(xs->configMgr, groupName, subGroupName); @@ -515,7 +527,6 @@ int _addGroupLocked(AQH_SERVICE *sv, const char *groupName, const char *subGroup rv=GWEN_ConfigMgr_UnlockGroup(xs->configMgr, groupName, subGroupName); if (rv<0) { DBG_ERROR(NULL, "Error unlocking group \"%s/%s\": %d", groupName, subGroupName, rv); - GWEN_DB_Group_free(db); return rv; } @@ -577,3 +588,24 @@ GWEN_STRINGLIST *_listGroup(AQH_SERVICE *sv, const char *groupName) } + +#if 0 +void _logGroup(const char *groupName, const char *subGroupName, GWEN_DB_NODE *db) +{ + if (db) { + GWEN_BUFFER *dbuf; + + dbuf=GWEN_Buffer_new(0, 256, 0, 1); + GWEN_DB_WriteToBuffer(db, dbuf, GWEN_DB_FLAGS_DEFAULT); + DBG_ERROR(NULL, "Group %s/%s:\n%s", groupName?groupName:"", subGroupName?subGroupName:"", + GWEN_Buffer_GetStart(dbuf)); + GWEN_Buffer_free(dbuf); + } + else { + DBG_ERROR(NULL, "Group %s/%s empty", groupName?groupName:"", subGroupName?subGroupName:""); + } +} +#endif + + + From aeb6df56853df1f866d123da8629218813eb6f77 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Tue, 17 Jun 2025 00:13:33 +0200 Subject: [PATCH 030/196] avr: reduce number of messages send. - sensor report interval 60->120s - stats report interval 11-31 mins --- avr/apps/reportsensors/main.asm | 24 +++++++++++------------ avr/apps/stats/main.asm | 34 ++++++++++++++++++++++----------- 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/avr/apps/reportsensors/main.asm b/avr/apps/reportsensors/main.asm index a01bac5..027da1f 100644 --- a/avr/apps/reportsensors/main.asm +++ b/avr/apps/reportsensors/main.asm @@ -11,7 +11,7 @@ ; *************************************************************************** ; defines -.equ APP_REPORT_SENSORS_INTERVAL_SECS = 60 +.equ APP_REPORT_SENSORS_INTERVAL_SECS = 120 @@ -78,39 +78,39 @@ AppReportSensors_OnEverySecond_store: #ifdef MODULES_SI7021 cpi r16, 1 breq AppReportSensors_OnEverySecond_measureValue1 - cpi r16, 19 + cpi r16, 11 breq AppReportSensors_OnEverySecond_measureValue2 - cpi r16, 39 + cpi r16, 16 breq AppReportSensors_OnEverySecond_sendValue1 - cpi r16, 49 + cpi r16, 21 breq AppReportSensors_OnEverySecond_sendValue2 #endif #ifdef MODULES_SGP40 - cpi r16, 27 + cpi r16, 32 breq AppReportSensors_OnEverySecond_measureValue4 - cpi r16, 55 + cpi r16, 42 breq AppReportSensors_OnEverySecond_sendValue4 #endif #ifdef MODULES_SGP30 - cpi r16, 29 + cpi r16, 53 breq AppReportSensors_OnEverySecond_measureValue5 - cpi r16, 57 + cpi r16, 63 breq AppReportSensors_OnEverySecond_sendValue5 - cpi r16, 59 + cpi r16, 73 breq AppReportSensors_OnEverySecond_sendValue6 #endif #ifdef MODULES_DS18B20 - cpi r16, 9 + cpi r16, 84 breq AppReportSensors_OnEverySecond_sendValue3 #endif #ifdef MODULES_CCS811 - cpi r16, 31 + cpi r16, 94 breq AppReportSensors_OnEverySecond_sendCCS811_TVOC - cpi r16, 35 + cpi r16, 104 breq AppReportSensors_OnEverySecond_sendCCS811_CO2 #endif diff --git a/avr/apps/stats/main.asm b/avr/apps/stats/main.asm index 45b9091..a669c49 100644 --- a/avr/apps/stats/main.asm +++ b/avr/apps/stats/main.asm @@ -11,7 +11,7 @@ ; *************************************************************************** ; defines -.equ APP_STATS_INTERVAL_MINS = 11 +.equ APP_STATS_INTERVAL_MINS = 31 @@ -77,26 +77,38 @@ AppStats_OnEveryMinute_store: ldi yh, HIGH(netInterfaceData) cpi r16, 1 breq AppStats_OnEveryMinute_sendDevice - cpi r16, 2 - breq AppStats_OnEveryMinute_sendPacketsIn cpi r16, 3 - breq AppStats_OnEveryMinute_sendPacketsOut - cpi r16, 4 - breq AppStats_OnEveryMinute_sendContentErrs + breq AppStats_OnEveryMinute_sendPacketsIn cpi r16, 5 - breq AppStats_OnEveryMinute_sendIoErrs + breq AppStats_OnEveryMinute_sendPacketsOut cpi r16, 6 - breq AppStats_OnEveryMinute_sendNoBufErrs + breq AppStats_OnEveryMinute_sendDevice cpi r16, 7 + breq AppStats_OnEveryMinute_sendContentErrs + cpi r16, 9 + breq AppStats_OnEveryMinute_sendIoErrs + cpi r16, 10 + breq AppStats_OnEveryMinute_sendDevice + cpi r16, 11 + breq AppStats_OnEveryMinute_sendNoBufErrs + cpi r16, 13 breq AppStats_OnEveryMinute_sendCollisionErrs - cpi r16, 8 + cpi r16, 14 + breq AppStats_OnEveryMinute_sendDevice + cpi r16, 15 breq AppStats_OnEveryMinute_sendBusyErrs #ifdef MODULES_HEAP - cpi r16, 9 + cpi r16, 17 breq AppStats_OnEveryMinute_sendHeapUsed - cpi r16, 10 + cpi r16, 19 breq AppStats_OnEveryMinute_sendHeapfree #endif + cpi r16, 18 + breq AppStats_OnEveryMinute_sendDevice + cpi r16, 23 + breq AppStats_OnEveryMinute_sendDevice + cpi r16, 28 + breq AppStats_OnEveryMinute_sendDevice AppStats_OnEveryMinute_sendDevice: rjmp AppNetwork_SendDevice From 026a943648b73d60df093ed24103d5bfa285df4f Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Tue, 17 Jun 2025 00:13:52 +0200 Subject: [PATCH 031/196] avr: adde stats messages to device definitions. --- devices/nodes/aqua_n16.xml | 8 ++++++++ devices/nodes/aqua_n17.xml | 11 +++++++++++ devices/nodes/aqua_n18.xml | 10 ++++++++++ devices/nodes/aqua_n19.xml | 11 +++++++++++ devices/nodes/aqua_n20.xml | 10 ++++++++++ devices/nodes/aqua_n22.xml | 9 +++++++++ devices/nodes/aqua_t03.xml | 8 ++++++++ 7 files changed, 67 insertions(+) diff --git a/devices/nodes/aqua_n16.xml b/devices/nodes/aqua_n16.xml index 11c8f22..c14dde5 100644 --- a/devices/nodes/aqua_n16.xml +++ b/devices/nodes/aqua_n16.xml @@ -10,6 +10,14 @@ + + + + + + + + diff --git a/devices/nodes/aqua_n17.xml b/devices/nodes/aqua_n17.xml index 78a4d89..afef95b 100644 --- a/devices/nodes/aqua_n17.xml +++ b/devices/nodes/aqua_n17.xml @@ -8,6 +8,17 @@ + + + + + + + + + + + diff --git a/devices/nodes/aqua_n18.xml b/devices/nodes/aqua_n18.xml index c86c0aa..ad1c691 100644 --- a/devices/nodes/aqua_n18.xml +++ b/devices/nodes/aqua_n18.xml @@ -9,6 +9,16 @@ + + + + + + + + + + diff --git a/devices/nodes/aqua_n19.xml b/devices/nodes/aqua_n19.xml index 951c020..22b6104 100644 --- a/devices/nodes/aqua_n19.xml +++ b/devices/nodes/aqua_n19.xml @@ -9,6 +9,17 @@ + + + + + + + + + + + diff --git a/devices/nodes/aqua_n20.xml b/devices/nodes/aqua_n20.xml index 7f5c7fd..559dc43 100644 --- a/devices/nodes/aqua_n20.xml +++ b/devices/nodes/aqua_n20.xml @@ -10,6 +10,16 @@ + + + + + + + + + + diff --git a/devices/nodes/aqua_n22.xml b/devices/nodes/aqua_n22.xml index 1648b48..8749b6a 100644 --- a/devices/nodes/aqua_n22.xml +++ b/devices/nodes/aqua_n22.xml @@ -14,6 +14,15 @@ + + + + + + + + + diff --git a/devices/nodes/aqua_t03.xml b/devices/nodes/aqua_t03.xml index 3d539ca..489580a 100644 --- a/devices/nodes/aqua_t03.xml +++ b/devices/nodes/aqua_t03.xml @@ -7,6 +7,14 @@ + + + + + + + + From 409155f0d06aa094b701e1935fce99e9320cd7e0 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Tue, 17 Jun 2025 00:14:14 +0200 Subject: [PATCH 032/196] increment version. --- avr/version.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avr/version.asm b/avr/version.asm index 7a4e7ac..e3f9dc1 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 = 4 +.equ FIRMWARE_VERSION_PATCHLEVEL = 5 From 9ea722607f3fe4b4139081d239c970280c2d26e8 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 23 Jun 2025 19:21:49 +0200 Subject: [PATCH 033/196] avr: added brightness sensor --- avr/apps/reportsensors/main.asm | 26 ++++--- avr/devices/all/includes.asm | 8 ++ avr/devices/all/main.asm | 10 +++ avr/devices/all/modules.asm | 4 + avr/devices/n24/defs.asm | 11 +++ avr/devices/n24/main/main.asm | 3 + avr/devices/n26/defs.asm | 3 +- avr/modules/0BUILD | 1 + avr/modules/brightness/0BUILD | 12 +++ avr/modules/brightness/main.asm | 130 ++++++++++++++++++++++++++++++++ avr/modules/brightness/send.asm | 31 ++++++++ avr/version.asm | 2 +- 12 files changed, 229 insertions(+), 12 deletions(-) create mode 100644 avr/modules/brightness/0BUILD create mode 100644 avr/modules/brightness/main.asm create mode 100644 avr/modules/brightness/send.asm diff --git a/avr/apps/reportsensors/main.asm b/avr/apps/reportsensors/main.asm index 027da1f..51b9a25 100644 --- a/avr/apps/reportsensors/main.asm +++ b/avr/apps/reportsensors/main.asm @@ -95,10 +95,8 @@ AppReportSensors_OnEverySecond_store: #ifdef MODULES_SGP30 cpi r16, 53 - breq AppReportSensors_OnEverySecond_measureValue5 - cpi r16, 63 breq AppReportSensors_OnEverySecond_sendValue5 - cpi r16, 73 + cpi r16, 63 breq AppReportSensors_OnEverySecond_sendValue6 #endif @@ -114,6 +112,11 @@ AppReportSensors_OnEverySecond_store: breq AppReportSensors_OnEverySecond_sendCCS811_CO2 #endif +#ifdef MODULES_BRIGHTNESS + cpi r16, 97 + breq AppReportSensors_OnEverySecond_sendBrightness +#endif + ret #ifdef MODULES_SI7021 @@ -140,13 +143,11 @@ AppReportSensors_OnEverySecond_sendValue3: #endif #ifdef MODULES_SGP30 - AppReportSensors_OnEverySecond_measureValue5: - rjmp SGP30_Measure - AppReportSensors_OnEverySecond_sendValue5: - rjmp SGP30_SendTVOC - ret - AppReportSensors_OnEverySecond_sendValue6: - rjmp SGP30_SendCO2 + AppReportSensors_OnEverySecond_sendValue5: + rjmp SGP30_SendTVOC + ret + AppReportSensors_OnEverySecond_sendValue6: + rjmp SGP30_SendCO2 #endif #ifdef MODULES_CCS811 @@ -156,6 +157,11 @@ AppReportSensors_OnEverySecond_sendCCS811_CO2: rjmp CCS811_SendCO2 #endif +#ifdef MODULES_BRIGHTNESS +AppReportSensors_OnEverySecond_sendBrightness: + rjmp Brightness_Send +#endif + ; @end diff --git a/avr/devices/all/includes.asm b/avr/devices/all/includes.asm index 3d6df0b..ad3a6a2 100644 --- a/avr/devices/all/includes.asm +++ b/avr/devices/all/includes.asm @@ -195,6 +195,14 @@ #endif +#ifdef MODULES_BRIGHTNESS +.include "modules/brightness/main.asm" + #ifdef MODULES_NETWORK + .include "modules/brightness/send.asm" + #endif +#endif + + #ifdef APPS_MOTION .include "modules/f_keepup/main.asm" .include "modules/valsched/main.asm" diff --git a/avr/devices/all/main.asm b/avr/devices/all/main.asm index 694afe7..522c148 100644 --- a/avr/devices/all/main.asm +++ b/avr/devices/all/main.asm @@ -112,6 +112,11 @@ onSystemTimerTick: #endif +#ifdef MODULES_BRIGHTNESS + bigcall Brightness_Every100ms +#endif + + #ifdef APPS_NETWORK ldi yl, LOW(netInterfaceData) ldi yh, HIGH(netInterfaceData) @@ -145,6 +150,11 @@ sysOnEverySecond: #ifdef APPS_REPORTSENSORS bigcall AppReportSensors_OnEverySecond #endif + +#ifdef MODULES_SGP30 + bigcall SGP30_EverySecond +#endif + bigjmp onEverySecond ; @end diff --git a/avr/devices/all/modules.asm b/avr/devices/all/modules.asm index bb63e77..6823fe7 100644 --- a/avr/devices/all/modules.asm +++ b/avr/devices/all/modules.asm @@ -148,6 +148,10 @@ initModules: bigcall ILI9341_Init #endif +#ifdef MODULES_BRIGHTNESS + bigcall Brightness_Init +#endif + ; done ret diff --git a/avr/devices/n24/defs.asm b/avr/devices/n24/defs.asm index 34ceb17..d1b401f 100644 --- a/avr/devices/n24/defs.asm +++ b/avr/devices/n24/defs.asm @@ -146,3 +146,14 @@ +; --------------------------------------------------------------------------- +; Brightness + + +.equ BRIGHTNESS_ADC_PORT = PORTA ; adc0 +.equ BRIGHTNESS_ADC_DDR = DDRA +.equ BRIGHTNESS_ADC_PIN = PORTA0 +.equ BRIGHTNESS_ADC_MUX = 0 + + + diff --git a/avr/devices/n24/main/main.asm b/avr/devices/n24/main/main.asm index 2b0b7b7..7a1e810 100644 --- a/avr/devices/n24/main/main.asm +++ b/avr/devices/n24/main/main.asm @@ -73,6 +73,7 @@ ;#define MODULES_DS18B20 #define MODULES_MOTION ;#define MODULES_CCS811 +#define MODULES_BRIGHTNESS #define APPS_NETWORK #define APPS_MOTION @@ -96,6 +97,8 @@ .equ VALUE_ID_SGP30_TVOC = 0x09 .equ VALUE_ID_SGP30_CO2 = 0x0a +.equ VALUE_ID_BRIGHTNESS = 0x0b + ;.equ VALUE_ID_REED_CONF = 0x81 .equ VALUE_ID_DEBUG = 0x7f diff --git a/avr/devices/n26/defs.asm b/avr/devices/n26/defs.asm index 04cc3d0..8f27140 100644 --- a/avr/devices/n26/defs.asm +++ b/avr/devices/n26/defs.asm @@ -13,7 +13,7 @@ ; AtTiny84 ; -------- ; VCC 1 14 GND -; PB0 2 13 PA0 +; PB0 2 13 PA0 Brightness ; PB1 3 12 PA1 COM-DATA ; /RESET PB3 4 11 PA2 ; PB2 5 10 PA3 LED @@ -96,3 +96,4 @@ + diff --git a/avr/modules/0BUILD b/avr/modules/0BUILD index d2ca36a..6b7dfdf 100644 --- a/avr/modules/0BUILD +++ b/avr/modules/0BUILD @@ -37,6 +37,7 @@ valsched xram heap + brightness diff --git a/avr/modules/brightness/0BUILD b/avr/modules/brightness/0BUILD new file mode 100644 index 0000000..c3dec70 --- /dev/null +++ b/avr/modules/brightness/0BUILD @@ -0,0 +1,12 @@ + + + + + + main.asm + send.asm + + + + + diff --git a/avr/modules/brightness/main.asm b/avr/modules/brightness/main.asm new file mode 100644 index 0000000..49d9e11 --- /dev/null +++ b/avr/modules/brightness/main.asm @@ -0,0 +1,130 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + + +.equ BRIGHTNESS_INTERVAL = 97 + +.equ BRIGHTNESS_FLAGS_VALID_BIT = 7 + + +; *************************************************************************** +; data + +.dseg + +brightnessDataBegin: + brightnessTimer: .byte 1 + brightnessFlags: .byte 1 + brightnessLastValue: .byte 1 +brightnessDataEnd: + + + + +; *************************************************************************** +; code + +.cseg + + + +; --------------------------------------------------------------------------- +; @routine Brightness_Init +; +; Init module. +; +; @return CFLAG always set + +Brightness_Init: + ; preset SRAM data area + ldi xh, HIGH(brightnessDataBegin) + ldi xl, LOW(brightnessDataBegin) + clr r16 + ldi r17, (brightnessDataEnd-brightnessDataBegin) + rcall Utils_FillSram + + ; setup pins + cbi BRIGHTNESS_ADC_PORT, BRIGHTNESS_ADC_PIN ; disable internal pullup for ADC + cbi BRIGHTNESS_ADC_DDR, BRIGHTNESS_ADC_PIN ; set ADC port as input + + ldi r16, BRIGHTNESS_ADC_MUX ; select input pin, use Vcc as reference voltage + out ADMUX, r16 + ldi r16, (1 << ADLAR) + out ADCSRB, r16 + ldi r16, (1 << ADEN) | (1 << ADPS1) | (1 << ADPS0) ; enable, prescaler 8 + out ADCSRA, r16 + + ldi r16, BRIGHTNESS_INTERVAL + sts brightnessTimer, r16 + + sec + ret + + + +Brightness_Fini: + sec + ret + + + +; --------------------------------------------------------------------------- +; @routine Brightness_Every100ms @global +; + +Brightness_Every100ms: + lds r16, brightnessTimer + dec r16 + breq Brightness_Every100ms_readValue + sts brightnessTimer, r16 + cpi r16, 1 + breq Brightness_Every100ms_startMeasure + ret +Brightness_Every100ms_startMeasure: + sbi ADCSRA, ADSC ; start conversion + ret +Brightness_Every100ms_readValue: + sbic ADCSRA, ADSC + ret ; return if bit still set, leave brightnessTimer at "1" + ; conversion complete, read value + ldi r16, BRIGHTNESS_INTERVAL ; restart timer + sts brightnessTimer, r16 + in r16, ADCH ; read value from ADC + sts brightnessLastValue, r16 + ; convert to 1/0 + lds r17, brightnessFlags + sbr r17, (1< Date: Mon, 23 Jun 2025 19:21:58 +0200 Subject: [PATCH 034/196] added n26. --- flashnode.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/flashnode.sh b/flashnode.sh index acb6aef..8c0ee7c 100755 --- a/flashnode.sh +++ b/flashnode.sh @@ -79,6 +79,13 @@ case $NODE in EFUSE_ARG="-U efuse:w:0xFE:m" FILE_ARG="-U flash:w:./0-build/avr/devices/n25/boot/n25_boot.hex" ;; + n26) + DEVICE_ARG="-p t84" + 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/n26/boot/n26_boot.hex" + ;; t03) DEVICE_ARG="-p t841" HFUSE_ARG="-U hfuse:w:0xD7:m" From 8bfaabcf276404625b89fae3a591f7838b79886c Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 23 Jun 2025 19:27:53 +0200 Subject: [PATCH 035/196] read 10bit brightness (instead of 8 bit). --- avr/modules/brightness/main.asm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/avr/modules/brightness/main.asm b/avr/modules/brightness/main.asm index 49d9e11..a3326b2 100644 --- a/avr/modules/brightness/main.asm +++ b/avr/modules/brightness/main.asm @@ -56,7 +56,7 @@ Brightness_Init: ldi r16, BRIGHTNESS_ADC_MUX ; select input pin, use Vcc as reference voltage out ADMUX, r16 - ldi r16, (1 << ADLAR) + ldi r16, (0 << ADLAR) out ADCSRB, r16 ldi r16, (1 << ADEN) | (1 << ADPS1) | (1 << ADPS0) ; enable, prescaler 8 out ADCSRA, r16 @@ -96,7 +96,12 @@ Brightness_Every100ms_readValue: ; conversion complete, read value ldi r16, BRIGHTNESS_INTERVAL ; restart timer sts brightnessTimer, r16 - in r16, ADCH ; read value from ADC + in r16, ADCL + in r17, ADCH ; read value from ADC + tst r17 + breq Brightness_Every100ms_storeValue + ldi r16, 0xff +Brightness_Every100ms_storeValue: sts brightnessLastValue, r16 ; convert to 1/0 lds r17, brightnessFlags From 78fec171f95c9e760b71bd095ab2511e8770a745 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 23 Jun 2025 19:28:20 +0200 Subject: [PATCH 036/196] sgp30: measure every second, increases accuracy. --- avr/modules/sgp30/main.asm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/avr/modules/sgp30/main.asm b/avr/modules/sgp30/main.asm index 9332a5a..e67de56 100644 --- a/avr/modules/sgp30/main.asm +++ b/avr/modules/sgp30/main.asm @@ -157,10 +157,22 @@ sgp30CheckPresence: +; --------------------------------------------------------------------------- +; @routine SGP30_EverySecond +; +; +; @return CFLAG set if okay, clear on error +; @clobbers R16, R17, R18, R19, R20, R21, R22 + +SGP30_EverySecond: + rjmp SGP30_Measure ; (R16, R17, R18, R19, R20, R21, R22) +; @end + + + ; --------------------------------------------------------------------------- ; @routine SGP30_Measure ; -; Expects interrupts being disabled! ; ; @return CFLAG set if okay, clear on error ; @clobbers R16, R17, R18, R19, R20, R21, R22 From 1e95b317bfc729629bcb890226c611a9d55b63fa Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 23 Jun 2025 19:28:35 +0200 Subject: [PATCH 037/196] incremented firmware version. --- avr/version.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avr/version.asm b/avr/version.asm index a0acf33..a21f6e4 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 = 6 +.equ FIRMWARE_VERSION_PATCHLEVEL = 7 From b2802a37aaa132a6e31c0859df122f0eef3a6f9e Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Wed, 25 Jun 2025 00:00:39 +0200 Subject: [PATCH 038/196] added AQH_Storage_GetFirstNDataPoints() --- aqhome/data/storage.c | 72 +++++++++++++++++++++++++++++++++++++++++ aqhome/data/storage.h | 6 ++++ aqhome/data/storage_p.h | 1 + 3 files changed, 79 insertions(+) diff --git a/aqhome/data/storage.c b/aqhome/data/storage.c index 74a8a65..70faf46 100644 --- a/aqhome/data/storage.c +++ b/aqhome/data/storage.c @@ -305,6 +305,17 @@ AQH_STORAGE_GETLASTDATAPOINT_FN AQH_Storage_SetGetLastDatapointFn(AQH_STORAGE *s +AQH_STORAGE_GETFIRSTNDATAPOINTS_FN AQH_Storage_SetGetFirstNDatapointsFn(AQH_STORAGE *sto, AQH_STORAGE_GETFIRSTNDATAPOINTS_FN fn) +{ + AQH_STORAGE_GETFIRSTNDATAPOINTS_FN oldFn; + + oldFn=sto->getFirstNDatapointsFn; + sto->getFirstNDatapointsFn=fn; + return oldFn; +} + + + AQH_STORAGE_GETLASTNDATAPOINTS_FN AQH_Storage_SetGetLastNDatapointsFn(AQH_STORAGE *sto, AQH_STORAGE_GETLASTNDATAPOINTS_FN fn) { AQH_STORAGE_GETLASTNDATAPOINTS_FN oldFn; @@ -468,6 +479,67 @@ uint64_t *AQH_Storage_GetDataPoints(AQH_STORAGE *sto, uint64_t valueId, uint64_t +uint64_t *AQH_Storage_GetFirstNDataPoints(AQH_STORAGE *sto, uint64_t valueId, uint64_t maxDataPointsRequested) +{ + AQH_DATAFILE *df; + uint64_t numEntries; + uint64_t numOfDataEntries; + uint64_t arrayLen; + uint64_t arrayPos; + uint64_t *arrayPtr; + uint64_t firstRecord; + uint64_t i; + + df=_getDataFileByValueId(sto, valueId); + if (df==NULL) { + DBG_ERROR(AQH_LOGDOMAIN, "No file for value id %lu", (unsigned long int) valueId); + return NULL; + } + numEntries=AQH_DataFile_GetNumberOfEntries(df); + numOfDataEntries=numEntries-1; /* first entry is reserved, don't count it here */ + if (numOfDataEntries<1) { + DBG_INFO(AQH_LOGDOMAIN, "No data records for value id %lu", (unsigned long int) valueId); + return NULL; + } + firstRecord=1; + if (numOfDataEntries>maxDataPointsRequested) /* more entries in file than requested */ + arrayLen=(maxDataPointsRequested*2)+1; /* +1 because the first array entry contains the number of entries */ + else + arrayLen=(numOfDataEntries*2)+1; + + arrayPtr=(uint64_t*) malloc(arrayLen*sizeof(uint64_t)); + if (arrayPtr==NULL) { + DBG_ERROR(AQH_LOGDOMAIN, "Not enough memory for %lu entries", (unsigned long int) arrayLen); + return NULL; + } + arrayPos=1; + + for (i=firstRecord; i=arrayLen) { + DBG_INFO(AQH_LOGDOMAIN, "Requested number of entries reached"); + break; + } + arrayPtr[arrayPos++]=ts; + arrayPtr[arrayPos++]=u.i; + } /* for */ + + arrayPtr[0]=arrayPos-1; + return arrayPtr; +} + + + uint64_t *AQH_Storage_GetLastNDataPoints(AQH_STORAGE *sto, uint64_t valueId, uint64_t maxDataPointsRequested) { AQH_DATAFILE *df; diff --git a/aqhome/data/storage.h b/aqhome/data/storage.h index c23152f..d30b257 100644 --- a/aqhome/data/storage.h +++ b/aqhome/data/storage.h @@ -53,6 +53,8 @@ typedef uint64_t *(*AQH_STORAGE_GETDATAPOINTS_FN)(AQH_STORAGE *sto, uint64_t val uint64_t maxArrayLen); typedef int (*AQH_STORAGE_GETFIRSTDATAPOINT_FN)(AQH_STORAGE *sto, uint64_t valueId, uint64_t *pTimestamp, double *pValue); typedef int (*AQH_STORAGE_GETLASTDATAPOINT_FN)(AQH_STORAGE *sto, uint64_t valueId, uint64_t *pTimestamp, double *pValue); + +typedef uint64_t *(*AQH_STORAGE_GETFIRSTNDATAPOINTS_FN)(AQH_STORAGE *sto, uint64_t valueId, uint64_t maxDataPointsRequested); typedef uint64_t *(*AQH_STORAGE_GETLASTNDATAPOINTS_FN)(AQH_STORAGE *sto, uint64_t valueId, uint64_t maxDataPointsRequested); @@ -96,6 +98,8 @@ AQHOME_API uint64_t *AQH_Storage_GetDataPoints(AQH_STORAGE *sto, uint64_t valueI uint64_t maxArrayLen); AQHOME_API int AQH_Storage_GetFirstDataPoint(AQH_STORAGE *sto, uint64_t valueId, uint64_t *pTimestamp, double *pValue); AQHOME_API int AQH_Storage_GetLastDataPoint(AQH_STORAGE *sto, uint64_t valueId, uint64_t *pTimestamp, double *pValue); + +AQHOME_API uint64_t *AQH_Storage_GetFirstNDataPoints(AQH_STORAGE *sto, uint64_t valueId, uint64_t maxDataPointsRequested); AQHOME_API uint64_t *AQH_Storage_GetLastNDataPoints(AQH_STORAGE *sto, uint64_t valueId, uint64_t maxDataPointsRequested); @@ -105,6 +109,8 @@ AQHOME_API AQH_STORAGE_ADDDATAPOINT_FN AQH_Storage_SetAddDatapointFn(AQH_STORAGE AQHOME_API AQH_STORAGE_GETDATAPOINTS_FN AQH_Storage_SetGetDatapointsFn(AQH_STORAGE *sto, AQH_STORAGE_GETDATAPOINTS_FN fn); AQHOME_API AQH_STORAGE_GETFIRSTDATAPOINT_FN AQH_Storage_SetGetFirstDatapointFn(AQH_STORAGE *sto, AQH_STORAGE_GETFIRSTDATAPOINT_FN fn); AQHOME_API AQH_STORAGE_GETLASTDATAPOINT_FN AQH_Storage_SetGetLastDatapointFn(AQH_STORAGE *sto, AQH_STORAGE_GETLASTDATAPOINT_FN fn); + +AQHOME_API AQH_STORAGE_GETFIRSTNDATAPOINTS_FN AQH_Storage_SetGetFirstNDatapointsFn(AQH_STORAGE *sto, AQH_STORAGE_GETFIRSTNDATAPOINTS_FN fn); AQHOME_API AQH_STORAGE_GETLASTNDATAPOINTS_FN AQH_Storage_SetGetLastNDatapointsFn(AQH_STORAGE *sto, AQH_STORAGE_GETLASTNDATAPOINTS_FN fn); diff --git a/aqhome/data/storage_p.h b/aqhome/data/storage_p.h index 0cc5701..c8cad6b 100644 --- a/aqhome/data/storage_p.h +++ b/aqhome/data/storage_p.h @@ -47,6 +47,7 @@ struct AQH_STORAGE { AQH_STORAGE_GETFIRSTDATAPOINT_FN getFirstDatapointFn; AQH_STORAGE_GETLASTDATAPOINT_FN getLastDatapointFn; AQH_STORAGE_GETLASTNDATAPOINTS_FN getLastNDatapointsFn; + AQH_STORAGE_GETFIRSTNDATAPOINTS_FN getFirstNDatapointsFn; }; From 63ebcbadc9a4a2eff1a61c307eeb0465ef36a586 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Wed, 25 Jun 2025 00:01:12 +0200 Subject: [PATCH 039/196] added msg "getValues" --- aqhome/msg/ipc/data/0BUILD | 2 + aqhome/msg/ipc/data/m_ipcd_getvalues.c | 81 ++++++++++++++++++++++++++ aqhome/msg/ipc/data/m_ipcd_getvalues.h | 36 ++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 aqhome/msg/ipc/data/m_ipcd_getvalues.c create mode 100644 aqhome/msg/ipc/data/m_ipcd_getvalues.h diff --git a/aqhome/msg/ipc/data/0BUILD b/aqhome/msg/ipc/data/0BUILD index 3962eb1..527384b 100644 --- a/aqhome/msg/ipc/data/0BUILD +++ b/aqhome/msg/ipc/data/0BUILD @@ -51,6 +51,7 @@ m_ipcd_values.h m_ipcd_getdata.h m_ipcd_setdata.h + m_ipcd_getvalues.h @@ -67,6 +68,7 @@ m_ipcd_values.c m_ipcd_getdata.c m_ipcd_setdata.c + m_ipcd_getvalues.c diff --git a/aqhome/msg/ipc/data/m_ipcd_getvalues.c b/aqhome/msg/ipc/data/m_ipcd_getvalues.c new file mode 100644 index 0000000..d90e0b1 --- /dev/null +++ b/aqhome/msg/ipc/data/m_ipcd_getvalues.c @@ -0,0 +1,81 @@ +/**************************************************************************** + * This file is part of the project AqHome. + * AqHome (c) by 2025 Martin Preuss, all rights reserved. + * + * The license for this file can be found in the file COPYING which you + * should have received along with this file. + ****************************************************************************/ + +#ifdef HAVE_CONFIG_H +# include +#endif + + +#include "aqhome/msg/ipc/data/m_ipcd_getvalues.h" +#include "aqhome/msg/ipc/m_ipc_tag16.h" +#include "aqhome/msg/ipc/data/m_ipcd.h" +#include "aqhome/msg/ipc/m_ipc.h" + +#include +#include +#include +#include + + + +/* ------------------------------------------------------------------------------------------------ + * forward declarations + * ------------------------------------------------------------------------------------------------ + */ + + + +/* ------------------------------------------------------------------------------------------------ + * implementation + * ------------------------------------------------------------------------------------------------ + */ + +AQH_MESSAGE *AQH_IpcdMessageGetValues_new(uint16_t code, uint32_t msgId, uint32_t refMsgId, + const char *deviceName, int modality) +{ + AQH_MESSAGE *msg; + GWEN_BUFFER *buf; + + buf=GWEN_Buffer_new(0, 256, 0, 1); + + if (deviceName && *deviceName) + GWEN_Tag16_WriteStringTagToBuffer(AQH_MSGDATA_GETVALUES_TAGS_DEVICENAME, deviceName, buf); + GWEN_Tag16_WriteUint64TagToBuffer(AQH_MSGDATA_GETVALUES_TAGS_MODALITY, modality, buf); + + msg=AQH_IpcMessage_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msgId, refMsgId, + GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf)); + GWEN_Buffer_free(buf); + return msg; +} + + + +void AQH_IpcdMessageGetValues_DumpToBuffer(const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList, + GWEN_BUFFER *dbuf, const char *sText) +{ + char *deviceName; + uint64_t modality; + + deviceName=tagList?AQH_Tag16_GetTagDataAsNewString(tagList, AQH_MSGDATA_GETVALUES_TAGS_DEVICENAME, NULL):NULL; + modality=tagList?AQH_Tag16_GetTagDataAsUint64(tagList, AQH_MSGDATA_GETVALUES_TAGS_MODALITY, 0):0; + + GWEN_Buffer_AppendArgs(dbuf, + "GETVALUES(%s) %s (code=%d, proto=%d, proto version=%d, device=%s, modality=%s)\n", + AQH_IpcdMessage_MsgTypeToChar(AQH_IpcMessage_GetCode(msg)), + sText?sText:"", + AQH_IpcMessage_GetCode(msg), + AQH_IpcMessage_GetProtoId(msg), + AQH_IpcMessage_GetProtoVersion(msg), + deviceName?deviceName:"", + AQH_ValueModality_toString(modality)); + free(deviceName); +} + + + + diff --git a/aqhome/msg/ipc/data/m_ipcd_getvalues.h b/aqhome/msg/ipc/data/m_ipcd_getvalues.h new file mode 100644 index 0000000..9680eae --- /dev/null +++ b/aqhome/msg/ipc/data/m_ipcd_getvalues.h @@ -0,0 +1,36 @@ +/**************************************************************************** + * This file is part of the project AqHome. + * AqHome (c) by 2025 Martin Preuss, all rights reserved. + * + * The license for this file can be found in the file COPYING which you + * should have received along with this file. + ****************************************************************************/ + +#ifndef AQH_M_IPCD_GETVALUES_H +#define AQH_M_IPCD_GETVALUES_H + + + +#include +#include +#include + +#include +#include + + + +#define AQH_MSGDATA_GETVALUES_TAGS_DEVICENAME 0x0001 +#define AQH_MSGDATA_GETVALUES_TAGS_MODALITY 0x0002 + + + +AQHOME_API AQH_MESSAGE *AQH_IpcdMessageGetValues_new(uint16_t code, uint32_t msgId, uint32_t refMsgId, + const char *deviceName, int modality); + +AQHOME_API void AQH_IpcdMessageGetValues_DumpToBuffer(const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList, + GWEN_BUFFER *dbuf, const char *sText); + + + +#endif From cd6a918533ac54b3e8238b9b11727727b251d8db Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Wed, 25 Jun 2025 00:01:52 +0200 Subject: [PATCH 040/196] s_getvalues: allow for filtering output list. --- apps/aqhome-data/s_getvalues.c | 146 ++++++++++++++++++++++++--------- 1 file changed, 106 insertions(+), 40 deletions(-) diff --git a/apps/aqhome-data/s_getvalues.c b/apps/aqhome-data/s_getvalues.c index ac592af..be430ce 100644 --- a/apps/aqhome-data/s_getvalues.c +++ b/apps/aqhome-data/s_getvalues.c @@ -13,13 +13,16 @@ #include "./s_getvalues.h" #include "./server_p.h" +#include "aqhome/aqhome.h" #include "aqhome/ipc2/endpoint.h" #include "aqhome/msg/ipc/m_ipc.h" #include "aqhome/msg/ipc/data/m_ipcd.h" +#include "aqhome/msg/ipc/data/m_ipcd_getvalues.h" #include "aqhome/msg/ipc/data/m_ipcd_values.h" #include "aqhome/msg/ipc/m_ipc_result.h" #include "aqhome/msg/ipc/m_ipc_tag16.h" +#include #include @@ -38,7 +41,10 @@ * ------------------------------------------------------------------------------------------------ */ -static void _sendValueList(AQH_OBJECT *ep, const AQH_VALUE_LIST *vl, uint32_t flags, uint32_t refMsgId); +static AQH_VALUE_LIST *_getMatchingValueList(AQHOME_SERVER *xo, const GWEN_TAG16_LIST *tagList); +static void _sendValueList(AQH_OBJECT *ep, const AQH_VALUE_LIST *vl, uint32_t refMsgId); +static void _sendValueListMsg(AQH_OBJECT *ep, const AQH_VALUE_LIST *vl, uint32_t flags, uint32_t refMsgId); +static int _valueMatches(const AQH_VALUE *v, const char *deviceName, int modality); @@ -47,64 +53,100 @@ static void _sendValueList(AQH_OBJECT *ep, const AQH_VALUE_LIST *vl, uint32_t fl * ------------------------------------------------------------------------------------------------ */ -void AqHomeDataServer_HandleGetValues(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg, GWEN_UNUSED const GWEN_TAG16_LIST *tagList) +void AqHomeDataServer_HandleGetValues(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList) { AQHOME_SERVER *xo; xo=AqHomeDataServer_GetServerData(o); if (xo) { - const AQH_VALUE_LIST *origValueList; - + AQH_VALUE_LIST *valueList; uint32_t refMsgId; refMsgId=AQH_IpcMessage_GetMsgId(msg); DBG_INFO(NULL, "HandleGetValues"); - origValueList=AQH_Storage_GetValueList(xo->storage); - if (origValueList) { - DBG_INFO(NULL, "Have a list of %d values", AQH_Value_List_GetCount(origValueList)); - if (AQH_Value_List_GetCount(origValueList)=AQHOMEDATA_VALUESPERMSG) { - DBG_INFO(NULL, "Sending %d values", AQH_Value_List_GetCount(tmpValueList)); - _sendValueList(ep, tmpValueList, next?0:AQH_MSGDATA_VALUES_FLAGS_LASTMSG, refMsgId); - AQH_Value_List_Clear(tmpValueList); - } - v=next; - } - if (AQH_Value_List_GetCount(tmpValueList)) { - DBG_INFO(NULL, "Sending %d values", AQH_Value_List_GetCount(tmpValueList)); - _sendValueList(ep, tmpValueList, AQH_MSGDATA_VALUES_FLAGS_LASTMSG, refMsgId); /* send remaining */ - } - AQH_Value_List_free(tmpValueList); - } + valueList=_getMatchingValueList(xo, tagList); + if (valueList) { + _sendValueList(ep, valueList, refMsgId); + AQH_Value_List_free(valueList); } else { /* empty list */ - _sendValueList(ep, NULL, AQH_MSGDATA_VALUES_FLAGS_LASTMSG, refMsgId); + _sendValueListMsg(ep, NULL, AQH_MSGDATA_VALUES_FLAGS_LASTMSG, refMsgId); } } } -void _sendValueList(AQH_OBJECT *ep, const AQH_VALUE_LIST *vl, uint32_t flags, uint32_t refMsgId) +AQH_VALUE_LIST *_getMatchingValueList(AQHOME_SERVER *xo, const GWEN_TAG16_LIST *tagList) +{ + const AQH_VALUE_LIST *origValueList; + AQH_VALUE_LIST *tmpValueList=NULL; + char *deviceName; + int modality; + + deviceName=tagList?AQH_Tag16_GetTagDataAsNewString(tagList, AQH_MSGDATA_GETVALUES_TAGS_DEVICENAME, NULL):NULL; + modality=tagList?AQH_Tag16_GetTagDataAsUint64(tagList, AQH_MSGDATA_GETVALUES_TAGS_MODALITY, 0):0; + + origValueList=AQH_Storage_GetValueList(xo->storage); + if (origValueList) { + const AQH_VALUE *v; + + tmpValueList=AQH_Value_List_new(); + v=AQH_Value_List_First(origValueList); + while(v) { + if (_valueMatches(v, deviceName, modality)) { + AQH_VALUE *copyOfValue; + + copyOfValue=AQH_Value_dup(v); + AQH_Value_List_Add(copyOfValue, tmpValueList); + } + v=AQH_Value_List_Next(v); + } + if (AQH_Value_List_GetCount(tmpValueList)<1) { + AQH_Value_List_free(tmpValueList); + tmpValueList=NULL; + } + } + free(deviceName); + + return tmpValueList; +} + + + +void _sendValueList(AQH_OBJECT *ep, const AQH_VALUE_LIST *vl, uint32_t refMsgId) +{ + AQH_VALUE_LIST *tmpValueList; + const AQH_VALUE *v; + + tmpValueList=AQH_Value_List_new(); + v=AQH_Value_List_First(vl); + while(v) { + const AQH_VALUE *next; + AQH_VALUE *copyOfValue; + + next=AQH_Value_List_Next(v); + copyOfValue=AQH_Value_dup(v); + AQH_Value_List_Add(copyOfValue, tmpValueList); + if (AQH_Value_List_GetCount(tmpValueList)>=AQHOMEDATA_VALUESPERMSG) { + DBG_INFO(NULL, "Sending %d values", AQH_Value_List_GetCount(tmpValueList)); + _sendValueListMsg(ep, tmpValueList, next?0:AQH_MSGDATA_VALUES_FLAGS_LASTMSG, refMsgId); + AQH_Value_List_Clear(tmpValueList); + } + v=next; + } + if (AQH_Value_List_GetCount(tmpValueList)) { + DBG_INFO(NULL, "Sending %d values", AQH_Value_List_GetCount(tmpValueList)); + _sendValueListMsg(ep, tmpValueList, AQH_MSGDATA_VALUES_FLAGS_LASTMSG, refMsgId); /* send remaining */ + } + AQH_Value_List_free(tmpValueList); +} + + + +void _sendValueListMsg(AQH_OBJECT *ep, const AQH_VALUE_LIST *vl, uint32_t flags, uint32_t refMsgId) { AQH_MESSAGE *msg; @@ -115,3 +157,27 @@ void _sendValueList(AQH_OBJECT *ep, const AQH_VALUE_LIST *vl, uint32_t flags, ui +int _valueMatches(const AQH_VALUE *v, const char *deviceName, int modality) +{ + if (modality!=AQH_ValueModality_Unknown) { + int valModality; + + valModality=AQH_Value_GetModality(v); + if (valModality!=modality) + return 0; + } + if (deviceName && *deviceName) { + const char *s; + + s=AQH_Value_GetDeviceNameForSystem(v); + if (s && *s && GWEN_Text_ComparePattern(s, deviceName, 0)==-1) + return 0; + } + + return 1; +} + + + + + From 033b7cd4db821b021ae3790e7c31191574bbcf8a Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Wed, 25 Jun 2025 00:02:32 +0200 Subject: [PATCH 041/196] getvalues: allow for filtering value list on server. --- apps/aqhome-tool/data/getvalues.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/apps/aqhome-tool/data/getvalues.c b/apps/aqhome-tool/data/getvalues.c index c91d0ea..7af66a3 100644 --- a/apps/aqhome-tool/data/getvalues.c +++ b/apps/aqhome-tool/data/getvalues.c @@ -14,10 +14,12 @@ #include "../client.h" #include "../utils.h" +#include "aqhome/aqhome.h" #include "aqhome/msg/ipc/m_ipc.h" #include "aqhome/msg/ipc/m_ipc_result.h" #include "aqhome/msg/ipc/data/m_ipcd.h" #include "aqhome/msg/ipc/data/m_ipcd_values.h" +#include "aqhome/msg/ipc/data/m_ipcd_getvalues.h" #include #include @@ -67,6 +69,8 @@ int AQH_Tool_GetValues(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv) { A_ARG, A_INT, "timeout", 0, 1, "T", NULL, I18S("Specify timeout in seconds for response"), NULL}, { A_ARG, A_CHAR, "brokerClientId", 0, 1, "c", "clientid", I18S("Specify CLIENTID"), NULL}, { A_ARG, A_CHAR, "userId", 0, 1, "u", "userid", I18S("Specify user id"), NULL}, + { A_ARG, A_CHAR, "device", 0, 1, "d", "device", I18S("device name to match"), NULL}, + { A_ARG, A_CHAR, "modality", 0, 1, "m", NULL, I18S("Modality to match"), NULL}, { A_ARG, A_CHAR, "password", 0, 1, "p", "password", I18S("Specify service password"), NULL}, { 0, A_INT, "printHeader", 0, 1, "H", "printheader", I18S("Print header if given"), NULL}, { A_END, A_INT, "help", 0, 0, "h", "help", I18S("Show this help screen"), NULL} @@ -90,11 +94,23 @@ int AQH_Tool_GetValues(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv) AQH_MESSAGE *_createRequestMessage(GWEN_UNUSED AQH_OBJECT *o, uint32_t msgId) { - return AQH_IpcMessage_new(AQH_IPC_PROTOCOL_DATA_ID, - AQH_IPC_PROTOCOL_DATA_VERSION, - AQH_MSGTYPE_IPC_DATA_GETVALUES_REQ, - msgId, 0, - 0, NULL); + GWEN_DB_NODE *dbArgs; + const char *deviceName; + const char *s; + int modality; + + dbArgs=AQH_ToolClient_GetDbLocalArgs(o); + deviceName=GWEN_DB_GetCharValue(dbArgs, "device", 0, NULL); + s=GWEN_DB_GetCharValue(dbArgs, "modality", 0, NULL); + if (s && *s) { + modality=AQH_ValueModality_fromString(s); + if (modality==AQH_ValueModality_Unknown) { + } + } + else + modality=AQH_ValueModality_Unknown; + + return AQH_IpcdMessageGetValues_new(AQH_MSGTYPE_IPC_DATA_GETVALUES_REQ, msgId, 0, deviceName, modality); } From a808450fa22fe1a8d6a9d185088f831c0d781995 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Wed, 25 Jun 2025 00:03:09 +0200 Subject: [PATCH 042/196] add dataclient sublib to be used by multiple tools. --- aqhome/0BUILD | 2 + aqhome/dataclient/0BUILD | 81 ++++++ aqhome/dataclient/client.c | 520 +++++++++++++++++++++++++++++++++++ aqhome/dataclient/client.h | 45 +++ aqhome/dataclient/client_p.h | 28 ++ 5 files changed, 676 insertions(+) create mode 100644 aqhome/dataclient/0BUILD create mode 100644 aqhome/dataclient/client.c create mode 100644 aqhome/dataclient/client.h create mode 100644 aqhome/dataclient/client_p.h diff --git a/aqhome/0BUILD b/aqhome/0BUILD index d33f5d3..fbb58e8 100644 --- a/aqhome/0BUILD +++ b/aqhome/0BUILD @@ -69,6 +69,7 @@ hexfile data events2 + dataclient @@ -79,6 +80,7 @@ aqhhexfile aqhdata aqhevents2 + aqhdataclient diff --git a/aqhome/dataclient/0BUILD b/aqhome/dataclient/0BUILD new file mode 100644 index 0000000..5300f9d --- /dev/null +++ b/aqhome/dataclient/0BUILD @@ -0,0 +1,81 @@ + + + + + + + + $(gwenhywfar_cflags) + $(aqdatabase_cflags) + -I$(topsrcdir) + -I$(topbuilddir) + + + + --include=$(builddir) + --include=$(srcdir) + --include=$(aqdatabase_AQDATABASE_TYPEMAKERDIR)/c + + + + + + $(visibility_cflags) + + + + --api=AQHOME_API + + + + + + + + + + + + + + + + + + $(local/built_headers_pub) + + + + + client.h + + + + + client_p.h + + + + + $(local/typefiles) + + client.c + + + + + + + + + + + + + + + + + + + diff --git a/aqhome/dataclient/client.c b/aqhome/dataclient/client.c new file mode 100644 index 0000000..780265a --- /dev/null +++ b/aqhome/dataclient/client.c @@ -0,0 +1,520 @@ +/**************************************************************************** + * This file is part of the project AqHome. + * AqHome (c) by 2025 Martin Preuss, all rights reserved. + * + * The license for this file can be found in the file COPYING which you + * should have received along with this file. + ****************************************************************************/ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "./client_p.h" + +#include "aqhome/msg/ipc/m_ipc.h" +#include "aqhome/msg/ipc/m_ipc_tag16.h" +#include "aqhome/msg/ipc/m_ipc_result.h" +#include "aqhome/msg/ipc/data/m_ipcd.h" +#include "aqhome/msg/ipc/nodes/m_ipcn.h" +#include "aqhome/msg/ipc/m_ipc_connect.h" +#include "aqhome/msg/ipc/data/m_ipcd_devices.h" +#include "aqhome/msg/ipc/data/m_ipcd_values.h" +#include "aqhome/msg/ipc/data/m_ipcd_getvalues.h" +#include "aqhome/msg/ipc/data/m_ipcd_getdata.h" +#include "aqhome/msg/ipc/data/m_ipcd_multidata.h" +#include "aqhome/msg/ipc/data/m_ipcd_setdata.h" +#include "aqhome/ipc2/tcp_object.h" +#include "aqhome/ipc2/ipc_client.h" +#include + +#include +#include +#include + + +#define AQH_DATA_CLIENT_DEFAULT_CMD_TIMEOUT 5 + + + +GWEN_INHERIT(AQH_OBJECT, AQH_DATA_CLIENT) + + + + +static void GWENHYWFAR_CB _freeData(void *bp, void *p); + +static int _connectEndpoint(AQH_OBJECT *o, const char *addr, int port, uint32_t flags); +static int _exchangeConnectMsgs(AQH_DATA_CLIENT *xo, const char *userId, const char *passwd, const char *clientId, uint32_t flags); +static uint64_t _getFirstOrLastData(AQH_OBJECT *o, const char *valueName, uint64_t *dataPtr, uint64_t maxNum, int mode); +static uint64_t _handleDataResponses(AQH_DATA_CLIENT *xo, uint64_t *dataPtr, uint64_t maxNum, uint32_t msgId); +static int _handleResult(AQH_DATA_CLIENT *xo, uint32_t msgId); + + + + + + +AQH_OBJECT *AQH_DataClient_new(AQH_EVENT_LOOP *eventLoop, uint8_t protoId, uint8_t protoVer) +{ + AQH_OBJECT *o; + AQH_DATA_CLIENT *xo; + + o=AQH_Object_new(eventLoop); + GWEN_NEW_OBJECT(AQH_DATA_CLIENT, xo); + GWEN_INHERIT_SETDATA(AQH_OBJECT, AQH_DATA_CLIENT, o, xo, _freeData); + + xo->protoId=protoId; + xo->protoVer=protoVer; + xo->timeoutInSeconds=AQH_DATA_CLIENT_DEFAULT_CMD_TIMEOUT; + + return 0; +} + + + +void GWENHYWFAR_CB _freeData(GWEN_UNUSED void *bp, void *p) +{ + AQH_DATA_CLIENT *xo; + + xo=(AQH_DATA_CLIENT*)p; + AQH_Object_free(xo->ipcEndpoint); + GWEN_FREE_OBJECT(xo); +} + + + +int AQH_DataClient_Connect(AQH_OBJECT *o, + const char *addr, int port, + const char *userId, const char *passwd, + const char *clientId, + uint32_t flags) +{ + AQH_DATA_CLIENT *xo; + + xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_DATA_CLIENT, o); + if (xo) { + int rv; + + AQH_Object_free(xo->ipcEndpoint); + xo->ipcEndpoint=NULL; + + rv=_connectEndpoint(o, addr, port, 0 /* connection flags */); + if (rv<0) { + DBG_INFO(NULL, "here (%d)", rv); + return rv; + } + + rv=_exchangeConnectMsgs(xo, userId, passwd, clientId, flags); + if (rv<0) { + AQH_Object_free(xo->ipcEndpoint); + xo->ipcEndpoint=NULL; + DBG_INFO(NULL, "here (%d)", rv); + return rv; + } + return 0; + } + return GWEN_ERROR_INVALID; +} + + + +int AQH_DataClient_Disconnect(AQH_OBJECT *o) +{ + AQH_DATA_CLIENT *xo; + + xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_DATA_CLIENT, o); + if (xo) { + AQH_Object_free(xo->ipcEndpoint); + xo->ipcEndpoint=NULL; + return 0; + } + return GWEN_ERROR_INVALID; +} + + + +void AQH_DataClient_SetTimeout(AQH_OBJECT *o, int i) +{ + AQH_DATA_CLIENT *xo; + + xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_DATA_CLIENT, o); + if (xo) { + xo->timeoutInSeconds=i; + } +} + + + +AQH_DEVICE_LIST *AQH_DataClient_GetDevices(AQH_OBJECT *o) +{ + AQH_DATA_CLIENT *xo; + + xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_DATA_CLIENT, o); + if (xo) { + AQH_MESSAGE *msgOut; + AQH_MESSAGE *msgIn; + uint32_t msgId; + AQH_DEVICE_LIST *fullDeviceList; + + fullDeviceList=AQH_Device_List_new(); + msgId=++(xo->lastMsgId); + msgOut=AQH_IpcMessage_new(xo->protoId, xo->protoVer, AQH_MSGTYPE_IPC_DATA_GETDEVICES_REQ, msgId, 0, 0, NULL); + AQH_Endpoint_AddMsgOut(xo->ipcEndpoint, msgOut); + + while( (msgIn=AQH_IpcEndpoint_WaitForResponseMsg(xo->ipcEndpoint, msgId, xo->timeoutInSeconds)) ) { + GWEN_TAG16_LIST *tagList; + + tagList=AQH_IpcMessageTag16_ParsePayload(msgIn, 0); + if (tagList) { + uint16_t code; + + code=AQH_IpcMessage_GetCode(msgIn); + if (code==AQH_MSGTYPE_IPC_DATA_GETDEVICES_RSP) { + AQH_DEVICE_LIST *deviceList; + + deviceList=AQH_IpcdMessageDevices_ReadDeviceList(tagList); + if (deviceList) { + AQH_Device_List_AddList(fullDeviceList, deviceList); + AQH_Device_List_free(deviceList); + } + if (AQH_IpcdMessageDevices_GetFlags(tagList) & AQH_MSGDATA_DEVICES_FLAGS_LASTMSG) { + GWEN_Tag16_List_free(tagList); + AQH_Message_free(msgIn); + break; + } + } + else if (code==AQH_MSGTYPE_IPC_DATA_RESULT) { + DBG_ERROR(NULL, "Server Error: %d", AQH_IpcMessageResult_GetResult(tagList)); + GWEN_Tag16_List_free(tagList); + AQH_Message_free(msgIn); + AQH_Device_List_free(fullDeviceList); + return NULL; + } + else { + DBG_INFO(NULL, "Ignoring message \"%d\"", code); + } + GWEN_Tag16_List_free(tagList); + } + AQH_Message_free(msgIn); + } /* while */ + + if (AQH_Device_List_GetCount(fullDeviceList)>0) + return fullDeviceList; + AQH_Device_List_free(fullDeviceList); + } + return NULL; +} + + + +AQH_VALUE_LIST *AQH_DataClient_GetValues(AQH_OBJECT *o, const char *deviceName, int modality) +{ + AQH_DATA_CLIENT *xo; + + xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_DATA_CLIENT, o); + if (xo) { + AQH_MESSAGE *msgOut; + AQH_MESSAGE *msgIn; + uint32_t msgId; + AQH_VALUE_LIST *fullValueList; + + fullValueList=AQH_Value_List_new(); + msgId=++(xo->lastMsgId); + msgOut=AQH_IpcdMessageGetValues_new(AQH_MSGTYPE_IPC_DATA_GETVALUES_REQ, msgId, 0, deviceName, modality); + AQH_Endpoint_AddMsgOut(xo->ipcEndpoint, msgOut); + + while( (msgIn=AQH_IpcEndpoint_WaitForResponseMsg(xo->ipcEndpoint, msgId, xo->timeoutInSeconds)) ) { + GWEN_TAG16_LIST *tagList; + + tagList=AQH_IpcMessageTag16_ParsePayload(msgIn, 0); + if (tagList) { + uint16_t code; + + code=AQH_IpcMessage_GetCode(msgIn); + if (code==AQH_MSGTYPE_IPC_DATA_GETVALUES_RSP) { + AQH_VALUE_LIST *valueList; + + valueList=AQH_IpcdMessageValues_ReadValueList(tagList); + if (valueList) { + AQH_Value_List_AddList(fullValueList, valueList); + AQH_Value_List_free(valueList); + } + if (AQH_IpcdMessageValues_GetFlags(tagList) & AQH_MSGDATA_VALUES_FLAGS_LASTMSG) { + GWEN_Tag16_List_free(tagList); + AQH_Message_free(msgIn); + break; + } + } + else if (code==AQH_MSGTYPE_IPC_DATA_RESULT) { + DBG_ERROR(NULL, "Server Error: %d", AQH_IpcMessageResult_GetResult(tagList)); + GWEN_Tag16_List_free(tagList); + AQH_Message_free(msgIn); + AQH_Value_List_free(fullValueList); + return NULL; + } + else { + DBG_INFO(NULL, "Ignoring message \"%d\"", code); + } + GWEN_Tag16_List_free(tagList); + } + AQH_Message_free(msgIn); + } /* while */ + + if (AQH_Value_List_GetCount(fullValueList)>0) + return fullValueList; + AQH_Value_List_free(fullValueList); + } + return NULL; +} + + + +uint64_t AQH_DataClient_GetFirstData(AQH_OBJECT *o, const char *valueName, uint64_t *dataPtr, uint64_t maxNum) +{ + return _getFirstOrLastData(o, valueName, dataPtr, maxNum, AQH_MSGDATA_GETDATA_MODE_FIRST); +} + + + +uint64_t AQH_DataClient_GetLastData(AQH_OBJECT *o, const char *valueName, uint64_t *dataPtr, uint64_t maxNum) +{ + return _getFirstOrLastData(o, valueName, dataPtr, maxNum, AQH_MSGDATA_GETDATA_MODE_LAST); +} + + + +uint64_t AQH_DataClient_GetPeriodData(AQH_OBJECT *o, const char *valueName, + uint64_t *dataPtr, uint64_t maxNum, + uint64_t tsBegin, uint64_t tsEnd) +{ + AQH_DATA_CLIENT *xo; + + xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_DATA_CLIENT, o); + if (xo) { + AQH_MESSAGE *msgOut; + uint32_t msgId; + + msgId=++(xo->lastMsgId); + msgOut=AQH_IpcdMessageGetData_new(AQH_MSGTYPE_IPC_DATA_GETDATA_REQ, + msgId, 0, + AQH_MSGDATA_GETDATA_MODE_PERIOD, + valueName, tsBegin, tsEnd, maxNum); + AQH_Endpoint_AddMsgOut(xo->ipcEndpoint, msgOut); + + return _handleDataResponses(xo, dataPtr, maxNum, msgId); + } + return 0; +} + + + +int AQH_DataClient_SetData(AQH_OBJECT *o, const AQH_VALUE *v, const char *data) +{ + AQH_DATA_CLIENT *xo; + + xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_DATA_CLIENT, o); + if (xo) { + AQH_MESSAGE *msgOut; + uint32_t msgId; + + msgId=++(xo->lastMsgId); + msgOut=AQH_IpcdMessageSetData_new(AQH_MSGTYPE_IPC_DATA_SETDATA, msgId, 0, v, data); + AQH_Endpoint_AddMsgOut(xo->ipcEndpoint, msgOut); + + return _handleResult(xo, msgId); + } + + return GWEN_ERROR_INVALID; +} + + + +int AQH_DataClient_UpdateData(AQH_OBJECT *o, const AQH_VALUE *v, uint64_t timeStamp, double dataPoint) +{ + AQH_DATA_CLIENT *xo; + + xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_DATA_CLIENT, o); + if (xo) { + AQH_MESSAGE *msgOut; + uint32_t msgId; + + msgId=++(xo->lastMsgId); + msgOut=AQH_IpcdMessageMultiData_newForOne(AQH_MSGTYPE_IPC_DATA_UPDATEDATA, msgId, 0, v, timeStamp, dataPoint); + AQH_Endpoint_AddMsgOut(xo->ipcEndpoint, msgOut); + + return _handleResult(xo, msgId); + } + + return GWEN_ERROR_INVALID; +} + + + + + + +int _connectEndpoint(AQH_OBJECT *o, const char *addr, int port, uint32_t flags) +{ + AQH_DATA_CLIENT *xo; + + xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_DATA_CLIENT, o); + if (xo) { + AQH_OBJECT *ep; + int fd; + + fd=AQH_TcpObject_CreateConnectedSocket(addr, port); + if (fd<0) { + DBG_ERROR(NULL, "Error connecting to broker server %s:%d", addr, port); + return GWEN_ERROR_IO; + } + + ep=AQH_IpcClientObject_new(AQH_Object_GetEventLoop(o), fd); + assert(ep); + AQH_Endpoint_AddFlags(ep, flags); + xo->ipcEndpoint=ep; + return 0; + } + + return GWEN_ERROR_INVALID; +} + + + +int _exchangeConnectMsgs(AQH_DATA_CLIENT *xo, const char *userId, const char *passwd, const char *clientId, uint32_t flags) +{ + AQH_MESSAGE *msgOut; + uint32_t msgId; + + DBG_INFO(NULL, "Sending connect message for proto=%d.%d", xo->protoId, xo->protoVer); + msgId=AQH_Endpoint_GetNextMessageId(xo->ipcEndpoint); + msgOut=AQH_IpcMessageConnect_new(xo->protoId, xo->protoVer, + AQH_MSGTYPE_IPC_CONNECT_REQ, + msgId, 0, + clientId, userId, passwd, flags); + AQH_Endpoint_AddMsgOut(xo->ipcEndpoint, msgOut); + return AQH_IpcEndpoint_WaitForResultMsg(xo->ipcEndpoint, + xo->protoId, xo->protoVer, AQH_MSGTYPE_IPC_RESULT, + msgId, xo->timeoutInSeconds); +} + + + +uint64_t _getFirstOrLastData(AQH_OBJECT *o, const char *valueName, uint64_t *dataPtr, uint64_t maxNum, int mode) +{ + AQH_DATA_CLIENT *xo; + + xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_DATA_CLIENT, o); + if (xo) { + AQH_MESSAGE *msgOut; + uint32_t msgId; + + msgId=++(xo->lastMsgId); + msgOut=AQH_IpcdMessageGetData_new(AQH_MSGTYPE_IPC_DATA_GETDATA_REQ, + msgId, 0, + mode, + valueName, 0, 0, maxNum); + AQH_Endpoint_AddMsgOut(xo->ipcEndpoint, msgOut); + + return _handleDataResponses(xo, dataPtr, maxNum, msgId); + } + return 0; +} + + + +uint64_t _handleDataResponses(AQH_DATA_CLIENT *xo, uint64_t *dataPtr, uint64_t maxNum, uint32_t msgId) +{ + AQH_MESSAGE *msgIn; + uint64_t fullNumberOfPoints=0; + + while( (msgIn=AQH_IpcEndpoint_WaitForResponseMsg(xo->ipcEndpoint, msgId, xo->timeoutInSeconds)) ) { + GWEN_TAG16_LIST *tagList; + + tagList=AQH_IpcMessageTag16_ParsePayload(msgIn, 0); + if (tagList) { + uint16_t code; + + code=AQH_IpcMessage_GetCode(msgIn); + if (code==AQH_MSGTYPE_IPC_DATA_GETDATA_RSP) { + const uint64_t *recvDataPtr; + uint64_t recvNumberOfPoints; + + AQH_IpcdMessageMultiData_ReadDatapoints(tagList, &recvDataPtr, &recvNumberOfPoints); + if (recvNumberOfPoints) { + uint64_t i; + + for (i=0; iipcEndpoint, msgId, xo->timeoutInSeconds)) ) { + GWEN_TAG16_LIST *tagList; + + tagList=AQH_IpcMessageTag16_ParsePayload(msgIn, 0); + if (tagList) { + uint16_t code; + + code=AQH_IpcMessage_GetCode(msgIn); + if (code==AQH_MSGTYPE_IPC_DATA_RESULT) { + int result; + + result=AQH_IpcMessageResult_GetResult(tagList); + DBG_INFO(NULL, "Server result: %d", result); + GWEN_Tag16_List_free(tagList); + AQH_Message_free(msgIn); + if (result!=AQH_MSGDATA_RESULT_SUCCESS) { + DBG_INFO(NULL, "here (%d)", result); + return GWEN_ERROR_GENERIC; + } + return 0; + } + else { + DBG_INFO(NULL, "Ignoring message \"%d\"", code); + } + GWEN_Tag16_List_free(tagList); + } + AQH_Message_free(msgIn); + } /* while */ + + return GWEN_ERROR_TIMEOUT; +} + + + + + diff --git a/aqhome/dataclient/client.h b/aqhome/dataclient/client.h new file mode 100644 index 0000000..85cbb77 --- /dev/null +++ b/aqhome/dataclient/client.h @@ -0,0 +1,45 @@ +/**************************************************************************** + * This file is part of the project AqHome. + * AqHome (c) by 2025 Martin Preuss, all rights reserved. + * + * The license for this file can be found in the file COPYING which you + * should have received along with this file. + ****************************************************************************/ + +#ifndef AQHOME_DATA_CLIENT_H +#define AQHOME_DATA_CLIENT_H + +#include +#include +#include +#include + + + +AQHOME_API AQH_OBJECT *AQH_DataClient_new(AQH_EVENT_LOOP *eventLoop, uint8_t protoId, uint8_t protoVer); + +AQHOME_API void AQH_DataClient_SetTimeout(AQH_OBJECT *o, int i); + + +AQHOME_API int AQH_DataClient_Connect(AQH_OBJECT *o, + const char *addr, int port, + const char *userId, const char *passwd, + const char *clientId, + uint32_t flags); +AQHOME_API int AQH_DataClient_Disconnect(AQH_OBJECT *o); + + +AQHOME_API AQH_DEVICE_LIST *AQH_DataClient_GetDevices(AQH_OBJECT *o); +AQHOME_API AQH_VALUE_LIST *AQH_DataClient_GetValues(AQH_OBJECT *o, const char *deviceName, int modality); + +AQHOME_API uint64_t AQH_DataClient_GetFirstData(AQH_OBJECT *o, const char *valueName, uint64_t *dataPtr, uint64_t maxNum); +AQHOME_API uint64_t AQH_DataClient_GetLastData(AQH_OBJECT *o, const char *valueName, uint64_t *dataPtr, uint64_t maxNum); +AQHOME_API uint64_t AQH_DataClient_GetPeriodData(AQH_OBJECT *o, const char *valueName, + uint64_t *dataPtr, uint64_t maxNum, + uint64_t tsBegin, uint64_t tsEnd); + +AQHOME_API int AQH_DataClient_SetData(AQH_OBJECT *o, const AQH_VALUE *v, const char *data); +AQHOME_API int AQH_DataClient_UpdateData(AQH_OBJECT *o, const AQH_VALUE *v, uint64_t timeStamp, double dataPoint); + + +#endif diff --git a/aqhome/dataclient/client_p.h b/aqhome/dataclient/client_p.h new file mode 100644 index 0000000..fdfac3f --- /dev/null +++ b/aqhome/dataclient/client_p.h @@ -0,0 +1,28 @@ +/**************************************************************************** + * This file is part of the project AqHome. + * AqHome (c) by 2025 Martin Preuss, all rights reserved. + * + * The license for this file can be found in the file COPYING which you + * should have received along with this file. + ****************************************************************************/ + +#ifndef AQHOME_DATA_CLIENT_P_H +#define AQHOME_DATA_CLIENT_P_H + +#include "aqhome/dataclient/client.h" + + +typedef struct AQH_DATA_CLIENT AQH_DATA_CLIENT; +struct AQH_DATA_CLIENT { + AQH_OBJECT *ipcEndpoint; + int timeoutInSeconds; + + uint8_t protoId; + uint8_t protoVer; + + uint32_t lastMsgId; +}; + + + +#endif From cbf88e05fe8990b8329cdee58cd381d9e9ae15a7 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Wed, 25 Jun 2025 00:03:58 +0200 Subject: [PATCH 043/196] added "mode" argument to "getdata" command. --- apps/aqhome-data/s_getdatapoints.c | 104 +++++++++++++------------- apps/aqhome-tool/data/getdatapoints.c | 7 +- aqhome/msg/ipc/data/m_ipcd_getdata.c | 23 +++++- aqhome/msg/ipc/data/m_ipcd_getdata.h | 10 +++ 4 files changed, 87 insertions(+), 57 deletions(-) diff --git a/apps/aqhome-data/s_getdatapoints.c b/apps/aqhome-data/s_getdatapoints.c index f2db538..fd9993e 100644 --- a/apps/aqhome-data/s_getdatapoints.c +++ b/apps/aqhome-data/s_getdatapoints.c @@ -1,6 +1,6 @@ /**************************************************************************** * This file is part of the project AqHome. - * AqHome (c) by 2023 Martin Preuss, all rights reserved. + * AqHome (c) by 2025 Martin Preuss, all rights reserved. * * The license for this file can be found in the file COPYING which you * should have received along with this file. @@ -33,8 +33,8 @@ * ------------------------------------------------------------------------------------------------ */ -#define AQHOMEDATA_HANDLEGETDATAPOINTS_MAXTABLEENTRIES 2048 -#define AQHOMEDATA_HANDLEGETDATAPOINTS_MAXDATAPOINTS 1024 +#define AQHOMEDATA_HANDLEGETDATAPOINTS_MAXTABLEENTRIES 1024 +#define AQHOMEDATA_HANDLEGETDATAPOINTS_MAXDATAPOINTS 512 /* ------------------------------------------------------------------------------------------------ @@ -44,13 +44,15 @@ static int _getAndSendDataPoints(AQH_STORAGE *storage, AQH_OBJECT *ep, const AQH_VALUE *value, + int mode, uint64_t tsBegin, uint64_t tsEnd, uint64_t num, uint32_t refMsgId); -static int _getAndSendDataPointsNoNum(AQH_STORAGE *storage, AQH_OBJECT *ep, const AQH_VALUE *value, uint64_t tsBegin, uint64_t tsEnd, +static int _getAndSendDataPointsPeriod(AQH_STORAGE *storage, AQH_OBJECT *ep, const AQH_VALUE *value, + uint64_t tsBegin, uint64_t tsEnd, uint64_t num, uint32_t refMsgId); -static int _getAndSendDataPointsWithNum(AQH_STORAGE *storage, AQH_OBJECT *ep, const AQH_VALUE *value, uint64_t num, uint32_t refMsgId); +static int _getAndSendDataPointsFirst(AQH_STORAGE *storage, AQH_OBJECT *ep, const AQH_VALUE *value, uint64_t num, uint32_t refMsgId); +static int _getAndSendDataPointsLast(AQH_STORAGE *storage, AQH_OBJECT *ep, const AQH_VALUE *value, uint64_t num, uint32_t refMsgId); static void _sendDataPointsResponse(AQH_OBJECT *ep, const AQH_VALUE *value, const uint64_t *tablePtr, uint32_t refMsgId); -static void _getAndSendLastDatapoint(AQH_STORAGE *storage, AQH_OBJECT *ep, const AQH_VALUE *value, uint32_t refMsgId); @@ -79,16 +81,18 @@ void AqHomeDataServer_HandleGetDataPoints(AQH_OBJECT *o, AQH_OBJECT *ep, const A uint64_t tsBegin; uint64_t tsEnd; uint64_t numRequested; + int mode; tsBegin=AQH_Tag16_GetTagDataAsUint64(tagList, AQH_MSGDATA_GETDATA_TAGS_BEGIN, 0); tsEnd=AQH_Tag16_GetTagDataAsUint64(tagList, AQH_MSGDATA_GETDATA_TAGS_END, 0); numRequested=AQH_Tag16_GetTagDataAsUint64(tagList, AQH_MSGDATA_GETDATA_TAGS_NUM, 0); + mode=AQH_Tag16_GetTagDataAsUint64(tagList, AQH_MSGDATA_GETDATA_TAGS_MODE, AQH_MSGDATA_GETDATA_MODE_FIRST); value=AQH_Storage_GetValueByNameForSystem(xo->storage, valueName); if (value) { int resultCode; - resultCode=_getAndSendDataPoints(xo->storage, ep, value, tsBegin, tsEnd, numRequested, refMsgId); + resultCode=_getAndSendDataPoints(xo->storage, ep, value, mode, tsBegin, tsEnd, numRequested, refMsgId); AqHomeDataServer_SendResponseResultToEndpoint(ep, refMsgId, resultCode); } else { @@ -114,30 +118,31 @@ void AqHomeDataServer_HandleGetDataPoints(AQH_OBJECT *o, AQH_OBJECT *ep, const A int _getAndSendDataPoints(AQH_STORAGE *storage, AQH_OBJECT *ep, const AQH_VALUE *value, + int mode, uint64_t tsBegin, uint64_t tsEnd, uint64_t num, uint32_t refMsgId) { - if (num==0) - return _getAndSendDataPointsNoNum(storage, ep, value, tsBegin, tsEnd, refMsgId); - else if (num==1) { - _getAndSendLastDatapoint(storage, ep, value, refMsgId); - return AQH_MSGDATA_RESULT_SUCCESS; + switch(mode) { + case AQH_MSGDATA_GETDATA_MODE_FIRST: return _getAndSendDataPointsFirst(storage, ep, value, num, refMsgId); + case AQH_MSGDATA_GETDATA_MODE_PERIOD: return _getAndSendDataPointsPeriod(storage, ep, value, tsBegin, tsEnd, num, refMsgId); + default: + case AQH_MSGDATA_GETDATA_MODE_LAST: return _getAndSendDataPointsLast(storage, ep, value, num, refMsgId); } - else - return _getAndSendDataPointsWithNum(storage, ep, value, num, refMsgId); } -int _getAndSendDataPointsNoNum(AQH_STORAGE *storage, AQH_OBJECT *ep, - const AQH_VALUE *value, uint64_t tsBegin, uint64_t tsEnd, - uint32_t refMsgId) +int _getAndSendDataPointsPeriod(AQH_STORAGE *storage, AQH_OBJECT *ep, + const AQH_VALUE *value, uint64_t tsBegin, uint64_t tsEnd, uint64_t num, + uint32_t refMsgId) { uint64_t valueId; uint64_t *tablePtr; valueId=AQH_Value_GetId(value); - tablePtr=AQH_Storage_GetDataPoints(storage, valueId, tsBegin, tsEnd, AQHOMEDATA_HANDLEGETDATAPOINTS_MAXTABLEENTRIES); + if (num==0 || num>AQHOMEDATA_HANDLEGETDATAPOINTS_MAXTABLEENTRIES) + num=AQHOMEDATA_HANDLEGETDATAPOINTS_MAXTABLEENTRIES; + tablePtr=AQH_Storage_GetDataPoints(storage, valueId, tsBegin, tsEnd, num); if (tablePtr) { _sendDataPointsResponse(ep, value, tablePtr, refMsgId); free(tablePtr); @@ -151,9 +156,9 @@ int _getAndSendDataPointsNoNum(AQH_STORAGE *storage, AQH_OBJECT *ep, -int _getAndSendDataPointsWithNum(AQH_STORAGE *storage, AQH_OBJECT *ep, - const AQH_VALUE *value, uint64_t num, - uint32_t refMsgId) +int _getAndSendDataPointsLast(AQH_STORAGE *storage, AQH_OBJECT *ep, + const AQH_VALUE *value, uint64_t num, + uint32_t refMsgId) { uint64_t valueId; uint64_t *tablePtr; @@ -175,6 +180,30 @@ int _getAndSendDataPointsWithNum(AQH_STORAGE *storage, AQH_OBJECT *ep, +int _getAndSendDataPointsFirst(AQH_STORAGE *storage, AQH_OBJECT *ep, + const AQH_VALUE *value, uint64_t num, + uint32_t refMsgId) +{ + uint64_t valueId; + uint64_t *tablePtr; + + if (num>AQHOMEDATA_HANDLEGETDATAPOINTS_MAXDATAPOINTS) + num=AQHOMEDATA_HANDLEGETDATAPOINTS_MAXDATAPOINTS; + valueId=AQH_Value_GetId(value); + tablePtr=AQH_Storage_GetFirstNDataPoints(storage, valueId, num); + if (tablePtr) { + _sendDataPointsResponse(ep, value, tablePtr, refMsgId); + free(tablePtr); + return AQH_MSGDATA_RESULT_SUCCESS; + } + else { + DBG_INFO(NULL, "No matching datapoints for value \"%s\"", AQH_Value_GetNameForSystem(value)); + return AQH_MSGDATA_RESULT_ERROR_NODATA; + } +} + + + void _sendDataPointsResponse(AQH_OBJECT *ep, const AQH_VALUE *value, const uint64_t *tablePtr, uint32_t refMsgId) @@ -193,36 +222,3 @@ void _sendDataPointsResponse(AQH_OBJECT *ep, -void _getAndSendLastDatapoint(AQH_STORAGE *storage, AQH_OBJECT *ep, - const AQH_VALUE *value, uint32_t refMsgId) -{ - int rv; - uint64_t timestamp=0; - double data=0.0; - - rv=AQH_Storage_GetLastDataPoint(storage, AQH_Value_GetId(value), ×tamp, &data); - if (rv<0) { - int resultCode; - - switch(rv) { - case GWEN_ERROR_INVALID: resultCode=AQH_MSGDATA_RESULT_ERROR_INVALID; break; - case GWEN_ERROR_NO_DATA: resultCode=AQH_MSGDATA_RESULT_ERROR_NODATA; break; - default: resultCode=AQH_MSGDATA_RESULT_ERROR_GENERIC; break; - } - AqHomeDataServer_SendResponseResultToEndpoint(ep, refMsgId, resultCode); - } - else { - AQH_MESSAGE *outMsg; - - outMsg=AQH_IpcdMessageMultiData_newForOne(AQH_MSGTYPE_IPC_DATA_GETDATA_RSP, - AQH_Endpoint_GetNextMessageId(ep), refMsgId, - value, timestamp, data); - AQH_Endpoint_AddMsgOut(ep, outMsg); - } -} - - - - - - diff --git a/apps/aqhome-tool/data/getdatapoints.c b/apps/aqhome-tool/data/getdatapoints.c index cb4c57d..f4ebe4a 100644 --- a/apps/aqhome-tool/data/getdatapoints.c +++ b/apps/aqhome-tool/data/getdatapoints.c @@ -121,7 +121,12 @@ AQH_MESSAGE *_createRequestMessage(GWEN_UNUSED AQH_OBJECT *o, uint32_t msgId) return NULL; } - return AQH_IpcdMessageGetData_new(AQH_MSGTYPE_IPC_DATA_GETDATA_REQ, msgId, 0, valueName, tsBegin, tsEnd, num); + // TODO: use "mode" correctly + return AQH_IpcdMessageGetData_new(AQH_MSGTYPE_IPC_DATA_GETDATA_REQ, + msgId, 0, + AQH_MSGDATA_GETDATA_MODE_LAST, + valueName, + tsBegin, tsEnd, num); } diff --git a/aqhome/msg/ipc/data/m_ipcd_getdata.c b/aqhome/msg/ipc/data/m_ipcd_getdata.c index 47b85cb..dcfd0bf 100644 --- a/aqhome/msg/ipc/data/m_ipcd_getdata.c +++ b/aqhome/msg/ipc/data/m_ipcd_getdata.c @@ -28,6 +28,8 @@ * ------------------------------------------------------------------------------------------------ */ +static const char *_modeToChar(int mode); + /* ------------------------------------------------------------------------------------------------ @@ -37,6 +39,7 @@ AQH_MESSAGE *AQH_IpcdMessageGetData_new(uint16_t code, uint32_t msgId, uint32_t refMsgId, + int mode, const char *valueName, uint64_t tsBegin, uint64_t tsEnd, uint64_t num) { AQH_MESSAGE *msg; @@ -49,6 +52,7 @@ AQH_MESSAGE *AQH_IpcdMessageGetData_new(uint16_t code, GWEN_Tag16_WriteUint64TagToBuffer(AQH_MSGDATA_GETDATA_TAGS_BEGIN, tsBegin, buf); GWEN_Tag16_WriteUint64TagToBuffer(AQH_MSGDATA_GETDATA_TAGS_END, tsEnd, buf); GWEN_Tag16_WriteUint64TagToBuffer(AQH_MSGDATA_GETDATA_TAGS_NUM, num, buf); + GWEN_Tag16_WriteUint64TagToBuffer(AQH_MSGDATA_GETDATA_TAGS_MODE, mode, buf); msg=AQH_IpcMessage_new(AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, code, msgId, refMsgId, GWEN_Buffer_GetUsedBytes(buf), (const uint8_t*) GWEN_Buffer_GetStart(buf)); @@ -64,19 +68,22 @@ void AQH_IpcdMessageGetData_DumpToBuffer(const AQH_MESSAGE *msg, const GWEN_TAG1 char *valueName; uint64_t tsBegin; uint64_t tsEnd; + uint64_t mode; valueName=tagList?AQH_Tag16_GetTagDataAsNewString(tagList, AQH_MSGDATA_GETDATA_TAGS_NAME, NULL):NULL; tsBegin=tagList?AQH_Tag16_GetTagDataAsUint64(tagList, AQH_MSGDATA_GETDATA_TAGS_BEGIN, 0):0; tsEnd=tagList?AQH_Tag16_GetTagDataAsUint64(tagList, AQH_MSGDATA_GETDATA_TAGS_END, 0):0; + mode=tagList?AQH_Tag16_GetTagDataAsUint64(tagList, AQH_MSGDATA_GETDATA_TAGS_MODE, 0):0; GWEN_Buffer_AppendArgs(dbuf, - "GETDATA(%s) %s (code=%d, proto=%d, proto version=%d, name=%s, tsBegin=%lu, tsEnd=%lu)\n", + "GETDATA(%s) %s (code=%d, proto=%d, proto version=%d, name=%s, mode=%s, tsBegin=%lu, tsEnd=%lu)\n", AQH_IpcdMessage_MsgTypeToChar(AQH_IpcMessage_GetCode(msg)), sText?sText:"", AQH_IpcMessage_GetCode(msg), AQH_IpcMessage_GetProtoId(msg), AQH_IpcMessage_GetProtoVersion(msg), - valueName?valueName:"", + valueName?valueName:"", + _modeToChar(mode), (unsigned long int) tsBegin, (unsigned long int) tsEnd); free(valueName); @@ -85,3 +92,15 @@ void AQH_IpcdMessageGetData_DumpToBuffer(const AQH_MESSAGE *msg, const GWEN_TAG1 +const char *_modeToChar(int mode) +{ + switch(mode) { + case AQH_MSGDATA_GETDATA_MODE_FIRST: return "first"; + case AQH_MSGDATA_GETDATA_MODE_LAST: return "last"; + case AQH_MSGDATA_GETDATA_MODE_PERIOD: return "period"; + default: return "unknown"; + } +} + + + diff --git a/aqhome/msg/ipc/data/m_ipcd_getdata.h b/aqhome/msg/ipc/data/m_ipcd_getdata.h index 46ea85d..3993cb7 100644 --- a/aqhome/msg/ipc/data/m_ipcd_getdata.h +++ b/aqhome/msg/ipc/data/m_ipcd_getdata.h @@ -24,10 +24,20 @@ #define AQH_MSGDATA_GETDATA_TAGS_BEGIN 0x0020 #define AQH_MSGDATA_GETDATA_TAGS_END 0x0021 #define AQH_MSGDATA_GETDATA_TAGS_NUM 0x0022 +#define AQH_MSGDATA_GETDATA_TAGS_MODE 0x0023 + + +enum { + AQH_MSGDATA_GETDATA_MODE_FIRST=0, + AQH_MSGDATA_GETDATA_MODE_LAST, + AQH_MSGDATA_GETDATA_MODE_PERIOD +}; + AQHOME_API AQH_MESSAGE *AQH_IpcdMessageGetData_new(uint16_t code, uint32_t msgId, uint32_t refMsgId, + int mode, const char *valueName, uint64_t tsBegin, uint64_t tsEnd, uint64_t num); AQHOME_API void AQH_IpcdMessageGetData_DumpToBuffer(const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList, From bf508712083ab5b495edd98f0d7d6d1b5c838051 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Wed, 25 Jun 2025 00:05:19 +0200 Subject: [PATCH 044/196] n25: use pin PA5 to select led strip driver to use does nothing for now but will later allow to select between SK6812 and SPI. --- avr/devices/n25/defs.asm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/avr/devices/n25/defs.asm b/avr/devices/n25/defs.asm index 093348b..1ad3575 100644 --- a/avr/devices/n25/defs.asm +++ b/avr/devices/n25/defs.asm @@ -17,7 +17,7 @@ ; PB3 4 11 PA2 ; PB2 5 10 PA3 LED ; COM_ATTN PA7 6 9 PA4 LED_CLK -; LED_DATA PA6 7 8 PA5 +; LED_DATA PA6 7 8 PA5 LED_Mode (0 for SPI) ; -------- ; ; *************************************************************************** @@ -80,6 +80,16 @@ .equ OWI_PINNUM = PORTB0 + +; --------------------------------------------------------------------------- +; LED mode pin + +.equ LED_MODE_DDR = DDRA +.equ LED_MODE_PORTOUT = PORTA +.equ LED_MODE_PORTIN = PINA +.equ LED_MODE_PINNUM = PORTA5 + + ; --------------------------------------------------------------------------- ; SK6812 From 81721ab7eb5c3d5664841d66e5ca0a6ab03c14f6 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Wed, 25 Jun 2025 00:05:47 +0200 Subject: [PATCH 045/196] avr: added device n27. --- avr/devices/0BUILD | 1 + avr/devices/n27/.gitignore | 2 + avr/devices/n27/0BUILD | 22 ++++ avr/devices/n27/README | 15 +++ avr/devices/n27/aqua_n27.xml | 27 ++++ avr/devices/n27/boot/0BUILD | 32 +++++ avr/devices/n27/boot/boot.asm | 157 ++++++++++++++++++++++++ avr/devices/n27/defs.asm | 159 ++++++++++++++++++++++++ avr/devices/n27/main/0BUILD | 34 ++++++ avr/devices/n27/main/data.asm | 14 +++ avr/devices/n27/main/main.asm | 224 ++++++++++++++++++++++++++++++++++ 11 files changed, 687 insertions(+) create mode 100644 avr/devices/n27/.gitignore create mode 100644 avr/devices/n27/0BUILD create mode 100644 avr/devices/n27/README create mode 100644 avr/devices/n27/aqua_n27.xml create mode 100644 avr/devices/n27/boot/0BUILD create mode 100644 avr/devices/n27/boot/boot.asm create mode 100644 avr/devices/n27/defs.asm create mode 100644 avr/devices/n27/main/0BUILD create mode 100644 avr/devices/n27/main/data.asm create mode 100644 avr/devices/n27/main/main.asm diff --git a/avr/devices/0BUILD b/avr/devices/0BUILD index 6a380c1..9662863 100644 --- a/avr/devices/0BUILD +++ b/avr/devices/0BUILD @@ -36,6 +36,7 @@ n24 n25 n26 + n27 t03 diff --git a/avr/devices/n27/.gitignore b/avr/devices/n27/.gitignore new file mode 100644 index 0000000..8e0618c --- /dev/null +++ b/avr/devices/n27/.gitignore @@ -0,0 +1,2 @@ +*.eep.hex +*.obj diff --git a/avr/devices/n27/0BUILD b/avr/devices/n27/0BUILD new file mode 100644 index 0000000..081044b --- /dev/null +++ b/avr/devices/n27/0BUILD @@ -0,0 +1,22 @@ + + + + + + boot + main + + + + aqua_n27.xml + + + + defs.asm + README + + + + + + diff --git a/avr/devices/n27/README b/avr/devices/n27/README new file mode 100644 index 0000000..f79221c --- /dev/null +++ b/avr/devices/n27/README @@ -0,0 +1,15 @@ + +N27 +=== + +- Role: Air quality and climate sensors +- MCU: AtTiny84 +- Connection: RJ45 +- Predecessor: N24, N23, N19 +- Periphery: + - PIR sensor (AMN31112) + - TWI interface + - SI7021 temperature and humidity sensor + or + - SGP-30/40 air quality sensor + diff --git a/avr/devices/n27/aqua_n27.xml b/avr/devices/n27/aqua_n27.xml new file mode 100644 index 0000000..9238a60 --- /dev/null +++ b/avr/devices/n27/aqua_n27.xml @@ -0,0 +1,27 @@ + + + AQUA + N + 27 + + + + + + + + + + + + + + + + + + + + + + diff --git a/avr/devices/n27/boot/0BUILD b/avr/devices/n27/boot/0BUILD new file mode 100644 index 0000000..444ac6f --- /dev/null +++ b/avr/devices/n27/boot/0BUILD @@ -0,0 +1,32 @@ + + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + boot.asm + + + + + + + + + + + + + + + + diff --git a/avr/devices/n27/boot/boot.asm b/avr/devices/n27/boot/boot.asm new file mode 100644 index 0000000..767f207 --- /dev/null +++ b/avr/devices/n27/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/n27/main/data.asm b/avr/devices/n27/main/data.asm new file mode 100644 index 0000000..31ccc2f --- /dev/null +++ b/avr/devices/n27/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/n27/main/main.asm b/avr/devices/n27/main/main.asm new file mode 100644 index 0000000..7a1e810 --- /dev/null +++ b/avr/devices/n27/main/main.asm @@ -0,0 +1,224 @@ +; *************************************************************************** +; 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 MODULES_BRIGHTNESS + +#define APPS_NETWORK +#define APPS_MOTION +#define APPS_REPORTSENSORS +#define APPS_STATS + + + +; --------------------------------------------------------------------------- +; defines for values + +.equ VALUE_ID_SI7021_TEMP = 0x01 +.equ VALUE_ID_SI7021_HUM = 0x02 + +.equ VALUE_ID_ADC = 0x03 +;.equ VALUE_ID_DS18B20_TEMP = 0x06 +.equ VALUE_ID_MOTION = 0x07 + +.equ VALUE_ID_SGP40_TVOC = 0x08 + +.equ VALUE_ID_SGP30_TVOC = 0x09 +.equ VALUE_ID_SGP30_CO2 = 0x0a + +.equ VALUE_ID_BRIGHTNESS = 0x0b + +;.equ VALUE_ID_REED_CONF = 0x81 + +.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 + + + From 688129cf08f271e59876e16f06d17395ffdccff2 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Wed, 25 Jun 2025 00:09:41 +0200 Subject: [PATCH 046/196] added n27 to flash script. --- flashnode.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/flashnode.sh b/flashnode.sh index 8c0ee7c..4e0116d 100755 --- a/flashnode.sh +++ b/flashnode.sh @@ -86,6 +86,13 @@ case $NODE in EFUSE_ARG="-U efuse:w:0xFE:m" FILE_ARG="-U flash:w:./0-build/avr/devices/n26/boot/n26_boot.hex" ;; + n27) + DEVICE_ARG="-p t84" + 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/n27/boot/n27_boot.hex" + ;; t03) DEVICE_ARG="-p t841" HFUSE_ARG="-U hfuse:w:0xD7:m" From 2ba802bb060f24504c1b936e2870d54eb39ff155 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Thu, 26 Jun 2025 00:16:52 +0200 Subject: [PATCH 047/196] More work on dataclient library. --- aqhome/dataclient/client.c | 283 ++++++++++++++++++++--------------- aqhome/dataclient/client.h | 36 +++-- aqhome/dataclient/client_p.h | 8 +- 3 files changed, 189 insertions(+), 138 deletions(-) diff --git a/aqhome/dataclient/client.c b/aqhome/dataclient/client.c index 780265a..d590a5d 100644 --- a/aqhome/dataclient/client.c +++ b/aqhome/dataclient/client.c @@ -12,6 +12,7 @@ #include "./client_p.h" +#include "aqhome/aqhome.h" #include "aqhome/msg/ipc/m_ipc.h" #include "aqhome/msg/ipc/m_ipc_tag16.h" #include "aqhome/msg/ipc/m_ipc_result.h" @@ -31,84 +32,116 @@ #include #include #include +#include +#include #define AQH_DATA_CLIENT_DEFAULT_CMD_TIMEOUT 5 -GWEN_INHERIT(AQH_OBJECT, AQH_DATA_CLIENT) - - - - -static void GWENHYWFAR_CB _freeData(void *bp, void *p); - -static int _connectEndpoint(AQH_OBJECT *o, const char *addr, int port, uint32_t flags); -static int _exchangeConnectMsgs(AQH_DATA_CLIENT *xo, const char *userId, const char *passwd, const char *clientId, uint32_t flags); -static uint64_t _getFirstOrLastData(AQH_OBJECT *o, const char *valueName, uint64_t *dataPtr, uint64_t maxNum, int mode); -static uint64_t _handleDataResponses(AQH_DATA_CLIENT *xo, uint64_t *dataPtr, uint64_t maxNum, uint32_t msgId); -static int _handleResult(AQH_DATA_CLIENT *xo, uint32_t msgId); +static int _connectEndpoint(AQH_DATACLIENT *dc, const char *addr, int port, uint32_t flags); +static int _exchangeConnectMsgs(AQH_DATACLIENT *dc, const char *userId, const char *passwd, const char *clientId, uint32_t flags); +static uint64_t _getFirstOrLastData(AQH_DATACLIENT *dc, const char *valueName, uint64_t *dataPtr, uint64_t maxNum, int mode); +static uint64_t _handleDataResponses(AQH_DATACLIENT *dc, uint64_t *dataPtr, uint64_t maxNum, uint32_t msgId); +static int _handleResult(AQH_DATACLIENT *dc, uint32_t msgId); -AQH_OBJECT *AQH_DataClient_new(AQH_EVENT_LOOP *eventLoop, uint8_t protoId, uint8_t protoVer) +AQH_DATACLIENT *AQH_DataClient_new(AQH_EVENT_LOOP *eventLoop, uint8_t protoId, uint8_t protoVer) { - AQH_OBJECT *o; - AQH_DATA_CLIENT *xo; + AQH_DATACLIENT *dc; - o=AQH_Object_new(eventLoop); - GWEN_NEW_OBJECT(AQH_DATA_CLIENT, xo); - GWEN_INHERIT_SETDATA(AQH_OBJECT, AQH_DATA_CLIENT, o, xo, _freeData); + GWEN_NEW_OBJECT(AQH_DATACLIENT, dc); - xo->protoId=protoId; - xo->protoVer=protoVer; - xo->timeoutInSeconds=AQH_DATA_CLIENT_DEFAULT_CMD_TIMEOUT; + dc->eventLoop=eventLoop; + dc->protoId=protoId; + dc->protoVer=protoVer; + dc->timeoutInSeconds=AQH_DATA_CLIENT_DEFAULT_CMD_TIMEOUT; - return 0; + return dc; } -void GWENHYWFAR_CB _freeData(GWEN_UNUSED void *bp, void *p) +void AQH_DataClient_free(AQH_DATACLIENT *dc) { - AQH_DATA_CLIENT *xo; - - xo=(AQH_DATA_CLIENT*)p; - AQH_Object_free(xo->ipcEndpoint); - GWEN_FREE_OBJECT(xo); + if (dc) { + AQH_Object_free(dc->ipcEndpoint); + GWEN_FREE_OBJECT(dc); + } } -int AQH_DataClient_Connect(AQH_OBJECT *o, +int AQH_DataClient_ReadLocalArgs(AQH_DATACLIENT *dc, + GWEN_DB_NODE *dbGlobalArgs, const GWEN_ARGS *args, + int argc, char **argv) +{ + if (dc) { + int rv; + + GWEN_DB_Group_free(dc->dbLocalArgs); + dc->dbLocalArgs=GWEN_DB_GetGroup(dbGlobalArgs, GWEN_DB_FLAGS_DEFAULT, "local"); + rv=GWEN_Args_Check(argc, argv, 1, GWEN_ARGS_MODE_ALLOW_FREEPARAM, args, dc->dbLocalArgs); + if (rv==GWEN_ARGS_RESULT_ERROR) { + fprintf(stderr, "ERROR: Could not parse arguments\n"); + return 1; + } + else if (rv==GWEN_ARGS_RESULT_HELP) { + GWEN_BUFFER *ubuf; + + ubuf=GWEN_Buffer_new(0, 1024, 0, 1); + if (GWEN_Args_Usage(args, ubuf, GWEN_ArgsOutType_Txt)) { + fprintf(stderr, "ERROR: Could not create help string\n"); + return 1; + } + fprintf(stderr, "%s\n", GWEN_Buffer_GetStart(ubuf)); + GWEN_Buffer_free(ubuf); + return 1; + } + dc->timeoutInSeconds=GWEN_DB_GetIntValue(dc->dbLocalArgs, "timeout", 0, 5); + + AQH_MergeConfigFileIntoConfig(dc->dbLocalArgs, "ConfigFile"); + return 0; + } + return GWEN_ERROR_INVALID; +} + + + +GWEN_DB_NODE *AQH_DataClient_GetDbLocalArgs(const AQH_DATACLIENT *dc) +{ + return dc?dc->dbLocalArgs:NULL; +} + + + +int AQH_DataClient_Connect(AQH_DATACLIENT *dc, const char *addr, int port, const char *userId, const char *passwd, const char *clientId, uint32_t flags) { - AQH_DATA_CLIENT *xo; - - xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_DATA_CLIENT, o); - if (xo) { + if (dc) { int rv; - AQH_Object_free(xo->ipcEndpoint); - xo->ipcEndpoint=NULL; + AQH_Object_free(dc->ipcEndpoint); + dc->ipcEndpoint=NULL; - rv=_connectEndpoint(o, addr, port, 0 /* connection flags */); + rv=_connectEndpoint(dc, addr, port, 0 /* connection flags */); if (rv<0) { DBG_INFO(NULL, "here (%d)", rv); return rv; } - rv=_exchangeConnectMsgs(xo, userId, passwd, clientId, flags); + rv=_exchangeConnectMsgs(dc, userId, passwd, clientId, flags); if (rv<0) { - AQH_Object_free(xo->ipcEndpoint); - xo->ipcEndpoint=NULL; + AQH_Object_free(dc->ipcEndpoint); + dc->ipcEndpoint=NULL; DBG_INFO(NULL, "here (%d)", rv); return rv; } @@ -119,14 +152,11 @@ int AQH_DataClient_Connect(AQH_OBJECT *o, -int AQH_DataClient_Disconnect(AQH_OBJECT *o) +int AQH_DataClient_Disconnect(AQH_DATACLIENT *dc) { - AQH_DATA_CLIENT *xo; - - xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_DATA_CLIENT, o); - if (xo) { - AQH_Object_free(xo->ipcEndpoint); - xo->ipcEndpoint=NULL; + if (dc) { + AQH_Object_free(dc->ipcEndpoint); + dc->ipcEndpoint=NULL; return 0; } return GWEN_ERROR_INVALID; @@ -134,35 +164,29 @@ int AQH_DataClient_Disconnect(AQH_OBJECT *o) -void AQH_DataClient_SetTimeout(AQH_OBJECT *o, int i) +void AQH_DataClient_SetTimeout(AQH_DATACLIENT *dc, int i) { - AQH_DATA_CLIENT *xo; - - xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_DATA_CLIENT, o); - if (xo) { - xo->timeoutInSeconds=i; + if (dc) { + dc->timeoutInSeconds=i; } } -AQH_DEVICE_LIST *AQH_DataClient_GetDevices(AQH_OBJECT *o) +AQH_DEVICE_LIST *AQH_DataClient_GetDevices(AQH_DATACLIENT *dc) { - AQH_DATA_CLIENT *xo; - - xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_DATA_CLIENT, o); - if (xo) { + if (dc) { AQH_MESSAGE *msgOut; AQH_MESSAGE *msgIn; uint32_t msgId; AQH_DEVICE_LIST *fullDeviceList; fullDeviceList=AQH_Device_List_new(); - msgId=++(xo->lastMsgId); - msgOut=AQH_IpcMessage_new(xo->protoId, xo->protoVer, AQH_MSGTYPE_IPC_DATA_GETDEVICES_REQ, msgId, 0, 0, NULL); - AQH_Endpoint_AddMsgOut(xo->ipcEndpoint, msgOut); + msgId=++(dc->lastMsgId); + msgOut=AQH_IpcMessage_new(dc->protoId, dc->protoVer, AQH_MSGTYPE_IPC_DATA_GETDEVICES_REQ, msgId, 0, 0, NULL); + AQH_Endpoint_AddMsgOut(dc->ipcEndpoint, msgOut); - while( (msgIn=AQH_IpcEndpoint_WaitForResponseMsg(xo->ipcEndpoint, msgId, xo->timeoutInSeconds)) ) { + while( (msgIn=AQH_IpcEndpoint_WaitForResponseMsg(dc->ipcEndpoint, msgId, dc->timeoutInSeconds)) ) { GWEN_TAG16_LIST *tagList; tagList=AQH_IpcMessageTag16_ParsePayload(msgIn, 0); @@ -208,23 +232,20 @@ AQH_DEVICE_LIST *AQH_DataClient_GetDevices(AQH_OBJECT *o) -AQH_VALUE_LIST *AQH_DataClient_GetValues(AQH_OBJECT *o, const char *deviceName, int modality) +AQH_VALUE_LIST *AQH_DataClient_GetValues(AQH_DATACLIENT *dc, const char *deviceName, int modality) { - AQH_DATA_CLIENT *xo; - - xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_DATA_CLIENT, o); - if (xo) { + if (dc) { AQH_MESSAGE *msgOut; AQH_MESSAGE *msgIn; uint32_t msgId; AQH_VALUE_LIST *fullValueList; fullValueList=AQH_Value_List_new(); - msgId=++(xo->lastMsgId); + msgId=++(dc->lastMsgId); msgOut=AQH_IpcdMessageGetValues_new(AQH_MSGTYPE_IPC_DATA_GETVALUES_REQ, msgId, 0, deviceName, modality); - AQH_Endpoint_AddMsgOut(xo->ipcEndpoint, msgOut); + AQH_Endpoint_AddMsgOut(dc->ipcEndpoint, msgOut); - while( (msgIn=AQH_IpcEndpoint_WaitForResponseMsg(xo->ipcEndpoint, msgId, xo->timeoutInSeconds)) ) { + while( (msgIn=AQH_IpcEndpoint_WaitForResponseMsg(dc->ipcEndpoint, msgId, dc->timeoutInSeconds)) ) { GWEN_TAG16_LIST *tagList; tagList=AQH_IpcMessageTag16_ParsePayload(msgIn, 0); @@ -270,59 +291,53 @@ AQH_VALUE_LIST *AQH_DataClient_GetValues(AQH_OBJECT *o, const char *deviceName, -uint64_t AQH_DataClient_GetFirstData(AQH_OBJECT *o, const char *valueName, uint64_t *dataPtr, uint64_t maxNum) +uint64_t AQH_DataClient_GetFirstData(AQH_DATACLIENT *dc, const char *valueName, uint64_t *dataPtr, uint64_t maxNum) { - return _getFirstOrLastData(o, valueName, dataPtr, maxNum, AQH_MSGDATA_GETDATA_MODE_FIRST); + return _getFirstOrLastData(dc, valueName, dataPtr, maxNum, AQH_MSGDATA_GETDATA_MODE_FIRST); } -uint64_t AQH_DataClient_GetLastData(AQH_OBJECT *o, const char *valueName, uint64_t *dataPtr, uint64_t maxNum) +uint64_t AQH_DataClient_GetLastData(AQH_DATACLIENT *dc, const char *valueName, uint64_t *dataPtr, uint64_t maxNum) { - return _getFirstOrLastData(o, valueName, dataPtr, maxNum, AQH_MSGDATA_GETDATA_MODE_LAST); + return _getFirstOrLastData(dc, valueName, dataPtr, maxNum, AQH_MSGDATA_GETDATA_MODE_LAST); } -uint64_t AQH_DataClient_GetPeriodData(AQH_OBJECT *o, const char *valueName, +uint64_t AQH_DataClient_GetPeriodData(AQH_DATACLIENT *dc, const char *valueName, uint64_t *dataPtr, uint64_t maxNum, uint64_t tsBegin, uint64_t tsEnd) { - AQH_DATA_CLIENT *xo; - - xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_DATA_CLIENT, o); - if (xo) { + if (dc) { AQH_MESSAGE *msgOut; uint32_t msgId; - msgId=++(xo->lastMsgId); + msgId=++(dc->lastMsgId); msgOut=AQH_IpcdMessageGetData_new(AQH_MSGTYPE_IPC_DATA_GETDATA_REQ, msgId, 0, AQH_MSGDATA_GETDATA_MODE_PERIOD, valueName, tsBegin, tsEnd, maxNum); - AQH_Endpoint_AddMsgOut(xo->ipcEndpoint, msgOut); + AQH_Endpoint_AddMsgOut(dc->ipcEndpoint, msgOut); - return _handleDataResponses(xo, dataPtr, maxNum, msgId); + return _handleDataResponses(dc, dataPtr, maxNum, msgId); } return 0; } -int AQH_DataClient_SetData(AQH_OBJECT *o, const AQH_VALUE *v, const char *data) +int AQH_DataClient_SetData(AQH_DATACLIENT *dc, const AQH_VALUE *v, const char *data) { - AQH_DATA_CLIENT *xo; - - xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_DATA_CLIENT, o); - if (xo) { + if (dc) { AQH_MESSAGE *msgOut; uint32_t msgId; - msgId=++(xo->lastMsgId); + msgId=++(dc->lastMsgId); msgOut=AQH_IpcdMessageSetData_new(AQH_MSGTYPE_IPC_DATA_SETDATA, msgId, 0, v, data); - AQH_Endpoint_AddMsgOut(xo->ipcEndpoint, msgOut); + AQH_Endpoint_AddMsgOut(dc->ipcEndpoint, msgOut); - return _handleResult(xo, msgId); + return _handleResult(dc, msgId); } return GWEN_ERROR_INVALID; @@ -330,20 +345,17 @@ int AQH_DataClient_SetData(AQH_OBJECT *o, const AQH_VALUE *v, const char *data) -int AQH_DataClient_UpdateData(AQH_OBJECT *o, const AQH_VALUE *v, uint64_t timeStamp, double dataPoint) +int AQH_DataClient_UpdateData(AQH_DATACLIENT *dc, const AQH_VALUE *v, uint64_t timeStamp, double dataPoint) { - AQH_DATA_CLIENT *xo; - - xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_DATA_CLIENT, o); - if (xo) { + if (dc) { AQH_MESSAGE *msgOut; uint32_t msgId; - msgId=++(xo->lastMsgId); + msgId=++(dc->lastMsgId); msgOut=AQH_IpcdMessageMultiData_newForOne(AQH_MSGTYPE_IPC_DATA_UPDATEDATA, msgId, 0, v, timeStamp, dataPoint); - AQH_Endpoint_AddMsgOut(xo->ipcEndpoint, msgOut); + AQH_Endpoint_AddMsgOut(dc->ipcEndpoint, msgOut); - return _handleResult(xo, msgId); + return _handleResult(dc, msgId); } return GWEN_ERROR_INVALID; @@ -354,12 +366,9 @@ int AQH_DataClient_UpdateData(AQH_OBJECT *o, const AQH_VALUE *v, uint64_t timeSt -int _connectEndpoint(AQH_OBJECT *o, const char *addr, int port, uint32_t flags) +int _connectEndpoint(AQH_DATACLIENT *dc, const char *addr, int port, uint32_t flags) { - AQH_DATA_CLIENT *xo; - - xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_DATA_CLIENT, o); - if (xo) { + if (dc) { AQH_OBJECT *ep; int fd; @@ -369,10 +378,10 @@ int _connectEndpoint(AQH_OBJECT *o, const char *addr, int port, uint32_t flags) return GWEN_ERROR_IO; } - ep=AQH_IpcClientObject_new(AQH_Object_GetEventLoop(o), fd); + ep=AQH_IpcClientObject_new(dc->eventLoop, fd); assert(ep); AQH_Endpoint_AddFlags(ep, flags); - xo->ipcEndpoint=ep; + dc->ipcEndpoint=ep; return 0; } @@ -381,54 +390,51 @@ int _connectEndpoint(AQH_OBJECT *o, const char *addr, int port, uint32_t flags) -int _exchangeConnectMsgs(AQH_DATA_CLIENT *xo, const char *userId, const char *passwd, const char *clientId, uint32_t flags) +int _exchangeConnectMsgs(AQH_DATACLIENT *dc, const char *userId, const char *passwd, const char *clientId, uint32_t flags) { AQH_MESSAGE *msgOut; uint32_t msgId; - DBG_INFO(NULL, "Sending connect message for proto=%d.%d", xo->protoId, xo->protoVer); - msgId=AQH_Endpoint_GetNextMessageId(xo->ipcEndpoint); - msgOut=AQH_IpcMessageConnect_new(xo->protoId, xo->protoVer, + DBG_INFO(NULL, "Sending connect message for proto=%d.%d", dc->protoId, dc->protoVer); + msgId=AQH_Endpoint_GetNextMessageId(dc->ipcEndpoint); + msgOut=AQH_IpcMessageConnect_new(dc->protoId, dc->protoVer, AQH_MSGTYPE_IPC_CONNECT_REQ, msgId, 0, clientId, userId, passwd, flags); - AQH_Endpoint_AddMsgOut(xo->ipcEndpoint, msgOut); - return AQH_IpcEndpoint_WaitForResultMsg(xo->ipcEndpoint, - xo->protoId, xo->protoVer, AQH_MSGTYPE_IPC_RESULT, - msgId, xo->timeoutInSeconds); + AQH_Endpoint_AddMsgOut(dc->ipcEndpoint, msgOut); + return AQH_IpcEndpoint_WaitForResultMsg(dc->ipcEndpoint, + dc->protoId, dc->protoVer, AQH_MSGTYPE_IPC_RESULT, + msgId, dc->timeoutInSeconds); } -uint64_t _getFirstOrLastData(AQH_OBJECT *o, const char *valueName, uint64_t *dataPtr, uint64_t maxNum, int mode) +uint64_t _getFirstOrLastData(AQH_DATACLIENT *dc, const char *valueName, uint64_t *dataPtr, uint64_t maxNum, int mode) { - AQH_DATA_CLIENT *xo; - - xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_DATA_CLIENT, o); - if (xo) { + if (dc) { AQH_MESSAGE *msgOut; uint32_t msgId; - msgId=++(xo->lastMsgId); + msgId=++(dc->lastMsgId); msgOut=AQH_IpcdMessageGetData_new(AQH_MSGTYPE_IPC_DATA_GETDATA_REQ, msgId, 0, mode, valueName, 0, 0, maxNum); - AQH_Endpoint_AddMsgOut(xo->ipcEndpoint, msgOut); + AQH_Endpoint_AddMsgOut(dc->ipcEndpoint, msgOut); - return _handleDataResponses(xo, dataPtr, maxNum, msgId); + return _handleDataResponses(dc, dataPtr, maxNum, msgId); } return 0; } -uint64_t _handleDataResponses(AQH_DATA_CLIENT *xo, uint64_t *dataPtr, uint64_t maxNum, uint32_t msgId) +uint64_t _handleDataResponses(AQH_DATACLIENT *dc, uint64_t *dataPtr, uint64_t maxNum, uint32_t msgId) { AQH_MESSAGE *msgIn; uint64_t fullNumberOfPoints=0; - while( (msgIn=AQH_IpcEndpoint_WaitForResponseMsg(xo->ipcEndpoint, msgId, xo->timeoutInSeconds)) ) { + while( (msgIn=AQH_IpcEndpoint_WaitForResponseMsg(dc->ipcEndpoint, msgId, dc->timeoutInSeconds)) ) { GWEN_TAG16_LIST *tagList; tagList=AQH_IpcMessageTag16_ParsePayload(msgIn, 0); @@ -478,11 +484,11 @@ uint64_t _handleDataResponses(AQH_DATA_CLIENT *xo, uint64_t *dataPtr, uint64_t m -int _handleResult(AQH_DATA_CLIENT *xo, uint32_t msgId) +int _handleResult(AQH_DATACLIENT *dc, uint32_t msgId) { AQH_MESSAGE *msgIn; - while( (msgIn=AQH_IpcEndpoint_WaitForResponseMsg(xo->ipcEndpoint, msgId, xo->timeoutInSeconds)) ) { + while( (msgIn=AQH_IpcEndpoint_WaitForResponseMsg(dc->ipcEndpoint, msgId, dc->timeoutInSeconds)) ) { GWEN_TAG16_LIST *tagList; tagList=AQH_IpcMessageTag16_ParsePayload(msgIn, 0); @@ -517,4 +523,33 @@ int _handleResult(AQH_DATA_CLIENT *xo, uint32_t msgId) +int AQH_DataClient_ConnectWithArgs(AQH_DATACLIENT *dc, uint32_t flags) +{ + const char *brokerAddress; + int brokerPort; + const char *userId; + const char *passwd; + const char *clientId; + int rv; + + brokerAddress=GWEN_DB_GetCharValue(dc->dbLocalArgs, "brokerAddress", 0, NULL); + if (!(brokerAddress && *brokerAddress)) + brokerAddress=GWEN_DB_GetCharValue(dc->dbLocalArgs, "ConfigFile/brokerAddress", 0, "127.0.0.1"); + + brokerPort=GWEN_DB_GetIntValue(dc->dbLocalArgs, "brokerPort", 0, -1); + if (brokerPort<0) + brokerPort=GWEN_DB_GetIntValue(dc->dbLocalArgs, "ConfigFile/brokerPort", 0, 45456); + + userId=GWEN_DB_GetCharValue(dc->dbLocalArgs, "userId", 0, NULL); + passwd=GWEN_DB_GetCharValue(dc->dbLocalArgs, "password", 0, NULL); + clientId=GWEN_DB_GetCharValue(dc->dbLocalArgs, "brokerClientId", 0, NULL); + + rv=AQH_DataClient_Connect(dc, brokerAddress, brokerPort, userId, passwd, clientId, flags); + if (rv<0) { + DBG_INFO(NULL, "here (%d)", rv); + return rv; + } + + return 0; +} diff --git a/aqhome/dataclient/client.h b/aqhome/dataclient/client.h index 85cbb77..05db794 100644 --- a/aqhome/dataclient/client.h +++ b/aqhome/dataclient/client.h @@ -14,32 +14,44 @@ #include #include +#include -AQHOME_API AQH_OBJECT *AQH_DataClient_new(AQH_EVENT_LOOP *eventLoop, uint8_t protoId, uint8_t protoVer); - -AQHOME_API void AQH_DataClient_SetTimeout(AQH_OBJECT *o, int i); +typedef struct AQH_DATACLIENT AQH_DATACLIENT; -AQHOME_API int AQH_DataClient_Connect(AQH_OBJECT *o, +AQHOME_API AQH_DATACLIENT *AQH_DataClient_new(AQH_EVENT_LOOP *eventLoop, uint8_t protoId, uint8_t protoVer); +AQHOME_API void AQH_DataClient_free(AQH_DATACLIENT *dc); + +AQHOME_API void AQH_DataClient_SetTimeout(AQH_DATACLIENT *dc, int i); + + +AQHOME_API int AQH_DataClient_Connect(AQH_DATACLIENT *dc, const char *addr, int port, const char *userId, const char *passwd, const char *clientId, uint32_t flags); -AQHOME_API int AQH_DataClient_Disconnect(AQH_OBJECT *o); +AQHOME_API int AQH_DataClient_Disconnect(AQH_DATACLIENT *dc); -AQHOME_API AQH_DEVICE_LIST *AQH_DataClient_GetDevices(AQH_OBJECT *o); -AQHOME_API AQH_VALUE_LIST *AQH_DataClient_GetValues(AQH_OBJECT *o, const char *deviceName, int modality); +AQHOME_API AQH_DEVICE_LIST *AQH_DataClient_GetDevices(AQH_DATACLIENT *dc); +AQHOME_API AQH_VALUE_LIST *AQH_DataClient_GetValues(AQH_DATACLIENT *dc, const char *deviceName, int modality); -AQHOME_API uint64_t AQH_DataClient_GetFirstData(AQH_OBJECT *o, const char *valueName, uint64_t *dataPtr, uint64_t maxNum); -AQHOME_API uint64_t AQH_DataClient_GetLastData(AQH_OBJECT *o, const char *valueName, uint64_t *dataPtr, uint64_t maxNum); -AQHOME_API uint64_t AQH_DataClient_GetPeriodData(AQH_OBJECT *o, const char *valueName, +AQHOME_API uint64_t AQH_DataClient_GetFirstData(AQH_DATACLIENT *dc, const char *valueName, uint64_t *dataPtr, uint64_t maxNum); +AQHOME_API uint64_t AQH_DataClient_GetLastData(AQH_DATACLIENT *dc, const char *valueName, uint64_t *dataPtr, uint64_t maxNum); +AQHOME_API uint64_t AQH_DataClient_GetPeriodData(AQH_DATACLIENT *dc, const char *valueName, uint64_t *dataPtr, uint64_t maxNum, uint64_t tsBegin, uint64_t tsEnd); -AQHOME_API int AQH_DataClient_SetData(AQH_OBJECT *o, const AQH_VALUE *v, const char *data); -AQHOME_API int AQH_DataClient_UpdateData(AQH_OBJECT *o, const AQH_VALUE *v, uint64_t timeStamp, double dataPoint); +AQHOME_API int AQH_DataClient_SetData(AQH_DATACLIENT *dc, const AQH_VALUE *v, const char *data); +AQHOME_API int AQH_DataClient_UpdateData(AQH_DATACLIENT *dc, const AQH_VALUE *v, uint64_t timeStamp, double dataPoint); + + +AQHOME_API int AQH_DataClient_ReadLocalArgs(AQH_DATACLIENT *dc, + GWEN_DB_NODE *dbGlobalArgs, const GWEN_ARGS *argDescrs, + int argc, char **argv); +AQHOME_API int AQH_DataClient_ConnectWithArgs(AQH_DATACLIENT *dc, uint32_t flags); +AQHOME_API GWEN_DB_NODE *AQH_DataClient_GetDbLocalArgs(const AQH_DATACLIENT *dc); #endif diff --git a/aqhome/dataclient/client_p.h b/aqhome/dataclient/client_p.h index fdfac3f..b62eadd 100644 --- a/aqhome/dataclient/client_p.h +++ b/aqhome/dataclient/client_p.h @@ -12,8 +12,9 @@ #include "aqhome/dataclient/client.h" -typedef struct AQH_DATA_CLIENT AQH_DATA_CLIENT; -struct AQH_DATA_CLIENT { +struct AQH_DATACLIENT { + AQH_EVENT_LOOP *eventLoop; + AQH_OBJECT *ipcEndpoint; int timeoutInSeconds; @@ -21,6 +22,9 @@ struct AQH_DATA_CLIENT { uint8_t protoVer; uint32_t lastMsgId; + + GWEN_DB_NODE *dbLocalArgs; + }; From 68ee24621693f70aa55fd527a4eb43504d790cab Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Thu, 26 Jun 2025 00:18:05 +0200 Subject: [PATCH 048/196] aqhome-tool: added some commands - getFirstData - getLastData - getPeriodData --- apps/aqhome-tool/data/0BUILD | 6 + apps/aqhome-tool/data/getdatapoints.c | 49 +------- apps/aqhome-tool/data/getfirstdata.c | 153 +++++++++++++++++++++++ apps/aqhome-tool/data/getfirstdata.h | 21 ++++ apps/aqhome-tool/data/getlastdata.c | 153 +++++++++++++++++++++++ apps/aqhome-tool/data/getlastdata.h | 21 ++++ apps/aqhome-tool/data/getperioddata.c | 167 ++++++++++++++++++++++++++ apps/aqhome-tool/data/getperioddata.h | 21 ++++ apps/aqhome-tool/main.c | 8 +- apps/aqhome-tool/utils.c | 45 +++++++ apps/aqhome-tool/utils.h | 2 + aqhome/data/storage.c | 35 +----- 12 files changed, 605 insertions(+), 76 deletions(-) create mode 100644 apps/aqhome-tool/data/getfirstdata.c create mode 100644 apps/aqhome-tool/data/getfirstdata.h create mode 100644 apps/aqhome-tool/data/getlastdata.c create mode 100644 apps/aqhome-tool/data/getlastdata.h create mode 100644 apps/aqhome-tool/data/getperioddata.c create mode 100644 apps/aqhome-tool/data/getperioddata.h diff --git a/apps/aqhome-tool/data/0BUILD b/apps/aqhome-tool/data/0BUILD index 4af2354..359c2f9 100644 --- a/apps/aqhome-tool/data/0BUILD +++ b/apps/aqhome-tool/data/0BUILD @@ -37,6 +37,9 @@ getdevices.h adddata.h getdatapoints.h + getfirstdata.h + getlastdata.h + getperioddata.h setdata.h moddevice.h watch.h @@ -49,6 +52,9 @@ getdevices.c adddata.c getdatapoints.c + getfirstdata.c + getlastdata.c + getperioddata.c setdata.c moddevice.c watch.c diff --git a/apps/aqhome-tool/data/getdatapoints.c b/apps/aqhome-tool/data/getdatapoints.c index f4ebe4a..5e77bee 100644 --- a/apps/aqhome-tool/data/getdatapoints.c +++ b/apps/aqhome-tool/data/getdatapoints.c @@ -10,7 +10,7 @@ # include #endif -#include "./getvalues.h" +#include "./getdatapoints.h" #include "../client.h" #include "../utils.h" @@ -52,7 +52,6 @@ static AQH_MESSAGE *_createRequestMessage(AQH_OBJECT *o, uint32_t msgId); static int _handleResponseMessage(AQH_OBJECT *o, const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList, int first); static void _handleDataResponse(const GWEN_TAG16_LIST *tagList, int printMean, int printDiff); -static uint64_t _getTimeStampFromString(const char *s); @@ -110,12 +109,12 @@ AQH_MESSAGE *_createRequestMessage(GWEN_UNUSED AQH_OBJECT *o, uint32_t msgId) dbArgs=AQH_ToolClient_GetDbLocalArgs(o); valueName=GWEN_DB_GetCharValue(dbArgs, "valueName", 0, NULL); num=GWEN_DB_GetIntValue(dbArgs, "numOfLastDatapoints", 0, 0); - tsBegin=_getTimeStampFromString(GWEN_DB_GetCharValue(dbArgs, "tsBegin", 0, NULL)); + tsBegin=Utils_GetTimeStampFromString(GWEN_DB_GetCharValue(dbArgs, "tsBegin", 0, NULL)); if (tsBegin==(uint64_t) (-1)) { DBG_ERROR(NULL, "Bad begin timestamp"); return NULL; } - tsEnd=_getTimeStampFromString(GWEN_DB_GetCharValue(dbArgs, "tsEnd", 0, NULL)); + tsEnd=Utils_GetTimeStampFromString(GWEN_DB_GetCharValue(dbArgs, "tsEnd", 0, NULL)); if (tsEnd==(uint64_t) (-1)) { DBG_ERROR(NULL, "Bad end timestamp"); return NULL; @@ -183,45 +182,3 @@ void _handleDataResponse(const GWEN_TAG16_LIST *tagList, int printMean, int prin -uint64_t _getTimeStampFromString(const char *s) -{ - if (s && *s) { - if (*s=='-') { - uint64_t x=0; - uint64_t now=time(NULL); - - s++; - while(*s && isdigit(*s)) { - unsigned int i; - - i=*(s++)-'0'; - x*=10; - x+=i; - } - if (*s) { - switch(*s) { - case 0: - case 'm': x*=60; break; - case 'h': x*=(60*60); break; - case 'd': x*=(60*60*24); break; - default: break; - } - } - return (now-x); - } - else { - unsigned long int x; - - if (1!=sscanf(s, "%lu", &x)) { - DBG_ERROR(NULL, "ERROR: Invalid timestamp"); - return (uint64_t) (-1); - } - return (uint64_t) x; - } - } - return 0; -} - - - - diff --git a/apps/aqhome-tool/data/getfirstdata.c b/apps/aqhome-tool/data/getfirstdata.c new file mode 100644 index 0000000..35f54c6 --- /dev/null +++ b/apps/aqhome-tool/data/getfirstdata.c @@ -0,0 +1,153 @@ +/**************************************************************************** + * This file is part of the project AqHome. + * AqHome (c) by 2025 Martin Preuss, all rights reserved. + * + * The license for this file can be found in the file COPYING which you + * should have received along with this file. + ****************************************************************************/ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "./getfirstdata.h" +#include "../utils.h" + +#include "aqhome/dataclient/client.h" +#include "aqhome/msg/ipc/m_ipc.h" +#include "aqhome/msg/ipc/m_ipc_result.h" +#include "aqhome/msg/ipc/data/m_ipcd.h" +#include "aqhome/msg/ipc/data/m_ipcd_getdata.h" +#include "aqhome/msg/ipc/data/m_ipcd_multidata.h" +#include "aqhome/dataclient/client.h" + +#include +#include +#include +#include + +#include + + + +/* ------------------------------------------------------------------------------------------------ + * defs + * ------------------------------------------------------------------------------------------------ + */ + +#define I18S(msg) msg +#define I18N(msg) GWEN_I18N_Translate(PACKAGE, msg) + +#define A_ARG GWEN_ARGS_FLAGS_HAS_ARGUMENT +#define A_END (GWEN_ARGS_FLAGS_HELP | GWEN_ARGS_FLAGS_LAST) +#define A_CHAR GWEN_ArgsType_Char +#define A_INT GWEN_ArgsType_Int + + + +/* ------------------------------------------------------------------------------------------------ + * forward declarations + * ------------------------------------------------------------------------------------------------ + */ + +static int _runCommand(AQH_DATACLIENT *dc); + + + + +/* ------------------------------------------------------------------------------------------------ + * code + * ------------------------------------------------------------------------------------------------ + */ + +int AQH_Tool_GetFirstData(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv) +{ + AQH_EVENT_LOOP *eventLoop; + AQH_DATACLIENT *dc; + int rv; + const GWEN_ARGS args[]= { + /* flags type name min max s long short_descr, long_descr */ + { A_ARG, A_CHAR, "brokerAddress", 0, 1, "t", "tcpaddress", I18S("TCP address to connect to [127.0.0.1]"), NULL}, + { A_ARG, A_INT, "brokerPort", 0, 1, "P", "tcpport", I18S("Specify the TCP port to listen on"), NULL}, + { A_ARG, A_INT, "timeout", 0, 1, "T", NULL, I18S("Specify timeout in seconds for response"), NULL}, + { A_ARG, A_CHAR, "brokerClientId", 0, 1, "c", "clientid", I18S("Specify CLIENTID"), NULL}, + { A_ARG, A_CHAR, "userId", 0, 1, "u", "userid", I18S("Specify user id"), NULL}, + { A_ARG, A_CHAR, "password", 0, 1, "p", "password", I18S("Specify service password"), NULL}, + { A_ARG, A_CHAR, "valueName", 1, 1, "N", "valuename", I18S("Value name (e.g. server/temp/system)"), NULL}, + { A_ARG, A_INT, "numOfDatapoints", 0, 1, "n", NULL, I18S("Get up to n datapoints"), NULL}, + { 0, A_INT, "printMean", 0, 1, "M", "mean", I18S("Print mean value of data received"), NULL}, + { 0, A_INT, "printDiff", 0, 1, "D", "diff", I18S("Print diff last-first value"), NULL}, + { A_END, A_INT, "help", 0, 0, "h", "help", I18S("Show this help screen"), NULL} + }; + + eventLoop=AQH_EventLoop_new(); + dc=AQH_DataClient_new(eventLoop, AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION); + + rv=AQH_DataClient_ReadLocalArgs(dc, dbGlobalArgs, args, argc, argv); + if (rv<0) { + DBG_ERROR(NULL, "here (%d)", rv); + AQH_DataClient_free(dc); + AQH_EventLoop_free(eventLoop); + return 2; + } + + rv=AQH_DataClient_ConnectWithArgs(dc, 0); + if (rv<0) { + DBG_ERROR(NULL, "Error connecting (%d)", rv); + AQH_DataClient_free(dc); + AQH_EventLoop_free(eventLoop); + return 2; + } + + rv=_runCommand(dc); + if (rv<0) { + DBG_ERROR(NULL, "Error running (%d)", rv); + AQH_DataClient_free(dc); + AQH_EventLoop_free(eventLoop); + return 2; + } + + AQH_DataClient_free(dc); + AQH_EventLoop_free(eventLoop); + return 0; +} + + + +int _runCommand(AQH_DATACLIENT *dc) +{ + GWEN_DB_NODE *dbLocalArgs; + const char *valueName; + uint64_t num; + int printMean; + int printDiff; + + dbLocalArgs=AQH_DataClient_GetDbLocalArgs(dc); + valueName=GWEN_DB_GetCharValue(dbLocalArgs, "valueName", 0, NULL); + num=GWEN_DB_GetIntValue(dbLocalArgs, "numOfDatapoints", 0, 1); + printMean=GWEN_DB_GetIntValue(dbLocalArgs, "printMean", 0, 0); + printDiff=GWEN_DB_GetIntValue(dbLocalArgs, "printDiff", 0, 0); + + if (num>0) { + uint64_t *dataPoints; + uint64_t recvdNum; + + dataPoints=malloc(num*sizeof(uint64_t)*2); + + recvdNum=AQH_DataClient_GetFirstData(dc, valueName, dataPoints, num); + if (recvdNum>0) { + if (printMean) + Utils_PrintMeanData(dataPoints, recvdNum, NULL); + else if (printDiff) + Utils_PrintDiffData(dataPoints, recvdNum, NULL); + else + Utils_PrintDataPoints(dataPoints, recvdNum, NULL); + } + free(dataPoints); + } + + return 0; +} + + + diff --git a/apps/aqhome-tool/data/getfirstdata.h b/apps/aqhome-tool/data/getfirstdata.h new file mode 100644 index 0000000..17f25e5 --- /dev/null +++ b/apps/aqhome-tool/data/getfirstdata.h @@ -0,0 +1,21 @@ +/**************************************************************************** + * This file is part of the project AqHome. + * AqHome (c) by 2025 Martin Preuss, all rights reserved. + * + * The license for this file can be found in the file COPYING which you + * should have received along with this file. + ****************************************************************************/ + +#ifndef AQHOME_TOOL_GETFIRSTDATA_H +#define AQHOME_TOOL_GETFIRSTDATA_H + + +#include + + + +int AQH_Tool_GetFirstData(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv); + + +#endif + diff --git a/apps/aqhome-tool/data/getlastdata.c b/apps/aqhome-tool/data/getlastdata.c new file mode 100644 index 0000000..d68fe2f --- /dev/null +++ b/apps/aqhome-tool/data/getlastdata.c @@ -0,0 +1,153 @@ +/**************************************************************************** + * This file is part of the project AqHome. + * AqHome (c) by 2025 Martin Preuss, all rights reserved. + * + * The license for this file can be found in the file COPYING which you + * should have received along with this file. + ****************************************************************************/ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "./getlastdata.h" +#include "../utils.h" + +#include "aqhome/dataclient/client.h" +#include "aqhome/msg/ipc/m_ipc.h" +#include "aqhome/msg/ipc/m_ipc_result.h" +#include "aqhome/msg/ipc/data/m_ipcd.h" +#include "aqhome/msg/ipc/data/m_ipcd_getdata.h" +#include "aqhome/msg/ipc/data/m_ipcd_multidata.h" +#include "aqhome/dataclient/client.h" + +#include +#include +#include +#include + +#include + + + +/* ------------------------------------------------------------------------------------------------ + * defs + * ------------------------------------------------------------------------------------------------ + */ + +#define I18S(msg) msg +#define I18N(msg) GWEN_I18N_Translate(PACKAGE, msg) + +#define A_ARG GWEN_ARGS_FLAGS_HAS_ARGUMENT +#define A_END (GWEN_ARGS_FLAGS_HELP | GWEN_ARGS_FLAGS_LAST) +#define A_CHAR GWEN_ArgsType_Char +#define A_INT GWEN_ArgsType_Int + + + +/* ------------------------------------------------------------------------------------------------ + * forward declarations + * ------------------------------------------------------------------------------------------------ + */ + +static int _runCommand(AQH_DATACLIENT *dc); + + + + +/* ------------------------------------------------------------------------------------------------ + * code + * ------------------------------------------------------------------------------------------------ + */ + +int AQH_Tool_GetLastData(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv) +{ + AQH_EVENT_LOOP *eventLoop; + AQH_DATACLIENT *dc; + int rv; + const GWEN_ARGS args[]= { + /* flags type name min max s long short_descr, long_descr */ + { A_ARG, A_CHAR, "brokerAddress", 0, 1, "t", "tcpaddress", I18S("TCP address to connect to [127.0.0.1]"), NULL}, + { A_ARG, A_INT, "brokerPort", 0, 1, "P", "tcpport", I18S("Specify the TCP port to listen on"), NULL}, + { A_ARG, A_INT, "timeout", 0, 1, "T", NULL, I18S("Specify timeout in seconds for response"), NULL}, + { A_ARG, A_CHAR, "brokerClientId", 0, 1, "c", "clientid", I18S("Specify CLIENTID"), NULL}, + { A_ARG, A_CHAR, "userId", 0, 1, "u", "userid", I18S("Specify user id"), NULL}, + { A_ARG, A_CHAR, "password", 0, 1, "p", "password", I18S("Specify service password"), NULL}, + { A_ARG, A_CHAR, "valueName", 1, 1, "N", "valuename", I18S("Value name (e.g. server/temp/system)"), NULL}, + { A_ARG, A_INT, "numOfDatapoints", 0, 1, "n", NULL, I18S("Get up to n datapoints"), NULL}, + { 0, A_INT, "printMean", 0, 1, "M", "mean", I18S("Print mean value of data received"), NULL}, + { 0, A_INT, "printDiff", 0, 1, "D", "diff", I18S("Print diff last-first value"), NULL}, + { A_END, A_INT, "help", 0, 0, "h", "help", I18S("Show this help screen"), NULL} + }; + + eventLoop=AQH_EventLoop_new(); + dc=AQH_DataClient_new(eventLoop, AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION); + + rv=AQH_DataClient_ReadLocalArgs(dc, dbGlobalArgs, args, argc, argv); + if (rv<0) { + DBG_ERROR(NULL, "here (%d)", rv); + AQH_DataClient_free(dc); + AQH_EventLoop_free(eventLoop); + return 2; + } + + rv=AQH_DataClient_ConnectWithArgs(dc, 0); + if (rv<0) { + DBG_ERROR(NULL, "Error connecting (%d)", rv); + AQH_DataClient_free(dc); + AQH_EventLoop_free(eventLoop); + return 2; + } + + rv=_runCommand(dc); + if (rv<0) { + DBG_ERROR(NULL, "Error running (%d)", rv); + AQH_DataClient_free(dc); + AQH_EventLoop_free(eventLoop); + return 2; + } + + AQH_DataClient_free(dc); + AQH_EventLoop_free(eventLoop); + return 0; +} + + + +int _runCommand(AQH_DATACLIENT *dc) +{ + GWEN_DB_NODE *dbLocalArgs; + const char *valueName; + uint64_t num; + int printMean; + int printDiff; + + dbLocalArgs=AQH_DataClient_GetDbLocalArgs(dc); + valueName=GWEN_DB_GetCharValue(dbLocalArgs, "valueName", 0, NULL); + num=GWEN_DB_GetIntValue(dbLocalArgs, "numOfDatapoints", 0, 1); + printMean=GWEN_DB_GetIntValue(dbLocalArgs, "printMean", 0, 0); + printDiff=GWEN_DB_GetIntValue(dbLocalArgs, "printDiff", 0, 0); + + if (num>0) { + uint64_t *dataPoints; + uint64_t recvdNum; + + dataPoints=malloc(num*sizeof(uint64_t)*2); + + recvdNum=AQH_DataClient_GetLastData(dc, valueName, dataPoints, num); + if (recvdNum>0) { + if (printMean) + Utils_PrintMeanData(dataPoints, recvdNum, NULL); + else if (printDiff) + Utils_PrintDiffData(dataPoints, recvdNum, NULL); + else + Utils_PrintDataPoints(dataPoints, recvdNum, NULL); + } + free(dataPoints); + } + + return 0; +} + + + diff --git a/apps/aqhome-tool/data/getlastdata.h b/apps/aqhome-tool/data/getlastdata.h new file mode 100644 index 0000000..40b7d86 --- /dev/null +++ b/apps/aqhome-tool/data/getlastdata.h @@ -0,0 +1,21 @@ +/**************************************************************************** + * This file is part of the project AqHome. + * AqHome (c) by 2025 Martin Preuss, all rights reserved. + * + * The license for this file can be found in the file COPYING which you + * should have received along with this file. + ****************************************************************************/ + +#ifndef AQHOME_TOOL_GETLASTDATA_H +#define AQHOME_TOOL_GETLASTDATA_H + + +#include + + + +int AQH_Tool_GetLastData(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv); + + +#endif + diff --git a/apps/aqhome-tool/data/getperioddata.c b/apps/aqhome-tool/data/getperioddata.c new file mode 100644 index 0000000..4fe2a0c --- /dev/null +++ b/apps/aqhome-tool/data/getperioddata.c @@ -0,0 +1,167 @@ +/**************************************************************************** + * This file is part of the project AqHome. + * AqHome (c) by 2025 Martin Preuss, all rights reserved. + * + * The license for this file can be found in the file COPYING which you + * should have received along with this file. + ****************************************************************************/ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "./getperioddata.h" +#include "../utils.h" + +#include "aqhome/dataclient/client.h" +#include "aqhome/msg/ipc/m_ipc.h" +#include "aqhome/msg/ipc/m_ipc_result.h" +#include "aqhome/msg/ipc/data/m_ipcd.h" +#include "aqhome/msg/ipc/data/m_ipcd_getdata.h" +#include "aqhome/msg/ipc/data/m_ipcd_multidata.h" +#include "aqhome/dataclient/client.h" + +#include +#include +#include +#include + +#include + + + +/* ------------------------------------------------------------------------------------------------ + * defs + * ------------------------------------------------------------------------------------------------ + */ + +#define I18S(msg) msg +#define I18N(msg) GWEN_I18N_Translate(PACKAGE, msg) + +#define A_ARG GWEN_ARGS_FLAGS_HAS_ARGUMENT +#define A_END (GWEN_ARGS_FLAGS_HELP | GWEN_ARGS_FLAGS_LAST) +#define A_CHAR GWEN_ArgsType_Char +#define A_INT GWEN_ArgsType_Int + + + +/* ------------------------------------------------------------------------------------------------ + * forward declarations + * ------------------------------------------------------------------------------------------------ + */ + +static int _runCommand(AQH_DATACLIENT *dc); + + + + +/* ------------------------------------------------------------------------------------------------ + * code + * ------------------------------------------------------------------------------------------------ + */ + +int AQH_Tool_GetPeriodData(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv) +{ + AQH_EVENT_LOOP *eventLoop; + AQH_DATACLIENT *dc; + int rv; + const GWEN_ARGS args[]= { + /* flags type name min max s long short_descr, long_descr */ + { A_ARG, A_CHAR, "brokerAddress", 0, 1, "t", "tcpaddress", I18S("TCP address to connect to [127.0.0.1]"), NULL}, + { A_ARG, A_INT, "brokerPort", 0, 1, "P", "tcpport", I18S("Specify the TCP port to listen on"), NULL}, + { A_ARG, A_INT, "timeout", 0, 1, "T", NULL, I18S("Specify timeout in seconds for response"), NULL}, + { A_ARG, A_CHAR, "brokerClientId", 0, 1, "c", "clientid", I18S("Specify CLIENTID"), NULL}, + { A_ARG, A_CHAR, "userId", 0, 1, "u", "userid", I18S("Specify user id"), NULL}, + { A_ARG, A_CHAR, "password", 0, 1, "p", "password", I18S("Specify service password"), NULL}, + { A_ARG, A_CHAR, "valueName", 1, 1, "N", "valuename", I18S("Value name (e.g. server/temp/system)"), NULL}, + { A_ARG, A_INT, "numOfDatapoints", 0, 1, "n", NULL, I18S("Get up to n datapoints"), NULL}, + { A_ARG, A_CHAR, "tsBegin", 0, 1, "tb", "tsbegin", I18S("Timestamp range begin"), NULL}, + { A_ARG, A_CHAR, "tsEnd", 0, 1, "te", "tsend", I18S("Timestamp range end"), NULL}, + { 0, A_INT, "printMean", 0, 1, "M", "mean", I18S("Print mean value of data received"), NULL}, + { 0, A_INT, "printDiff", 0, 1, "D", "diff", I18S("Print diff last-first value"), NULL}, + { A_END, A_INT, "help", 0, 0, "h", "help", I18S("Show this help screen"), NULL} + }; + + eventLoop=AQH_EventLoop_new(); + dc=AQH_DataClient_new(eventLoop, AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION); + + rv=AQH_DataClient_ReadLocalArgs(dc, dbGlobalArgs, args, argc, argv); + if (rv<0) { + DBG_ERROR(NULL, "here (%d)", rv); + AQH_DataClient_free(dc); + AQH_EventLoop_free(eventLoop); + return 2; + } + + rv=AQH_DataClient_ConnectWithArgs(dc, 0); + if (rv<0) { + DBG_ERROR(NULL, "Error connecting (%d)", rv); + AQH_DataClient_free(dc); + AQH_EventLoop_free(eventLoop); + return 2; + } + + rv=_runCommand(dc); + if (rv<0) { + DBG_ERROR(NULL, "Error running (%d)", rv); + AQH_DataClient_free(dc); + AQH_EventLoop_free(eventLoop); + return 2; + } + + AQH_DataClient_free(dc); + AQH_EventLoop_free(eventLoop); + return 0; +} + + + +int _runCommand(AQH_DATACLIENT *dc) +{ + GWEN_DB_NODE *dbLocalArgs; + const char *valueName; + uint64_t num; + uint64_t tsBegin; + uint64_t tsEnd; + int printMean; + int printDiff; + + dbLocalArgs=AQH_DataClient_GetDbLocalArgs(dc); + valueName=GWEN_DB_GetCharValue(dbLocalArgs, "valueName", 0, NULL); + num=GWEN_DB_GetIntValue(dbLocalArgs, "numOfDatapoints", 0, 1); + tsBegin=Utils_GetTimeStampFromString(GWEN_DB_GetCharValue(dbLocalArgs, "tsBegin", 0, NULL)); + if (tsBegin==(uint64_t) (-1)) { + DBG_ERROR(NULL, "Bad begin timestamp"); + return 1; + } + tsEnd=Utils_GetTimeStampFromString(GWEN_DB_GetCharValue(dbLocalArgs, "tsEnd", 0, NULL)); + if (tsEnd==(uint64_t) (-1)) { + DBG_ERROR(NULL, "Bad end timestamp"); + return 1; + } + printMean=GWEN_DB_GetIntValue(dbLocalArgs, "printMean", 0, 0); + printDiff=GWEN_DB_GetIntValue(dbLocalArgs, "printDiff", 0, 0); + + if (num>0) { + uint64_t *dataPoints; + uint64_t recvdNum; + + dataPoints=malloc(num*sizeof(uint64_t)*2); + + recvdNum=AQH_DataClient_GetPeriodData(dc, valueName, dataPoints, num, tsBegin, tsEnd); + if (recvdNum>0) { + if (printMean) + Utils_PrintMeanData(dataPoints, recvdNum, NULL); + else if (printDiff) + Utils_PrintDiffData(dataPoints, recvdNum, NULL); + else + Utils_PrintDataPoints(dataPoints, recvdNum, NULL); + } + free(dataPoints); + } + + return 0; +} + + + diff --git a/apps/aqhome-tool/data/getperioddata.h b/apps/aqhome-tool/data/getperioddata.h new file mode 100644 index 0000000..77e7e0f --- /dev/null +++ b/apps/aqhome-tool/data/getperioddata.h @@ -0,0 +1,21 @@ +/**************************************************************************** + * This file is part of the project AqHome. + * AqHome (c) by 2025 Martin Preuss, all rights reserved. + * + * The license for this file can be found in the file COPYING which you + * should have received along with this file. + ****************************************************************************/ + +#ifndef AQHOME_TOOL_GETPERIODDATA_H +#define AQHOME_TOOL_GETPERIODDATA_H + + +#include + + + +int AQH_Tool_GetPeriodData(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv); + + +#endif + diff --git a/apps/aqhome-tool/main.c b/apps/aqhome-tool/main.c index a062873..a13cb83 100644 --- a/apps/aqhome-tool/main.c +++ b/apps/aqhome-tool/main.c @@ -1,6 +1,6 @@ /**************************************************************************** * This file is part of the project AqHome. - * AqHome (c) by 2023 Martin Preuss, all rights reserved. + * AqHome (c) by 2025 Martin Preuss, all rights reserved. * * The license for this file can be found in the file COPYING which you * should have received along with this file. @@ -17,6 +17,9 @@ #include "./data/getdevices.h" #include "./data/adddata.h" #include "./data/getdatapoints.h" +#include "./data/getfirstdata.h" +#include "./data/getlastdata.h" +#include "./data/getperioddata.h" #include "./data/setdata.h" #include "./data/moddevice.h" #include "./data/watch.h" @@ -92,6 +95,9 @@ int main(int argc, char **argv) GWEN_FE_DAH("adddata", AQH_Tool_AddDataPoint, I18N("Send a datapoint to the data server")), GWEN_FE_DAH("addjsondata", AQH_Tool_AddDataPoint, I18N("(same as adddata)")), GWEN_FE_DAH("getdata", AQH_Tool_GetDataPoints, I18N("Request list of datapoints for a value on the data server")), + GWEN_FE_DAH("getfirstdata", AQH_Tool_GetFirstData, I18N("Request first datapoints for a value on the data server")), + GWEN_FE_DAH("getlastdata", AQH_Tool_GetLastData, I18N("Request last datapoints for a value on the data server")), + GWEN_FE_DAH("getperioddata", AQH_Tool_GetPeriodData, I18N("Request datapoints from a date range for a value on the data server")), GWEN_FE_DAH("setdata", AQH_Tool_SetData, I18N("Set data for a value on the data server (e.g. a switch or thermostat)")), GWEN_FE_DAH("moddevice", AQH_Tool_ModDevice, I18N("Modify a device on the data server")), GWEN_FE_DAH("watch", AQH_Tool_Watch, I18N("Watch and print changes of values on the data server")), diff --git a/apps/aqhome-tool/utils.c b/apps/aqhome-tool/utils.c index 9c9b718..5c7ddf1 100644 --- a/apps/aqhome-tool/utils.c +++ b/apps/aqhome-tool/utils.c @@ -19,6 +19,7 @@ #include "aqhome/msg/ipc/nodes/m_ipcn_setaccmsggrps.h" #include "aqhome/ipc2/tcp_object.h" #include "aqhome/ipc2/ipc_client.h" +#include "aqhome/dataclient/client.h" #include @@ -27,6 +28,7 @@ #include #include +#include #define UTILS_IPC_ENDPOINT_DEFAULT_MSGSIZE 4096 @@ -361,4 +363,47 @@ void Utils_PrintValue(const AQH_VALUE *value, int printHeader) +uint64_t Utils_GetTimeStampFromString(const char *s) +{ + if (s && *s) { + if (*s=='-') { + uint64_t x=0; + uint64_t now=time(NULL); + + s++; + while(*s && isdigit(*s)) { + unsigned int i; + + i=*(s++)-'0'; + x*=10; + x+=i; + } + if (*s) { + switch(*s) { + case 0: + case 'm': x*=60; break; + case 'h': x*=(60*60); break; + case 'd': x*=(60*60*24); break; + default: break; + } + } + return (now-x); + } + else { + unsigned long int x; + + if (1!=sscanf(s, "%lu", &x)) { + DBG_ERROR(NULL, "ERROR: Invalid timestamp"); + return (uint64_t) (-1); + } + return (uint64_t) x; + } + } + return 0; +} + + + + + diff --git a/apps/aqhome-tool/utils.h b/apps/aqhome-tool/utils.h index 125c31d..9c001bf 100644 --- a/apps/aqhome-tool/utils.h +++ b/apps/aqhome-tool/utils.h @@ -41,6 +41,8 @@ void Utils_PrintValue(const AQH_VALUE *value, int printHeader); AQH_DEVICE *Utils_DeviceFromArgs(GWEN_DB_NODE *dbArgs); +uint64_t Utils_GetTimeStampFromString(const char *s); + #endif diff --git a/aqhome/data/storage.c b/aqhome/data/storage.c index 70faf46..561cbf8 100644 --- a/aqhome/data/storage.c +++ b/aqhome/data/storage.c @@ -394,8 +394,8 @@ int AQH_Storage_AddDatapoint(AQH_STORAGE *sto, uint64_t valueId, uint64_t timest } - -uint64_t *AQH_Storage_GetDataPoints(AQH_STORAGE *sto, uint64_t valueId, uint64_t fromTime, uint64_t toTime, uint64_t maxArrayLen) +uint64_t *AQH_Storage_GetDataPoints(AQH_STORAGE *sto, uint64_t valueId, uint64_t fromTime, uint64_t toTime, + uint64_t maxDataPointsRequested) { AQH_DATAFILE *df; uint64_t numEntries; @@ -410,13 +410,9 @@ uint64_t *AQH_Storage_GetDataPoints(AQH_STORAGE *sto, uint64_t valueId, uint64_t return NULL; } numEntries=AQH_DataFile_GetNumberOfEntries(df); - if (fromTime==0 && toTime==0) - arrayLen=(numEntries*2)+1; - else - arrayLen=(AQH_STORAGE_DATAPOINTS_STEPS*2)+1; - if (arrayLen>maxArrayLen+1) - arrayLen=maxArrayLen+1; - + if (maxDataPointsRequested>numEntries) + maxDataPointsRequested=numEntries; + arrayLen=(maxDataPointsRequested*2)+1; arrayPtr=(uint64_t*) malloc(arrayLen*sizeof(uint64_t)); if (arrayPtr==NULL) { DBG_ERROR(AQH_LOGDOMAIN, "Not enough memory for %lu entries", (unsigned long int) arrayLen); @@ -438,30 +434,11 @@ uint64_t *AQH_Storage_GetDataPoints(AQH_STORAGE *sto, uint64_t valueId, uint64_t } if ((fromTime==0 || ts>=fromTime) && (toTime==0 || ts<=toTime)) { - if ((arrayPos+1)>maxArrayLen) { + if ((arrayPos+1)>arrayLen) { DBG_INFO(AQH_LOGDOMAIN, "Limit for number of returned entries reached"); break; } - if (arrayPos+1>=arrayLen) { - uint64_t newArrayLen; - void *p; - newArrayLen=arrayLen+(AQH_STORAGE_DATAPOINTS_STEPS*2); - if (newArrayLen>maxArrayLen+1) - newArrayLen=maxArrayLen+1; - if (newArrayLen==arrayLen) { - DBG_INFO(AQH_LOGDOMAIN, "Limit for number of returned entries reached"); - break; - } - p=realloc((void*) arrayPtr, newArrayLen*sizeof(uint64_t)); - if (p==NULL) { - DBG_ERROR(AQH_LOGDOMAIN, "Not enough memory for %lu entries", (unsigned long int) arrayLen+AQH_STORAGE_DATAPOINTS_STEPS); - free(arrayPtr); - return NULL; - } - arrayPtr=(uint64_t*) p; - arrayLen=newArrayLen; - } arrayPtr[arrayPos++]=ts; arrayPtr[arrayPos++]=u.i; } From 850975a85b25f597efac7e1c298f6dd3b60aa9d5 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Thu, 26 Jun 2025 00:18:33 +0200 Subject: [PATCH 049/196] avr: fixed a bug (was not calling sysOnEveryDay) --- avr/modules/clock/main.asm | 2 +- avr/version.asm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/avr/modules/clock/main.asm b/avr/modules/clock/main.asm index c36f0bc..03d5b8d 100644 --- a/avr/modules/clock/main.asm +++ b/avr/modules/clock/main.asm @@ -118,7 +118,7 @@ Clock_Every100ms_inc1h: Clock_Every100ms_1d: clr r16 sts clockModuleCounterHours, r16 - rcall onEveryDay + rcall sysOnEveryDay ret ; @end diff --git a/avr/version.asm b/avr/version.asm index a21f6e4..644cc10 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 = 7 +.equ FIRMWARE_VERSION_PATCHLEVEL = 8 From 72acef3aafed1fd2303c785c657e4ffb16f4f4b1 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Thu, 26 Jun 2025 00:31:11 +0200 Subject: [PATCH 050/196] Increased max message size. --- aqhome/ipc2/ipc_msgreader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aqhome/ipc2/ipc_msgreader.c b/aqhome/ipc2/ipc_msgreader.c index 3c4b78c..6f46ca6 100644 --- a/aqhome/ipc2/ipc_msgreader.c +++ b/aqhome/ipc2/ipc_msgreader.c @@ -24,7 +24,7 @@ #define AQH_MSG_READER_HEADER_SIZE 4 #define AQH_MSG_READER_MINMSGSIZE 12 -#define AQH_MSG_READER_MAXMSGSIZE 10240 +#define AQH_MSG_READER_MAXMSGSIZE 20480 From cfc7dc63201f4a99d62784d3f6b9a2be8e3c37bc Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 29 Jun 2025 22:31:51 +0200 Subject: [PATCH 051/196] avr: added r04. --- avr/devices/r04/.gitignore | 2 + avr/devices/r04/0BUILD | 22 ++ avr/devices/r04/README | 0 avr/devices/r04/aqua_r04.xml | 21 ++ avr/devices/r04/boot/0BUILD | 32 +++ avr/devices/r04/boot/boot.asm | 151 ++++++++++++++ avr/devices/r04/defs.asm | 106 ++++++++++ avr/devices/r04/main/0BUILD | 33 +++ avr/devices/r04/main/main.asm | 370 ++++++++++++++++++++++++++++++++++ 9 files changed, 737 insertions(+) create mode 100644 avr/devices/r04/.gitignore create mode 100644 avr/devices/r04/0BUILD create mode 100644 avr/devices/r04/README create mode 100644 avr/devices/r04/aqua_r04.xml create mode 100644 avr/devices/r04/boot/0BUILD create mode 100644 avr/devices/r04/boot/boot.asm create mode 100644 avr/devices/r04/defs.asm create mode 100644 avr/devices/r04/main/0BUILD create mode 100644 avr/devices/r04/main/main.asm diff --git a/avr/devices/r04/.gitignore b/avr/devices/r04/.gitignore new file mode 100644 index 0000000..8e0618c --- /dev/null +++ b/avr/devices/r04/.gitignore @@ -0,0 +1,2 @@ +*.eep.hex +*.obj diff --git a/avr/devices/r04/0BUILD b/avr/devices/r04/0BUILD new file mode 100644 index 0000000..9622ec9 --- /dev/null +++ b/avr/devices/r04/0BUILD @@ -0,0 +1,22 @@ + + + + + + boot + main + + + + defs.asm + README + + + + aqua_r04.xml + + + + + + diff --git a/avr/devices/r04/README b/avr/devices/r04/README new file mode 100644 index 0000000..e69de29 diff --git a/avr/devices/r04/aqua_r04.xml b/avr/devices/r04/aqua_r04.xml new file mode 100644 index 0000000..e591864 --- /dev/null +++ b/avr/devices/r04/aqua_r04.xml @@ -0,0 +1,21 @@ + + + AQUA + R + 4 + + + + + + + + + + + + + + + + diff --git a/avr/devices/r04/boot/0BUILD b/avr/devices/r04/boot/0BUILD new file mode 100644 index 0000000..b2940e7 --- /dev/null +++ b/avr/devices/r04/boot/0BUILD @@ -0,0 +1,32 @@ + + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + boot.asm + + + + + + + + + + + + + + + + diff --git a/avr/devices/r04/boot/boot.asm b/avr/devices/r04/boot/boot.asm new file mode 100644 index 0000000..d86fa14 --- /dev/null +++ b/avr/devices/r04/boot/boot.asm @@ -0,0 +1,151 @@ +; *************************************************************************** +; 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 +.equ clock=8000000 ; Define the clock frequency + +.nolist +.include "include/tn841def.inc" ; Define device ATtiny841 +.list + +.include "version.asm" +.include "../defs.asm" +.include "devices/all/defs.asm" + +.include "common/calls.asm" +.include "common/utils_wait.asm" + + + +; *************************************************************************** +; defines + + +;#define COM_ACCEPT_ALL_DEST 1 + + + +; --------------------------------------------------------------------------- +; LED + +.equ LED_DDR = DDRB +.equ LED_PORT = PORTB +.equ LED_PIN = PINB +.equ LED_PINNUM = PORTB2 + + +; *************************************************************************** +; code segment + +.cseg +.org 0x0000 + + + +; --------------------------------------------------------------------------- +; Reset and interrupt vectors + + rjmp main ; 1: RESET Reset vector use this for flashed system + reti ; 2: INT0 External Interrupt Request 0 + reti ; 3: PCINT0 Pin Change Interrupt 0 + reti ; 4: PCINT1 Pin Change Interrupt 1 + reti ; 5: WDT Watchdog Time-out + reti ; 6: TIM1_CAPT Timer/Counter1 Capture Event + reti ; 7: TIM1_COMPA (OC1A) Timer/Counter1 Compare Match A + reti ; 8: TIM1_COMPB (OC1B) Timer/Counter1 Compare Match B + reti ; 9: TIM1_OVF (OVF1) Timer/Counter1 Overflow + reti ; 10: TIM0_COMPA (OC0A) Timer/Counter0 Compare Match A + reti ; 11: TIM0_COMPB (OC0B) Timer/Counter0 Compare Match B + reti ; 12: TIM0_OVF (OVF0) Timer/Counter0 Overflow + reti ; 13: ANA_COMP0 Analog Comparator 0 + reti ; 14: ADC_READY ADC Conversion Complete + reti ; 15: EE_RDY (ERDY) EEPROM Ready + reti ; 16: ANA_COMP1 Analog Comparator 1 + reti ; 17: TIM2_CAPT Timer/Counter2 Capture Event + reti ; 18: TIM2_COMPA (OC2A) Timer/Counter2 Compare Match A + reti ; 19: TIM2_COMPB (OC2B) Timer/Counter2 Compare Match B + reti ; 20: TIM2_OVF (OVF2) Timer/Counter2 Overflow + reti ; 21: SPI SPI Serial Transfer Complete + reti ; 22: USART0_RXS USART0 Rx Start + reti ; 23: USART0_RXC USART0 Rx Complete + reti ; 24: USART0_DRE USART0 Data Register Empty + reti ; 25: USART0_TXC USART0 Tx Complete + reti ; 26: USART1_RXS USART1 Rx Start + reti ; 27: USART1_RXC USART1 Rx Complete + reti ; 28: USART1_DRE USART1 Data Register Empty + reti ; 29: USART1_TXC USART1 Tx Complete + reti ; 30: TWI Two-Wire-Interface + reti ; 31: RESERVED reserved + + + +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/flashxp.asm" +.include "modules/flash/flash4p.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 == 1000000 + ldi r17, 0xd8 + ldi r16, (1< + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + main.asm + + + + + + + + + + + + + + + + + diff --git a/avr/devices/r04/main/main.asm b/avr/devices/r04/main/main.asm new file mode 100644 index 0000000..d3a69fa --- /dev/null +++ b/avr/devices/r04/main/main.asm @@ -0,0 +1,370 @@ +; *************************************************************************** +; 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. +; +; +; *************************************************************************** + + +;.equ clock=1000000 ; Define the clock frequency +.equ clock=8000000 ; Define the clock frequency + + +.nolist +.include "include/tn841def.inc" ; Define device ATtiny841 +.list + +.include "../defs.asm" +.include "version.asm" +;.include "defs_all.asm" + +.include "devices/all/defs.asm" + +.include "common/calls.asm" +.include "common/utils_wait.asm" +.include "common/utils_io.asm" + + + +; *************************************************************************** +; defines + +; --------------------------------------------------------------------------- +; generic + + +; --------------------------------------------------------------------------- +; firmware settings including list of modules used + + +#define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes + +#define MODULES_CLOCK +;#define MODULES_COM +;#define MODULES_COM_WITH_ADDR_PROTO +;#define MODULES_LED +#define MODULES_LED_SIMPLE +;#define MODULES_TWI_MASTER +;#define MODULES_LCD +;#define LCD_MINIMAL_FONT +;#define MODULES_SI7021 +;#define MODULES_STATS +;#define MODULES_CNY70 +;#define MODULES_REED +;#define MODULES_OWI_MASTER +;#define MODULES_DS18B20 +;#define MODULES_MOTION +#define MODULES_NETWORK +;#define MODULES_TTYONUART1 +#define MODULES_COMONUART0 +#define MODULES_COMONUART1 +#define APPS_STATS +#define APPS_NETWORK + + + +.equ NET_BUFFERS_NUM = 12 +.equ NET_BUFFERS_SIZE = 32 + +.equ UART_HW_MSGNUMINBUF_SIZE = 8 +.equ UART_HW_MSGNUMOUTBUF_SIZE = 8 + + + +; --------------------------------------------------------------------------- +; defines for values + +.equ VALUE_ID_LEDSIMPLE_TIMING = 0x88 + + +; *************************************************************************** +; code segment + +.cseg +.org 000000 + + + +; --------------------------------------------------------------------------- +; Reset and interrupt vectors + + rjmp BOOTLOADER_ADDR ; 1: RESET Reset vector use this for flashed system + reti ; 2: INT0 External Interrupt Request 0 + rjmp onAttnChangeIsr ; 3: PCINT0 Pin Change Interrupt 0 + reti ; 4: PCINT1 Pin Change Interrupt 1 + reti ; 5: WDT Watchdog Time-out + reti ; 6: TIM1_CAPT Timer/Counter1 Capture Event + reti ; 7: TIM1_COMPA (OC1A) Timer/Counter1 Compare Match A + reti ; 8: TIM1_COMPB (OC1B) Timer/Counter1 Compare Match B + reti ; 9: TIM1_OVF (OVF1) Timer/Counter1 Overflow + rjmp baseTimerIrqOC0A ; 10: TIM0_COMPA (OC0A) Timer/Counter0 Compare Match A + reti ; 11: TIM0_COMPB (OC0B) Timer/Counter0 Compare Match B + reti ; 12: TIM0_OVF (OVF0) Timer/Counter0 Overflow + reti ; 13: ANA_COMP0 Analog Comparator 0 + reti ; 14: ADC_READY ADC Conversion Complete + reti ; 15: EE_RDY (ERDY) EEPROM Ready + reti ; 16: ANA_COMP1 Analog Comparator 1 + reti ; 17: TIM2_CAPT Timer/Counter2 Capture Event + reti ; 18: TIM2_COMPA (OC2A) Timer/Counter2 Compare Match A + reti ; 19: TIM2_COMPB (OC2B) Timer/Counter2 Compare Match B + reti ; 20: TIM2_OVF (OVF2) Timer/Counter2 Overflow + reti ; 21: SPI SPI Serial Transfer Complete + reti ; 22: USART0_RXS USART0 Rx Start + rjmp ComOnUart0_RxCharIsr ; 23: USART0_RXC USART0 Rx Complete + rjmp ComOnUart0_TxUdreIsr ; 24: USART0_DRE USART0 Data Register Empty + rjmp ComOnUart0_TxCharIsr ; 25: USART0_TXC USART0 Tx Complete + reti ; 26: USART1_RXS USART1 Rx Start + rjmp ComOnUart1_RxCharIsr ; 27: USART1_RXC USART1 Rx Complete + rjmp ComOnUart1_TxUdreIsr ; 28: USART1_DRE USART1 Data Register Empty + rjmp ComOnUart1_TxCharIsr ; 29: USART1_TXC USART1 Tx Complete + reti ; 30: TWI Two-Wire-Interface + reti ; 31: RESERVED reserved + + + +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: + clr r16 + sts debugCounter, r16 + ldi r16, 0xff + sts attnByte, r16 + ret +; @end + + + + + + + +onEvery100ms: +onEverySecond: +onEveryHour: +onEveryDay: + ret + + + +onEveryMinute: + rcall sendPacketsIface2In + rcall sendErrorsIface2 + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine onEveryLoop +; +; Called on every loop (i.e. after awakening from sleep). + +onEveryLoop: + rcall checkRecvdMsg + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine onMessageReceived +; +; Called on every message received + +onMessageReceived: + clc + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine onAttnChange @global @isr +; +; Called whenever PCINT0 is activated. +; This code assumes that both ATTN pins are on the same port which is true for +; R04 nodes. + +onAttnChangeIsr: + push r15 + in r15, SREG + push r16 + in r16, COM_ATTN_INPUT + push r17 + lds r17, attnByte + sts attnByte, r16 + eor r17, r16 + sbrc r17, COM_ATTN1_PIN + rcall onAttnChangeAttn1 + sbrc r17, COM_ATTN_PIN + rcall onAttnChangeAttn0 + pop r17 + pop r16 + out SREG, r15 + pop r15 + reti +; @end + + + +onAttnChangeAttn0: + sbrs r16, COM_ATTN_PIN + rcall ComOnUart0_HandleAttnChange ; (none) + ret + +onAttnChangeAttn1: + sbrs r16, COM_ATTN1_PIN + rcall ComOnUart1_HandleAttnChange ; (none) + ret + + + +; --------------------------------------------------------------------------- +; @routine checkRecvdMsg +; +; Read messages from either interface and forward to the other one. + +checkRecvdMsg: + rcall NET_PeekNextIncomingMsgNum ; check read queue (bufNum->r16) + brcc checkRecvdMsg_end ; no msg, jmp + rcall NET_Buffer_Locate ; (R17) + ; let system handle incoming messages + push r16 + push xl + push xh + adiw xh:xl, 1 + rcall onMessageReceived + rcall mainModulesOnPacketReceived + rcall mainAppsOnPacketReceived + pop xh + pop xl + pop r16 + + ; forward to other interface + ld r17, X + andi r17, (NET_IFACE_BUFFER_IFACENUM1_BIT | NET_IFACE_BUFFER_IFACENUM0_BIT) + rcall reverseInterfaceNum ; (R16, R17) +; ldi r17, COMONUART0_IFACENUM ; DEBUG: send everything to uart0 to test that code first + rcall addMsgToInterface + brcc checkRecvdMsg_end ; could not add, jmp + rcall NET_GetNextIncomingMsgNum ; take off the queue + rjmp checkRecvdMsg +checkRecvdMsg_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine reverseInterfaceNum +; +; @param r17 buffer num +; @return r17 reversed interface number +; @clobbers r16, r17 + +reverseInterfaceNum: + ldi r16, (NET_IFACE_BUFFER_IFACENUM1_BIT | NET_IFACE_BUFFER_IFACENUM0_BIT) + eor r17, r16 + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine addMsgToInterface +; @param r16 buffer num +; @param r17 interface num + +addMsgToInterface: + cpi r17, COMONUART0_IFACENUM + brne addMsgToInterface_notUart0 + ldi yl, LOW(comOnUart0_iface) + ldi yh, HIGH(comOnUart0_iface) + rjmp NET_Interface_AddOutgoingMsgNum ; try to add msg to interface +addMsgToInterface_notUart0: + ldi yl, LOW(comOnUart1_iface) + ldi yh, HIGH(comOnUart1_iface) + rjmp NET_Interface_AddOutgoingMsgNum ; try to add msg to interface +addMsgToInterface_end: + clc + ret +; @end + + + +sendPacketsIface2In: + ldi yl, LOW(netInterfaceData) + ldi yh, HIGH(netInterfaceData) + ldi r17, AQHOME_VALUEID_STATS_PACKETS2_IN + lds r18, comOnUart1_iface+NET_IFACE_OFFS_PACKETSIN_LOW + lds r19, comOnUart1_iface+NET_IFACE_OFFS_PACKETSIN_HIGH + rjmp appStatsSend16BitValue + +sendErrorsIface2: + ldi yl, LOW(netInterfaceData) + ldi yh, HIGH(netInterfaceData) + ldi r17, 0xf0 + lds r18, comOnUart1_iface+NET_IFACE_OFFS_ERR_MISSED_LOW + lds r19, comOnUart1_iface+NET_IFACE_OFFS_ERR_MISSED_HIGH +; lds r18, debugCounter +; clr r19 + rjmp appStatsSend16BitValue + + + + + + +; *************************************************************************** +; includes + +.include "devices/all/hw_tn841.asm" +.include "devices/all/includes.asm" + + + + +; --------------------------------------------------------------------------- +; defines for network interface + +.equ netInterfaceData = comOnUart0_iface + + +.dseg +attnByte: .byte 1 +debugCounter: .byte 1 + From 6383d18e0ec9c1af5bb62634c24885cb6ab2ead5 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 29 Jun 2025 22:32:43 +0200 Subject: [PATCH 052/196] avr: added comonuart1. --- avr/devices/all/defs.asm | 2 +- avr/devices/all/includes.asm | 13 + avr/devices/all/main.asm | 6 +- avr/devices/all/modules.asm | 9 + avr/modules/uart_hw/comonuart0.asm | 60 ++- avr/modules/uart_hw/comonuart1.asm | 670 +++++++++++++++++++++++++++++ 6 files changed, 734 insertions(+), 26 deletions(-) create mode 100644 avr/modules/uart_hw/comonuart1.asm diff --git a/avr/devices/all/defs.asm b/avr/devices/all/defs.asm index 9966df5..d81b01a 100644 --- a/avr/devices/all/defs.asm +++ b/avr/devices/all/defs.asm @@ -36,7 +36,7 @@ .equ AQHOME_VALUEID_STATS_HEAP_FREE = 0xe8 - +.equ AQHOME_VALUEID_STATS_PACKETS2_IN = 0xe9 ; --------------------------------------------------------------------------- diff --git a/avr/devices/all/includes.asm b/avr/devices/all/includes.asm index ad3a6a2..d28721b 100644 --- a/avr/devices/all/includes.asm +++ b/avr/devices/all/includes.asm @@ -74,6 +74,15 @@ .include "modules/uart_hw/comonuart0.asm" #endif +#ifdef MODULES_COMONUART1 +#ifndef MODULES_COMONUART0 +.include "modules/uart_hw/defs.asm" +.include "modules/uart_hw/lowlevel.asm" +.include "modules/uart_hw/m_lowlevel_uart.asm" +#endif +.include "modules/uart_hw/comonuart1.asm" +#endif + #ifdef MODULES_TTYONUART1 #ifndef MODULES_COMONUART0 @@ -160,6 +169,10 @@ #endif #endif +#ifdef MODULES_LCD + .include "modules/lcd/main.asm" +#endif + #ifdef MODULES_ILI9341 .include "modules/lcd2/ili9341/defs.asm" .include "modules/lcd2/ili9341/main.asm" diff --git a/avr/devices/all/main.asm b/avr/devices/all/main.asm index 522c148..98f5f17 100644 --- a/avr/devices/all/main.asm +++ b/avr/devices/all/main.asm @@ -107,16 +107,18 @@ onSystemTimerTick: bigcall ComOnUart0_Periodically #endif +#ifdef MODULES_COMONUART1 + bigcall ComOnUart1_Periodically +#endif + #ifdef MODULES_TCRT1000 bigcall TCRT1K_Every100ms #endif - #ifdef MODULES_BRIGHTNESS bigcall Brightness_Every100ms #endif - #ifdef APPS_NETWORK ldi yl, LOW(netInterfaceData) ldi yh, HIGH(netInterfaceData) diff --git a/avr/devices/all/modules.asm b/avr/devices/all/modules.asm index 6823fe7..ab73847 100644 --- a/avr/devices/all/modules.asm +++ b/avr/devices/all/modules.asm @@ -77,6 +77,10 @@ initModules: bigcall ComOnUart0_Init #endif +#ifdef MODULES_COMONUART1 + bigcall ComOnUart1_Init +#endif + #ifdef MODULES_MOTION bigcall Motion_Init #endif @@ -194,6 +198,10 @@ runModules_ComEnd: bigcall ComOnUart0_Run #endif +#ifdef MODULES_COMONUART1 + bigcall ComOnUart1_Run +#endif + #ifdef MODULES_STATS bigcall Stats_Run #endif @@ -215,6 +223,7 @@ runModules_ComEnd: ; rcall TCRT1K_Run #endif + ; add more modules here ret diff --git a/avr/modules/uart_hw/comonuart0.asm b/avr/modules/uart_hw/comonuart0.asm index 402dee0..1d6300c 100644 --- a/avr/modules/uart_hw/comonuart0.asm +++ b/avr/modules/uart_hw/comonuart0.asm @@ -38,8 +38,10 @@ ComOnUart0_Init: std Y+NET_IFACE_OFFS_IFACENUM, r16 sbi COM_IRQ_ADDR_ATTN, COM_IRQ_BIT_ATTN ; enable pin change irq for ATTN line + + in r16, GIMSK ; enable pin change irq PCIE0 or PCIE1 - ori r16, (1< Date: Mon, 30 Jun 2025 21:29:05 +0200 Subject: [PATCH 053/196] started working on improved UART_HW module. --- avr/devices/all/includes.asm | 8 +- avr/modules/uart_hw2/0BUILD | 12 + avr/modules/uart_hw2/comonuart1.asm | 816 ++++++++++++++++++++++++++++ avr/modules/uart_hw2/defs.asm | 43 ++ 4 files changed, 873 insertions(+), 6 deletions(-) create mode 100644 avr/modules/uart_hw2/0BUILD create mode 100644 avr/modules/uart_hw2/comonuart1.asm create mode 100644 avr/modules/uart_hw2/defs.asm diff --git a/avr/devices/all/includes.asm b/avr/devices/all/includes.asm index d28721b..37d6646 100644 --- a/avr/devices/all/includes.asm +++ b/avr/devices/all/includes.asm @@ -75,12 +75,8 @@ #endif #ifdef MODULES_COMONUART1 -#ifndef MODULES_COMONUART0 -.include "modules/uart_hw/defs.asm" -.include "modules/uart_hw/lowlevel.asm" -.include "modules/uart_hw/m_lowlevel_uart.asm" -#endif -.include "modules/uart_hw/comonuart1.asm" +.include "modules/uart_hw2/defs.asm" +.include "modules/uart_hw2/comonuart1.asm" #endif diff --git a/avr/modules/uart_hw2/0BUILD b/avr/modules/uart_hw2/0BUILD new file mode 100644 index 0000000..aecc13e --- /dev/null +++ b/avr/modules/uart_hw2/0BUILD @@ -0,0 +1,12 @@ + + + + + + comonuart1.asm + defs.asm + + + + + diff --git a/avr/modules/uart_hw2/comonuart1.asm b/avr/modules/uart_hw2/comonuart1.asm new file mode 100644 index 0000000..3df179b --- /dev/null +++ b/avr/modules/uart_hw2/comonuart1.asm @@ -0,0 +1,816 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + +#ifndef AVR_MODULES_UART_HW2_COMONUART1_H +#define AVR_MODULES_UART_HW2_COMONUART1_H + + +.dseg + +comOnUart1_iface: .byte UART_HW2_IFACE_SIZE + + + +.cseg + + + +; --------------------------------------------------------------------------- +; @routine ComOnUart1_Init @global +; +; @clobbers R16, R17, Y (X) + +ComOnUart1_Init: + ldi yl, LOW(comOnUart1_iface) + ldi yh, HIGH(comOnUart1_iface) + rcall NET_Interface_Init ; (R16, R17, X) + ldi r16, 0xff + std Y+UART_HW_IFACE_OFFS_WRITEBUFNUM, r16 + ldi r16, UART_HW2_MODE_IDLE + std Y+UART_HW2_IFACE_OFFS_MODE, r16 + clr r16 + std Y+NET_IFACE_OFFS_IFACENUM, r16 + rcall comOnUart1SetAttnInput + + ; set baudrate +.if clock == 8000000 + ldi r16, 25 ; (19.2Kb/s at 8MHz) + ldi r17, 0 +.endif + +.if clock == 1000000 + ldi r16, 2 ; (19.2Kb/s at 1MHz) + ldi r17, 0 +.endif + + sts UBRR1H, r17 + sts UBRR1L, r16 + + ; set character format + ldi r16, (1< Date: Tue, 1 Jul 2025 00:52:44 +0200 Subject: [PATCH 054/196] avr: new uart_hw2 module comonuart1 works now. --- avr/modules/uart_hw2/comonuart1.asm | 139 ++++++++++++++++------------ 1 file changed, 80 insertions(+), 59 deletions(-) diff --git a/avr/modules/uart_hw2/comonuart1.asm b/avr/modules/uart_hw2/comonuart1.asm index 3df179b..a9e3f27 100644 --- a/avr/modules/uart_hw2/comonuart1.asm +++ b/avr/modules/uart_hw2/comonuart1.asm @@ -31,13 +31,20 @@ ComOnUart1_Init: ldi yh, HIGH(comOnUart1_iface) rcall NET_Interface_Init ; (R16, R17, X) ldi r16, 0xff - std Y+UART_HW_IFACE_OFFS_WRITEBUFNUM, r16 + std Y+UART_HW2_IFACE_OFFS_WRITEBUFNUM, r16 ldi r16, UART_HW2_MODE_IDLE std Y+UART_HW2_IFACE_OFFS_MODE, r16 clr r16 std Y+NET_IFACE_OFFS_IFACENUM, r16 rcall comOnUart1SetAttnInput + sbi COM_IRQ_ADDR_ATTN1, COM_IRQ_BIT_ATTN1 ; enable pin change irq for ATTN line + inr r16, GIMSK ; enable pin change irq PCIE0 or PCIE1 + sbr r16, (1< Date: Wed, 2 Jul 2025 00:08:01 +0200 Subject: [PATCH 055/196] comonuart1: try to solve timing/irq problem. --- avr/modules/uart_hw2/comonuart1.asm | 31 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/avr/modules/uart_hw2/comonuart1.asm b/avr/modules/uart_hw2/comonuart1.asm index a9e3f27..9c15a1d 100644 --- a/avr/modules/uart_hw2/comonuart1.asm +++ b/avr/modules/uart_hw2/comonuart1.asm @@ -97,6 +97,7 @@ ComOnUart1_Periodically_end: ; ; @param R16 mode ; @clobbers R17 + comOnUart1SetMode: push r15 in r15, SREG @@ -127,7 +128,7 @@ comOnUart1StartReading: adiw xh:xl, UART_HW2_IFACE_OFFS_BUFFER std Y+UART_HW2_IFACE_OFFS_BUFPOS_LOW, xl std Y+UART_HW2_IFACE_OFFS_BUFPOS_HIGH, xh - ldi r16, UART_HW2_BUFFER_SIZE + ldi r16, UART_HW2_BUFFER_SIZE-1 std Y+UART_HW2_IFACE_OFFS_BUFLEFT, r16 clr r16 std Y+UART_HW2_IFACE_OFFS_BUFUSED, r16 @@ -195,23 +196,13 @@ comOnUart1StartWriting_end: ComOnUart1_Run: ldi yl, LOW(comOnUart1_iface) ldi yh, HIGH(comOnUart1_iface) - push r15 - in r15, SREG - cli - ldd r16, Y+UART_HW2_IFACE_OFFS_MODE - out SREG, r15 - pop r15 + ldd r16, Y+UART_HW2_IFACE_OFFS_MODE ComOnUart1_Run_loop: push r16 ; current state rcall comOnUart1RunMode ; (all but Y) pop r17 ; previous state (pop from r16 into r17) ; read new state - push r15 - in r15, SREG - cli - ldd r16, Y+UART_HW2_IFACE_OFFS_MODE - out SREG, r15 - pop r15 + ldd r16, Y+UART_HW2_IFACE_OFFS_MODE cp r16, r17 brne ComOnUart1_Run_loop ; state changed, run again ret @@ -460,7 +451,8 @@ comOnUart1StartTx: cbr r16, (1< Date: Wed, 2 Jul 2025 00:10:46 +0200 Subject: [PATCH 056/196] comonuart1: undid some of the latest changes. --- avr/modules/uart_hw2/comonuart1.asm | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/avr/modules/uart_hw2/comonuart1.asm b/avr/modules/uart_hw2/comonuart1.asm index 9c15a1d..f93b950 100644 --- a/avr/modules/uart_hw2/comonuart1.asm +++ b/avr/modules/uart_hw2/comonuart1.asm @@ -451,8 +451,7 @@ comOnUart1StartTx: cbr r16, (1< Date: Thu, 3 Jul 2025 00:16:29 +0200 Subject: [PATCH 057/196] comonuart1: fixed bit names, disable IRQ when starting to write. --- avr/modules/uart_hw2/comonuart1.asm | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/avr/modules/uart_hw2/comonuart1.asm b/avr/modules/uart_hw2/comonuart1.asm index f93b950..3cba555 100644 --- a/avr/modules/uart_hw2/comonuart1.asm +++ b/avr/modules/uart_hw2/comonuart1.asm @@ -149,6 +149,22 @@ comOnUart1StartReading: ; @clobbers R16, R17, X, Z (R22, R24, R25) comOnUart1StartWriting: + push r15 + inr r15, SREG + cli + rcall comOnUart1StartWriting_noIrq + brcc comOnUart1StartWriting_clc + outr SREG, r15 + pop r15 + sec + ret +comOnUart1StartWriting_clc: + outr SREG, r15 + pop r15 + clc + ret + +comOnUart1StartWriting_noIrq: rcall comOnUart1AcquireAttn ; (R22) brcc comOnUart1StartWriting_ebusy ; copy buffer @@ -451,7 +467,7 @@ comOnUart1StartTx: cbr r16, (1< Date: Thu, 3 Jul 2025 22:11:27 +0200 Subject: [PATCH 058/196] added test firmware for r04. --- avr/devices/r04/0BUILD | 1 + avr/devices/r04/aqua_r04.xml | 26 +++- avr/devices/r04/boot/boot.asm | 1 + avr/devices/r04/defs.asm | 30 ++-- avr/devices/r04/main/main.asm | 169 ++++++++++++++-------- avr/devices/r04/test/0BUILD | 33 +++++ avr/devices/r04/test/main.asm | 264 ++++++++++++++++++++++++++++++++++ 7 files changed, 448 insertions(+), 76 deletions(-) create mode 100644 avr/devices/r04/test/0BUILD create mode 100644 avr/devices/r04/test/main.asm diff --git a/avr/devices/r04/0BUILD b/avr/devices/r04/0BUILD index 9622ec9..31fee02 100644 --- a/avr/devices/r04/0BUILD +++ b/avr/devices/r04/0BUILD @@ -5,6 +5,7 @@ boot main + test diff --git a/avr/devices/r04/aqua_r04.xml b/avr/devices/r04/aqua_r04.xml index e591864..865441c 100644 --- a/avr/devices/r04/aqua_r04.xml +++ b/avr/devices/r04/aqua_r04.xml @@ -7,13 +7,25 @@ - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/avr/devices/r04/boot/boot.asm b/avr/devices/r04/boot/boot.asm index d86fa14..ac3da73 100644 --- a/avr/devices/r04/boot/boot.asm +++ b/avr/devices/r04/boot/boot.asm @@ -39,6 +39,7 @@ .equ LED_PINNUM = PORTB2 + ; *************************************************************************** ; code segment diff --git a/avr/devices/r04/defs.asm b/avr/devices/r04/defs.asm index 395711f..e89b454 100644 --- a/avr/devices/r04/defs.asm +++ b/avr/devices/r04/defs.asm @@ -62,16 +62,28 @@ .equ COM_DATA_PUE = PUEA .equ COM_DATA_PIN = PORTA2 -.equ COM_ATTN_DDR = DDRA -.equ COM_ATTN_INPUT = PINA -.equ COM_ATTN_OUTPUT = PORTA -.equ COM_ATTN_PUE = PUEA -.equ COM_ATTN_PIN = PORTA0 +.equ COM_ATTN0_DDR = DDRA +.equ COM_ATTN0_INPUT = PINA +.equ COM_ATTN0_OUTPUT = PORTA +.equ COM_ATTN0_PUE = PUEA +.equ COM_ATTN0_PIN = PORTA0 -.equ COM_IRQ_ADDR_ATTN = PCMSK0 -.equ COM_IRQ_BIT_ATTN = PCINT0 ; bit 0 in PCMSK0 -.equ COM_IRQ_GIFR_ATTN = PCIF0 -.equ COM_IRQ_GIMSK_ATTN = PCIE0 +.equ COM_IRQ_ADDR_ATTN0 = PCMSK0 +.equ COM_IRQ_BIT_ATTN0 = PCINT0 ; bit 0 in PCMSK0 +.equ COM_IRQ_GIFR_ATTN0 = PCIF0 +.equ COM_IRQ_GIMSK_ATTN0 = PCIE0 + +; compatibility +.equ COM_ATTN_DDR = COM_ATTN0_DDR +.equ COM_ATTN_INPUT = COM_ATTN0_INPUT +.equ COM_ATTN_OUTPUT = COM_ATTN0_OUTPUT +.equ COM_ATTN_PUE = COM_ATTN0_PUE +.equ COM_ATTN_PIN = COM_ATTN0_PIN + +.equ COM_IRQ_ADDR_ATTN = COM_IRQ_ADDR_ATTN0 +.equ COM_IRQ_BIT_ATTN = COM_IRQ_BIT_ATTN0 +.equ COM_IRQ_GIFR_ATTN = COM_IRQ_GIFR_ATTN0 +.equ COM_IRQ_GIMSK_ATTN = COM_IRQ_GIMSK_ATTN0 ; settings for comOnUart1 diff --git a/avr/devices/r04/main/main.asm b/avr/devices/r04/main/main.asm index d3a69fa..71f8590 100644 --- a/avr/devices/r04/main/main.asm +++ b/avr/devices/r04/main/main.asm @@ -47,12 +47,16 @@ ; --------------------------------------------------------------------------- ; generic +.equ COMONUART0_IFACENUM = 1 +.equ COMONUART1_IFACENUM = 2 + ; --------------------------------------------------------------------------- ; firmware settings including list of modules used #define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes +#define APP_STATS_NETDEV2 #define MODULES_CLOCK ;#define MODULES_COM @@ -73,12 +77,14 @@ ;#define MODULES_TTYONUART1 #define MODULES_COMONUART0 #define MODULES_COMONUART1 + #define APPS_STATS #define APPS_NETWORK +;#define APPS_REPORTSENSORS -.equ NET_BUFFERS_NUM = 12 +.equ NET_BUFFERS_NUM = 9 .equ NET_BUFFERS_SIZE = 32 .equ UART_HW_MSGNUMINBUF_SIZE = 8 @@ -89,6 +95,8 @@ ; --------------------------------------------------------------------------- ; defines for values +.equ VALUE_ID_DS18B20_TEMP = 0x06 + .equ VALUE_ID_LEDSIMPLE_TIMING = 0x88 @@ -159,10 +167,13 @@ firmwareStart: ; @routine onSystemStart onSystemStart: - clr r16 - sts debugCounter, r16 - ldi r16, 0xff - sts attnByte, r16 + ; set interface number for UART0 + ldi r16, COMONUART0_IFACENUM + sts comOnUart0_iface+NET_IFACE_OFFS_IFACENUM, r16 + ; set interface number for UART1 + ldi r16, COMONUART1_IFACENUM + sts comOnUart1_iface+NET_IFACE_OFFS_IFACENUM, r16 + ret ; @end @@ -182,7 +193,8 @@ onEveryDay: onEveryMinute: rcall sendPacketsIface2In - rcall sendErrorsIface2 +; rcall sendErrorsIface2 + rcall sendDeviceUart1 ret ; @end @@ -223,16 +235,13 @@ onAttnChangeIsr: push r15 in r15, SREG push r16 - in r16, COM_ATTN_INPUT - push r17 - lds r17, attnByte - sts attnByte, r16 - eor r17, r16 - sbrc r17, COM_ATTN1_PIN - rcall onAttnChangeAttn1 - sbrc r17, COM_ATTN_PIN - rcall onAttnChangeAttn0 - pop r17 + inr r16, COM_ATTN1_INPUT + sbrs r16, COM_ATTN1_PIN + rcall ComOnUart1_HandleAttnChange ; (none) + + inr r16, COM_ATTN0_INPUT + sbrs r16, COM_ATTN0_PIN + rcall ComOnUart0_HandleAttnChange ; (none) pop r16 out SREG, r15 pop r15 @@ -241,18 +250,6 @@ onAttnChangeIsr: -onAttnChangeAttn0: - sbrs r16, COM_ATTN_PIN - rcall ComOnUart0_HandleAttnChange ; (none) - ret - -onAttnChangeAttn1: - sbrs r16, COM_ATTN1_PIN - rcall ComOnUart1_HandleAttnChange ; (none) - ret - - - ; --------------------------------------------------------------------------- ; @routine checkRecvdMsg ; @@ -267,18 +264,16 @@ checkRecvdMsg: push xl push xh adiw xh:xl, 1 - rcall onMessageReceived - rcall mainModulesOnPacketReceived - rcall mainAppsOnPacketReceived + rcall letSysHandleMsg pop xh pop xl pop r16 ; forward to other interface ld r17, X - andi r17, (NET_IFACE_BUFFER_IFACENUM1_BIT | NET_IFACE_BUFFER_IFACENUM0_BIT) - rcall reverseInterfaceNum ; (R16, R17) -; ldi r17, COMONUART0_IFACENUM ; DEBUG: send everything to uart0 to test that code first + andi r17, (1< + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + main.asm + + + + + + + + + + + + + + + + + diff --git a/avr/devices/r04/test/main.asm b/avr/devices/r04/test/main.asm new file mode 100644 index 0000000..53981c5 --- /dev/null +++ b/avr/devices/r04/test/main.asm @@ -0,0 +1,264 @@ +; *************************************************************************** +; 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/tn841def.inc" ; Define device ATtiny841 +.list + +.include "../defs.asm" +.include "version.asm" +;.include "defs_all.asm" + +.include "devices/all/defs.asm" + +.include "common/calls.asm" +.include "common/utils_wait.asm" +.include "common/utils_io.asm" + + + +; *************************************************************************** +; defines + +; --------------------------------------------------------------------------- +; generic + +.equ COMONUART0_IFACENUM = 1 +.equ COMONUART1_IFACENUM = 2 + + +; --------------------------------------------------------------------------- +; firmware settings including list of modules used + + +;#define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes +;#define APP_STATS_NETDEV2 + +#define MODULES_CLOCK +;#define MODULES_COM +;#define MODULES_COM_WITH_ADDR_PROTO +;#define MODULES_LED +#define MODULES_LED_SIMPLE +;#define MODULES_TWI_MASTER +;#define MODULES_LCD +;#define LCD_MINIMAL_FONT +;#define MODULES_SI7021 +;#define MODULES_STATS +;#define MODULES_CNY70 +;#define MODULES_REED +#define MODULES_OWI_MASTER +#define MODULES_DS18B20 +;#define MODULES_MOTION +#define MODULES_NETWORK +;#define MODULES_TTYONUART1 +#define MODULES_COMONUART0 +;#define MODULES_COMONUART1 + +#define APPS_STATS +#define APPS_NETWORK +#define APPS_REPORTSENSORS + + + +.equ NET_BUFFERS_NUM = 8 +.equ NET_BUFFERS_SIZE = 32 + +.equ UART_HW_MSGNUMINBUF_SIZE = 8 +.equ UART_HW_MSGNUMOUTBUF_SIZE = 8 + + + +; --------------------------------------------------------------------------- +; defines for values + +.equ VALUE_ID_DS18B20_TEMP = 0x06 + +.equ VALUE_ID_LEDSIMPLE_TIMING = 0x88 + + +; *************************************************************************** +; code segment + +.cseg +.org 000000 + + + +; --------------------------------------------------------------------------- +; Reset and interrupt vectors + + rjmp BOOTLOADER_ADDR ; 1: RESET Reset vector use this for flashed system + reti ; 2: INT0 External Interrupt Request 0 + rjmp onAttnChangeIsr ; 3: PCINT0 Pin Change Interrupt 0 + reti ; 4: PCINT1 Pin Change Interrupt 1 + reti ; 5: WDT Watchdog Time-out + reti ; 6: TIM1_CAPT Timer/Counter1 Capture Event + reti ; 7: TIM1_COMPA (OC1A) Timer/Counter1 Compare Match A + reti ; 8: TIM1_COMPB (OC1B) Timer/Counter1 Compare Match B + reti ; 9: TIM1_OVF (OVF1) Timer/Counter1 Overflow + rjmp baseTimerIrqOC0A ; 10: TIM0_COMPA (OC0A) Timer/Counter0 Compare Match A + reti ; 11: TIM0_COMPB (OC0B) Timer/Counter0 Compare Match B + reti ; 12: TIM0_OVF (OVF0) Timer/Counter0 Overflow + reti ; 13: ANA_COMP0 Analog Comparator 0 + reti ; 14: ADC_READY ADC Conversion Complete + reti ; 15: EE_RDY (ERDY) EEPROM Ready + reti ; 16: ANA_COMP1 Analog Comparator 1 + reti ; 17: TIM2_CAPT Timer/Counter2 Capture Event + reti ; 18: TIM2_COMPA (OC2A) Timer/Counter2 Compare Match A + reti ; 19: TIM2_COMPB (OC2B) Timer/Counter2 Compare Match B + reti ; 20: TIM2_OVF (OVF2) Timer/Counter2 Overflow + reti ; 21: SPI SPI Serial Transfer Complete + reti ; 22: USART0_RXS USART0 Rx Start + rjmp ComOnUart0_RxCharIsr ; 23: USART0_RXC USART0 Rx Complete + rjmp ComOnUart0_TxUdreIsr ; 24: USART0_DRE USART0 Data Register Empty + rjmp ComOnUart0_TxCharIsr ; 25: USART0_TXC USART0 Tx Complete + reti ; 26: USART1_RXS USART1 Rx Start +; rjmp ComOnUart1_RxCharIsr ; 27: USART1_RXC USART1 Rx Complete + reti ; 27: USART1_RXC USART1 Rx Complete +; rjmp ComOnUart1_TxUdreIsr ; 28: USART1_DRE USART1 Data Register Empty + reti ; 28: USART1_DRE USART1 Data Register Empty +; rjmp ComOnUart1_TxCharIsr ; 29: USART1_TXC USART1 Tx Complete + reti ; 29: USART1_TXC USART1 Tx Complete + reti ; 30: TWI Two-Wire-Interface + reti ; 31: RESERVED reserved + + + +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: + ; set interface number for UART0 + ldi r16, COMONUART0_IFACENUM + sts comOnUart0_iface+NET_IFACE_OFFS_IFACENUM, r16 + ; set interface number for UART1 +; ldi r16, COMONUART1_IFACENUM +; sts comOnUart1_iface+NET_IFACE_OFFS_IFACENUM, r16 + + ret +; @end + + + + + + + +onEvery100ms: +onEverySecond: +onEveryMinute: +onEveryHour: +onEveryDay: + ret + + + + +; --------------------------------------------------------------------------- +; @routine onEveryLoop +; +; Called on every loop (i.e. after awakening from sleep). + +onEveryLoop: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine onMessageReceived +; +; Called on every message received + +onMessageReceived: + clc + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine onAttnChange @global @isr +; +; Called whenever PCINT0 is activated. +; This code assumes that both ATTN pins are on the same port which is true for +; R04 nodes. + +onAttnChangeIsr: + push r15 + in r15, SREG + push r16 +; inr r16, COM_ATTN1_INPUT +; sbrs r16, COM_ATTN1_PIN +; rcall ComOnUart1_HandleAttnChange ; (none) + +; inr r16, COM_ATTN0_INPUT +; sbrs r16, COM_ATTN0_PIN + rcall ComOnUart0_HandleAttnChange ; (none) + pop r16 + out SREG, r15 + pop r15 + reti +; @end + + + + +; *************************************************************************** +; includes + +.include "devices/all/hw_tn841.asm" +.include "devices/all/includes.asm" + + + + +; --------------------------------------------------------------------------- +; defines for network interface + +.equ netInterfaceData = comOnUart0_iface +;.equ netInterfaceData2 = comOnUart1_iface + + From fc5394a5c9170ffa90e1984d67ce7014c4d062ac Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Thu, 3 Jul 2025 22:12:40 +0200 Subject: [PATCH 059/196] avr: added comonuart0 works fine so far. --- avr/modules/uart_hw2/comonuart0.asm | 847 ++++++++++++++++++++++++++++ 1 file changed, 847 insertions(+) create mode 100644 avr/modules/uart_hw2/comonuart0.asm diff --git a/avr/modules/uart_hw2/comonuart0.asm b/avr/modules/uart_hw2/comonuart0.asm new file mode 100644 index 0000000..c5cd661 --- /dev/null +++ b/avr/modules/uart_hw2/comonuart0.asm @@ -0,0 +1,847 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + +#ifndef AVR_MODULES_UART_HW2_COMONUART0_H +#define AVR_MODULES_UART_HW2_COMONUART0_H + + +.dseg + +comOnUart0_iface: .byte UART_HW2_IFACE_SIZE + + + +.cseg + + + +; --------------------------------------------------------------------------- +; @routine ComOnUart0_Init @global +; +; @clobbers R16, R17, Y (X) + +ComOnUart0_Init: + rcall comOnUart0StopRx + rcall comOnUart0StopTx + + ldi yl, LOW(comOnUart0_iface) + ldi yh, HIGH(comOnUart0_iface) + rcall NET_Interface_Init ; (R16, R17, X) + ldi r16, 0xff + std Y+UART_HW2_IFACE_OFFS_WRITEBUFNUM, r16 + ldi r16, UART_HW2_MODE_IDLE + std Y+UART_HW2_IFACE_OFFS_MODE, r16 + clr r16 + std Y+NET_IFACE_OFFS_IFACENUM, r16 + rcall comOnUart0SetAttnInput + + sbi COM_IRQ_ADDR_ATTN0, COM_IRQ_BIT_ATTN0 ; enable pin change irq for ATTN line + inr r16, GIMSK ; enable pin change irq PCIE0 or PCIE1 + sbr r16, (1< Date: Sun, 6 Jul 2025 12:21:41 +0200 Subject: [PATCH 060/196] uart_hw2: basically works, but skips messages. --- avr/modules/uart_hw2/comonuart0.asm | 4 +- avr/modules/uart_hw2/comonuart1.asm | 53 +- avr/modules/uart_hw2/defs.asm | 12 + avr/modules/uart_hw2/ttyonuart1.asm | 739 ++++++++++++++++++++++++++++ avr/version.asm | 2 +- 5 files changed, 791 insertions(+), 19 deletions(-) create mode 100644 avr/modules/uart_hw2/ttyonuart1.asm diff --git a/avr/modules/uart_hw2/comonuart0.asm b/avr/modules/uart_hw2/comonuart0.asm index c5cd661..2766b59 100644 --- a/avr/modules/uart_hw2/comonuart0.asm +++ b/avr/modules/uart_hw2/comonuart0.asm @@ -466,7 +466,7 @@ comOnUart0StopRx: ; @clobbers R16 comOnUart0StartTx: - lds r16, UCSR0A + inr r16, UCSR0A cbr r16, (1< Date: Sun, 6 Jul 2025 12:22:22 +0200 Subject: [PATCH 061/196] added code to read calibration data. --- avr/devices/all/hw_tn841.asm | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/avr/devices/all/hw_tn841.asm b/avr/devices/all/hw_tn841.asm index 1804319..9f2924b 100644 --- a/avr/devices/all/hw_tn841.asm +++ b/avr/devices/all/hw_tn841.asm @@ -19,14 +19,14 @@ systemInitHardware: ; set all ports as inputs and enable internal pull-up resistors - ldi r16, 0xff +; ldi r16, 0xff clr r17 - out DDRA, r17 ; all input - sts PUEA, r16 ; enable pull-up on all + outr DDRA, r17 ; all input + outr PUEA, r17 ; disable pull-up on all - out DDRB, r17 ; all input - sts PUEB, r16 ; enable pull-up on all + outr DDRB, r17 ; all input + outr PUEB, r17 ; disable pull-up on all ret ; @end @@ -50,6 +50,22 @@ systemSetSpeed: clr r16 ; SUT=0, CLKPS=0 sts CCP, r17 sts CLKPR, r16 + +#if 0 + ; read and set calibration data + push r15 + inr r15, SREG + cli + ldi zl, 0 + ldi zh, 1 + ldi r16, (1< Date: Sun, 6 Jul 2025 12:22:50 +0200 Subject: [PATCH 062/196] use uart_hw2 now. --- avr/devices/all/includes.asm | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/avr/devices/all/includes.asm b/avr/devices/all/includes.asm index 37d6646..35219b4 100644 --- a/avr/devices/all/includes.asm +++ b/avr/devices/all/includes.asm @@ -68,25 +68,31 @@ #ifdef MODULES_COMONUART0 -.include "modules/uart_hw/defs.asm" -.include "modules/uart_hw/lowlevel.asm" -.include "modules/uart_hw/m_lowlevel_uart.asm" -.include "modules/uart_hw/comonuart0.asm" +;.include "modules/uart_hw/defs.asm" +;.include "modules/uart_hw/lowlevel.asm" +;.include "modules/uart_hw/m_lowlevel_uart.asm" +;.include "modules/uart_hw/comonuart0.asm" +.include "modules/uart_hw2/defs.asm" +.include "modules/uart_hw2/comonuart0.asm" #endif #ifdef MODULES_COMONUART1 +;.include "modules/uart_hw/defs.asm" +;.include "modules/uart_hw/lowlevel.asm" +;.include "modules/uart_hw/m_lowlevel_uart.asm" +;.include "modules/uart_hw/comonuart1.asm" .include "modules/uart_hw2/defs.asm" .include "modules/uart_hw2/comonuart1.asm" #endif #ifdef MODULES_TTYONUART1 -#ifndef MODULES_COMONUART0 .include "modules/uart_hw/defs.asm" .include "modules/uart_hw/lowlevel.asm" .include "modules/uart_hw/m_lowlevel_uart.asm" -#endif .include "modules/uart_hw/ttyonuart1.asm" +;.include "modules/uart_hw2/defs.asm" +;.include "modules/uart_hw2/ttyonuart1.asm" #endif From 4ad508eca6e32cbc72a7bc3ce63947caf6e75a18 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 6 Jul 2025 12:23:49 +0200 Subject: [PATCH 063/196] n27: removed driver for SGP30 (is now used externally in n26). --- avr/devices/n27/defs.asm | 7 ------- avr/devices/n27/main/main.asm | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/avr/devices/n27/defs.asm b/avr/devices/n27/defs.asm index 32f1cdc..26d3f8b 100644 --- a/avr/devices/n27/defs.asm +++ b/avr/devices/n27/defs.asm @@ -89,13 +89,6 @@ -; --------------------------------------------------------------------------- -; LCD module - -.equ LCD_TWI_ADDRESS = 0x3c - - - ; --------------------------------------------------------------------------- ; SI 7021 diff --git a/avr/devices/n27/main/main.asm b/avr/devices/n27/main/main.asm index 7a1e810..69b0bfe 100644 --- a/avr/devices/n27/main/main.asm +++ b/avr/devices/n27/main/main.asm @@ -66,7 +66,7 @@ ;#define MODULES_LCD ;#define LCD_MINIMAL_FONT #define MODULES_SI7021 -#define MODULES_SGP30 +;#define MODULES_SGP30 ;#define MODULES_SGP40 ;#define MODULES_STATS ;#define MODULES_OWI_MASTER From 5bda393b10e62dfa46b253ef55e728d3a0f2dcd3 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 6 Jul 2025 12:24:46 +0200 Subject: [PATCH 064/196] added valueids for stats from 2nd network device. --- avr/devices/all/defs.asm | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/avr/devices/all/defs.asm b/avr/devices/all/defs.asm index d81b01a..0cdbfd5 100644 --- a/avr/devices/all/defs.asm +++ b/avr/devices/all/defs.asm @@ -32,11 +32,21 @@ .equ AQHOME_VALUEID_STATS_ERRS_NOBUF = 0xe4 .equ AQHOME_VALUEID_STATS_ERRS_COLLISIONS = 0xe5 .equ AQHOME_VALUEID_STATS_ERRS_BUSY = 0xe6 -.equ AQHOME_VALUEID_STATS_HEAP_USED = 0xe7 -.equ AQHOME_VALUEID_STATS_HEAP_FREE = 0xe8 +.equ AQHOME_VALUEID_STATS_ERRS_MSGSIZE = 0xe7 +.equ AQHOME_VALUEID_STATS_ERRS_MISSED = 0xe8 +.equ AQHOME_VALUEID_STATS_PACKETS_IN2 = 0xe9 +.equ AQHOME_VALUEID_STATS_PACKETS_OUT2 = 0xea +.equ AQHOME_VALUEID_STATS_ERRS_CONTENT2 = 0xeb +.equ AQHOME_VALUEID_STATS_ERRS_IO2 = 0xec +.equ AQHOME_VALUEID_STATS_ERRS_NOBUF2 = 0xed +.equ AQHOME_VALUEID_STATS_ERRS_COLLISIONS2 = 0xee +.equ AQHOME_VALUEID_STATS_ERRS_BUSY2 = 0xef +.equ AQHOME_VALUEID_STATS_ERRS_MSGSIZE2 = 0xf0 +.equ AQHOME_VALUEID_STATS_ERRS_MISSED2 = 0xf1 -.equ AQHOME_VALUEID_STATS_PACKETS2_IN = 0xe9 +.equ AQHOME_VALUEID_STATS_HEAP_USED = 0xf2 +.equ AQHOME_VALUEID_STATS_HEAP_FREE = 0xf3 ; --------------------------------------------------------------------------- From b56ab22117a5951bd1228b6dfecdf1c9c50f3688 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 6 Jul 2025 14:34:55 +0200 Subject: [PATCH 065/196] more work on test firmware for r04 --- avr/devices/r04/defs.asm | 10 ++++---- avr/devices/r04/test/main.asm | 46 ++++++++++++++++------------------- 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/avr/devices/r04/defs.asm b/avr/devices/r04/defs.asm index e89b454..b4de9c0 100644 --- a/avr/devices/r04/defs.asm +++ b/avr/devices/r04/defs.asm @@ -74,11 +74,11 @@ .equ COM_IRQ_GIMSK_ATTN0 = PCIE0 ; compatibility -.equ COM_ATTN_DDR = COM_ATTN0_DDR -.equ COM_ATTN_INPUT = COM_ATTN0_INPUT -.equ COM_ATTN_OUTPUT = COM_ATTN0_OUTPUT -.equ COM_ATTN_PUE = COM_ATTN0_PUE -.equ COM_ATTN_PIN = COM_ATTN0_PIN +;.equ COM_ATTN_DDR = COM_ATTN0_DDR +;.equ COM_ATTN_INPUT = COM_ATTN0_INPUT +;.equ COM_ATTN_OUTPUT = COM_ATTN0_OUTPUT +;.equ COM_ATTN_PUE = COM_ATTN0_PUE +;.equ COM_ATTN_PIN = COM_ATTN0_PIN .equ COM_IRQ_ADDR_ATTN = COM_IRQ_ADDR_ATTN0 .equ COM_IRQ_BIT_ATTN = COM_IRQ_BIT_ATTN0 diff --git a/avr/devices/r04/test/main.asm b/avr/devices/r04/test/main.asm index 53981c5..456d6e0 100644 --- a/avr/devices/r04/test/main.asm +++ b/avr/devices/r04/test/main.asm @@ -75,8 +75,8 @@ ;#define MODULES_MOTION #define MODULES_NETWORK ;#define MODULES_TTYONUART1 -#define MODULES_COMONUART0 -;#define MODULES_COMONUART1 +;#define MODULES_COMONUART0 +#define MODULES_COMONUART1 #define APPS_STATS #define APPS_NETWORK @@ -133,16 +133,19 @@ reti ; 20: TIM2_OVF (OVF2) Timer/Counter2 Overflow reti ; 21: SPI SPI Serial Transfer Complete reti ; 22: USART0_RXS USART0 Rx Start - rjmp ComOnUart0_RxCharIsr ; 23: USART0_RXC USART0 Rx Complete - rjmp ComOnUart0_TxUdreIsr ; 24: USART0_DRE USART0 Data Register Empty - rjmp ComOnUart0_TxCharIsr ; 25: USART0_TXC USART0 Tx Complete +; rjmp ComOnUart0_RxCharIsr ; 23: USART0_RXC USART0 Rx Complete + reti ; 23: USART0_RXC USART0 Rx Complete +; rjmp ComOnUart0_TxUdreIsr ; 24: USART0_DRE USART0 Data Register Empty + reti ; 24: USART0_DRE USART0 Data Register Empty +; rjmp ComOnUart0_TxCharIsr ; 25: USART0_TXC USART0 Tx Complete + reti ; 25: USART0_TXC USART0 Tx Complete reti ; 26: USART1_RXS USART1 Rx Start -; rjmp ComOnUart1_RxCharIsr ; 27: USART1_RXC USART1 Rx Complete - reti ; 27: USART1_RXC USART1 Rx Complete -; rjmp ComOnUart1_TxUdreIsr ; 28: USART1_DRE USART1 Data Register Empty - reti ; 28: USART1_DRE USART1 Data Register Empty -; rjmp ComOnUart1_TxCharIsr ; 29: USART1_TXC USART1 Tx Complete - reti ; 29: USART1_TXC USART1 Tx Complete + rjmp ComOnUart1_RxCharIsr ; 27: USART1_RXC USART1 Rx Complete +; reti ; 27: USART1_RXC USART1 Rx Complete + rjmp ComOnUart1_TxUdreIsr ; 28: USART1_DRE USART1 Data Register Empty +; reti ; 28: USART1_DRE USART1 Data Register Empty + rjmp ComOnUart1_TxCharIsr ; 29: USART1_TXC USART1 Tx Complete +; reti ; 29: USART1_TXC USART1 Tx Complete reti ; 30: TWI Two-Wire-Interface reti ; 31: RESERVED reserved @@ -171,11 +174,11 @@ firmwareStart: onSystemStart: ; set interface number for UART0 - ldi r16, COMONUART0_IFACENUM - sts comOnUart0_iface+NET_IFACE_OFFS_IFACENUM, r16 +; ldi r16, COMONUART0_IFACENUM +; sts comOnUart0_iface+NET_IFACE_OFFS_IFACENUM, r16 ; set interface number for UART1 -; ldi r16, COMONUART1_IFACENUM -; sts comOnUart1_iface+NET_IFACE_OFFS_IFACENUM, r16 + ldi r16, COMONUART1_IFACENUM + sts comOnUart1_iface+NET_IFACE_OFFS_IFACENUM, r16 ret ; @end @@ -229,15 +232,8 @@ onMessageReceived: onAttnChangeIsr: push r15 in r15, SREG - push r16 -; inr r16, COM_ATTN1_INPUT -; sbrs r16, COM_ATTN1_PIN -; rcall ComOnUart1_HandleAttnChange ; (none) - -; inr r16, COM_ATTN0_INPUT -; sbrs r16, COM_ATTN0_PIN - rcall ComOnUart0_HandleAttnChange ; (none) - pop r16 + rcall ComOnUart1_HandleAttnChange ; (none) +; rcall ComOnUart0_HandleAttnChange ; (none) out SREG, r15 pop r15 reti @@ -258,7 +254,7 @@ onAttnChangeIsr: ; --------------------------------------------------------------------------- ; defines for network interface -.equ netInterfaceData = comOnUart0_iface +.equ netInterfaceData = comOnUart1_iface ;.equ netInterfaceData2 = comOnUart1_iface From b059f4a56e1f302a277ab16e0f2d762b9c944589 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 6 Jul 2025 14:35:22 +0200 Subject: [PATCH 066/196] added node r05. --- avr/devices/0BUILD | 2 + avr/devices/r05/.gitignore | 2 + avr/devices/r05/0BUILD | 23 +++ avr/devices/r05/README | 0 avr/devices/r05/aqua_r05.xml | 24 +++ avr/devices/r05/boot/0BUILD | 32 ++++ avr/devices/r05/boot/boot.asm | 151 +++++++++++++++ avr/devices/r05/defs.asm | 134 +++++++++++++ avr/devices/r05/main/0BUILD | 33 ++++ avr/devices/r05/main/main.asm | 347 ++++++++++++++++++++++++++++++++++ avr/devices/r05/test/0BUILD | 33 ++++ avr/devices/r05/test/main.asm | 242 ++++++++++++++++++++++++ 12 files changed, 1023 insertions(+) create mode 100644 avr/devices/r05/.gitignore create mode 100644 avr/devices/r05/0BUILD create mode 100644 avr/devices/r05/README create mode 100644 avr/devices/r05/aqua_r05.xml create mode 100644 avr/devices/r05/boot/0BUILD create mode 100644 avr/devices/r05/boot/boot.asm create mode 100644 avr/devices/r05/defs.asm create mode 100644 avr/devices/r05/main/0BUILD create mode 100644 avr/devices/r05/main/main.asm create mode 100644 avr/devices/r05/test/0BUILD create mode 100644 avr/devices/r05/test/main.asm diff --git a/avr/devices/0BUILD b/avr/devices/0BUILD index 9662863..67b5e1f 100644 --- a/avr/devices/0BUILD +++ b/avr/devices/0BUILD @@ -37,6 +37,8 @@ n25 n26 n27 + r04 + r05 t03 diff --git a/avr/devices/r05/.gitignore b/avr/devices/r05/.gitignore new file mode 100644 index 0000000..8e0618c --- /dev/null +++ b/avr/devices/r05/.gitignore @@ -0,0 +1,2 @@ +*.eep.hex +*.obj diff --git a/avr/devices/r05/0BUILD b/avr/devices/r05/0BUILD new file mode 100644 index 0000000..9e83ec2 --- /dev/null +++ b/avr/devices/r05/0BUILD @@ -0,0 +1,23 @@ + + + + + + boot + main + test + + + + defs.asm + README + + + + aqua_r05.xml + + + + + + diff --git a/avr/devices/r05/README b/avr/devices/r05/README new file mode 100644 index 0000000..e69de29 diff --git a/avr/devices/r05/aqua_r05.xml b/avr/devices/r05/aqua_r05.xml new file mode 100644 index 0000000..d8d51a2 --- /dev/null +++ b/avr/devices/r05/aqua_r05.xml @@ -0,0 +1,24 @@ + + + AQUA + R + 5 + + + + + + + + + + + + + + + + + + + diff --git a/avr/devices/r05/boot/0BUILD b/avr/devices/r05/boot/0BUILD new file mode 100644 index 0000000..3a65629 --- /dev/null +++ b/avr/devices/r05/boot/0BUILD @@ -0,0 +1,32 @@ + + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + boot.asm + + + + + + + + + + + + + + + + diff --git a/avr/devices/r05/boot/boot.asm b/avr/devices/r05/boot/boot.asm new file mode 100644 index 0000000..d86fa14 --- /dev/null +++ b/avr/devices/r05/boot/boot.asm @@ -0,0 +1,151 @@ +; *************************************************************************** +; 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 +.equ clock=8000000 ; Define the clock frequency + +.nolist +.include "include/tn841def.inc" ; Define device ATtiny841 +.list + +.include "version.asm" +.include "../defs.asm" +.include "devices/all/defs.asm" + +.include "common/calls.asm" +.include "common/utils_wait.asm" + + + +; *************************************************************************** +; defines + + +;#define COM_ACCEPT_ALL_DEST 1 + + + +; --------------------------------------------------------------------------- +; LED + +.equ LED_DDR = DDRB +.equ LED_PORT = PORTB +.equ LED_PIN = PINB +.equ LED_PINNUM = PORTB2 + + +; *************************************************************************** +; code segment + +.cseg +.org 0x0000 + + + +; --------------------------------------------------------------------------- +; Reset and interrupt vectors + + rjmp main ; 1: RESET Reset vector use this for flashed system + reti ; 2: INT0 External Interrupt Request 0 + reti ; 3: PCINT0 Pin Change Interrupt 0 + reti ; 4: PCINT1 Pin Change Interrupt 1 + reti ; 5: WDT Watchdog Time-out + reti ; 6: TIM1_CAPT Timer/Counter1 Capture Event + reti ; 7: TIM1_COMPA (OC1A) Timer/Counter1 Compare Match A + reti ; 8: TIM1_COMPB (OC1B) Timer/Counter1 Compare Match B + reti ; 9: TIM1_OVF (OVF1) Timer/Counter1 Overflow + reti ; 10: TIM0_COMPA (OC0A) Timer/Counter0 Compare Match A + reti ; 11: TIM0_COMPB (OC0B) Timer/Counter0 Compare Match B + reti ; 12: TIM0_OVF (OVF0) Timer/Counter0 Overflow + reti ; 13: ANA_COMP0 Analog Comparator 0 + reti ; 14: ADC_READY ADC Conversion Complete + reti ; 15: EE_RDY (ERDY) EEPROM Ready + reti ; 16: ANA_COMP1 Analog Comparator 1 + reti ; 17: TIM2_CAPT Timer/Counter2 Capture Event + reti ; 18: TIM2_COMPA (OC2A) Timer/Counter2 Compare Match A + reti ; 19: TIM2_COMPB (OC2B) Timer/Counter2 Compare Match B + reti ; 20: TIM2_OVF (OVF2) Timer/Counter2 Overflow + reti ; 21: SPI SPI Serial Transfer Complete + reti ; 22: USART0_RXS USART0 Rx Start + reti ; 23: USART0_RXC USART0 Rx Complete + reti ; 24: USART0_DRE USART0 Data Register Empty + reti ; 25: USART0_TXC USART0 Tx Complete + reti ; 26: USART1_RXS USART1 Rx Start + reti ; 27: USART1_RXC USART1 Rx Complete + reti ; 28: USART1_DRE USART1 Data Register Empty + reti ; 29: USART1_TXC USART1 Tx Complete + reti ; 30: TWI Two-Wire-Interface + reti ; 31: RESERVED reserved + + + +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/flashxp.asm" +.include "modules/flash/flash4p.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 == 1000000 + ldi r17, 0xd8 + ldi r16, (1< + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + main.asm + + + + + + + + + + + + + + + + + diff --git a/avr/devices/r05/main/main.asm b/avr/devices/r05/main/main.asm new file mode 100644 index 0000000..14ccb80 --- /dev/null +++ b/avr/devices/r05/main/main.asm @@ -0,0 +1,347 @@ +; *************************************************************************** +; 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. +; +; +; *************************************************************************** + + +;.equ clock=1000000 ; Define the clock frequency +.equ clock=8000000 ; Define the clock frequency + +;#define WITH_LCD + +.nolist +.include "include/tn841def.inc" ; Define device ATtiny841 +.list + +.include "../defs.asm" +.include "version.asm" +;.include "defs_all.asm" + +.include "devices/all/defs.asm" + +.include "common/calls.asm" +.include "common/utils_wait.asm" +.include "common/utils_io.asm" + + + +; *************************************************************************** +; defines + +; --------------------------------------------------------------------------- +; generic + +; --------------------------------------------------------------------------- +; network interfaces + +.equ COMONUART0_IFACENUM = 1 +.equ COMONUART1_IFACENUM = 2 + + +; --------------------------------------------------------------------------- +; firmware settings including list of modules used + + +#define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes + +#define MODULES_CLOCK +#define MODULES_LED_SIMPLE +#ifdef WITH_LCD + #define MODULES_TWI_MASTER ; using TWI display for debugging + #define MODULES_LCD + #define LCD_MINIMAL_FONT +#else ; decrease code when using display + #define MODULES_OWI_MASTER + #define MODULES_DS18B20 + #define APPS_STATS +#endif +#define MODULES_NETWORK +#define MODULES_COMONUART0 +#define MODULES_COMONUART1 +#define APPS_NETWORK + + + +.equ NET_BUFFERS_NUM = 8 +.equ NET_BUFFERS_SIZE = 32 + +.equ UART_HW_MSGNUMINBUF_SIZE = 8 +.equ UART_HW_MSGNUMOUTBUF_SIZE = 8 + + + +; --------------------------------------------------------------------------- +; defines for values + +.equ VALUE_ID_DS18B20_TEMP = 0x06 + +.equ VALUE_ID_LEDSIMPLE_TIMING = 0x88 + + +; *************************************************************************** +; code segment + +.cseg +.org 000000 + + + +; --------------------------------------------------------------------------- +; Reset and interrupt vectors + + rjmp BOOTLOADER_ADDR ; 1: RESET Reset vector use this for flashed system + reti ; 2: INT0 External Interrupt Request 0 + rjmp ComOnUart0_AttnChangeIsr ; 3: PCINT0 Pin Change Interrupt 0 + rjmp ComOnUart1_AttnChangeIsr ; 4: PCINT1 Pin Change Interrupt 1 + reti ; 5: WDT Watchdog Time-out + reti ; 6: TIM1_CAPT Timer/Counter1 Capture Event + reti ; 7: TIM1_COMPA (OC1A) Timer/Counter1 Compare Match A + reti ; 8: TIM1_COMPB (OC1B) Timer/Counter1 Compare Match B + reti ; 9: TIM1_OVF (OVF1) Timer/Counter1 Overflow + rjmp baseTimerIrqOC0A ; 10: TIM0_COMPA (OC0A) Timer/Counter0 Compare Match A + reti ; 11: TIM0_COMPB (OC0B) Timer/Counter0 Compare Match B + reti ; 12: TIM0_OVF (OVF0) Timer/Counter0 Overflow + reti ; 13: ANA_COMP0 Analog Comparator 0 + reti ; 14: ADC_READY ADC Conversion Complete + reti ; 15: EE_RDY (ERDY) EEPROM Ready + reti ; 16: ANA_COMP1 Analog Comparator 1 + reti ; 17: TIM2_CAPT Timer/Counter2 Capture Event + reti ; 18: TIM2_COMPA (OC2A) Timer/Counter2 Compare Match A + reti ; 19: TIM2_COMPB (OC2B) Timer/Counter2 Compare Match B + reti ; 20: TIM2_OVF (OVF2) Timer/Counter2 Overflow + reti ; 21: SPI SPI Serial Transfer Complete + reti ; 22: USART0_RXS USART0 Rx Start + rjmp ComOnUart0_RxCharIsr ; 23: USART0_RXC USART0 Rx Complete + rjmp ComOnUart0_TxUdreIsr ; 24: USART0_DRE USART0 Data Register Empty + rjmp ComOnUart0_TxCharIsr ; 25: USART0_TXC USART0 Tx Complete + reti ; 26: USART1_RXS USART1 Rx Start + rjmp ComOnUart1_RxCharIsr ; 27: USART1_RXC USART1 Rx Complete + rjmp ComOnUart1_TxUdreIsr ; 28: USART1_DRE USART1 Data Register Empty + rjmp ComOnUart1_TxCharIsr ; 29: USART1_TXC USART1 Tx Complete + reti ; 30: TWI Two-Wire-Interface + reti ; 31: RESERVED reserved + + + +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 + + + + + + + +onEvery100ms: +onEverySecond: +onEveryHour: +onEveryDay: + ret + + + +onEveryMinute: +#ifdef APPS_STATS + rcall sendPacketsIface2In +#endif + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine onEveryLoop +; +; Called on every loop (i.e. after awakening from sleep). + +onEveryLoop: + rcall checkRecvdMsg + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine onMessageReceived +; +; Called on every message received + +onMessageReceived: + clc + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine checkRecvdMsg +; +; Read messages from either interface and forward to the other one. + +checkRecvdMsg: + rcall NET_PeekNextIncomingMsgNum ; check read queue (bufNum->r16) + brcc checkRecvdMsg_end ; no msg, jmp + rcall NET_Buffer_Locate ; (R17) + ; let system handle incoming messages + push r16 + adiw xh:xl, 1 + rcall letSysHandleMsg + sbiw xh:xl, 1 + pop r16 + + ; forward to other interface + ld r17, X + andi r17, (NET_IFACE_BUFFER_IFACENUM1_BIT | NET_IFACE_BUFFER_IFACENUM0_BIT) + rcall reverseInterfaceNum ; (R16, R17) +; ldi r17, COMONUART0_IFACENUM ; DEBUG: send everything to uart0 to test that code first + rcall addMsgToInterface + brcc checkRecvdMsg_end ; could not add, jmp + rcall NET_GetNextIncomingMsgNum ; take off the queue + rjmp checkRecvdMsg +checkRecvdMsg_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine letSysHandleMsg +; +; @param X pointer to msg to handle (point behind the buffer header!) +; @clobbers any, !X + +letSysHandleMsg: + ld r16, X + cpi r16, 0xff + breq letSysHandleMsg_forMe + lds r17, comOnUart0_iface+NET_IFACE_OFFS_ADDRESS + cp r16, r17 + brne letSysHandleMsg_end +letSysHandleMsg_forMe: + push xl + push xh + rcall onMessageReceived + pop xh + pop xl + push xl + push xh + rcall mainModulesOnPacketReceived + pop xh + pop xl + push xl + push xh + rcall mainAppsOnPacketReceived + pop xh + pop xl +letSysHandleMsg_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine reverseInterfaceNum +; +; @param r17 buffer num +; @return r17 reversed interface number +; @clobbers r16, r17 + +reverseInterfaceNum: + ldi r16, (1< + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + main.asm + + + + + + + + + + + + + + + + + diff --git a/avr/devices/r05/test/main.asm b/avr/devices/r05/test/main.asm new file mode 100644 index 0000000..4874b8c --- /dev/null +++ b/avr/devices/r05/test/main.asm @@ -0,0 +1,242 @@ +; *************************************************************************** +; 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/tn841def.inc" ; Define device ATtiny841 +.list + +.include "../defs.asm" +.include "version.asm" +;.include "defs_all.asm" + +.include "devices/all/defs.asm" + +.include "common/calls.asm" +.include "common/utils_wait.asm" +.include "common/utils_io.asm" + + + +; *************************************************************************** +; defines + +; --------------------------------------------------------------------------- +; generic + +.equ COMONUART0_IFACENUM = 1 +.equ COMONUART1_IFACENUM = 2 + + +; --------------------------------------------------------------------------- +; firmware settings including list of modules used + + +;#define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes +;#define APP_STATS_NETDEV2 + +#define MODULES_CLOCK +;#define MODULES_COM +;#define MODULES_COM_WITH_ADDR_PROTO +;#define MODULES_LED +#define MODULES_LED_SIMPLE +;#define MODULES_TWI_MASTER +;#define MODULES_LCD +;#define LCD_MINIMAL_FONT +;#define MODULES_SI7021 +;#define MODULES_STATS +;#define MODULES_CNY70 +;#define MODULES_REED +#define MODULES_OWI_MASTER +#define MODULES_DS18B20 +;#define MODULES_MOTION +#define MODULES_NETWORK +;#define MODULES_TTYONUART1 +;#define MODULES_COMONUART0 +#define MODULES_COMONUART1 + +#define APPS_STATS +#define APPS_NETWORK +#define APPS_REPORTSENSORS + + + +.equ NET_BUFFERS_NUM = 8 +.equ NET_BUFFERS_SIZE = 32 + +.equ UART_HW_MSGNUMINBUF_SIZE = 8 +.equ UART_HW_MSGNUMOUTBUF_SIZE = 8 + + + +; --------------------------------------------------------------------------- +; defines for values + +.equ VALUE_ID_DS18B20_TEMP = 0x06 + +.equ VALUE_ID_LEDSIMPLE_TIMING = 0x88 + + +; *************************************************************************** +; code segment + +.cseg +.org 000000 + + + +; --------------------------------------------------------------------------- +; Reset and interrupt vectors + + rjmp BOOTLOADER_ADDR ; 1: RESET Reset vector use this for flashed system + reti ; 2: INT0 External Interrupt Request 0 +; rjmp ComOnUart0_AttnChangeIsr ; 3: PCINT0 Pin Change Interrupt 0 + reti ; 3: PCINT0 Pin Change Interrupt 0 + rjmp ComOnUart1_AttnChangeIsr ; 4: PCINT1 Pin Change Interrupt 1 + reti ; 5: WDT Watchdog Time-out + reti ; 6: TIM1_CAPT Timer/Counter1 Capture Event + reti ; 7: TIM1_COMPA (OC1A) Timer/Counter1 Compare Match A + reti ; 8: TIM1_COMPB (OC1B) Timer/Counter1 Compare Match B + reti ; 9: TIM1_OVF (OVF1) Timer/Counter1 Overflow + rjmp baseTimerIrqOC0A ; 10: TIM0_COMPA (OC0A) Timer/Counter0 Compare Match A + reti ; 11: TIM0_COMPB (OC0B) Timer/Counter0 Compare Match B + reti ; 12: TIM0_OVF (OVF0) Timer/Counter0 Overflow + reti ; 13: ANA_COMP0 Analog Comparator 0 + reti ; 14: ADC_READY ADC Conversion Complete + reti ; 15: EE_RDY (ERDY) EEPROM Ready + reti ; 16: ANA_COMP1 Analog Comparator 1 + reti ; 17: TIM2_CAPT Timer/Counter2 Capture Event + reti ; 18: TIM2_COMPA (OC2A) Timer/Counter2 Compare Match A + reti ; 19: TIM2_COMPB (OC2B) Timer/Counter2 Compare Match B + reti ; 20: TIM2_OVF (OVF2) Timer/Counter2 Overflow + reti ; 21: SPI SPI Serial Transfer Complete + reti ; 22: USART0_RXS USART0 Rx Start +; rjmp ComOnUart0_RxCharIsr ; 23: USART0_RXC USART0 Rx Complete + reti ; 23: USART0_RXC USART0 Rx Complete +; rjmp ComOnUart0_TxUdreIsr ; 24: USART0_DRE USART0 Data Register Empty + reti ; 24: USART0_DRE USART0 Data Register Empty +; rjmp ComOnUart0_TxCharIsr ; 25: USART0_TXC USART0 Tx Complete + reti ; 25: USART0_TXC USART0 Tx Complete + reti ; 26: USART1_RXS USART1 Rx Start + rjmp ComOnUart1_RxCharIsr ; 27: USART1_RXC USART1 Rx Complete +; reti ; 27: USART1_RXC USART1 Rx Complete + rjmp ComOnUart1_TxUdreIsr ; 28: USART1_DRE USART1 Data Register Empty +; reti ; 28: USART1_DRE USART1 Data Register Empty + rjmp ComOnUart1_TxCharIsr ; 29: USART1_TXC USART1 Tx Complete +; reti ; 29: USART1_TXC USART1 Tx Complete + reti ; 30: TWI Two-Wire-Interface + reti ; 31: RESERVED reserved + + + +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: + ; set interface number for UART0 +; ldi r16, COMONUART0_IFACENUM +; sts comOnUart0_iface+NET_IFACE_OFFS_IFACENUM, r16 + ; set interface number for UART1 + ldi r16, COMONUART1_IFACENUM + sts comOnUart1_iface+NET_IFACE_OFFS_IFACENUM, r16 + + ret +; @end + + + + + + + +onEvery100ms: +onEverySecond: +onEveryMinute: +onEveryHour: +onEveryDay: + ret + + + + +; --------------------------------------------------------------------------- +; @routine onEveryLoop +; +; Called on every loop (i.e. after awakening from sleep). + +onEveryLoop: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine onMessageReceived +; +; Called on every message received + +onMessageReceived: + clc + ret +; @end + + + +; *************************************************************************** +; includes + +.include "devices/all/hw_tn841.asm" +.include "devices/all/includes.asm" + +.include "common/debug.asm" + + + +; --------------------------------------------------------------------------- +; defines for network interface + +.equ netInterfaceData = comOnUart1_iface +;.equ netInterfaceData2 = comOnUart1_iface + + From 85d445ec6108aed5b10a80f29652f81e42a5da61 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 6 Jul 2025 14:35:52 +0200 Subject: [PATCH 067/196] t03: use comonuart0 from uart_hw2 --- avr/devices/t03/defs.asm | 30 +++++++++---- avr/devices/t03/main/main.asm | 80 ++++++++++++++++++++++++++--------- 2 files changed, 80 insertions(+), 30 deletions(-) diff --git a/avr/devices/t03/defs.asm b/avr/devices/t03/defs.asm index 75a19f4..c0841b4 100644 --- a/avr/devices/t03/defs.asm +++ b/avr/devices/t03/defs.asm @@ -54,16 +54,28 @@ .equ COM_BIT_LENGTH = 52000 ; 104000ns=9600, 52000ns=19200, 26000ns=38400 -.equ COM_ATTN_DDR = DDRA -.equ COM_ATTN_INPUT = PINA -.equ COM_ATTN_OUTPUT = PORTA -.equ COM_ATTN_PUE = PUEA -.equ COM_ATTN_PIN = PORTA0 +.equ COM_ATTN0_DDR = DDRA +.equ COM_ATTN0_INPUT = PINA +.equ COM_ATTN0_OUTPUT = PORTA +.equ COM_ATTN0_PUE = PUEA +.equ COM_ATTN0_PIN = PORTA0 -.equ COM_IRQ_ADDR_ATTN = PCMSK0 -.equ COM_IRQ_BIT_ATTN = PCINT0 ; bit 0 in PCMSK0 -.equ COM_IRQ_GIFR_ATTN = PCIF0 -.equ COM_IRQ_GIMSK_ATTN = PCIE0 +.equ COM_IRQ_ADDR_ATTN0 = PCMSK0 +.equ COM_IRQ_BIT_ATTN0 = PCINT0 ; bit 0 in PCMSK0 +.equ COM_IRQ_GIFR_ATTN0 = PCIF0 +.equ COM_IRQ_GIMSK_ATTN0 = PCIE0 + +; compatibility +.equ COM_ATTN_DDR = COM_ATTN0_DDR +.equ COM_ATTN_INPUT = COM_ATTN0_INPUT +.equ COM_ATTN_OUTPUT = COM_ATTN0_OUTPUT +.equ COM_ATTN_PUE = COM_ATTN0_PUE +.equ COM_ATTN_PIN = COM_ATTN0_PIN + +.equ COM_IRQ_ADDR_ATTN = COM_IRQ_ADDR_ATTN0 +.equ COM_IRQ_BIT_ATTN = COM_IRQ_BIT_ATTN0 +.equ COM_IRQ_GIFR_ATTN = COM_IRQ_GIFR_ATTN0 +.equ COM_IRQ_GIMSK_ATTN = COM_IRQ_GIMSK_ATTN0 diff --git a/avr/devices/t03/main/main.asm b/avr/devices/t03/main/main.asm index 6dcb305..bda6094 100644 --- a/avr/devices/t03/main/main.asm +++ b/avr/devices/t03/main/main.asm @@ -47,12 +47,16 @@ ; --------------------------------------------------------------------------- ; generic +.equ COMONUART0_IFACENUM = 1 +.equ TTYONUART1_IFACENUM = 2 + ; --------------------------------------------------------------------------- ; firmware settings including list of modules used #define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes +#define APP_STATS_NETDEV2 #define MODULES_CLOCK ;#define MODULES_COM @@ -70,13 +74,14 @@ ;#define MODULES_DS18B20 ;#define MODULES_MOTION #define MODULES_NETWORK -#define MODULES_TTYONUART1 #define MODULES_COMONUART0 +#define MODULES_TTYONUART1 #define APPS_STATS +#define APPS_NETWORK -.equ NET_BUFFERS_NUM = 8 +.equ NET_BUFFERS_NUM = 10 .equ NET_BUFFERS_SIZE = 32 .equ UART_HW_MSGNUMINBUF_SIZE = 8 @@ -87,6 +92,8 @@ ; --------------------------------------------------------------------------- ; defines for values +.equ VALUE_ID_DS18B20_TEMP = 0x06 + .equ VALUE_ID_LEDSIMPLE_TIMING = 0x88 @@ -103,7 +110,7 @@ rjmp BOOTLOADER_ADDR ; 1: RESET Reset vector use this for flashed system reti ; 2: INT0 External Interrupt Request 0 - rjmp ComOnUart0_AttnChangeIsr ; 3: PCINT0 Pin Change Interrupt 0 + rjmp ComOnUart0AttnChangeIsr ; 3: PCINT0 Pin Change Interrupt 0 reti ; 4: PCINT1 Pin Change Interrupt 1 reti ; 5: WDT Watchdog Time-out reti ; 6: TIM1_CAPT Timer/Counter1 Capture Event @@ -157,15 +164,18 @@ firmwareStart: ; @routine onSystemStart onSystemStart: + ; set interface number for UART0 + ldi r16, COMONUART0_IFACENUM + sts comOnUart0_iface+NET_IFACE_OFFS_IFACENUM, r16 + ; set interface number for UART1 + ldi r16, TTYONUART1_IFACENUM + sts ttyOnUart1_iface+NET_IFACE_OFFS_IFACENUM, r16 + ret ; @end - - - - onEvery100ms: onEverySecond: onEveryMinute: @@ -213,16 +223,14 @@ checkRecvdMsg: push xl push xh adiw xh:xl, 1 - rcall onMessageReceived - rcall mainModulesOnPacketReceived - rcall mainAppsOnPacketReceived + rcall letSysHandleMsg pop xh pop xl pop r16 ; forward to other interface ld r17, X - andi r17, (NET_IFACE_BUFFER_IFACENUM1_BIT | NET_IFACE_BUFFER_IFACENUM0_BIT) + andi r17, (1< Date: Sun, 6 Jul 2025 14:36:50 +0200 Subject: [PATCH 068/196] sort counters to simplify stats app. --- avr/apps/stats/main.asm | 105 ++++++++++++++++++++++++----------- avr/modules/network/defs.asm | 36 ++++++------ 2 files changed, 89 insertions(+), 52 deletions(-) diff --git a/avr/apps/stats/main.asm b/avr/apps/stats/main.asm index a669c49..283141a 100644 --- a/avr/apps/stats/main.asm +++ b/avr/apps/stats/main.asm @@ -75,6 +75,10 @@ AppStats_OnEveryMinute_store: sts appStatsTimer, r16 ldi yl, LOW(netInterfaceData) ldi yh, HIGH(netInterfaceData) + + ldi r17, AQHOME_VALUEID_STATS_PACKETS_IN + ldi xl, LOW(netInterfaceData) + ldi xh, HIGH(netInterfaceData) cpi r16, 1 breq AppStats_OnEveryMinute_sendDevice cpi r16, 3 @@ -97,57 +101,68 @@ AppStats_OnEveryMinute_store: breq AppStats_OnEveryMinute_sendDevice cpi r16, 15 breq AppStats_OnEveryMinute_sendBusyErrs -#ifdef MODULES_HEAP + +#ifdef APP_STATS_NETDEV2 + ldi r17, AQHOME_VALUEID_STATS_PACKETS_IN2 + ldi xl, LOW(netInterfaceData2) + ldi xh, HIGH(netInterfaceData2) + cpi r16, 16 + breq AppStats_OnEveryMinute_sendPacketsIn cpi r16, 17 - breq AppStats_OnEveryMinute_sendHeapUsed - cpi r16, 19 - breq AppStats_OnEveryMinute_sendHeapfree -#endif + breq AppStats_OnEveryMinute_sendPacketsOut cpi r16, 18 breq AppStats_OnEveryMinute_sendDevice + cpi r16, 19 + breq AppStats_OnEveryMinute_sendContentErrs + cpi r16, 20 + breq AppStats_OnEveryMinute_sendIoErrs + cpi r16, 21 + breq AppStats_OnEveryMinute_sendDevice + cpi r16, 22 + breq AppStats_OnEveryMinute_sendNoBufErrs cpi r16, 23 breq AppStats_OnEveryMinute_sendDevice + cpi r16, 24 + breq AppStats_OnEveryMinute_sendCollisionErrs + cpi r16, 25 + breq AppStats_OnEveryMinute_sendBusyErrs +#endif + +#ifdef MODULES_HEAP + cpi r16, 26 + breq AppStats_OnEveryMinute_sendHeapUsed + cpi r16, 27 + breq AppStats_OnEveryMinute_sendHeapfree +#endif cpi r16, 28 breq AppStats_OnEveryMinute_sendDevice + ret AppStats_OnEveryMinute_sendDevice: rjmp AppNetwork_SendDevice AppStats_OnEveryMinute_sendPacketsIn: - ldi r17, AQHOME_VALUEID_STATS_PACKETS_IN - ldd r18, Y+NET_IFACE_OFFS_PACKETSIN_LOW - ldd r19, Y+NET_IFACE_OFFS_PACKETSIN_HIGH - rjmp appStatsSend16BitValue + ldi r16, 0 + rjmp appStatsSendDeviceStat AppStats_OnEveryMinute_sendPacketsOut: - ldi r17, AQHOME_VALUEID_STATS_PACKETS_OUT - ldd r18, Y+NET_IFACE_OFFS_PACKETSOUT_LOW - ldd r19, Y+NET_IFACE_OFFS_PACKETSOUT_HIGH - rjmp appStatsSend16BitValue + ldi r16, 1 + rjmp appStatsSendDeviceStat AppStats_OnEveryMinute_sendContentErrs: - ldi r17, AQHOME_VALUEID_STATS_ERRS_CONTENT - ldd r18, Y+NET_IFACE_OFFS_ERR_CONTENT_LOW - ldd r19, Y+NET_IFACE_OFFS_ERR_CONTENT_HIGH - rjmp appStatsSend16BitValue + ldi r16, 2 + rjmp appStatsSendDeviceStat AppStats_OnEveryMinute_sendIoErrs: - ldi r17, AQHOME_VALUEID_STATS_ERRS_IO - ldd r18, Y+NET_IFACE_OFFS_ERR_IO_LOW - ldd r19, Y+NET_IFACE_OFFS_ERR_IO_HIGH - rjmp appStatsSend16BitValue + ldi r16, 3 + rjmp appStatsSendDeviceStat AppStats_OnEveryMinute_sendNoBufErrs: - ldi r17, AQHOME_VALUEID_STATS_ERRS_NOBUF - ldd r18, Y+NET_IFACE_OFFS_ERR_NOBUF_LOW - ldd r19, Y+NET_IFACE_OFFS_ERR_NOBUF_HIGH - rjmp appStatsSend16BitValue + ldi r16, 4 + rjmp appStatsSendDeviceStat AppStats_OnEveryMinute_sendCollisionErrs: - ldi r17, AQHOME_VALUEID_STATS_ERRS_COLLISIONS - ldd r18, Y+NET_IFACE_OFFS_ERR_COLLISIONS_LOW - ldd r19, Y+NET_IFACE_OFFS_ERR_COLLISIONS_HIGH - rjmp appStatsSend16BitValue + ldi r16, 5 + rjmp appStatsSendDeviceStat AppStats_OnEveryMinute_sendBusyErrs: - ldi r17, AQHOME_VALUEID_STATS_ERRS_BUSY - ldd r18, Y+NET_IFACE_OFFS_ERR_BUSY_LOW - ldd r19, Y+NET_IFACE_OFFS_ERR_BUSY_HIGH - rjmp appStatsSend16BitValue + ldi r16, 6 + rjmp appStatsSendDeviceStat + #ifdef MODULES_HEAP AppStats_OnEveryMinute_sendHeapUsed: ldi r17, AQHOME_VALUEID_STATS_HEAP_USED @@ -164,6 +179,30 @@ AppStats_OnEveryMinute_sendHeapfree: + +; --------------------------------------------------------------------------- +; @routine AppStats_OnEveryMinute @global +; +; @param r16 index into device table (e.g. 0 for NET_IFACE_OFFS_PACKETSIN_LOW) +; @param r17 offset to first value id (e.g. AQHOME_VALUEID_STATS_PACKETS_IN for device 0, +; AQHOME_VALUEID_STATS_PACKETS_IN2 for device 1) +; @param Y pointer to device to send data to +; @param X pointer to device to inspect + +appStatsSendDeviceStat: + add r17, r16 + lsl r16 + adiw xh:xl, NET_IFACE_OFFS_PACKETSIN_LOW + add xl, r16 + adc xh, r16 + sub xh, r16 + ld r18, X+ + ld r19, X + rjmp appStatsSend16BitValue +; @end + + + ; --------------------------------------------------------------------------- ; @routine AppStats_OnEveryMinute @global ; diff --git a/avr/modules/network/defs.asm b/avr/modules/network/defs.asm index ff1f6d3..e805442 100644 --- a/avr/modules/network/defs.asm +++ b/avr/modules/network/defs.asm @@ -31,27 +31,25 @@ .equ NET_IFACE_OFFS_LASTMSGID_LOW = 8 .equ NET_IFACE_OFFS_LASTMSGID_HIGH = 9 -; receiption stats +; device stats .equ NET_IFACE_OFFS_PACKETSIN_LOW = 10 .equ NET_IFACE_OFFS_PACKETSIN_HIGH = 11 -.equ NET_IFACE_OFFS_ERR_CONTENT_LOW = 12 -.equ NET_IFACE_OFFS_ERR_CONTENT_HIGH = 13 -.equ NET_IFACE_OFFS_ERR_IO_LOW = 14 -.equ NET_IFACE_OFFS_ERR_IO_HIGH = 15 -.equ NET_IFACE_OFFS_ERR_NOBUF_LOW = 16 -.equ NET_IFACE_OFFS_ERR_NOBUF_HIGH = 17 -.equ NET_IFACE_OFFS_ERR_MSGSIZE_LOW = 18 -.equ NET_IFACE_OFFS_ERR_MSGSIZE_HIGH = 19 -.equ NET_IFACE_OFFS_ERR_MISSED_LOW = 20 -.equ NET_IFACE_OFFS_ERR_MISSED_HIGH = 21 - -; send stats -.equ NET_IFACE_OFFS_PACKETSOUT_LOW = 22 -.equ NET_IFACE_OFFS_PACKETSOUT_HIGH = 23 -.equ NET_IFACE_OFFS_ERR_COLLISIONS_LOW = 24 -.equ NET_IFACE_OFFS_ERR_COLLISIONS_HIGH = 25 -.equ NET_IFACE_OFFS_ERR_BUSY_LOW = 26 -.equ NET_IFACE_OFFS_ERR_BUSY_HIGH = 27 +.equ NET_IFACE_OFFS_PACKETSOUT_LOW = 12 +.equ NET_IFACE_OFFS_PACKETSOUT_HIGH = 13 +.equ NET_IFACE_OFFS_ERR_CONTENT_LOW = 14 +.equ NET_IFACE_OFFS_ERR_CONTENT_HIGH = 15 +.equ NET_IFACE_OFFS_ERR_IO_LOW = 16 +.equ NET_IFACE_OFFS_ERR_IO_HIGH = 17 +.equ NET_IFACE_OFFS_ERR_NOBUF_LOW = 18 +.equ NET_IFACE_OFFS_ERR_NOBUF_HIGH = 19 +.equ NET_IFACE_OFFS_ERR_COLLISIONS_LOW = 20 +.equ NET_IFACE_OFFS_ERR_COLLISIONS_HIGH = 21 +.equ NET_IFACE_OFFS_ERR_BUSY_LOW = 22 +.equ NET_IFACE_OFFS_ERR_BUSY_HIGH = 23 +.equ NET_IFACE_OFFS_ERR_MSGSIZE_LOW = 24 +.equ NET_IFACE_OFFS_ERR_MSGSIZE_HIGH = 25 +.equ NET_IFACE_OFFS_ERR_MISSED_LOW = 26 +.equ NET_IFACE_OFFS_ERR_MISSED_HIGH = 27 .equ NET_IFACE_OFFS_OUTMSGRINGBUF = 28 ; RINGBUFFERY_SIZE+UART_HW_IFACE_OUTMSGBUF_SIZE From c540135705b2621fd83f7b99771920691d4b4c9b Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 6 Jul 2025 14:37:10 +0200 Subject: [PATCH 069/196] fixed a bug. --- avr/modules/network/iface.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/avr/modules/network/iface.asm b/avr/modules/network/iface.asm index 06f9a20..b0174f9 100644 --- a/avr/modules/network/iface.asm +++ b/avr/modules/network/iface.asm @@ -188,9 +188,9 @@ NET_Interface_IncCounter16_end: NET_Interface_SetIfaceNumInBuffer: ldd r16, Y+NET_IFACE_OFFS_IFACENUM - andi r16, (NET_IFACE_BUFFER_IFACENUM1_BIT | NET_IFACE_BUFFER_IFACENUM0_BIT) + andi r16, (1< Date: Sun, 6 Jul 2025 14:38:21 +0200 Subject: [PATCH 070/196] minor changes to unify modules. --- avr/modules/uart_hw/comonuart0.asm | 1 - avr/modules/uart_hw/comonuart1.asm | 11 +++++------ avr/modules/uart_hw/ttyonuart1.asm | 1 - 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/avr/modules/uart_hw/comonuart0.asm b/avr/modules/uart_hw/comonuart0.asm index 1d6300c..61c6730 100644 --- a/avr/modules/uart_hw/comonuart0.asm +++ b/avr/modules/uart_hw/comonuart0.asm @@ -8,7 +8,6 @@ ; *************************************************************************** -.equ COMONUART0_IFACENUM = 1 .equ COMONUART0_READ_TIMEOUT = 3 .equ COMONUART0_MSG_INTERVAL = 0 diff --git a/avr/modules/uart_hw/comonuart1.asm b/avr/modules/uart_hw/comonuart1.asm index 8e7c2c6..5ea61f9 100644 --- a/avr/modules/uart_hw/comonuart1.asm +++ b/avr/modules/uart_hw/comonuart1.asm @@ -8,7 +8,6 @@ ; *************************************************************************** -.equ COMONUART1_IFACENUM = 2 .equ COMONUART1_READ_TIMEOUT = 3 .equ COMONUART1_MSG_INTERVAL = 0 @@ -358,13 +357,13 @@ comOnUart1RunWriteModes: comOnUart1RunWriteIdle: ldd r16, Y+NET_IFACE_OFFS_WRITETIMER - cpi r16, COMONUART0_MSG_INTERVAL ; wait a bit between messages + cpi r16, COMONUART1_MSG_INTERVAL ; wait a bit between messages brcs comOnUart1RunWriteIdle_end rcall NET_Interface_PeekNextOutgoingMsgNum ; r16=msgNum brcc comOnUart1RunWriteIdle_end ; no outmsg in queue - sbis COM_ATTN_INPUT, COM_ATTN_PIN ; ATTN low? + sbis COM_ATTN1_INPUT, COM_ATTN1_PIN ; ATTN low? rjmp comOnUart1RunWriteIdle_end ; yes, line busy, jmp rcall comOnUart1SetAttnLow ; reserve bus as soon as possible @@ -468,7 +467,7 @@ comOnUart1RunReading: ret ldd r16, Y+NET_IFACE_OFFS_READTIMER - cpi r16, COMONUART0_READ_TIMEOUT + cpi r16, COMONUART1_READ_TIMEOUT brcs comOnUart1RunReading_end rcall comOnUart1StopRx ; (R16) ldd r16, Y+UART_HW_IFACE_OFFS_READBUFNUM @@ -499,7 +498,7 @@ comOnUart1RunSkipping: breq comOnUart1RunSkipping_checkAttn rcall NET_Buffer_ReleaseByNum ; (R16, X) comOnUart1RunSkipping_checkAttn: - sbis COM_ATTN_INPUT, COM_ATTN_PIN ; ATTN low? + sbis COM_ATTN1_INPUT, COM_ATTN1_PIN ; ATTN low? rjmp comOnUart1RunSkipping_end ; yes, jmp ; ATTN ishigh, skipped message finished ldi r16, UART_HW_READMODE_IDLE @@ -528,7 +527,7 @@ comOnUart1RunMsgReceived: ; @clobbers R16, R17, X comOnUart1Init: -.ifdef COM_ATTN_PUE +.ifdef COM_ATTN1_PUE lds r16, COM_ATTN1_PUE cbr r16, 1< Date: Sun, 6 Jul 2025 14:38:43 +0200 Subject: [PATCH 071/196] add devices r04 and r05 to flash script. --- flashnode.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/flashnode.sh b/flashnode.sh index 4e0116d..ba15e05 100755 --- a/flashnode.sh +++ b/flashnode.sh @@ -93,6 +93,20 @@ case $NODE in EFUSE_ARG="-U efuse:w:0xFE:m" FILE_ARG="-U flash:w:./0-build/avr/devices/n27/boot/n27_boot.hex" ;; + r04) + DEVICE_ARG="-p t841" + 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/r04/boot/r04_boot.hex" + ;; + r05) + DEVICE_ARG="-p t841" + 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/r05/boot/r05_boot.hex" + ;; t03) DEVICE_ARG="-p t841" HFUSE_ARG="-U hfuse:w:0xD7:m" From f549ef5d27e8d72015cf596d7de241cd49cdc02d Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 6 Jul 2025 14:39:02 +0200 Subject: [PATCH 072/196] added debug output. --- aqhome/events2/fdobject.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aqhome/events2/fdobject.c b/aqhome/events2/fdobject.c index 211706a..d66ac04 100644 --- a/aqhome/events2/fdobject.c +++ b/aqhome/events2/fdobject.c @@ -14,6 +14,7 @@ #include #include +#include //#include #include @@ -170,6 +171,7 @@ int AQH_FdObject_Read(AQH_OBJECT *o, uint8_t *ptrBuffer, uint32_t lenBuffer) else if (rv>0) { /* data received */ DBG_DEBUG(AQH_LOGDOMAIN, "Received %d bytes", (int) rv); +// GWEN_Text_LogString((const char*) ptrBuffer, rv, NULL, GWEN_LoggerLevel_Error); return (int) rv; } else { From 86982d00002524bbe98bd4872a2647695bb46e49 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 6 Jul 2025 14:39:16 +0200 Subject: [PATCH 073/196] reuse code. --- aqhome/msg/node/m_value.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/aqhome/msg/node/m_value.c b/aqhome/msg/node/m_value.c index 01a0f58..a8cf759 100644 --- a/aqhome/msg/node/m_value.c +++ b/aqhome/msg/node/m_value.c @@ -12,6 +12,7 @@ +#include "aqhome/aqhome.h" #include "aqhome/msg/node/m_value.h" #include "aqhome/msg/node/m_node.h" @@ -102,19 +103,7 @@ uint16_t AQH_ValueMessage_GetValueDenom(const AQH_MESSAGE *msg) const char *AQH_ValueMessage_GetValueTypeName(const AQH_MESSAGE *msg) { - uint8_t t; - - t=AQH_ValueMessage_GetValueType(msg); - switch(t) { - case AQH_MSG_VALUE_TYPE_TEMP: return "temperature"; - case AQH_MSG_VALUE_TYPE_HUMIDITY: return "humidity"; - case AQH_MSG_VALUE_TYPE_DOOR: return "door_window"; - case AQH_MSG_VALUE_TYPE_MOTION: return "motion"; - case AQH_MSG_VALUE_TYPE_CO2: return "CO2"; - case AQH_MSG_VALUE_TYPE_TVOC: return "TVOC"; - default: break; - } - return "unknown"; + return AQH_ValueModality_toString(AQH_ValueMessage_GetValueType(msg)); } From d242d63c2e0f76318fea8bfee965ad99fbbdc4f1 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 6 Jul 2025 14:39:48 +0200 Subject: [PATCH 074/196] disable irqs when releasing buffer. --- avr/modules/network/buffer.asm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/avr/modules/network/buffer.asm b/avr/modules/network/buffer.asm index e3d48cf..92732e4 100644 --- a/avr/modules/network/buffer.asm +++ b/avr/modules/network/buffer.asm @@ -95,10 +95,15 @@ NET_Buffer_ReleaseByAddr: ; @clobbers X (R16) NET_Buffer_ReleaseByNum: - rcall NET_Buffer_Locate ; (R16, X) - brcc NET_Buffer_ReleaseByNum_end - rcall NET_Buffer_ReleaseByAddr ; (R16) + push r15 + in r15, SREG + cli + rcall NET_Buffer_Locate ; (R16, X) + brcc NET_Buffer_ReleaseByNum_end + rcall NET_Buffer_ReleaseByAddr ; (R16) NET_Buffer_ReleaseByNum_end: + out SREG, r15 + pop r15 ret ; @end From 439e787d37145dcf21fe23c9088a1884cb6a50f7 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 6 Jul 2025 14:40:14 +0200 Subject: [PATCH 075/196] added values to device description file for t03. --- devices/nodes/aqua_t03.xml | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/devices/nodes/aqua_t03.xml b/devices/nodes/aqua_t03.xml index 489580a..1ca7901 100644 --- a/devices/nodes/aqua_t03.xml +++ b/devices/nodes/aqua_t03.xml @@ -7,13 +7,25 @@ - - - - - - - + + + + + + + + + + + + + + + + + + + From 81b008af0c87340d8eb8bd25729f40529cc202fa Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 6 Jul 2025 17:19:59 +0200 Subject: [PATCH 076/196] r05, comOnUart0 and comOnUart1 work! --- avr/devices/r05/main/main.asm | 21 +- avr/devices/r05/test/main.asm | 35 ++- avr/modules/uart_hw2/comonuart0.asm | 390 +++++++++------------------ avr/modules/uart_hw2/comonuart1.asm | 404 +++++++++------------------- avr/modules/uart_hw2/defs.asm | 18 +- 5 files changed, 302 insertions(+), 566 deletions(-) diff --git a/avr/devices/r05/main/main.asm b/avr/devices/r05/main/main.asm index 14ccb80..dc6d041 100644 --- a/avr/devices/r05/main/main.asm +++ b/avr/devices/r05/main/main.asm @@ -129,12 +129,12 @@ reti ; 21: SPI SPI Serial Transfer Complete reti ; 22: USART0_RXS USART0 Rx Start rjmp ComOnUart0_RxCharIsr ; 23: USART0_RXC USART0 Rx Complete - rjmp ComOnUart0_TxUdreIsr ; 24: USART0_DRE USART0 Data Register Empty - rjmp ComOnUart0_TxCharIsr ; 25: USART0_TXC USART0 Tx Complete + reti ; 24: USART0_DRE USART0 Data Register Empty + reti ; 25: USART0_TXC USART0 Tx Complete reti ; 26: USART1_RXS USART1 Rx Start rjmp ComOnUart1_RxCharIsr ; 27: USART1_RXC USART1 Rx Complete - rjmp ComOnUart1_TxUdreIsr ; 28: USART1_DRE USART1 Data Register Empty - rjmp ComOnUart1_TxCharIsr ; 29: USART1_TXC USART1 Tx Complete + reti ; 28: USART1_DRE USART1 Data Register Empty + reti ; 29: USART1_TXC USART1 Tx Complete reti ; 30: TWI Two-Wire-Interface reti ; 31: RESERVED reserved @@ -162,6 +162,13 @@ firmwareStart: ; @routine onSystemStart onSystemStart: + ; set interface number for UART0 + ldi r16, COMONUART0_IFACENUM + sts comOnUart0_iface+NET_IFACE_OFFS_IFACENUM, r16 + ; set interface number for UART1 + ldi r16, COMONUART1_IFACENUM + sts comOnUart1_iface+NET_IFACE_OFFS_IFACENUM, r16 + ret ; @end @@ -230,7 +237,7 @@ checkRecvdMsg: ; forward to other interface ld r17, X - andi r17, (NET_IFACE_BUFFER_IFACENUM1_BIT | NET_IFACE_BUFFER_IFACENUM0_BIT) + andi r17, (1< Date: Sun, 6 Jul 2025 18:21:48 +0200 Subject: [PATCH 077/196] make router functionality of r05 an app. --- avr/apps/0BUILD | 1 + avr/apps/router/0BUILD | 15 ++++ avr/apps/router/main.asm | 158 ++++++++++++++++++++++++++++++++++ avr/devices/all/apps.asm | 8 ++ avr/devices/all/includes.asm | 5 ++ avr/devices/r05/aqua_r05.xml | 29 ++++--- avr/devices/r05/main/main.asm | 141 +----------------------------- 7 files changed, 209 insertions(+), 148 deletions(-) create mode 100644 avr/apps/router/0BUILD create mode 100644 avr/apps/router/main.asm diff --git a/avr/apps/0BUILD b/avr/apps/0BUILD index 0e4cf4b..6934125 100644 --- a/avr/apps/0BUILD +++ b/avr/apps/0BUILD @@ -9,6 +9,7 @@ network reportsensors stats + router diff --git a/avr/apps/router/0BUILD b/avr/apps/router/0BUILD new file mode 100644 index 0000000..593fe80 --- /dev/null +++ b/avr/apps/router/0BUILD @@ -0,0 +1,15 @@ + + + + + + + + + main.asm + + + + + + diff --git a/avr/apps/router/main.asm b/avr/apps/router/main.asm new file mode 100644 index 0000000..5350c27 --- /dev/null +++ b/avr/apps/router/main.asm @@ -0,0 +1,158 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + + +; *************************************************************************** +; defines + +; --------------------------------------------------------------------------- +; network interfaces + +.equ NETDEV0_IFACENUM = 1 +.equ NETDEV1_IFACENUM = 2 + + + +; *************************************************************************** +; code + +.cseg + +; --------------------------------------------------------------------------- +; @routine AppRouter_Init @global + +AppRouter_Init: + ; set interface number for NETDEV0 + ldi r16, NETDEV0_IFACENUM + sts netInterfaceData+NET_IFACE_OFFS_IFACENUM, r16 + ; set interface number for NETDEV1 + ldi r16, NETDEV1_IFACENUM + sts netInterfaceData2+NET_IFACE_OFFS_IFACENUM, r16 + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine AppRouter_Run @global +; +; Read messages from either interface and forward to the other one. + +AppRouter_Run: + rjmp appRouterCheckRecvdMsg +; @end + + + +; --------------------------------------------------------------------------- +; @routine appRouterCheckRecvdMsg +; +; Read messages from either interface and forward to the other one. + +appRouterCheckRecvdMsg: + rcall NET_PeekNextIncomingMsgNum ; check read queue (bufNum->r16) + brcc appRouterCheckRecvdMsg_end ; no msg, jmp + rcall NET_Buffer_Locate ; (R17) + ; let system handle incoming messages + push r16 + adiw xh:xl, 1 + rcall appRouterLetSysHandleMsg + sbiw xh:xl, 1 + pop r16 + + ; forward to other interface + ld r17, X + andi r17, (1< - - - - - - - + + + + + + + + + - - + + + + + + + + + - + diff --git a/avr/devices/r05/main/main.asm b/avr/devices/r05/main/main.asm index dc6d041..a94b187 100644 --- a/avr/devices/r05/main/main.asm +++ b/avr/devices/r05/main/main.asm @@ -48,18 +48,13 @@ ; --------------------------------------------------------------------------- ; generic -; --------------------------------------------------------------------------- -; network interfaces - -.equ COMONUART0_IFACENUM = 1 -.equ COMONUART1_IFACENUM = 2 ; --------------------------------------------------------------------------- ; firmware settings including list of modules used -#define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes +#define MAIN_WITHOUT_MSG_HANDLING ; message handling in AppRouter! #define MODULES_CLOCK #define MODULES_LED_SIMPLE @@ -76,7 +71,7 @@ #define MODULES_COMONUART0 #define MODULES_COMONUART1 #define APPS_NETWORK - +#define APPS_ROUTER .equ NET_BUFFERS_NUM = 8 @@ -162,13 +157,6 @@ firmwareStart: ; @routine onSystemStart onSystemStart: - ; set interface number for UART0 - ldi r16, COMONUART0_IFACENUM - sts comOnUart0_iface+NET_IFACE_OFFS_IFACENUM, r16 - ; set interface number for UART1 - ldi r16, COMONUART1_IFACENUM - sts comOnUart1_iface+NET_IFACE_OFFS_IFACENUM, r16 - ret ; @end @@ -187,9 +175,6 @@ onEveryDay: onEveryMinute: -#ifdef APPS_STATS - rcall sendPacketsIface2In -#endif ret ; @end @@ -201,7 +186,6 @@ onEveryMinute: ; Called on every loop (i.e. after awakening from sleep). onEveryLoop: - rcall checkRecvdMsg ret ; @end @@ -219,126 +203,6 @@ onMessageReceived: -; --------------------------------------------------------------------------- -; @routine checkRecvdMsg -; -; Read messages from either interface and forward to the other one. - -checkRecvdMsg: - rcall NET_PeekNextIncomingMsgNum ; check read queue (bufNum->r16) - brcc checkRecvdMsg_end ; no msg, jmp - rcall NET_Buffer_Locate ; (R17) - ; let system handle incoming messages - push r16 - adiw xh:xl, 1 - rcall letSysHandleMsg - sbiw xh:xl, 1 - pop r16 - - ; forward to other interface - ld r17, X - andi r17, (1< Date: Sun, 6 Jul 2025 20:01:35 +0200 Subject: [PATCH 078/196] Increment packets-out counter. --- avr/modules/uart_hw2/comonuart0.asm | 2 ++ avr/modules/uart_hw2/comonuart1.asm | 2 ++ 2 files changed, 4 insertions(+) diff --git a/avr/modules/uart_hw2/comonuart0.asm b/avr/modules/uart_hw2/comonuart0.asm index 10244b4..3534567 100644 --- a/avr/modules/uart_hw2/comonuart0.asm +++ b/avr/modules/uart_hw2/comonuart0.asm @@ -704,6 +704,8 @@ comOnUart0SendMsg_loopComplete: sbrs r16, TXC0 rjmp comOnUart0SendMsg_loopComplete rcall comOnUart0StopTx ; (R16) + ldi r16, NET_IFACE_OFFS_PACKETSOUT_LOW + rcall NET_Interface_IncCounter16 ; (R24, R25) rcall comOnUart0SetAttnInput ; release ATTN (none) rcall Utils_WaitFor10MicroSecs ; make sure ATTN is at least high for a short period (R22) sec diff --git a/avr/modules/uart_hw2/comonuart1.asm b/avr/modules/uart_hw2/comonuart1.asm index 5d4e985..27c51ec 100644 --- a/avr/modules/uart_hw2/comonuart1.asm +++ b/avr/modules/uart_hw2/comonuart1.asm @@ -704,6 +704,8 @@ comOnUart1SendMsg_loopComplete: sbrs r16, TXC1 rjmp comOnUart1SendMsg_loopComplete rcall comOnUart1StopTx ; (R16) + ldi r16, NET_IFACE_OFFS_PACKETSOUT_LOW + rcall NET_Interface_IncCounter16 ; (R24, R25) rcall comOnUart1SetAttnInput ; release ATTN (none) rcall Utils_WaitFor10MicroSecs ; make sure ATTN is at least high for a short period (R22) sec From 6ecc1721b09a86e74bce3c350d60b8f9202e2471 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 6 Jul 2025 20:21:51 +0200 Subject: [PATCH 079/196] r05: no longer use APPS_NETWORK. Implemented some of those features in APP_ROUTER like PING, REBOOT. --- avr/apps/router/main.asm | 122 ++++++++++++++++++++++++++++++++++ avr/devices/all/apps.asm | 4 ++ avr/devices/all/includes.asm | 3 + avr/devices/all/main.asm | 4 ++ avr/devices/r05/main/main.asm | 10 +-- 5 files changed, 136 insertions(+), 7 deletions(-) diff --git a/avr/apps/router/main.asm b/avr/apps/router/main.asm index 5350c27..4df9bf2 100644 --- a/avr/apps/router/main.asm +++ b/avr/apps/router/main.asm @@ -20,6 +20,19 @@ +; *************************************************************************** +; data + +.dseg + +appRouterDataBegin: + appRouterRangeBegin: .byte 1 + appRouterRangeEnd: .byte 1 +appRouterDataEnd: + + + + ; *************************************************************************** ; code @@ -29,6 +42,20 @@ ; @routine AppRouter_Init @global AppRouter_Init: + ldi xh, HIGH(appRouterDataBegin) + ldi xl, LOW(appRouterDataBegin) + clr r16 + ldi r17, (appRouterDataEnd-appRouterDataBegin) + rcall Utils_FillSram + + ldi r16, 0xe0 ; default range from 0xe0-0xef (will be changed later) + sts netInterfaceData+NET_IFACE_OFFS_ADDRESS, r16 ; use first address for router itself + sts netInterfaceData2+NET_IFACE_OFFS_ADDRESS, r16 ; use same address for both interfaces to save on addresses + inc r16 + sts appRouterRangeBegin, r16 ; range from router+1 + ldi r16, 0xef + sts appRouterRangeEnd, r16 + ; set interface number for NETDEV0 ldi r16, NETDEV0_IFACENUM sts netInterfaceData+NET_IFACE_OFFS_IFACENUM, r16 @@ -40,6 +67,24 @@ AppRouter_Init: +; --------------------------------------------------------------------------- +; @routine AppRouter_EveryDay @global +; +; @clobbers R16, R17, X + +AppRouter_EveryDay: + ldi yl, LOW(netInterfaceData) + ldi yh, HIGH(netInterfaceData) + bigcall NET_Interface_ResetStats ; (R16, R17, X) + + ldi yl, LOW(netInterfaceData2) + ldi yh, HIGH(netInterfaceData2) + bigcall NET_Interface_ResetStats ; (R16, R17, X) + ret +; @end + + + ; --------------------------------------------------------------------------- ; @routine AppRouter_Run @global ; @@ -51,6 +96,83 @@ AppRouter_Run: +; --------------------------------------------------------------------------- +; @routine AppRouter_HandleMsg @global +; +; @param X pointer to received message + +AppRouter_HandleMsg: + adiw xh:xl, NETMSG_OFFS_CMD ; maybe move ping/reboot handling to all/main.asm? + ld r16, X + sbiw xh:xl, NETMSG_OFFS_CMD + cpi r16, NETMSG_CMD_REBOOT_REQUEST + breq AppRouter_HandleMsg_handleRebootMsg + cpi r16, NETMSG_CMD_PING + breq AppRouter_HandleMsg_handlePingMsg + rjmp AppRouter_HandleMsg_clcRet +AppRouter_HandleMsg_handleRebootMsg: + push xl + push xh + rcall appRouterHandleRebootRequest + pop xh + pop xl + ret +AppRouter_HandleMsg_handlePingMsg: + push xl + push xh + rcall appRouterHandlePingRequest + pop xh + pop xl + ret +AppRouter_HandleMsg_clcRet: + clc + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appRouterHandleRebootRequest +; +; @param X pointer to received message + +appRouterHandleRebootRequest: + ld r16, X ; dest addr + cpi r16, 0xff ; don't reboot for broadcast address + breq appRouterHandleRebootRequest_end + + rcall NETMSG_RebootRequestRead + brcc appRouterHandleRebootRequest_end + ; reboot + cli + bigjmp BOOTLOADER_ADDR +appRouterHandleRebootRequest_end: + ret +; @end + + + +appRouterHandlePingRequest: + adiw xh:xl, NETMSG_OFFS_SRCADDR + ld r17, X + push r17 + bigcall NET_Buffer_Alloc ; (R16, R17, X) + pop r17 + brcc appRouterHandlePingRequest_end ; jmp on error + push r16 ; buffer num + mov r16, r17 ; DEST addr + adiw xh:xl, 1 + ldi yl, LOW(netInterfaceData) + ldi yh, HIGH(netInterfaceData) + bigcall NETMSG_Pong_Write ; (R16, R17, R18, R19, R20, X) + sbiw xh:xl, 1 + pop r16 ; buffer num + bigcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) +appRouterHandlePingRequest_end: + ret + + + ; --------------------------------------------------------------------------- ; @routine appRouterCheckRecvdMsg ; diff --git a/avr/devices/all/apps.asm b/avr/devices/all/apps.asm index 0c17385..1489a59 100644 --- a/avr/devices/all/apps.asm +++ b/avr/devices/all/apps.asm @@ -89,6 +89,10 @@ mainAppsOnPacketReceived: bigcall AppNetwork_HandleMsg #endif +#ifdef APPS_ROUTER + bigcall AppRouter_HandleMsg +#endif + #ifdef APPS_MA_LIGHT bigcall AppMotionLight_OnPacketReceived #endif diff --git a/avr/devices/all/includes.asm b/avr/devices/all/includes.asm index 172803d..7a8b6ae 100644 --- a/avr/devices/all/includes.asm +++ b/avr/devices/all/includes.asm @@ -244,6 +244,9 @@ #ifdef APPS_ROUTER .include "apps/router/main.asm" +.include "modules/network/msg/reboot-d.asm" +.include "modules/network/msg/reboot-r.asm" +.include "modules/network/msg/pong-w.asm" #endif diff --git a/avr/devices/all/main.asm b/avr/devices/all/main.asm index 98f5f17..d752723 100644 --- a/avr/devices/all/main.asm +++ b/avr/devices/all/main.asm @@ -186,6 +186,10 @@ sysOnEveryDay: bigcall AppNetwork_EveryDay #endif +#ifdef APPS_ROUTER + bigcall AppRouter_EveryDay +#endif + bigjmp onEveryDay ; @end diff --git a/avr/devices/r05/main/main.asm b/avr/devices/r05/main/main.asm index a94b187..b777a22 100644 --- a/avr/devices/r05/main/main.asm +++ b/avr/devices/r05/main/main.asm @@ -55,6 +55,7 @@ #define MAIN_WITHOUT_MSG_HANDLING ; message handling in AppRouter! +#define APP_STATS_NETDEV2 ; send stats for 2nd device #define MODULES_CLOCK #define MODULES_LED_SIMPLE @@ -70,7 +71,7 @@ #define MODULES_NETWORK #define MODULES_COMONUART0 #define MODULES_COMONUART1 -#define APPS_NETWORK +;#define APPS_NETWORK #define APPS_ROUTER @@ -168,18 +169,13 @@ onSystemStart: onEvery100ms: onEverySecond: +onEveryMinute: onEveryHour: onEveryDay: ret -onEveryMinute: - ret -; @end - - - ; --------------------------------------------------------------------------- ; @routine onEveryLoop ; From 280d5828bf006d50efc06d664d2f6ad4d6abba64 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 6 Jul 2025 20:22:19 +0200 Subject: [PATCH 080/196] fixed a possible problem. don't reboot on broadcast request. --- avr/apps/network/main.asm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/avr/apps/network/main.asm b/avr/apps/network/main.asm index e7b5d8a..18e7ed5 100644 --- a/avr/apps/network/main.asm +++ b/avr/apps/network/main.asm @@ -101,7 +101,7 @@ AppNetwork_Every100ms_jump: ; --------------------------------------------------------------------------- -; @routine AppNetwork_Every100ms @global +; @routine AppNetwork_EveryDay @global ; ; @clobbers R16, R17, X @@ -171,6 +171,10 @@ AppNetwork_HandleMsg_clcRet: ; @param X pointer to received message appNetworkHandleRebootRequest: + ld r16, X ; dest addr + cpi r16, 0xff ; don't reboot for broadcast address + breq appNetworkHandleRebootRequest_end + rcall NETMSG_RebootRequestRead brcc appNetworkHandleRebootRequest_end ; reboot From 691ee3c71b5906e5dcb827f43907eac2bcdae28b Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 6 Jul 2025 20:22:38 +0200 Subject: [PATCH 081/196] incremented firmware version. --- avr/version.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avr/version.asm b/avr/version.asm index 5a20d76..7991e72 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 = 10 +.equ FIRMWARE_VERSION_PATCHLEVEL = 11 From cbd498150f9bae31cf64e8fa383af0b3b2dcce55 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 7 Jul 2025 16:05:53 +0200 Subject: [PATCH 082/196] avr: fully implemented router functionality in network and router app. --- aqhome/msg/node/0BUILD | 2 + aqhome/msg/node/m_node.c | 5 +- aqhome/msg/node/m_node.h | 1 + aqhome/msg/node/m_range.c | 61 ++++++ aqhome/msg/node/m_range.h | 30 +++ avr/apps/network/main.asm | 71 +++--- avr/apps/router/main.asm | 324 +++++++++++++++++++++++++--- avr/apps/stats/main.asm | 15 +- avr/common/0BUILD | 2 + avr/common/eeprom-r.asm | 86 ++++++++ avr/common/eeprom-w.asm | 100 +++++++++ avr/devices/all/apps.asm | 4 - avr/devices/all/defs.asm | 21 +- avr/devices/all/includes.asm | 7 + avr/devices/r05/aqua_r05.xml | 1 + avr/devices/r05/main/main.asm | 1 + avr/modules/network/msg/0BUILD | 3 + avr/modules/network/msg/defs.asm | 1 + avr/modules/network/msg/range-d.asm | 18 ++ avr/modules/network/msg/range-r.asm | 38 ++++ avr/modules/network/msg/range-w.asm | 44 ++++ 21 files changed, 769 insertions(+), 66 deletions(-) create mode 100644 aqhome/msg/node/m_range.c create mode 100644 aqhome/msg/node/m_range.h create mode 100644 avr/common/eeprom-r.asm create mode 100644 avr/common/eeprom-w.asm create mode 100644 avr/modules/network/msg/range-d.asm create mode 100644 avr/modules/network/msg/range-r.asm create mode 100644 avr/modules/network/msg/range-w.asm diff --git a/aqhome/msg/node/0BUILD b/aqhome/msg/node/0BUILD index 595ef36..43d0bc1 100644 --- a/aqhome/msg/node/0BUILD +++ b/aqhome/msg/node/0BUILD @@ -62,6 +62,7 @@ m_flashend.h m_flashready.h m_flashresponse.h + m_range.h @@ -89,6 +90,7 @@ m_flashend.c m_flashready.c m_flashresponse.c + m_range.c diff --git a/aqhome/msg/node/m_node.c b/aqhome/msg/node/m_node.c index 3959207..f345b4a 100644 --- a/aqhome/msg/node/m_node.c +++ b/aqhome/msg/node/m_node.c @@ -28,6 +28,7 @@ #include "aqhome/msg/node/m_flashend.h" #include "aqhome/msg/node/m_flashready.h" #include "aqhome/msg/node/m_flashresponse.h" +#include "aqhome/msg/node/m_range.h" #include @@ -212,6 +213,7 @@ const char *AQH_NodeMessage_MsgTypeToChar(uint8_t i) case AQH_MSG_TYPE_CLAIM_ADDRESS: return "ClaimAddress"; case AQH_MSG_TYPE_DENY_ADDRESS: return "DenyAddress"; case AQH_MSG_TYPE_ADDRESS_RANGE: return "Range"; + case AQH_MSG_TYPE_REENUM: return "Reenum"; case AQH_MSG_TYPE_FLASH_START: return "FlashStart"; case AQH_MSG_TYPE_FLASH_END: return "FlashEnd"; @@ -246,6 +248,8 @@ void AQH_NodeMessage_DumpSpecificToBuffer(const AQH_MESSAGE *msg, GWEN_BUFFER *d case AQH_MSG_TYPE_HAVE_ADDRESS: AQH_AddrMessage_DumpToBuffer(msg, dbuf, sText); break; case AQH_MSG_TYPE_CLAIM_ADDRESS: AQH_AddrMessage_DumpToBuffer(msg, dbuf, sText); break; case AQH_MSG_TYPE_DENY_ADDRESS: AQH_AddrMessage_DumpToBuffer(msg, dbuf, sText); break; + case AQH_MSG_TYPE_ADDRESS_RANGE: AQH_RangeMessage_DumpToBuffer(msg, dbuf, sText); break; + case AQH_MSG_TYPE_REENUM: AQH_RangeMessage_DumpToBuffer(msg, dbuf, sText); break; case AQH_MSG_TYPE_FLASH_START: AQH_FlashStartMessage_DumpToBuffer(msg, dbuf, sText); break; case AQH_MSG_TYPE_FLASH_END: AQH_FlashEndMessage_DumpToBuffer(msg, dbuf, sText); break; @@ -266,7 +270,6 @@ void AQH_NodeMessage_DumpSpecificToBuffer(const AQH_MESSAGE *msg, GWEN_BUFFER *d case AQH_MSG_TYPE_DEBUG: case AQH_MSG_TYPE_TWIBUSMEMBER: - case AQH_MSG_TYPE_ADDRESS_RANGE: default: AQH_NodeMessage_DumpToBuffer(msg, dbuf, sText); break; } } diff --git a/aqhome/msg/node/m_node.h b/aqhome/msg/node/m_node.h index ba9acb2..151d625 100644 --- a/aqhome/msg/node/m_node.h +++ b/aqhome/msg/node/m_node.h @@ -40,6 +40,7 @@ #define AQH_MSG_TYPE_CLAIM_ADDRESS 62 #define AQH_MSG_TYPE_DENY_ADDRESS 63 #define AQH_MSG_TYPE_ADDRESS_RANGE 64 +#define AQH_MSG_TYPE_REENUM 65 #define AQH_MSG_TYPE_FLASH_START 70 #define AQH_MSG_TYPE_FLASH_END 71 diff --git a/aqhome/msg/node/m_range.c b/aqhome/msg/node/m_range.c new file mode 100644 index 0000000..fa898c6 --- /dev/null +++ b/aqhome/msg/node/m_range.c @@ -0,0 +1,61 @@ +/**************************************************************************** + * This file is part of the project AqHome. + * AqHome (c) by 2025 Martin Preuss, all rights reserved. + * + * The license for this file can be found in the file COPYING which you + * should have received along with this file. + ****************************************************************************/ + +#ifdef HAVE_CONFIG_H +# include +#endif + + + +#include "aqhome/msg/node/m_range.h" +#include "aqhome/msg/node/m_node.h" + +#include + + +#define AQH_MSG_OFFS_RANGE_UID 0 /* 4 bytes */ +#define AQH_MSG_OFFS_RANGE_BEGIN 4 /* 1 bytes */ +#define AQH_MSG_OFFS_RANGE_END 5 /* 1 bytes */ + + + +uint32_t AQH_RangeMessage_GetUid(const AQH_MESSAGE *msg) +{ + return AQH_Message_ReadUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RANGE_UID, 0); +} + + + +uint8_t AQH_RangeMessage_GetRangeBegin(const AQH_MESSAGE *msg) +{ + return AQH_Message_ReadUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RANGE_BEGIN, 0); +} + + + +uint8_t AQH_RangeMessage_GetRangeEnd(const AQH_MESSAGE *msg) +{ + return AQH_Message_ReadUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RANGE_END, 0); +} + + + +void AQH_RangeMessage_DumpToBuffer(const AQH_MESSAGE *msg, GWEN_BUFFER *dbuf, const char *sText) +{ + GWEN_Buffer_AppendArgs(dbuf, + "0x%02x->0x%02x: RANGE(%s) %s (uid=0x%08x, begin=0x%x, end=0x%x)\n", + AQH_NodeMessage_GetSourceAddress(msg), + AQH_NodeMessage_GetDestAddress(msg), + AQH_NodeMessage_MsgTypeToChar(AQH_NodeMessage_GetMsgType(msg)), + sText, + (unsigned int) AQH_RangeMessage_GetUid(msg), + AQH_RangeMessage_GetRangeBegin(msg), + AQH_RangeMessage_GetRangeEnd(msg)); +} + + diff --git a/aqhome/msg/node/m_range.h b/aqhome/msg/node/m_range.h new file mode 100644 index 0000000..a77120e --- /dev/null +++ b/aqhome/msg/node/m_range.h @@ -0,0 +1,30 @@ +/**************************************************************************** + * This file is part of the project AqHome. + * AqHome (c) by 2025 Martin Preuss, all rights reserved. + * + * The license for this file can be found in the file COPYING which you + * should have received along with this file. + ****************************************************************************/ + +#ifndef AQH_M_RANGE_H +#define AQH_M_RANGE_H + + +#include +#include + +#include + + +/* This message is used for message types ClaimAddr, DenyAddr, HaveAddr */ + +AQHOME_API uint32_t AQH_RangeMessage_GetUid(const AQH_MESSAGE *msg); +AQHOME_API uint8_t AQH_RangeMessage_GetAddr(const AQH_MESSAGE *msg); +AQHOME_API uint8_t AQH_RangeMessage_GetRangeBegin(const AQH_MESSAGE *msg); +AQHOME_API uint8_t AQH_RangeMessage_GetRangeEnd(const AQH_MESSAGE *msg); + +AQHOME_API void AQH_RangeMessage_DumpToBuffer(const AQH_MESSAGE *msg, GWEN_BUFFER *dbuf, const char *sText); + + + +#endif diff --git a/avr/apps/network/main.asm b/avr/apps/network/main.asm index 18e7ed5..5205261 100644 --- a/avr/apps/network/main.asm +++ b/avr/apps/network/main.asm @@ -117,6 +117,13 @@ AppNetwork_EveryDay: ; @param X pointer to received message AppNetwork_HandleMsg: + push xl + push xh + rcall AppNetwork_HandleMsg_savedX + pop xh + pop xl + rjmp AppNetwork_HandleMsg_end +AppNetwork_HandleMsg_savedX: adiw xh:xl, NETMSG_OFFS_CMD ld r16, X sbiw xh:xl, NETMSG_OFFS_CMD @@ -124,14 +131,21 @@ AppNetwork_HandleMsg: breq AppNetwork_HandleMsg_handleRebootMsg cpi r16, NETMSG_CMD_PING breq AppNetwork_HandleMsg_handlePingMsg + cpi r16, NETMSG_CMD_REENUM + breq AppNetwork_HandleMsg_handleReenumMsg cpi r16, NETMSG_CMD_NEED_ADDRESS brcs AppNetwork_HandleMsg_clcRet ; lower than "HAVE_NEED" cpi r16, NETMSG_CMD_ADDRESS_RANGE breq AppNetwork_HandleMsg_handleRangeMsg brcc AppNetwork_HandleMsg_clcRet ; higher or equal to "ADDR_RANGE" rjmp AppNetwork_HandleMsg_handleAddrMsg +AppNetwork_HandleMsg_handleReenumMsg: + rjmp appNetworkHandleReeunumRequest AppNetwork_HandleMsg_handleRangeMsg: - ; TODO + bigcall NETMSG_Range_Read + std Y+NET_IFACE_OFFS_RANGE_BEGIN, r20 + std Y+NET_IFACE_OFFS_RANGE_END, r21 + std Y+NET_IFACE_OFFS_ADDRESS, r20 rjmp AppNetwork_HandleMsg_clcRet AppNetwork_HandleMsg_handleAddrMsg: @@ -145,21 +159,13 @@ AppNetwork_HandleMsg_handleAddrMsg: sub zh, r16 ijmp AppNetwork_HandleMsg_handleRebootMsg: - push xl - push xh - rcall appNetworkHandleRebootRequest - pop xh - pop xl + rcall appNetworkHandleRebootRequest ret AppNetwork_HandleMsg_handlePingMsg: - push xl - push xh - rcall appNetworkHandlePingRequest - pop xh - pop xl - ret + rjmp appNetworkHandlePingRequest AppNetwork_HandleMsg_clcRet: clc +AppNetwork_HandleMsg_end: ret ; @end @@ -171,12 +177,8 @@ AppNetwork_HandleMsg_clcRet: ; @param X pointer to received message appNetworkHandleRebootRequest: - ld r16, X ; dest addr - cpi r16, 0xff ; don't reboot for broadcast address - breq appNetworkHandleRebootRequest_end - rcall NETMSG_RebootRequestRead - brcc appNetworkHandleRebootRequest_end + brcc appNetworkHandleRebootRequest_end ; uid doesn't match ; reboot cli bigjmp BOOTLOADER_ADDR @@ -207,6 +209,20 @@ appNetworkHandlePingRequest_end: +appNetworkHandleReeunumRequest: + rcall NETMSG_Range_Read + ldi r16, APP_NETWORK_STATE_INITIALWAIT + std Y+NET_IFACE_OFFS_STATUS, r16 + ldd r16, Y+NET_IFACE_OFFS_ADDRESS ; use current address as timer + std Y+NET_IFACE_OFFS_STATETIMER, r16 + ldi r16, APP_NETWORK_ADDRESS_RANGE_BEGIN + std Y+NET_IFACE_OFFS_RANGE_BEGIN, r20 + std Y+NET_IFACE_OFFS_RANGE_END, r21 + ret +; @end + + + appNetworkTimerTable: rjmp appNetworkHandleStateInitialWait rjmp appNetworkHandleStateNeedAddress @@ -253,12 +269,8 @@ appNetworkHandleStateHaveAddress2: std Y+NET_IFACE_OFFS_STATUS, r16 ldi r16, APP_NETWORK_TIMER_100MS std Y+NET_IFACE_OFFS_STATETIMER, r16 - ldd r16, Y+NET_IFACE_OFFS_RANGE_BEGIN ; set interface address - ldd r17, Y+NET_IFACE_OFFS_ADDRESS - cp r16, r17 - breq appNetworkHandleStateHaveAddress2_end ; store new address in IFACE and in EEPROM - std Y+NET_IFACE_OFFS_ADDRESS, r16 + ldd r16, Y+NET_IFACE_OFFS_ADDRESS push r15 in r15, SREG cli @@ -284,7 +296,7 @@ appNetworkHandleStateUp: ; @clobbers R16, R19 (R17, R18, R20, R21, X) appNetworkSendMsgNextState: - ldd r19, Y+NET_IFACE_OFFS_RANGE_BEGIN + ldd r19, Y+NET_IFACE_OFFS_ADDRESS rcall appNetworkSendAddrMsg ; (R16, R17, R18, R19, R20, R21, X) brcc appNetworkSendMsgNextState_retry ldd r16, Y+NET_IFACE_OFFS_STATUS @@ -349,9 +361,9 @@ appNetworkHandleMsgClaimAddr: cp r19, r16 brne appNetworkHandleMsgClaimAddr_end ; not our address ldd r16, Y+NET_IFACE_OFFS_STATUS - cpi r16, APP_NETWORK_STATE_UP ; up? - brne appNetworkHandleMsgClaimAddr_end ; nope, ignore - ; network is up, someone claimed our address, deny it + cpi r16, APP_NETWORK_STATE_CLAIMADDRESS1 + brcs appNetworkHandleMsgClaimAddr_end ; nope, ignore + ; network is somewhat up, someone claimed our address, deny it ldi r18, NETMSG_CMD_DENY_ADDRESS ; deny our addr ldd r19, Y+NET_IFACE_OFFS_ADDRESS rjmp appNetworkSendAddrMsg @@ -373,12 +385,12 @@ appNetworkHandleMsgDenyAddr: cpi r16, APP_NETWORK_STATE_UP breq appNetworkHandleMsgDenyAddr_end ; ignore (our network stack is up) ; still setting up address, check whether the last one is denied now - ldd r16, Y+NET_IFACE_OFFS_RANGE_BEGIN + ldd r16, Y+NET_IFACE_OFFS_ADDRESS cp r19, r16 ; our claimed address? brne appNetworkHandleMsgDenyAddr_end ; nope, jump ; try next address (if any left) ldd r17, Y+NET_IFACE_OFFS_RANGE_END - inc r16 ; RANGE_BEGIN+1 + inc r16 ; next address cp r17, r16 ; smaller than or equal to RANGE_END? brcc appNetworkHandleMsgDenyAddr_claimNext ; out of addresses, start completely new after some waiting time @@ -388,7 +400,7 @@ appNetworkHandleMsgDenyAddr: rjmp appNetworkHandleMsgDenyAddr_end appNetworkHandleMsgDenyAddr_claimNext: ; send CLAIM_ADDR for next address (new state: APP_NETWORK_STATE_NEEDADDRESS+1) - std Y+NET_IFACE_OFFS_RANGE_BEGIN, r16 + std Y+NET_IFACE_OFFS_ADDRESS, r16 ldi r16, APP_NETWORK_STATE_NEEDADDRESS std Y+NET_IFACE_OFFS_STATUS, r16 ldi r18, NETMSG_CMD_CLAIM_ADDRESS @@ -439,6 +451,7 @@ appNetworkResetState: std Y+NET_IFACE_OFFS_STATETIMER, r16 ldi r16, APP_NETWORK_ADDRESS_RANGE_BEGIN std Y+NET_IFACE_OFFS_RANGE_BEGIN, r16 + std Y+NET_IFACE_OFFS_ADDRESS, r16 rcall appNetworkGetAddressFromEeprom ; R16=addr (R15, X) tst r16 breq appNetworkResetState_setRangeEnd diff --git a/avr/apps/router/main.asm b/avr/apps/router/main.asm index 4df9bf2..76e1d0d 100644 --- a/avr/apps/router/main.asm +++ b/avr/apps/router/main.asm @@ -56,6 +56,8 @@ AppRouter_Init: ldi r16, 0xef sts appRouterRangeEnd, r16 + rcall appRouterReadConfFromEeprom ; try to read config from EEPROM + ; set interface number for NETDEV0 ldi r16, NETDEV0_IFACENUM sts netInterfaceData+NET_IFACE_OFFS_IFACENUM, r16 @@ -97,35 +99,207 @@ AppRouter_Run: ; --------------------------------------------------------------------------- -; @routine AppRouter_HandleMsg @global +; @routine appRouterHandleMsgAnyDev @global ; ; @param X pointer to received message +; @return CFLAG set if msg handled, cleared otherwise +; @clobbers any, !X -AppRouter_HandleMsg: - adiw xh:xl, NETMSG_OFFS_CMD ; maybe move ping/reboot handling to all/main.asm? +appRouterHandleMsgAnyDev: + push xl + push xh + rcall appRouterHandleMsgAnyDev_savedX + pop xh + pop xl + rjmp appRouterHandleMsgAnyDev_end +appRouterHandleMsgAnyDev_savedX: + adiw xh:xl, NETMSG_OFFS_CMD ; maybe move ping/reboot handling to all/main.asm? ld r16, X sbiw xh:xl, NETMSG_OFFS_CMD cpi r16, NETMSG_CMD_REBOOT_REQUEST - breq AppRouter_HandleMsg_handleRebootMsg + breq appRouterHandleMsgAnyDev_handleRebootMsg cpi r16, NETMSG_CMD_PING - breq AppRouter_HandleMsg_handlePingMsg - rjmp AppRouter_HandleMsg_clcRet -AppRouter_HandleMsg_handleRebootMsg: - push xl - push xh - rcall appRouterHandleRebootRequest - pop xh - pop xl + breq appRouterHandleMsgAnyDev_handlePingMsg + cpi r16, NETMSG_CMD_VALUE_SET + breq appRouterHandleMsgAnyDev_handleSetValue + rjmp appRouterHandleMsgAnyDev_clcRet +appRouterHandleMsgAnyDev_handleRebootMsg: + rcall appRouterHandleRebootRequest ret -AppRouter_HandleMsg_handlePingMsg: - push xl - push xh - rcall appRouterHandlePingRequest - pop xh - pop xl +appRouterHandleMsgAnyDev_handlePingMsg: + rcall appRouterHandlePingRequest ret -AppRouter_HandleMsg_clcRet: +appRouterHandleMsgAnyDev_handleSetValue: + rcall NETMSG_ValueRead ; (none) + cpi r17, VALUE_ID_ROUTER_SETRANGE + breq appRouterHandleMsgAnyDev_handleSetRange + rjmp appRouterHandleMsgAnyDev_clcRet +appRouterHandleMsgAnyDev_handleSetRange: + sts netInterfaceData+NET_IFACE_OFFS_ADDRESS, r18 ; use first address for router itself + sts netInterfaceData2+NET_IFACE_OFFS_ADDRESS, r18 ; use same address for both interfaces to save on addresses + inc r18 ; start range after router + sts appRouterRangeBegin, r18 + sts appRouterRangeEnd, r19 + ; send ACK + ldi r23, NETMSG_CMD_VALUE_SET_ACK + rcall Main_SendValueResponse ; (clobbers all, including Y) + ; let subnodes re-eunumerate + ldi r18, NETMSG_CMD_REENUM + rcall appRouterSendRangeMsgToDev1 ; (R16, R17, R18, R19, R20, R21, X, Y) + rcall appRouterWriteConfToEeprom ; (r16, r17, X) + sec + ret +appRouterHandleMsgAnyDev_clcRet: clc +appRouterHandleMsgAnyDev_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appRouterHandleDev1Msg @global +; +; Handle messages from controlled subnet. +; +; @param X pointer to received message +; @return CFLAG set if msg handled, cleared otherwise +; @clobbers any, !X + +appRouterHandleDev1Msg: + push xl + push xh + rcall appRouterHandleDev1Msg_savedX + pop xh + pop xl + rjmp appRouterHandleDev1Msg_end +appRouterHandleDev1Msg_savedX: + adiw xh:xl, NETMSG_OFFS_CMD ; maybe move ping/reboot handling to all/main.asm? + ld r16, X + sbiw xh:xl, NETMSG_OFFS_CMD + cpi r16, NETMSG_CMD_NEED_ADDRESS + breq appRouterHandleDev1Msg_handleNeedAddr + cpi r16, NETMSG_CMD_CLAIM_ADDRESS + breq appRouterHandleDev1Msg_handleClaimAddr + ; add more here + rjmp appRouterHandleDev1Msg_clcRet +appRouterHandleDev1Msg_handleNeedAddr: + ldi r18, NETMSG_CMD_ADDRESS_RANGE + rcall appRouterSendRangeMsgToDev1 ; (R16, R17, R18, R19, R20, R21, X, Y) + sec + rjmp appRouterHandleDev1Msg_end +appRouterHandleDev1Msg_handleClaimAddr: + rcall NETMSG_Address_Read ; R18=cmd, R19=addr(R18, R19) + rcall appRouterIsR19InRange + brcs appRouterHandleDev1Msg_end + ; is not in subnet range, deny + rcall appRouterSendDenyAddrR19ToDev1 ; (R16, R17, R18, R19, R20, R21, X, Y) + sec + rjmp appRouterHandleDev1Msg_end +appRouterHandleDev1Msg_clcRet: + clc +appRouterHandleDev1Msg_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appRouterIsR19InRange +; +; @param R19 address to check against range +; @clobbers R16 + +appRouterIsR19InRange: + lds r16, appRouterRangeBegin + cp r19, r16 + brcs appRouterIsR19InRangeClcRet + lds r16, appRouterRangeEnd + cp r16, r19 + brcs appRouterIsR19InRangeClcRet + sec + rjmp appRouterIsR19InRange_end +appRouterIsR19InRangeClcRet: + clc +appRouterIsR19InRange_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appRouterSendDenyAddrR19ToDev1 +; +; @param R19 address to send +; @clobbers R16, R17, R18, R19, R20, R21, X, Y + +appRouterSendDenyAddrR19ToDev1: + ldi r18, NETMSG_CMD_DENY_ADDRESS ; deny addr + rjmp appRouterSendAddrMsgToDev1 ; (R16, R17, R18, R19, R20, R21, X, Y) +; @end + + + +; --------------------------------------------------------------------------- +; @routine appRouterSendAddrMsgToDev1 +; +; @param R18 command +; @param R19 address to send +; @clobbers R16 (R17, R18, R19, R20, R21, X, Y) + +appRouterSendAddrMsgToDev1: + bigcall NET_Buffer_Alloc ; (R16, R17, X) + brcc appRouterSendAddrMsgToDev1_end + push r16 + adiw xh:xl, 1 + bigcall NETMSG_Address_Write ; (R16, R17, R18, R19, R20, R21) + sbiw xh:xl, 1 + pop r16 + rcall appRouterSendMsgToDev1 ; (R16, R17, R18, X, Y) +appRouterSendAddrMsgToDev1_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appRouterSendRangeMsgToDev1 +; +; @param R18 msg code +; @clobbers (R16, R17, R18, R19, R20, R21, X, Y) + +appRouterSendRangeMsgToDev1: + bigcall NET_Buffer_Alloc ; (R16, R17, X) + brcc appRouterSendRangeMsgToDev1_end + push r16 + lds r20, appRouterRangeBegin + lds r21, appRouterRangeEnd + adiw xh:xl, 1 + bigcall NETMSG_Range_Write ; (R16, R17, R18, R19, R20, R21) + sbiw xh:xl, 1 + pop r16 + rcall appRouterSendMsgToDev1 ; (R16, R17, R18, X, Y) +appRouterSendRangeMsgToDev1_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appRouterSendMsgToDev1 +; +; @param R16 num of allocated buffer +; @param X msg to send (points to start of allocated buffer, e.g. buffer header) +; @clobbers Y (R16, R17, R18, X) + +appRouterSendMsgToDev1: + ldi yl, LOW(netInterfaceData2) + ldi yh, HIGH(netInterfaceData2) + bigcall NET_Interface_AddOutgoingMsgNum ; (R17, R18, X) + brcs appRouterSendMsgToDev1_end + bigcall NET_Buffer_ReleaseByNum ; (R16, X) + clc +appRouterSendMsgToDev1_end: ret ; @end @@ -134,13 +308,11 @@ AppRouter_HandleMsg_clcRet: ; --------------------------------------------------------------------------- ; @routine appRouterHandleRebootRequest ; +; Doesn't return if reboot msg is valid. +; ; @param X pointer to received message appRouterHandleRebootRequest: - ld r16, X ; dest addr - cpi r16, 0xff ; don't reboot for broadcast address - breq appRouterHandleRebootRequest_end - rcall NETMSG_RebootRequestRead brcc appRouterHandleRebootRequest_end ; reboot @@ -152,6 +324,11 @@ appRouterHandleRebootRequest_end: +; --------------------------------------------------------------------------- +; @routine appRouterHandlePingRequest +; +; @param X pointer to received message + appRouterHandlePingRequest: adiw xh:xl, NETMSG_OFFS_SRCADDR ld r17, X @@ -180,14 +357,14 @@ appRouterHandlePingRequest_end: appRouterCheckRecvdMsg: rcall NET_PeekNextIncomingMsgNum ; check read queue (bufNum->r16) - brcc appRouterCheckRecvdMsg_end ; no msg, jmp + brcc appRouterCheckRecvdMsg_end ; no msg, jmp rcall NET_Buffer_Locate ; (R17) + rcall appRouterHandleRouterMsgWithHdr ; filter out router msgs + brcs appRouterCheckRecvdMsg_removeMsg ; handled by router code, don't forward ; let system handle incoming messages - push r16 - adiw xh:xl, 1 - rcall appRouterLetSysHandleMsg - sbiw xh:xl, 1 - pop r16 + adiw xh:xl, 1 + rcall appRouterLetSysHandleMsg + sbiw xh:xl, 1 ; forward to other interface ld r17, X @@ -197,11 +374,43 @@ appRouterCheckRecvdMsg: brcc appRouterCheckRecvdMsg_end ; could not add, jmp rcall NET_GetNextIncomingMsgNum ; take off the queue rjmp appRouterCheckRecvdMsg + +appRouterCheckRecvdMsg_removeMsg: + rcall NET_GetNextIncomingMsgNum ; take off the queue + rcall NET_Buffer_ReleaseByNum ; (R16, X) + sec appRouterCheckRecvdMsg_end: ret ; @end +; --------------------------------------------------------------------------- +; @routine appRouterHandleRouterMsgWithHdr +; +; @param X pointer to msg +; @return CFLAG set if msg handled, cleared otherwise + +appRouterHandleRouterMsgWithHdr: + ld r17, X + andi r17, (1< diff --git a/avr/common/eeprom-r.asm b/avr/common/eeprom-r.asm new file mode 100644 index 0000000..bd66fa0 --- /dev/null +++ b/avr/common/eeprom-r.asm @@ -0,0 +1,86 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + +#ifndef AQH_AVR_COMMON_EEPROM_R_H +#define AQH_AVR_COMMON_EEPROM_R_H + + + +; --------------------------------------------------------------------------- +; @routine Eeprom_ReadByte +; +; Read a byte from EEPROM (see example in ATtiny24/44/84 manual p.19). +; +; @param X EEPROM Address to read from +; @return CFLAG set if address okay, cleared if out of range +; @return R16 byte read +; @return X EEPROM Address incremented +; @clobbers none + +Eeprom_ReadByte: + rcall Eeprom_CheckAddr + brcs Eeprom_ReadByte_addrOk + ret +Eeprom_ReadByte_addrOk: + ; call routine with IRQs disabled + push r15 + inr r15, SREG + cli + rcall Eeprom_ReadByte_noirq + outr SREG, r15 + pop r15 + sec + ret +Eeprom_ReadByte_noirq: + ; wait until EEPROM ready +Eeprom_ReadByte_waitLoop: +.ifdef EEPE + sbic EECR, EEPE ; wait for previous write to complete (if any) +.else + sbic EECR, EEWE ; wait for previous write to complete (if any) +.endif + rjmp Eeprom_ReadByte_waitLoop +; read from EEPROM + out EEARH, xh ; set EEPROM address + out EEARL, xl + sbi EECR, EERE ; start EEPROM read by writing EERE + in r16, EEDR ; read data from data register + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine Eeprom_CheckAddr +; +; +; @param X EEPROM Address to validate +; @return CFLAG set if address okay, cleared if out of range +; @clobbers r16 + +Eeprom_CheckAddr: + mov r16, xl + subi r16, LOW(EEPROMEND) + mov r16, xh + sbci r16, HIGH(EEPROMEND) + brcc Eeprom_CheckAddr_ok + clc + rjmp Eeprom_CheckAddr_end +Eeprom_CheckAddr_ok: + sec +Eeprom_CheckAddr_end: + ret +; @end + + + + +#endif ; AQH_AVR_COMMON_EEPROM_R_H + + diff --git a/avr/common/eeprom-w.asm b/avr/common/eeprom-w.asm new file mode 100644 index 0000000..02d87a2 --- /dev/null +++ b/avr/common/eeprom-w.asm @@ -0,0 +1,100 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + +#ifndef AQH_AVR_COMMON_EEPROM_W_H +#define AQH_AVR_COMMON_EEPROM_W_H + + +; --------------------------------------------------------------------------- +; Utils_WriteEepromIncr +; +; Write a byte to EEPROM (see example in ATtiny24/44/84 manual p.18). +; +; @param R16 byte to write +; @param X EEPROM Address to write to +; @return CFLAG set if data written, cleared on error +; @clobbers R17 + +Eeprom_WriteByte: + mov r17, r16 + rcall Eeprom_CheckAddr ; (r16) + mov r16, r17 + brcs Eeprom_WriteByte_addrOk + ret +Eeprom_WriteByte_addrOk: + ; call routine with IRQs disabled + push r15 + inr r15, SREG + cli + rcall Eeprom_WriteByte_noirq + outr SREG, r15 + pop r15 + sec + ret +Eeprom_WriteByte_noirq: + ; wait for EEPROM to be ready +Eeprom_WriteByte_waitLoop: +.ifdef EEPE + sbic EECR, EEPE ; wait for previous write to complete (if any) +.else + sbic EECR, EEWE ; wait for previous write to complete (if any) +.endif + rjmp Eeprom_WriteByte_waitLoop + ; write data +.ifdef EEPM1 + ldi r17, (0< + diff --git a/avr/devices/r05/main/main.asm b/avr/devices/r05/main/main.asm index b777a22..b036a5e 100644 --- a/avr/devices/r05/main/main.asm +++ b/avr/devices/r05/main/main.asm @@ -89,6 +89,7 @@ .equ VALUE_ID_DS18B20_TEMP = 0x06 .equ VALUE_ID_LEDSIMPLE_TIMING = 0x88 +.equ VALUE_ID_ROUTER_SETRANGE = 0x89 ; *************************************************************************** diff --git a/avr/modules/network/msg/0BUILD b/avr/modules/network/msg/0BUILD index 88b6afe..8c7a484 100644 --- a/avr/modules/network/msg/0BUILD +++ b/avr/modules/network/msg/0BUILD @@ -13,6 +13,9 @@ device-w.asm memstats-w.asm pong-w.asm + range-d.asm + range-r.asm + range-w.asm reboot-d.asm reboot-r.asm recvstats-w.asm diff --git a/avr/modules/network/msg/defs.asm b/avr/modules/network/msg/defs.asm index e5b8c3d..5b2a62c 100644 --- a/avr/modules/network/msg/defs.asm +++ b/avr/modules/network/msg/defs.asm @@ -26,6 +26,7 @@ .equ NETMSG_CMD_CLAIM_ADDRESS = 62 .equ NETMSG_CMD_DENY_ADDRESS = 63 .equ NETMSG_CMD_ADDRESS_RANGE = 64 +.equ NETMSG_CMD_REENUM = 65 .equ NETMSG_CMD_FLASH_START = 70 .equ NETMSG_CMD_FLASH_END = 71 diff --git a/avr/modules/network/msg/range-d.asm b/avr/modules/network/msg/range-d.asm new file mode 100644 index 0000000..723d8cc --- /dev/null +++ b/avr/modules/network/msg/range-d.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. * +; *************************************************************************** + + + +.equ NETMSG_RANGE_OFFS_UID = 4 +.equ NETMSG_RANGE_OFFS_FROM = 8 +.equ NETMSG_RANGE_OFFS_TO = 9 + + + + diff --git a/avr/modules/network/msg/range-r.asm b/avr/modules/network/msg/range-r.asm new file mode 100644 index 0000000..ad46e4c --- /dev/null +++ b/avr/modules/network/msg/range-r.asm @@ -0,0 +1,38 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + +; *************************************************************************** +; code + +.cseg + + +; --------------------------------------------------------------------------- +; @routine NETMSG_RangeRead @global +; Read a RANGE message. +; +; @param X buffer to read from +; @return R18 command +; @return R20 range begin +; @return R21 range end +; @clobbers none + +NETMSG_Range_Read: + adiw xh:xl, NETMSG_OFFS_CMD + ld r18, X ; command + adiw xh:xl, NETMSG_RANGE_OFFS_FROM-NETMSG_OFFS_CMD ; skip src addr and uid + ld r20, X+ ; range from + ld r21, X ; range to + sbiw xh:xl, NETMSG_RANGE_OFFS_TO ; back to msg begin + ret +; @end + + + diff --git a/avr/modules/network/msg/range-w.asm b/avr/modules/network/msg/range-w.asm new file mode 100644 index 0000000..1511da4 --- /dev/null +++ b/avr/modules/network/msg/range-w.asm @@ -0,0 +1,44 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + +; --------------------------------------------------------------------------- +; @routine NETMSG_Range_Write +; +; @param Y pointer to device to write msg for +; @param X pointer to buffer to write to +; @param R18 command +; @param R20 range begin +; @param R21 range end +; @clobbers R16, R18 (R17, R19, R20, R21, Z) + +NETMSG_Range_Write: + ldi r16, 0xff + st X+, r16 ; dest address + ldi r16, 8 ; msg code+src address+6 payload bytes + st X+, r16 ; msg len + st X+, r18 ; msg code + ldd r16, Y+NET_IFACE_OFFS_ADDRESS + st X+, r16 ; src address + push r20 + push r21 + rcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21) + pop r21 + pop r20 + st X+, r20 ; range begin + st X+, r21 ; range end + + sbiw xh:xl, 10 ; go back to beginning of message (1 byte dst addr, 1 byte length, 8 bytes payload) + rcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X) + sbiw xh:xl, 11 ; go back to beginning of message (1 byte dst addr, 1 byte length, 8 bytes payload, 1 byte crc) + ret +; @end + + + From fbb710a4e3f891a59cfa816666e073b91bec0cb4 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 7 Jul 2025 16:06:18 +0200 Subject: [PATCH 083/196] added TLV code for EEPROM (not used for now). --- avr/common/eeprom_tlv.asm | 135 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 avr/common/eeprom_tlv.asm diff --git a/avr/common/eeprom_tlv.asm b/avr/common/eeprom_tlv.asm new file mode 100644 index 0000000..23a4709 --- /dev/null +++ b/avr/common/eeprom_tlv.asm @@ -0,0 +1,135 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + +#ifndef AQH_AVR_COMMON_EEPROM_TLV_H +#define AQH_AVR_COMMON_EEPROM_TLV_H + + +; --------------------------------------------------------------------------- +; @routine EepromTlv_AddTlv @global +; +; @param r16 type (must not be 0xff!) +; @param r17 length +; @return CFLAG set if free bytes found, cleared on error +; @return X EEPROM address of data for TLV (behind TLV header) +; @clobbers R16, R20, R21, X (R18) + +EepromTlv_AddTlv: + mov r20, r16 + mov r21, r17 + ldi r16, 0xff + rcall EepromTlv_FindFirst ; (R18) + brcc EepromTlv_AddTlv_end + cpi r17, 0xff + brne EepromTlv_AddTlv_clcEnd + add xl, r21 ; wanted size + adc xh, r21 + sub xh, r21 + rcall Eeprom_CheckAddr ; check end address + brcc EepromTlv_AddTlv_end + sub xl, r21 + sbc xh, r21 + add xh, r21 + sbiw xh:xl, 2 + mov r16, r20 ; type + rcall Eeprom_WriteByte + adiw xh:xl, 1 + mov r16, r21 ; length + rcall Eeprom_WriteByte + adiw xh:xl, 1 + sec + rjmp EepromTlv_AddTlv_end +EepromTlv_AddTlv_clcEnd: + clc +EepromTlv_AddTlv_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine EepromTlv_FindFirst @global +; +; Find first matching TLV +; +; @param r16 TLV type to find +; @return CFLAG set if TLV found, cleared otherwise +; @return r16 type +; @return r17 length +; @return X points to begin of TLV data +; @clobbers r18 + +EepromTlv_FindFirst: + ldi xl, LOW(EEPROM_OFFS_TLV) + ldi xh, HIGH(EEPROM_OFFS_TLV) + rjmp EepromTlv_Find +; @end + + + +; --------------------------------------------------------------------------- +; @routine EepromTlv_Find @global +; +; @param r16 TLV type to find +; @param X EEPROM address to start search +; @return CFLAG set if TLV found, cleared otherwise +; @return r16 type +; @return r17 length +; @return X points to begin of TLV data +; @clobbers r18 + +EepromTlv_Find: + mov r18, r16 +EepromTlv_Find_loop: + rcall EepromTlv_ReadHeader + brcc EepromTlv_Find_notFound + cpi r16, r18 ; the one we wanted? + breq EepromTlv_Find_found + add xl, r17 ; skip TLV data + adc xh, r17 + sub xh, r17 + rjmp EepromTlv_Find_loop +EepromTlv_Find_notFound: + clc + rjmp EepromTlv_Find_end +EepromTlv_Find_found: + sec +EepromTlv_Find_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine EepromTlv_ReadHeader +; +; @param X EEPROM address +; @return CFLAG set if address okay, cleared if out of range +; @return r16 type +; @return r17 length (only data length, can be 0) +; @return X EEPROM address behind TLV header +; @clobbers none + +EepromTlv_ReadHeader: + rcall Eeprom_ReadByteIncr ; read type + brcc EepromTlv_ReadHeader + adiw xh:xl, 1 + push r16 + rcall Eeprom_ReadByteIncr ; read length + mov r17, r16 + pop r16 + brcc EepromTlv_ReadHeader + adiw xh:xl, 1 + sec +EepromTlv_ReadHeader: + ret +; @end + + + From f3020562bf110a7e33b340dc8f8cbdb850a263b5 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 7 Jul 2025 16:06:31 +0200 Subject: [PATCH 084/196] incremented firmware version. --- avr/version.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avr/version.asm b/avr/version.asm index 7991e72..2b7f92c 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 = 11 +.equ FIRMWARE_VERSION_PATCHLEVEL = 12 From e32e8e7c13874d7ebcd3f880b6a61d4d41fca1ee Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 7 Jul 2025 21:43:28 +0200 Subject: [PATCH 085/196] use Eeprom_WriteByteIfChanged --- avr/apps/network/main.asm | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/avr/apps/network/main.asm b/avr/apps/network/main.asm index 5205261..9c64e8c 100644 --- a/avr/apps/network/main.asm +++ b/avr/apps/network/main.asm @@ -271,14 +271,9 @@ appNetworkHandleStateHaveAddress2: std Y+NET_IFACE_OFFS_STATETIMER, r16 ; store new address in IFACE and in EEPROM ldd r16, Y+NET_IFACE_OFFS_ADDRESS - push r15 - in r15, SREG - cli - ldi xl, LOW(EEPROM_OFFS_COMADDR) - ldi xh, HIGH(EEPROM_OFFS_COMADDR) - bigcall Utils_WriteEepromIncr ; write address to EEPROM - out SREG, r15 - pop r15 + ldi xl, LOW(EEPROM_OFFS_COMADDR) + ldi xh, HIGH(EEPROM_OFFS_COMADDR) + bigcall Eeprom_WriteByteIfChanged ; write address to EEPROM (R17) appNetworkHandleStateHaveAddress2_end: ret From 4f497fc41a5bd4a1c5fe44e3a6de36c6448435f3 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 7 Jul 2025 21:43:41 +0200 Subject: [PATCH 086/196] removed unneeded code. --- avr/common/utils_io.asm | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/avr/common/utils_io.asm b/avr/common/utils_io.asm index e9f3a1f..4ce16f5 100644 --- a/avr/common/utils_io.asm +++ b/avr/common/utils_io.asm @@ -7,29 +7,6 @@ ; * Please see toplevel file COPYING of that project for license details. * ; *************************************************************************** -#if 0 -; M_IO_READ DEST, SRC -.macro M_IO_READ -.if @1 < 64 - in @0, @1 -.else - lds @0, @1 -.endif -.endmacro - - - -; M_IO_WRITE DEST, SRC -.macro M_IO_WRITE -.if @0 < 64 - out @0, @1 -.else - sts @0, @1 -.endif -.endmacro - -#endif - ; inr DEST, SRC .macro inr From 245d44c05d172b7ef9b73df1fb25dbdb49b57a4d Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 7 Jul 2025 21:44:40 +0200 Subject: [PATCH 087/196] improved "run" code. --- avr/apps/router/main.asm | 60 +++++++++++++++++----------- avr/devices/all/apps.asm | 12 +++++- avr/devices/all/includes.asm | 2 + avr/devices/all/main.asm | 22 ++++++++-- avr/devices/all/modules.asm | 62 ++++++++++++----------------- avr/modules/uart_hw2/comonuart0.asm | 20 ++++++++-- avr/modules/uart_hw2/comonuart1.asm | 20 ++++++++-- 7 files changed, 126 insertions(+), 72 deletions(-) diff --git a/avr/apps/router/main.asm b/avr/apps/router/main.asm index 76e1d0d..047a126 100644 --- a/avr/apps/router/main.asm +++ b/avr/apps/router/main.asm @@ -64,6 +64,10 @@ AppRouter_Init: ; set interface number for NETDEV1 ldi r16, NETDEV1_IFACENUM sts netInterfaceData2+NET_IFACE_OFFS_IFACENUM, r16 + + ldi r18, NETMSG_CMD_ADDRESS_RANGE + rcall appRouterSendRangeMsgToDev1 + ret ; @end @@ -128,6 +132,7 @@ appRouterHandleMsgAnyDev_handleRebootMsg: ret appRouterHandleMsgAnyDev_handlePingMsg: rcall appRouterHandlePingRequest + clc ret appRouterHandleMsgAnyDev_handleSetValue: rcall NETMSG_ValueRead ; (none) @@ -174,7 +179,7 @@ appRouterHandleDev1Msg: pop xl rjmp appRouterHandleDev1Msg_end appRouterHandleDev1Msg_savedX: - adiw xh:xl, NETMSG_OFFS_CMD ; maybe move ping/reboot handling to all/main.asm? + adiw xh:xl, NETMSG_OFFS_CMD ld r16, X sbiw xh:xl, NETMSG_OFFS_CMD cpi r16, NETMSG_CMD_NEED_ADDRESS @@ -182,6 +187,7 @@ appRouterHandleDev1Msg_savedX: cpi r16, NETMSG_CMD_CLAIM_ADDRESS breq appRouterHandleDev1Msg_handleClaimAddr ; add more here + ldi r16, 0 rjmp appRouterHandleDev1Msg_clcRet appRouterHandleDev1Msg_handleNeedAddr: ldi r18, NETMSG_CMD_ADDRESS_RANGE @@ -255,7 +261,7 @@ appRouterSendAddrMsgToDev1: bigcall NETMSG_Address_Write ; (R16, R17, R18, R19, R20, R21) sbiw xh:xl, 1 pop r16 - rcall appRouterSendMsgToDev1 ; (R16, R17, R18, X, Y) + rcall appRouterSendMsgToDev1 ; (R16, R17, R18, R24, R25, X, Y) appRouterSendAddrMsgToDev1_end: ret ; @end @@ -266,7 +272,8 @@ appRouterSendAddrMsgToDev1_end: ; @routine appRouterSendRangeMsgToDev1 ; ; @param R18 msg code -; @clobbers (R16, R17, R18, R19, R20, R21, X, Y) +; @return CFLAG set if message enqueued, cleared on error +; @clobbers (R16, R17, R18, R19, R20, R21, R24, R25, X, Y) appRouterSendRangeMsgToDev1: bigcall NET_Buffer_Alloc ; (R16, R17, X) @@ -278,7 +285,7 @@ appRouterSendRangeMsgToDev1: bigcall NETMSG_Range_Write ; (R16, R17, R18, R19, R20, R21) sbiw xh:xl, 1 pop r16 - rcall appRouterSendMsgToDev1 ; (R16, R17, R18, X, Y) + rcall appRouterSendMsgToDev1 ; (R16, R17, R18, R24, R25, X, Y) appRouterSendRangeMsgToDev1_end: ret ; @end @@ -290,7 +297,8 @@ appRouterSendRangeMsgToDev1_end: ; ; @param R16 num of allocated buffer ; @param X msg to send (points to start of allocated buffer, e.g. buffer header) -; @clobbers Y (R16, R17, R18, X) +; @return CFLAG set if message enqueued, cleared on error +; @clobbers Y (R16, R17, R18, R24, R25, X) appRouterSendMsgToDev1: ldi yl, LOW(netInterfaceData2) @@ -298,6 +306,8 @@ appRouterSendMsgToDev1: bigcall NET_Interface_AddOutgoingMsgNum ; (R17, R18, X) brcs appRouterSendMsgToDev1_end bigcall NET_Buffer_ReleaseByNum ; (R16, X) + ldi r16, NET_IFACE_OFFS_ERR_NOBUF_LOW + rcall NET_Interface_IncCounter16 ; (R24, R25) clc appRouterSendMsgToDev1_end: ret @@ -354,27 +364,29 @@ appRouterHandlePingRequest_end: ; @routine appRouterCheckRecvdMsg ; ; Read messages from either interface and forward to the other one. +; +; @return CFLAG set if something done, cleared otherwise appRouterCheckRecvdMsg: - rcall NET_PeekNextIncomingMsgNum ; check read queue (bufNum->r16) - brcc appRouterCheckRecvdMsg_end ; no msg, jmp - rcall NET_Buffer_Locate ; (R17) - rcall appRouterHandleRouterMsgWithHdr ; filter out router msgs - brcs appRouterCheckRecvdMsg_removeMsg ; handled by router code, don't forward - ; let system handle incoming messages - adiw xh:xl, 1 - rcall appRouterLetSysHandleMsg - sbiw xh:xl, 1 + rcall NET_PeekNextIncomingMsgNum ; check read queue (bufNum->r16) + brcc appRouterCheckRecvdMsg_end ; no msg, jmp + rcall NET_Buffer_Locate ; (R17) + rcall appRouterHandleRouterMsgWithHdr ; filter out router msgs + brcs appRouterCheckRecvdMsg_removeMsg ; handled by router code, don't forward + ; let system handle incoming messages + adiw xh:xl, 1 + rcall appRouterLetSysHandleMsg + sbiw xh:xl, 1 - ; forward to other interface - ld r17, X - andi r17, (1< Date: Mon, 7 Jul 2025 21:44:54 +0200 Subject: [PATCH 088/196] improved apidoc. --- avr/devices/all/sendvalue.asm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/avr/devices/all/sendvalue.asm b/avr/devices/all/sendvalue.asm index 0a870a6..d97ac38 100644 --- a/avr/devices/all/sendvalue.asm +++ b/avr/devices/all/sendvalue.asm @@ -23,6 +23,7 @@ ; @param R19:R18 value ; @param R21:R20 denom (e.g. 100, meaning value must be divided by 100) ; @param R22 value type +; @return CFLAG on success, cleared on error Main_SendValueReport: push r17 @@ -52,6 +53,7 @@ Main_SendValueReport_end: ; @param R21:R20 denom (e.g. 100, meaning value must be divided by 100) ; @param R23 command ; @param R25:R24 ref msg id +; @return CFLAG on success, cleared on error Main_SendValueResponse: push r17 From 8c397dd6b2c16fa94d2de188b72362bb8a1f9446 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 7 Jul 2025 21:45:19 +0200 Subject: [PATCH 089/196] added missing includes. --- avr/devices/n14/main/main.asm | 1 + avr/devices/n16/main/main.asm | 1 + avr/devices/n19/main/main.asm | 1 + avr/devices/n20/main/main.asm | 1 + avr/devices/n21/main/main.asm | 1 + avr/devices/n22/main/main.asm | 1 + avr/devices/n23/main/main.asm | 1 + avr/devices/n24/main/main.asm | 1 + avr/devices/n25/main/main.asm | 1 + avr/devices/n26/main/main.asm | 1 + avr/devices/n27/main/main.asm | 1 + 11 files changed, 11 insertions(+) diff --git a/avr/devices/n14/main/main.asm b/avr/devices/n14/main/main.asm index 66496a1..79f9d05 100644 --- a/avr/devices/n14/main/main.asm +++ b/avr/devices/n14/main/main.asm @@ -29,6 +29,7 @@ .include "devices/all/defs.asm" .include "common/calls.asm" +.include "common/utils_io.asm" .include "common/utils_wait.asm" diff --git a/avr/devices/n16/main/main.asm b/avr/devices/n16/main/main.asm index 353b3b1..216900d 100644 --- a/avr/devices/n16/main/main.asm +++ b/avr/devices/n16/main/main.asm @@ -36,6 +36,7 @@ .include "devices/all/defs.asm" .include "common/calls.asm" +.include "common/utils_io.asm" .include "common/utils_wait.asm" diff --git a/avr/devices/n19/main/main.asm b/avr/devices/n19/main/main.asm index aed7831..8eecde0 100644 --- a/avr/devices/n19/main/main.asm +++ b/avr/devices/n19/main/main.asm @@ -25,6 +25,7 @@ .include "../defs.asm" .include "devices/all/defs.asm" .include "common/calls.asm" +.include "common/utils_io.asm" .include "common/utils_wait.asm" ; wait macro diff --git a/avr/devices/n20/main/main.asm b/avr/devices/n20/main/main.asm index eb7c165..8889776 100644 --- a/avr/devices/n20/main/main.asm +++ b/avr/devices/n20/main/main.asm @@ -35,6 +35,7 @@ .include "devices/all/defs.asm" .include "common/calls.asm" +.include "common/utils_io.asm" .include "common/utils_wait.asm" diff --git a/avr/devices/n21/main/main.asm b/avr/devices/n21/main/main.asm index c3b00dc..c9e421e 100644 --- a/avr/devices/n21/main/main.asm +++ b/avr/devices/n21/main/main.asm @@ -36,6 +36,7 @@ .include "devices/all/defs.asm" .include "common/calls.asm" +.include "common/utils_io.asm" .include "common/utils_wait.asm" diff --git a/avr/devices/n22/main/main.asm b/avr/devices/n22/main/main.asm index 40d0b99..e240018 100644 --- a/avr/devices/n22/main/main.asm +++ b/avr/devices/n22/main/main.asm @@ -29,6 +29,7 @@ .include "devices/all/defs.asm" .include "common/calls.asm" +.include "common/utils_io.asm" .include "common/utils_wait.asm" diff --git a/avr/devices/n23/main/main.asm b/avr/devices/n23/main/main.asm index f2f9b29..c849b01 100644 --- a/avr/devices/n23/main/main.asm +++ b/avr/devices/n23/main/main.asm @@ -36,6 +36,7 @@ .include "devices/all/defs.asm" .include "common/calls.asm" +.include "common/utils_io.asm" .include "common/utils_wait.asm" diff --git a/avr/devices/n24/main/main.asm b/avr/devices/n24/main/main.asm index 7a1e810..43b24fa 100644 --- a/avr/devices/n24/main/main.asm +++ b/avr/devices/n24/main/main.asm @@ -36,6 +36,7 @@ .include "version.asm" .include "devices/all/defs.asm" .include "common/calls.asm" +.include "common/utils_io.asm" .include "common/utils_wait.asm" diff --git a/avr/devices/n25/main/main.asm b/avr/devices/n25/main/main.asm index 1cb6359..9f4a3e0 100644 --- a/avr/devices/n25/main/main.asm +++ b/avr/devices/n25/main/main.asm @@ -29,6 +29,7 @@ .include "devices/all/defs.asm" .include "common/calls.asm" +.include "common/utils_io.asm" .include "common/utils_wait.asm" diff --git a/avr/devices/n26/main/main.asm b/avr/devices/n26/main/main.asm index 9fd683b..f5bf584 100644 --- a/avr/devices/n26/main/main.asm +++ b/avr/devices/n26/main/main.asm @@ -36,6 +36,7 @@ .include "version.asm" .include "devices/all/defs.asm" .include "common/calls.asm" +.include "common/utils_io.asm" .include "common/utils_wait.asm" diff --git a/avr/devices/n27/main/main.asm b/avr/devices/n27/main/main.asm index 69b0bfe..a0ca13a 100644 --- a/avr/devices/n27/main/main.asm +++ b/avr/devices/n27/main/main.asm @@ -36,6 +36,7 @@ .include "version.asm" .include "devices/all/defs.asm" .include "common/calls.asm" +.include "common/utils_io.asm" .include "common/utils_wait.asm" From b709b7e624c7b23157774cd33cd6db31ffb150cb Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 7 Jul 2025 21:45:36 +0200 Subject: [PATCH 090/196] updated node doc. --- avr/devices/n27/README | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/avr/devices/n27/README b/avr/devices/n27/README index f79221c..b878152 100644 --- a/avr/devices/n27/README +++ b/avr/devices/n27/README @@ -2,7 +2,7 @@ N27 === -- Role: Air quality and climate sensors +- Role: Climate sensors - MCU: AtTiny84 - Connection: RJ45 - Predecessor: N24, N23, N19 @@ -10,6 +10,4 @@ N27 - PIR sensor (AMN31112) - TWI interface - SI7021 temperature and humidity sensor - or - - SGP-30/40 air quality sensor From 04c02b5e33c94649c7f76ad8993d4568bca9cb53 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 7 Jul 2025 21:53:35 +0200 Subject: [PATCH 091/196] fixed a bug. --- avr/common/eeprom-r.asm | 6 ------ 1 file changed, 6 deletions(-) diff --git a/avr/common/eeprom-r.asm b/avr/common/eeprom-r.asm index bd66fa0..85447f6 100644 --- a/avr/common/eeprom-r.asm +++ b/avr/common/eeprom-r.asm @@ -69,12 +69,6 @@ Eeprom_CheckAddr: subi r16, LOW(EEPROMEND) mov r16, xh sbci r16, HIGH(EEPROMEND) - brcc Eeprom_CheckAddr_ok - clc - rjmp Eeprom_CheckAddr_end -Eeprom_CheckAddr_ok: - sec -Eeprom_CheckAddr_end: ret ; @end From f3544f5e930d867b6a8bda62d3d3026e35ba6b00 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 7 Jul 2025 21:53:48 +0200 Subject: [PATCH 092/196] fixed apidoc. --- avr/apps/router/main.asm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/avr/apps/router/main.asm b/avr/apps/router/main.asm index 047a126..05bc1be 100644 --- a/avr/apps/router/main.asm +++ b/avr/apps/router/main.asm @@ -533,7 +533,7 @@ appRouterReadConfFromEeprom: rcall Eeprom_ReadByte brcc appRouterReadConfFromEeprom_end cpi r16, 0xff - breq appRouterReadConfFromEeprom_okay + breq appRouterReadConfFromEeprom_okay ; not set, jmp cpi r16, 2 ; range should at least start at 2 to assign 1 to router brcs appRouterReadConfFromEeprom_okay sts appRouterRangeBegin, r16 @@ -553,6 +553,7 @@ appRouterReadConfFromEeprom_okay: sec appRouterReadConfFromEeprom_end: ret +; @end From 2d84198e54da21e0c9008311d703a08129a293aa Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 7 Jul 2025 21:53:59 +0200 Subject: [PATCH 093/196] incremented version. --- avr/version.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avr/version.asm b/avr/version.asm index 2b7f92c..db303a3 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 = 12 +.equ FIRMWARE_VERSION_PATCHLEVEL = 13 From 3054274da5e38b4555a30ef7b4604d2b9d1fdb27 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Fri, 11 Jul 2025 23:20:53 +0200 Subject: [PATCH 094/196] Fixed stats value list. --- avr/devices/n23/aqua_n23.xml | 16 +++++++++------- avr/devices/n24/aqua_n24.xml | 18 ++++++++++-------- avr/devices/n25/aqua_n25.xml | 18 ++++++++++-------- avr/devices/n26/aqua_n26.xml | 6 ++++-- avr/devices/n27/aqua_n27.xml | 18 ++++++++++-------- avr/devices/r04/aqua_r04.xml | 3 ++- devices/nodes/aqua_n16.xml | 12 +++++++----- devices/nodes/aqua_n17.xml | 10 ++++++---- devices/nodes/aqua_n18.xml | 12 +++++++----- devices/nodes/aqua_n19.xml | 12 +++++++----- devices/nodes/aqua_n20.xml | 14 ++++++++------ devices/nodes/aqua_n22.xml | 18 ++++++++++-------- 12 files changed, 90 insertions(+), 67 deletions(-) diff --git a/avr/devices/n23/aqua_n23.xml b/avr/devices/n23/aqua_n23.xml index a4de1bd..2fd9f35 100644 --- a/avr/devices/n23/aqua_n23.xml +++ b/avr/devices/n23/aqua_n23.xml @@ -5,12 +5,12 @@ 23 - - - - - - + + + + + + @@ -19,8 +19,10 @@ + + - + diff --git a/avr/devices/n24/aqua_n24.xml b/avr/devices/n24/aqua_n24.xml index 207c53e..6cee19c 100644 --- a/avr/devices/n24/aqua_n24.xml +++ b/avr/devices/n24/aqua_n24.xml @@ -5,13 +5,13 @@ 24 - - - - - - - + + + + + + + @@ -20,8 +20,10 @@ + + - + diff --git a/avr/devices/n25/aqua_n25.xml b/avr/devices/n25/aqua_n25.xml index 5eea16c..470ff46 100644 --- a/avr/devices/n25/aqua_n25.xml +++ b/avr/devices/n25/aqua_n25.xml @@ -5,15 +5,15 @@ 25 - + - - + + - - - - + + + + @@ -22,8 +22,10 @@ + + - + diff --git a/avr/devices/n26/aqua_n26.xml b/avr/devices/n26/aqua_n26.xml index b7a38e2..33515b5 100644 --- a/avr/devices/n26/aqua_n26.xml +++ b/avr/devices/n26/aqua_n26.xml @@ -5,8 +5,8 @@ 26 - - + + @@ -15,6 +15,8 @@ + + diff --git a/avr/devices/n27/aqua_n27.xml b/avr/devices/n27/aqua_n27.xml index 9238a60..26b7ef5 100644 --- a/avr/devices/n27/aqua_n27.xml +++ b/avr/devices/n27/aqua_n27.xml @@ -5,13 +5,13 @@ 27 - - - - - - - + + + + + + + @@ -20,8 +20,10 @@ + + - + diff --git a/avr/devices/r04/aqua_r04.xml b/avr/devices/r04/aqua_r04.xml index 865441c..a9b72ef 100644 --- a/avr/devices/r04/aqua_r04.xml +++ b/avr/devices/r04/aqua_r04.xml @@ -27,7 +27,8 @@ - + + diff --git a/devices/nodes/aqua_n16.xml b/devices/nodes/aqua_n16.xml index c14dde5..4f18f70 100644 --- a/devices/nodes/aqua_n16.xml +++ b/devices/nodes/aqua_n16.xml @@ -5,10 +5,10 @@ 16 - - - - + + + + @@ -17,8 +17,10 @@ + + - + diff --git a/devices/nodes/aqua_n17.xml b/devices/nodes/aqua_n17.xml index afef95b..ef7a596 100644 --- a/devices/nodes/aqua_n17.xml +++ b/devices/nodes/aqua_n17.xml @@ -5,9 +5,9 @@ 17 - - - + + + @@ -16,8 +16,10 @@ + + - + diff --git a/devices/nodes/aqua_n18.xml b/devices/nodes/aqua_n18.xml index ad1c691..46e4212 100644 --- a/devices/nodes/aqua_n18.xml +++ b/devices/nodes/aqua_n18.xml @@ -5,10 +5,10 @@ 18 - - - - + + + + @@ -17,8 +17,10 @@ + + - + diff --git a/devices/nodes/aqua_n19.xml b/devices/nodes/aqua_n19.xml index 22b6104..78a306d 100644 --- a/devices/nodes/aqua_n19.xml +++ b/devices/nodes/aqua_n19.xml @@ -5,10 +5,10 @@ 19 - - - - + + + + @@ -17,8 +17,10 @@ + + - + diff --git a/devices/nodes/aqua_n20.xml b/devices/nodes/aqua_n20.xml index 559dc43..e465cbe 100644 --- a/devices/nodes/aqua_n20.xml +++ b/devices/nodes/aqua_n20.xml @@ -5,11 +5,11 @@ 20 - - - - - + + + + + @@ -18,8 +18,10 @@ + + - + diff --git a/devices/nodes/aqua_n22.xml b/devices/nodes/aqua_n22.xml index 8749b6a..7e76bf1 100644 --- a/devices/nodes/aqua_n22.xml +++ b/devices/nodes/aqua_n22.xml @@ -5,15 +5,15 @@ 22 - + - - + + - - - - + + + + @@ -22,8 +22,10 @@ + + - + From 3283a38981fa5dbd0d9726851ca9aaac75c7f9e0 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Fri, 11 Jul 2025 23:22:09 +0200 Subject: [PATCH 095/196] Release 0.9.12. --- 0BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/0BUILD b/0BUILD index fe14b3a..6876dd2 100644 --- a/0BUILD +++ b/0BUILD @@ -2,7 +2,7 @@ - + $(project_name) $(project_vmajor).$(project_vminor).$(project_vpatchlevel) From c1ea4212f2abd78dd967ad229193b2cfc5497ebf Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Fri, 11 Jul 2025 23:24:26 +0200 Subject: [PATCH 096/196] Moved NET_BUFFERS_SIZE to network/defs.asm - Changing this value requires changing the routine NET_Buffer_Locate so its best to keep both in one module. - Redefining it in the individual devices doesn't change the code in NET_Buffer_Locate --- avr/devices/n14/main/main.asm | 1 - avr/devices/n16/main/main.asm | 1 - avr/devices/n19/main/main.asm | 1 - avr/devices/n20/main/main.asm | 1 - avr/devices/n21/main/main.asm | 1 - avr/devices/n22/main/main.asm | 1 - avr/devices/n23/main/main.asm | 1 - avr/devices/n24/main/main.asm | 1 - avr/devices/n25/main/main.asm | 1 - avr/devices/n26/main/main.asm | 1 - avr/devices/n27/main/main.asm | 1 - avr/devices/r04/main/main.asm | 1 - avr/devices/r04/test/main.asm | 1 - avr/devices/r05/main/main.asm | 1 - avr/devices/r05/test/main.asm | 1 - avr/devices/t03/main/main.asm | 7 +++---- avr/modules/network/defs.asm | 5 ++++- 17 files changed, 7 insertions(+), 20 deletions(-) diff --git a/avr/devices/n14/main/main.asm b/avr/devices/n14/main/main.asm index 79f9d05..425a941 100644 --- a/avr/devices/n14/main/main.asm +++ b/avr/devices/n14/main/main.asm @@ -41,7 +41,6 @@ ; generic .equ NET_BUFFERS_NUM = 6 -.equ NET_BUFFERS_SIZE = 32 diff --git a/avr/devices/n16/main/main.asm b/avr/devices/n16/main/main.asm index 216900d..461aeb2 100644 --- a/avr/devices/n16/main/main.asm +++ b/avr/devices/n16/main/main.asm @@ -48,7 +48,6 @@ ; generic .equ NET_BUFFERS_NUM = 6 -.equ NET_BUFFERS_SIZE = 32 diff --git a/avr/devices/n19/main/main.asm b/avr/devices/n19/main/main.asm index 8eecde0..146038d 100644 --- a/avr/devices/n19/main/main.asm +++ b/avr/devices/n19/main/main.asm @@ -35,7 +35,6 @@ .equ NET_BUFFERS_NUM = 6 -.equ NET_BUFFERS_SIZE = 32 ; --------------------------------------------------------------------------- diff --git a/avr/devices/n20/main/main.asm b/avr/devices/n20/main/main.asm index 8889776..fadb333 100644 --- a/avr/devices/n20/main/main.asm +++ b/avr/devices/n20/main/main.asm @@ -47,7 +47,6 @@ ; generic .equ NET_BUFFERS_NUM = 4 -.equ NET_BUFFERS_SIZE = 32 diff --git a/avr/devices/n21/main/main.asm b/avr/devices/n21/main/main.asm index c9e421e..6fa58e2 100644 --- a/avr/devices/n21/main/main.asm +++ b/avr/devices/n21/main/main.asm @@ -48,7 +48,6 @@ ; generic .equ NET_BUFFERS_NUM = 6 -.equ NET_BUFFERS_SIZE = 32 diff --git a/avr/devices/n22/main/main.asm b/avr/devices/n22/main/main.asm index e240018..91c25da 100644 --- a/avr/devices/n22/main/main.asm +++ b/avr/devices/n22/main/main.asm @@ -41,7 +41,6 @@ ; generic .equ NET_BUFFERS_NUM = 6 -.equ NET_BUFFERS_SIZE = 32 diff --git a/avr/devices/n23/main/main.asm b/avr/devices/n23/main/main.asm index c849b01..895bb69 100644 --- a/avr/devices/n23/main/main.asm +++ b/avr/devices/n23/main/main.asm @@ -48,7 +48,6 @@ ; generic .equ NET_BUFFERS_NUM = 6 -.equ NET_BUFFERS_SIZE = 32 .equ PROGRAM_SENSOR_INTERVAL_SECS = 60 .equ PROGRAM_STATS_INTERVAL_MINS = 10 diff --git a/avr/devices/n24/main/main.asm b/avr/devices/n24/main/main.asm index 43b24fa..b11d874 100644 --- a/avr/devices/n24/main/main.asm +++ b/avr/devices/n24/main/main.asm @@ -48,7 +48,6 @@ ; generic .equ NET_BUFFERS_NUM = 6 -.equ NET_BUFFERS_SIZE = 32 .equ PROGRAM_SENSOR_INTERVAL_SECS = 60 .equ PROGRAM_STATS_INTERVAL_MINS = 10 diff --git a/avr/devices/n25/main/main.asm b/avr/devices/n25/main/main.asm index 9f4a3e0..3f52ad5 100644 --- a/avr/devices/n25/main/main.asm +++ b/avr/devices/n25/main/main.asm @@ -41,7 +41,6 @@ ; generic .equ NET_BUFFERS_NUM = 6 -.equ NET_BUFFERS_SIZE = 32 diff --git a/avr/devices/n26/main/main.asm b/avr/devices/n26/main/main.asm index f5bf584..bec6550 100644 --- a/avr/devices/n26/main/main.asm +++ b/avr/devices/n26/main/main.asm @@ -48,7 +48,6 @@ ; generic .equ NET_BUFFERS_NUM = 6 -.equ NET_BUFFERS_SIZE = 32 .equ PROGRAM_SENSOR_INTERVAL_SECS = 60 .equ PROGRAM_STATS_INTERVAL_MINS = 10 diff --git a/avr/devices/n27/main/main.asm b/avr/devices/n27/main/main.asm index a0ca13a..e340261 100644 --- a/avr/devices/n27/main/main.asm +++ b/avr/devices/n27/main/main.asm @@ -48,7 +48,6 @@ ; generic .equ NET_BUFFERS_NUM = 6 -.equ NET_BUFFERS_SIZE = 32 .equ PROGRAM_SENSOR_INTERVAL_SECS = 60 .equ PROGRAM_STATS_INTERVAL_MINS = 10 diff --git a/avr/devices/r04/main/main.asm b/avr/devices/r04/main/main.asm index 71f8590..2aeb170 100644 --- a/avr/devices/r04/main/main.asm +++ b/avr/devices/r04/main/main.asm @@ -85,7 +85,6 @@ .equ NET_BUFFERS_NUM = 9 -.equ NET_BUFFERS_SIZE = 32 .equ UART_HW_MSGNUMINBUF_SIZE = 8 .equ UART_HW_MSGNUMOUTBUF_SIZE = 8 diff --git a/avr/devices/r04/test/main.asm b/avr/devices/r04/test/main.asm index 456d6e0..795a5e8 100644 --- a/avr/devices/r04/test/main.asm +++ b/avr/devices/r04/test/main.asm @@ -85,7 +85,6 @@ .equ NET_BUFFERS_NUM = 8 -.equ NET_BUFFERS_SIZE = 32 .equ UART_HW_MSGNUMINBUF_SIZE = 8 .equ UART_HW_MSGNUMOUTBUF_SIZE = 8 diff --git a/avr/devices/r05/main/main.asm b/avr/devices/r05/main/main.asm index b036a5e..ebf87b3 100644 --- a/avr/devices/r05/main/main.asm +++ b/avr/devices/r05/main/main.asm @@ -76,7 +76,6 @@ .equ NET_BUFFERS_NUM = 8 -.equ NET_BUFFERS_SIZE = 32 .equ UART_HW_MSGNUMINBUF_SIZE = 8 .equ UART_HW_MSGNUMOUTBUF_SIZE = 8 diff --git a/avr/devices/r05/test/main.asm b/avr/devices/r05/test/main.asm index fe106ee..6abe2ca 100644 --- a/avr/devices/r05/test/main.asm +++ b/avr/devices/r05/test/main.asm @@ -85,7 +85,6 @@ .equ NET_BUFFERS_NUM = 8 -.equ NET_BUFFERS_SIZE = 32 .equ UART_HW_MSGNUMINBUF_SIZE = 8 .equ UART_HW_MSGNUMOUTBUF_SIZE = 8 diff --git a/avr/devices/t03/main/main.asm b/avr/devices/t03/main/main.asm index bda6094..8a1799b 100644 --- a/avr/devices/t03/main/main.asm +++ b/avr/devices/t03/main/main.asm @@ -82,7 +82,6 @@ .equ NET_BUFFERS_NUM = 10 -.equ NET_BUFFERS_SIZE = 32 .equ UART_HW_MSGNUMINBUF_SIZE = 8 .equ UART_HW_MSGNUMOUTBUF_SIZE = 8 @@ -110,7 +109,7 @@ rjmp BOOTLOADER_ADDR ; 1: RESET Reset vector use this for flashed system reti ; 2: INT0 External Interrupt Request 0 - rjmp ComOnUart0AttnChangeIsr ; 3: PCINT0 Pin Change Interrupt 0 + rjmp ComOnUart0_AttnChangeIsr ; 3: PCINT0 Pin Change Interrupt 0 reti ; 4: PCINT1 Pin Change Interrupt 1 reti ; 5: WDT Watchdog Time-out reti ; 6: TIM1_CAPT Timer/Counter1 Capture Event @@ -131,8 +130,8 @@ reti ; 21: SPI SPI Serial Transfer Complete reti ; 22: USART0_RXS USART0 Rx Start rjmp ComOnUart0_RxCharIsr ; 23: USART0_RXC USART0 Rx Complete - rjmp ComOnUart0_TxUdreIsr ; 24: USART0_DRE USART0 Data Register Empty - rjmp ComOnUart0_TxCharIsr ; 25: USART0_TXC USART0 Tx Complete + reti ; 24: USART0_DRE USART0 Data Register Empty + reti ; 25: USART0_TXC USART0 Tx Complete reti ; 26: USART1_RXS USART1 Rx Start rjmp TtyOnUart1_RxCharIsr ; 27: USART1_RXC USART1 Rx Complete rjmp TtyOnUart1_TxUdreIsr ; 28: USART1_DRE USART1 Data Register Empty diff --git a/avr/modules/network/defs.asm b/avr/modules/network/defs.asm index e805442..f048c80 100644 --- a/avr/modules/network/defs.asm +++ b/avr/modules/network/defs.asm @@ -9,7 +9,10 @@ ; defs -.equ NET_MSGNUMINBUF_SIZE = 4 ; max buffer nums in ringbuffer (global incoming) + +.equ NET_BUFFERS_SIZE = 32 ; CAVE: need to adapt routine NET_Buffer_Locate when changing this value!! + +.equ NET_MSGNUMINBUF_SIZE = 6 ; max buffer nums in ringbuffer (global incoming) .equ NET_IFACE_OUTMSGBUF_SIZE = 4 ; max buffer nums in ringbuffer (per interface outbound) From 003f53b0b7e8fe8ffa99d7bb4d70f8f21ee18101 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Fri, 11 Jul 2025 23:25:19 +0200 Subject: [PATCH 097/196] added READMEs --- avr/devices/r04/README | 13 +++++++++++++ avr/devices/r05/README | 13 +++++++++++++ avr/devices/t03/README | 13 +++++++++++++ 3 files changed, 39 insertions(+) diff --git a/avr/devices/r04/README b/avr/devices/r04/README index e69de29..388a291 100644 --- a/avr/devices/r04/README +++ b/avr/devices/r04/README @@ -0,0 +1,13 @@ + +R04 +=== + +- Role: Router +- MCU: AtTiny841 +- Connection: RJ45 +- Predecessor: none +- UART: comonuart0 (uart_hw2), comonuart1 (uart_hw2) +- Periphery: + - OWI interface + - DS18B20 temperature sensor + diff --git a/avr/devices/r05/README b/avr/devices/r05/README index e69de29..004d17a 100644 --- a/avr/devices/r05/README +++ b/avr/devices/r05/README @@ -0,0 +1,13 @@ + +R05 +=== + +- Role: Router +- MCU: AtTiny841 +- Connection: RJ45 +- Predecessor: R04 +- UART: comonuart0 (uart_hw2), comonuart1 (uart_hw2) +- Periphery: + - OWI interface + - DS18B20 temperature sensor + diff --git a/avr/devices/t03/README b/avr/devices/t03/README index e69de29..58c57bc 100644 --- a/avr/devices/t03/README +++ b/avr/devices/t03/README @@ -0,0 +1,13 @@ + +T03 +=== + +- Role: COM-PC-Interface +- MCU: AtTiny841 +- Connection: RJ45 +- Predecessor: none +- UART: comonuart0 (uart_hw2), ttyonuart1 (uart_hw) +- Periphery: + - OWI interface + - DS18B20 temperature sensor + From 3cd23d5f6014d618916ad8f6009ef363fa611190 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 12 Jul 2025 00:21:47 +0200 Subject: [PATCH 098/196] reduce size of net buffers from 32 to 28. allows us to use 10 buffers in R05. --- avr/devices/r05/main/main.asm | 5 +---- avr/modules/network/buffer.asm | 23 +++++++++++++++++++++++ avr/modules/network/defs.asm | 2 +- avr/modules/uart_hw2/comonuart0.asm | 9 ++++++--- avr/modules/uart_hw2/comonuart1.asm | 8 +++++--- avr/modules/uart_hw2/defs.asm | 3 ++- 6 files changed, 38 insertions(+), 12 deletions(-) diff --git a/avr/devices/r05/main/main.asm b/avr/devices/r05/main/main.asm index ebf87b3..b22236f 100644 --- a/avr/devices/r05/main/main.asm +++ b/avr/devices/r05/main/main.asm @@ -75,10 +75,7 @@ #define APPS_ROUTER -.equ NET_BUFFERS_NUM = 8 - -.equ UART_HW_MSGNUMINBUF_SIZE = 8 -.equ UART_HW_MSGNUMOUTBUF_SIZE = 8 +.equ NET_BUFFERS_NUM = 10 diff --git a/avr/modules/network/buffer.asm b/avr/modules/network/buffer.asm index 92732e4..5404450 100644 --- a/avr/modules/network/buffer.asm +++ b/avr/modules/network/buffer.asm @@ -124,6 +124,8 @@ NET_Buffer_ReleaseByNum_end: NET_Buffer_Locate: cpi r16, NET_BUFFERS_NUM brcc NET_Buffer_Locate_end ; out of range + +.if NET_BUFFERS_SIZE == 32 mov xh, r16 ; * 256 clr xl lsr xh ; *128 @@ -132,10 +134,31 @@ NET_Buffer_Locate: ror xl lsr xh ; *32 ror xl +.elif NET_BUFFERS_SIZE == 28 + clr r17 + mov xl, r16 ; * 256 + clr xh + lsl xl ; * 2 + rol xh + add xl, r16 ; * 3 + adc xh, r17 + lsl xl ; * 6 + rol xh + add xl, r16 ; * 7 + adc xh, r17 + lsl xl ; * 14 + rol xh + lsl xl ; * 28 + rol xh +.else +.error "Unhandled buffer size" +.endif + ldi r17, LOW(netBuffers) add xl, r17 ldi r17, HIGH(netBuffers) adc xh, r17 + sec NET_Buffer_Locate_end: ret diff --git a/avr/modules/network/defs.asm b/avr/modules/network/defs.asm index f048c80..9e68b37 100644 --- a/avr/modules/network/defs.asm +++ b/avr/modules/network/defs.asm @@ -10,7 +10,7 @@ ; defs -.equ NET_BUFFERS_SIZE = 32 ; CAVE: need to adapt routine NET_Buffer_Locate when changing this value!! +.equ NET_BUFFERS_SIZE = 28 ; CAVE: need to adapt routine NET_Buffer_Locate when changing this value!! .equ NET_MSGNUMINBUF_SIZE = 6 ; max buffer nums in ringbuffer (global incoming) diff --git a/avr/modules/uart_hw2/comonuart0.asm b/avr/modules/uart_hw2/comonuart0.asm index 60f718a..46c86da 100644 --- a/avr/modules/uart_hw2/comonuart0.asm +++ b/avr/modules/uart_hw2/comonuart0.asm @@ -132,7 +132,7 @@ comOnUart0StartReading: adiw xh:xl, UART_HW2_IFACE_OFFS_BUFFER std Y+UART_HW2_IFACE_OFFS_BUFPOS_LOW, xl std Y+UART_HW2_IFACE_OFFS_BUFPOS_HIGH, xh - ldi r16, UART_HW2_BUFFER_SIZE-1 + ldi r16, UART_HW2_BUFFER_SIZE std Y+UART_HW2_IFACE_OFFS_BUFLEFT, r16 clr r16 std Y+UART_HW2_IFACE_OFFS_BUFUSED, r16 @@ -650,8 +650,11 @@ comOnUart0RxCharIsr: brne comOnUart0RxCharIsr_end ; determine msg size inc r16 ; last byte was payload length, add byte for crc - cp r16, r17 ; compare remaining length against remaining space - brcc comOnUart0RxCharIsr_emsgsize ; msg too long +; cp r16, r17 ; compare remaining length against remaining space +; brcc comOnUart0RxCharIsr_emsgsize ; msg too long + cp r17, r16 ; compare remaining length against remaining space + brcs comOnUart0RxCharIsr_emsgsize ; msg too long + std Y+UART_HW2_IFACE_OFFS_BUFLEFT, r16 ; set new number of bytes left tst r16 brne comOnUart0RxCharIsr_end ; jmp if still bytes left to receive diff --git a/avr/modules/uart_hw2/comonuart1.asm b/avr/modules/uart_hw2/comonuart1.asm index 6f87faf..6449877 100644 --- a/avr/modules/uart_hw2/comonuart1.asm +++ b/avr/modules/uart_hw2/comonuart1.asm @@ -132,7 +132,7 @@ comOnUart1StartReading: adiw xh:xl, UART_HW2_IFACE_OFFS_BUFFER std Y+UART_HW2_IFACE_OFFS_BUFPOS_LOW, xl std Y+UART_HW2_IFACE_OFFS_BUFPOS_HIGH, xh - ldi r16, UART_HW2_BUFFER_SIZE-1 + ldi r16, UART_HW2_BUFFER_SIZE std Y+UART_HW2_IFACE_OFFS_BUFLEFT, r16 clr r16 std Y+UART_HW2_IFACE_OFFS_BUFUSED, r16 @@ -650,8 +650,10 @@ comOnUart1RxCharIsr: brne comOnUart1RxCharIsr_end ; determine msg size inc r16 ; last byte was payload length, add byte for crc - cp r16, r17 ; compare remaining length against remaining space - brcc comOnUart1RxCharIsr_emsgsize ; msg too long +; cp r16, r17 ; compare remaining length against remaining space +; brcc comOnUart1RxCharIsr_emsgsize ; msg too long + cp r17, r16 ; compare remaining length against remaining space + brcs comOnUart1RxCharIsr_emsgsize ; msg too long std Y+UART_HW2_IFACE_OFFS_BUFLEFT, r16 ; set new number of bytes left tst r16 brne comOnUart1RxCharIsr_end ; jmp if still bytes left to receive diff --git a/avr/modules/uart_hw2/defs.asm b/avr/modules/uart_hw2/defs.asm index a50a9f6..8bb10f2 100644 --- a/avr/modules/uart_hw2/defs.asm +++ b/avr/modules/uart_hw2/defs.asm @@ -11,7 +11,8 @@ #define AVR_MODULES_UART_HW2_DEFS_H -.equ UART_HW2_BUFFER_SIZE = NET_BUFFERS_SIZE +;.equ UART_HW2_BUFFER_SIZE = NET_BUFFERS_SIZE +.equ UART_HW2_BUFFER_SIZE = NET_BUFFERS_SIZE-1 .equ UART_HW2_MODE_IDLE = 0 From 68aa3beab86a08423e92211427f446460dd8e7a2 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 12 Jul 2025 00:21:59 +0200 Subject: [PATCH 099/196] incremented firmware version. --- avr/version.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avr/version.asm b/avr/version.asm index db303a3..87b7a16 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 = 13 +.equ FIRMWARE_VERSION_PATCHLEVEL = 14 From fa9419034554b698f41fee2e376f0d2b0c007e11 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 12 Jul 2025 00:22:18 +0200 Subject: [PATCH 100/196] fixed message description for FLASH_DATA. --- avr/modules/comproto/MESSAGES | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/avr/modules/comproto/MESSAGES b/avr/modules/comproto/MESSAGES index 1f1b0dd..fe9f3e6 100644 --- a/avr/modules/comproto/MESSAGES +++ b/avr/modules/comproto/MESSAGES @@ -306,10 +306,10 @@ Offset Length Meaning 2 1 command code 3 1 source address --------------------------------------------------------- - 4 2 msg id/ref msg id - 6 n data bytes + 4 4 ROM address + 8 n data bytes --------------------------------------------------------- - 6+n 1 CRC8 byte + 8+n 1 CRC8 byte From 83225c453db501e3ca408eb8448c00ee3e4b9ef6 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 12 Jul 2025 20:07:33 +0200 Subject: [PATCH 101/196] Use uid to determine initial wait time after re-enum request. --- avr/apps/network/main.asm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/avr/apps/network/main.asm b/avr/apps/network/main.asm index 9c64e8c..09ef659 100644 --- a/avr/apps/network/main.asm +++ b/avr/apps/network/main.asm @@ -210,12 +210,19 @@ appNetworkHandlePingRequest_end: appNetworkHandleReeunumRequest: - rcall NETMSG_Range_Read + push xl + push xh + rcall Utils_ReadUid ; r21:r20:r19:r18=uid (r16, X) + pop xh + pop xl + rcall NETMSG_Range_Read ; r20=range begin, r21=range end (none) ldi r16, APP_NETWORK_STATE_INITIALWAIT std Y+NET_IFACE_OFFS_STATUS, r16 - ldd r16, Y+NET_IFACE_OFFS_ADDRESS ; use current address as timer - std Y+NET_IFACE_OFFS_STATETIMER, r16 - ldi r16, APP_NETWORK_ADDRESS_RANGE_BEGIN + cpi r18, 20 + brcc appNetworkHandleReeunumRequest_setWait + subi r18, -20 ; minimum 2s +appNetworkHandleReeunumRequest_setWait: + std Y+NET_IFACE_OFFS_STATETIMER, r18 ; use lowest byte of uid as wat time std Y+NET_IFACE_OFFS_RANGE_BEGIN, r20 std Y+NET_IFACE_OFFS_RANGE_END, r21 ret From a06d24534531cee20d9f31b165cd76c612568506 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 12 Jul 2025 20:08:30 +0200 Subject: [PATCH 102/196] r05: disable OWI and ds18b20 modules (no time to handle those), increase buffers --- avr/devices/r05/main/main.asm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/avr/devices/r05/main/main.asm b/avr/devices/r05/main/main.asm index b22236f..01ed840 100644 --- a/avr/devices/r05/main/main.asm +++ b/avr/devices/r05/main/main.asm @@ -64,8 +64,8 @@ #define MODULES_LCD #define LCD_MINIMAL_FONT #else ; decrease code when using display - #define MODULES_OWI_MASTER - #define MODULES_DS18B20 +; #define MODULES_OWI_MASTER +; #define MODULES_DS18B20 #define APPS_STATS #endif #define MODULES_NETWORK @@ -75,7 +75,7 @@ #define APPS_ROUTER -.equ NET_BUFFERS_NUM = 10 +.equ NET_BUFFERS_NUM = 11 From 349b4a929ac53b33f8eda571f66729e2a738c3c0 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 12 Jul 2025 20:08:54 +0200 Subject: [PATCH 103/196] use in instead of inr (SREG is always inside normal io space). --- avr/modules/uart_hw2/comonuart1.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/avr/modules/uart_hw2/comonuart1.asm b/avr/modules/uart_hw2/comonuart1.asm index 6449877..b00141a 100644 --- a/avr/modules/uart_hw2/comonuart1.asm +++ b/avr/modules/uart_hw2/comonuart1.asm @@ -213,7 +213,7 @@ comOnUart1ModeJumpTable: comOnUart1RunIdle: push r15 - inr r15, SREG + in r15, SREG cli ; look for outbound message rcall NET_Interface_PeekNextOutgoingMsgNum ; r16=msgNum @@ -244,7 +244,7 @@ comOnUart1RunIdle_haveMsg: brcc comOnUart1RunIdle_end push r15 - inr r15, SREG + in r15, SREG cli rcall NET_Interface_GetNextOutgoingMsgNum ; take current msg off the queue rcall NET_Buffer_ReleaseByNum ; (R16, X) From 357ffe4e17e9e2cefb26f483375883675c01c798 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 12 Jul 2025 20:09:40 +0200 Subject: [PATCH 104/196] comonuartX: handle multiple messages in one run. still there are NOBUF errors... --- avr/devices/all/modules.asm | 54 ++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/avr/devices/all/modules.asm b/avr/devices/all/modules.asm index 5cdbcb0..14f405d 100644 --- a/avr/devices/all/modules.asm +++ b/avr/devices/all/modules.asm @@ -187,25 +187,10 @@ runModules: pop r16 #endif -#ifdef MODULES_COMONUART0 push r16 - bigcall ComOnUart0_Run + rcall runComModules pop r16 sbci r16, 0 -#endif - -#ifdef MODULES_COMONUART1 - push r16 - bigcall ComOnUart1_Run - pop r16 - sbci r16, 0 -#endif - -#ifdef MODULES_STATS - push r16 - bigcall Stats_Run - pop r16 -#endif ; add more modules here @@ -218,6 +203,43 @@ runModules_end: ret +; run until every module idle + +runComModules: + clr r17 +runComModules_loop: + push r17 + clr r16 +#ifdef MODULES_COMONUART0 + push r16 + bigcall ComOnUart0_Run + pop r16 + sbci r16, 0 +#endif + +#ifdef MODULES_COMONUART1 + push r16 + bigcall ComOnUart1_Run + pop r16 + sbci r16, 0 +#endif + pop r17 + ; check for repeat request + tst r16 + clc + breq runComModules_loopEnd + inc r17 + cpi r17, 2 + brne runComModules_loop +runComModules_loopEnd: + tst r17 + clc + breq runComModules_end + sec +runComModules_end: + ret + + mainModulesOnPacketReceived: From 535a695c5028f2fc9ffbc085c1da9be152041e1e Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 12 Jul 2025 20:16:34 +0200 Subject: [PATCH 105/196] limit number of loops inside main_runLoop. --- avr/devices/all/main.asm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/avr/devices/all/main.asm b/avr/devices/all/main.asm index a2c94e1..3d29c32 100644 --- a/avr/devices/all/main.asm +++ b/avr/devices/all/main.asm @@ -57,7 +57,9 @@ main_loop: bigcall systemSleep ; system-dependant ; run loop as long as some run function returns with CFLAG set + clr r17 main_runLoop: + push r17 clr r16 push r16 bigcall runModules @@ -72,10 +74,16 @@ main_runLoop: push r16 bigcall onEveryLoop ; call into main app pop r16 + pop r17 + + tst r16 + breq main_endRunLoop + inc r17 + cpi r17, 2 + brcc main_endRunLoop + brne main_runLoop +main_endRunLoop: - tst r16 - brne main_runLoop - #ifdef MODULES_NETWORK #ifndef MAIN_WITHOUT_MSG_HANDLING rcall mainHandleMessages From bdd710fc5cb9728832005f457a56aeb5499887d4 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 19 Jul 2025 09:42:02 +0200 Subject: [PATCH 106/196] avr: started working on new SPI-like COM protocol. use a clock and a data line to introduce synchronisation into the protocol to be able to work with the wide range of mcu speeds (no need for exact timing, no need for exact calibration). --- avr/devices/all/includes.asm | 15 + avr/devices/all/main.asm | 13 + avr/devices/all/modules.asm | 27 ++ avr/modules/com2w/com2w.asm | 664 +++++++++++++++++++++++++++++++++++ avr/modules/com2w/com2w1.asm | 638 +++++++++++++++++++++++++++++++++ avr/modules/com2w/common.asm | 244 +++++++++++++ avr/modules/com2w/defs.asm | 74 ++++ 7 files changed, 1675 insertions(+) create mode 100644 avr/modules/com2w/com2w.asm create mode 100644 avr/modules/com2w/com2w1.asm create mode 100644 avr/modules/com2w/common.asm create mode 100644 avr/modules/com2w/defs.asm diff --git a/avr/devices/all/includes.asm b/avr/devices/all/includes.asm index 220c03e..41039f9 100644 --- a/avr/devices/all/includes.asm +++ b/avr/devices/all/includes.asm @@ -96,6 +96,21 @@ #endif + +#ifdef MODULES_COM2W +.include "modules/com2w/defs.asm" +.include "modules/com2w/com2w.asm" +#endif + + + +#ifdef MODULES_COM2W1 +.include "modules/com2w/defs.asm" +.include "modules/com2w/common.asm" +.include "modules/com2w/com2w1.asm" +#endif + + #ifdef MODULES_CLOCK .include "modules/clock/main.asm" #endif diff --git a/avr/devices/all/main.asm b/avr/devices/all/main.asm index 3d29c32..8c520a0 100644 --- a/avr/devices/all/main.asm +++ b/avr/devices/all/main.asm @@ -135,6 +135,19 @@ onSystemTimerTick: bigcall ComOnUart1_Periodically #endif +#ifdef MODULES_COM2W + bigcall COM2W_Every100ms +#endif + + +#ifdef MODULES_COM2W0 + bigcall COM2W0_Periodically +#endif + +#ifdef MODULES_COM2W1 + bigcall COM2W1_Periodically +#endif + #ifdef MODULES_TCRT1000 bigcall TCRT1K_Every100ms #endif diff --git a/avr/devices/all/modules.asm b/avr/devices/all/modules.asm index 14f405d..b5a3e19 100644 --- a/avr/devices/all/modules.asm +++ b/avr/devices/all/modules.asm @@ -81,6 +81,18 @@ initModules: bigcall ComOnUart1_Init #endif +#ifdef MODULES_COM2W + bigcall COM2W_Init +#endif + +#ifdef MODULES_COM2W0 + bigcall COM2W0_Init +#endif + +#ifdef MODULES_COM2W1 + bigcall COM2W1_Init +#endif + #ifdef MODULES_MOTION bigcall Motion_Init #endif @@ -223,6 +235,21 @@ runComModules_loop: pop r16 sbci r16, 0 #endif + +#ifdef MODULES_COM2W0 + push r16 + bigcall COM2W0_Run + pop r16 + sbci r16, 0 +#endif + +#ifdef MODULES_COM2W1 + push r16 + bigcall COM2W1_Run + pop r16 + sbci r16, 0 +#endif + pop r17 ; check for repeat request tst r16 diff --git a/avr/modules/com2w/com2w.asm b/avr/modules/com2w/com2w.asm new file mode 100644 index 0000000..00c38b4 --- /dev/null +++ b/avr/modules/com2w/com2w.asm @@ -0,0 +1,664 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + +#ifndef AVR_MODULES_COM2W_COM2W_H +#define AVR_MODULES_COM2W_COM2W_H + + +.dseg + +com2w_iface: .byte COM2W_IFACE_SIZE + + + +.cseg + + + +; --------------------------------------------------------------------------- +; @routine COM2W_Init +; +; @clobbers + +COM2W_Init: + ldi yl, LOW(com2w_iface) + ldi yh, HIGH(com2w_iface) + rcall NET_Interface_Init ; (R16, R17, X) + + ; setup CLK line (as input, disable internal pull-up resistor) + cbi COM_CLK_DDR, COM_CLK_PIN ; set CLK as input +.ifdef COM_CLK_PUE + inr r16, COM_CLK_PUE + cbr r16, (1< Date: Sat, 19 Jul 2025 09:46:06 +0200 Subject: [PATCH 107/196] increase buffer size. --- avr/modules/network/defs.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/avr/modules/network/defs.asm b/avr/modules/network/defs.asm index 9e68b37..ac409a7 100644 --- a/avr/modules/network/defs.asm +++ b/avr/modules/network/defs.asm @@ -12,9 +12,9 @@ .equ NET_BUFFERS_SIZE = 28 ; CAVE: need to adapt routine NET_Buffer_Locate when changing this value!! -.equ NET_MSGNUMINBUF_SIZE = 6 ; max buffer nums in ringbuffer (global incoming) +.equ NET_MSGNUMINBUF_SIZE = 8 ; max buffer nums in ringbuffer (global incoming) -.equ NET_IFACE_OUTMSGBUF_SIZE = 4 ; max buffer nums in ringbuffer (per interface outbound) +.equ NET_IFACE_OUTMSGBUF_SIZE = 8 ; max buffer nums in ringbuffer (per interface outbound) .equ NET_IFACE_BUFFER_INUSE_BIT = 7 From b7234a6da2cc1826340387c8c85b9685d3c995f2 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 19 Jul 2025 09:47:23 +0200 Subject: [PATCH 108/196] start using new COM module in n27, r05 and t03. --- avr/devices/n27/defs.asm | 11 +++++++++++ avr/devices/n27/main/main.asm | 9 ++++++--- avr/devices/r05/defs.asm | 29 ++++++++++++++++++++++++----- avr/devices/r05/main/main.asm | 11 ++++++----- avr/devices/t03/defs.asm | 19 +++++++++++++++++++ avr/devices/t03/main/main.asm | 20 ++++++++++++-------- 6 files changed, 78 insertions(+), 21 deletions(-) diff --git a/avr/devices/n27/defs.asm b/avr/devices/n27/defs.asm index 26d3f8b..21f980e 100644 --- a/avr/devices/n27/defs.asm +++ b/avr/devices/n27/defs.asm @@ -70,6 +70,17 @@ .equ COM_IRQ_GIMSK_ATTN = PCIE0 +.equ COM_CLK_DDR = DDRA +.equ COM_CLK_INPUT = PINA +.equ COM_CLK_OUTPUT = PORTA +.equ COM_CLK_PIN = PORTA7 + +.equ COM_IRQ_ADDR_CLK = PCMSK0 +.equ COM_IRQ_BIT_CLK = PCINT7 ; bit 7 in PCMSK0 +.equ COM_IRQ_GIFR_CLK = PCIF0 +.equ COM_IRQ_GIMSK_CLK = PCIE0 + + ; --------------------------------------------------------------------------- ; TWI master module diff --git a/avr/devices/n27/main/main.asm b/avr/devices/n27/main/main.asm index e340261..f1695b2 100644 --- a/avr/devices/n27/main/main.asm +++ b/avr/devices/n27/main/main.asm @@ -61,7 +61,8 @@ #define MODULES_CLOCK #define MODULES_LED_SIMPLE #define MODULES_NETWORK -#define MODULES_UART_BITBANG +;#define MODULES_UART_BITBANG +#define MODULES_COM2W #define MODULES_TWI_MASTER ;#define MODULES_LCD ;#define LCD_MINIMAL_FONT @@ -123,7 +124,8 @@ ; rjmp main ; Reset vector rjmp BOOTLOADER_ADDR ; Reset vector ; use this for flashed system reti ; EXT_INT0 - rjmp UART_BitBang_PcintIsr ; PCI0 +; rjmp UART_BitBang_PcintIsr ; PCI0 + rjmp com2wPcintIsr ; PCI0 reti ; PCI1 reti ; WATCHDOG reti ; ICP1 @@ -218,7 +220,8 @@ onEveryLoop: ; --------------------------------------------------------------------------- ; defines for network interface -.equ netInterfaceData = uart_bitbang_iface +;.equ netInterfaceData = uart_bitbang_iface +.equ netInterfaceData = com2w_iface diff --git a/avr/devices/r05/defs.asm b/avr/devices/r05/defs.asm index bfd2e29..7e1b8d5 100644 --- a/avr/devices/r05/defs.asm +++ b/avr/devices/r05/defs.asm @@ -56,11 +56,11 @@ .equ COM_HALFBIT_LENGTH = 26000 ; see https://de.wikipedia.org/wiki/Universal_Asynchronous_Receiver_Transmitter ; settings for comOnUart0 -;.equ COM_DATA_DDR = DDRA -;.equ COM_DATA_INPUT = PINA -;.equ COM_DATA_OUTPUT = PORTA -;.equ COM_DATA_PUE = PUEA -;.equ COM_DATA_PIN = PORTA2 +.equ COM_DATA0_DDR = DDRA +.equ COM_DATA0_INPUT = PINA +.equ COM_DATA0_OUTPUT = PORTA +.equ COM_DATA0_PUE = PUEA +.equ COM_DATA0_PIN = PORTA2 .equ COM_ATTN0_DDR = DDRA .equ COM_ATTN0_INPUT = PINA @@ -87,6 +87,25 @@ .equ COM_IRQ_GIMSK_ATTN1 = PCIE1 +; settings for comOnUart1 +.equ COM_DATA1_DDR = DDRA +.equ COM_DATA1_INPUT = PINA +.equ COM_DATA1_OUTPUT = PORTA +.equ COM_DATA1_PUE = PUEA +.equ COM_DATA1_PIN = PORTA4 + +.equ COM_CLK1_DDR = DDRB +.equ COM_CLK1_INPUT = PINB +.equ COM_CLK1_OUTPUT = PORTB +.equ COM_CLK1_PUE = PUEB +.equ COM_CLK1_PIN = PORTB1 + +.equ COM_IRQ_ADDR_CLK1 = PCMSK1 +.equ COM_IRQ_BIT_CLK1 = PCINT9 ; bit PCINT9 in PCMSK1 +.equ COM_IRQ_GIFR_CLK1 = PCIF1 +.equ COM_IRQ_GIMSK_CLK1 = PCIE1 + + ; --------------------------------------------------------------------------- ; TWI master module diff --git a/avr/devices/r05/main/main.asm b/avr/devices/r05/main/main.asm index 01ed840..8a48ebe 100644 --- a/avr/devices/r05/main/main.asm +++ b/avr/devices/r05/main/main.asm @@ -70,12 +70,13 @@ #endif #define MODULES_NETWORK #define MODULES_COMONUART0 -#define MODULES_COMONUART1 +;#define MODULES_COMONUART1 +#define MODULES_COM2W1 ;#define APPS_NETWORK #define APPS_ROUTER -.equ NET_BUFFERS_NUM = 11 +.equ NET_BUFFERS_NUM = 10 @@ -102,7 +103,7 @@ rjmp BOOTLOADER_ADDR ; 1: RESET Reset vector use this for flashed system reti ; 2: INT0 External Interrupt Request 0 rjmp ComOnUart0_AttnChangeIsr ; 3: PCINT0 Pin Change Interrupt 0 - rjmp ComOnUart1_AttnChangeIsr ; 4: PCINT1 Pin Change Interrupt 1 + rjmp COM2W1_ClkChangeIsr ; 4: PCINT1 Pin Change Interrupt 1 reti ; 5: WDT Watchdog Time-out reti ; 6: TIM1_CAPT Timer/Counter1 Capture Event reti ; 7: TIM1_COMPA (OC1A) Timer/Counter1 Compare Match A @@ -125,7 +126,7 @@ reti ; 24: USART0_DRE USART0 Data Register Empty reti ; 25: USART0_TXC USART0 Tx Complete reti ; 26: USART1_RXS USART1 Rx Start - rjmp ComOnUart1_RxCharIsr ; 27: USART1_RXC USART1 Rx Complete + reti ; 27: USART1_RXC USART1 Rx Complete reti ; 28: USART1_DRE USART1 Data Register Empty reti ; 29: USART1_TXC USART1 Tx Complete reti ; 30: TWI Two-Wire-Interface @@ -210,7 +211,7 @@ onMessageReceived: ; defines for network interface .equ netInterfaceData = comOnUart0_iface -.equ netInterfaceData2 = comOnUart1_iface +.equ netInterfaceData2 = com2w1_iface diff --git a/avr/devices/t03/defs.asm b/avr/devices/t03/defs.asm index c0841b4..cf5f970 100644 --- a/avr/devices/t03/defs.asm +++ b/avr/devices/t03/defs.asm @@ -79,6 +79,25 @@ +.equ COM_DATA_DDR = DDRA +.equ COM_DATA_INPUT = PINA +.equ COM_DATA_OUTPUT = PORTA +.equ COM_DATA_PUE = PUEA +.equ COM_DATA_PIN = PORTA2 + +.equ COM_CLK_DDR = DDRA +.equ COM_CLK_INPUT = PINA +.equ COM_CLK_OUTPUT = PORTA +.equ COM_CLK_PUE = PUEA +.equ COM_CLK_PIN = PORTA0 + +.equ COM_IRQ_ADDR_CLK = PCMSK0 +.equ COM_IRQ_BIT_CLK = PCINT0 ; bit 0 in PCMSK0 +.equ COM_IRQ_GIFR_CLK = PCIF0 +.equ COM_IRQ_GIMSK_CLK = PCIE0 + + + ; --------------------------------------------------------------------------- ; 1-Wire Master ; diff --git a/avr/devices/t03/main/main.asm b/avr/devices/t03/main/main.asm index 8a1799b..c817180 100644 --- a/avr/devices/t03/main/main.asm +++ b/avr/devices/t03/main/main.asm @@ -74,7 +74,8 @@ ;#define MODULES_DS18B20 ;#define MODULES_MOTION #define MODULES_NETWORK -#define MODULES_COMONUART0 +#define MODULES_COM2W +;#define MODULES_COMONUART0 #define MODULES_TTYONUART1 #define APPS_STATS #define APPS_NETWORK @@ -109,7 +110,8 @@ rjmp BOOTLOADER_ADDR ; 1: RESET Reset vector use this for flashed system reti ; 2: INT0 External Interrupt Request 0 - rjmp ComOnUart0_AttnChangeIsr ; 3: PCINT0 Pin Change Interrupt 0 +; rjmp COM2W1_ClkChangeIsr ; 3: PCINT0 Pin Change Interrupt 0 + rjmp com2wPcintIsr ; 3: PCINT0 Pin Change Interrupt 0 reti ; 4: PCINT1 Pin Change Interrupt 1 reti ; 5: WDT Watchdog Time-out reti ; 6: TIM1_CAPT Timer/Counter1 Capture Event @@ -129,7 +131,8 @@ reti ; 20: TIM2_OVF (OVF2) Timer/Counter2 Overflow reti ; 21: SPI SPI Serial Transfer Complete reti ; 22: USART0_RXS USART0 Rx Start - rjmp ComOnUart0_RxCharIsr ; 23: USART0_RXC USART0 Rx Complete +; rjmp ComOnUart0_RxCharIsr ; 23: USART0_RXC USART0 Rx Complete + reti ; 23: USART0_RXC USART0 Rx Complete reti ; 24: USART0_DRE USART0 Data Register Empty reti ; 25: USART0_TXC USART0 Tx Complete reti ; 26: USART1_RXS USART1 Rx Start @@ -165,7 +168,7 @@ firmwareStart: onSystemStart: ; set interface number for UART0 ldi r16, COMONUART0_IFACENUM - sts comOnUart0_iface+NET_IFACE_OFFS_IFACENUM, r16 + sts netInterfaceData2+NET_IFACE_OFFS_IFACENUM, r16 ; set interface number for UART1 ldi r16, TTYONUART1_IFACENUM sts ttyOnUart1_iface+NET_IFACE_OFFS_IFACENUM, r16 @@ -246,7 +249,7 @@ letSysHandleMsg: ld r16, X cpi r16, 0xff breq letSysHandleMsg_forMe - lds r17, comOnUart0_iface+NET_IFACE_OFFS_ADDRESS + lds r17, netInterfaceData2+NET_IFACE_OFFS_ADDRESS cp r16, r17 brne letSysHandleMsg_end letSysHandleMsg_forMe: @@ -304,8 +307,8 @@ addMsgToInterface: clc ret addMsgToInterface_toUart0: - ldi yl, LOW(comOnUart0_iface) - ldi yh, HIGH(comOnUart0_iface) + ldi yl, LOW(netInterfaceData2) + ldi yh, HIGH(netInterfaceData2) rjmp NET_Interface_AddOutgoingMsgNum ; try to add msg to interface addMsgToInterface_toUart1: ldi yl, LOW(ttyOnUart1_iface) @@ -332,5 +335,6 @@ addMsgToInterface_toUart1: ; defines for network interface .equ netInterfaceData = ttyOnUart1_iface -.equ netInterfaceData2 = comOnUart0_iface +;.equ netInterfaceData2 = comOnUart0_iface +.equ netInterfaceData2 = com2w_iface From 323a5b76bebbef7e8d5368df9f9321beba97a014 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 19 Jul 2025 09:48:56 +0200 Subject: [PATCH 109/196] sync test. --- avr/modules/uart_hw2/sync_recv.asm | 58 ++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 avr/modules/uart_hw2/sync_recv.asm diff --git a/avr/modules/uart_hw2/sync_recv.asm b/avr/modules/uart_hw2/sync_recv.asm new file mode 100644 index 0000000..bfd8ecd --- /dev/null +++ b/avr/modules/uart_hw2/sync_recv.asm @@ -0,0 +1,58 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + +#ifndef AVR_MODULES_UART_HW2_SYNC_H +#define AVR_MODULES_UART_HW2_SYNC_H + + +.dseg + + +.cseg + + + + +; sync length is 1000 us, so this should return: +; - 125 for 1 MHz +; - 1000 for 8 MHz + +syncRecv: +syncRecv_waitForHigh: + sbis COM_DATA0_INPUT, COM_DATA0_PIN + rjmp syncRecv_waitForHigh + + clr r24 + clr r25 + +syncRecv_waitForLow: + sbic COM_DATA0_INPUT, COM_DATA0_PIN + rjmp syncRecv_waitForLow + +syncRecv_countLow: ; total: +8 per loop + sbic COM_DATA0_INPUT, COM_DATA0_PIN ; +1 if noskip, +2 if skip + rjmp syncRecv_countDone ; +2, total: +2 every loop, +3 in last loop + adiw r25:r24, 1 ; +1 + breq syncRecv_countError ; +1 if not 0, +2 if 0 + nop ; +1 + nop ; +1 + rjmp syncRecv_countLow ; +2 + +syncRecv_countError: + clr r24 + clr r25 +syncRecv_countDone: + ret +; @end + + + + +#endif + From 59a0962420aa984f318f2df480bbbb3c06b9a692 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 19 Jul 2025 15:02:31 +0200 Subject: [PATCH 110/196] added com2w0 --- avr/devices/all/includes.asm | 8 + avr/modules/com2w/com2w.asm | 11 - avr/modules/com2w/com2w0.asm | 643 +++++++++++++++++++++++++++++++++++ 3 files changed, 651 insertions(+), 11 deletions(-) create mode 100644 avr/modules/com2w/com2w0.asm diff --git a/avr/devices/all/includes.asm b/avr/devices/all/includes.asm index 41039f9..83a040b 100644 --- a/avr/devices/all/includes.asm +++ b/avr/devices/all/includes.asm @@ -104,6 +104,14 @@ +#ifdef MODULES_COM2W0 +.include "modules/com2w/defs.asm" +.include "modules/com2w/common.asm" +.include "modules/com2w/com2w0.asm" +#endif + + + #ifdef MODULES_COM2W1 .include "modules/com2w/defs.asm" .include "modules/com2w/common.asm" diff --git a/avr/modules/com2w/com2w.asm b/avr/modules/com2w/com2w.asm index 00c38b4..d888f15 100644 --- a/avr/modules/com2w/com2w.asm +++ b/avr/modules/com2w/com2w.asm @@ -98,10 +98,6 @@ COM2W_Every100ms: ; @clobbers R16, R17, R18, R19, R20, R22, R24, R25, X com2wReceiveNextPkg: -; ldi r20, 3 ; make sure clock remains low for at least 15us -; rcall com2wWaitForClockHighMulti5Us ; (R20, R22) -; brcs com2wReceiveNextPkg_end ; clock got high quite soon, maybe just flaky line - rcall NET_Buffer_Alloc ; R16=buffer num (R16, R17, X) brcs com2wReceiveNextPkg_gotBuffer ldi r16, NET_IFACE_OFFS_ERR_NOBUF_LOW @@ -119,13 +115,6 @@ com2wReceiveNextPkg_gotBuffer: rcall NET_AddIncomingMsgNum ; (R17, R18, X) brcs com2wReceiveNextPkg_end -; debug -push r18 - push r19 - rcall LedSimple_SetFastTiming - pop r19 -pop r18 - push r16 ldi r16, NET_IFACE_OFFS_ERR_MISSED_LOW rcall NET_Interface_IncCounter16 ; (R24, R25) diff --git a/avr/modules/com2w/com2w0.asm b/avr/modules/com2w/com2w0.asm new file mode 100644 index 0000000..8d0589e --- /dev/null +++ b/avr/modules/com2w/com2w0.asm @@ -0,0 +1,643 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + +#ifndef AVR_MODULES_COM2W_COM2W0_H +#define AVR_MODULES_COM2W_COM2W0_H + + +.dseg + +com2w0_iface: .byte COM2W_IFACE_SIZE + + + +.cseg + + + + +; --------------------------------------------------------------------------- +; @routine COM2W0_Init +; +; @clobbers + +COM2W0_Init: + ldi yl, LOW(com2w0_iface) + ldi yh, HIGH(com2w0_iface) + rcall NET_Interface_Init ; (R16, R17, X) + ldi r16, COM2W_MODE_IDLE + rcall com2wSetMode ; (R17) + + ; setup CLK line (as input, disable internal pull-up resistor) + cbi COM_CLK0_DDR, COM_CLK0_PIN ; set CLK as input +.ifdef COM_CLK0_PUE + inr r16, COM_CLK0_PUE + cbr r16, (1< Date: Sat, 19 Jul 2025 15:02:46 +0200 Subject: [PATCH 111/196] t03: added test firmware. --- avr/devices/t03/0BUILD | 1 + avr/devices/t03/test/0BUILD | 33 +++ avr/devices/t03/test/main.asm | 366 ++++++++++++++++++++++++++++++++++ 3 files changed, 400 insertions(+) create mode 100644 avr/devices/t03/test/0BUILD create mode 100644 avr/devices/t03/test/main.asm diff --git a/avr/devices/t03/0BUILD b/avr/devices/t03/0BUILD index dc4c439..b004c20 100644 --- a/avr/devices/t03/0BUILD +++ b/avr/devices/t03/0BUILD @@ -5,6 +5,7 @@ boot main + test diff --git a/avr/devices/t03/test/0BUILD b/avr/devices/t03/test/0BUILD new file mode 100644 index 0000000..2ee4b03 --- /dev/null +++ b/avr/devices/t03/test/0BUILD @@ -0,0 +1,33 @@ + + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + main.asm + + + + + + + + + + + + + + + + + diff --git a/avr/devices/t03/test/main.asm b/avr/devices/t03/test/main.asm new file mode 100644 index 0000000..ab5794a --- /dev/null +++ b/avr/devices/t03/test/main.asm @@ -0,0 +1,366 @@ +; *************************************************************************** +; 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. +; +; +; *************************************************************************** + + +;.equ clock=1000000 ; Define the clock frequency +.equ clock=8000000 ; Define the clock frequency + + +.nolist +.include "include/tn841def.inc" ; Define device ATtiny841 +.list + +.include "../defs.asm" +.include "version.asm" +;.include "defs_all.asm" + +.include "devices/all/defs.asm" + +.include "common/calls.asm" +.include "common/utils_wait.asm" +.include "common/utils_io.asm" + + + +; *************************************************************************** +; defines + +; --------------------------------------------------------------------------- +; generic + +.equ COMONUART0_IFACENUM = 1 +.equ TTYONUART1_IFACENUM = 2 + + +; --------------------------------------------------------------------------- +; firmware settings including list of modules used + + +#define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes +#define APP_STATS_NETDEV2 + +#define MODULES_CLOCK +;#define MODULES_COM +;#define MODULES_COM_WITH_ADDR_PROTO +;#define MODULES_LED +#define MODULES_LED_SIMPLE +;#define MODULES_TWI_MASTER +;#define MODULES_LCD +;#define LCD_MINIMAL_FONT +;#define MODULES_SI7021 +;#define MODULES_STATS +;#define MODULES_CNY70 +;#define MODULES_REED +;#define MODULES_OWI_MASTER +;#define MODULES_DS18B20 +;#define MODULES_MOTION +#define MODULES_NETWORK +#define MODULES_COM2W0 +;#define MODULES_COMONUART0 +#define MODULES_TTYONUART1 +#define APPS_STATS +#define APPS_NETWORK + + + +.equ NET_BUFFERS_NUM = 10 + +.equ UART_HW_MSGNUMINBUF_SIZE = 8 +.equ UART_HW_MSGNUMOUTBUF_SIZE = 8 + + + +; --------------------------------------------------------------------------- +; defines for values + +.equ VALUE_ID_DS18B20_TEMP = 0x06 + +.equ VALUE_ID_LEDSIMPLE_TIMING = 0x88 + + + +.equ COM_DATA0_DDR = COM_DATA_DDR +.equ COM_DATA0_INPUT = COM_DATA_INPUT +.equ COM_DATA0_OUTPUT = COM_DATA_OUTPUT +.equ COM_DATA0_PUE = COM_DATA_PUE +.equ COM_DATA0_PIN = COM_DATA_PIN + +.equ COM_CLK0_DDR = COM_CLK_DDR +.equ COM_CLK0_INPUT = COM_CLK_INPUT +.equ COM_CLK0_OUTPUT = COM_CLK_OUTPUT +.equ COM_CLK0_PUE = COM_CLK_PUE +.equ COM_CLK0_PIN = COM_CLK_PIN + +.equ COM_IRQ_ADDR_CLK0 = COM_IRQ_ADDR_CLK +.equ COM_IRQ_BIT_CLK0 = COM_IRQ_BIT_CLK +.equ COM_IRQ_GIFR_CLK0 = COM_IRQ_GIFR_CLK +.equ COM_IRQ_GIMSK_CLK0 = COM_IRQ_GIMSK_CLK + + +; *************************************************************************** +; code segment + +.cseg +.org 000000 + + + +; --------------------------------------------------------------------------- +; Reset and interrupt vectors + + rjmp BOOTLOADER_ADDR ; 1: RESET Reset vector use this for flashed system + reti ; 2: INT0 External Interrupt Request 0 + rjmp COM2W0_ClkChangeIsr ; 3: PCINT0 Pin Change Interrupt 0 + reti ; 4: PCINT1 Pin Change Interrupt 1 + reti ; 5: WDT Watchdog Time-out + reti ; 6: TIM1_CAPT Timer/Counter1 Capture Event + reti ; 7: TIM1_COMPA (OC1A) Timer/Counter1 Compare Match A + reti ; 8: TIM1_COMPB (OC1B) Timer/Counter1 Compare Match B + reti ; 9: TIM1_OVF (OVF1) Timer/Counter1 Overflow + rjmp baseTimerIrqOC0A ; 10: TIM0_COMPA (OC0A) Timer/Counter0 Compare Match A + reti ; 11: TIM0_COMPB (OC0B) Timer/Counter0 Compare Match B + reti ; 12: TIM0_OVF (OVF0) Timer/Counter0 Overflow + reti ; 13: ANA_COMP0 Analog Comparator 0 + reti ; 14: ADC_READY ADC Conversion Complete + reti ; 15: EE_RDY (ERDY) EEPROM Ready + reti ; 16: ANA_COMP1 Analog Comparator 1 + reti ; 17: TIM2_CAPT Timer/Counter2 Capture Event + reti ; 18: TIM2_COMPA (OC2A) Timer/Counter2 Compare Match A + reti ; 19: TIM2_COMPB (OC2B) Timer/Counter2 Compare Match B + reti ; 20: TIM2_OVF (OVF2) Timer/Counter2 Overflow + reti ; 21: SPI SPI Serial Transfer Complete + reti ; 22: USART0_RXS USART0 Rx Start +; rjmp ComOnUart0_RxCharIsr ; 23: USART0_RXC USART0 Rx Complete + reti ; 23: USART0_RXC USART0 Rx Complete + reti ; 24: USART0_DRE USART0 Data Register Empty + reti ; 25: USART0_TXC USART0 Tx Complete + reti ; 26: USART1_RXS USART1 Rx Start + rjmp TtyOnUart1_RxCharIsr ; 27: USART1_RXC USART1 Rx Complete + rjmp TtyOnUart1_TxUdreIsr ; 28: USART1_DRE USART1 Data Register Empty + rjmp TtyOnUart1_TxCharIsr ; 29: USART1_TXC USART1 Tx Complete + reti ; 30: TWI Two-Wire-Interface + reti ; 31: RESERVED reserved + + + +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: + ; set interface number for UART0 + ldi r16, COMONUART0_IFACENUM + sts netInterfaceData2+NET_IFACE_OFFS_IFACENUM, r16 + ; set interface number for UART1 + ldi r16, TTYONUART1_IFACENUM + sts ttyOnUart1_iface+NET_IFACE_OFFS_IFACENUM, r16 + + ret +; @end + + + +onEvery100ms: +onEverySecond: +onEveryMinute: +onEveryHour: +onEveryDay: + ret + + + +; --------------------------------------------------------------------------- +; @routine onEveryLoop +; +; Called on every loop (i.e. after awakening from sleep). + +onEveryLoop: + rcall checkRecvdMsg + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine onMessageReceived +; +; Called on every message received + +onMessageReceived: + clc + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine checkRecvdMsg +; +; Read messages from either interface and forward to the other one. + +checkRecvdMsg: + rcall NET_PeekNextIncomingMsgNum ; check read queue (bufNum->r16) + brcc checkRecvdMsg_end ; no msg, jmp + rcall NET_Buffer_Locate ; (R17) + ; let system handle incoming messages + push r16 + push xl + push xh + adiw xh:xl, 1 + rcall letSysHandleMsg + pop xh + pop xl + pop r16 + + ; forward to other interface + ld r17, X + andi r17, (1< Date: Sat, 19 Jul 2025 17:07:52 +0200 Subject: [PATCH 112/196] check dest address for ping requests. --- avr/apps/router/main.asm | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/avr/apps/router/main.asm b/avr/apps/router/main.asm index 05bc1be..b077898 100644 --- a/avr/apps/router/main.asm +++ b/avr/apps/router/main.asm @@ -48,6 +48,7 @@ AppRouter_Init: ldi r17, (appRouterDataEnd-appRouterDataBegin) rcall Utils_FillSram +#ifndef APP_ROUTER_NO_ADDR_MGR ldi r16, 0xe0 ; default range from 0xe0-0xef (will be changed later) sts netInterfaceData+NET_IFACE_OFFS_ADDRESS, r16 ; use first address for router itself sts netInterfaceData2+NET_IFACE_OFFS_ADDRESS, r16 ; use same address for both interfaces to save on addresses @@ -57,6 +58,7 @@ AppRouter_Init: sts appRouterRangeEnd, r16 rcall appRouterReadConfFromEeprom ; try to read config from EEPROM +#endif ; set interface number for NETDEV0 ldi r16, NETDEV0_IFACENUM @@ -65,9 +67,11 @@ AppRouter_Init: ldi r16, NETDEV1_IFACENUM sts netInterfaceData2+NET_IFACE_OFFS_IFACENUM, r16 +#ifndef APP_ROUTER_NO_ADDR_MGR ldi r18, NETMSG_CMD_ADDRESS_RANGE rcall appRouterSendRangeMsgToDev1 - +#endif + ret ; @end @@ -140,6 +144,7 @@ appRouterHandleMsgAnyDev_handleSetValue: breq appRouterHandleMsgAnyDev_handleSetRange rjmp appRouterHandleMsgAnyDev_clcRet appRouterHandleMsgAnyDev_handleSetRange: +#ifndef APP_ROUTER_NO_ADDR_MGR sts netInterfaceData+NET_IFACE_OFFS_ADDRESS, r18 ; use first address for router itself sts netInterfaceData2+NET_IFACE_OFFS_ADDRESS, r18 ; use same address for both interfaces to save on addresses inc r18 ; start range after router @@ -152,6 +157,7 @@ appRouterHandleMsgAnyDev_handleSetRange: ldi r18, NETMSG_CMD_REENUM rcall appRouterSendRangeMsgToDev1 ; (R16, R17, R18, R19, R20, R21, X, Y) rcall appRouterWriteConfToEeprom ; (r16, r17, X) +#endif sec ret appRouterHandleMsgAnyDev_clcRet: @@ -172,6 +178,7 @@ appRouterHandleMsgAnyDev_end: ; @clobbers any, !X appRouterHandleDev1Msg: +#ifndef APP_ROUTER_NO_ADDR_MGR push xl push xh rcall appRouterHandleDev1Msg_savedX @@ -202,6 +209,7 @@ appRouterHandleDev1Msg_handleClaimAddr: rcall appRouterSendDenyAddrR19ToDev1 ; (R16, R17, R18, R19, R20, R21, X, Y) sec rjmp appRouterHandleDev1Msg_end +#endif appRouterHandleDev1Msg_clcRet: clc appRouterHandleDev1Msg_end: @@ -340,8 +348,18 @@ appRouterHandleRebootRequest_end: ; @param X pointer to received message appRouterHandlePingRequest: + ld r17, X + lds r16, (netInterfaceData+NET_IFACE_OFFS_ADDRESS) + cp r16, r17 + breq appRouterHandlePingRequest_forMe + cpi r17, 0xff + breq appRouterHandlePingRequest_forMe + clc + rjmp appRouterHandlePingRequest_end +appRouterHandlePingRequest_forMe: adiw xh:xl, NETMSG_OFFS_SRCADDR ld r17, X + sbiw xh:xl, NETMSG_OFFS_SRCADDR push r17 bigcall NET_Buffer_Alloc ; (R16, R17, X) pop r17 @@ -408,8 +426,10 @@ appRouterHandleRouterMsgWithHdr: andi r17, (1< Date: Sat, 19 Jul 2025 17:08:19 +0200 Subject: [PATCH 113/196] enable sending messages. --- avr/modules/com2w/com2w0.asm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/avr/modules/com2w/com2w0.asm b/avr/modules/com2w/com2w0.asm index 8d0589e..b9e5e04 100644 --- a/avr/modules/com2w/com2w0.asm +++ b/avr/modules/com2w/com2w0.asm @@ -306,7 +306,7 @@ com2w0WaitForClockLowMulti5Us_stateReached: com2w0SendMsg: ldi r20, 11 ; wait for about 55us for clock low - rcall com2w0WaitForClockLowMulti5Us + rcall com2w0WaitForClockLowMulti5Us ; (R20, R22) brcs com2w0SendMsg_busy ; CLK got low while waiting, so line is busy push r15 in r15, SREG @@ -443,7 +443,7 @@ com2w0ModeJumpTable: ; @clobbers R16, R17, R22, R24, R25, X com2w0RunIdle: -rjmp com2w0RunIdle_end ; DEBUG +;rjmp com2w0RunIdle_end ; DEBUG push r15 in r15, SREG cli @@ -468,7 +468,7 @@ com2w0RunIdle_haveMsg: adiw xh:xl, 1 rcall com2w0SendMsg ; (R16, R17, R22, R24, R25, X) push r15 - inr r15, SREG ; save SREG (no CLI, we want to save CFLAG only) + in r15, SREG ; save SREG (no CLI, we want to save CFLAG only) ldi r16, COM2W_MODE_IDLE rcall com2wSetMode ; (R17) out SREG, r15 ; restore SREG From c8c12bb892d209e864a98b4b010762ad23326d15 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 19 Jul 2025 17:08:39 +0200 Subject: [PATCH 114/196] t03: use router app. --- avr/devices/t03/test/main.asm | 123 ++-------------------------------- 1 file changed, 7 insertions(+), 116 deletions(-) diff --git a/avr/devices/t03/test/main.asm b/avr/devices/t03/test/main.asm index ab5794a..1154fbb 100644 --- a/avr/devices/t03/test/main.asm +++ b/avr/devices/t03/test/main.asm @@ -57,6 +57,7 @@ #define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes #define APP_STATS_NETDEV2 +#define APP_ROUTER_NO_ADDR_MGR #define MODULES_CLOCK ;#define MODULES_COM @@ -78,7 +79,8 @@ ;#define MODULES_COMONUART0 #define MODULES_TTYONUART1 #define APPS_STATS -#define APPS_NETWORK +;#define APPS_NETWORK +#define APPS_ROUTER @@ -95,6 +97,7 @@ .equ VALUE_ID_DS18B20_TEMP = 0x06 .equ VALUE_ID_LEDSIMPLE_TIMING = 0x88 +.equ VALUE_ID_ROUTER_SETRANGE = 0x89 @@ -184,13 +187,9 @@ firmwareStart: ; @routine onSystemStart onSystemStart: - ; set interface number for UART0 - ldi r16, COMONUART0_IFACENUM - sts netInterfaceData2+NET_IFACE_OFFS_IFACENUM, r16 - ; set interface number for UART1 - ldi r16, TTYONUART1_IFACENUM - sts ttyOnUart1_iface+NET_IFACE_OFFS_IFACENUM, r16 - + ldi r16, 0xf0 + sts netInterfaceData+NET_IFACE_OFFS_ADDRESS, r16 + sts netInterfaceData2+NET_IFACE_OFFS_ADDRESS, r16 ret ; @end @@ -211,7 +210,6 @@ onEveryDay: ; Called on every loop (i.e. after awakening from sleep). onEveryLoop: - rcall checkRecvdMsg ret ; @end @@ -229,113 +227,6 @@ onMessageReceived: -; --------------------------------------------------------------------------- -; @routine checkRecvdMsg -; -; Read messages from either interface and forward to the other one. - -checkRecvdMsg: - rcall NET_PeekNextIncomingMsgNum ; check read queue (bufNum->r16) - brcc checkRecvdMsg_end ; no msg, jmp - rcall NET_Buffer_Locate ; (R17) - ; let system handle incoming messages - push r16 - push xl - push xh - adiw xh:xl, 1 - rcall letSysHandleMsg - pop xh - pop xl - pop r16 - - ; forward to other interface - ld r17, X - andi r17, (1< Date: Sat, 19 Jul 2025 17:47:52 +0200 Subject: [PATCH 115/196] com2w: alloc buffer after receiving message. receiving works now. --- avr/modules/com2w/com2w.asm | 64 ++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/avr/modules/com2w/com2w.asm b/avr/modules/com2w/com2w.asm index d888f15..d2fe8b2 100644 --- a/avr/modules/com2w/com2w.asm +++ b/avr/modules/com2w/com2w.asm @@ -98,23 +98,64 @@ COM2W_Every100ms: ; @clobbers R16, R17, R18, R19, R20, R22, R24, R25, X com2wReceiveNextPkg: + mov xl, yl + mov xh, yh + adiw xh:xl, COM2W_IFACE_OFFS_BUFFER + ldd r18, Y+NET_IFACE_OFFS_ADDRESS + ldi r19, COM2W_BUFFER_SIZE + rcall com2wRecvMsg ; (r16, r17, r18, r19, r20, r22, r24, r25, X) + brcc com2wReceiveNextPkg_end + + mov xl, yl + mov xh, yh + adiw xh:xl, COM2W_IFACE_OFFS_BUFFER + rcall NETMSG_CheckMessageInBuffer ; (R16, R17, R18, R19, R20, X) + brcc com2wReceiveNextPkg_eCrc + + ; msg received, alloc buffer for it rcall NET_Buffer_Alloc ; R16=buffer num (R16, R17, X) brcs com2wReceiveNextPkg_gotBuffer ldi r16, NET_IFACE_OFFS_ERR_NOBUF_LOW rcall NET_Interface_IncCounter16 ; (R24, R25) rjmp com2wReceiveNextPkg_end -com2wReceiveNextPkg_gotBuffer: - push r16 ; buffer number - rcall NET_Interface_SetIfaceNumInBuffer ; (R16, R17) - adiw xh:xl, 1 - ldd r18, Y+NET_IFACE_OFFS_ADDRESS - ldi r19, NET_BUFFERS_SIZE-1 - rcall com2wReceiveAndCheckMsg ; (R16, R17, R18, R19, R20, R22, R24, R25) - pop r16 - brcc com2wReceiveNextPkg_relBuffer - rcall NET_AddIncomingMsgNum ; (R17, R18, X) - brcs com2wReceiveNextPkg_end + ; copy received message into allocated buffer +com2wReceiveNextPkg_gotBuffer: + mov r19, r16 ; save buffer num + rcall NET_Interface_SetIfaceNumInBuffer ; (R16, R17) + mov r16, r19 ; restore buffer num + push zl + push zh + mov zl, yl + mov zh, yh + adiw zh:zl, COM2W_IFACE_OFFS_BUFFER + adiw xh:xl, 1 + ldd r18, Z+NETMSG_OFFS_MSGLEN + inc r18 + inc r18 + inc r18 +com2wReceiveNextPkg_copyLoop: + ld r17, Z+ + st X+, r17 + dec r18 + brne com2wReceiveNextPkg_copyLoop + pop zh + pop zl + + ; add to incoming msg pool + rcall NET_AddIncomingMsgNum ; (R17, R18, X) + brcc com2wReceiveNextPkg_eMissed + ldi r16, NET_IFACE_OFFS_PACKETSIN_LOW + rcall NET_Interface_IncCounter16 ; (R24, R25) + sec + rjmp com2wReceiveNextPkg_end +com2wReceiveNextPkg_eCrc: + push r16 + ldi r16, NET_IFACE_OFFS_ERR_CONTENT_LOW + rcall NET_Interface_IncCounter16 ; (R24, R25) + pop r16 + rjmp com2wReceiveNextPkg_relBuffer +com2wReceiveNextPkg_eMissed: push r16 ldi r16, NET_IFACE_OFFS_ERR_MISSED_LOW rcall NET_Interface_IncCounter16 ; (R24, R25) @@ -122,6 +163,7 @@ com2wReceiveNextPkg_gotBuffer: ; fall-through to release buffer com2wReceiveNextPkg_relBuffer: rcall NET_Buffer_ReleaseByNum ; (R16, X) + clc com2wReceiveNextPkg_end: ret ; @end From ae1e4c3e3754fb77232f1b71e41ea758314e2cb4 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 20 Jul 2025 00:05:53 +0200 Subject: [PATCH 116/196] avr: bootloader works with new com2w code. --- avr/devices/n27/boot/boot.asm | 4 +- avr/modules/flash/0BUILD | 1 + avr/modules/flash/io_com2w.asm | 462 +++++++++++++++++++++++++++++++++ avr/modules/flash/io_stub.asm | 60 +++++ 4 files changed, 525 insertions(+), 2 deletions(-) create mode 100644 avr/modules/flash/io_com2w.asm create mode 100644 avr/modules/flash/io_stub.asm diff --git a/avr/devices/n27/boot/boot.asm b/avr/devices/n27/boot/boot.asm index 767f207..f867d2b 100644 --- a/avr/devices/n27/boot/boot.asm +++ b/avr/devices/n27/boot/boot.asm @@ -26,6 +26,7 @@ .include "../defs.asm" .include "common/calls.asm" +.include "common/utils_io.asm" .include "devices/all/defs.asm" @@ -122,8 +123,7 @@ main: .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/io_com2w.asm" .include "modules/flash/flash1p.asm" .include "modules/flash/flashxp.asm" .include "modules/flash/flashprocess.asm" diff --git a/avr/modules/flash/0BUILD b/avr/modules/flash/0BUILD index 53f3762..d6e181c 100644 --- a/avr/modules/flash/0BUILD +++ b/avr/modules/flash/0BUILD @@ -9,6 +9,7 @@ flash4p.asm flashxp.asm flashprocess.asm + io_stub.asm io.asm io_attn.asm io_bitbang.asm diff --git a/avr/modules/flash/io_com2w.asm b/avr/modules/flash/io_com2w.asm new file mode 100644 index 0000000..1a56014 --- /dev/null +++ b/avr/modules/flash/io_com2w.asm @@ -0,0 +1,462 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + +#ifndef AVR_MODULES_FLASH_IO_COM2W_H +#define AVR_MODULES_FLASH_IO_COM2W_H + + + + +.equ COM2W_WAITTIME1 = 30000 +.equ COM2W_WAITTIME2 = 10000 + + + + +; *************************************************************************** +; code + +.cseg + + + +; --------------------------------------------------------------------------- +; @routine ioRawInit +; +; Init raw message subsystem. +; + +ioRawInit: + ; setup CLK line (as input, disable internal pull-up resistor) + cbi COM_CLK_DDR, COM_CLK_PIN ; set CLK as input +.ifdef COM_CLK_PUE + inr r16, COM_CLK_PUE + cbr r16, (1< Date: Sun, 20 Jul 2025 00:15:13 +0200 Subject: [PATCH 117/196] adapt com2w1 from com2w0 (the latter is proven to work now). --- avr/modules/com2w/com2w1.asm | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/avr/modules/com2w/com2w1.asm b/avr/modules/com2w/com2w1.asm index 73ed414..c54ad98 100644 --- a/avr/modules/com2w/com2w1.asm +++ b/avr/modules/com2w/com2w1.asm @@ -184,9 +184,9 @@ com2w1DataSetLow: ; @clobbers r16, r17, r18, r20, r22 com2w1ReadNextBit: - ldi r20, 50 ; wait for up to 250us for clock rise - rcall com2w1WaitForClockHighMulti5Us ; (R20, R22) - brcc com2w1ReadNextBit_end +; ldi r20, 50 ; wait for up to 250us for clock rise +; rcall com2w1WaitForClockHighMulti5Us ; (R20, R22) +; brcc com2w1ReadNextBit_end ; clock is high now, read bit inr r17, COM_DATA1_INPUT ; reset read timer (for leaving skipping mode) @@ -306,7 +306,7 @@ com2w1WaitForClockLowMulti5Us_stateReached: com2w1SendMsg: ldi r20, 11 ; wait for about 55us for clock low - rcall com2w1WaitForClockLowMulti5Us + rcall com2w1WaitForClockLowMulti5Us ; (R20, R22) brcs com2w1SendMsg_busy ; CLK got low while waiting, so line is busy push r15 in r15, SREG @@ -443,7 +443,7 @@ com2w1ModeJumpTable: ; @clobbers R16, R17, R22, R24, R25, X com2w1RunIdle: -rjmp com2w1RunIdle_end ; DEBUG +;rjmp com2w1RunIdle_end ; DEBUG push r15 in r15, SREG cli @@ -468,7 +468,7 @@ com2w1RunIdle_haveMsg: adiw xh:xl, 1 rcall com2w1SendMsg ; (R16, R17, R22, R24, R25, X) push r15 - inr r15, SREG ; save SREG (no CLI, we want to save CFLAG only) + in r15, SREG ; save SREG (no CLI, we want to save CFLAG only) ldi r16, COM2W_MODE_IDLE rcall com2wSetMode ; (R17) out SREG, r15 ; restore SREG @@ -613,19 +613,24 @@ COM2W1_HandleClockInterrupt: com2w1ActOnClock: andi r16, (1< Date: Sun, 20 Jul 2025 23:15:22 +0200 Subject: [PATCH 118/196] read CLK and DATA early. --- avr/modules/com2w/com2w0.asm | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/avr/modules/com2w/com2w0.asm b/avr/modules/com2w/com2w0.asm index b9e5e04..24a3b28 100644 --- a/avr/modules/com2w/com2w0.asm +++ b/avr/modules/com2w/com2w0.asm @@ -181,6 +181,7 @@ com2w0DataSetLow: ; --------------------------------------------------------------------------- ; @routine com2w0ReadNextBit ; +; @param r17 data from COM_DATAn_INPUT ; @clobbers r16, r17, r18, r20, r22 com2w0ReadNextBit: @@ -188,7 +189,6 @@ com2w0ReadNextBit: ; rcall com2w0WaitForClockHighMulti5Us ; (R20, R22) ; brcc com2w0ReadNextBit_end ; clock is high now, read bit - inr r17, COM_DATA0_INPUT ; reset read timer (for leaving skipping mode) clr r16 std Y+NET_IFACE_OFFS_READTIMER, r16 @@ -566,8 +566,11 @@ COM2W0_ClkChangeIsr: push r15 in r15, SREG push r16 - inr r16, COM_CLK0_INPUT ; read clk state early - rcall COM2W0_HandleClockInterrupt + push r17 + inr r16, COM_CLK0_INPUT ; read clk state early + inr r17, COM_DATA0_INPUT ; read data state early + rcall COM2W0_HandleClockInterrupt + pop r17 pop r16 out SREG, r15 pop r15 @@ -580,6 +583,7 @@ COM2W0_ClkChangeIsr: ; @routine COM2W0_HandleClockInterrupt @global ; ; @param r16 data from COM_CLKn_INPUT +; @param r17 data from COM_DATAn_INPUT ; @clobbers none COM2W0_HandleClockInterrupt: @@ -609,20 +613,30 @@ COM2W0_HandleClockInterrupt: ; @routine com2w0ActOnClock ; ; @param r16 data from COM_CLKn_INPUT +; @param r17 data from COM_DATAn_INPUT ; @clobbers r16 (r17, r18, X) com2w0ActOnClock: andi r16, (1< Date: Sun, 20 Jul 2025 23:15:46 +0200 Subject: [PATCH 119/196] guard some changes on network data with CLI. --- avr/modules/network/iface.asm | 45 ++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/avr/modules/network/iface.asm b/avr/modules/network/iface.asm index b0174f9..1ed7baa 100644 --- a/avr/modules/network/iface.asm +++ b/avr/modules/network/iface.asm @@ -205,16 +205,21 @@ NET_Interface_SetIfaceNumInBuffer: ; @clobbers R16 NET_Interface_Periodically: - ldd r16, Y+NET_IFACE_OFFS_READTIMER - inc r16 - breq NET_Interface_Periodically_l1 - std Y+NET_IFACE_OFFS_READTIMER, r16 + push r15 + in r15, SREG + cli + ldd r16, Y+NET_IFACE_OFFS_READTIMER + inc r16 + breq NET_Interface_Periodically_l1 + std Y+NET_IFACE_OFFS_READTIMER, r16 NET_Interface_Periodically_l1: - ldd r16, Y+NET_IFACE_OFFS_WRITETIMER - inc r16 - breq NET_Interface_Periodically_l2 - std Y+NET_IFACE_OFFS_WRITETIMER, r16 + ldd r16, Y+NET_IFACE_OFFS_WRITETIMER + inc r16 + breq NET_Interface_Periodically_l2 + std Y+NET_IFACE_OFFS_WRITETIMER, r16 NET_Interface_Periodically_l2: + out SREG, r15 + pop r15 ret ; @end @@ -227,15 +232,21 @@ NET_Interface_Periodically_l2: ; @clobbers R16, R17, X NET_Interface_ResetStats: - clr r16 - std Y+NET_IFACE_OFFS_PACKETSIN_LOW, r16 - - mov xl, yl - mov xh, yh - adiw xh:xl, NET_IFACE_OFFS_PACKETSIN_LOW - ldi r17, ((NET_IFACE_OFFS_ERR_BUSY_HIGH+1)-NET_IFACE_OFFS_PACKETSIN_LOW) - clr r16 - rjmp Utils_FillSram ; (R17, X) + push r15 + in r15, SREG + cli + clr r16 + std Y+NET_IFACE_OFFS_PACKETSIN_LOW, r16 + + mov xl, yl + mov xh, yh + adiw xh:xl, NET_IFACE_OFFS_PACKETSIN_LOW + ldi r17, ((NET_IFACE_OFFS_ERR_BUSY_HIGH+1)-NET_IFACE_OFFS_PACKETSIN_LOW) + clr r16 + rcall Utils_FillSram ; (R17, X) + out SREG, r15 + pop r15 + ret ; @end From 2b25fed2cd4c9889cf9099fcb447b5cd5923aa22 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 21 Jul 2025 18:25:17 +0200 Subject: [PATCH 120/196] com2w1: follow changes in com2w0. --- avr/modules/com2w/com2w1.asm | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/avr/modules/com2w/com2w1.asm b/avr/modules/com2w/com2w1.asm index c54ad98..a57189c 100644 --- a/avr/modules/com2w/com2w1.asm +++ b/avr/modules/com2w/com2w1.asm @@ -181,6 +181,7 @@ com2w1DataSetLow: ; --------------------------------------------------------------------------- ; @routine com2w1ReadNextBit ; +; @param r17 data from COM_DATAn_INPUT ; @clobbers r16, r17, r18, r20, r22 com2w1ReadNextBit: @@ -188,7 +189,6 @@ com2w1ReadNextBit: ; rcall com2w1WaitForClockHighMulti5Us ; (R20, R22) ; brcc com2w1ReadNextBit_end ; clock is high now, read bit - inr r17, COM_DATA1_INPUT ; reset read timer (for leaving skipping mode) clr r16 std Y+NET_IFACE_OFFS_READTIMER, r16 @@ -566,8 +566,11 @@ COM2W1_ClkChangeIsr: push r15 in r15, SREG push r16 - inr r16, COM_CLK1_INPUT ; read clk state early - rcall COM2W1_HandleClockInterrupt + push r17 + inr r16, COM_CLK1_INPUT ; read clk state early + inr r17, COM_DATA1_INPUT ; read data state early + rcall COM2W1_HandleClockInterrupt + pop r17 pop r16 out SREG, r15 pop r15 @@ -580,6 +583,7 @@ COM2W1_ClkChangeIsr: ; @routine COM2W1_HandleClockInterrupt @global ; ; @param r16 data from COM_CLKn_INPUT +; @param r17 data from COM_DATAn_INPUT ; @clobbers none COM2W1_HandleClockInterrupt: @@ -609,20 +613,30 @@ COM2W1_HandleClockInterrupt: ; @routine com2w1ActOnClock ; ; @param r16 data from COM_CLKn_INPUT +; @param r17 data from COM_DATAn_INPUT ; @clobbers r16 (r17, r18, X) com2w1ActOnClock: andi r16, (1< Date: Sun, 3 Aug 2025 00:54:45 +0200 Subject: [PATCH 121/196] avr: fixed apidoc. --- avr/common/ringbuffer_y.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avr/common/ringbuffer_y.asm b/avr/common/ringbuffer_y.asm index e4e2ec9..b887b3c 100644 --- a/avr/common/ringbuffer_y.asm +++ b/avr/common/ringbuffer_y.asm @@ -120,7 +120,7 @@ RingBufferY_Reset: ; ; @return CFLAG on success, cleared on error ; @return r16 byte read -; @param Y pointer to start of interface data +; @param Y base address of ringbuffer struct ; @clobbers R17, R18, X RingBufferY_ReadByteGuarded: From 6c5dc21f6aaa3a7eacaf56ee59ccdf921e83cce3 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 3 Aug 2025 00:55:21 +0200 Subject: [PATCH 122/196] avr: started adding r06 device. --- avr/devices/r06/.gitignore | 2 + avr/devices/r06/0BUILD | 22 ++++ avr/devices/r06/README | 11 ++ avr/devices/r06/aqua_r06.xml | 20 +++ avr/devices/r06/boot/0BUILD | 32 +++++ avr/devices/r06/boot/boot.asm | 157 +++++++++++++++++++++++ avr/devices/r06/defs.asm | 167 +++++++++++++++++++++++++ avr/devices/r06/main/0BUILD | 34 +++++ avr/devices/r06/main/data.asm | 14 +++ avr/devices/r06/main/main.asm | 227 ++++++++++++++++++++++++++++++++++ avr/modules/com2w/defs.asm | 24 ++-- 11 files changed, 700 insertions(+), 10 deletions(-) create mode 100644 avr/devices/r06/.gitignore create mode 100644 avr/devices/r06/0BUILD create mode 100644 avr/devices/r06/README create mode 100644 avr/devices/r06/aqua_r06.xml create mode 100644 avr/devices/r06/boot/0BUILD create mode 100644 avr/devices/r06/boot/boot.asm create mode 100644 avr/devices/r06/defs.asm create mode 100644 avr/devices/r06/main/0BUILD create mode 100644 avr/devices/r06/main/data.asm create mode 100644 avr/devices/r06/main/main.asm diff --git a/avr/devices/r06/.gitignore b/avr/devices/r06/.gitignore new file mode 100644 index 0000000..8e0618c --- /dev/null +++ b/avr/devices/r06/.gitignore @@ -0,0 +1,2 @@ +*.eep.hex +*.obj diff --git a/avr/devices/r06/0BUILD b/avr/devices/r06/0BUILD new file mode 100644 index 0000000..ef47309 --- /dev/null +++ b/avr/devices/r06/0BUILD @@ -0,0 +1,22 @@ + + + + + + boot + main + + + + aqua_r06.xml + + + + defs.asm + README + + + + + + diff --git a/avr/devices/r06/README b/avr/devices/r06/README new file mode 100644 index 0000000..684bdcc --- /dev/null +++ b/avr/devices/r06/README @@ -0,0 +1,11 @@ + +R06 +=== + +- Role: Router +- MCU: AtTiny841 +- Connection: RJ45 +- Predecessor: R05, R04 +- COM: com2wg +- Periphery: + - TWI interface diff --git a/avr/devices/r06/aqua_r06.xml b/avr/devices/r06/aqua_r06.xml new file mode 100644 index 0000000..f0fc612 --- /dev/null +++ b/avr/devices/r06/aqua_r06.xml @@ -0,0 +1,20 @@ + + + AQUA + R + 6 + + + + + + + + + + + + + + + diff --git a/avr/devices/r06/boot/0BUILD b/avr/devices/r06/boot/0BUILD new file mode 100644 index 0000000..ebf4780 --- /dev/null +++ b/avr/devices/r06/boot/0BUILD @@ -0,0 +1,32 @@ + + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + boot.asm + + + + + + + + + + + + + + + + diff --git a/avr/devices/r06/boot/boot.asm b/avr/devices/r06/boot/boot.asm new file mode 100644 index 0000000..de9617c --- /dev/null +++ b/avr/devices/r06/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 "common/utils_io.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 = DDRB ; LED0 +.equ LED_PORT = PORTB +.equ LED_PIN = PINB +.equ LED_PINNUM = PORTB0 + + +; *************************************************************************** +; 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_com2w.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/r06/main/data.asm b/avr/devices/r06/main/data.asm new file mode 100644 index 0000000..31ccc2f --- /dev/null +++ b/avr/devices/r06/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/r06/main/main.asm b/avr/devices/r06/main/main.asm new file mode 100644 index 0000000..9ef4528 --- /dev/null +++ b/avr/devices/r06/main/main.asm @@ -0,0 +1,227 @@ +; *************************************************************************** +; 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_io.asm" +.include "common/utils_wait.asm" + + + +; *************************************************************************** +; defines + +; --------------------------------------------------------------------------- +; generic + +.equ NET_BUFFERS_NUM = 6 + +.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_COM2WG +;#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 MODULES_BRIGHTNESS + +;#define APPS_NETWORK +;#define APPS_MOTION +;#define APPS_REPORTSENSORS +#define APPS_STATS + + + +; --------------------------------------------------------------------------- +; defines for values + +.equ VALUE_ID_SI7021_TEMP = 0x01 +.equ VALUE_ID_SI7021_HUM = 0x02 + +.equ VALUE_ID_ADC = 0x03 +;.equ VALUE_ID_DS18B20_TEMP = 0x06 +.equ VALUE_ID_MOTION = 0x07 + +.equ VALUE_ID_SGP40_TVOC = 0x08 + +.equ VALUE_ID_SGP30_TVOC = 0x09 +.equ VALUE_ID_SGP30_CO2 = 0x0a + +.equ VALUE_ID_BRIGHTNESS = 0x0b + +;.equ VALUE_ID_REED_CONF = 0x81 + +.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 + rjmp com2wPcintIsr ; 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 +.equ netInterfaceData = com2w0_iface + + + diff --git a/avr/modules/com2w/defs.asm b/avr/modules/com2w/defs.asm index 0fd5c39..5837e1d 100644 --- a/avr/modules/com2w/defs.asm +++ b/avr/modules/com2w/defs.asm @@ -44,7 +44,8 @@ .equ COM2W_BUFFER_SIZE = NET_BUFFERS_SIZE-1 - +.equ COM2W_IO_RINGBUFFER_SIZE = 32 +.equ COM2W_IO_FLAGS_BIT_OVR = 7 .equ COM2W_MODE_IDLE = 0 .equ COM2W_MODE_READING = 1 @@ -54,15 +55,18 @@ .equ COM2W_IFACE_OFFS_BEGIN = NET_IFACE_SIZE -.equ COM2W_IFACE_OFFS_CURRBYTE = COM2W_IFACE_OFFS_BEGIN -.equ COM2W_IFACE_OFFS_BITCOUNTER = COM2W_IFACE_OFFS_BEGIN+1 -.equ COM2W_IFACE_OFFS_MODE = COM2W_IFACE_OFFS_BEGIN+2 -.equ COM2W_IFACE_OFFS_MODECOUNTER = COM2W_IFACE_OFFS_BEGIN+3 -.equ COM2W_IFACE_OFFS_BUFPOS_LOW = COM2W_IFACE_OFFS_BEGIN+4 -.equ COM2W_IFACE_OFFS_BUFPOS_HIGH = COM2W_IFACE_OFFS_BEGIN+5 -.equ COM2W_IFACE_OFFS_BUFUSED = COM2W_IFACE_OFFS_BEGIN+6 -.equ COM2W_IFACE_OFFS_BUFLEFT = COM2W_IFACE_OFFS_BEGIN+7 -.equ COM2W_IFACE_OFFS_BUFFER = COM2W_IFACE_OFFS_BEGIN+8 +.equ COM2W_IFACE_OFFS_PINMASK_CLK = COM2W_IFACE_OFFS_BEGIN +.equ COM2W_IFACE_OFFS_PINMASK_DATA = COM2W_IFACE_OFFS_BEGIN+1 +.equ COM2W_IFACE_OFFS_PINMASK_IRQ = COM2W_IFACE_OFFS_BEGIN+2 +.equ COM2W_IFACE_OFFS_CURRBYTE = COM2W_IFACE_OFFS_BEGIN+3 +.equ COM2W_IFACE_OFFS_BITCOUNTER = COM2W_IFACE_OFFS_BEGIN+4 +.equ COM2W_IFACE_OFFS_MODE = COM2W_IFACE_OFFS_BEGIN+5 +.equ COM2W_IFACE_OFFS_MODECOUNTER = COM2W_IFACE_OFFS_BEGIN+6 +.equ COM2W_IFACE_OFFS_BUFPOS_LOW = COM2W_IFACE_OFFS_BEGIN+7 +.equ COM2W_IFACE_OFFS_BUFPOS_HIGH = COM2W_IFACE_OFFS_BEGIN+8 +.equ COM2W_IFACE_OFFS_BUFUSED = COM2W_IFACE_OFFS_BEGIN+9 +.equ COM2W_IFACE_OFFS_BUFLEFT = COM2W_IFACE_OFFS_BEGIN+10 +.equ COM2W_IFACE_OFFS_BUFFER = COM2W_IFACE_OFFS_BEGIN+11 .equ COM2W_IFACE_SIZE = COM2W_IFACE_OFFS_BUFFER+COM2W_BUFFER_SIZE From 8c13f9fdf7d2474e64a8237a5c2d0a9e713f7030 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 3 Aug 2025 00:55:52 +0200 Subject: [PATCH 123/196] avr: started adding com2wn module (multiple com2w devices in one) --- avr/modules/com2w/com2wn_data.asm | 59 ++++++ avr/modules/com2w/com2wn_init.asm | 112 ++++++++++++ avr/modules/com2w/com2wn_io.asm | 165 +++++++++++++++++ avr/modules/com2w/com2wn_irq.asm | 165 +++++++++++++++++ avr/modules/com2w/com2wn_recv.asm | 242 +++++++++++++++++++++++++ avr/modules/com2w/com2wn_run.asm | 289 ++++++++++++++++++++++++++++++ avr/modules/com2w/com2wn_send.asm | 154 ++++++++++++++++ avr/modules/com2w/com2wn_wait.asm | 119 ++++++++++++ 8 files changed, 1305 insertions(+) create mode 100644 avr/modules/com2w/com2wn_data.asm create mode 100644 avr/modules/com2w/com2wn_init.asm create mode 100644 avr/modules/com2w/com2wn_io.asm create mode 100644 avr/modules/com2w/com2wn_irq.asm create mode 100644 avr/modules/com2w/com2wn_recv.asm create mode 100644 avr/modules/com2w/com2wn_run.asm create mode 100644 avr/modules/com2w/com2wn_send.asm create mode 100644 avr/modules/com2w/com2wn_wait.asm diff --git a/avr/modules/com2w/com2wn_data.asm b/avr/modules/com2w/com2wn_data.asm new file mode 100644 index 0000000..6b92875 --- /dev/null +++ b/avr/modules/com2w/com2wn_data.asm @@ -0,0 +1,59 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + +#ifndef AVR_MODULES_COM2W_COM2WN_DATA_H +#define AVR_MODULES_COM2W_COM2WN_DATA_H + + +.dseg + + +com2wnIoRingBuffer: .byte RINGBUFFERY_SIZE+COM2WN_IO_RINGBUFFER_SIZE +com2wnIoCurrentClockStates: .byte 1 +com2wnIoLastClockStates: .byte 1 +com2wnIoFlags: .byte 1 + + +.if COM_PORTS >0 +com2w0_iface: .byte COM2W_IFACE_SIZE +.endif + +.if COM_PORTS >1 +com2w1_iface: .byte COM2W_IFACE_SIZE +.endif + +.if COM_PORTS >2 +com2w2_iface: .byte COM2W_IFACE_SIZE +.endif + +.if COM_PORTS >3 +com2w3_iface: .byte COM2W_IFACE_SIZE +.endif + +.if COM_PORTS >4 +com2w4_iface: .byte COM2W_IFACE_SIZE +.endif + +.if COM_PORTS >5 +com2w5_iface: .byte COM2W_IFACE_SIZE +.endif + +.if COM_PORTS >6 +com2w6_iface: .byte COM2W_IFACE_SIZE +.endif + +.if COM_PORTS >7 +com2w7_iface: .byte COM2W_IFACE_SIZE +.endif + + + + +#endif ; AVR_MODULES_COM2W_COM2WN_DATA_H + diff --git a/avr/modules/com2w/com2wn_init.asm b/avr/modules/com2w/com2wn_init.asm new file mode 100644 index 0000000..897253d --- /dev/null +++ b/avr/modules/com2w/com2wn_init.asm @@ -0,0 +1,112 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + +#ifndef AVR_MODULES_COM2W_COM2WN_INIT_H +#define AVR_MODULES_COM2W_COM2WN_INIT_H + + +; WORK IN PROGRESS + + +; --------------------------------------------------------------------------- +; @macro mCOM2WN_INIT +; +; @param @0 interface number (beginning with 0) + +.macro mCOM2WN_INIT + ldi yl, LOW(com2w@0_iface) + ldi yh, HIGH(com2w@0_iface) + rcall com2wnInit + ldi r16, COM_MASK_CLK@0 + std Y+COM2W_IFACE_OFFS_PINMASK_CLK, r16 + ldi r16, COM_MASK_DATA@0 + std Y+COM2W_IFACE_OFFS_PINMASK_DATA, r16 + ldi r16, COM_MASK_IRQ@0 + std Y+COM2W_IFACE_OFFS_PINMASK_IRQ, r16 +.endmacro +; @end + + + + + +.cseg + + + +; --------------------------------------------------------------------------- +; @routine COM2WN_Init +; + +COM2WN_Init: + ldi r16, 0xff ; start with all clock lines hi + sts com2wnIoCurrentClockStates, r16 + sts com2wnIoLastClockStates, r16 + + clr r16 + sts com2wnIoFlags, r16 + + ldi yl, LOW(com2wnIoRingBuffer) + ldi yh, HIGH(com2wnIoRingBuffer) + ldi r16, COM2WN_IO_RINGBUFFER_SIZE + rcall RingBufferY_Init ; (R17) + +.if COM_PORTS >0 + mCOM2WN_INIT 0 +.endif +.if COM_PORTS >1 + mCOM2WN_INIT 1 +.endif + +.if COM_PORTS >2 + mCOM2WN_INIT 2 +.endif +.if COM_PORTS >3 + mCOM2WN_INIT 3 +.endif + +.if COM_PORTS >4 + mCOM2WN_INIT 4 +.endif +.if COM_PORTS >5 + mCOM2WN_INIT 5 +.endif + +.if COM_PORTS >6 + mCOM2WN_INIT 6 +.endif +.if COM_PORTS >7 + mCOM2WN_INIT 7 +.endif + + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine com2wInit +; + +com2wnInit: + rcall NET_Interface_Init ; (R16, R17, X) + ldi r16, COM2W_MODE_IDLE + rcall com2wSetMode ; (R17) + + rcall com2wSetupLines + rcall com2wSetupIrq + + ret +; @end + + + +#endif ; AVR_MODULES_COM2W_COM2WN_INIT_H + + diff --git a/avr/modules/com2w/com2wn_io.asm b/avr/modules/com2w/com2wn_io.asm new file mode 100644 index 0000000..9cf78a5 --- /dev/null +++ b/avr/modules/com2w/com2wn_io.asm @@ -0,0 +1,165 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + +#ifndef AVR_MODULES_COM2W_COM2WN_IO_H +#define AVR_MODULES_COM2W_COM2WN_IO_H + + +; WORK IN PROGRESS + + +.cseg + + + +; --------------------------------------------------------------------------- +; @routine com2wSetupLines + +com2wSetupLines: + ; setup CLK line (as input, disable internal pull-up resistor) + rcall com2wClkSetHigh + +.ifdef COM_CLK_PUE + ldd r16, Y+COM2W_IFACE_OFFS_PINMASK_CLK + com r16 + inr r17, COM_CLK_PUE + and r17, r16 + outr COM_CLK_PUE, r17 +.endif + + ; setup DATA line (as input, disable internal pull-up resistor) + rcall com2wDataSetHigh +.ifdef COM_DATA_PUE + ldd r16, Y+COM2W_IFACE_OFFS_PINMASK_DATA + com r16 + inr r17, COM_DATA_PUE + and r17, r16 + outr COM_DATA_PUE, r17 +.endif + + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine com2wClkSetHigh +; +; @clobbers none + +com2wClkSetHigh: + push r16 + push r17 + ldd r16, Y+COM2W_IFACE_OFFS_PINMASK_CLK + ; clear bit in io reg (AND with complement) + com r16 + inr r17, COM_CLK_DDR + and r17, r16 + outr COM_CLK_DDR, r17 ; make pin input +.ifndef COM_CLK_PUE + inr r17, COM_CLK_OUTPUT + and r17, r16 ; disable pullup + outr COM_CLK_OUTPUT, r17 +.endif + pop r17 + pop r16 + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine com2wClkSetLow +; +; @param Y pointer to interface data in SRAM +; @clobbers none + +com2wClkSetLow: + push r16 + push r17 + ldd r16, Y+COM2W_IFACE_OFFS_PINMASK_CLK + ; set bit in io reg + inr r17, COM_CLK_DDR + or r17, r16 + outr COM_CLK_DDR, r17 ; make pin output + + com r16 + inr r17, COM_CLK_OUTPUT + and r17, r16 + outr COM_CLK_OUTPUT, r17 ; set pin low + + pop r17 + pop r16 + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine com2wDataSetHigh +; +; @param Y pointer to interface data in SRAM +; @clobbers none + +com2wDataSetHigh: + push r16 + push r17 + ldd r16, Y+COM2W_IFACE_OFFS_PINMASK_DATA + ; clear bit in io reg (AND with complement) + com r16 + inr r17, COM_DATA_DDR + and r17, r16 + outr COM_DATA_DDR, r17 ; make pin input +.ifndef COM_DATA_PUE + inr r17, COM_DATA_OUTPUT + and r17, r16 ; disable pullup + outr COM_DATA_OUTPUT, r17 +.endif + pop r17 + pop r16 + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine com2wDataSetLow +; +; @param Y pointer to interface data in SRAM +; @clobbers none + +com2wDataSetLow: + push r16 + push r17 + ldd r16, Y+COM2W_IFACE_OFFS_PINMASK_DATA + ; set bit in io reg + inr r17, COM_DATA_DDR + or r17, r16 + outr COM_DATA_DDR, r17 ; make pin output + + com r16 + inr r17, COM_DATA_OUTPUT + and r17, r16 + outr COM_DATA_OUTPUT, r17 ; set pin low + + pop r17 + pop r16 + ret +; @end + + + + + + + + + +#endif ; AVR_MODULES_COM2W_COM2WN_IO_H + diff --git a/avr/modules/com2w/com2wn_irq.asm b/avr/modules/com2w/com2wn_irq.asm new file mode 100644 index 0000000..b2e5f9e --- /dev/null +++ b/avr/modules/com2w/com2wn_irq.asm @@ -0,0 +1,165 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + +#ifndef AVR_MODULES_COM2W_COM2WN_IRQ_H +#define AVR_MODULES_COM2W_COM2WN_IRQ_H + + +.cseg + + + +; --------------------------------------------------------------------------- +; @routine com2wnSetupIrq +; + +com2wnSetupIrq: + ; setup pin-change interrupt for CLK + rcall com2wnEnableClkIrq + + ; enable and clear PCIE0/1 (@TODO put later into general setup) + inr r16, GIMSK ; enable pin change irq PCIE0 or PCIE1 + sbr r16, (1< Date: Sun, 3 Aug 2025 00:56:22 +0200 Subject: [PATCH 124/196] started working on mqtt support in aqhome-nodes --- apps/aqhome-nodes/0BUILD | 2 + apps/aqhome-nodes/main.c | 15 ++ apps/aqhome-nodes/r_publish.c | 34 +++ apps/aqhome-nodes/r_publish.h | 28 +++ apps/aqhome-nodes/server.c | 396 ++++++++++++++++++++++++++++++++-- apps/aqhome-nodes/server.h | 9 + apps/aqhome-nodes/server_p.h | 13 ++ 7 files changed, 481 insertions(+), 16 deletions(-) create mode 100644 apps/aqhome-nodes/r_publish.c create mode 100644 apps/aqhome-nodes/r_publish.h diff --git a/apps/aqhome-nodes/0BUILD b/apps/aqhome-nodes/0BUILD index 243ce46..402448b 100644 --- a/apps/aqhome-nodes/0BUILD +++ b/apps/aqhome-nodes/0BUILD @@ -44,6 +44,7 @@ r_forward.h r_setaccmsggrps.h r_getnodes.h + r_publish.h server.h server_p.h @@ -59,6 +60,7 @@ r_forward.c r_setaccmsggrps.c r_getnodes.c + r_publish.c main.c diff --git a/apps/aqhome-nodes/main.c b/apps/aqhome-nodes/main.c index 0d6fc9e..0c919d7 100644 --- a/apps/aqhome-nodes/main.c +++ b/apps/aqhome-nodes/main.c @@ -36,6 +36,7 @@ #define CONNCLEAN_INTERVAL_IN_SECS 2 #define CONNCHECK_INTERVAL_IN_SECS 10 +#define PING_INTERVAL_IN_SECS 120 @@ -133,11 +134,13 @@ void _runService(AQH_OBJECT *aqh, AQH_EVENT_LOOP *eventLoop) int timeout; time_t timeLastConnectionCleanup; time_t timeLastConnCheck; + time_t timeLastPingSend; timeout=AQH_NodeServer_GetTimeout(aqh); timeStart=time(NULL); timeLastConnectionCleanup=time(NULL); timeLastConnCheck=time(NULL); + timeLastPingSend=time(NULL); while(!stopService) { time_t now; @@ -146,6 +149,7 @@ void _runService(AQH_OBJECT *aqh, AQH_EVENT_LOOP *eventLoop) AQH_NodeServer_HandleTtyMsgs(aqh); AQH_NodeServer_HandleClientMsgs(aqh); AQH_NodeServer_HandleBrokerMsgs(aqh); + AQH_NodeServer_HandleMqttMsgs(aqh); now=time(NULL); @@ -159,9 +163,20 @@ void _runService(AQH_OBJECT *aqh, AQH_EVENT_LOOP *eventLoop) DBG_INFO(NULL, "Check connections"); AQH_NodeServer_CheckBrokerConnection(aqh); AQH_NodeServer_CheckTtyConnection(aqh); + AQH_NodeServer_CheckMqttConnection(aqh); timeLastConnCheck=now; } + if (_diffInSeconds(now, timeLastPingSend)>PING_INTERVAL_IN_SECS) { + int rv; + + rv=AQH_NodeServer_SendPing(aqh); + if (rv<0) { + DBG_INFO(NULL, "Error sending PING"); + } + timeLastPingSend=time(NULL); + } + if (timeout && (_diffInSeconds(now, timeStart)>timeout)) { DBG_INFO(NULL, "Timeout"); break; diff --git a/apps/aqhome-nodes/r_publish.c b/apps/aqhome-nodes/r_publish.c new file mode 100644 index 0000000..897fac4 --- /dev/null +++ b/apps/aqhome-nodes/r_publish.c @@ -0,0 +1,34 @@ +/**************************************************************************** + * This file is part of the project AqHome. + * AqHome (c) by 2025 Martin Preuss, all rights reserved. + * + * The license for this file can be found in the file COPYING which you + * should have received along with this file. + ****************************************************************************/ + +#ifdef HAVE_CONFIG_H +# include +#endif + + +#include "./r_publish.h" +#include "./server_p.h" +#include "aqhome/ipc2/endpoint.h" +#include + +#include + + + +/* ------------------------------------------------------------------------------------------------ + * code + * ------------------------------------------------------------------------------------------------ + */ + +void AQH_NodeServer_HandlePublishMsg(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg) +{ + +} + + + diff --git a/apps/aqhome-nodes/r_publish.h b/apps/aqhome-nodes/r_publish.h new file mode 100644 index 0000000..b68046e --- /dev/null +++ b/apps/aqhome-nodes/r_publish.h @@ -0,0 +1,28 @@ +/**************************************************************************** + * This file is part of the project AqHome. + * AqHome (c) by 2025 Martin Preuss, all rights reserved. + * + * The license for this file can be found in the file COPYING which you + * should have received along with this file. + ****************************************************************************/ + +#ifndef AQHOMED_R_PUBLISH_H +#define AQHOMED_R_PUBLISH_H + + +#include "./server.h" + +#include +#include + + +void AQH_NodeServer_HandlePublishMsg(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg); + + + + + + +#endif + + diff --git a/apps/aqhome-nodes/server.c b/apps/aqhome-nodes/server.c index 320f612..8a3f3a7 100644 --- a/apps/aqhome-nodes/server.c +++ b/apps/aqhome-nodes/server.c @@ -18,6 +18,7 @@ #include "./r_forward.h" #include "./r_setaccmsggrps.h" #include "./r_getnodes.h" +#include "./r_publish.h" #include #include @@ -41,6 +42,14 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -70,13 +79,15 @@ #define AQH_NODE_SERVER_BROKER_RESTARTTIME 10 #define AQH_NODE_SERVER_TTY_RESTARTTIME 10 +#define AQH_NODE_SERVER_MQTT_RESTARTTIME 10 enum { AQH_NODE_SERVER_SLOT_NEWCLIENT=1, AQH_NODE_SERVER_SLOT_CLIENTCLOSED, AQH_NODE_SERVER_SLOT_BROKERCLOSED, - AQH_NODE_SERVER_SLOT_TTYCLOSED + AQH_NODE_SERVER_SLOT_TTYCLOSED, + AQH_NODE_SERVER_SLOT_MQTTCLOSED, }; @@ -97,13 +108,17 @@ GWEN_INHERIT(AQH_OBJECT, AQH_NODE_SERVER) static void GWENHYWFAR_CB _freeData(void *bp, void *p); static void _readConfig(AQH_OBJECT *o, AQH_NODE_SERVER *xo, GWEN_DB_NODE *dbArgs); -static const char *readCharConfigWithAlt(GWEN_DB_NODE *dbArgs, const char *varName, const char *altVarName, const char *defaultValue); -static int readIntConfigWithAlt(GWEN_DB_NODE *dbArgs, const char *varName, const char *altVarName, int defaultValue, int nonValue); +static const char *_readCharConfigWithAlt(GWEN_DB_NODE *dbArgs, const char *varName, const char *altVarName, const char *defaultValue); +static int _readIntConfigWithAlt(GWEN_DB_NODE *dbArgs, const char *varName, const char *altVarName, int defaultValue, int nonValue); static int _startIpc(AQH_OBJECT *o, AQH_NODE_SERVER *xo); static int _startTty(AQH_OBJECT *o, AQH_NODE_SERVER *xo); static int _startBroker(AQH_OBJECT *o, AQH_NODE_SERVER *xo); static int _exchangeConnect(AQH_NODE_SERVER *xo, uint32_t flags); +static int _startMqtt(AQH_OBJECT *o, AQH_NODE_SERVER *xo); +static int _exchangeMqttConnect(AQH_NODE_SERVER *xo); +static int _exchangeMqttSubscribe(AQH_NODE_SERVER *xo); + static void _setupDb(AQH_NODE_SERVER *xo); static int _loadDeviceList(AQH_NODE_SERVER *xo); @@ -112,11 +127,15 @@ static int _handleNewIpcClient(AQH_OBJECT *o, AQH_NODE_SERVER *xo, AQH_OBJECT *c static int _handleIpcClientDown(AQH_OBJECT *clientEndpoint); static int _handleBrokerDown(AQH_NODE_SERVER *xo); static int _handleTtyDown(AQH_NODE_SERVER *xo); +static int _handleMqttDown(AQH_NODE_SERVER *xo); static void _handleMsgsFromClient(AQH_OBJECT *o, AQH_NODE_SERVER *xo, AQH_OBJECT *ep); static void _handleMsgFromClient(AQH_OBJECT *o, AQH_NODE_SERVER *xo, AQH_OBJECT *ep, const AQH_MESSAGE *msg); - +static void _handleMsgFromMqtt(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg); static void _handleMsgFromTty(AQH_OBJECT *o, AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg); +static void _handleMqttMsgPingRsp(void); + + static void _writeTtyMsgToLogFile(AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg); static void _forwardTtyMsgToBroker(AQH_OBJECT *o, AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg); static void _forwardValueMessageToBroker(AQH_OBJECT *o, AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg); @@ -178,6 +197,7 @@ void GWENHYWFAR_CB _freeData(GWEN_UNUSED void *bp, void *p) AQH_Object_free(xo->ipcEndpoint); AQH_Object_free(xo->ttyEndpoint); AQH_Object_free(xo->brokerEndpoint); + AQH_Object_free(xo->mqttEndpoint); AQHNODE_Device_List_free(xo->deviceDefList); GWEN_DB_Group_free(xo->dbArgs); AQH_MsgRequest_free(xo->requestTree); @@ -190,6 +210,9 @@ void GWENHYWFAR_CB _freeData(GWEN_UNUSED void *bp, void *p) free(xo->tcpAddress); free(xo->brokerAddress); free(xo->brokerClientId); + free(xo->mqttAddress); + free(xo->mqttClientId); + free(xo->mqttDiscoveryPrefix); GWEN_FREE_OBJECT(xo); } @@ -361,6 +384,81 @@ void AQH_NodeServer_SetBrokerClientId(AQH_OBJECT *o, const char *s) +void AQH_NodeServer_SetMqttAddress(AQH_OBJECT *o, const char *s) +{ + if (o) { + AQH_NODE_SERVER *xo; + + xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_NODE_SERVER, o); + if (xo) { + free(xo->mqttAddress); + xo->mqttAddress=s?strdup(s):NULL; + } + } +} + + +void AQH_NodeServer_SetMqttPort(AQH_OBJECT *o, int i) +{ + if (o) { + AQH_NODE_SERVER *xo; + + xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_NODE_SERVER, o); + if (xo) { + xo->mqttPort=i; + } + } +} + + + +void AQH_NodeServer_SetMqttClientId(AQH_OBJECT *o, const char *s) +{ + if (o) { + AQH_NODE_SERVER *xo; + + xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_NODE_SERVER, o); + if (xo) { + free(xo->mqttClientId); + xo->mqttClientId=s?strdup(s):NULL; + } + } +} + + + +void AQH_NodeServer_SetMqttKeepAlive(AQH_OBJECT *o, int i) +{ + if (o) { + AQH_NODE_SERVER *xo; + + xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_NODE_SERVER, o); + if (xo) { + xo->mqttKeepAlive=i; + } + } +} + + + +void AQH_NodeServer_SetMqttDiscoveryPrefix(AQH_OBJECT *o, const char *s) +{ + if (o) { + AQH_NODE_SERVER *xo; + + xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_NODE_SERVER, o); + if (xo) { + free(xo->mqttDiscoveryPrefix); + xo->mqttDiscoveryPrefix=s?strdup(s):NULL; + } + } +} + + + + + + /* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx @@ -427,12 +525,25 @@ int AQH_NodeServer_Init(AQH_OBJECT *o, int argc, char **argv) DBG_INFO(NULL, "here (%d)", rv); return rv; } - DBG_INFO(NULL, "Starting Broker Connection"); - rv=_startBroker(o, xo); - if (rv<0) { - DBG_INFO(NULL, "here (%d)", rv); - return rv; + + if (xo->flags & AQHOMED_FLAGS_START_BROKER) { + DBG_INFO(NULL, "Starting Broker Connection"); + rv=_startBroker(o, xo); + if (rv<0) { + DBG_INFO(NULL, "here (%d)", rv); + return rv; + } } + + if (xo->flags & AQHOMED_FLAGS_START_MQTT) { + DBG_INFO(NULL, "Starting MQTT Connection"); + rv=_startMqtt(o, xo); + if (rv<0) { + DBG_INFO(NULL, "here (%d)", rv); + return rv; + } + } + return 0; } else { @@ -450,23 +561,31 @@ void _readConfig(AQH_OBJECT *o, AQH_NODE_SERVER *xo, GWEN_DB_NODE *dbArgs) xo->timeout=GWEN_DB_GetIntValue(dbArgs, "timeout", 0, 0); xo->noAttn=GWEN_DB_GetIntValue(dbArgs, "noAttn", 0, 0); xo->nodeAddress=GWEN_DB_GetIntValue(dbArgs, "nodeAddress", 0, AQHOMED_DEFAULT_NODEADDR); + xo->flags|=GWEN_DB_GetIntValue(dbArgs, "startBroker", 0, 1)?AQHOMED_FLAGS_START_BROKER:0; + xo->flags|=GWEN_DB_GetIntValue(dbArgs, "startMqtt", 0, 0)?AQHOMED_FLAGS_START_MQTT:0; AQH_NodeServer_SetDbFile(o, GWEN_DB_GetCharValue(dbArgs, "dbfile", 0, NULL)); AQH_NodeServer_SetLogFile(o, GWEN_DB_GetCharValue(dbArgs, "logfile", 0, NULL)); AQH_NodeServer_SetDevicePath(o, GWEN_DB_GetCharValue(dbArgs, "device", 0, AQHOMED_DEFAULT_DEVICE)); - AQH_NodeServer_SetTpcAddress(o, readCharConfigWithAlt(dbArgs, "tcpAddress", "ConfigFile/nodesAddress", NULL)); - AQH_NodeServer_SetTcpPort(o, readIntConfigWithAlt(dbArgs, "tcpPort", "ConfigFile/nodesPort", AQHOMED_DEFAULT_IPC_PORT, -1)); + AQH_NodeServer_SetTpcAddress(o, _readCharConfigWithAlt(dbArgs, "tcpAddress", "ConfigFile/nodesAddress", NULL)); + AQH_NodeServer_SetTcpPort(o, _readIntConfigWithAlt(dbArgs, "tcpPort", "ConfigFile/nodesPort", AQHOMED_DEFAULT_IPC_PORT, -1)); - AQH_NodeServer_SetBrokerAddress(o, readCharConfigWithAlt(dbArgs, "brokerAddress", "ConfigFile/brokerAddress", "127.0.0.1")); - AQH_NodeServer_SetBrokerPort(o, readIntConfigWithAlt(dbArgs, "brokerPort", "ConfigFile/brokerPort", AQHOMED_DEFAULT_BROKER_PORT, -1)); + AQH_NodeServer_SetBrokerAddress(o, _readCharConfigWithAlt(dbArgs, "brokerAddress", "ConfigFile/brokerAddress", "127.0.0.1")); + AQH_NodeServer_SetBrokerPort(o, _readIntConfigWithAlt(dbArgs, "brokerPort", "ConfigFile/brokerPort", AQHOMED_DEFAULT_BROKER_PORT, -1)); AQH_NodeServer_SetBrokerClientId(o, GWEN_DB_GetCharValue(dbArgs, "brokerClientId", 0, AQHOMED_DEFAULT_BROKER_CLIENTID)); + AQH_NodeServer_SetMqttAddress(o, _readCharConfigWithAlt(dbArgs, "mqttAddress", "ConfigFile/mqttAddr", "127.0.0.1")); + AQH_NodeServer_SetMqttPort(o, _readIntConfigWithAlt(dbArgs, "mqttPort", "ConfigFile/mqttPort", 1883, -1)); + AQH_NodeServer_SetMqttClientId(o, _readCharConfigWithAlt(dbArgs, "mqttClientId", "ConfigFile/mqttClientId", "aqhome-mqtt")); + AQH_NodeServer_SetMqttKeepAlive(o, _readIntConfigWithAlt(dbArgs, "mqttKeepAlive", "ConfigFile/mqttKeepAlive", 600, -1)); + AQH_NodeServer_SetMqttDiscoveryPrefix(o, _readCharConfigWithAlt(dbArgs, "mqttDiscovery", "ConfigFile/mqttDiscovery", "homeassistant")); + } -const char *readCharConfigWithAlt(GWEN_DB_NODE *dbArgs, const char *varName, const char *altVarName, const char *defaultValue) +const char *_readCharConfigWithAlt(GWEN_DB_NODE *dbArgs, const char *varName, const char *altVarName, const char *defaultValue) { const char *s; @@ -478,7 +597,7 @@ const char *readCharConfigWithAlt(GWEN_DB_NODE *dbArgs, const char *varName, con -int readIntConfigWithAlt(GWEN_DB_NODE *dbArgs, const char *varName, const char *altVarName, int defaultValue, int nonValue) +int _readIntConfigWithAlt(GWEN_DB_NODE *dbArgs, const char *varName, const char *altVarName, int defaultValue, int nonValue) { int i; @@ -615,6 +734,132 @@ int _exchangeConnect(AQH_NODE_SERVER *xo, uint32_t flags) + + + +int _startMqtt(AQH_OBJECT *o, AQH_NODE_SERVER *xo) +{ + if (xo->mqttEndpoint) { + AQH_Object_Disable(xo->mqttEndpoint); + AQH_Object_free(xo->mqttEndpoint); + xo->mqttEndpoint=NULL; + } + + if (xo->mqttAddress && *(xo->mqttAddress) && xo->mqttPort) { + AQH_OBJECT *ep; + int fd; + int rv; + + fd=AQH_TcpObject_CreateConnectedSocket(xo->mqttAddress, xo->mqttPort); + if (fd<0) { + DBG_ERROR(NULL, "Error connecting to MQTT server %s:%d", xo->mqttAddress, xo->mqttPort); + return GWEN_ERROR_IO; + } + DBG_INFO(NULL, "Physically connected to MQTT server %s:%d", xo->mqttAddress, xo->mqttPort); + + ep=AQH_MqttClientObject_new(AQH_Object_GetEventLoop(o), fd); + assert(ep); + AQH_Endpoint_SetServiceName(ep, xo->mqttClientId); + AQH_Object_AddLink(ep, AQH_ENDPOINT_SIGNAL_CLOSED, AQH_NODE_SERVER_SLOT_MQTTCLOSED, o); + AQH_Object_Enable(ep); + xo->mqttEndpoint=ep; + + rv=_exchangeMqttConnect(xo); + if (rv!=0) { + DBG_ERROR(NULL, "MQTT: Error exchanging CONNECT request (%d)", rv); + return (rv<0)?rv:GWEN_ERROR_PERMISSIONS; + } + + rv=_exchangeMqttSubscribe(xo); + if (rv!=0) { + DBG_ERROR(NULL, "MQTT: Error exchanging SUBSCRIBE request (%d)", rv); + return (rv<0)?rv:GWEN_ERROR_PERMISSIONS; + } + + DBG_NOTICE(NULL, "Connected to MQTT at %s:%d", xo->mqttAddress, xo->mqttPort); + return 0; + } + else { + DBG_ERROR(NULL, "No MQTT server settings"); + return GWEN_ERROR_BAD_DATA; + } + + return 0; +} + + + +int _exchangeMqttConnect(AQH_NODE_SERVER *xo) +{ + AQH_MESSAGE *msg; + + msg=AQH_MqttMessageConnect_new("MQTT", 0x04, 0, xo->mqttKeepAlive, xo->mqttClientId, NULL, NULL); + AQH_Endpoint_AddMsgOut(xo->mqttEndpoint, msg); + + msg=AQH_MqttEndpoint_WaitForConnAckMsg(xo->mqttEndpoint, xo->timeoutInSeconds); + if (msg) { + int resultCode; + + resultCode=AQH_MqttMessageConnAck_GetResultCode(msg); + AQH_Message_free(msg); + if (resultCode==AQH_MQTTMSG_CONNACK_RESULT_ACCEPTED) { + DBG_INFO(AQH_LOGDOMAIN, "Positive CONNACK response"); + return 0; + } + else { + DBG_ERROR(NULL, "Negative CONNACK response: %d", resultCode); + return GWEN_ERROR_GENERIC; + } + } + else { + DBG_ERROR(NULL, "No CONNACK message received."); + return GWEN_ERROR_GENERIC; + } +} + + + +int _exchangeMqttSubscribe(AQH_NODE_SERVER *xo) +{ + uint16_t pckId; + AQH_MESSAGE *msg; + + pckId=AQH_Endpoint_GetNextMessageId(xo->mqttEndpoint); + msg=AQH_MqttMessageSubscribe_new(0, pckId, "#", 0); + AQH_Endpoint_AddMsgOut(xo->mqttEndpoint, msg); + + msg=AQH_MqttEndpoint_WaitForMsg(xo->mqttEndpoint, AQH_MQTTMSG_MSGTYPE_SUBACK, xo->timeoutInSeconds); + if (msg) { + int resultCode; + + resultCode=AQH_MqttMessageSubAck_GetResultCode(msg); + AQH_Message_free(msg); + if (resultCode!=128) { + DBG_INFO(AQH_LOGDOMAIN, "Positive SUBACK response"); + return 0; + } + else { + DBG_ERROR(NULL, "Negative SUBACK response: %d", resultCode); + return GWEN_ERROR_GENERIC; + } + } + else { + DBG_ERROR(NULL, "No SUBACK message received."); + return GWEN_ERROR_GENERIC; + } +} + + + + + + + + + + + + void _setupDb(AQH_NODE_SERVER *xo) { if (xo->dbFile) { @@ -1139,7 +1384,7 @@ void AQH_NodeServer_CheckBrokerConnection(AQH_OBJECT *o) AQH_NODE_SERVER *xo; xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_NODE_SERVER, o); - if (xo && xo->dbArgs) { + if (xo && xo->dbArgs && (xo->flags & AQHOMED_FLAGS_START_BROKER)) { if (xo->brokerEndpoint) { if (AQH_Object_GetFlags(xo->brokerEndpoint) & AQH_OBJECT_FLAGS_DELETE) { @@ -1170,6 +1415,106 @@ void AQH_NodeServer_CheckBrokerConnection(AQH_OBJECT *o) + +/* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + * MQTT management functions + * xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + */ + + +void AQH_NodeServer_HandleMqttMsgs(AQH_OBJECT *o) +{ + AQH_NODE_SERVER *xo; + + xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_NODE_SERVER, o); + if (xo && xo->mqttEndpoint) { + AQH_MESSAGE *msg; + + while( (msg=AQH_Endpoint_GetNextMsgIn(xo->mqttEndpoint)) ) { + AQH_Message_SetObject(msg, xo->mqttEndpoint); + _handleMsgFromMqtt(o, xo->mqttEndpoint, msg); + AQH_Message_free(msg); + } + } +} + + + +void _handleMsgFromMqtt(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg) +{ + uint8_t code; + + /* exec IPC message */ + code=AQH_MqttMessage_GetTypeAndFlags(msg); + switch(code & 0xf0) { + case (AQH_MQTTMSG_MSGTYPE_PUBLISH & 0xf0): AQH_NodeServer_HandlePublishMsg(o, ep, msg); break; + case (AQH_MQTTMSG_MSGTYPE_PINGRESP & 0xf0): _handleMqttMsgPingRsp(); break; + default: break; + } +} + + + +void _handleMqttMsgPingRsp(void) +{ + DBG_INFO(NULL, "PING response received"); +} + + + +void AQH_NodeServer_CheckMqttConnection(AQH_OBJECT *o) +{ + AQH_NODE_SERVER *xo; + + xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_NODE_SERVER, o); + if (xo && (xo->flags & AQHOMED_FLAGS_START_MQTT)) { + if (xo->mqttEndpoint) { + if (AQH_Object_GetFlags(xo->mqttEndpoint) & AQH_OBJECT_FLAGS_DELETE) { + DBG_INFO(NULL, "Deleting mqtt connection"); + AQH_Object_Disable(xo->mqttEndpoint); + AQH_Object_free(xo->mqttEndpoint); + xo->mqttEndpoint=NULL; + } + } + + if (xo->mqttEndpoint==NULL) { + time_t now; + + now=time(NULL); + if (_diffInSeconds(now, xo->timestampMqttDown)>AQH_NODE_SERVER_MQTT_RESTARTTIME) { + int rv; + + DBG_INFO(NULL, "Restarting MQTT connection"); + rv=_startMqtt(o, xo); + if (rv<0) { + DBG_ERROR(NULL, "here (%d)", rv); + } + } + } + } +} + + + +int AQH_NodeServer_SendPing(AQH_OBJECT *o) +{ + AQH_NODE_SERVER *xo; + + xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_NODE_SERVER, o); + if (xo && xo->mqttEndpoint) { + AQH_MESSAGE *msgOut; + + DBG_INFO(NULL, "Sending PING"); + msgOut=AQH_MqttMessage_new(AQH_MQTTMSG_MSGTYPE_PINGREQ, 0, NULL); + AQH_Endpoint_AddMsgOut(xo->mqttEndpoint, msgOut); + return 0; + } + return GWEN_ERROR_INVALID; +} + + + + /* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx * request management functions * xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx @@ -1231,6 +1576,7 @@ int _handleSignal(AQH_OBJECT *o, uint32_t slotId, AQH_OBJECT *senderObject, GWEN case AQH_NODE_SERVER_SLOT_CLIENTCLOSED: return _handleIpcClientDown(senderObject); case AQH_NODE_SERVER_SLOT_BROKERCLOSED: return _handleBrokerDown(xo); case AQH_NODE_SERVER_SLOT_TTYCLOSED: return _handleTtyDown(xo); + case AQH_NODE_SERVER_SLOT_MQTTCLOSED: return _handleMqttDown(xo); default: break; } @@ -1284,6 +1630,18 @@ int _handleTtyDown(AQH_NODE_SERVER *xo) +int _handleMqttDown(AQH_NODE_SERVER *xo) +{ + if (xo->mqttEndpoint) { + DBG_WARN(NULL, "MQTT connection down"); + AQH_Object_AddFlags(xo->mqttEndpoint, AQH_OBJECT_FLAGS_DELETE); + xo->timestampMqttDown=time(NULL); + } + return 1; +} + + + /* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx @@ -1411,10 +1769,16 @@ int _readArgs(int argc, char **argv, GWEN_DB_NODE *dbArgs) { A_ARG, A_CHAR, "brokerAddress", 0, 1, "ba", "brokerddress", I18S("Broker address [127.0.0.1]"), NULL}, { A_ARG, A_INT, "brokerPort", 0, 1, "bp", "brokerport", I18S("Broker port [1899]"), NULL}, { A_ARG, A_CHAR, "brokerClientId", 0, 1, NULL, "brokerclientid", I18S("Broker client id"), NULL}, + { A_ARG, A_CHAR, "mqttAddress", 0, 1, "ma", "mqttaddress", I18S("Address of MQTT server"), NULL}, + { A_ARG, A_INT, "mqttPort", 0, 1, "mp", "mqttport", I18S("Port of MQTT server (default: 1883)"), NULL}, + { A_ARG, A_CHAR, "mqttClientId", 0, 1, NULL, "mqttclientid", I18S("MQTT client id"), NULL}, + { A_ARG, A_INT, "mqttKeepAlive", 0, 1, "P", "mqttkeepalive", I18S("MQTT keep-alive time"), NULL}, { A_ARG, A_CHAR, "dbfile", 0, 1, "db", "dbfile", I18S("DB file to read/write node database"), NULL}, { A_ARG, A_CHAR, "pidfile", 0, 1, "p", "pidfile", I18S("PID file"), NULL}, { A_ARG, A_INT, "timeout", 0, 1, "T", NULL, I18S("timeout in seconds [0]"), NULL}, { 0, A_INT, "noAttn", 0, 1, "N", "noattn", I18S("Don't use ATTN line (for T03 or newer)"), NULL}, + { 0, A_INT, "startMqtt", 0, 1, "M", "startMqtt", I18S("Start MQTT connection"), NULL}, + { 0, A_INT, "startBroker", 0, 1, "M", "startBroker", I18S("Start AqHome Broker connection"), NULL}, { A_END, A_INT, "help", 0, 0, "h", "help", I18S("Show this help screen"), NULL} }; diff --git a/apps/aqhome-nodes/server.h b/apps/aqhome-nodes/server.h index a59b7f9..523132d 100644 --- a/apps/aqhome-nodes/server.h +++ b/apps/aqhome-nodes/server.h @@ -57,6 +57,9 @@ void AQH_NodeServer_HandleClientMsgs(AQH_OBJECT *o); void AQH_NodeServer_HandleBrokerMsgs(AQH_OBJECT *o); void AQH_NodeServer_CheckBrokerConnection(AQH_OBJECT *o); void AQH_NodeServer_CheckTtyConnection(AQH_OBJECT *o); +void AQH_NodeServer_HandleMqttMsgs(AQH_OBJECT *o); +void AQH_NodeServer_CheckMqttConnection(AQH_OBJECT *o); +int AQH_NodeServer_SendPing(AQH_OBJECT *o); /* getters and setters */ @@ -72,6 +75,12 @@ void AQH_NodeServer_SetBrokerAddress(AQH_OBJECT *o, const char *s); void AQH_NodeServer_SetBrokerPort(AQH_OBJECT *o, int i); void AQH_NodeServer_SetBrokerClientId(AQH_OBJECT *o, const char *s); +void AQH_NodeServer_SetMqttAddress(AQH_OBJECT *o, const char *s); +void AQH_NodeServer_SetMqttPort(AQH_OBJECT *o, int i); +void AQH_NodeServer_SetMqttClientId(AQH_OBJECT *o, const char *s); +void AQH_NodeServer_SetMqttKeepAlive(AQH_OBJECT *o, int i); +void AQH_NodeServer_SetMqttDiscoveryPrefix(AQH_OBJECT *o, const char *s); + /* device management */ const AQHNODE_DEVICE_LIST *AQH_NodeServer_GetDeviceDefList(const AQH_OBJECT *o); diff --git a/apps/aqhome-nodes/server_p.h b/apps/aqhome-nodes/server_p.h index 8b65a9a..280cc35 100644 --- a/apps/aqhome-nodes/server_p.h +++ b/apps/aqhome-nodes/server_p.h @@ -27,12 +27,16 @@ #define AQHOMED_DEFAULT_BROKER_PORT 1899 #define AQHOMED_DEFAULT_BROKER_CLIENTID "nodes" +#define AQHOMED_FLAGS_START_BROKER 0x00000001 +#define AQHOMED_FLAGS_START_MQTT 0x00000002 + typedef struct AQH_NODE_SERVER AQH_NODE_SERVER; struct AQH_NODE_SERVER { AQH_OBJECT *ttyEndpoint; AQH_OBJECT *brokerEndpoint; + AQH_OBJECT *mqttEndpoint; AQH_OBJECT *ipcEndpoint; AQH_OBJECT_LIST *ipcClientList; @@ -44,6 +48,8 @@ struct AQH_NODE_SERVER { GWEN_DB_NODE *dbArgs; + uint32_t flags; + char *dbFile; char *logFile; char *pidFile; @@ -58,8 +64,15 @@ struct AQH_NODE_SERVER { int brokerPort; char *brokerClientId; + char *mqttAddress; + int mqttPort; + char *mqttClientId; + char *mqttDiscoveryPrefix; + int mqttKeepAlive; + time_t timestampTtyDown; time_t timestampBrokerDown; + time_t timestampMqttDown; int nodeAddress; From 3f2ae9dd03be64c8dbf714af7f1426afd4dcc0dd Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 3 Aug 2025 00:56:46 +0200 Subject: [PATCH 125/196] Revert "started working on mqtt support in aqhome-nodes" This reverts commit 7fbc616ce4ccb28bd52a241fe05d0719046f7ef0. --- apps/aqhome-nodes/0BUILD | 2 - apps/aqhome-nodes/main.c | 15 -- apps/aqhome-nodes/r_publish.c | 34 --- apps/aqhome-nodes/r_publish.h | 28 --- apps/aqhome-nodes/server.c | 396 ++-------------------------------- apps/aqhome-nodes/server.h | 9 - apps/aqhome-nodes/server_p.h | 13 -- 7 files changed, 16 insertions(+), 481 deletions(-) delete mode 100644 apps/aqhome-nodes/r_publish.c delete mode 100644 apps/aqhome-nodes/r_publish.h diff --git a/apps/aqhome-nodes/0BUILD b/apps/aqhome-nodes/0BUILD index 402448b..243ce46 100644 --- a/apps/aqhome-nodes/0BUILD +++ b/apps/aqhome-nodes/0BUILD @@ -44,7 +44,6 @@ r_forward.h r_setaccmsggrps.h r_getnodes.h - r_publish.h server.h server_p.h @@ -60,7 +59,6 @@ r_forward.c r_setaccmsggrps.c r_getnodes.c - r_publish.c main.c diff --git a/apps/aqhome-nodes/main.c b/apps/aqhome-nodes/main.c index 0c919d7..0d6fc9e 100644 --- a/apps/aqhome-nodes/main.c +++ b/apps/aqhome-nodes/main.c @@ -36,7 +36,6 @@ #define CONNCLEAN_INTERVAL_IN_SECS 2 #define CONNCHECK_INTERVAL_IN_SECS 10 -#define PING_INTERVAL_IN_SECS 120 @@ -134,13 +133,11 @@ void _runService(AQH_OBJECT *aqh, AQH_EVENT_LOOP *eventLoop) int timeout; time_t timeLastConnectionCleanup; time_t timeLastConnCheck; - time_t timeLastPingSend; timeout=AQH_NodeServer_GetTimeout(aqh); timeStart=time(NULL); timeLastConnectionCleanup=time(NULL); timeLastConnCheck=time(NULL); - timeLastPingSend=time(NULL); while(!stopService) { time_t now; @@ -149,7 +146,6 @@ void _runService(AQH_OBJECT *aqh, AQH_EVENT_LOOP *eventLoop) AQH_NodeServer_HandleTtyMsgs(aqh); AQH_NodeServer_HandleClientMsgs(aqh); AQH_NodeServer_HandleBrokerMsgs(aqh); - AQH_NodeServer_HandleMqttMsgs(aqh); now=time(NULL); @@ -163,20 +159,9 @@ void _runService(AQH_OBJECT *aqh, AQH_EVENT_LOOP *eventLoop) DBG_INFO(NULL, "Check connections"); AQH_NodeServer_CheckBrokerConnection(aqh); AQH_NodeServer_CheckTtyConnection(aqh); - AQH_NodeServer_CheckMqttConnection(aqh); timeLastConnCheck=now; } - if (_diffInSeconds(now, timeLastPingSend)>PING_INTERVAL_IN_SECS) { - int rv; - - rv=AQH_NodeServer_SendPing(aqh); - if (rv<0) { - DBG_INFO(NULL, "Error sending PING"); - } - timeLastPingSend=time(NULL); - } - if (timeout && (_diffInSeconds(now, timeStart)>timeout)) { DBG_INFO(NULL, "Timeout"); break; diff --git a/apps/aqhome-nodes/r_publish.c b/apps/aqhome-nodes/r_publish.c deleted file mode 100644 index 897fac4..0000000 --- a/apps/aqhome-nodes/r_publish.c +++ /dev/null @@ -1,34 +0,0 @@ -/**************************************************************************** - * This file is part of the project AqHome. - * AqHome (c) by 2025 Martin Preuss, all rights reserved. - * - * The license for this file can be found in the file COPYING which you - * should have received along with this file. - ****************************************************************************/ - -#ifdef HAVE_CONFIG_H -# include -#endif - - -#include "./r_publish.h" -#include "./server_p.h" -#include "aqhome/ipc2/endpoint.h" -#include - -#include - - - -/* ------------------------------------------------------------------------------------------------ - * code - * ------------------------------------------------------------------------------------------------ - */ - -void AQH_NodeServer_HandlePublishMsg(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg) -{ - -} - - - diff --git a/apps/aqhome-nodes/r_publish.h b/apps/aqhome-nodes/r_publish.h deleted file mode 100644 index b68046e..0000000 --- a/apps/aqhome-nodes/r_publish.h +++ /dev/null @@ -1,28 +0,0 @@ -/**************************************************************************** - * This file is part of the project AqHome. - * AqHome (c) by 2025 Martin Preuss, all rights reserved. - * - * The license for this file can be found in the file COPYING which you - * should have received along with this file. - ****************************************************************************/ - -#ifndef AQHOMED_R_PUBLISH_H -#define AQHOMED_R_PUBLISH_H - - -#include "./server.h" - -#include -#include - - -void AQH_NodeServer_HandlePublishMsg(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg); - - - - - - -#endif - - diff --git a/apps/aqhome-nodes/server.c b/apps/aqhome-nodes/server.c index 8a3f3a7..320f612 100644 --- a/apps/aqhome-nodes/server.c +++ b/apps/aqhome-nodes/server.c @@ -18,7 +18,6 @@ #include "./r_forward.h" #include "./r_setaccmsggrps.h" #include "./r_getnodes.h" -#include "./r_publish.h" #include #include @@ -42,14 +41,6 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include #include #include @@ -79,15 +70,13 @@ #define AQH_NODE_SERVER_BROKER_RESTARTTIME 10 #define AQH_NODE_SERVER_TTY_RESTARTTIME 10 -#define AQH_NODE_SERVER_MQTT_RESTARTTIME 10 enum { AQH_NODE_SERVER_SLOT_NEWCLIENT=1, AQH_NODE_SERVER_SLOT_CLIENTCLOSED, AQH_NODE_SERVER_SLOT_BROKERCLOSED, - AQH_NODE_SERVER_SLOT_TTYCLOSED, - AQH_NODE_SERVER_SLOT_MQTTCLOSED, + AQH_NODE_SERVER_SLOT_TTYCLOSED }; @@ -108,17 +97,13 @@ GWEN_INHERIT(AQH_OBJECT, AQH_NODE_SERVER) static void GWENHYWFAR_CB _freeData(void *bp, void *p); static void _readConfig(AQH_OBJECT *o, AQH_NODE_SERVER *xo, GWEN_DB_NODE *dbArgs); -static const char *_readCharConfigWithAlt(GWEN_DB_NODE *dbArgs, const char *varName, const char *altVarName, const char *defaultValue); -static int _readIntConfigWithAlt(GWEN_DB_NODE *dbArgs, const char *varName, const char *altVarName, int defaultValue, int nonValue); +static const char *readCharConfigWithAlt(GWEN_DB_NODE *dbArgs, const char *varName, const char *altVarName, const char *defaultValue); +static int readIntConfigWithAlt(GWEN_DB_NODE *dbArgs, const char *varName, const char *altVarName, int defaultValue, int nonValue); static int _startIpc(AQH_OBJECT *o, AQH_NODE_SERVER *xo); static int _startTty(AQH_OBJECT *o, AQH_NODE_SERVER *xo); static int _startBroker(AQH_OBJECT *o, AQH_NODE_SERVER *xo); static int _exchangeConnect(AQH_NODE_SERVER *xo, uint32_t flags); -static int _startMqtt(AQH_OBJECT *o, AQH_NODE_SERVER *xo); -static int _exchangeMqttConnect(AQH_NODE_SERVER *xo); -static int _exchangeMqttSubscribe(AQH_NODE_SERVER *xo); - static void _setupDb(AQH_NODE_SERVER *xo); static int _loadDeviceList(AQH_NODE_SERVER *xo); @@ -127,15 +112,11 @@ static int _handleNewIpcClient(AQH_OBJECT *o, AQH_NODE_SERVER *xo, AQH_OBJECT *c static int _handleIpcClientDown(AQH_OBJECT *clientEndpoint); static int _handleBrokerDown(AQH_NODE_SERVER *xo); static int _handleTtyDown(AQH_NODE_SERVER *xo); -static int _handleMqttDown(AQH_NODE_SERVER *xo); static void _handleMsgsFromClient(AQH_OBJECT *o, AQH_NODE_SERVER *xo, AQH_OBJECT *ep); static void _handleMsgFromClient(AQH_OBJECT *o, AQH_NODE_SERVER *xo, AQH_OBJECT *ep, const AQH_MESSAGE *msg); -static void _handleMsgFromMqtt(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg); + static void _handleMsgFromTty(AQH_OBJECT *o, AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg); -static void _handleMqttMsgPingRsp(void); - - static void _writeTtyMsgToLogFile(AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg); static void _forwardTtyMsgToBroker(AQH_OBJECT *o, AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg); static void _forwardValueMessageToBroker(AQH_OBJECT *o, AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg); @@ -197,7 +178,6 @@ void GWENHYWFAR_CB _freeData(GWEN_UNUSED void *bp, void *p) AQH_Object_free(xo->ipcEndpoint); AQH_Object_free(xo->ttyEndpoint); AQH_Object_free(xo->brokerEndpoint); - AQH_Object_free(xo->mqttEndpoint); AQHNODE_Device_List_free(xo->deviceDefList); GWEN_DB_Group_free(xo->dbArgs); AQH_MsgRequest_free(xo->requestTree); @@ -210,9 +190,6 @@ void GWENHYWFAR_CB _freeData(GWEN_UNUSED void *bp, void *p) free(xo->tcpAddress); free(xo->brokerAddress); free(xo->brokerClientId); - free(xo->mqttAddress); - free(xo->mqttClientId); - free(xo->mqttDiscoveryPrefix); GWEN_FREE_OBJECT(xo); } @@ -384,81 +361,6 @@ void AQH_NodeServer_SetBrokerClientId(AQH_OBJECT *o, const char *s) -void AQH_NodeServer_SetMqttAddress(AQH_OBJECT *o, const char *s) -{ - if (o) { - AQH_NODE_SERVER *xo; - - xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_NODE_SERVER, o); - if (xo) { - free(xo->mqttAddress); - xo->mqttAddress=s?strdup(s):NULL; - } - } -} - - -void AQH_NodeServer_SetMqttPort(AQH_OBJECT *o, int i) -{ - if (o) { - AQH_NODE_SERVER *xo; - - xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_NODE_SERVER, o); - if (xo) { - xo->mqttPort=i; - } - } -} - - - -void AQH_NodeServer_SetMqttClientId(AQH_OBJECT *o, const char *s) -{ - if (o) { - AQH_NODE_SERVER *xo; - - xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_NODE_SERVER, o); - if (xo) { - free(xo->mqttClientId); - xo->mqttClientId=s?strdup(s):NULL; - } - } -} - - - -void AQH_NodeServer_SetMqttKeepAlive(AQH_OBJECT *o, int i) -{ - if (o) { - AQH_NODE_SERVER *xo; - - xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_NODE_SERVER, o); - if (xo) { - xo->mqttKeepAlive=i; - } - } -} - - - -void AQH_NodeServer_SetMqttDiscoveryPrefix(AQH_OBJECT *o, const char *s) -{ - if (o) { - AQH_NODE_SERVER *xo; - - xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_NODE_SERVER, o); - if (xo) { - free(xo->mqttDiscoveryPrefix); - xo->mqttDiscoveryPrefix=s?strdup(s):NULL; - } - } -} - - - - - - /* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx @@ -525,25 +427,12 @@ int AQH_NodeServer_Init(AQH_OBJECT *o, int argc, char **argv) DBG_INFO(NULL, "here (%d)", rv); return rv; } - - if (xo->flags & AQHOMED_FLAGS_START_BROKER) { - DBG_INFO(NULL, "Starting Broker Connection"); - rv=_startBroker(o, xo); - if (rv<0) { - DBG_INFO(NULL, "here (%d)", rv); - return rv; - } + DBG_INFO(NULL, "Starting Broker Connection"); + rv=_startBroker(o, xo); + if (rv<0) { + DBG_INFO(NULL, "here (%d)", rv); + return rv; } - - if (xo->flags & AQHOMED_FLAGS_START_MQTT) { - DBG_INFO(NULL, "Starting MQTT Connection"); - rv=_startMqtt(o, xo); - if (rv<0) { - DBG_INFO(NULL, "here (%d)", rv); - return rv; - } - } - return 0; } else { @@ -561,31 +450,23 @@ void _readConfig(AQH_OBJECT *o, AQH_NODE_SERVER *xo, GWEN_DB_NODE *dbArgs) xo->timeout=GWEN_DB_GetIntValue(dbArgs, "timeout", 0, 0); xo->noAttn=GWEN_DB_GetIntValue(dbArgs, "noAttn", 0, 0); xo->nodeAddress=GWEN_DB_GetIntValue(dbArgs, "nodeAddress", 0, AQHOMED_DEFAULT_NODEADDR); - xo->flags|=GWEN_DB_GetIntValue(dbArgs, "startBroker", 0, 1)?AQHOMED_FLAGS_START_BROKER:0; - xo->flags|=GWEN_DB_GetIntValue(dbArgs, "startMqtt", 0, 0)?AQHOMED_FLAGS_START_MQTT:0; AQH_NodeServer_SetDbFile(o, GWEN_DB_GetCharValue(dbArgs, "dbfile", 0, NULL)); AQH_NodeServer_SetLogFile(o, GWEN_DB_GetCharValue(dbArgs, "logfile", 0, NULL)); AQH_NodeServer_SetDevicePath(o, GWEN_DB_GetCharValue(dbArgs, "device", 0, AQHOMED_DEFAULT_DEVICE)); - AQH_NodeServer_SetTpcAddress(o, _readCharConfigWithAlt(dbArgs, "tcpAddress", "ConfigFile/nodesAddress", NULL)); - AQH_NodeServer_SetTcpPort(o, _readIntConfigWithAlt(dbArgs, "tcpPort", "ConfigFile/nodesPort", AQHOMED_DEFAULT_IPC_PORT, -1)); + AQH_NodeServer_SetTpcAddress(o, readCharConfigWithAlt(dbArgs, "tcpAddress", "ConfigFile/nodesAddress", NULL)); + AQH_NodeServer_SetTcpPort(o, readIntConfigWithAlt(dbArgs, "tcpPort", "ConfigFile/nodesPort", AQHOMED_DEFAULT_IPC_PORT, -1)); - AQH_NodeServer_SetBrokerAddress(o, _readCharConfigWithAlt(dbArgs, "brokerAddress", "ConfigFile/brokerAddress", "127.0.0.1")); - AQH_NodeServer_SetBrokerPort(o, _readIntConfigWithAlt(dbArgs, "brokerPort", "ConfigFile/brokerPort", AQHOMED_DEFAULT_BROKER_PORT, -1)); + AQH_NodeServer_SetBrokerAddress(o, readCharConfigWithAlt(dbArgs, "brokerAddress", "ConfigFile/brokerAddress", "127.0.0.1")); + AQH_NodeServer_SetBrokerPort(o, readIntConfigWithAlt(dbArgs, "brokerPort", "ConfigFile/brokerPort", AQHOMED_DEFAULT_BROKER_PORT, -1)); AQH_NodeServer_SetBrokerClientId(o, GWEN_DB_GetCharValue(dbArgs, "brokerClientId", 0, AQHOMED_DEFAULT_BROKER_CLIENTID)); - AQH_NodeServer_SetMqttAddress(o, _readCharConfigWithAlt(dbArgs, "mqttAddress", "ConfigFile/mqttAddr", "127.0.0.1")); - AQH_NodeServer_SetMqttPort(o, _readIntConfigWithAlt(dbArgs, "mqttPort", "ConfigFile/mqttPort", 1883, -1)); - AQH_NodeServer_SetMqttClientId(o, _readCharConfigWithAlt(dbArgs, "mqttClientId", "ConfigFile/mqttClientId", "aqhome-mqtt")); - AQH_NodeServer_SetMqttKeepAlive(o, _readIntConfigWithAlt(dbArgs, "mqttKeepAlive", "ConfigFile/mqttKeepAlive", 600, -1)); - AQH_NodeServer_SetMqttDiscoveryPrefix(o, _readCharConfigWithAlt(dbArgs, "mqttDiscovery", "ConfigFile/mqttDiscovery", "homeassistant")); - } -const char *_readCharConfigWithAlt(GWEN_DB_NODE *dbArgs, const char *varName, const char *altVarName, const char *defaultValue) +const char *readCharConfigWithAlt(GWEN_DB_NODE *dbArgs, const char *varName, const char *altVarName, const char *defaultValue) { const char *s; @@ -597,7 +478,7 @@ const char *_readCharConfigWithAlt(GWEN_DB_NODE *dbArgs, const char *varName, co -int _readIntConfigWithAlt(GWEN_DB_NODE *dbArgs, const char *varName, const char *altVarName, int defaultValue, int nonValue) +int readIntConfigWithAlt(GWEN_DB_NODE *dbArgs, const char *varName, const char *altVarName, int defaultValue, int nonValue) { int i; @@ -734,132 +615,6 @@ int _exchangeConnect(AQH_NODE_SERVER *xo, uint32_t flags) - - - -int _startMqtt(AQH_OBJECT *o, AQH_NODE_SERVER *xo) -{ - if (xo->mqttEndpoint) { - AQH_Object_Disable(xo->mqttEndpoint); - AQH_Object_free(xo->mqttEndpoint); - xo->mqttEndpoint=NULL; - } - - if (xo->mqttAddress && *(xo->mqttAddress) && xo->mqttPort) { - AQH_OBJECT *ep; - int fd; - int rv; - - fd=AQH_TcpObject_CreateConnectedSocket(xo->mqttAddress, xo->mqttPort); - if (fd<0) { - DBG_ERROR(NULL, "Error connecting to MQTT server %s:%d", xo->mqttAddress, xo->mqttPort); - return GWEN_ERROR_IO; - } - DBG_INFO(NULL, "Physically connected to MQTT server %s:%d", xo->mqttAddress, xo->mqttPort); - - ep=AQH_MqttClientObject_new(AQH_Object_GetEventLoop(o), fd); - assert(ep); - AQH_Endpoint_SetServiceName(ep, xo->mqttClientId); - AQH_Object_AddLink(ep, AQH_ENDPOINT_SIGNAL_CLOSED, AQH_NODE_SERVER_SLOT_MQTTCLOSED, o); - AQH_Object_Enable(ep); - xo->mqttEndpoint=ep; - - rv=_exchangeMqttConnect(xo); - if (rv!=0) { - DBG_ERROR(NULL, "MQTT: Error exchanging CONNECT request (%d)", rv); - return (rv<0)?rv:GWEN_ERROR_PERMISSIONS; - } - - rv=_exchangeMqttSubscribe(xo); - if (rv!=0) { - DBG_ERROR(NULL, "MQTT: Error exchanging SUBSCRIBE request (%d)", rv); - return (rv<0)?rv:GWEN_ERROR_PERMISSIONS; - } - - DBG_NOTICE(NULL, "Connected to MQTT at %s:%d", xo->mqttAddress, xo->mqttPort); - return 0; - } - else { - DBG_ERROR(NULL, "No MQTT server settings"); - return GWEN_ERROR_BAD_DATA; - } - - return 0; -} - - - -int _exchangeMqttConnect(AQH_NODE_SERVER *xo) -{ - AQH_MESSAGE *msg; - - msg=AQH_MqttMessageConnect_new("MQTT", 0x04, 0, xo->mqttKeepAlive, xo->mqttClientId, NULL, NULL); - AQH_Endpoint_AddMsgOut(xo->mqttEndpoint, msg); - - msg=AQH_MqttEndpoint_WaitForConnAckMsg(xo->mqttEndpoint, xo->timeoutInSeconds); - if (msg) { - int resultCode; - - resultCode=AQH_MqttMessageConnAck_GetResultCode(msg); - AQH_Message_free(msg); - if (resultCode==AQH_MQTTMSG_CONNACK_RESULT_ACCEPTED) { - DBG_INFO(AQH_LOGDOMAIN, "Positive CONNACK response"); - return 0; - } - else { - DBG_ERROR(NULL, "Negative CONNACK response: %d", resultCode); - return GWEN_ERROR_GENERIC; - } - } - else { - DBG_ERROR(NULL, "No CONNACK message received."); - return GWEN_ERROR_GENERIC; - } -} - - - -int _exchangeMqttSubscribe(AQH_NODE_SERVER *xo) -{ - uint16_t pckId; - AQH_MESSAGE *msg; - - pckId=AQH_Endpoint_GetNextMessageId(xo->mqttEndpoint); - msg=AQH_MqttMessageSubscribe_new(0, pckId, "#", 0); - AQH_Endpoint_AddMsgOut(xo->mqttEndpoint, msg); - - msg=AQH_MqttEndpoint_WaitForMsg(xo->mqttEndpoint, AQH_MQTTMSG_MSGTYPE_SUBACK, xo->timeoutInSeconds); - if (msg) { - int resultCode; - - resultCode=AQH_MqttMessageSubAck_GetResultCode(msg); - AQH_Message_free(msg); - if (resultCode!=128) { - DBG_INFO(AQH_LOGDOMAIN, "Positive SUBACK response"); - return 0; - } - else { - DBG_ERROR(NULL, "Negative SUBACK response: %d", resultCode); - return GWEN_ERROR_GENERIC; - } - } - else { - DBG_ERROR(NULL, "No SUBACK message received."); - return GWEN_ERROR_GENERIC; - } -} - - - - - - - - - - - - void _setupDb(AQH_NODE_SERVER *xo) { if (xo->dbFile) { @@ -1384,7 +1139,7 @@ void AQH_NodeServer_CheckBrokerConnection(AQH_OBJECT *o) AQH_NODE_SERVER *xo; xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_NODE_SERVER, o); - if (xo && xo->dbArgs && (xo->flags & AQHOMED_FLAGS_START_BROKER)) { + if (xo && xo->dbArgs) { if (xo->brokerEndpoint) { if (AQH_Object_GetFlags(xo->brokerEndpoint) & AQH_OBJECT_FLAGS_DELETE) { @@ -1415,106 +1170,6 @@ void AQH_NodeServer_CheckBrokerConnection(AQH_OBJECT *o) - -/* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - * MQTT management functions - * xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - */ - - -void AQH_NodeServer_HandleMqttMsgs(AQH_OBJECT *o) -{ - AQH_NODE_SERVER *xo; - - xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_NODE_SERVER, o); - if (xo && xo->mqttEndpoint) { - AQH_MESSAGE *msg; - - while( (msg=AQH_Endpoint_GetNextMsgIn(xo->mqttEndpoint)) ) { - AQH_Message_SetObject(msg, xo->mqttEndpoint); - _handleMsgFromMqtt(o, xo->mqttEndpoint, msg); - AQH_Message_free(msg); - } - } -} - - - -void _handleMsgFromMqtt(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg) -{ - uint8_t code; - - /* exec IPC message */ - code=AQH_MqttMessage_GetTypeAndFlags(msg); - switch(code & 0xf0) { - case (AQH_MQTTMSG_MSGTYPE_PUBLISH & 0xf0): AQH_NodeServer_HandlePublishMsg(o, ep, msg); break; - case (AQH_MQTTMSG_MSGTYPE_PINGRESP & 0xf0): _handleMqttMsgPingRsp(); break; - default: break; - } -} - - - -void _handleMqttMsgPingRsp(void) -{ - DBG_INFO(NULL, "PING response received"); -} - - - -void AQH_NodeServer_CheckMqttConnection(AQH_OBJECT *o) -{ - AQH_NODE_SERVER *xo; - - xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_NODE_SERVER, o); - if (xo && (xo->flags & AQHOMED_FLAGS_START_MQTT)) { - if (xo->mqttEndpoint) { - if (AQH_Object_GetFlags(xo->mqttEndpoint) & AQH_OBJECT_FLAGS_DELETE) { - DBG_INFO(NULL, "Deleting mqtt connection"); - AQH_Object_Disable(xo->mqttEndpoint); - AQH_Object_free(xo->mqttEndpoint); - xo->mqttEndpoint=NULL; - } - } - - if (xo->mqttEndpoint==NULL) { - time_t now; - - now=time(NULL); - if (_diffInSeconds(now, xo->timestampMqttDown)>AQH_NODE_SERVER_MQTT_RESTARTTIME) { - int rv; - - DBG_INFO(NULL, "Restarting MQTT connection"); - rv=_startMqtt(o, xo); - if (rv<0) { - DBG_ERROR(NULL, "here (%d)", rv); - } - } - } - } -} - - - -int AQH_NodeServer_SendPing(AQH_OBJECT *o) -{ - AQH_NODE_SERVER *xo; - - xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_NODE_SERVER, o); - if (xo && xo->mqttEndpoint) { - AQH_MESSAGE *msgOut; - - DBG_INFO(NULL, "Sending PING"); - msgOut=AQH_MqttMessage_new(AQH_MQTTMSG_MSGTYPE_PINGREQ, 0, NULL); - AQH_Endpoint_AddMsgOut(xo->mqttEndpoint, msgOut); - return 0; - } - return GWEN_ERROR_INVALID; -} - - - - /* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx * request management functions * xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx @@ -1576,7 +1231,6 @@ int _handleSignal(AQH_OBJECT *o, uint32_t slotId, AQH_OBJECT *senderObject, GWEN case AQH_NODE_SERVER_SLOT_CLIENTCLOSED: return _handleIpcClientDown(senderObject); case AQH_NODE_SERVER_SLOT_BROKERCLOSED: return _handleBrokerDown(xo); case AQH_NODE_SERVER_SLOT_TTYCLOSED: return _handleTtyDown(xo); - case AQH_NODE_SERVER_SLOT_MQTTCLOSED: return _handleMqttDown(xo); default: break; } @@ -1630,18 +1284,6 @@ int _handleTtyDown(AQH_NODE_SERVER *xo) -int _handleMqttDown(AQH_NODE_SERVER *xo) -{ - if (xo->mqttEndpoint) { - DBG_WARN(NULL, "MQTT connection down"); - AQH_Object_AddFlags(xo->mqttEndpoint, AQH_OBJECT_FLAGS_DELETE); - xo->timestampMqttDown=time(NULL); - } - return 1; -} - - - /* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx @@ -1769,16 +1411,10 @@ int _readArgs(int argc, char **argv, GWEN_DB_NODE *dbArgs) { A_ARG, A_CHAR, "brokerAddress", 0, 1, "ba", "brokerddress", I18S("Broker address [127.0.0.1]"), NULL}, { A_ARG, A_INT, "brokerPort", 0, 1, "bp", "brokerport", I18S("Broker port [1899]"), NULL}, { A_ARG, A_CHAR, "brokerClientId", 0, 1, NULL, "brokerclientid", I18S("Broker client id"), NULL}, - { A_ARG, A_CHAR, "mqttAddress", 0, 1, "ma", "mqttaddress", I18S("Address of MQTT server"), NULL}, - { A_ARG, A_INT, "mqttPort", 0, 1, "mp", "mqttport", I18S("Port of MQTT server (default: 1883)"), NULL}, - { A_ARG, A_CHAR, "mqttClientId", 0, 1, NULL, "mqttclientid", I18S("MQTT client id"), NULL}, - { A_ARG, A_INT, "mqttKeepAlive", 0, 1, "P", "mqttkeepalive", I18S("MQTT keep-alive time"), NULL}, { A_ARG, A_CHAR, "dbfile", 0, 1, "db", "dbfile", I18S("DB file to read/write node database"), NULL}, { A_ARG, A_CHAR, "pidfile", 0, 1, "p", "pidfile", I18S("PID file"), NULL}, { A_ARG, A_INT, "timeout", 0, 1, "T", NULL, I18S("timeout in seconds [0]"), NULL}, { 0, A_INT, "noAttn", 0, 1, "N", "noattn", I18S("Don't use ATTN line (for T03 or newer)"), NULL}, - { 0, A_INT, "startMqtt", 0, 1, "M", "startMqtt", I18S("Start MQTT connection"), NULL}, - { 0, A_INT, "startBroker", 0, 1, "M", "startBroker", I18S("Start AqHome Broker connection"), NULL}, { A_END, A_INT, "help", 0, 0, "h", "help", I18S("Show this help screen"), NULL} }; diff --git a/apps/aqhome-nodes/server.h b/apps/aqhome-nodes/server.h index 523132d..a59b7f9 100644 --- a/apps/aqhome-nodes/server.h +++ b/apps/aqhome-nodes/server.h @@ -57,9 +57,6 @@ void AQH_NodeServer_HandleClientMsgs(AQH_OBJECT *o); void AQH_NodeServer_HandleBrokerMsgs(AQH_OBJECT *o); void AQH_NodeServer_CheckBrokerConnection(AQH_OBJECT *o); void AQH_NodeServer_CheckTtyConnection(AQH_OBJECT *o); -void AQH_NodeServer_HandleMqttMsgs(AQH_OBJECT *o); -void AQH_NodeServer_CheckMqttConnection(AQH_OBJECT *o); -int AQH_NodeServer_SendPing(AQH_OBJECT *o); /* getters and setters */ @@ -75,12 +72,6 @@ void AQH_NodeServer_SetBrokerAddress(AQH_OBJECT *o, const char *s); void AQH_NodeServer_SetBrokerPort(AQH_OBJECT *o, int i); void AQH_NodeServer_SetBrokerClientId(AQH_OBJECT *o, const char *s); -void AQH_NodeServer_SetMqttAddress(AQH_OBJECT *o, const char *s); -void AQH_NodeServer_SetMqttPort(AQH_OBJECT *o, int i); -void AQH_NodeServer_SetMqttClientId(AQH_OBJECT *o, const char *s); -void AQH_NodeServer_SetMqttKeepAlive(AQH_OBJECT *o, int i); -void AQH_NodeServer_SetMqttDiscoveryPrefix(AQH_OBJECT *o, const char *s); - /* device management */ const AQHNODE_DEVICE_LIST *AQH_NodeServer_GetDeviceDefList(const AQH_OBJECT *o); diff --git a/apps/aqhome-nodes/server_p.h b/apps/aqhome-nodes/server_p.h index 280cc35..8b65a9a 100644 --- a/apps/aqhome-nodes/server_p.h +++ b/apps/aqhome-nodes/server_p.h @@ -27,16 +27,12 @@ #define AQHOMED_DEFAULT_BROKER_PORT 1899 #define AQHOMED_DEFAULT_BROKER_CLIENTID "nodes" -#define AQHOMED_FLAGS_START_BROKER 0x00000001 -#define AQHOMED_FLAGS_START_MQTT 0x00000002 - typedef struct AQH_NODE_SERVER AQH_NODE_SERVER; struct AQH_NODE_SERVER { AQH_OBJECT *ttyEndpoint; AQH_OBJECT *brokerEndpoint; - AQH_OBJECT *mqttEndpoint; AQH_OBJECT *ipcEndpoint; AQH_OBJECT_LIST *ipcClientList; @@ -48,8 +44,6 @@ struct AQH_NODE_SERVER { GWEN_DB_NODE *dbArgs; - uint32_t flags; - char *dbFile; char *logFile; char *pidFile; @@ -64,15 +58,8 @@ struct AQH_NODE_SERVER { int brokerPort; char *brokerClientId; - char *mqttAddress; - int mqttPort; - char *mqttClientId; - char *mqttDiscoveryPrefix; - int mqttKeepAlive; - time_t timestampTtyDown; time_t timestampBrokerDown; - time_t timestampMqttDown; int nodeAddress; From 32bd3bc2f96028ad51d9abd75a7e98dbe997f275 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 4 Aug 2025 22:26:26 +0200 Subject: [PATCH 126/196] added r06 again. --- avr/devices/0BUILD | 1 + 1 file changed, 1 insertion(+) diff --git a/avr/devices/0BUILD b/avr/devices/0BUILD index 67b5e1f..94f5ce1 100644 --- a/avr/devices/0BUILD +++ b/avr/devices/0BUILD @@ -39,6 +39,7 @@ n27 r04 r05 + r06 t03 From 0dc4a3a952a35c96d5e7c785ea33a3cad26d2f92 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 4 Aug 2025 22:28:49 +0200 Subject: [PATCH 127/196] avr: started adding COM2WN module. --- avr/devices/all/includes.asm | 14 ++++++++++++++ avr/devices/all/main.asm | 5 +++++ avr/devices/all/modules.asm | 12 ++++++++++++ avr/devices/r06/main/main.asm | 10 +++++----- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/avr/devices/all/includes.asm b/avr/devices/all/includes.asm index 83a040b..4c75d55 100644 --- a/avr/devices/all/includes.asm +++ b/avr/devices/all/includes.asm @@ -119,6 +119,20 @@ #endif + +#ifdef MODULES_COM2WN +.include "modules/com2w/defs.asm" +.include "modules/com2w/com2wn_init.asm" +.include "modules/com2w/com2wn_io.asm" +.include "modules/com2w/com2wn_irq.asm" +.include "modules/com2w/com2wn_recv.asm" +.include "modules/com2w/com2wn_run.asm" +.include "modules/com2w/com2wn_send.asm" +.include "modules/com2w/com2wn_wait.asm" +.include "modules/com2w/com2wn_data.asm" +#endif + + #ifdef MODULES_CLOCK .include "modules/clock/main.asm" #endif diff --git a/avr/devices/all/main.asm b/avr/devices/all/main.asm index 8c520a0..d5d5047 100644 --- a/avr/devices/all/main.asm +++ b/avr/devices/all/main.asm @@ -148,6 +148,11 @@ onSystemTimerTick: bigcall COM2W1_Periodically #endif +#ifdef MODULES_COM2WN + bigcall COM2WN_Periodically +#endif + + #ifdef MODULES_TCRT1000 bigcall TCRT1K_Every100ms #endif diff --git a/avr/devices/all/modules.asm b/avr/devices/all/modules.asm index b5a3e19..027bb77 100644 --- a/avr/devices/all/modules.asm +++ b/avr/devices/all/modules.asm @@ -93,6 +93,11 @@ initModules: bigcall COM2W1_Init #endif +#ifdef MODULES_COM2WN + bigcall COM2WN_Init +#endif + + #ifdef MODULES_MOTION bigcall Motion_Init #endif @@ -250,6 +255,13 @@ runComModules_loop: sbci r16, 0 #endif +#ifdef MODULES_COM2WN + push r16 + bigcall COM2WN_Run + pop r16 + sbci r16, 0 +#endif + pop r17 ; check for repeat request tst r16 diff --git a/avr/devices/r06/main/main.asm b/avr/devices/r06/main/main.asm index 9ef4528..14e7ee4 100644 --- a/avr/devices/r06/main/main.asm +++ b/avr/devices/r06/main/main.asm @@ -47,7 +47,8 @@ ; --------------------------------------------------------------------------- ; generic -.equ NET_BUFFERS_NUM = 6 +.equ NET_BUFFERS_NUM = 6 +.equ COM2WN_IO_RINGBUFFER_SIZE = 128 .equ PROGRAM_SENSOR_INTERVAL_SECS = 60 .equ PROGRAM_STATS_INTERVAL_MINS = 10 @@ -62,7 +63,7 @@ #define MODULES_LED_SIMPLE #define MODULES_NETWORK ;#define MODULES_UART_BITBANG -#define MODULES_COM2WG +#define MODULES_COM2WN ;#define MODULES_TWI_MASTER ;#define MODULES_LCD ;#define LCD_MINIMAL_FONT @@ -122,10 +123,9 @@ ; 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 + rjmp BOOTLOADER_ADDR ; Reset vector ; use this for flashed system reti ; EXT_INT0 -; rjmp UART_BitBang_PcintIsr ; PCI0 - rjmp com2wPcintIsr ; PCI0 + rjmp COM2WN_ClkChangeIsr ; PCI0 reti ; PCI1 reti ; WATCHDOG reti ; ICP1 From 9b1badb3100dfc3952a46a9ca69be9e362c6c6fb Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 18 Aug 2025 18:03:24 +0200 Subject: [PATCH 128/196] avr: introduce reference counter for network buffers. --- avr/common/m_fixedbuffers.asm | 2 +- avr/modules/network/buffer.asm | 49 +++++++++++++++++++++++++++++++++- avr/modules/network/defs.asm | 12 ++++++--- 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/avr/common/m_fixedbuffers.asm b/avr/common/m_fixedbuffers.asm index b2831e1..9ad97a3 100644 --- a/avr/common/m_fixedbuffers.asm +++ b/avr/common/m_fixedbuffers.asm @@ -52,7 +52,7 @@ l_loop: brcs l_loop rjmp l_end ; use cleared CFLAG l_foundfree: - ldi r16, 0x80 ; mark as used + ldi r16, 0x10 ; mark as used st X, r16 mov r16, r17 sec ; set CFLAG, return bufnum in r16, pointre in X diff --git a/avr/modules/network/buffer.asm b/avr/modules/network/buffer.asm index 5404450..c8e54e9 100644 --- a/avr/modules/network/buffer.asm +++ b/avr/modules/network/buffer.asm @@ -62,7 +62,7 @@ NET_Buffer_Alloc_noIrq: ldi xh, HIGH(netBuffers) m_fixedbuf_reserve NET_BUFFERS_SIZE, NET_BUFFERS_NUM brcc NET_Buffer_Alloc_end - ldi r17, (1< not in use + dec r16 + breq NET_Buffer_ReleaseByAddr_release + swap r16 + push r17 + ld r17, X + andi r17, 0x0f + or r16, r17 + st X, r16 + pop r17 + rjmp NET_Buffer_ReleaseByAddr_done +NET_Buffer_ReleaseByAddr_release: m_fixedbuf_release +NET_Buffer_ReleaseByAddr_done: + out SREG, r15 + pop r15 + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine NET_Buffer_IncRef @global +; +; @param X pointer to start of buffer +; @clobbers R16 + +NET_Buffer_IncRef: + push r15 + in r15, SREG + cli + ld r16, X + swap r16 ; ref counter now in lower nibble + andi r16, 0x0f + breq NET_Buffer_IncRef_done ; refcounter 0? -> not in use + inc r16 + breq NET_Buffer_IncRef_done ; don't increment if refcounter at max!!! + swap r16 ; ref counter now in high nibble again + push r17 + ld r17, X + andi r17, 0x0f ; clear ref counter in r17 + or r16, r17 ; or new ref counter into r17 + st X, r16 ; store new header byte + pop r17 +NET_Buffer_IncRef_done: out SREG, r15 pop r15 ret diff --git a/avr/modules/network/defs.asm b/avr/modules/network/defs.asm index ac409a7..b670706 100644 --- a/avr/modules/network/defs.asm +++ b/avr/modules/network/defs.asm @@ -12,12 +12,16 @@ .equ NET_BUFFERS_SIZE = 28 ; CAVE: need to adapt routine NET_Buffer_Locate when changing this value!! -.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) +;.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) -.equ NET_IFACE_BUFFER_INUSE_BIT = 7 +.equ NET_IFACE_BUFFER_INUSE_BIT3 = 7 +.equ NET_IFACE_BUFFER_INUSE_BIT2 = 6 +.equ NET_IFACE_BUFFER_INUSE_BIT1 = 5 +.equ NET_IFACE_BUFFER_INUSE_BIT0 = 4 +.equ NET_IFACE_BUFFER_IFACENUM3_BIT = 3 +.equ NET_IFACE_BUFFER_IFACENUM2_BIT = 2 .equ NET_IFACE_BUFFER_IFACENUM1_BIT = 1 .equ NET_IFACE_BUFFER_IFACENUM0_BIT = 0 From d9e7d4df81316a8b0a6480864f766382cc26f465 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 18 Aug 2025 18:04:30 +0200 Subject: [PATCH 129/196] com2w*: allow for higher frequencies than 8MHz to be used with node S03, which is run at 20MHz. --- avr/modules/com2w/com2wn_init.asm | 2 +- avr/modules/com2w/com2wn_io.asm | 14 +-- avr/modules/com2w/com2wn_irq.asm | 55 +++++---- avr/modules/com2w/com2wn_run.asm | 162 ++++++++++++++++++++++++-- avr/modules/com2w/com2wn_send.asm | 70 +++++------ avr/modules/com2w/com2wn_wait.asm | 94 +++++++++++---- avr/modules/flash/io_com2w.asm | 187 +++++++++++++++++++----------- 7 files changed, 412 insertions(+), 172 deletions(-) diff --git a/avr/modules/com2w/com2wn_init.asm b/avr/modules/com2w/com2wn_init.asm index 897253d..4af9982 100644 --- a/avr/modules/com2w/com2wn_init.asm +++ b/avr/modules/com2w/com2wn_init.asm @@ -100,7 +100,7 @@ com2wnInit: rcall com2wSetMode ; (R17) rcall com2wSetupLines - rcall com2wSetupIrq + rcall com2wnSetupIrq ret ; @end diff --git a/avr/modules/com2w/com2wn_io.asm b/avr/modules/com2w/com2wn_io.asm index 9cf78a5..43e9f8d 100644 --- a/avr/modules/com2w/com2wn_io.asm +++ b/avr/modules/com2w/com2wn_io.asm @@ -34,7 +34,7 @@ com2wSetupLines: .endif ; setup DATA line (as input, disable internal pull-up resistor) - rcall com2wDataSetHigh + rcall com2wnDataSetHigh .ifdef COM_DATA_PUE ldd r16, Y+COM2W_IFACE_OFFS_PINMASK_DATA com r16 @@ -75,12 +75,12 @@ com2wClkSetHigh: ; --------------------------------------------------------------------------- -; @routine com2wClkSetLow +; @routine com2wnClkSetLow ; ; @param Y pointer to interface data in SRAM ; @clobbers none -com2wClkSetLow: +com2wnClkSetLow: push r16 push r17 ldd r16, Y+COM2W_IFACE_OFFS_PINMASK_CLK @@ -102,12 +102,12 @@ com2wClkSetLow: ; --------------------------------------------------------------------------- -; @routine com2wDataSetHigh +; @routine com2wnDataSetHigh ; ; @param Y pointer to interface data in SRAM ; @clobbers none -com2wDataSetHigh: +com2wnDataSetHigh: push r16 push r17 ldd r16, Y+COM2W_IFACE_OFFS_PINMASK_DATA @@ -129,12 +129,12 @@ com2wDataSetHigh: ; --------------------------------------------------------------------------- -; @routine com2wDataSetLow +; @routine com2wnDataSetLow ; ; @param Y pointer to interface data in SRAM ; @clobbers none -com2wDataSetLow: +com2wnDataSetLow: push r16 push r17 ldd r16, Y+COM2W_IFACE_OFFS_PINMASK_DATA diff --git a/avr/modules/com2w/com2wn_irq.asm b/avr/modules/com2w/com2wn_irq.asm index b2e5f9e..3f5fb31 100644 --- a/avr/modules/com2w/com2wn_irq.asm +++ b/avr/modules/com2w/com2wn_irq.asm @@ -23,12 +23,16 @@ com2wnSetupIrq: ; setup pin-change interrupt for CLK rcall com2wnEnableClkIrq - ; enable and clear PCIE0/1 (@TODO put later into general setup) - inr r16, GIMSK ; enable pin change irq PCIE0 or PCIE1 - sbr r16, (1< 1000000 +; begin version for > 1000000 Hz + ldi r20, LOW(clock/1000000) + ldd r22, Y+COM2W_IFACE_OFFS_PINMASK_CLK ; +2 +com2wWaitForClockHighMulti10Us_loop0: + push r20 ; +2 +com2wWaitForClockHighMulti10Us_loop: ; 10 cycles per loop + inr r16, COM_CLK_INPUT ; +1 (if low port, +2 if high port) + and r16, r22 ; +1 + breq com2wWaitForClockHighMulti10Us_stateReached ; +1 if FALSE, +2 if TRUE + + inr r16, COM_CLK_INPUT ; +1 (if low port, +2 if high port) + and r16, r22 ; +1 + breq com2wWaitForClockHighMulti10Us_stateReached ; +1 if FALSE, +2 if TRUE + + nop ; +1 + + dec r20 ; +1 + brne com2wWaitForClockHighMulti10Us_loop ; +2 if TRUE, +1 if FALSE + pop r20 ; +2 + dec r20 ; +1 + brne com2wWaitForClockHighMulti10Us_loop0 ; +1 if FALSE, +2 if TRUE + clc ; +1 + ret ; +4 +com2wWaitForClockHighMulti10Us_stateReached: + pop r20 + sec ; +1 + ret ; +4 +; end version for > 1000000 Hz +.elif clock < 1000000 + .error "Clock speed too low" .else - .error "Unhandled clock speed" -.endif - +; begin version for 1000000 Hz ldd r22, Y+COM2W_IFACE_OFFS_PINMASK_CLK ; +2 com2wWaitForClockHighMulti10Us_loop: ; 10 cycles per loop inr r16, COM_CLK_INPUT ; +1 (if low port, +2 if high port) and r16, r22 ; +1 - brne com2wWaitForClockHighMulti10Us_stateReached ; +1 if FALSE, +2 if TRUE + breq com2wWaitForClockHighMulti10Us_stateReached ; +1 if FALSE, +2 if TRUE inr r16, COM_CLK_INPUT ; +1 (if low port, +2 if high port) and r16, r22 ; +1 @@ -53,12 +75,14 @@ com2wWaitForClockHighMulti10Us_loop: ; 10 cycles per loop nop ; +1 dec r20 ; +1 - brne com2wWaitForClockHighMulti10Us_loop ; +2 if TRUE, +1 if FALSE + brne com2wWaitForClockHighMulti10Us_loop ; +2 if TRUE, +1 if FALSE clc ; +1 ret ; +4 com2wWaitForClockHighMulti10Us_stateReached: sec ; +1 ret ; +4 +; end version for 1000000 Hz +.endif ; @end @@ -68,22 +92,44 @@ com2wWaitForClockHighMulti10Us_stateReached: ; ; Wait for low CLK ; -; @param R20 multiple of 10us to wait (e.g. "2" for "20" us, max: 32) +; @param R20 multiple of 10us to wait (e.g. "2" for "20" us) ; @return CFLAG set if okay (state reached), cleared on error ; @clobbers: r16, r20, r22 com2wWaitForClockLowMulti10Us: -.if clock == 8000000 - add r20, r20 ; *2 - add r20, r20 ; *4 - add r20, r20 ; *8 -.endif -.elif clock == 1000000 -; nothing to do +.if clock > 1000000 +; begin version for > 1000000 Hz + ldi r20, LOW(clock/1000000) + ldd r22, Y+COM2W_IFACE_OFFS_PINMASK_CLK ; +2 +com2wWaitForClockLowMulti10Us_loop0: + push r20 ; +2 +com2wWaitForClockLowMulti10Us_loop: ; 10 cycles per loop + inr r16, COM_CLK_INPUT ; +1 (if low port, +2 if high port) + and r16, r22 ; +1 + breq com2wWaitForClockLowMulti10Us_stateReached ; +1 if FALSE, +2 if TRUE + + inr r16, COM_CLK_INPUT ; +1 (if low port, +2 if high port) + and r16, r22 ; +1 + breq com2wWaitForClockLowMulti10Us_stateReached ; +1 if FALSE, +2 if TRUE + + nop ; +1 + + dec r20 ; +1 + brne com2wWaitForClockLowMulti10Us_loop ; +2 if TRUE, +1 if FALSE + pop r20 ; +2 + dec r20 ; +1 + brne com2wWaitForClockLowMulti10Us_loop0 ; +1 if FALSE, +2 if TRUE + clc ; +1 + ret ; +4 +com2wWaitForClockLowMulti10Us_stateReached: + pop r20 + sec ; +1 + ret ; +4 +; end version for > 1000000 Hz +.elif clock < 1000000 + .error "Clock speed too low" .else - .error "Unhandled clock speed" -.endif - +; begin version for 1000000 Hz ldd r22, Y+COM2W_IFACE_OFFS_PINMASK_CLK ; +2 com2wWaitForClockLowMulti10Us_loop: ; 10 cycles per loop inr r16, COM_CLK_INPUT ; +1 (if low port, +2 if high port) @@ -103,6 +149,8 @@ com2wWaitForClockLowMulti10Us_loop: ; 10 cycles per loop com2wWaitForClockLowMulti10Us_stateReached: sec ; +1 ret ; +4 +; end version for 1000000 Hz +.endif ; @end diff --git a/avr/modules/flash/io_com2w.asm b/avr/modules/flash/io_com2w.asm index 1a56014..0343e7e 100644 --- a/avr/modules/flash/io_com2w.asm +++ b/avr/modules/flash/io_com2w.asm @@ -92,8 +92,8 @@ ioRawWaitForValidMsg_waitLowLoop1: .endif ldi r18, 5 ioRawWaitForValidMsg_waitLowLoop2: - ldi r20, 20 ; wait for about 100us for clock low - rcall com2wWaitForClockLowMulti5Us ; R20, R22 + ldi r20, 10 ; wait for about 100us for clock low + rcall com2wWaitForClockLowMulti10Us ; R20, R22 brcs ioRawWaitForValidMsg_recvMsg dec r18 brne ioRawWaitForValidMsg_waitLowLoop2 @@ -132,8 +132,8 @@ ioRawWaitForValidMsg_end: ; @clobbers R18, R20 (R16, R17, R20, R22, X) com2wSendMsg: - ldi r20, 11 ; wait for about 55us for clock low - rcall com2wWaitForClockLowMulti5Us + ldi r20, 6 ; wait for about 60us for clock low + rcall com2wWaitForClockLowMulti10Us brcs com2wSendMsg_busy ; CLK got low while waiting, so line is busy rcall com2wClkSetLow ; reserve bus (none) adiw xh:xl, NETMSG_OFFS_MSGLEN @@ -267,21 +267,12 @@ com2wRecvByte: ldi r17, 8 clr r16 com2wRecvByte_loop: - ldi r20, 31 ; wait up to 155us for clock low - rcall com2wWaitForClockLowMulti5Us ; (R20, R22) - brcs com2wRecvByte_waitForClkHigh - ldi r20, 31 ; wait up to 155us for clock low - rcall com2wWaitForClockLowMulti5Us ; (R20, R22) + ldi r20, 30 ; wait up to 300us for clock low + rcall com2wWaitForClockLowMulti10Us ; (R20, R22) brcc com2wRecvByte_end -com2wRecvByte_waitForClkHigh: - ldi r20, 31 ; wait up to 155us for clock high - rcall com2wWaitForClockHighMulti5Us ; (R20, R22) - brcs com2wRecvByte_readBit - ldi r20, 31 ; wait up to 155us for clock high - rcall com2wWaitForClockHighMulti5Us ; (R20, R22) + ldi r20, 30 ; wait up to 300us for clock high + rcall com2wWaitForClockHighMulti10Us ; (R20, R22) brcc com2wRecvByte_end - -com2wRecvByte_readBit: ; handle received bit inr r18, COM_DATA_INPUT andi r18, (1< 1000000 +; begin version for > 1000000 Hz + ldi r20, LOW(clock/1000000) + ldi r22, (1< 1000000 Hz +.elif clock < 1000000 + .error "Clock speed too low" .else - .error "Unhandled clock speed" -.endif +; begin version for 1000000 Hz + ldi r22, (1< 1000000 +; begin version for > 1000000 Hz + ldi r20, LOW(clock/1000000) + ldi r22, (1< 1000000 Hz +.elif clock < 1000000 + .error "Clock speed too low" .else - .error "Unhandled clock speed" -.endif +; begin version for 1000000 Hz + ldi r22, (1< Date: Mon, 18 Aug 2025 18:05:12 +0200 Subject: [PATCH 130/196] split wait for 50us (value 50000 doesn't work for 20MHz nodes). --- avr/common/wait_50us.asm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/avr/common/wait_50us.asm b/avr/common/wait_50us.asm index 33c4d41..19ade01 100644 --- a/avr/common/wait_50us.asm +++ b/avr/common/wait_50us.asm @@ -18,7 +18,8 @@ ; @clobbers r22 Utils_WaitFor50MicroSecs: - Utils_WaitNanoSecs 50000, 7, r22 ; wait for 50us (minus RCALL and RET) + Utils_WaitNanoSecs 25000, 0, r22 ; wait for 25us + Utils_WaitNanoSecs 25000, 7, r22 ; wait for 25us (minus RCALL and RET) ret ; @end From 3592a745d32782948ca24cc7938dc8d3404bdcd1 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 18 Aug 2025 18:06:35 +0200 Subject: [PATCH 131/196] introduce app "hub" --- avr/apps/0BUILD | 1 + avr/apps/hub/0BUILD | 15 + avr/apps/hub/main.asm | 715 +++++++++++++++++++++++++++++++++++ avr/devices/all/apps.asm | 8 + avr/devices/all/includes.asm | 13 + avr/devices/all/modules.asm | 102 ++--- 6 files changed, 787 insertions(+), 67 deletions(-) create mode 100644 avr/apps/hub/0BUILD create mode 100644 avr/apps/hub/main.asm diff --git a/avr/apps/0BUILD b/avr/apps/0BUILD index 6934125..29dc20d 100644 --- a/avr/apps/0BUILD +++ b/avr/apps/0BUILD @@ -10,6 +10,7 @@ reportsensors stats router + hub diff --git a/avr/apps/hub/0BUILD b/avr/apps/hub/0BUILD new file mode 100644 index 0000000..593fe80 --- /dev/null +++ b/avr/apps/hub/0BUILD @@ -0,0 +1,15 @@ + + + + + + + + + main.asm + + + + + + diff --git a/avr/apps/hub/main.asm b/avr/apps/hub/main.asm new file mode 100644 index 0000000..7779153 --- /dev/null +++ b/avr/apps/hub/main.asm @@ -0,0 +1,715 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + + +; *************************************************************************** +; defines + +; --------------------------------------------------------------------------- +; network interfaces + + + + +; *************************************************************************** +; data + +.dseg + +appHubDataBegin: + appHubRangeBegin: .byte 1 + appHubRangeEnd: .byte 1 +appHubDataEnd: + + + + +; *************************************************************************** +; code + +.cseg + +; --------------------------------------------------------------------------- +; @routine AppHub_Init @global + +AppHub_Init: + ldi xh, HIGH(appHubDataBegin) + ldi xl, LOW(appHubDataBegin) + clr r16 + ldi r17, (appHubDataEnd-appHubDataBegin) + rcall Utils_FillSram + + ; set device address and interface number in all interfaces + ldi r16, 0xf0 ; hub address + ldi r17, 1 ; first interface number + rcall appHubAllSetAddrIfaceNumAndRange ; (R17, R19, R20, Y) + + ; TODO: read ranges from EEPROM + ; TODO: send range msg to all interfaces + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine AppHub_Run @global +; +; Read messages from any interface, handle them and probably forward to the other +; interfaces. +; @return CFLAG set if something done, cleared otherwise +; @clobbers all + +AppHub_Run: + rjmp appHubCheckRecvdMsg +; @end + + + +; --------------------------------------------------------------------------- +; @routine appHubGetDeviceByIfaceNum +; +; @param r16 interface number +; @clobbers r17, r19, r20, Y + +appHubGetDeviceByIfaceNum: + ldi r19, COM_PORTS + ldi yl, LOW(com2w0_iface) ; first interface + ldi yh, HIGH(com2w0_iface) +appHubGetDeviceByIfaceNum_loop: + ldd r17, Y+NET_IFACE_OFFS_IFACENUM + cp r16, r17 + sec ; mark "found" + breq appHubGetDeviceByIfaceNum_ret + ldi r20, COM2W_IFACE_SIZE + add yl, r20 + adc yh, r20 + sub yh, r20 + dec r19 + brne appHubGetDeviceByIfaceNum_loop + clc ; mark "not found" +appHubGetDeviceByIfaceNum_ret: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appHubAllSetAddrIfaceNumAndRange +; +; @clobbers R17, R18, R19, R20, Y + +appHubAllSetAddrIfaceNumAndRange: + ldi r19, COM_PORTS + ldi yl, LOW(com2w0_iface) ; first interface + ldi yh, HIGH(com2w0_iface) + ldi r18, 0x10 +appHubAllSetAddrIfaceNumAndRange_loop: + ; set address + std Y+NET_IFACE_OFFS_ADDRESS, r16 + ; set interface number + std Y+NET_IFACE_OFFS_IFACENUM, r17 + inc r17 + ; set default range (step of 16) + std Y+NET_IFACE_OFFS_RANGE_BEGIN, r18 + subi r18, -15 + std Y+NET_IFACE_OFFS_RANGE_END, r18 + inc r18 + ; next interface + ldi r20, COM2W_IFACE_SIZE + add yl, r20 + adc yh, r20 + sub yh, r20 + dec r19 + brne appHubAllSetAddrIfaceNumAndRange_loop + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appHubSendRangeMsg +; +; @param R18 msg code +; @param Y pointer to interface data +; @return CFLAG set if message enqueued, cleared on error +; @clobbers (R16, R17, R18, R19, R20, R21, R24, R25, X) + +appHubSendRangeMsg: + bigcall NET_Buffer_Alloc ; (R16, R17, X) + brcc appHubSendRangeMsg_end + push r16 + ldd r20, Y+NET_IFACE_OFFS_RANGE_BEGIN + ldd r21, Y+NET_IFACE_OFFS_RANGE_END + adiw xh:xl, 1 + bigcall NETMSG_Range_Write ; (R16, R17, R18, R19, R20, R21) + sbiw xh:xl, 1 + pop r16 + rcall appHubSendMsg ; (R16, R17, R18, R24, R25, X) +appHubSendRangeMsg_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appHubSendDenyAddrR19 +; +; @param R19 address to send +; @clobbers R16, R17, R18, R19, R20, R21, X, Y + +appHubSendDenyAddrR19: + ldi r18, NETMSG_CMD_DENY_ADDRESS ; deny addr + rjmp appHubSendAddrMsg ; (R16, R17, R18, R19, R20, R21, X, Y) +; @end + + + +; --------------------------------------------------------------------------- +; @routine appHubSendAddrMsg +; +; @param R18 command +; @param R19 address to send +; @clobbers R16 (R17, R18, R19, R20, R21, X, Y) + +appHubSendAddrMsg: + bigcall NET_Buffer_Alloc ; (R16, R17, X) + brcc appHubSendAddrMsg_end + push r16 + adiw xh:xl, 1 + bigcall NETMSG_Address_Write ; (R16, R17, R18, R19, R20, R21) + sbiw xh:xl, 1 + pop r16 + rcall appHubSendMsg ; (R16, R17, R18, R24, R25, X) +appHubSendAddrMsg_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appHubSendValueResponse +; +; @param R17 value id +; @param R19:R18 value +; @param R21:R20 denom (e.g. 100, meaning value must be divided by 100) +; @param R23 command +; @param R25:R24 ref msg id +; @return CFLAG on success, cleared on error +; @clobbers r22 (r16, r17, r18, r19, r20, r21, r23, r24, r25, X) + +appHubSendValueResponse: + push r17 + rcall NET_Buffer_Alloc ; (R16, R17, X) + pop r17 + brcc appHubSendValueResponse_end ; jmp on error + push r16 ; buffer num + ldi r16, 0xff ; DEST addr + clr r22 ; value type + adiw xh:xl, 1 + rcall NETMSG_ValueWriteResponse ; (R16, R17, R18, R19, R20, R21, R23, R24, R25) + sbiw xh:xl, 1 + pop r16 ; buffer num + rcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) +appHubSendValueResponse_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appHubSendMsg +; +; @param R16 num of allocated buffer +; @param Y pointer to interface data +; @param X msg to send (points to start of allocated buffer, e.g. buffer header) +; @return CFLAG set if message enqueued, cleared on error +; @clobbers R16 (R17, R18, R24, R25, X) + +appHubSendMsg: + bigcall NET_Interface_AddOutgoingMsgNum ; (R17, R18, X) + brcs appHubSendMsg_end + bigcall NET_Buffer_ReleaseByNum ; (R16, X) + ldi r16, NET_IFACE_OFFS_ERR_NOBUF_LOW + rcall NET_Interface_IncCounter16 ; (R24, R25) + clc +appHubSendMsg_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appHubAllResetStats +; +; @clobbers r19, r20, Y (r16, r17, X) + +appHubAllResetStats: + ldi r19, COM_PORTS + ldi yl, LOW(com2w0_iface) ; first interface + ldi yh, HIGH(com2w0_iface) +appHubAllResetStats_loop: + bigcall NET_Interface_ResetStats ; (R16, R17, X) + + ldi r20, COM2W_IFACE_SIZE + add yl, r20 + adc yh, r20 + sub yh, r20 + dec r19 + brne appHubAllResetStats_loop + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine AppHub_EveryDay @global +; +; @clobbers R16, R17, X + +AppHub_EveryDay: + rcall appHubAllResetStats + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appHubSendMsgToAllOthers +; +; @param R16 buffer number +; @param X buffer pointer +; @clobbers r17, r19, r20, r24, r25 (r16, r18, X) + +appHubSendMsgToAllOthers: + ld r24, X + andi r24, 0x0f ; get sender interface num + ldi r19, COM_PORTS ; number of ports + ldi yl, LOW(com2w0_iface) ; first interface + ldi yh, HIGH(com2w0_iface) +appHubSendMsgToAllOthers_loop: + ldd r25, Y+NET_IFACE_OFFS_IFACENUM + cp r24, r25 ; same interface? + breq appHubSendMsgToAllOthers_next + ; current iface is not source, send and inc ref counter + bigcall NET_Interface_AddOutgoingMsgNum ; (R17, R18, X) + brcs appHubSendMsgToAllOthers_added + ; inc error counter + push r24 + mov r17, r16 ; save r16 + ldi r16, NET_IFACE_OFFS_ERR_NOBUF_LOW + bigcall NET_Interface_IncCounter16 ; (R24, R25) + mov r16, r17 ; restore r16 + pop r24 + rjmp appHubSendMsgToAllOthers_next +appHubSendMsgToAllOthers_added: + mov r17, r16 ; save r16 + bigcall NET_Buffer_IncRef ; (r16) + mov r16, r17 ; restore r16 +appHubSendMsgToAllOthers_next: + ldi r20, COM2W_IFACE_SIZE + add yl, r20 + adc yh, r20 + sub yh, r20 + dec r19 + brne appHubSendMsgToAllOthers_loop + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appHubHandleMsgLocally +; +; @param X pointer to received buffer (points to header byte) +; @param Y pointer to IFACE data from which msg was received +; @clobbers all, !X + +appHubHandleMsgLocally: + push xl + push xh + rcall appHubHandleMsgLocally_savedX + pop xh + pop xl + rjmp appHubHandleMsgLocally_ret +appHubHandleMsgLocally_savedX: + ; get message type + adiw xh:xl, NETMSG_OFFS_CMD+1 ; account for header byte + ld r16, X + sbiw xh:xl, NETMSG_OFFS_CMD+1 + cpi r16, NETMSG_CMD_PING + breq appHubHandleMsgLocally_handlePingMsg + cpi r16, NETMSG_CMD_REBOOT_REQUEST + breq appHubHandleMsgLocally_handleRebootMsg + cpi r16, NETMSG_CMD_VALUE_SET + breq appHubHandleMsgLocally_handleSetValue + rjmp appHubHandleMsgLocally_ret +appHubHandleMsgLocally_handlePingMsg: + rjmp appHubHandlePingMsg +appHubHandleMsgLocally_handleRebootMsg: + rjmp appHubHandleRebootMsg +appHubHandleMsgLocally_handleSetValue: + rjmp appHubHandleSetValueMsg +appHubHandleMsgLocally_ret: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appHubHandlePingMsg +; +; @param X pointer to received message +; @clobbers any, !X, !Y + +appHubHandlePingMsg: + adiw xh:xl, NETMSG_OFFS_DESTADDR+1 + ld r17, X + sbiw xh:xl, NETMSG_OFFS_DESTADDR+1 + ldd r16, Y+NET_IFACE_OFFS_ADDRESS + cp r16, r17 + breq appHubHandlePingMsg_forMe + cpi r17, 0xff + breq appHubHandlePingMsg_forMe + clc + rjmp appHubHandlePingMsg_end +appHubHandlePingMsg_forMe: + adiw xh:xl, NETMSG_OFFS_SRCADDR+1 + ld r17, X + sbiw xh:xl, NETMSG_OFFS_SRCADDR+1 + push r17 + bigcall NET_Buffer_Alloc ; (R16, R17, X) + pop r17 + brcc appHubHandlePingMsg_end ; jmp on error + push r16 ; buffer num + mov r16, r17 ; DEST addr + adiw xh:xl, 1 + bigcall NETMSG_Pong_Write ; (R16, R17, R18, R19, R20, X) + sbiw xh:xl, 1 + pop r16 ; buffer num + bigcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) +appHubHandlePingMsg_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appHubHandleRebootMsg +; +; Doesn't return if reboot msg is valid. +; +; @param X pointer to received message + +appHubHandleRebootMsg: + rcall NETMSG_RebootRequestRead + brcc appHubHandleRebootMsg_end + ; reboot + cli + bigjmp BOOTLOADER_ADDR +appHubHandleRebootMsg_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appHubHandleSetValueMsg +; +; @param X pointer to received message +; @param Y pointer to IFACE data from which msg was received +; @clobbers all, !Y + +appHubHandleSetValueMsg: + adiw xh:xl, NETMSG_OFFS_DESTADDR+1 + ld r17, X + sbiw xh:xl, NETMSG_OFFS_DESTADDR+1 + ldd r16, Y+NET_IFACE_OFFS_ADDRESS + cp r16, r17 + breq appHubHandleSetValueMsg_forMe + cpi r17, 0xff + breq appHubHandleSetValueMsg_forMe + rjmp appHubHandleSetValueMsg_ret +appHubHandleSetValueMsg_forMe: + rcall NETMSG_ValueRead ; (none) + cpi r17, VALUE_ID_HUB_SETRANGE1 + brcs appHubHandleSetValueMsg_ret + cpi r17, VALUE_ID_HUB_SETRANGE8+1 + brcc appHubHandleSetValueMsg_ret +appHubHandleSetValueMsg_setRange: + push yl + push yh + subi r17, (VALUE_ID_HUB_SETRANGE1-1) + push r18 + push r19 + ; send ACK back the same interface the request came from + push r17 ; interface number + ldi r23, NETMSG_CMD_VALUE_SET_ACK + rcall appHubSendValueResponse ; r22 (r16, r17, r18, r19, r20, r21, r23, r24, r25, X) + pop r16 ; pop interface number to r16 (from r17) + rcall appHubGetDeviceByIfaceNum ; Y=interface to modify (r17, r19, r20) + pop r19 + pop r18 + ; modify interface + std Y+NET_IFACE_OFFS_RANGE_BEGIN, r18 + std Y+NET_IFACE_OFFS_RANGE_END, r19 + ; TODO: store new config + + ; let subnodes of modified interface re-eunumerate + ldi r18, NETMSG_CMD_REENUM + rcall appHubSendRangeMsg ; (R16, R17, R18, R19, R20, R21, X) + pop yh + pop yl + +appHubHandleSetValueMsg_ret: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appHubHandleRoutingMsg +; +; @param X pointer to received buffer (points to header byte) +; @param Y pointer to IFACE data from which msg was received +; @clobbers all, !X + +appHubHandleRoutingMsg: + push xl + push xh + rcall appHubHandleRoutingMsg_savedX + pop xh + pop xl + rjmp appHubHandleRoutingMsg_ret +appHubHandleRoutingMsg_savedX: + ; get message type + adiw xh:xl, NETMSG_OFFS_CMD+1 ; account for header byte + ld r16, X + sbiw xh:xl, NETMSG_OFFS_CMD+1 + cpi r16, NETMSG_CMD_NEED_ADDRESS + breq appHubHandleRoutingMsg_handleNeedAddress + cpi r16, NETMSG_CMD_CLAIM_ADDRESS + breq appHubHandleRoutingMsg_handleClaimAddress + clc + rjmp appHubHandleRoutingMsg_ret +appHubHandleRoutingMsg_handleNeedAddress: + rcall appHubHandleNeedAddressMsg + rjmp appHubHandleRoutingMsg_secRet +appHubHandleRoutingMsg_handleClaimAddress: + rcall appHubHandleClaimAddressMsg +appHubHandleRoutingMsg_secRet: + sec +appHubHandleRoutingMsg_ret: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appHubHandleNeedAddressMsg +; +; @param X pointer to received message +; @param Y pointer to IFACE data from which msg was received +; @clobbers all, !Y + +appHubHandleNeedAddressMsg: + ldi r18, NETMSG_CMD_ADDRESS_RANGE + rcall appHubSendRangeMsg ; (R16, R17, R18, R19, R20, R21, X) + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appHubHandleClaimAddressMsg +; +; @param X pointer to received message +; @param Y pointer to IFACE data from which msg was received +; @clobbers all, !Y + +appHubHandleClaimAddressMsg: + rcall NETMSG_Address_Read ; R18=cmd, R19=addr(R18, R19) + rcall appHubIsR19InRange + brcs appHubHandleClaimAddressMsg_end + ; is not in subnet range, deny + rcall appHubSendDenyAddrR19 ; (R16, R17, R18, R19, R20, R21, X) +appHubHandleClaimAddressMsg_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appHubIsR19InRange +; +; @param R19 address to check against range +; @param Y pointer to IFACE data +; @clobbers R16 + +appHubIsR19InRange: + ldd r16, Y+NET_IFACE_OFFS_RANGE_BEGIN + cp r19, r16 + brcs appHubIsR19InRangeClcRet + ldd r16, Y+NET_IFACE_OFFS_RANGE_END + cp r16, r19 + brcs appHubIsR19InRangeClcRet + sec + rjmp appHubIsR19InRange_end +appHubIsR19InRangeClcRet: + clc +appHubIsR19InRange_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appHubCheckRecvdMsg +; +; Read messages from any interface and forward to the other ones. +; +; @return CFLAG set if something done, cleared otherwise + +appHubCheckRecvdMsg: + rcall NET_PeekNextIncomingMsgNum ; check read queue (R16=bufNum) + brcc appHubCheckRecvdMsg_end ; no msg, jmp + rcall NET_Buffer_Locate ; (R17) + rcall appHubHandleRecvdMsg ; (all, !X) + rcall NET_GetNextIncomingMsgNum ; take off the queue + rcall NET_Buffer_ReleaseByNum ; (R16, X) + sec ; we had a message, so something was done +appHubCheckRecvdMsg_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appHubHandleRecvdMsg +; +; @param R16 buffer number +; @param X pointer to received message +; @clobbers all, !X + +appHubHandleRecvdMsg: + mov r18, r16 + ld r16, X + andi r16, 0x0f + rcall appHubGetDeviceByIfaceNum ; Y=source iface (r17, r19, r20) + brcc appHubHandleRecvdMsg_ret + ; filter out routing msgs + push yl + push yh + push r18 + rcall appHubHandleRoutingMsg ; (all, !X) + pop r18 + pop yh + pop yl + brcs appHubHandleRecvdMsg_ret + ; check for PING, SETVALUE etc + push r18 + push yl + push yh + rcall appHubHandleMsgLocally ; (all, !X) + pop yh + pop yl + ; let other apps and modules handle message + push xl + push xh + rcall mainHandleMessages + pop xh + pop xl + pop r18 + ; forward message to all other interfaces + mov r16, r18 ; buffer number + push xl + push xh + rcall appHubSendMsgToAllOthers ; (r17, r19, r20, r24, r25 (r16, r18, X) + pop xh + pop xl +appHubHandleRecvdMsg_ret: + ret +; @end + + + + + + + + + + + + + + + + +; --------------------------------------------------------------------------- +; @routine appHubWriteConfToEeprom +; +; @clobbers R16, X (R17) + +appHubWriteConfToEeprom: + ; write range begin + ldi xl, LOW(EEPROM_OFFS_ROUTER_RANGE_BEGIN) + ldi xh, HIGH(EEPROM_OFFS_ROUTER_RANGE_BEGIN) + lds r16, appHubRangeBegin + rcall Eeprom_WriteByteIfChanged ; (R17) + brcc appHubWriteConfToEeprom_end + + ; write range end + ldi xl, LOW(EEPROM_OFFS_ROUTER_RANGE_END) + ldi xh, HIGH(EEPROM_OFFS_ROUTER_RANGE_END) + lds r16, appHubRangeEnd + rcall Eeprom_WriteByteIfChanged ; (R17) +appHubWriteConfToEeprom_end: + ret +; @end + + +#if 0 +; --------------------------------------------------------------------------- +; @routine appHubReadConfFromEeprom +; +; @clobbers R16, X (R17) + +appHubReadConfFromEeprom: + ; read range begin + ldi xl, LOW(EEPROM_OFFS_ROUTER_RANGE_BEGIN) + ldi xh, HIGH(EEPROM_OFFS_ROUTER_RANGE_BEGIN) + rcall Eeprom_ReadByte + brcc appHubReadConfFromEeprom_end + cpi r16, 0xff + breq appHubReadConfFromEeprom_okay ; not set, jmp + cpi r16, 2 ; range should at least start at 2 to assign 1 to router + brcs appHubReadConfFromEeprom_okay + sts appHubRangeBegin, r16 + dec r16 + sts netInterfaceData+NET_IFACE_OFFS_ADDRESS, r16 ; use addr rangeBegin-1 for router itself + sts netInterfaceData2+NET_IFACE_OFFS_ADDRESS, r16 ; use same address for both interfaces to save on addresses + + ; read range end + ldi xl, LOW(EEPROM_OFFS_ROUTER_RANGE_END) + ldi xh, HIGH(EEPROM_OFFS_ROUTER_RANGE_END) + rcall Eeprom_ReadByte + brcc appHubReadConfFromEeprom_end + cpi r16, 0xff + breq appHubReadConfFromEeprom_okay + sts appHubRangeEnd, r16 +appHubReadConfFromEeprom_okay: + sec +appHubReadConfFromEeprom_end: + ret +; @end +#endif + + + diff --git a/avr/devices/all/apps.asm b/avr/devices/all/apps.asm index 92c89b1..1cc7ebe 100644 --- a/avr/devices/all/apps.asm +++ b/avr/devices/all/apps.asm @@ -33,6 +33,10 @@ initApps: bigcall AppRouter_Init #endif +#ifdef APPS_HUB + bigcall AppHub_Init +#endif + #ifdef APPS_MOTION bigcall AppMotion_Init #endif @@ -74,6 +78,10 @@ runApps: sbci r16, 0 ; decrease r16 only if CFLAG set #endif +#ifdef APPS_HUB + bigcall AppHub_Run +#endif + ; add more modules here tst r16 diff --git a/avr/devices/all/includes.asm b/avr/devices/all/includes.asm index 4c75d55..e166c09 100644 --- a/avr/devices/all/includes.asm +++ b/avr/devices/all/includes.asm @@ -296,6 +296,19 @@ #endif +#ifdef APPS_HUB +.include "apps/hub/main.asm" +.include "modules/network/msg/reboot-d.asm" +.include "modules/network/msg/reboot-r.asm" +.include "modules/network/msg/pong-w.asm" +.include "modules/network/msg/range-d.asm" +.include "modules/network/msg/range-r.asm" +.include "modules/network/msg/range-w.asm" +.include "common/eeprom-r.asm" +.include "common/eeprom-w.asm" +#endif + + #ifdef APPS_REPORTSENSORS .include "apps/reportsensors/data.asm" .include "apps/reportsensors/main.asm" diff --git a/avr/devices/all/modules.asm b/avr/devices/all/modules.asm index 027bb77..36862fe 100644 --- a/avr/devices/all/modules.asm +++ b/avr/devices/all/modules.asm @@ -185,11 +185,8 @@ initModules: ; ; Call run functions of the used modules. Add your routine calls here. ; -; IN: -; - nothing -; OUT: -; - nothing -; USED: depending on called routines +; @return CFLAG set: at least one RUN routine returned CFLAG set +; @clobbers all runModules: clr r16 @@ -197,6 +194,7 @@ runModules: push r16 bigcall BaseTimer_Run pop r16 + sbci r16, 0 #ifdef MODULES_TTYONUART1 push r16 @@ -204,10 +202,40 @@ runModules: pop r16 #endif +#ifdef MODULES_COMONUART0 push r16 - rcall runComModules + bigcall ComOnUart0_Run pop r16 sbci r16, 0 +#endif + +#ifdef MODULES_COMONUART1 + push r16 + bigcall ComOnUart1_Run + pop r16 + sbci r16, 0 +#endif + +#ifdef MODULES_COM2W0 + push r16 + bigcall COM2W0_Run + pop r16 + sbci r16, 0 +#endif + +#ifdef MODULES_COM2W1 + push r16 + bigcall COM2W1_Run + pop r16 + sbci r16, 0 +#endif + +#ifdef MODULES_COM2WN + push r16 + bigcall COM2WN_Run + pop r16 + sbci r16, 0 +#endif ; add more modules here @@ -218,67 +246,7 @@ runModules: sec runModules_end: ret - - -; run until every module idle - -runComModules: - clr r17 -runComModules_loop: - push r17 - clr r16 -#ifdef MODULES_COMONUART0 - push r16 - bigcall ComOnUart0_Run - pop r16 - sbci r16, 0 -#endif - -#ifdef MODULES_COMONUART1 - push r16 - bigcall ComOnUart1_Run - pop r16 - sbci r16, 0 -#endif - -#ifdef MODULES_COM2W0 - push r16 - bigcall COM2W0_Run - pop r16 - sbci r16, 0 -#endif - -#ifdef MODULES_COM2W1 - push r16 - bigcall COM2W1_Run - pop r16 - sbci r16, 0 -#endif - -#ifdef MODULES_COM2WN - push r16 - bigcall COM2WN_Run - pop r16 - sbci r16, 0 -#endif - - pop r17 - ; check for repeat request - tst r16 - clc - breq runComModules_loopEnd - inc r17 - cpi r17, 2 - brne runComModules_loop -runComModules_loopEnd: - tst r17 - clc - breq runComModules_end - sec -runComModules_end: - ret - - +; @end mainModulesOnPacketReceived: From fa404a5fcf759d1c1794dee342ae7b243c47f88f Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 18 Aug 2025 18:06:56 +0200 Subject: [PATCH 132/196] increase number of runs to 10 (was: 2) --- avr/devices/all/main.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avr/devices/all/main.asm b/avr/devices/all/main.asm index d5d5047..1615d36 100644 --- a/avr/devices/all/main.asm +++ b/avr/devices/all/main.asm @@ -79,7 +79,7 @@ main_runLoop: tst r16 breq main_endRunLoop inc r17 - cpi r17, 2 + cpi r17, 10 brcc main_endRunLoop brne main_runLoop main_endRunLoop: From 6bf8f03fbb91ca957c3ef5e33217209a203a4166 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 18 Aug 2025 18:07:34 +0200 Subject: [PATCH 133/196] added node S03. --- avr/devices/0BUILD | 1 + avr/devices/s03/.gitignore | 2 + avr/devices/s03/0BUILD | 22 +++ avr/devices/s03/README | 9 ++ avr/devices/s03/aqua_s03.xml | 12 ++ avr/devices/s03/boot/0BUILD | 32 +++++ avr/devices/s03/boot/boot.asm | 159 ++++++++++++++++++++++ avr/devices/s03/defs.asm | 127 ++++++++++++++++++ avr/devices/s03/main/0BUILD | 34 +++++ avr/devices/s03/main/data.asm | 14 ++ avr/devices/s03/main/main.asm | 244 ++++++++++++++++++++++++++++++++++ flashnode.sh | 7 + 12 files changed, 663 insertions(+) create mode 100644 avr/devices/s03/.gitignore create mode 100644 avr/devices/s03/0BUILD create mode 100644 avr/devices/s03/README create mode 100644 avr/devices/s03/aqua_s03.xml create mode 100644 avr/devices/s03/boot/0BUILD create mode 100644 avr/devices/s03/boot/boot.asm create mode 100644 avr/devices/s03/defs.asm create mode 100644 avr/devices/s03/main/0BUILD create mode 100644 avr/devices/s03/main/data.asm create mode 100644 avr/devices/s03/main/main.asm diff --git a/avr/devices/0BUILD b/avr/devices/0BUILD index 94f5ce1..99d2668 100644 --- a/avr/devices/0BUILD +++ b/avr/devices/0BUILD @@ -41,6 +41,7 @@ r05 r06 t03 + s03 diff --git a/avr/devices/s03/.gitignore b/avr/devices/s03/.gitignore new file mode 100644 index 0000000..8e0618c --- /dev/null +++ b/avr/devices/s03/.gitignore @@ -0,0 +1,2 @@ +*.eep.hex +*.obj diff --git a/avr/devices/s03/0BUILD b/avr/devices/s03/0BUILD new file mode 100644 index 0000000..0829603 --- /dev/null +++ b/avr/devices/s03/0BUILD @@ -0,0 +1,22 @@ + + + + + + boot + main + + + + aqua_s03.xml + + + + defs.asm + README + + + + + + diff --git a/avr/devices/s03/README b/avr/devices/s03/README new file mode 100644 index 0000000..b6eff6d --- /dev/null +++ b/avr/devices/s03/README @@ -0,0 +1,9 @@ + +S03 +=== + +- Role: Router +- MCU: AtMega 644P +- Connection: RJ45 +- Periphery: + diff --git a/avr/devices/s03/aqua_s03.xml b/avr/devices/s03/aqua_s03.xml new file mode 100644 index 0000000..6e9685a --- /dev/null +++ b/avr/devices/s03/aqua_s03.xml @@ -0,0 +1,12 @@ + + + AQUA + S + 3 + + + + + + + diff --git a/avr/devices/s03/boot/0BUILD b/avr/devices/s03/boot/0BUILD new file mode 100644 index 0000000..2dae797 --- /dev/null +++ b/avr/devices/s03/boot/0BUILD @@ -0,0 +1,32 @@ + + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + boot.asm + + + + + + + + + + + + + + + + diff --git a/avr/devices/s03/boot/boot.asm b/avr/devices/s03/boot/boot.asm new file mode 100644 index 0000000..18e3064 --- /dev/null +++ b/avr/devices/s03/boot/boot.asm @@ -0,0 +1,159 @@ +; *************************************************************************** +; Source file for base system node on AtMega 644P +; +; This is for the maintenance system (i.e. the flash loader). +; +; All definitions and changes should go into this file. +; *************************************************************************** + +.equ clock=20000000 ; Define the clock frequency + +.nolist +.include "include/m644Pdef.inc" ; Define device ATmega644P +.list + +.include "../defs.asm" +.include "devices/all/defs.asm" + +.include "common/calls.asm" +.include "common/utils_wait.asm" +.include "common/utils_io.asm" + + + +; *************************************************************************** +; defines + +; --------------------------------------------------------------------------- +; generic + + +.equ NET_BUFFERS_NUM = 6 +.equ NET_BUFFERS_SIZE = 32 + + + +; --------------------------------------------------------------------------- +; firmware settings + +.equ FIRMWARE_VERSION_MAJOR = 0 +.equ FIRMWARE_VERSION_MINOR = 0 +.equ FIRMWARE_VERSION_PATCHLEVEL = 1 + + + +; --------------------------------------------------------------------------- +; LED + +.equ LED_DDR = DDRB +.equ LED_PORT = PORTB +.equ LED_PIN = PINB +.equ LED_PINNUM = PORTB0 + + + + + +; *************************************************************************** +; code segment + +.cseg +.org 0x0000 + + + +; --------------------------------------------------------------------------- +; Reset and interrupt vectors + jmp main ; 1: Reset vector RESET + jmp irqNotSet ; 2: INT0 External Interrupt Request 0 + jmp irqNotSet ; 3: INT1 External Interrupt Request 1 + jmp irqNotSet ; 4: INT2 External Interrupt Request 2 + jmp irqNotSet ; 5: PCINT0 Pin Change Interrupt Request 0 + jmp irqNotSet ; 6: PCINT1 Pin Change Interrupt Request 1 + jmp irqNotSet ; 7: PCINT2 Pin Change Interrupt Request 2 + jmp irqNotSet ; 8: PCINT3 Pin Change Interrupt Request 3 + jmp irqNotSet ; 9: WDT Watchdog Time-out Interrupt + jmp irqNotSet ; 10: TIMER2_COMPA Timer/Counter2 Compare Match A + jmp irqNotSet ; 11: TIMER2_COMPB Timer/Counter2 Compare Match B + jmp irqNotSet ; 12: TIMER2_OVF Timer/Counter2 Overflow + jmp irqNotSet ; 13: TIMER1_CAPT Timer/Counter1 Capture Event + jmp irqNotSet ; 14: TIMER1_COMPA Timer/Counter1 Compare Match A + jmp irqNotSet ; 15: TIMER1_COMPB Timer/Counter1 Compare Match B + jmp irqNotSet ; 16: TIMER1_OVF Timer/Counter1 Overflow + jmp irqNotSet ; 17: TIMER0_COMPA Timer/Counter0 Compare Match A + jmp irqNotSet ; 18: TIMER0_COMPB Timer/Counter0 Compare Match B + jmp irqNotSet ; 19: TIMER0_OVF Timer/Counter0 Overflow + jmp irqNotSet ; 20: SPI_STC Serial Transfer Complete + jmp irqNotSet ; 21: USART0_RXC USART0 Rx Complete + jmp irqNotSet ; 22: USART0_UDRE USART0 Data Register Empty + jmp irqNotSet ; 23: USART0_TXC USART0 Tx Complete + jmp irqNotSet ; 24: ANA_COMP Analog Comparator + jmp irqNotSet ; 25: ADC ADC Conversion Complete + jmp irqNotSet ; 26: EE_RDY EEPROM Ready + jmp irqNotSet ; 27: TWI 2-Wire Interface + jmp irqNotSet ; 28: SPM_RDY Store Program Memory Ready + + + +; --------------------------------------------------------------------------- +; Device Info Block + +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: + jmp main ; will be overwritten when flashing + +irqNotSet: + reti + + + +; *************************************************************************** +; main code + + +.org BOOTLOADER_ADDR + + +main: +; ldi r16, 0xb0 ; orig: a0 +; out OSCCAL, r16 + jmp bootLoader ; this routine is in modules/bootloader/main.asm + + + +; *************************************************************************** +; includes + +.include "common/wait_10us.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/flash1pmega.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: + ; speed not changeable at runtime on this device + ret + + + + diff --git a/avr/devices/s03/defs.asm b/avr/devices/s03/defs.asm new file mode 100644 index 0000000..b284a31 --- /dev/null +++ b/avr/devices/s03/defs.asm @@ -0,0 +1,127 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + +; *************************************************************************** +; +; AtMega644 +; -------- +; LED PB0 1 40 PA0 COM0-CLK +; PB1 2 39 PA1 COM1-CLK +; PB2 3 38 PA2 COM2-CLK +; PB3 4 37 PA3 COM3-CLK +; PB4 5 36 PA4 COM4-CLK +; MOSI PB5 6 35 PA5 COM5-CLK +; MISO PB6 7 34 PA6 COM6-CLK +; SCK PB7 8 33 PA7 COM7-CLK +; /RESET 9 32 AREF +; VCC 10 31 GND +; GND 11 30 AVCC +; XTAL2 12 29 PC7 COM7-DATA +; XTAL1 13 28 PC6 COM6-DATA +; COM0-LED PD0 14 27 PC5 COM5-DATA +; COM1-LED PD1 15 26 PC4 COM4-DATA +; COM2-LED PD2 16 25 PC3 COM3-DATA +; COM3-LED PD3 17 24 PC2 COM2-DATA +; COM4-LED PD4 18 23 PC1 COM1-DATA +; COM5-LED PD5 19 22 PC0 COM0-DATA +; COM6-LED PD6 20 21 COM7-LED +; -------- +; +; *************************************************************************** + + + +.equ BOOTLOADER_ADDR = 0x7c00 + +.equ FIRMWARE_VARIANT_BOOT = 0 +.equ FIRMWARE_VARIANT_TEMP_WINDOW = 1 + +.equ DEVICEINFO_ID = 'S' +.equ DEVICEINFO_VERSION = 3 +.equ DEVICEINFO_REVISION = 0 + + + +; --------------------------------------------------------------------------- +; LED module + +.equ LED_SIMPLE_ONTIME = 1 ; shorter +.equ LED_SIMPLE_OFFTIME = 50 ; longer +.equ LED_SIMPLE_DDR = DDRB +.equ LED_SIMPLE_PORT = PORTB +.equ LED_SIMPLE_PORTIN = PINB +.equ LED_SIMPLE_PINNUM = PORTB0 + + + +; --------------------------------------------------------------------------- +; COM module + +.equ COM_BIT_LENGTH = 52000 ; 104000ns=9600, 52000ns=19200, 26000ns=38400 +.equ COM_HALFBIT_LENGTH = 26000 ; see https://de.wikipedia.org/wiki/Universal_Asynchronous_Receiver_Transmitter + +.equ COM_DATA_DDR = DDRC +.equ COM_DATA_INPUT = PINC +.equ COM_DATA_OUTPUT = PORTC +.equ COM_DATA_PIN = PORTC6 + +.equ COM_CLK_DDR = DDRA +.equ COM_CLK_INPUT = PINA +.equ COM_CLK_OUTPUT = PORTA +.equ COM_CLK_PIN = PORTA6 + +.equ COM_IRQ_ADDR_M_CLK = PCICR +.equ COM_IRQ_BIT_M_CLK = PCIE0 + +.equ COM_IRQ_ADDR_F_CLK = PCIFR +.equ COM_IRQ_BIT_F_CLK = PCIF0 + +.equ COM_IRQ_ADDR_CLK = PCMSK0 + + + +.equ COM_PORTS = 8 + +.equ COM_MASK_CLK0 = (1< + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + main.asm + + + + + + + + + + + + data.asm + + + + + + diff --git a/avr/devices/s03/main/data.asm b/avr/devices/s03/main/data.asm new file mode 100644 index 0000000..31ccc2f --- /dev/null +++ b/avr/devices/s03/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/s03/main/main.asm b/avr/devices/s03/main/main.asm new file mode 100644 index 0000000..c8773f1 --- /dev/null +++ b/avr/devices/s03/main/main.asm @@ -0,0 +1,244 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + +;.equ clock=1000000 ; Define the clock frequency +.equ clock=20000000 ; Define the clock frequency + + + +.nolist +.include "include/m644Pdef.inc" ; Define device ATmega644P +.list + +.include "version.asm" +.include "../defs.asm" +.include "./data.asm" + +.include "devices/all/defs.asm" +.include "common/calls.asm" +.include "common/utils_wait.asm" +.include "common/utils_io.asm" + + + +; *************************************************************************** +; defines + +; --------------------------------------------------------------------------- +; generic + +.equ NET_BUFFERS_NUM = 96 +.equ NET_MSGNUMINBUF_SIZE = 64 ; max buffer nums in ringbuffer (global incoming) +.equ NET_IFACE_OUTMSGBUF_SIZE = 16 ; max buffer nums in ringbuffer (per interface outbound) +.equ COM2WN_IO_RINGBUFFER_SIZE = 128 + + + +; --------------------------------------------------------------------------- +; firmware settings including list of modules used + +#define MAIN_WITHOUT_MSG_HANDLING ; message handling done here + +; #define MODULES_TIMER +#define MODULES_CLOCK +;#define MODULES_XRAM +;#define MODULES_HEAP +#define MODULES_LED_SIMPLE +#define MODULES_NETWORK +#define MODULES_COM2WN +;#define MODULES_COMONUART0 +;#define MODULES_UART_HW +;#define MODULES_UART_BITBANG +;#define MODULES_SPI_HW +;#define MODULES_ILI9341 +;#define MODULES_FONT +;#define MODULES_WIN +;#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 +#define APPS_HUB + + + +; --------------------------------------------------------------------------- +; defines for values + +.equ VALUE_ID_HUB_SETRANGE1 = 0x11 +.equ VALUE_ID_HUB_SETRANGE2 = 0x12 +.equ VALUE_ID_HUB_SETRANGE3 = 0x13 +.equ VALUE_ID_HUB_SETRANGE4 = 0x14 +.equ VALUE_ID_HUB_SETRANGE5 = 0x15 +.equ VALUE_ID_HUB_SETRANGE6 = 0x16 +.equ VALUE_ID_HUB_SETRANGE7 = 0x17 +.equ VALUE_ID_HUB_SETRANGE8 = 0x18 + +.equ VALUE_ID_DEBUG = 0x7f + +.equ VALUE_ID_LEDSIMPLE_TIMING = 0x88 + + + + + +; *************************************************************************** +; code segment + +.cseg +.org 000000 + + + +; --------------------------------------------------------------------------- +; Reset and interrupt vectors + jmp BOOTLOADER_ADDR ; 1: Reset vector RESET + jmp irqNotSet ; 2: INT0 External Interrupt Request 0 + jmp irqNotSet ; 3: INT1 External Interrupt Request 1 + jmp irqNotSet ; 4: INT2 External Interrupt Request 2 + jmp COM2WN_ClkChangeIsr ; 5: PCINT0 Pin Change Interrupt Request 0 + jmp irqNotSet ; 6: PCINT1 Pin Change Interrupt Request 1 + jmp irqNotSet ; 7: PCINT2 Pin Change Interrupt Request 2 + jmp irqNotSet ; 8: PCINT3 Pin Change Interrupt Request 3 + jmp irqNotSet ; 9: WDT Watchdog Time-out Interrupt + jmp irqNotSet ; 10: TIMER2_COMPA Timer/Counter2 Compare Match A + jmp irqNotSet ; 11: TIMER2_COMPB Timer/Counter2 Compare Match B + jmp irqNotSet ; 12: TIMER2_OVF Timer/Counter2 Overflow + jmp irqNotSet ; 13: TIMER1_CAPT Timer/Counter1 Capture Event + jmp irqNotSet ; 14: TIMER1_COMPA Timer/Counter1 Compare Match A + jmp irqNotSet ; 15: TIMER1_COMPB Timer/Counter1 Compare Match B + jmp irqNotSet ; 16: TIMER1_OVF Timer/Counter1 Overflow + jmp baseTimerIrqOC0A ; 17: TIMER0_COMPA Timer/Counter0 Compare Match A + jmp irqNotSet ; 18: TIMER0_COMPB Timer/Counter0 Compare Match B + jmp irqNotSet ; 19: TIMER0_OVF Timer/Counter0 Overflow + jmp irqNotSet ; 20: SPI_STC Serial Transfer Complete + jmp irqNotSet ; 21: USART0_RXC USART0 Rx Complete + jmp irqNotSet ; 22: USART0_UDRE USART0 Data Register Empty + jmp irqNotSet ; 23: USART0_TXC USART0 Tx Complete + jmp irqNotSet ; 24: ANA_COMP Analog Comparator + jmp irqNotSet ; 25: ADC ADC Conversion Complete + jmp irqNotSet ; 26: EE_RDY EEPROM Ready + jmp irqNotSet ; 27: TWI 2-Wire Interface + jmp irqNotSet ; 28: SPM_RDY Store Program Memory Ready + + + +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 + + +irqNotSet: + reti + + + +; --------------------------------------------------------------------------- +; @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_m644p.asm" +.include "devices/all/includes.asm" + +;.include "common/debug.asm" + +;.include "modules/lcd2/font/font2.asm" +;.include "modules/lcd2/font/font3.asm" +;.include "modules/lcd2/font/font16x26.asm" +;.include "modules/lcd2/font/font4.asm" +;.include "modules/lcd2/font/font12x16.asm" +;.include "modules/lcd2/font/font5.asm" +;.include "modules/lcd2/font/font12x20.asm" +;.include "common/list_t.asm" +;.include "common/tree_t.asm" +;.include "common/divide.asm" + + +; --------------------------------------------------------------------------- +; defines for network interface + +;.equ netInterfaceData = netUartIface +;.equ netInterfaceData = uart_bitbang_iface +.equ netInterfaceData = com2w0_iface + + + + + diff --git a/flashnode.sh b/flashnode.sh index ba15e05..6370233 100755 --- a/flashnode.sh +++ b/flashnode.sh @@ -107,6 +107,13 @@ case $NODE in EFUSE_ARG="-U efuse:w:0xFE:m" FILE_ARG="-U flash:w:./0-build/avr/devices/r05/boot/r05_boot.hex" ;; + s03) + DEVICE_ARG="-p m644p" + HFUSE_ARG="-U hfuse:w:0x95:m" + LFUSE_ARG="-U lfuse:w:0xdF:m" + EFUSE_ARG="-U efuse:w:0xFF:m" + FILE_ARG="-U flash:w:./0-build/avr/devices/s03/boot/s03_boot.hex" + ;; t03) DEVICE_ARG="-p t841" HFUSE_ARG="-U hfuse:w:0xD7:m" From f9d721ac02c0dc481fc2839e2b88c065eb72e576 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 18 Aug 2025 18:46:46 +0200 Subject: [PATCH 134/196] removed unused device nodes. - n00 - n06 - n11 - n12 - n15 - n17 - n18 - n19 - n20 - n22 - n23 - r02 - r04 - x03 --- avr/devices/0BUILD | 7 +- avr/devices/n00/.gitignore | 2 - avr/devices/n00/0BUILD | 52 ---- avr/devices/n00/n00_boot.asm | 143 --------- avr/devices/n00/n00_defs.asm | 135 --------- avr/devices/n00/n00_main.asm | 363 ---------------------- avr/devices/n06/.gitignore | 2 - avr/devices/n06/0BUILD | 52 ---- avr/devices/n06/n06_boot.asm | 142 --------- avr/devices/n06/n06_defs.asm | 139 --------- avr/devices/n06/n06_main.asm | 363 ---------------------- avr/devices/n11/.gitignore | 2 - avr/devices/n11/0BUILD | 52 ---- avr/devices/n11/n11_boot.asm | 142 --------- avr/devices/n11/n11_defs.asm | 172 ----------- avr/devices/n11/n11_main.asm | 522 -------------------------------- avr/devices/n12/.gitignore | 2 - avr/devices/n12/0BUILD | 52 ---- avr/devices/n12/n12_boot.asm | 144 --------- avr/devices/n12/n12_defs.asm | 175 ----------- avr/devices/n12/n12_main.asm | 480 ----------------------------- avr/devices/n15/.gitignore | 2 - avr/devices/n15/0BUILD | 52 ---- avr/devices/n15/n15_boot.asm | 178 ----------- avr/devices/n15/n15_defs.asm | 176 ----------- avr/devices/n15/n15_main.asm | 462 ---------------------------- avr/devices/n17/.gitignore | 2 - avr/devices/n17/0BUILD | 52 ---- avr/devices/n17/n17_boot.asm | 178 ----------- avr/devices/n17/n17_defs.asm | 127 -------- avr/devices/n17/n17_main.asm | 459 ---------------------------- avr/devices/n18/.gitignore | 2 - avr/devices/n18/0BUILD | 52 ---- avr/devices/n18/boot.asm | 140 --------- avr/devices/n18/defs.asm | 103 ------- avr/devices/n18/main.asm | 379 ----------------------- avr/devices/n19/.gitignore | 2 - avr/devices/n19/0BUILD | 17 -- avr/devices/n19/README | 13 - avr/devices/n19/boot/0BUILD | 32 -- avr/devices/n19/boot/boot.asm | 138 --------- avr/devices/n19/defs.asm | 104 ------- avr/devices/n19/main/0BUILD | 33 -- avr/devices/n19/main/main.asm | 176 ----------- avr/devices/n20/.gitignore | 2 - avr/devices/n20/0BUILD | 17 -- avr/devices/n20/README | 13 - avr/devices/n20/boot/0BUILD | 32 -- avr/devices/n20/boot/boot.asm | 129 -------- avr/devices/n20/defs.asm | 135 --------- avr/devices/n20/main/0BUILD | 33 -- avr/devices/n20/main/main.asm | 222 -------------- avr/devices/n22/.gitignore | 2 - avr/devices/n22/0BUILD | 17 -- avr/devices/n22/README | 15 - avr/devices/n22/boot/0BUILD | 32 -- avr/devices/n22/boot/boot.asm | 129 -------- avr/devices/n22/defs.asm | 88 ------ avr/devices/n22/main/0BUILD | 33 -- avr/devices/n22/main/main.asm | 206 ------------- avr/devices/n23/.gitignore | 2 - avr/devices/n23/0BUILD | 22 -- avr/devices/n23/README | 14 - avr/devices/n23/aqua_n23.xml | 28 -- avr/devices/n23/boot/0BUILD | 32 -- avr/devices/n23/boot/boot.asm | 134 -------- avr/devices/n23/defs.asm | 148 --------- avr/devices/n23/main/0BUILD | 34 --- avr/devices/n23/main/data.asm | 14 - avr/devices/n23/main/main.asm | 221 -------------- avr/devices/r02/.gitignore | 2 - avr/devices/r02/0BUILD | 52 ---- avr/devices/r02/boot.asm | 163 ---------- avr/devices/r02/defs.asm | 87 ------ avr/devices/r02/main.asm | 448 --------------------------- avr/devices/r04/.gitignore | 2 - avr/devices/r04/0BUILD | 23 -- avr/devices/r04/README | 13 - avr/devices/r04/aqua_r04.xml | 34 --- avr/devices/r04/boot/0BUILD | 32 -- avr/devices/r04/boot/boot.asm | 152 ---------- avr/devices/r04/defs.asm | 118 -------- avr/devices/r04/main/0BUILD | 33 -- avr/devices/r04/main/main.asm | 418 ------------------------- avr/devices/r04/test/0BUILD | 33 -- avr/devices/r04/test/main.asm | 259 ---------------- avr/devices/x03/0BUILD | 11 - avr/devices/x03/ccs811/0BUILD | 52 ---- avr/devices/x03/ccs811/boot.asm | 124 -------- avr/devices/x03/ccs811/defs.asm | 134 -------- avr/devices/x03/ccs811/main.asm | 344 --------------------- avr/devices/x03/uart/.gitignore | 2 - avr/devices/x03/uart/0BUILD | 52 ---- avr/devices/x03/uart/boot.asm | 162 ---------- avr/devices/x03/uart/defs.asm | 72 ----- avr/devices/x03/uart/main.asm | 221 -------------- 96 files changed, 1 insertion(+), 10818 deletions(-) delete mode 100644 avr/devices/n00/.gitignore delete mode 100644 avr/devices/n00/0BUILD delete mode 100644 avr/devices/n00/n00_boot.asm delete mode 100644 avr/devices/n00/n00_defs.asm delete mode 100644 avr/devices/n00/n00_main.asm delete mode 100644 avr/devices/n06/.gitignore delete mode 100644 avr/devices/n06/0BUILD delete mode 100644 avr/devices/n06/n06_boot.asm delete mode 100644 avr/devices/n06/n06_defs.asm delete mode 100644 avr/devices/n06/n06_main.asm delete mode 100644 avr/devices/n11/.gitignore delete mode 100644 avr/devices/n11/0BUILD delete mode 100644 avr/devices/n11/n11_boot.asm delete mode 100644 avr/devices/n11/n11_defs.asm delete mode 100644 avr/devices/n11/n11_main.asm delete mode 100644 avr/devices/n12/.gitignore delete mode 100644 avr/devices/n12/0BUILD delete mode 100644 avr/devices/n12/n12_boot.asm delete mode 100644 avr/devices/n12/n12_defs.asm delete mode 100644 avr/devices/n12/n12_main.asm delete mode 100644 avr/devices/n15/.gitignore delete mode 100644 avr/devices/n15/0BUILD delete mode 100644 avr/devices/n15/n15_boot.asm delete mode 100644 avr/devices/n15/n15_defs.asm delete mode 100644 avr/devices/n15/n15_main.asm delete mode 100644 avr/devices/n17/.gitignore delete mode 100644 avr/devices/n17/0BUILD delete mode 100644 avr/devices/n17/n17_boot.asm delete mode 100644 avr/devices/n17/n17_defs.asm delete mode 100644 avr/devices/n17/n17_main.asm delete mode 100644 avr/devices/n18/.gitignore delete mode 100644 avr/devices/n18/0BUILD delete mode 100644 avr/devices/n18/boot.asm delete mode 100644 avr/devices/n18/defs.asm delete mode 100644 avr/devices/n18/main.asm delete mode 100644 avr/devices/n19/.gitignore delete mode 100644 avr/devices/n19/0BUILD delete mode 100644 avr/devices/n19/README delete mode 100644 avr/devices/n19/boot/0BUILD delete mode 100644 avr/devices/n19/boot/boot.asm delete mode 100644 avr/devices/n19/defs.asm delete mode 100644 avr/devices/n19/main/0BUILD delete mode 100644 avr/devices/n19/main/main.asm delete mode 100644 avr/devices/n20/.gitignore delete mode 100644 avr/devices/n20/0BUILD delete mode 100644 avr/devices/n20/README delete mode 100644 avr/devices/n20/boot/0BUILD delete mode 100644 avr/devices/n20/boot/boot.asm delete mode 100644 avr/devices/n20/defs.asm delete mode 100644 avr/devices/n20/main/0BUILD delete mode 100644 avr/devices/n20/main/main.asm delete mode 100644 avr/devices/n22/.gitignore delete mode 100644 avr/devices/n22/0BUILD delete mode 100644 avr/devices/n22/README delete mode 100644 avr/devices/n22/boot/0BUILD delete mode 100644 avr/devices/n22/boot/boot.asm delete mode 100644 avr/devices/n22/defs.asm delete mode 100644 avr/devices/n22/main/0BUILD delete mode 100644 avr/devices/n22/main/main.asm delete mode 100644 avr/devices/n23/.gitignore delete mode 100644 avr/devices/n23/0BUILD delete mode 100644 avr/devices/n23/README delete mode 100644 avr/devices/n23/aqua_n23.xml delete mode 100644 avr/devices/n23/boot/0BUILD delete mode 100644 avr/devices/n23/boot/boot.asm delete mode 100644 avr/devices/n23/defs.asm delete mode 100644 avr/devices/n23/main/0BUILD delete mode 100644 avr/devices/n23/main/data.asm delete mode 100644 avr/devices/n23/main/main.asm delete mode 100644 avr/devices/r02/.gitignore delete mode 100644 avr/devices/r02/0BUILD delete mode 100644 avr/devices/r02/boot.asm delete mode 100644 avr/devices/r02/defs.asm delete mode 100644 avr/devices/r02/main.asm delete mode 100644 avr/devices/r04/.gitignore delete mode 100644 avr/devices/r04/0BUILD delete mode 100644 avr/devices/r04/README delete mode 100644 avr/devices/r04/aqua_r04.xml delete mode 100644 avr/devices/r04/boot/0BUILD delete mode 100644 avr/devices/r04/boot/boot.asm delete mode 100644 avr/devices/r04/defs.asm delete mode 100644 avr/devices/r04/main/0BUILD delete mode 100644 avr/devices/r04/main/main.asm delete mode 100644 avr/devices/r04/test/0BUILD delete mode 100644 avr/devices/r04/test/main.asm delete mode 100644 avr/devices/x03/0BUILD delete mode 100644 avr/devices/x03/ccs811/0BUILD delete mode 100644 avr/devices/x03/ccs811/boot.asm delete mode 100644 avr/devices/x03/ccs811/defs.asm delete mode 100644 avr/devices/x03/ccs811/main.asm delete mode 100644 avr/devices/x03/uart/.gitignore delete mode 100644 avr/devices/x03/uart/0BUILD delete mode 100644 avr/devices/x03/uart/boot.asm delete mode 100644 avr/devices/x03/uart/defs.asm delete mode 100644 avr/devices/x03/uart/main.asm diff --git a/avr/devices/0BUILD b/avr/devices/0BUILD index 99d2668..be0570c 100644 --- a/avr/devices/0BUILD +++ b/avr/devices/0BUILD @@ -28,20 +28,15 @@ c02 n14 n16 - n19 - n20 n21 - n22 - n23 n24 n25 n26 n27 - r04 r05 r06 - t03 s03 + t03 diff --git a/avr/devices/n00/.gitignore b/avr/devices/n00/.gitignore deleted file mode 100644 index 8e0618c..0000000 --- a/avr/devices/n00/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.eep.hex -*.obj diff --git a/avr/devices/n00/0BUILD b/avr/devices/n00/0BUILD deleted file mode 100644 index aaaaf7e..0000000 --- a/avr/devices/n00/0BUILD +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - n00_main.asm - - - - - - - - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - n00_boot.asm - - - - - - - - - - - n00_defs.asm - - - - - - diff --git a/avr/devices/n00/n00_boot.asm b/avr/devices/n00/n00_boot.asm deleted file mode 100644 index 209cd84..0000000 --- a/avr/devices/n00/n00_boot.asm +++ /dev/null @@ -1,143 +0,0 @@ -; *************************************************************************** -; 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 "./n00_defs.asm" -.include "defs_all.asm" - - - -; *************************************************************************** -; defines - -; --------------------------------------------------------------------------- -; generic - -.include "common/utils_wait.asm" -.include "modules/com2/defs.asm" -.include "modules/comproto/defs.asm" - - - -; --------------------------------------------------------------------------- -; firmware settings - -.equ FIRMWARE_VERSION_MAJOR = 0 -.equ FIRMWARE_VERSION_MINOR = 0 -.equ FIRMWARE_VERSION_PATCHLEVEL = 1 - - - -; --------------------------------------------------------------------------- -; 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 'N', 0 -devInfoVersion: .db 0, 1 ; 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/flash/proto.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/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 - - - - - n06_main.asm - - - - - - - - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - n06_boot.asm - - - - - - - - - - - n06_defs.asm - - - - - - diff --git a/avr/devices/n06/n06_boot.asm b/avr/devices/n06/n06_boot.asm deleted file mode 100644 index cf83e97..0000000 --- a/avr/devices/n06/n06_boot.asm +++ /dev/null @@ -1,142 +0,0 @@ -; *************************************************************************** -; 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 "./n06_defs.asm" -.include "defs_all.asm" - - - -; *************************************************************************** -; defines - -; --------------------------------------------------------------------------- -; generic - -.include "common/utils_wait.asm" -.include "modules/com2/defs.asm" -.include "modules/comproto/defs.asm" - - - -; --------------------------------------------------------------------------- -; firmware settings - -.equ FIRMWARE_VERSION_MAJOR = 0 -.equ FIRMWARE_VERSION_MINOR = 0 -.equ FIRMWARE_VERSION_PATCHLEVEL = 1 - - - -; --------------------------------------------------------------------------- -; 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/flash/proto.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/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 - - - - - 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 deleted file mode 100644 index 5db7a4d..0000000 --- a/avr/devices/n11/n11_boot.asm +++ /dev/null @@ -1,142 +0,0 @@ -; *************************************************************************** -; 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 "n11_defs.asm" -.include "defs_all.asm" - - - -; *************************************************************************** -; defines - -; --------------------------------------------------------------------------- -; generic - -.include "common/utils_wait.asm" -.include "modules/com2/defs.asm" -.include "modules/comproto/defs.asm" - - - -; --------------------------------------------------------------------------- -; firmware settings - -.equ FIRMWARE_VERSION_MAJOR = 0 -.equ FIRMWARE_VERSION_MINOR = 0 -.equ FIRMWARE_VERSION_PATCHLEVEL = 1 - - - -; --------------------------------------------------------------------------- -; 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/flash/proto.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/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 - - - - - n12_main.asm - - - - - - - - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - n12_boot.asm - - - - - - - - - - - n12_defs.asm - - - - - - diff --git a/avr/devices/n12/n12_boot.asm b/avr/devices/n12/n12_boot.asm deleted file mode 100644 index 58f20d8..0000000 --- a/avr/devices/n12/n12_boot.asm +++ /dev/null @@ -1,144 +0,0 @@ -; *************************************************************************** -; 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 "n12_defs.asm" -.include "defs_all.asm" - - - -; *************************************************************************** -; defines - -; --------------------------------------------------------------------------- -; generic - -.include "common/utils_wait.asm" -.include "modules/com2/defs.asm" -.include "modules/comproto/defs.asm" - - -; --------------------------------------------------------------------------- -; firmware settings - -.equ FIRMWARE_VERSION_MAJOR = 0 -.equ FIRMWARE_VERSION_MINOR = 0 -.equ FIRMWARE_VERSION_PATCHLEVEL = 1 - - -; --------------------------------------------------------------------------- -; LED - -.equ LED_DDR = DDRA -.equ LED_PORT = PORTA -.equ LED_PIN = PINA -.equ LED_PINNUM = PORTA7 - - - -; *************************************************************************** -; 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/flash/proto.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/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 - - - - - n15_main.asm - - - - - - - - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - n15_boot.asm - - - - - - - - - - - n15_defs.asm - - - - - - diff --git a/avr/devices/n15/n15_boot.asm b/avr/devices/n15/n15_boot.asm deleted file mode 100644 index b64771d..0000000 --- a/avr/devices/n15/n15_boot.asm +++ /dev/null @@ -1,178 +0,0 @@ -; *************************************************************************** -; 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 "n15_defs.asm" -.include "defs_all.asm" - - - -; *************************************************************************** -; defines - -; --------------------------------------------------------------------------- -; generic - -.include "common/utils_wait.asm" -.include "modules/com2/defs.asm" -.include "modules/comproto/defs.asm" - - - -; --------------------------------------------------------------------------- -; firmware settings - -.equ FIRMWARE_VERSION_MAJOR = 0 -.equ FIRMWARE_VERSION_MINOR = 0 -.equ FIRMWARE_VERSION_PATCHLEVEL = 1 - - - -; --------------------------------------------------------------------------- -; 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/flash/proto.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/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 - - - - - n17_main.asm - - - - - - - - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - n17_boot.asm - - - - - - - - - - - n17_defs.asm - - - - - - diff --git a/avr/devices/n17/n17_boot.asm b/avr/devices/n17/n17_boot.asm deleted file mode 100644 index 3730141..0000000 --- a/avr/devices/n17/n17_boot.asm +++ /dev/null @@ -1,178 +0,0 @@ -; *************************************************************************** -; 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 "n17_defs.asm" -.include "defs_all.asm" - - - -; *************************************************************************** -; defines - -; --------------------------------------------------------------------------- -; generic - -.include "common/utils_wait.asm" -.include "modules/com2/defs.asm" -.include "modules/comproto/defs.asm" - - - -; --------------------------------------------------------------------------- -; firmware settings - -.equ FIRMWARE_VERSION_MAJOR = 0 -.equ FIRMWARE_VERSION_MINOR = 0 -.equ FIRMWARE_VERSION_PATCHLEVEL = 1 - - - -; --------------------------------------------------------------------------- -; 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/flash/proto.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/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 - - - - - - - - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - boot.asm - - - - - - - - - - - defs.asm - - - - - - diff --git a/avr/devices/n18/boot.asm b/avr/devices/n18/boot.asm deleted file mode 100644 index d201486..0000000 --- a/avr/devices/n18/boot.asm +++ /dev/null @@ -1,140 +0,0 @@ -; *************************************************************************** -; Source file for base system node on AtTiny 85 -; -; 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/tn85def.inc" ; Define device ATtiny85 -.list - -.include "./defs.asm" -.include "defs_all.asm" - - - -; *************************************************************************** -; defines - -; --------------------------------------------------------------------------- -; generic - -.include "common/utils_wait.asm" -.include "modules/com2/defs.asm" -.include "modules/comproto/defs.asm" - - -; --------------------------------------------------------------------------- -; firmware settings - -.equ FIRMWARE_VERSION_MAJOR = 0 -.equ FIRMWARE_VERSION_MINOR = 0 -.equ FIRMWARE_VERSION_PATCHLEVEL = 1 - - -; --------------------------------------------------------------------------- -; LED - -.equ LED_DDR = DDRB -.equ LED_PORT = PORTB -.equ LED_PIN = PINB -.equ LED_PINNUM = PORTB3 - - - -; *************************************************************************** -; code segment - -.cseg -.org 0x0000 - - - -; --------------------------------------------------------------------------- -; Reset and interrupt vectors - rjmp main ; Reset vector - reti ; EXT_INT0 - reti ; PCI0 - reti ; OC1A - reti ; OVF1 - reti ; OVF0 - reti ; ERDY - reti ; ACI - reti ; ADCC - reti ; OC1B - reti ; 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_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/flash/proto.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/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< - - - - - boot - main - - - - defs.asm - README - - - - - diff --git a/avr/devices/n19/README b/avr/devices/n19/README deleted file mode 100644 index 4b8fb4d..0000000 --- a/avr/devices/n19/README +++ /dev/null @@ -1,13 +0,0 @@ - -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/n19/boot/0BUILD b/avr/devices/n19/boot/0BUILD deleted file mode 100644 index c0e7053..0000000 --- a/avr/devices/n19/boot/0BUILD +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - boot.asm - - - - - - - - - - - - - - - - diff --git a/avr/devices/n19/boot/boot.asm b/avr/devices/n19/boot/boot.asm deleted file mode 100644 index eb13227..0000000 --- a/avr/devices/n19/boot/boot.asm +++ /dev/null @@ -1,138 +0,0 @@ -; *************************************************************************** -; Source file for base system node on AtTiny 85 -; -; 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/tn85def.inc" ; Define device ATtiny85 -.list - -.include "../defs.asm" -.include "devices/all/defs.asm" -.include "common/calls.asm" -.include "common/utils_wait.asm" - - - -; *************************************************************************** -; defines - -; --------------------------------------------------------------------------- -; generic - - -; --------------------------------------------------------------------------- -; firmware settings - -.equ FIRMWARE_VERSION_MAJOR = 0 -.equ FIRMWARE_VERSION_MINOR = 0 -.equ FIRMWARE_VERSION_PATCHLEVEL = 1 - - -; --------------------------------------------------------------------------- -; LED - -.equ LED_DDR = DDRB -.equ LED_PORT = PORTB -.equ LED_PIN = PINB -.equ LED_PINNUM = PORTB3 - - - -; *************************************************************************** -; code segment - -.cseg -.org 0x0000 - - - -; --------------------------------------------------------------------------- -; Reset and interrupt vectors - rjmp main ; Reset vector - reti ; EXT_INT0 - reti ; PCI0 - reti ; OC1A - reti ; OVF1 - reti ; OVF0 - reti ; ERDY - reti ; ACI - reti ; ADCC - reti ; OC1B - reti ; 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_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/flash/proto.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/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/n19/main/main.asm b/avr/devices/n19/main/main.asm deleted file mode 100644 index 146038d..0000000 --- a/avr/devices/n19/main/main.asm +++ /dev/null @@ -1,176 +0,0 @@ -; *************************************************************************** -; 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 85 -; -; This is for the full system (i.e. not the boot loader). -; *************************************************************************** - -.equ clock=1000000 ; Define the clock frequency - - - -.nolist -.include "include/tn85def.inc" ; Define device ATtiny85 -.list - -.include "../defs.asm" -.include "devices/all/defs.asm" -.include "common/calls.asm" -.include "common/utils_io.asm" -.include "common/utils_wait.asm" ; wait macro - - - -; *************************************************************************** -; defines - - -.equ NET_BUFFERS_NUM = 6 - - -; --------------------------------------------------------------------------- -; firmware settings including list of modules used - -.equ FIRMWARE_VERSION_MAJOR = 0 -.equ FIRMWARE_VERSION_MINOR = 0 -.equ FIRMWARE_VERSION_PATCHLEVEL = 1 - -#define MODULES_CLOCK -#define MODULES_LED_SIMPLE -#define MODULES_NETWORK -#define MODULES_UART_BITBANG -#define MODULES_TWI_MASTER -#define MODULES_SI7021 -#define MODULES_CCS811 - -#define APPS_NETWORK -#define APPS_REPORTSENSORS -#define APPS_STATS - - - -; --------------------------------------------------------------------------- -; defines for modules - -.equ VALUE_ID_SI7021_TEMP = 0x01 -.equ VALUE_ID_SI7021_HUM = 0x02 - -.equ VALUE_ID_CO2 = 0x07 -.equ VALUE_ID_TVOC = 0x08 - -.equ VALUE_ID_DEBUG = 0x7f - -.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 UART_BitBang_PcintIsr ; 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_MAIN, FIRMWARE_VERSION_MAJOR - .db FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCHLEVEL - -firmwareStart: - rjmp main - - - -; --------------------------------------------------------------------------- -; @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_tn85.asm" -.include "devices/all/includes.asm" - - - -; --------------------------------------------------------------------------- -; defines for network interface - -.equ netInterfaceData = uart_bitbang_iface - - - diff --git a/avr/devices/n20/.gitignore b/avr/devices/n20/.gitignore deleted file mode 100644 index 8e0618c..0000000 --- a/avr/devices/n20/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.eep.hex -*.obj diff --git a/avr/devices/n20/0BUILD b/avr/devices/n20/0BUILD deleted file mode 100644 index be449f6..0000000 --- a/avr/devices/n20/0BUILD +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - boot - main - - - - defs.asm - README - - - - - diff --git a/avr/devices/n20/README b/avr/devices/n20/README deleted file mode 100644 index 60505df..0000000 --- a/avr/devices/n20/README +++ /dev/null @@ -1,13 +0,0 @@ - -N20 -=== - -- 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/n20/boot/0BUILD b/avr/devices/n20/boot/0BUILD deleted file mode 100644 index dec3837..0000000 --- a/avr/devices/n20/boot/0BUILD +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - boot.asm - - - - - - - - - - - - - - - - diff --git a/avr/devices/n20/boot/boot.asm b/avr/devices/n20/boot/boot.asm deleted file mode 100644 index df58b6f..0000000 --- a/avr/devices/n20/boot/boot.asm +++ /dev/null @@ -1,129 +0,0 @@ -; *************************************************************************** -; 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_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 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" - - - -systemSetSpeed: -.if clock == 8000000 - ldi r16, (1< - - - - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - main.asm - - - - - - - - - - - - - - - - - diff --git a/avr/devices/n20/main/main.asm b/avr/devices/n20/main/main.asm deleted file mode 100644 index fadb333..0000000 --- a/avr/devices/n20/main/main.asm +++ /dev/null @@ -1,222 +0,0 @@ -; *************************************************************************** -; 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. -; -; -; *************************************************************************** - - -.equ clock=1000000 ; Define the clock frequency -;.equ clock=8000000 ; 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 - -; --------------------------------------------------------------------------- -; generic - -.equ NET_BUFFERS_NUM = 4 - - - -; --------------------------------------------------------------------------- -; 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_STATS -;#define MODULES_OWI_MASTER -;#define MODULES_DS18B20 -;#define MODULES_MOTION -;#define MODULES_TCRT1000 -#define MODULES_CCS811 - -#define APPS_NETWORK -;#define APPS_MOTION -;#define APPS_DOOR -#define APPS_REPORTSENSORS -#define APPS_STATS - - - -; --------------------------------------------------------------------------- -; defines for values - -.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_MOTION = 0x07 - -.equ VALUE_ID_CO2 = 0x08 -.equ VALUE_ID_TVOC = 0x09 - -;.equ VALUE_ID_REED_CONF = 0x81 - -.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" - -;.include "common/debug.asm" - - - - -; --------------------------------------------------------------------------- -; defines for network interface - -.equ netInterfaceData = uart_bitbang_iface - - - - - - - - - diff --git a/avr/devices/n22/.gitignore b/avr/devices/n22/.gitignore deleted file mode 100644 index 8e0618c..0000000 --- a/avr/devices/n22/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.eep.hex -*.obj diff --git a/avr/devices/n22/0BUILD b/avr/devices/n22/0BUILD deleted file mode 100644 index be449f6..0000000 --- a/avr/devices/n22/0BUILD +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - boot - main - - - - defs.asm - README - - - - - diff --git a/avr/devices/n22/README b/avr/devices/n22/README deleted file mode 100644 index 95d68e6..0000000 --- a/avr/devices/n22/README +++ /dev/null @@ -1,15 +0,0 @@ - -N22 -=== - -- Role: LED strip controller -- MCU: AtTiny85 -- Connection: RJ45 -- Predecessor: N16 -- UART: uart_bitbang2 -- Periphery: - - LED strip connection (SK6812) - - OWI interface - - DS18B20 temperature sensor -- Modules: - - MA_LIGHT: motion activated light diff --git a/avr/devices/n22/boot/0BUILD b/avr/devices/n22/boot/0BUILD deleted file mode 100644 index 068003c..0000000 --- a/avr/devices/n22/boot/0BUILD +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - boot.asm - - - - - - - - - - - - - - - - diff --git a/avr/devices/n22/boot/boot.asm b/avr/devices/n22/boot/boot.asm deleted file mode 100644 index 2acc025..0000000 --- a/avr/devices/n22/boot/boot.asm +++ /dev/null @@ -1,129 +0,0 @@ -; *************************************************************************** -; Source file for base system node on AtTiny 85 -; -; 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/tn85def.inc" ; Define device ATtiny85 -.list - -.include "version.asm" -.include "../defs.asm" -.include "devices/all/defs.asm" - -.include "common/calls.asm" -.include "common/utils_wait.asm" -.include "modules/com2/defs.asm" -.include "modules/comproto/defs.asm" - - - -; *************************************************************************** -; defines - - -; --------------------------------------------------------------------------- -; LED - -.equ LED_DDR = DDRB -.equ LED_PORT = PORTB -.equ LED_PIN = PINB -.equ LED_PINNUM = PORTB4 - - - -; *************************************************************************** -; code segment - -.cseg -.org 0x0000 - - - -; --------------------------------------------------------------------------- -; Reset and interrupt vectors - rjmp main ; Reset vector - reti ; EXT_INT0 - reti ; PCI0 - reti ; OC1A - reti ; OVF1 - reti ; OVF0 - reti ; ERDY - reti ; ACI - reti ; ADCC - reti ; OC1B - reti ; 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_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/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/n22/main/main.asm b/avr/devices/n22/main/main.asm deleted file mode 100644 index 91c25da..0000000 --- a/avr/devices/n22/main/main.asm +++ /dev/null @@ -1,206 +0,0 @@ -; *************************************************************************** -; 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 - - - -; --------------------------------------------------------------------------- -; firmware settings including list of modules used - -#define MODULES_CLOCK -#define MODULES_LED_SIMPLE -#define MODULES_NETWORK -#define MODULES_UART_BITBANG -#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 UART_BitBang_PcintIsr ; 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 = uart_bitbang_iface - - - - diff --git a/avr/devices/n23/.gitignore b/avr/devices/n23/.gitignore deleted file mode 100644 index 8e0618c..0000000 --- a/avr/devices/n23/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.eep.hex -*.obj diff --git a/avr/devices/n23/0BUILD b/avr/devices/n23/0BUILD deleted file mode 100644 index bed977a..0000000 --- a/avr/devices/n23/0BUILD +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - boot - main - - - - aqua_n23.xml - - - - defs.asm - README - - - - - - diff --git a/avr/devices/n23/README b/avr/devices/n23/README deleted file mode 100644 index be29416..0000000 --- a/avr/devices/n23/README +++ /dev/null @@ -1,14 +0,0 @@ - -N23 -=== - -- Role: Air quality and climate sensors -- MCU: AtTiny84 -- Connection: RJ45 -- Predecessor: N19 -- Periphery: - - PIR sensor (AMN31112) - - TWI interface - - SI7021 temperature and humidity sensor - - CCS811 air quality sensor - diff --git a/avr/devices/n23/aqua_n23.xml b/avr/devices/n23/aqua_n23.xml deleted file mode 100644 index 2fd9f35..0000000 --- a/avr/devices/n23/aqua_n23.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - AQUA - N - 23 - - - - - - - - - - - - - - - - - - - - - - - diff --git a/avr/devices/n23/boot/0BUILD b/avr/devices/n23/boot/0BUILD deleted file mode 100644 index d266259..0000000 --- a/avr/devices/n23/boot/0BUILD +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - boot.asm - - - - - - - - - - - - - - - - diff --git a/avr/devices/n23/boot/boot.asm b/avr/devices/n23/boot/boot.asm deleted file mode 100644 index 39bb493..0000000 --- a/avr/devices/n23/boot/boot.asm +++ /dev/null @@ -1,134 +0,0 @@ -; *************************************************************************** -; 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_wait.asm" - - -#define COM_ACCEPT_ALL_DEST - - - -; *************************************************************************** -; 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 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/n23/main/data.asm b/avr/devices/n23/main/data.asm deleted file mode 100644 index 31ccc2f..0000000 --- a/avr/devices/n23/main/data.asm +++ /dev/null @@ -1,14 +0,0 @@ -; *************************************************************************** -; 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/n23/main/main.asm b/avr/devices/n23/main/main.asm deleted file mode 100644 index 895bb69..0000000 --- a/avr/devices/n23/main/main.asm +++ /dev/null @@ -1,221 +0,0 @@ -; *************************************************************************** -; 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. -; -; -; *************************************************************************** - - -.equ clock=1000000 ; Define the clock frequency -;.equ clock=8000000 ; Define the clock frequency - - - -.nolist -.include "include/tn84def.inc" ; Define device ATtiny84 -.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 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_SI7021_TEMP = 0x01 -.equ VALUE_ID_SI7021_HUM = 0x02 - -.equ VALUE_ID_ADC = 0x03 -;.equ VALUE_ID_DS18B20_TEMP = 0x06 -.equ VALUE_ID_MOTION = 0x07 - -.equ VALUE_ID_SGP40_TVOC = 0x08 - -.equ VALUE_ID_SGP30_TVOC = 0x09 -.equ VALUE_ID_SGP30_CO2 = 0x0a - -;.equ VALUE_ID_REED_CONF = 0x81 - -.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/devices/r02/.gitignore b/avr/devices/r02/.gitignore deleted file mode 100644 index 8e0618c..0000000 --- a/avr/devices/r02/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.eep.hex -*.obj diff --git a/avr/devices/r02/0BUILD b/avr/devices/r02/0BUILD deleted file mode 100644 index c82f090..0000000 --- a/avr/devices/r02/0BUILD +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - main.asm - - - - - - - - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - boot.asm - - - - - - - - - - - defs.asm - - - - - - diff --git a/avr/devices/r02/boot.asm b/avr/devices/r02/boot.asm deleted file mode 100644 index 5fb6ebe..0000000 --- a/avr/devices/r02/boot.asm +++ /dev/null @@ -1,163 +0,0 @@ -; *************************************************************************** -; 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/tn841def.inc" ; Define device ATtiny841 -.list - -.include "./defs.asm" -.include "defs_all.asm" - - - -; *************************************************************************** -; defines - -; --------------------------------------------------------------------------- -; generic - -.include "common/utils_wait.asm" -.include "modules/com2/defs.asm" -.include "modules/comproto/defs.asm" - - - -; --------------------------------------------------------------------------- -; firmware settings - -.equ FIRMWARE_VERSION_MAJOR = 0 -.equ FIRMWARE_VERSION_MINOR = 0 -.equ FIRMWARE_VERSION_PATCHLEVEL = 1 - - - -; --------------------------------------------------------------------------- -; LED - -.equ LED_DDR = DDRB -.equ LED_PORT = PORTB -.equ LED_PIN = PINB -.equ LED_PINNUM = PORTB2 - - -; *************************************************************************** -; 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 'R', 0 -devInfoVersion: .db 2, 0 ; 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 debugStop - rjmp bootLoader ; this routine is in modules/flash/proto.asm - - - - -; *************************************************************************** -; includes - -.include "modules/uart_bitbang/bytelevel.asm" -.include "modules/uart_bitbang/packetlevel.asm" -.include "modules/com2/crc.asm" -.include "common/crc8.asm" -.include "common/utils_wait_fixed.asm" -.include "common/utils_copy_from_flash.asm" -.include "common/utils_copy_sdram.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" - - -#if 1 -debugStop: - cli - sbi LED_SIMPLE_DDR, LED_SIMPLE_PINNUM ; out - cbi LED_SIMPLE_PORT, LED_SIMPLE_PINNUM ; on - - cbi COM_ATTN_DDR, COM_ATTN_PIN ; set ATTN port as input - cbi COM_ATTN_OUTPUT, COM_ATTN_PIN ; disable internal pullup for ATTN - - ldi r18, 0 -test_loop1: - ldi r16, 100 -test_loop2: - ldi r17, 100 -test_loop3: - Utils_WaitNanoSecs 10000, 0, r22 - dec r17 - brne test_loop3 - dec r16 - brne test_loop2 - sbi LED_SIMPLE_PORTIN, LED_SIMPLE_PINNUM ; toggle - inc r18 - mov r19, r18 - andi r19, 1 - brne test1 - sbi COM_ATTN_DDR, COM_ATTN_PIN - cbi COM_ATTN_OUTPUT, COM_ATTN_PIN - rjmp test_loop1 -test1: - cbi COM_ATTN_DDR, COM_ATTN_PIN - cbi COM_ATTN_OUTPUT, COM_ATTN_PIN - - rjmp test_loop1 -#endif - - - diff --git a/avr/devices/r02/defs.asm b/avr/devices/r02/defs.asm deleted file mode 100644 index e331a5b..0000000 --- a/avr/devices/r02/defs.asm +++ /dev/null @@ -1,87 +0,0 @@ -; *************************************************************************** -; 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. * -; *************************************************************************** - - -; *************************************************************************** -; -; AtTiny 841 -; ------- -; VCC 1 14 GND -; PB0 2 13 PA0 ATTN0 -; PB1 3 12 PA1 TXD0 (UART0) -; /RESET PB3 4 11 PA2 RXD0 (UART0) -; LED PB2 5 10 PA3 ATTN1 -; 1-wire PA7 6 9 PA4 RXD1 (UART1) [SCK, PRG] -; [MOSI,PRG] SDA (I2C) PA6 7 8 PA5 TXD1 (UART1) [MISO, PRG] -; ------- -; -; *************************************************************************** - - - -.equ BOOTLOADER_ADDR = 0xd00 - -.equ FIRMWARE_VARIANT_BOOT = 0 -.equ FIRMWARE_VARIANT_TEMP_WINDOW = 1 - - - -; --------------------------------------------------------------------------- -; LED module - -.equ LED_SIMPLE_ONTIME = 2 -.equ LED_SIMPLE_OFFTIME = 30 -.equ LED_SIMPLE_DDR = DDRB -.equ LED_SIMPLE_PORT = PORTB -.equ LED_SIMPLE_PORTIN = PINB -.equ LED_SIMPLE_PINNUM = PORTB2 - - - -; --------------------------------------------------------------------------- -; COM module - -.equ COM_BIT_LENGTH = 52000 ; 104000ns=9600, 52000ns=19200, 26000ns=38400 -.equ COM_HALFBIT_LENGTH = 26000 ; see https://de.wikipedia.org/wiki/Universal_Asynchronous_Receiver_Transmitter - -.equ COM_DATA_DDR = DDRA -.equ COM_DATA_INPUT = PINA -.equ COM_DATA_OUTPUT = PORTA -.equ COM_DATA_PIN = PORTA2 - -.equ COM_ATTN_DDR = DDRA -.equ COM_ATTN_INPUT = PINA -.equ COM_ATTN_OUTPUT = PORTA -.equ COM_ATTN_PIN = PORTA0 - -.equ COM_IRQ_ADDR_ATTN = PCMSK0 -.equ COM_IRQ_BIT_ATTN = PCINT0 ; bit 7 in PCMSK0 -.equ COM_IRQ_GIFR_ATTN = PCIF0 -.equ COM_IRQ_GIMSK_ATTN = PCIE0 - - - -; --------------------------------------------------------------------------- -; LCD module - -.equ LCD_TWI_ADDRESS = 0x3c - - - -; --------------------------------------------------------------------------- -; 1-Wire Master -; - -.equ OWI_DDR = DDRA -.equ OWI_PORTOUT = PORTA -.equ OWI_PORTIN = PINA -.equ OWI_PINNUM = PORTA7 - - - diff --git a/avr/devices/r02/main.asm b/avr/devices/r02/main.asm deleted file mode 100644 index cd2e59c..0000000 --- a/avr/devices/r02/main.asm +++ /dev/null @@ -1,448 +0,0 @@ -; *************************************************************************** -; 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. -; -; -; *************************************************************************** - - -.equ clock=1000000 ; Define the clock frequency -;.equ clock=8000000 ; Define the clock frequency - - - -.nolist -.include "include/tn841def.inc" ; Define device ATtiny841 -.list - -.include "./defs.asm" -.include "defs_all.asm" - - - -; *************************************************************************** -; defines - -; --------------------------------------------------------------------------- -; generic - - -.include "common/utils_wait.asm" - - -; --------------------------------------------------------------------------- -; firmware settings including list of modules used - -.equ FIRMWARE_VERSION_MAJOR = 0 -.equ FIRMWARE_VERSION_MINOR = 0 -.equ FIRMWARE_VERSION_PATCHLEVEL = 1 - - -#define MODULES_TIMER -#define MODULES_COM -#define MODULES_COM_WITH_ADDR_PROTO -;#define MODULES_LED -#define MODULES_LED_SIMPLE -;#define MODULES_TWI_MASTER -;#define MODULES_LCD -#define LCD_MINIMAL_FONT -;#define MODULES_SI7021 -#define MODULES_STATS -;#define MODULES_CNY70 -;#define MODULES_REED -#define MODULES_OWI_MASTER -;#define MODULES_DS18B20 -;#define MODULES_MOTION - - - -; *************************************************************************** -; 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 uartBitbangIsrPcint0 ; 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 'R', 0 -devInfoVersion: .db 2, 0 ; version, revision -firmwareVersion: .db FIRMWARE_VARIANT_TEMP_WINDOW, FIRMWARE_VERSION_MAJOR - .db FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCHLEVEL - -firmwareStart: rjmp main - - -; *************************************************************************** -; includes - -.include "common/utils.asm" -.include "common/utils_wait_fixed.asm" -.include "common/utils_copy_from_flash.asm" -.include "common/utils_copy_sdram.asm" -.include "common/crc8.asm" - -.include "modules/basetimer/main.asm" - -#ifdef MODULES_TIMER - .include "modules/timer/main.asm" -#endif -#ifdef MODULES_LED -.include "modules/led/main.asm" -#endif -#ifdef MODULES_LED_SIMPLE -.include "modules/led_simple/main.asm" -#endif -#ifdef MODULES_COM - .include "modules/com2/defs.asm" - .include "modules/com2/main.asm" - .include "modules/com2/buffer.asm" - .include "modules/uart_bitbang/defs.asm" - .include "modules/uart_bitbang/main.asm" - .include "modules/uart_bitbang/bytelevel.asm" - .include "modules/uart_bitbang/packetlevel.asm" - #ifdef MODULES_COM_WITH_ADDR_PROTO - .include "modules/comproto/defs.asm" - .include "modules/comproto/main.asm" - .include "modules/comproto/addr.asm" - .include "modules/comproto/msg_recvstats.asm" - .include "modules/comproto/msg_sendstats.asm" - .include "modules/comproto/msg_sysstats.asm" - .include "modules/comproto/msg_memstats.asm" - .include "modules/comproto/msg_pong.asm" - .include "modules/comproto/msg_value.asm" - .include "modules/comproto/msg_device.asm" - .include "modules/comproto/msg_reboot.asm" - #endif - #ifdef MODULES_LCD - .include "modules/com2/screen.asm" - .include "modules/comproto/screen.asm" - #endif -#endif -#ifdef MODULES_TWI_MASTER - .include "modules/twimaster/main.asm" -#endif -#ifdef MODULES_OWI_MASTER - .include "modules/owimaster/main.asm" -#endif -#ifdef MODULES_LCD - .include "modules/lcd/main.asm" -#endif -#ifdef MODULES_SI7021 - .include "modules/si7021/main.asm" -#endif -#ifdef MODULES_DS18B20 - .include "modules/ds18b20/main.asm" -#endif -#ifdef MODULES_STATS - .include "modules/stats/main.asm" -#endif -#ifdef MODULES_CNY70 - .include "modules/cny70/main.asm" -#endif -#ifdef MODULES_REED - .include "modules/reed/main.asm" -#endif - -#ifdef MODULES_MOTION - .include "modules/motion/main.asm" -#endif - -; test -;#include "modules/uart_irq/defs.asm" -;#include "modules/uart_irq/iface.asm" -;#include "modules/uart_irq/iface1.asm" - - -; *************************************************************************** -; data in SRAM - -.dseg - -programRamBegin: -#ifdef MODULES_LCD - screenCounter: .byte 1 -#endif - -programRamEnd: - - - -#ifdef MODULES_LCD - sramTimerWriteStats: .byte 2 - sramTimerScreen: .byte 2 -#endif -#ifdef MODULES_SI7021 - sramTimerSI7021Measure: .byte 2 - sramTimerSI7021SendTemp: .byte 2 - sramTimerSI7021SendHumidity: .byte 2 -#endif -#ifdef MODULES_CNY70 - sramTimerCny70SendAdc: .byte 2 -#endif -#ifdef MODULES_LCD - sramPeriodicalLcdMark: .byte 2 -#endif -#ifdef MODULES_DS18B20 - sramDs18b20Timer: .byte 2 - sramSendDs18b20TempTimer: .byte 2 -#endif - - -; *************************************************************************** -; data in FLASH - -.cseg - - - -; --------------------------------------------------------------------------- -; timer list - - -timerList: -; SRAM variable/counter routine flags secs (0=don't start or restart) -#ifdef MODULES_COM_WITH_ADDR_PROTO - .dw cproAddresModeTimer, CPRO_Address_OnTimer, 0, 0 ; (no restart) -#endif -#ifdef MODULES_STATS - .dw statsSendTimer, Stats_Timer, TIMER_FLAGS_IF_ADDR, 9000 ; every 15m -#endif -#ifdef MODULES_LCD -; .dw sramPeriodicalLcdMark, periodicalLcdMark, 0, 20 ; every 2s -; .dw sramTimerWriteStats, writeStats, 0, 100 - .dw sramTimerScreen, printScreen, TIMER_FLAGS_IF_ADDR, 50 ; every 5s -#endif -#ifdef MODULES_SI7021 - .dw sramTimerSI7021Measure, SI7021_OnTimer, 0, 300 ; every 30s - .dw sramTimerSI7021SendTemp, sendSI7021Temp, TIMER_FLAGS_IF_ADDR, 600 ; every 60s - .dw sramTimerSI7021SendHumidity, sendSI7021Humidity, TIMER_FLAGS_IF_ADDR, 600 ; every 60s -#endif -#ifdef MODULES_CNY70 - .dw sramTimerCny70SendAdc, CNY70_OnTimer, TIMER_FLAGS_IF_ADDR, 50 ; every 5s -#endif -#ifdef MODULES_DS18B20 - .dw sramDs18b20Timer, Ds18b20_OnTimer, 0, 300 ; every 30s - .dw sramSendDs18b20TempTimer, sendDs18b20Temp, TIMER_FLAGS_IF_ADDR, 600 ; every 60s -#endif - .dw 0 ; end of list - - - - - -.include "main_all.asm" - - - -systemSetSpeed: -.if clock == 8000000 - ldi r16, (1< - - - - - boot - main - test - - - - defs.asm - README - - - - aqua_r04.xml - - - - - - diff --git a/avr/devices/r04/README b/avr/devices/r04/README deleted file mode 100644 index 388a291..0000000 --- a/avr/devices/r04/README +++ /dev/null @@ -1,13 +0,0 @@ - -R04 -=== - -- Role: Router -- MCU: AtTiny841 -- Connection: RJ45 -- Predecessor: none -- UART: comonuart0 (uart_hw2), comonuart1 (uart_hw2) -- Periphery: - - OWI interface - - DS18B20 temperature sensor - diff --git a/avr/devices/r04/aqua_r04.xml b/avr/devices/r04/aqua_r04.xml deleted file mode 100644 index a9b72ef..0000000 --- a/avr/devices/r04/aqua_r04.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - AQUA - R - 4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/avr/devices/r04/boot/0BUILD b/avr/devices/r04/boot/0BUILD deleted file mode 100644 index b2940e7..0000000 --- a/avr/devices/r04/boot/0BUILD +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - boot.asm - - - - - - - - - - - - - - - - diff --git a/avr/devices/r04/boot/boot.asm b/avr/devices/r04/boot/boot.asm deleted file mode 100644 index ac3da73..0000000 --- a/avr/devices/r04/boot/boot.asm +++ /dev/null @@ -1,152 +0,0 @@ -; *************************************************************************** -; 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 -.equ clock=8000000 ; Define the clock frequency - -.nolist -.include "include/tn841def.inc" ; Define device ATtiny841 -.list - -.include "version.asm" -.include "../defs.asm" -.include "devices/all/defs.asm" - -.include "common/calls.asm" -.include "common/utils_wait.asm" - - - -; *************************************************************************** -; defines - - -;#define COM_ACCEPT_ALL_DEST 1 - - - -; --------------------------------------------------------------------------- -; LED - -.equ LED_DDR = DDRB -.equ LED_PORT = PORTB -.equ LED_PIN = PINB -.equ LED_PINNUM = PORTB2 - - - -; *************************************************************************** -; code segment - -.cseg -.org 0x0000 - - - -; --------------------------------------------------------------------------- -; Reset and interrupt vectors - - rjmp main ; 1: RESET Reset vector use this for flashed system - reti ; 2: INT0 External Interrupt Request 0 - reti ; 3: PCINT0 Pin Change Interrupt 0 - reti ; 4: PCINT1 Pin Change Interrupt 1 - reti ; 5: WDT Watchdog Time-out - reti ; 6: TIM1_CAPT Timer/Counter1 Capture Event - reti ; 7: TIM1_COMPA (OC1A) Timer/Counter1 Compare Match A - reti ; 8: TIM1_COMPB (OC1B) Timer/Counter1 Compare Match B - reti ; 9: TIM1_OVF (OVF1) Timer/Counter1 Overflow - reti ; 10: TIM0_COMPA (OC0A) Timer/Counter0 Compare Match A - reti ; 11: TIM0_COMPB (OC0B) Timer/Counter0 Compare Match B - reti ; 12: TIM0_OVF (OVF0) Timer/Counter0 Overflow - reti ; 13: ANA_COMP0 Analog Comparator 0 - reti ; 14: ADC_READY ADC Conversion Complete - reti ; 15: EE_RDY (ERDY) EEPROM Ready - reti ; 16: ANA_COMP1 Analog Comparator 1 - reti ; 17: TIM2_CAPT Timer/Counter2 Capture Event - reti ; 18: TIM2_COMPA (OC2A) Timer/Counter2 Compare Match A - reti ; 19: TIM2_COMPB (OC2B) Timer/Counter2 Compare Match B - reti ; 20: TIM2_OVF (OVF2) Timer/Counter2 Overflow - reti ; 21: SPI SPI Serial Transfer Complete - reti ; 22: USART0_RXS USART0 Rx Start - reti ; 23: USART0_RXC USART0 Rx Complete - reti ; 24: USART0_DRE USART0 Data Register Empty - reti ; 25: USART0_TXC USART0 Tx Complete - reti ; 26: USART1_RXS USART1 Rx Start - reti ; 27: USART1_RXC USART1 Rx Complete - reti ; 28: USART1_DRE USART1 Data Register Empty - reti ; 29: USART1_TXC USART1 Tx Complete - reti ; 30: TWI Two-Wire-Interface - reti ; 31: RESERVED reserved - - - -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/flashxp.asm" -.include "modules/flash/flash4p.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 == 1000000 - ldi r17, 0xd8 - ldi r16, (1< - - - - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - main.asm - - - - - - - - - - - - - - - - - diff --git a/avr/devices/r04/main/main.asm b/avr/devices/r04/main/main.asm deleted file mode 100644 index 2aeb170..0000000 --- a/avr/devices/r04/main/main.asm +++ /dev/null @@ -1,418 +0,0 @@ -; *************************************************************************** -; 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. -; -; -; *************************************************************************** - - -;.equ clock=1000000 ; Define the clock frequency -.equ clock=8000000 ; Define the clock frequency - - -.nolist -.include "include/tn841def.inc" ; Define device ATtiny841 -.list - -.include "../defs.asm" -.include "version.asm" -;.include "defs_all.asm" - -.include "devices/all/defs.asm" - -.include "common/calls.asm" -.include "common/utils_wait.asm" -.include "common/utils_io.asm" - - - -; *************************************************************************** -; defines - -; --------------------------------------------------------------------------- -; generic - -.equ COMONUART0_IFACENUM = 1 -.equ COMONUART1_IFACENUM = 2 - - -; --------------------------------------------------------------------------- -; firmware settings including list of modules used - - -#define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes -#define APP_STATS_NETDEV2 - -#define MODULES_CLOCK -;#define MODULES_COM -;#define MODULES_COM_WITH_ADDR_PROTO -;#define MODULES_LED -#define MODULES_LED_SIMPLE -;#define MODULES_TWI_MASTER -;#define MODULES_LCD -;#define LCD_MINIMAL_FONT -;#define MODULES_SI7021 -;#define MODULES_STATS -;#define MODULES_CNY70 -;#define MODULES_REED -;#define MODULES_OWI_MASTER -;#define MODULES_DS18B20 -;#define MODULES_MOTION -#define MODULES_NETWORK -;#define MODULES_TTYONUART1 -#define MODULES_COMONUART0 -#define MODULES_COMONUART1 - -#define APPS_STATS -#define APPS_NETWORK -;#define APPS_REPORTSENSORS - - - -.equ NET_BUFFERS_NUM = 9 - -.equ UART_HW_MSGNUMINBUF_SIZE = 8 -.equ UART_HW_MSGNUMOUTBUF_SIZE = 8 - - - -; --------------------------------------------------------------------------- -; defines for values - -.equ VALUE_ID_DS18B20_TEMP = 0x06 - -.equ VALUE_ID_LEDSIMPLE_TIMING = 0x88 - - -; *************************************************************************** -; code segment - -.cseg -.org 000000 - - - -; --------------------------------------------------------------------------- -; Reset and interrupt vectors - - rjmp BOOTLOADER_ADDR ; 1: RESET Reset vector use this for flashed system - reti ; 2: INT0 External Interrupt Request 0 - rjmp onAttnChangeIsr ; 3: PCINT0 Pin Change Interrupt 0 - reti ; 4: PCINT1 Pin Change Interrupt 1 - reti ; 5: WDT Watchdog Time-out - reti ; 6: TIM1_CAPT Timer/Counter1 Capture Event - reti ; 7: TIM1_COMPA (OC1A) Timer/Counter1 Compare Match A - reti ; 8: TIM1_COMPB (OC1B) Timer/Counter1 Compare Match B - reti ; 9: TIM1_OVF (OVF1) Timer/Counter1 Overflow - rjmp baseTimerIrqOC0A ; 10: TIM0_COMPA (OC0A) Timer/Counter0 Compare Match A - reti ; 11: TIM0_COMPB (OC0B) Timer/Counter0 Compare Match B - reti ; 12: TIM0_OVF (OVF0) Timer/Counter0 Overflow - reti ; 13: ANA_COMP0 Analog Comparator 0 - reti ; 14: ADC_READY ADC Conversion Complete - reti ; 15: EE_RDY (ERDY) EEPROM Ready - reti ; 16: ANA_COMP1 Analog Comparator 1 - reti ; 17: TIM2_CAPT Timer/Counter2 Capture Event - reti ; 18: TIM2_COMPA (OC2A) Timer/Counter2 Compare Match A - reti ; 19: TIM2_COMPB (OC2B) Timer/Counter2 Compare Match B - reti ; 20: TIM2_OVF (OVF2) Timer/Counter2 Overflow - reti ; 21: SPI SPI Serial Transfer Complete - reti ; 22: USART0_RXS USART0 Rx Start - rjmp ComOnUart0_RxCharIsr ; 23: USART0_RXC USART0 Rx Complete - rjmp ComOnUart0_TxUdreIsr ; 24: USART0_DRE USART0 Data Register Empty - rjmp ComOnUart0_TxCharIsr ; 25: USART0_TXC USART0 Tx Complete - reti ; 26: USART1_RXS USART1 Rx Start - rjmp ComOnUart1_RxCharIsr ; 27: USART1_RXC USART1 Rx Complete - rjmp ComOnUart1_TxUdreIsr ; 28: USART1_DRE USART1 Data Register Empty - rjmp ComOnUart1_TxCharIsr ; 29: USART1_TXC USART1 Tx Complete - reti ; 30: TWI Two-Wire-Interface - reti ; 31: RESERVED reserved - - - -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: - ; set interface number for UART0 - ldi r16, COMONUART0_IFACENUM - sts comOnUart0_iface+NET_IFACE_OFFS_IFACENUM, r16 - ; set interface number for UART1 - ldi r16, COMONUART1_IFACENUM - sts comOnUart1_iface+NET_IFACE_OFFS_IFACENUM, r16 - - ret -; @end - - - - - - - -onEvery100ms: -onEverySecond: -onEveryHour: -onEveryDay: - ret - - - -onEveryMinute: - rcall sendPacketsIface2In -; rcall sendErrorsIface2 - rcall sendDeviceUart1 - ret -; @end - - - -; --------------------------------------------------------------------------- -; @routine onEveryLoop -; -; Called on every loop (i.e. after awakening from sleep). - -onEveryLoop: - rcall checkRecvdMsg - ret -; @end - - - -; --------------------------------------------------------------------------- -; @routine onMessageReceived -; -; Called on every message received - -onMessageReceived: - clc - ret -; @end - - - -; --------------------------------------------------------------------------- -; @routine onAttnChange @global @isr -; -; Called whenever PCINT0 is activated. -; This code assumes that both ATTN pins are on the same port which is true for -; R04 nodes. - -onAttnChangeIsr: - push r15 - in r15, SREG - push r16 - inr r16, COM_ATTN1_INPUT - sbrs r16, COM_ATTN1_PIN - rcall ComOnUart1_HandleAttnChange ; (none) - - inr r16, COM_ATTN0_INPUT - sbrs r16, COM_ATTN0_PIN - rcall ComOnUart0_HandleAttnChange ; (none) - pop r16 - out SREG, r15 - pop r15 - reti -; @end - - - -; --------------------------------------------------------------------------- -; @routine checkRecvdMsg -; -; Read messages from either interface and forward to the other one. - -checkRecvdMsg: - rcall NET_PeekNextIncomingMsgNum ; check read queue (bufNum->r16) - brcc checkRecvdMsg_end ; no msg, jmp - rcall NET_Buffer_Locate ; (R17) - ; let system handle incoming messages - push r16 - push xl - push xh - adiw xh:xl, 1 - rcall letSysHandleMsg - pop xh - pop xl - pop r16 - - ; forward to other interface - ld r17, X - andi r17, (1< - - - - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - main.asm - - - - - - - - - - - - - - - - - diff --git a/avr/devices/r04/test/main.asm b/avr/devices/r04/test/main.asm deleted file mode 100644 index 795a5e8..0000000 --- a/avr/devices/r04/test/main.asm +++ /dev/null @@ -1,259 +0,0 @@ -; *************************************************************************** -; 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/tn841def.inc" ; Define device ATtiny841 -.list - -.include "../defs.asm" -.include "version.asm" -;.include "defs_all.asm" - -.include "devices/all/defs.asm" - -.include "common/calls.asm" -.include "common/utils_wait.asm" -.include "common/utils_io.asm" - - - -; *************************************************************************** -; defines - -; --------------------------------------------------------------------------- -; generic - -.equ COMONUART0_IFACENUM = 1 -.equ COMONUART1_IFACENUM = 2 - - -; --------------------------------------------------------------------------- -; firmware settings including list of modules used - - -;#define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes -;#define APP_STATS_NETDEV2 - -#define MODULES_CLOCK -;#define MODULES_COM -;#define MODULES_COM_WITH_ADDR_PROTO -;#define MODULES_LED -#define MODULES_LED_SIMPLE -;#define MODULES_TWI_MASTER -;#define MODULES_LCD -;#define LCD_MINIMAL_FONT -;#define MODULES_SI7021 -;#define MODULES_STATS -;#define MODULES_CNY70 -;#define MODULES_REED -#define MODULES_OWI_MASTER -#define MODULES_DS18B20 -;#define MODULES_MOTION -#define MODULES_NETWORK -;#define MODULES_TTYONUART1 -;#define MODULES_COMONUART0 -#define MODULES_COMONUART1 - -#define APPS_STATS -#define APPS_NETWORK -#define APPS_REPORTSENSORS - - - -.equ NET_BUFFERS_NUM = 8 - -.equ UART_HW_MSGNUMINBUF_SIZE = 8 -.equ UART_HW_MSGNUMOUTBUF_SIZE = 8 - - - -; --------------------------------------------------------------------------- -; defines for values - -.equ VALUE_ID_DS18B20_TEMP = 0x06 - -.equ VALUE_ID_LEDSIMPLE_TIMING = 0x88 - - -; *************************************************************************** -; code segment - -.cseg -.org 000000 - - - -; --------------------------------------------------------------------------- -; Reset and interrupt vectors - - rjmp BOOTLOADER_ADDR ; 1: RESET Reset vector use this for flashed system - reti ; 2: INT0 External Interrupt Request 0 - rjmp onAttnChangeIsr ; 3: PCINT0 Pin Change Interrupt 0 - reti ; 4: PCINT1 Pin Change Interrupt 1 - reti ; 5: WDT Watchdog Time-out - reti ; 6: TIM1_CAPT Timer/Counter1 Capture Event - reti ; 7: TIM1_COMPA (OC1A) Timer/Counter1 Compare Match A - reti ; 8: TIM1_COMPB (OC1B) Timer/Counter1 Compare Match B - reti ; 9: TIM1_OVF (OVF1) Timer/Counter1 Overflow - rjmp baseTimerIrqOC0A ; 10: TIM0_COMPA (OC0A) Timer/Counter0 Compare Match A - reti ; 11: TIM0_COMPB (OC0B) Timer/Counter0 Compare Match B - reti ; 12: TIM0_OVF (OVF0) Timer/Counter0 Overflow - reti ; 13: ANA_COMP0 Analog Comparator 0 - reti ; 14: ADC_READY ADC Conversion Complete - reti ; 15: EE_RDY (ERDY) EEPROM Ready - reti ; 16: ANA_COMP1 Analog Comparator 1 - reti ; 17: TIM2_CAPT Timer/Counter2 Capture Event - reti ; 18: TIM2_COMPA (OC2A) Timer/Counter2 Compare Match A - reti ; 19: TIM2_COMPB (OC2B) Timer/Counter2 Compare Match B - reti ; 20: TIM2_OVF (OVF2) Timer/Counter2 Overflow - reti ; 21: SPI SPI Serial Transfer Complete - reti ; 22: USART0_RXS USART0 Rx Start -; rjmp ComOnUart0_RxCharIsr ; 23: USART0_RXC USART0 Rx Complete - reti ; 23: USART0_RXC USART0 Rx Complete -; rjmp ComOnUart0_TxUdreIsr ; 24: USART0_DRE USART0 Data Register Empty - reti ; 24: USART0_DRE USART0 Data Register Empty -; rjmp ComOnUart0_TxCharIsr ; 25: USART0_TXC USART0 Tx Complete - reti ; 25: USART0_TXC USART0 Tx Complete - reti ; 26: USART1_RXS USART1 Rx Start - rjmp ComOnUart1_RxCharIsr ; 27: USART1_RXC USART1 Rx Complete -; reti ; 27: USART1_RXC USART1 Rx Complete - rjmp ComOnUart1_TxUdreIsr ; 28: USART1_DRE USART1 Data Register Empty -; reti ; 28: USART1_DRE USART1 Data Register Empty - rjmp ComOnUart1_TxCharIsr ; 29: USART1_TXC USART1 Tx Complete -; reti ; 29: USART1_TXC USART1 Tx Complete - reti ; 30: TWI Two-Wire-Interface - reti ; 31: RESERVED reserved - - - -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: - ; set interface number for UART0 -; ldi r16, COMONUART0_IFACENUM -; sts comOnUart0_iface+NET_IFACE_OFFS_IFACENUM, r16 - ; set interface number for UART1 - ldi r16, COMONUART1_IFACENUM - sts comOnUart1_iface+NET_IFACE_OFFS_IFACENUM, r16 - - ret -; @end - - - - - - - -onEvery100ms: -onEverySecond: -onEveryMinute: -onEveryHour: -onEveryDay: - ret - - - - -; --------------------------------------------------------------------------- -; @routine onEveryLoop -; -; Called on every loop (i.e. after awakening from sleep). - -onEveryLoop: - ret -; @end - - - -; --------------------------------------------------------------------------- -; @routine onMessageReceived -; -; Called on every message received - -onMessageReceived: - clc - ret -; @end - - - -; --------------------------------------------------------------------------- -; @routine onAttnChange @global @isr -; -; Called whenever PCINT0 is activated. -; This code assumes that both ATTN pins are on the same port which is true for -; R04 nodes. - -onAttnChangeIsr: - push r15 - in r15, SREG - rcall ComOnUart1_HandleAttnChange ; (none) -; rcall ComOnUart0_HandleAttnChange ; (none) - out SREG, r15 - pop r15 - reti -; @end - - - - -; *************************************************************************** -; includes - -.include "devices/all/hw_tn841.asm" -.include "devices/all/includes.asm" - - - - -; --------------------------------------------------------------------------- -; defines for network interface - -.equ netInterfaceData = comOnUart1_iface -;.equ netInterfaceData2 = comOnUart1_iface - - diff --git a/avr/devices/x03/0BUILD b/avr/devices/x03/0BUILD deleted file mode 100644 index b317b73..0000000 --- a/avr/devices/x03/0BUILD +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - uart - ccs811 - - - - diff --git a/avr/devices/x03/ccs811/0BUILD b/avr/devices/x03/ccs811/0BUILD deleted file mode 100644 index 6329fc6..0000000 --- a/avr/devices/x03/ccs811/0BUILD +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - main.asm - - - - - - - - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - boot.asm - - - - - - - - - - - defs.asm - - - - - - diff --git a/avr/devices/x03/ccs811/boot.asm b/avr/devices/x03/ccs811/boot.asm deleted file mode 100644 index b887867..0000000 --- a/avr/devices/x03/ccs811/boot.asm +++ /dev/null @@ -1,124 +0,0 @@ -; *************************************************************************** -; Source file for base system node on AtTiny 85 -; -; 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 "./defs.asm" -.include "defs_all.asm" - - - -; *************************************************************************** -; defines - -; --------------------------------------------------------------------------- -; generic - -.include "common/utils_wait.asm" -.include "modules/com2/defs.asm" -.include "modules/comproto/defs.asm" - - -; --------------------------------------------------------------------------- -; firmware settings - -.equ FIRMWARE_VERSION_MAJOR = 0 -.equ FIRMWARE_VERSION_MINOR = 0 -.equ FIRMWARE_VERSION_PATCHLEVEL = 1 - - -; --------------------------------------------------------------------------- -; 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 ; Reset vector - reti ; EXT_INT0 - reti ; PCI0 - reti ; OC1A - reti ; OVF1 - reti ; OVF0 - reti ; ERDY - reti ; ACI - reti ; ADCC - reti ; OC1B - reti ; OC0A - reti ; OC0B - reti ; WATCHDOG - reti ; USI_STR - reti ; USI_OVF - -devInfoBlock: ; 12 bytes -devInfoManufacturer: .db 'A', 'Q', 'U', 'A' -devInfoId: .db 'N', 0 -devInfoVersion: .db 14, 0 ; 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/flash/proto.asm - - - - -; *************************************************************************** -; includes - -.include "modules/uart_bitbang/bytelevel.asm" -.include "modules/uart_bitbang/packetlevel.asm" -.include "modules/com2/crc.asm" -.include "common/crc8.asm" -.include "common/utils_wait_fixed.asm" -.include "common/utils_copy_from_flash.asm" -.include "common/utils_copy_sdram.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/x03/ccs811/defs.asm b/avr/devices/x03/ccs811/defs.asm deleted file mode 100644 index 9d7ae13..0000000 --- a/avr/devices/x03/ccs811/defs.asm +++ /dev/null @@ -1,134 +0,0 @@ -; *************************************************************************** -; 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. * -; *************************************************************************** - - -; *************************************************************************** -; -; AtTiny84 -; -------- -; VCC 1 14 GND -; PB0 2 13 PA0 AUX-A0 -; PIR PB1 3 12 PA1 COM-DATA -; /RESET PB3 4 11 PA2 -; AUX-B2 PB2 5 10 PA3 LED -; COM_ATTN PA7 6 9 PA4 TWI-SCL -; TWI-SDA PA6 7 8 PA5 -; -------- -; -; *************************************************************************** - - - -.equ BOOTLOADER_ADDR = 0xd00 - -.equ FIRMWARE_VARIANT_BOOT = 0 -.equ FIRMWARE_VARIANT_MAIN = 1 - - - -; --------------------------------------------------------------------------- -; LED module - -.equ LED_SIMPLE_ONTIME = 1 ; shorter -.equ LED_SIMPLE_OFFTIME = 50 ; longer -.equ LED_SIMPLE_DDR = DDRA -.equ LED_SIMPLE_PORT = PORTA -.equ LED_SIMPLE_PORTIN = PINA -.equ LED_SIMPLE_PINNUM = PORTA3 - - -.equ LED_DEBUG_DDR = DDRA -.equ LED_DEBUG_PORT = PORTA -.equ LED_DEBUG_PORTIN = PINA -.equ LED_DEBUG_PINNUM = PORTA5 - - - -; --------------------------------------------------------------------------- -; COM module - -.equ COM_BIT_LENGTH = 52000 ; 104000ns=9600, 52000ns=19200, 26000ns=38400 -.equ COM_HALFBIT_LENGTH = 26000 ; see https://de.wikipedia.org/wiki/Universal_Asynchronous_Receiver_Transmitter - -.equ COM_DATA_DDR = DDRA -.equ COM_DATA_INPUT = PINA -.equ COM_DATA_OUTPUT = PORTA -.equ COM_DATA_PIN = PORTA1 - -.equ COM_ATTN_DDR = DDRA -.equ COM_ATTN_INPUT = PINA -.equ COM_ATTN_OUTPUT = PORTA -.equ COM_ATTN_PIN = PORTA7 - -.equ COM_IRQ_ADDR_ATTN = PCMSK0 -.equ COM_IRQ_BIT_ATTN = PCINT7 ; bit 7 in PCMSK0 -.equ COM_IRQ_GIFR_ATTN = PCIF0 -.equ COM_IRQ_GIMSK_ATTN = PCIE0 - - - -; --------------------------------------------------------------------------- -; TWI master module - -;.equ TWI_BIT_LENGTH = 10000 ; 100000 and 200000 works for display: 10000, 100000, 200000 -.equ TWI_BIT_LENGTH = 1 ; 10, 100, 500, 100000 and 200000 works for display: 10000, 100000, 200000 - -.equ TWI_DDR_SCL = DDRA -.equ TWI_PORT_SCL = PORTA -.equ TWI_PIN_SCL = PINA -.equ TWI_PINNUM_SCL = PORTA4 - -.equ TWI_DDR_SDA = DDRA -.equ TWI_PORT_SDA = PORTA -.equ TWI_PIN_SDA = PINA -.equ TWI_PINNUM_SDA = PORTA6 - - - -; --------------------------------------------------------------------------- -; LCD module - -.equ LCD_TWI_ADDRESS = 0x3c - - - -; --------------------------------------------------------------------------- -; SI 7021 - -.equ SI7021_ADDR = 0x40 - - - -; --------------------------------------------------------------------------- -; 1-Wire Master -; - -.equ OWI_DDR = DDRB -.equ OWI_PORTOUT = PORTB -.equ OWI_PORTIN = PINB -.equ OWI_PINNUM = PORTB2 - - - -; --------------------------------------------------------------------------- -; Motion Sensor -; - -.equ MOTION_DDR = DDRB -.equ MOTION_INPUT = PINB -.equ MOTION_OUTPUT = PORTB -.equ MOTION_PIN = PORTB1 - - - - -.equ CCS811_ADDR = 0x5a ; or 0x5b - - - diff --git a/avr/devices/x03/ccs811/main.asm b/avr/devices/x03/ccs811/main.asm deleted file mode 100644 index a6d0463..0000000 --- a/avr/devices/x03/ccs811/main.asm +++ /dev/null @@ -1,344 +0,0 @@ -; *************************************************************************** -; 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=1000000 ; Define the clock frequency - - - -.nolist -.include "include/tn84def.inc" ; Define device ATtiny84 -.list - -.include "./defs.asm" -.include "defs_all.asm" -.include "common/utils_wait.asm" ; wait macro - - - -; *************************************************************************** -; defines - -; --------------------------------------------------------------------------- -; firmware settings including list of modules used - -.equ FIRMWARE_VERSION_MAJOR = 0 -.equ FIRMWARE_VERSION_MINOR = 0 -.equ FIRMWARE_VERSION_PATCHLEVEL = 1 - - -#define MODULES_TIMER -#define MODULES_COM -#define MODULES_COM_WITH_ADDR_PROTO -#define MODULES_LED_SIMPLE -#define MODULES_TWI_MASTER -;#define MODULES_SI7021 -#define MODULES_STATS -; #define MODULES_OWI_MASTER -; #define MODULES_DS18B20 -; #define MODULES_SK6812 -; #define MODULES_MOTION_LIGHT - -; #define COM_ACCEPT_ALL_DEST -#define MODULES_CCS811 - - -; --------------------------------------------------------------------------- -; defines for modules - -.equ VALUE_ID_CO2 = 0x07 -.equ VALUE_ID_TVOC = 0x08 - -.equ VALUE_ID_DEBUG = 0x7f - -;.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_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 - - -; *************************************************************************** -; code segment - -.cseg -.org 000000 - - - -; --------------------------------------------------------------------------- -; Reset and interrupt vectors - - rjmp BOOTLOADER_ADDR ; Reset vector ; use this for flashed system - reti ; EXT_INT0 - rjmp uartBitbangIsrPcint0 ; 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 'N', 0 -devInfoVersion: .db 18, 0 ; version, revision -firmwareVersion: .db FIRMWARE_VARIANT_MAIN, FIRMWARE_VERSION_MAJOR - .db FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCHLEVEL - -firmwareStart: rjmp main - - -; *************************************************************************** -; includes - -.include "common/utils.asm" -.include "common/utils_wait_fixed.asm" -.include "common/utils_copy_from_flash.asm" -.include "common/utils_copy_sdram.asm" -.include "common/crc8.asm" - -.include "modules/basetimer/main.asm" - -#ifdef MODULES_TIMER - .include "modules/timer/main.asm" -#endif -#ifdef MODULES_LED_SIMPLE -.include "modules/led_simple/main.asm" -#endif -#ifdef MODULES_COM - .include "modules/com2/defs.asm" - .include "modules/com2/main.asm" - .include "modules/com2/buffer.asm" - #ifdef MODULES_STATS - .include "modules/comproto/msg_recvstats.asm" - .include "modules/comproto/msg_sendstats.asm" - .include "modules/comproto/msg_sysstats.asm" - .include "modules/comproto/msg_memstats.asm" - #endif - .include "modules/comproto/msg_pong.asm" - .include "modules/comproto/msg_value.asm" - .include "modules/comproto/msg_device.asm" - .include "modules/comproto/msg_reboot.asm" - .include "modules/uart_bitbang/defs.asm" - .include "modules/uart_bitbang/main.asm" - .include "modules/uart_bitbang/bytelevel.asm" - .include "modules/uart_bitbang/packetlevel.asm" - #ifdef MODULES_COM_WITH_ADDR_PROTO - .include "modules/comproto/defs.asm" - .include "modules/comproto/main.asm" - .include "modules/comproto/addr.asm" - #endif -#endif -#ifdef MODULES_STATS - .include "modules/stats/main.asm" -#endif -#ifdef MODULES_TWI_MASTER - .include "modules/twimaster/main.asm" -#endif -#ifdef MODULES_OWI_MASTER - .include "modules/owimaster/main.asm" -#endif -#ifdef MODULES_SI7021 - .include "modules/si7021/main.asm" -#endif -#ifdef MODULES_DS18B20 - .include "modules/ds18b20/main.asm" -#endif -#ifdef MODULES_SK6812 - .include "modules/sk6812/main.asm" -#endif -#ifdef MODULES_MOTION_LIGHT - .include "modules/ma_light/main.asm" -#endif -#ifdef MODULES_CCS811 - .include "modules/ccs811/main.asm" -#endif - - - -; *************************************************************************** -; data in SRAM - -.dseg - - -#ifdef MODULES_DS18B20 - sramDs18b20Timer: .byte 2 - sramSendDs18b20TempTimer: .byte 2 -#endif - - -; *************************************************************************** -; data in FLASH - -.cseg - - - -; --------------------------------------------------------------------------- -; timer list - - -timerList: -; SRAM variable/counter routine flags secs (0=don't start or restart) -#ifdef MODULES_COM_WITH_ADDR_PROTO - .dw cproAddresModeTimer, CPRO_Address_OnTimer, 0, 0 ; (no restart) -#endif -#ifdef MODULES_STATS - .dw statsSendTimer, Stats_Timer, TIMER_FLAGS_IF_ADDR, 9000 ; every 15m -#endif -#ifdef MODULES_DS18B20 - .dw sramDs18b20Timer, Ds18b20_OnTimer, 0, 300 ; every 30s - .dw sramSendDs18b20TempTimer, sendDs18b20Temp, TIMER_FLAGS_IF_ADDR, 600 ; every 60s -#endif - .dw 0 ; end of list - - - - - -.include "main_all.asm" - - -; --------------------------------------------------------------------------- -; Called early on system startup. No arguments, no results. - -systemSetSpeed: -.if clock == 8000000 - ldi r16, (1< - - - - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - main.asm - - - - - - - - - - - -I $(builddir) - -I $(srcdir) - -I $(topsrcdir)/avr - -I $(topbuilddir)/avr - - - - - boot.asm - - - - - - - - - - - defs.asm - - - - - - diff --git a/avr/devices/x03/uart/boot.asm b/avr/devices/x03/uart/boot.asm deleted file mode 100644 index 8e833a4..0000000 --- a/avr/devices/x03/uart/boot.asm +++ /dev/null @@ -1,162 +0,0 @@ -; *************************************************************************** -; 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 "defs_all.asm" -.include "./defs.asm" - - - -; *************************************************************************** -; defines - -; --------------------------------------------------------------------------- -; generic - -.include "common/utils_wait.asm" -.include "modules/com2/defs.asm" -.include "modules/comproto/defs.asm" - - - -; --------------------------------------------------------------------------- -; firmware settings - -.equ FIRMWARE_VERSION_MAJOR = 0 -.equ FIRMWARE_VERSION_MINOR = 0 -.equ FIRMWARE_VERSION_PATCHLEVEL = 1 - - - -; --------------------------------------------------------------------------- -; 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 'X', 0 -devInfoVersion: .db 3, 0 ; 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/flash/proto.asm - - - - -; *************************************************************************** -; includes - -.include "modules/uart_bitbang/bytelevel.asm" -.include "modules/uart_bitbang/packetlevel.asm" -.include "modules/com2/crc.asm" -.include "common/crc8.asm" -.include "common/utils_wait_fixed.asm" -.include "common/utils_copy_from_flash.asm" -.include "common/utils_copy_sdram.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" - - -#if 0 -debugStop: - cli - sbi LED_SIMPLE_DDR, LED_SIMPLE_PINNUM ; out - cbi LED_SIMPLE_PORT, LED_SIMPLE_PINNUM ; on - - cbi COM_ATTN_DDR, COM_ATTN_PIN ; set ATTN port as input - cbi COM_ATTN_OUTPUT, COM_ATTN_PIN ; disable internal pullup for ATTN - - ldi r18, 0 -test_loop1: - ldi r16, 100 -test_loop2: - ldi r17, 100 -test_loop3: - Utils_WaitNanoSecs 10000, 0, r22 - dec r17 - brne test_loop3 - dec r16 - brne test_loop2 - sbi LED_SIMPLE_PORTIN, LED_SIMPLE_PINNUM ; toggle - inc r18 - mov r19, r18 - andi r19, 1 - brne test1 - sbi COM_ATTN_DDR, COM_ATTN_PIN - cbi COM_ATTN_OUTPUT, COM_ATTN_PIN - rjmp test_loop1 -test1: - cbi COM_ATTN_DDR, COM_ATTN_PIN - cbi COM_ATTN_OUTPUT, COM_ATTN_PIN - - rjmp test_loop1 -#endif - - - diff --git a/avr/devices/x03/uart/defs.asm b/avr/devices/x03/uart/defs.asm deleted file mode 100644 index df7903b..0000000 --- a/avr/devices/x03/uart/defs.asm +++ /dev/null @@ -1,72 +0,0 @@ -; *************************************************************************** -; 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. * -; *************************************************************************** - - -; *************************************************************************** -; -; AtTiny84 -; -------- -; VCC 1 14 GND -; PB0 2 13 PA0 COM_ATTN1 -; PB1 3 12 PA1 COM-DATA1 -; /RESET PB3 4 11 PA2 -; COM_ATTN2 PB2 5 10 PA3 LED -; COM_DATA2 PA7 6 9 PA4 -; PA6 7 8 PA5 -; -------- -; -; *************************************************************************** - - - -.equ BOOTLOADER_ADDR = 0xd00 - -.equ FIRMWARE_VARIANT_BOOT = 0 -.equ FIRMWARE_VARIANT_ROUTER = 1 - - - -; --------------------------------------------------------------------------- -; LED module - -.equ LED_SIMPLE_DDR = DDRA -.equ LED_SIMPLE_PORT = PORTA -.equ LED_SIMPLE_PORTIN = PINA -.equ LED_SIMPLE_PINNUM = PORTA3 - - - -; --------------------------------------------------------------------------- -; COM module - -.equ COM_BIT_LENGTH = 52000 ; 104000ns=9600, 52000ns=19200, 26000ns=38400 -.equ COM_HALFBIT_LENGTH = 26000 ; see https://de.wikipedia.org/wiki/Universal_Asynchronous_Receiver_Transmitter - -.equ COM_DATA_DDR = DDRA -.equ COM_DATA_INPUT = PINA -.equ COM_DATA_OUTPUT = PORTA -.equ COM_DATA_PIN = PORTA1 - -.equ COM_ATTN_DDR = DDRA -.equ COM_ATTN_INPUT = PINA -.equ COM_ATTN_OUTPUT = PORTA -.equ COM_ATTN_PIN = PORTA0 - -.equ COM_DATA2_DDR = DDRA -.equ COM_DATA2_INPUT = PINA -.equ COM_DATA2_OUTPUT = PORTA -.equ COM_DATA2_PIN = PORTA7 - -.equ COM_ATTN2_DDR = DDRB -.equ COM_ATTN2_INPUT = PINB -.equ COM_ATTN2_OUTPUT = PORTB -.equ COM_ATTN2_PIN = PORTB2 - - - diff --git a/avr/devices/x03/uart/main.asm b/avr/devices/x03/uart/main.asm deleted file mode 100644 index 1606d2c..0000000 --- a/avr/devices/x03/uart/main.asm +++ /dev/null @@ -1,221 +0,0 @@ -; *************************************************************************** -; 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. -; -; -; *************************************************************************** - - -; .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_all.asm" -.include "./defs.asm" - - - -; *************************************************************************** -; defines - -; --------------------------------------------------------------------------- -; generic - - -.include "common/utils_wait.asm" - - -; --------------------------------------------------------------------------- -; firmware settings including list of modules used - -.equ FIRMWARE_VERSION_MAJOR = 0 -.equ FIRMWARE_VERSION_MINOR = 0 -.equ FIRMWARE_VERSION_PATCHLEVEL = 1 - - - - -; *************************************************************************** -; 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 - reti ; PCI0 - reti ; PCI1 - reti ; WATCHDOG - reti ; ICP1 - reti ; OC1A - reti ; OC1B - reti ; OVF1 - rjmp uartIrqIsrOC0A ; 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 'X', 0 -devInfoVersion: .db 3, 0 ; version, revision -firmwareVersion: .db FIRMWARE_VARIANT_ROUTER, FIRMWARE_VERSION_MAJOR - .db FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCHLEVEL - -firmwareStart: rjmp main - - -; *************************************************************************** -; includes - -.include "common/utils.asm" -.include "common/utils_wait_fixed.asm" -;.include "common/utils_copy_from_flash.asm" -;.include "common/utils_copy_sdram.asm" -.include "common/crc8.asm" - -#include "modules/uart_irq/defs.asm" -#include "modules/uart_irq/iface.asm" -#include "modules/uart_irq/iface1.asm" -#include "modules/uart_irq/iface2.asm" - - -; *************************************************************************** -; data in SRAM - -.dseg - -programRamBegin: -ledTimer: .byte 1 -programRamEnd: - - - -; *************************************************************************** -; data in FLASH - -.cseg - - -main: - ldi xh, HIGH(programRamBegin) - ldi xl, LOW(programRamBegin) - clr r16 - ldi r17, (programRamEnd-programRamBegin) - rcall Utils_FillSram - rcall init - sbi LED_SIMPLE_DDR, LED_SIMPLE_PINNUM ; out - cbi LED_SIMPLE_PORT, LED_SIMPLE_PINNUM ; on - clr r16 - sts ledTimer, r16 - sei -main_loop: -; rcall writeTestByteToIface2 -; rcall copyFromIface1To2 -; brcc main_sleep -; rjmp main_loop - -main_sleep: - ; only modify SE, SM1 and SM0 - cli - in r16, MCUCR - ldi r17, (1< Date: Mon, 18 Aug 2025 18:47:13 +0200 Subject: [PATCH 135/196] avr: switched most devices to com2w interface now. --- avr/devices/n14/boot/boot.asm | 4 ++-- avr/devices/n14/defs.asm | 16 ++++++++-------- avr/devices/n14/main/main.asm | 10 ++++++---- avr/devices/n16/boot/boot.asm | 4 ++-- avr/devices/n16/defs.asm | 18 +++++++++--------- avr/devices/n16/main/main.asm | 4 +++- avr/devices/n21/boot/boot.asm | 4 ++-- avr/devices/n21/defs.asm | 18 +++++++++--------- avr/devices/n21/main/main.asm | 10 ++++++---- avr/devices/n24/boot/boot.asm | 4 ++-- avr/devices/n24/defs.asm | 18 +++++++++--------- avr/devices/n24/main/main.asm | 10 ++++++---- avr/devices/n25/boot/boot.asm | 4 ++-- avr/devices/n25/defs.asm | 18 +++++++++--------- avr/devices/n25/main/main.asm | 16 ++++++---------- avr/devices/n26/boot/boot.asm | 4 ++-- avr/devices/n26/defs.asm | 18 +++++++++--------- avr/devices/n26/main/main.asm | 9 ++++++--- avr/devices/n27/defs.asm | 13 +------------ avr/devices/n27/main/main.asm | 8 ++++---- avr/devices/r06/defs.asm | 5 +++++ avr/devices/r06/main/main.asm | 4 +++- avr/version.asm | 4 ++-- 23 files changed, 113 insertions(+), 110 deletions(-) diff --git a/avr/devices/n14/boot/boot.asm b/avr/devices/n14/boot/boot.asm index 2acc025..175be30 100644 --- a/avr/devices/n14/boot/boot.asm +++ b/avr/devices/n14/boot/boot.asm @@ -19,6 +19,7 @@ .include "devices/all/defs.asm" .include "common/calls.asm" +.include "common/utils_io.asm" .include "common/utils_wait.asm" .include "modules/com2/defs.asm" .include "modules/comproto/defs.asm" @@ -98,8 +99,7 @@ main: .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/io_com2w.asm" .include "modules/flash/flashxp.asm" .include "modules/flash/flash1p.asm" .include "modules/flash/flashprocess.asm" diff --git a/avr/devices/n14/defs.asm b/avr/devices/n14/defs.asm index 13d0245..b450626 100644 --- a/avr/devices/n14/defs.asm +++ b/avr/devices/n14/defs.asm @@ -55,15 +55,15 @@ .equ COM_DATA_OUTPUT = PORTB .equ COM_DATA_PIN = PORTB1 -.equ COM_ATTN_DDR = DDRB -.equ COM_ATTN_INPUT = PINB -.equ COM_ATTN_OUTPUT = PORTB -.equ COM_ATTN_PIN = PORTB2 +.equ COM_CLK_DDR = DDRB +.equ COM_CLK_INPUT = PINB +.equ COM_CLK_OUTPUT = PORTB +.equ COM_CLK_PIN = PORTB2 -.equ COM_IRQ_ADDR_ATTN = PCMSK -.equ COM_IRQ_BIT_ATTN = PCINT2 ; bit 2 in PCMSK0 (PCINT2) -.equ COM_IRQ_GIFR_ATTN = PCIF -.equ COM_IRQ_GIMSK_ATTN = PCIE +.equ COM_IRQ_ADDR_CLK = PCMSK +.equ COM_IRQ_BIT_CLK = PCINT2 ; bit 2 in PCMSK0 (PCINT2) +.equ COM_IRQ_GIFR_CLK = PCIF +.equ COM_IRQ_GIMSK_CLK = PCIE diff --git a/avr/devices/n14/main/main.asm b/avr/devices/n14/main/main.asm index 425a941..b05ccfe 100644 --- a/avr/devices/n14/main/main.asm +++ b/avr/devices/n14/main/main.asm @@ -40,7 +40,9 @@ ; --------------------------------------------------------------------------- ; generic -.equ NET_BUFFERS_NUM = 6 +.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) @@ -50,7 +52,7 @@ #define MODULES_CLOCK #define MODULES_LED_SIMPLE #define MODULES_NETWORK -#define MODULES_UART_BITBANG +#define MODULES_COM2W #define MODULES_OWI_MASTER #define MODULES_DS18B20 #define MODULES_SK6812 @@ -98,7 +100,7 @@ rjmp BOOTLOADER_ADDR ; Reset vector ; use this for flashed system reti ; EXT_INT0 - rjmp UART_BitBang_PcintIsr ; PCI0 + rjmp com2wPcintIsr ; PCI0 reti ; OC1A reti ; OVF1 reti ; OVF0 @@ -199,7 +201,7 @@ onEveryLoop: ; --------------------------------------------------------------------------- ; defines for network interface -.equ netInterfaceData = uart_bitbang_iface +.equ netInterfaceData = com2w_iface diff --git a/avr/devices/n16/boot/boot.asm b/avr/devices/n16/boot/boot.asm index 74bd935..8096bff 100644 --- a/avr/devices/n16/boot/boot.asm +++ b/avr/devices/n16/boot/boot.asm @@ -17,6 +17,7 @@ .include "devices/all/defs.asm" .include "common/calls.asm" +.include "common/utils_io.asm" .include "common/utils_wait.asm" ;.include "modules/com2/defs.asm" ;.include "modules/comproto/defs.asm" @@ -99,8 +100,7 @@ main: .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/io_com2w.asm" .include "modules/flash/flash1p.asm" .include "modules/flash/flashxp.asm" .include "modules/flash/flashprocess.asm" diff --git a/avr/devices/n16/defs.asm b/avr/devices/n16/defs.asm index f5e1371..12d4e10 100644 --- a/avr/devices/n16/defs.asm +++ b/avr/devices/n16/defs.asm @@ -17,7 +17,7 @@ ; PIR PB1 3 12 PA1 COM-DATA ; /RESET PB3 4 11 PA2 TCRT1000_Input ; PB2 5 10 PA3 LED -; COM_ATTN PA7 6 9 PA4 TWI-SCL +; COM_CLK PA7 6 9 PA4 TWI-SCL ; TWI-SDA PA6 7 8 PA5 ; -------- ; @@ -59,15 +59,15 @@ .equ COM_DATA_OUTPUT = PORTA .equ COM_DATA_PIN = PORTA1 -.equ COM_ATTN_DDR = DDRA -.equ COM_ATTN_INPUT = PINA -.equ COM_ATTN_OUTPUT = PORTA -.equ COM_ATTN_PIN = PORTA7 +.equ COM_CLK_DDR = DDRA +.equ COM_CLK_INPUT = PINA +.equ COM_CLK_OUTPUT = PORTA +.equ COM_CLK_PIN = PORTA7 -.equ COM_IRQ_ADDR_ATTN = PCMSK0 -.equ COM_IRQ_BIT_ATTN = PCINT7 ; bit 7 in PCMSK0 -.equ COM_IRQ_GIFR_ATTN = PCIF0 -.equ COM_IRQ_GIMSK_ATTN = PCIE0 +.equ COM_IRQ_ADDR_CLK = PCMSK0 +.equ COM_IRQ_BIT_CLK = PCINT7 ; bit 7 in PCMSK0 +.equ COM_IRQ_GIFR_CLK = PCIF0 +.equ COM_IRQ_GIMSK_CLK = PCIE0 diff --git a/avr/devices/n16/main/main.asm b/avr/devices/n16/main/main.asm index 461aeb2..4354219 100644 --- a/avr/devices/n16/main/main.asm +++ b/avr/devices/n16/main/main.asm @@ -47,7 +47,9 @@ ; --------------------------------------------------------------------------- ; generic -.equ NET_BUFFERS_NUM = 6 +.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) diff --git a/avr/devices/n21/boot/boot.asm b/avr/devices/n21/boot/boot.asm index c05a918..cd8ec3e 100644 --- a/avr/devices/n21/boot/boot.asm +++ b/avr/devices/n21/boot/boot.asm @@ -17,6 +17,7 @@ .include "devices/all/defs.asm" .include "common/calls.asm" +.include "common/utils_io.asm" .include "common/utils_wait.asm" @@ -98,8 +99,7 @@ main: .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/io_com2w.asm" .include "modules/flash/flash1p.asm" .include "modules/flash/flashxp.asm" .include "modules/flash/flashprocess.asm" diff --git a/avr/devices/n21/defs.asm b/avr/devices/n21/defs.asm index 2b5eb92..2f5b3ae 100644 --- a/avr/devices/n21/defs.asm +++ b/avr/devices/n21/defs.asm @@ -17,7 +17,7 @@ ; PIR PB1 3 12 PA1 COM-DATA ; /RESET PB3 4 11 PA2 TCRT1000_Input ; AUX-B2 PB2 5 10 PA3 LED -; COM_ATTN PA7 6 9 PA4 TWI-SCL +; COM_CLK PA7 6 9 PA4 TWI-SCL ; TWI-SDA PA6 7 8 PA5 ; -------- ; @@ -59,15 +59,15 @@ .equ COM_DATA_OUTPUT = PORTA .equ COM_DATA_PIN = PORTA1 -.equ COM_ATTN_DDR = DDRA -.equ COM_ATTN_INPUT = PINA -.equ COM_ATTN_OUTPUT = PORTA -.equ COM_ATTN_PIN = PORTA7 +.equ COM_CLK_DDR = DDRA +.equ COM_CLK_INPUT = PINA +.equ COM_CLK_OUTPUT = PORTA +.equ COM_CLK_PIN = PORTA7 -.equ COM_IRQ_ADDR_ATTN = PCMSK0 -.equ COM_IRQ_BIT_ATTN = PCINT7 ; bit 7 in PCMSK0 -.equ COM_IRQ_GIFR_ATTN = PCIF0 -.equ COM_IRQ_GIMSK_ATTN = PCIE0 +.equ COM_IRQ_ADDR_CLK = PCMSK0 +.equ COM_IRQ_BIT_CLK = PCINT7 ; bit 7 in PCMSK0 +.equ COM_IRQ_GIFR_CLK = PCIF0 +.equ COM_IRQ_GIMSK_CLK = PCIE0 diff --git a/avr/devices/n21/main/main.asm b/avr/devices/n21/main/main.asm index 6fa58e2..dcb1f8c 100644 --- a/avr/devices/n21/main/main.asm +++ b/avr/devices/n21/main/main.asm @@ -47,7 +47,9 @@ ; --------------------------------------------------------------------------- ; generic -.equ NET_BUFFERS_NUM = 6 +.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) @@ -59,7 +61,7 @@ #define MODULES_CLOCK #define MODULES_LED_SIMPLE #define MODULES_NETWORK -#define MODULES_UART_BITBANG +#define MODULES_COM2W #define MODULES_TWI_MASTER ;#define MODULES_LCD ;#define LCD_MINIMAL_FONT @@ -112,7 +114,7 @@ ; rjmp main ; Reset vector rjmp BOOTLOADER_ADDR ; Reset vector ; use this for flashed system reti ; EXT_INT0 - rjmp UART_BitBang_PcintIsr ; PCI0 + rjmp com2wPcintIsr ; PCI0 reti ; PCI1 reti ; WATCHDOG reti ; ICP1 @@ -212,6 +214,6 @@ onEveryLoop: ; --------------------------------------------------------------------------- ; defines for network interface -.equ netInterfaceData = uart_bitbang_iface +.equ netInterfaceData = com2w_iface diff --git a/avr/devices/n24/boot/boot.asm b/avr/devices/n24/boot/boot.asm index 767f207..f867d2b 100644 --- a/avr/devices/n24/boot/boot.asm +++ b/avr/devices/n24/boot/boot.asm @@ -26,6 +26,7 @@ .include "../defs.asm" .include "common/calls.asm" +.include "common/utils_io.asm" .include "devices/all/defs.asm" @@ -122,8 +123,7 @@ main: .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/io_com2w.asm" .include "modules/flash/flash1p.asm" .include "modules/flash/flashxp.asm" .include "modules/flash/flashprocess.asm" diff --git a/avr/devices/n24/defs.asm b/avr/devices/n24/defs.asm index d1b401f..0bdeb74 100644 --- a/avr/devices/n24/defs.asm +++ b/avr/devices/n24/defs.asm @@ -17,7 +17,7 @@ ; PIR PB1 3 12 PA1 COM-DATA ; /RESET PB3 4 11 PA2 AUX-PA2 ; PB2 5 10 PA3 LED -; COM_ATTN PA7 6 9 PA4 TWI-SCL +; COM_CLK PA7 6 9 PA4 TWI-SCL ; TWI-SDA PA6 7 8 PA5 ; -------- ; @@ -59,15 +59,15 @@ .equ COM_DATA_OUTPUT = PORTA .equ COM_DATA_PIN = PORTA1 -.equ COM_ATTN_DDR = DDRA -.equ COM_ATTN_INPUT = PINA -.equ COM_ATTN_OUTPUT = PORTA -.equ COM_ATTN_PIN = PORTA7 +.equ COM_CLK_DDR = DDRA +.equ COM_CLK_INPUT = PINA +.equ COM_CLK_OUTPUT = PORTA +.equ COM_CLK_PIN = PORTA7 -.equ COM_IRQ_ADDR_ATTN = PCMSK0 -.equ COM_IRQ_BIT_ATTN = PCINT7 ; bit 7 in PCMSK0 -.equ COM_IRQ_GIFR_ATTN = PCIF0 -.equ COM_IRQ_GIMSK_ATTN = PCIE0 +.equ COM_IRQ_ADDR_CLK = PCMSK0 +.equ COM_IRQ_BIT_CLK = PCINT7 ; bit 7 in PCMSK0 +.equ COM_IRQ_GIFR_CLK = PCIF0 +.equ COM_IRQ_GIMSK_CLK = PCIE0 diff --git a/avr/devices/n24/main/main.asm b/avr/devices/n24/main/main.asm index b11d874..242d8c7 100644 --- a/avr/devices/n24/main/main.asm +++ b/avr/devices/n24/main/main.asm @@ -47,7 +47,9 @@ ; --------------------------------------------------------------------------- ; generic -.equ NET_BUFFERS_NUM = 6 +.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) .equ PROGRAM_SENSOR_INTERVAL_SECS = 60 .equ PROGRAM_STATS_INTERVAL_MINS = 10 @@ -61,7 +63,7 @@ #define MODULES_CLOCK #define MODULES_LED_SIMPLE #define MODULES_NETWORK -#define MODULES_UART_BITBANG +#define MODULES_COM2W #define MODULES_TWI_MASTER ;#define MODULES_LCD ;#define LCD_MINIMAL_FONT @@ -123,7 +125,7 @@ ; rjmp main ; Reset vector rjmp BOOTLOADER_ADDR ; Reset vector ; use this for flashed system reti ; EXT_INT0 - rjmp UART_BitBang_PcintIsr ; PCI0 + rjmp com2wPcintIsr ; PCI0 reti ; PCI1 reti ; WATCHDOG reti ; ICP1 @@ -218,7 +220,7 @@ onEveryLoop: ; --------------------------------------------------------------------------- ; defines for network interface -.equ netInterfaceData = uart_bitbang_iface +.equ netInterfaceData = com2w_iface diff --git a/avr/devices/n25/boot/boot.asm b/avr/devices/n25/boot/boot.asm index d0987a0..df06de6 100644 --- a/avr/devices/n25/boot/boot.asm +++ b/avr/devices/n25/boot/boot.asm @@ -19,6 +19,7 @@ .include "devices/all/defs.asm" .include "common/calls.asm" +.include "common/utils_io.asm" .include "common/utils_wait.asm" @@ -99,8 +100,7 @@ main: .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/io_com2w.asm" .include "modules/flash/flashxp.asm" .include "modules/flash/flash1p.asm" .include "modules/flash/flashprocess.asm" diff --git a/avr/devices/n25/defs.asm b/avr/devices/n25/defs.asm index 1ad3575..2a9b1e3 100644 --- a/avr/devices/n25/defs.asm +++ b/avr/devices/n25/defs.asm @@ -16,7 +16,7 @@ ; PB1 3 12 PA1 COM-DATA ; PB3 4 11 PA2 ; PB2 5 10 PA3 LED -; COM_ATTN PA7 6 9 PA4 LED_CLK +; COM_CLK PA7 6 9 PA4 LED_CLK ; LED_DATA PA6 7 8 PA5 LED_Mode (0 for SPI) ; -------- ; @@ -58,15 +58,15 @@ .equ COM_DATA_OUTPUT = PORTA .equ COM_DATA_PIN = PORTA1 -.equ COM_ATTN_DDR = DDRA -.equ COM_ATTN_INPUT = PINA -.equ COM_ATTN_OUTPUT = PORTA -.equ COM_ATTN_PIN = PORTA7 +.equ COM_CLK_DDR = DDRA +.equ COM_CLK_INPUT = PINA +.equ COM_CLK_OUTPUT = PORTA +.equ COM_CLK_PIN = PORTA7 -.equ COM_IRQ_ADDR_ATTN = PCMSK0 -.equ COM_IRQ_BIT_ATTN = PCINT7 ; bit 7 in PCMSK0 (PCINT7) -.equ COM_IRQ_GIFR_ATTN = PCIF0 -.equ COM_IRQ_GIMSK_ATTN = PCIE0 +.equ COM_IRQ_ADDR_CLK = PCMSK0 +.equ COM_IRQ_BIT_CLK = PCINT7 ; bit 7 in PCMSK0 (PCINT7) +.equ COM_IRQ_GIFR_CLK = PCIF0 +.equ COM_IRQ_GIMSK_CLK = PCIE0 diff --git a/avr/devices/n25/main/main.asm b/avr/devices/n25/main/main.asm index 3f52ad5..139400a 100644 --- a/avr/devices/n25/main/main.asm +++ b/avr/devices/n25/main/main.asm @@ -40,7 +40,9 @@ ; --------------------------------------------------------------------------- ; generic -.equ NET_BUFFERS_NUM = 6 +.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) @@ -51,7 +53,7 @@ #define MODULES_CLOCK #define MODULES_LED_SIMPLE #define MODULES_NETWORK -#define MODULES_UART_BITBANG +#define MODULES_COM2W #define MODULES_OWI_MASTER #define MODULES_DS18B20 #define MODULES_SK6812 @@ -99,11 +101,7 @@ rjmp BOOTLOADER_ADDR ; 1: Reset vector ; use this for flashed system reti ; 2: EXT_INT0 -#ifdef MODULES_UART_BITBANG - rjmp UART_BitBang_PcintIsr ; 3: PCI0 -#else - reti ; 3: PCI0 -#endif + rjmp com2wPcintIsr ; 3: PCI0 reti ; 4: PCI1 reti ; 5: WDT reti ; 6: TIM1_CAPT @@ -208,9 +206,7 @@ onEveryLoop: ; --------------------------------------------------------------------------- ; defines for network interface -#ifdef MODULES_UART_BITBANG -.equ netInterfaceData = uart_bitbang_iface -#endif +.equ netInterfaceData = com2w_iface diff --git a/avr/devices/n26/boot/boot.asm b/avr/devices/n26/boot/boot.asm index 767f207..f867d2b 100644 --- a/avr/devices/n26/boot/boot.asm +++ b/avr/devices/n26/boot/boot.asm @@ -26,6 +26,7 @@ .include "../defs.asm" .include "common/calls.asm" +.include "common/utils_io.asm" .include "devices/all/defs.asm" @@ -122,8 +123,7 @@ main: .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/io_com2w.asm" .include "modules/flash/flash1p.asm" .include "modules/flash/flashxp.asm" .include "modules/flash/flashprocess.asm" diff --git a/avr/devices/n26/defs.asm b/avr/devices/n26/defs.asm index 8f27140..904a131 100644 --- a/avr/devices/n26/defs.asm +++ b/avr/devices/n26/defs.asm @@ -17,7 +17,7 @@ ; PB1 3 12 PA1 COM-DATA ; /RESET PB3 4 11 PA2 ; PB2 5 10 PA3 LED -; COM_ATTN PA7 6 9 PA4 TWI-SCL +; COM_CLK PA7 6 9 PA4 TWI-SCL ; TWI-SDA PA6 7 8 PA5 ; -------- ; @@ -59,15 +59,15 @@ .equ COM_DATA_OUTPUT = PORTA .equ COM_DATA_PIN = PORTA1 -.equ COM_ATTN_DDR = DDRA -.equ COM_ATTN_INPUT = PINA -.equ COM_ATTN_OUTPUT = PORTA -.equ COM_ATTN_PIN = PORTA7 +.equ COM_CLK_DDR = DDRA +.equ COM_CLK_INPUT = PINA +.equ COM_CLK_OUTPUT = PORTA +.equ COM_CLK_PIN = PORTA7 -.equ COM_IRQ_ADDR_ATTN = PCMSK0 -.equ COM_IRQ_BIT_ATTN = PCINT7 ; bit 7 in PCMSK0 -.equ COM_IRQ_GIFR_ATTN = PCIF0 -.equ COM_IRQ_GIMSK_ATTN = PCIE0 +.equ COM_IRQ_ADDR_CLK = PCMSK0 +.equ COM_IRQ_BIT_CLK = PCINT7 ; bit 7 in PCMSK0 +.equ COM_IRQ_GIFR_CLK = PCIF0 +.equ COM_IRQ_GIMSK_CLK = PCIE0 diff --git a/avr/devices/n26/main/main.asm b/avr/devices/n26/main/main.asm index bec6550..63abdc6 100644 --- a/avr/devices/n26/main/main.asm +++ b/avr/devices/n26/main/main.asm @@ -48,6 +48,8 @@ ; 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) .equ PROGRAM_SENSOR_INTERVAL_SECS = 60 .equ PROGRAM_STATS_INTERVAL_MINS = 10 @@ -61,7 +63,8 @@ #define MODULES_CLOCK #define MODULES_LED_SIMPLE #define MODULES_NETWORK -#define MODULES_UART_BITBANG +;#define MODULES_UART_BITBANG +#define MODULES_COM2W #define MODULES_TWI_MASTER ;#define MODULES_LCD ;#define LCD_MINIMAL_FONT @@ -109,7 +112,7 @@ ; rjmp main ; Reset vector rjmp BOOTLOADER_ADDR ; Reset vector ; use this for flashed system reti ; EXT_INT0 - rjmp UART_BitBang_PcintIsr ; PCI0 + rjmp com2wPcintIsr ; PCI0 reti ; PCI1 reti ; WATCHDOG reti ; ICP1 @@ -204,7 +207,7 @@ onEveryLoop: ; --------------------------------------------------------------------------- ; defines for network interface -.equ netInterfaceData = uart_bitbang_iface +.equ netInterfaceData = com2w_iface diff --git a/avr/devices/n27/defs.asm b/avr/devices/n27/defs.asm index 21f980e..7fc3e86 100644 --- a/avr/devices/n27/defs.asm +++ b/avr/devices/n27/defs.asm @@ -17,7 +17,7 @@ ; PIR PB1 3 12 PA1 COM-DATA ; /RESET PB3 4 11 PA2 AUX-PA2 ; PB2 5 10 PA3 LED -; COM_ATTN PA7 6 9 PA4 TWI-SCL +; COM_CLK PA7 6 9 PA4 TWI-SCL ; TWI-SDA PA6 7 8 PA5 ; -------- ; @@ -59,17 +59,6 @@ .equ COM_DATA_OUTPUT = PORTA .equ COM_DATA_PIN = PORTA1 -.equ COM_ATTN_DDR = DDRA -.equ COM_ATTN_INPUT = PINA -.equ COM_ATTN_OUTPUT = PORTA -.equ COM_ATTN_PIN = PORTA7 - -.equ COM_IRQ_ADDR_ATTN = PCMSK0 -.equ COM_IRQ_BIT_ATTN = PCINT7 ; bit 7 in PCMSK0 -.equ COM_IRQ_GIFR_ATTN = PCIF0 -.equ COM_IRQ_GIMSK_ATTN = PCIE0 - - .equ COM_CLK_DDR = DDRA .equ COM_CLK_INPUT = PINA .equ COM_CLK_OUTPUT = PORTA diff --git a/avr/devices/n27/main/main.asm b/avr/devices/n27/main/main.asm index f1695b2..9f9b7aa 100644 --- a/avr/devices/n27/main/main.asm +++ b/avr/devices/n27/main/main.asm @@ -47,10 +47,12 @@ ; --------------------------------------------------------------------------- ; generic -.equ NET_BUFFERS_NUM = 6 +.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) .equ PROGRAM_SENSOR_INTERVAL_SECS = 60 -.equ PROGRAM_STATS_INTERVAL_MINS = 10 +.equ PROGRAM_STATS_INTERVAL_MINS = 10 @@ -124,7 +126,6 @@ ; rjmp main ; Reset vector rjmp BOOTLOADER_ADDR ; Reset vector ; use this for flashed system reti ; EXT_INT0 -; rjmp UART_BitBang_PcintIsr ; PCI0 rjmp com2wPcintIsr ; PCI0 reti ; PCI1 reti ; WATCHDOG @@ -220,7 +221,6 @@ onEveryLoop: ; --------------------------------------------------------------------------- ; defines for network interface -;.equ netInterfaceData = uart_bitbang_iface .equ netInterfaceData = com2w_iface diff --git a/avr/devices/r06/defs.asm b/avr/devices/r06/defs.asm index 7c0728e..e952453 100644 --- a/avr/devices/r06/defs.asm +++ b/avr/devices/r06/defs.asm @@ -74,6 +74,11 @@ .equ COM_LED_PIN = PORTB0 +.equ COM_IRQ_ADDR_M_CLK = GIMSK +.equ COM_IRQ_BIT_M_CLK = PCIE0 +.equ COM_IRQ_ADDR_F_CLK = GIFR +.equ COM_IRQ_BIT_F_CLK = PCIE0 + .equ COM_PORTS = 2 .equ COM_MASK_CLK0 = (1< Date: Tue, 19 Aug 2025 23:03:15 +0200 Subject: [PATCH 136/196] avr: tweaked timing for com2w transport layer. --- avr/devices/n16/defs.asm | 2 +- avr/devices/n16/main/main.asm | 6 +- avr/devices/n21/defs.asm | 2 +- avr/devices/n24/defs.asm | 2 +- avr/devices/n25/defs.asm | 2 +- avr/devices/n26/defs.asm | 2 +- avr/devices/n27/defs.asm | 2 +- avr/devices/t03/defs.asm | 6 +- avr/devices/t03/main/main.asm | 7 +- avr/devices/t03/test/main.asm | 9 +- avr/modules/com2w/com2w.asm | 169 +++++++++++++++++++----------- avr/modules/com2w/com2wn_send.asm | 6 +- avr/modules/com2w/com2wn_wait.asm | 116 ++++++++++++++++---- avr/modules/com2w/defs.asm | 2 +- avr/modules/flash/io_com2w.asm | 167 +++++++++++++++-------------- 15 files changed, 311 insertions(+), 189 deletions(-) diff --git a/avr/devices/n16/defs.asm b/avr/devices/n16/defs.asm index 12d4e10..0340b5f 100644 --- a/avr/devices/n16/defs.asm +++ b/avr/devices/n16/defs.asm @@ -17,7 +17,7 @@ ; PIR PB1 3 12 PA1 COM-DATA ; /RESET PB3 4 11 PA2 TCRT1000_Input ; PB2 5 10 PA3 LED -; COM_CLK PA7 6 9 PA4 TWI-SCL +; COM_CLK PA7 6 9 PA4 TWI-SCL ; TWI-SDA PA6 7 8 PA5 ; -------- ; diff --git a/avr/devices/n16/main/main.asm b/avr/devices/n16/main/main.asm index 4354219..531361f 100644 --- a/avr/devices/n16/main/main.asm +++ b/avr/devices/n16/main/main.asm @@ -59,7 +59,7 @@ #define MODULES_CLOCK #define MODULES_LED_SIMPLE #define MODULES_NETWORK -#define MODULES_UART_BITBANG +#define MODULES_COM2W #define MODULES_TWI_MASTER ;#define MODULES_LCD ;#define LCD_MINIMAL_FONT @@ -109,7 +109,7 @@ ; rjmp main ; Reset vector rjmp BOOTLOADER_ADDR ; Reset vector ; use this for flashed system reti ; EXT_INT0 - rjmp UART_BitBang_PcintIsr ; PCI0 + rjmp com2wPcintIsr ; PCI0 reti ; PCI1 reti ; WATCHDOG reti ; ICP1 @@ -204,7 +204,7 @@ onEveryLoop: ; --------------------------------------------------------------------------- ; defines for network interface -.equ netInterfaceData = uart_bitbang_iface +.equ netInterfaceData = com2w_iface diff --git a/avr/devices/n21/defs.asm b/avr/devices/n21/defs.asm index 2f5b3ae..67bed89 100644 --- a/avr/devices/n21/defs.asm +++ b/avr/devices/n21/defs.asm @@ -17,7 +17,7 @@ ; PIR PB1 3 12 PA1 COM-DATA ; /RESET PB3 4 11 PA2 TCRT1000_Input ; AUX-B2 PB2 5 10 PA3 LED -; COM_CLK PA7 6 9 PA4 TWI-SCL +; COM_CLK PA7 6 9 PA4 TWI-SCL ; TWI-SDA PA6 7 8 PA5 ; -------- ; diff --git a/avr/devices/n24/defs.asm b/avr/devices/n24/defs.asm index 0bdeb74..1e7d5cb 100644 --- a/avr/devices/n24/defs.asm +++ b/avr/devices/n24/defs.asm @@ -17,7 +17,7 @@ ; PIR PB1 3 12 PA1 COM-DATA ; /RESET PB3 4 11 PA2 AUX-PA2 ; PB2 5 10 PA3 LED -; COM_CLK PA7 6 9 PA4 TWI-SCL +; COM_CLK PA7 6 9 PA4 TWI-SCL ; TWI-SDA PA6 7 8 PA5 ; -------- ; diff --git a/avr/devices/n25/defs.asm b/avr/devices/n25/defs.asm index 2a9b1e3..fa508c6 100644 --- a/avr/devices/n25/defs.asm +++ b/avr/devices/n25/defs.asm @@ -16,7 +16,7 @@ ; PB1 3 12 PA1 COM-DATA ; PB3 4 11 PA2 ; PB2 5 10 PA3 LED -; COM_CLK PA7 6 9 PA4 LED_CLK +; COM_CLK PA7 6 9 PA4 LED_CLK ; LED_DATA PA6 7 8 PA5 LED_Mode (0 for SPI) ; -------- ; diff --git a/avr/devices/n26/defs.asm b/avr/devices/n26/defs.asm index 904a131..0b4a2fd 100644 --- a/avr/devices/n26/defs.asm +++ b/avr/devices/n26/defs.asm @@ -17,7 +17,7 @@ ; PB1 3 12 PA1 COM-DATA ; /RESET PB3 4 11 PA2 ; PB2 5 10 PA3 LED -; COM_CLK PA7 6 9 PA4 TWI-SCL +; COM_CLK PA7 6 9 PA4 TWI-SCL ; TWI-SDA PA6 7 8 PA5 ; -------- ; diff --git a/avr/devices/n27/defs.asm b/avr/devices/n27/defs.asm index 7fc3e86..c1646cc 100644 --- a/avr/devices/n27/defs.asm +++ b/avr/devices/n27/defs.asm @@ -17,7 +17,7 @@ ; PIR PB1 3 12 PA1 COM-DATA ; /RESET PB3 4 11 PA2 AUX-PA2 ; PB2 5 10 PA3 LED -; COM_CLK PA7 6 9 PA4 TWI-SCL +; COM_CLK PA7 6 9 PA4 TWI-SCL ; TWI-SDA PA6 7 8 PA5 ; -------- ; diff --git a/avr/devices/t03/defs.asm b/avr/devices/t03/defs.asm index cf5f970..14b690a 100644 --- a/avr/devices/t03/defs.asm +++ b/avr/devices/t03/defs.asm @@ -13,9 +13,9 @@ ; AtTiny 841 ; ------- ; VCC 1 14 GND -; PB0 2 13 PA0 ATTN0 -; PB1 3 12 PA1 TXD0 (UART0) -; /RESET PB3 4 11 PA2 RXD0 (UART0) +; PB0 2 13 PA0 COM-CLK +; PB1 3 12 PA1 +; /RESET PB3 4 11 PA2 COM-DATA ; LED PB2 5 10 PA3 ; 1-wire PA7 6 9 PA4 RXD1 (UART1) [SCK, PRG] ; [MOSI,PRG] SDA (I2C) PA6 7 8 PA5 TXD1 (UART1) [MISO, PRG] diff --git a/avr/devices/t03/main/main.asm b/avr/devices/t03/main/main.asm index c817180..9580fc8 100644 --- a/avr/devices/t03/main/main.asm +++ b/avr/devices/t03/main/main.asm @@ -83,9 +83,9 @@ .equ NET_BUFFERS_NUM = 10 +.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) -.equ UART_HW_MSGNUMINBUF_SIZE = 8 -.equ UART_HW_MSGNUMOUTBUF_SIZE = 8 @@ -110,7 +110,6 @@ rjmp BOOTLOADER_ADDR ; 1: RESET Reset vector use this for flashed system reti ; 2: INT0 External Interrupt Request 0 -; rjmp COM2W1_ClkChangeIsr ; 3: PCINT0 Pin Change Interrupt 0 rjmp com2wPcintIsr ; 3: PCINT0 Pin Change Interrupt 0 reti ; 4: PCINT1 Pin Change Interrupt 1 reti ; 5: WDT Watchdog Time-out @@ -131,7 +130,6 @@ reti ; 20: TIM2_OVF (OVF2) Timer/Counter2 Overflow reti ; 21: SPI SPI Serial Transfer Complete reti ; 22: USART0_RXS USART0 Rx Start -; rjmp ComOnUart0_RxCharIsr ; 23: USART0_RXC USART0 Rx Complete reti ; 23: USART0_RXC USART0 Rx Complete reti ; 24: USART0_DRE USART0 Data Register Empty reti ; 25: USART0_TXC USART0 Tx Complete @@ -335,6 +333,5 @@ addMsgToInterface_toUart1: ; defines for network interface .equ netInterfaceData = ttyOnUart1_iface -;.equ netInterfaceData2 = comOnUart0_iface .equ netInterfaceData2 = com2w_iface diff --git a/avr/devices/t03/test/main.asm b/avr/devices/t03/test/main.asm index 1154fbb..79b7a06 100644 --- a/avr/devices/t03/test/main.asm +++ b/avr/devices/t03/test/main.asm @@ -75,7 +75,7 @@ ;#define MODULES_DS18B20 ;#define MODULES_MOTION #define MODULES_NETWORK -#define MODULES_COM2W0 +#define MODULES_COM2W ;#define MODULES_COMONUART0 #define MODULES_TTYONUART1 #define APPS_STATS @@ -85,6 +85,8 @@ .equ NET_BUFFERS_NUM = 10 +.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) .equ UART_HW_MSGNUMINBUF_SIZE = 8 .equ UART_HW_MSGNUMOUTBUF_SIZE = 8 @@ -132,7 +134,7 @@ rjmp BOOTLOADER_ADDR ; 1: RESET Reset vector use this for flashed system reti ; 2: INT0 External Interrupt Request 0 - rjmp COM2W0_ClkChangeIsr ; 3: PCINT0 Pin Change Interrupt 0 + rjmp com2wPcintIsr ; 3: PCINT0 Pin Change Interrupt 0 reti ; 4: PCINT1 Pin Change Interrupt 1 reti ; 5: WDT Watchdog Time-out reti ; 6: TIM1_CAPT Timer/Counter1 Capture Event @@ -244,8 +246,7 @@ onMessageReceived: ; defines for network interface .equ netInterfaceData = ttyOnUart1_iface -;.equ netInterfaceData2 = comOnUart0_iface -.equ netInterfaceData2 = com2w0_iface +.equ netInterfaceData2 = com2w_iface ; debug diff --git a/avr/modules/com2w/com2w.asm b/avr/modules/com2w/com2w.asm index d2fe8b2..56988d3 100644 --- a/avr/modules/com2w/com2w.asm +++ b/avr/modules/com2w/com2w.asm @@ -170,6 +170,7 @@ com2wReceiveNextPkg_end: +#if 0 ; --------------------------------------------------------------------------- ; @routine com2wReceiveAndCheckMsg ; @@ -208,6 +209,7 @@ com2wReceiveAndCheckMsg_msgOk: sec ret ; @end +#endif @@ -247,9 +249,9 @@ com2wSendNextPkg_end: ; @clobbers R16, R18 (R20, R22, R24, R25, X) com2wSendMsg: - ldi r20, 11 ; wait for about 55us for clock low - rcall com2wWaitForClockLowMulti5Us - brcs com2wSendMsg_busy ; CLK got low while waiting, so line is busy + ldi r20, 6 ; wait for about 60us for clock low + rcall com2wWaitForClockLowMulti10Us ; (R16, R20, R22) + brcs com2wSendMsg_busy ; CLK got low while waiting, so line is busy push r15 in r15, SREG cli ; atomic disable irq and set CLK low @@ -313,7 +315,7 @@ com2wSendByte: ldi r17, 8 com2wSendByte_loop: rcall com2wClkSetLow - rcall com2wWaitTime1 ; longer wait period (R22) + rcall com2wWaitTime2 ; shorter wait period (R22) lsr r16 brcs com2wSendByte_send1 rcall com2wDataSetLow @@ -321,12 +323,12 @@ com2wSendByte_loop: com2wSendByte_send1: rcall com2wDataSetHigh com2wSendByte_sent: - rcall com2wWaitTime2 ; shorter wait period (R22) + Utils_WaitNanoSecs 5000, 0, r22 ; wait for very short time to ensure data is stable when clock rises push r15 in r15, SREG cli ; ensure time period by disabling irqs rcall com2wClkSetHigh - rcall com2wWaitTime1 ; longer wait period (R22) + rcall com2wWaitTime2 ; shorter wait period (R22) out SREG, r15 pop r15 dec r17 @@ -416,21 +418,12 @@ com2wRecvByte: ldi r17, 8 clr r16 com2wRecvByte_loop: - ldi r20, 31 ; wait up to 155us for clock low - rcall com2wWaitForClockLowMulti5Us ; (R20, R22) - brcs com2wRecvByte_waitForClkHigh - ldi r20, 31 ; wait up to 155us for clock low - rcall com2wWaitForClockLowMulti5Us ; (R20, R22) + ldi r20, 50 ; wait up to 500us for clock low + rcall com2wWaitForClockLowMulti10Us ; (R16, R20, R22) brcc com2wRecvByte_end -com2wRecvByte_waitForClkHigh: - ldi r20, 31 ; wait up to 155us for clock high - rcall com2wWaitForClockHighMulti5Us ; (R20, R22) - brcs com2wRecvByte_readBit - ldi r20, 31 ; wait up to 155us for clock high - rcall com2wWaitForClockHighMulti5Us ; (R20, R22) + ldi r20, 50 ; wait up to 500us for clock high + rcall com2wWaitForClockHighMulti10Us ; (R16, R20, R22) brcc com2wRecvByte_end - -com2wRecvByte_readBit: ; handle received bit inr r18, COM_DATA_INPUT andi r18, (1< 1000000 +; begin version for > 1000000 Hz + ldi r22, clock/1000000 +com2wWaitForClockHighMulti10Us_loop0: + push r20 +com2wWaitForClockHighMulti10Us_loop: ; 10 cycles per loop + sbic COM_CLK_INPUT, COM_CLK_PIN ; +2 if skipped, +1 if taken + rjmp com2wWaitForClockHighMulti10Us_stateReached ; (+2 if taken) + sbic COM_CLK_INPUT, COM_CLK_PIN ; +2 if skipped, +1 if taken + rjmp com2wWaitForClockHighMulti10Us_stateReached ; (+2 if taken) + sbic COM_CLK_INPUT, COM_CLK_PIN ; +2 if skipped, +1 if taken + rjmp com2wWaitForClockHighMulti10Us_stateReached ; (+2 if taken) + nop ; +1 + dec r20 ; +1 + brne com2wWaitForClockHighMulti10Us_loop ; +2 if TRUE, +1 if FALSE + pop r20 + dec r22 ; +1 + brne com2wWaitForClockHighMulti10Us_loop0 ; +1 if FALSE, +2 if TRUE + clc ; +1 + ret ; +4 +com2wWaitForClockHighMulti10Us_stateReached: + pop r20 + sec ; +1 + ret ; +4 +; end version for > 1000000 Hz +.elif clock < 1000000 + .error "Clock speed too low" .else - .error "Unhandled clock speed" +; begin version for 1000000 Hz +com2wWaitForClockHighMulti10Us_loop: ; 10 cycles per loop + sbic COM_CLK_INPUT, COM_CLK_PIN ; +2 if skipped, +1 if taken + rjmp com2wWaitForClockHighMulti10Us_stateReached ; (+2 if taken) + sbic COM_CLK_INPUT, COM_CLK_PIN ; +2 if skipped, +1 if taken + rjmp com2wWaitForClockHighMulti10Us_stateReached ; (+2 if taken) + sbic COM_CLK_INPUT, COM_CLK_PIN ; +2 if skipped, +1 if taken + rjmp com2wWaitForClockHighMulti10Us_stateReached ; (+2 if taken) + nop ; +1 + dec r20 ; +1 + brne com2wWaitForClockHighMulti10Us_loop ; +2 if TRUE, +1 if FALSE + clc ; +1 + ret ; +4 +com2wWaitForClockHighMulti10Us_stateReached: + sec ; +1 + ret ; +4 +; end version for 1000000 Hz .endif - -com2wWaitForClockHighMulti5Us_loop: ; 5 cycles per loop - sbic COM_CLK_INPUT, COM_CLK_PIN ; +2 if skipped, +1 if not - rjmp com2wWaitForClockHighMulti5Us_stateReached ; +2 - dec r20 ; +1 - brne com2wWaitForClockHighMulti5Us_loop ; +2 - clc ; +1 - ret ; +4 -com2wWaitForClockHighMulti5Us_stateReached: - sec ; +1 - ret ; +4 ; @end ; --------------------------------------------------------------------------- -; @routine com2wWaitForClockLowMulti5Us +; @routine com2wWaitForClockLowMulti10Us ; ; Wait for low CLK ; -; @param R20 multiple of 5us to wait (e.g. "2" for "10" us, max: 64) +; @param R20 multiple of 10us to wait (e.g. "2" for "20" us) ; @return CFLAG set if okay (state reached), cleared on error ; @clobbers: r20, r22 -com2wWaitForClockLowMulti5Us: -.if clock == 8000000 - add r20, r20 ; *2 - add r20, r20 ; *4 - add r20, r20 ; *8 -.endif -.elif clock == 1000000 -; nothing to do +com2wWaitForClockLowMulti10Us: +.if clock > 1000000 +; begin version for > 1000000 Hz + ldi r22, clock/1000000 +com2wWaitForClockLowMulti10Us_loop0: + push r20 +com2wWaitForClockLowMulti10Us_loop: ; 10 cycles per loop + sbis COM_CLK_INPUT, COM_CLK_PIN ; +2 if skipped, +1 if taken + rjmp com2wWaitForClockLowMulti10Us_stateReached ; (+2 if taken) + sbis COM_CLK_INPUT, COM_CLK_PIN ; +2 if skipped, +1 if taken + rjmp com2wWaitForClockLowMulti10Us_stateReached ; (+2 if taken) + sbis COM_CLK_INPUT, COM_CLK_PIN ; +2 if skipped, +1 if taken + rjmp com2wWaitForClockLowMulti10Us_stateReached ; (+2 if taken) + nop ; +1 + dec r20 ; +1 + brne com2wWaitForClockLowMulti10Us_loop ; +2 if TRUE, +1 if FALSE + pop r20 + dec r22 ; +1 + brne com2wWaitForClockLowMulti10Us_loop0 ; +1 if FALSE, +2 if TRUE + clc ; +1 + ret ; +4 +com2wWaitForClockLowMulti10Us_stateReached: + pop r20 + sec ; +1 + ret ; +4 +; end version for > 1000000 Hz +.elif clock < 1000000 + .error "Clock speed too low" .else - .error "Unhandled clock speed" +; begin version for 1000000 Hz +com2wWaitForClockLowMulti10Us_loop: ; 10 cycles per loop + sbis COM_CLK_INPUT, COM_CLK_PIN ; +2 if skipped, +1 if taken + rjmp com2wWaitForClockLowMulti10Us_stateReached ; (+2 if taken) + sbis COM_CLK_INPUT, COM_CLK_PIN ; +2 if skipped, +1 if taken + rjmp com2wWaitForClockLowMulti10Us_stateReached ; (+2 if taken) + sbis COM_CLK_INPUT, COM_CLK_PIN ; +2 if skipped, +1 if taken + rjmp com2wWaitForClockLowMulti10Us_stateReached ; (+2 if taken) + nop ; +1 + dec r20 ; +1 + brne com2wWaitForClockLowMulti10Us_loop ; +2 if TRUE, +1 if FALSE + clc ; +1 + ret ; +4 +com2wWaitForClockLowMulti10Us_stateReached: + sec ; +1 + ret ; +4 +; end version for 1000000 Hz .endif - -com2wWaitForClockLowMulti5Us_loop: ; 5 cycles per loop - sbis COM_CLK_INPUT, COM_CLK_PIN ; +2 if skipped, +1 if not - rjmp com2wWaitForClockLowMulti5Us_stateReached ; +2 - dec r20 ; +1 - brne com2wWaitForClockLowMulti5Us_loop ; +2 - clc ; +1 - ret ; +4 -com2wWaitForClockLowMulti5Us_stateReached: - sec ; +1 - ret ; +4 ; @end diff --git a/avr/modules/com2w/com2wn_send.asm b/avr/modules/com2w/com2wn_send.asm index 3faee47..137abbc 100644 --- a/avr/modules/com2w/com2wn_send.asm +++ b/avr/modules/com2w/com2wn_send.asm @@ -29,13 +29,13 @@ com2wnSendMsg: ldi r20, 6 ; wait for about 60us for clock low - rcall com2wWaitForClockLowMulti10Us ; (R17, R20, R22) - brcs com2wnSendMsg_busy ; CLK got low while waiting, so line is busy + rcall com2wWaitForClockLowMulti10Us ; (R16, R20, R22) + brcs com2wnSendMsg_busy ; CLK got low while waiting, so line is busy push r15 in r15, SREG cli ; atomic disable irq and set CLK low rcall com2wnDisableClkIrq ; (none) - rcall com2wnClkSetLow ; reserve bus (none) + rcall com2wnClkSetLow ; reserve bus (none) out SREG, r15 pop r15 adiw xh:xl, NETMSG_OFFS_MSGLEN diff --git a/avr/modules/com2w/com2wn_wait.asm b/avr/modules/com2w/com2wn_wait.asm index 0f95350..365589f 100644 --- a/avr/modules/com2w/com2wn_wait.asm +++ b/avr/modules/com2w/com2wn_wait.asm @@ -31,30 +31,33 @@ com2wWaitForClockHighMulti10Us: .if clock > 1000000 ; begin version for > 1000000 Hz - ldi r20, LOW(clock/1000000) - ldd r22, Y+COM2W_IFACE_OFFS_PINMASK_CLK ; +2 + push r19 + ldi r19, LOW(clock/1000000) + ldd r22, Y+COM2W_IFACE_OFFS_PINMASK_CLK ; +2 com2wWaitForClockHighMulti10Us_loop0: - push r20 ; +2 + push r20 com2wWaitForClockHighMulti10Us_loop: ; 10 cycles per loop - inr r16, COM_CLK_INPUT ; +1 (if low port, +2 if high port) - and r16, r22 ; +1 - breq com2wWaitForClockHighMulti10Us_stateReached ; +1 if FALSE, +2 if TRUE - - inr r16, COM_CLK_INPUT ; +1 (if low port, +2 if high port) - and r16, r22 ; +1 - breq com2wWaitForClockHighMulti10Us_stateReached ; +1 if FALSE, +2 if TRUE - - nop ; +1 + inr r16, COM_CLK_INPUT ; +1 (if low port, +2 if high port) + and r16, r22 ; +1 + brne com2wWaitForClockHighMulti10Us_stateReached ; +1 if FALSE, +2 if TRUE - dec r20 ; +1 - brne com2wWaitForClockHighMulti10Us_loop ; +2 if TRUE, +1 if FALSE - pop r20 ; +2 - dec r20 ; +1 - brne com2wWaitForClockHighMulti10Us_loop0 ; +1 if FALSE, +2 if TRUE + inr r16, COM_CLK_INPUT ; +1 (if low port, +2 if high port) + and r16, r22 ; +1 + brne com2wWaitForClockHighMulti10Us_stateReached ; +1 if FALSE, +2 if TRUE + + nop ; +1 + + dec r20 ; +1 + brne com2wWaitForClockHighMulti10Us_loop ; +2 if TRUE, +1 if FALSE + pop r20 + dec r19 ; +1 + brne com2wWaitForClockHighMulti10Us_loop0 ; +1 if FALSE, +2 if TRUE + pop r19 clc ; +1 ret ; +4 com2wWaitForClockHighMulti10Us_stateReached: - pop r20 + pop r20 + pop r19 sec ; +1 ret ; +4 ; end version for > 1000000 Hz @@ -66,11 +69,11 @@ com2wWaitForClockHighMulti10Us_stateReached: com2wWaitForClockHighMulti10Us_loop: ; 10 cycles per loop inr r16, COM_CLK_INPUT ; +1 (if low port, +2 if high port) and r16, r22 ; +1 - breq com2wWaitForClockHighMulti10Us_stateReached ; +1 if FALSE, +2 if TRUE + brne com2wWaitForClockHighMulti10Us_stateReached ; +1 if FALSE, +2 if TRUE inr r16, COM_CLK_INPUT ; +1 (if low port, +2 if high port) and r16, r22 ; +1 - brne com2wWaitForClockHighMulti10Us_stateReached ; +1 if FALSE, +2 if TRUE + brne com2wWaitForClockHighMulti10Us_stateReached ; +1 if FALSE, +2 if TRUE nop ; +1 @@ -97,6 +100,79 @@ com2wWaitForClockHighMulti10Us_stateReached: ; @clobbers: r16, r20, r22 com2wWaitForClockLowMulti10Us: +.if clock > 1000000 +; begin version for > 1000000 Hz + push r19 + ldi r19, LOW(clock/1000000) + ldd r22, Y+COM2W_IFACE_OFFS_PINMASK_CLK ; +2 +com2wWaitForClockLowMulti10Us_loop0: + push r20 +com2wWaitForClockLowMulti10Us_loop: ; 10 cycles per loop + inr r16, COM_CLK_INPUT ; +1 (if low port, +2 if high port) + and r16, r22 ; +1 + breq com2wWaitForClockLowMulti10Us_stateReached ; +1 if FALSE, +2 if TRUE + + inr r16, COM_CLK_INPUT ; +1 (if low port, +2 if high port) + and r16, r22 ; +1 + breq com2wWaitForClockLowMulti10Us_stateReached ; +1 if FALSE, +2 if TRUE + + nop ; +1 + + dec r20 ; +1 + brne com2wWaitForClockLowMulti10Us_loop ; +2 if TRUE, +1 if FALSE + pop r20 + dec r19 ; +1 + brne com2wWaitForClockLowMulti10Us_loop0 ; +1 if FALSE, +2 if TRUE + pop r19 + clc ; +1 + ret ; +4 +com2wWaitForClockLowMulti10Us_stateReached: + pop r20 + pop r19 + sec ; +1 + ret ; +4 +; end version for > 1000000 Hz +.elif clock < 1000000 + .error "Clock speed too low" +.else +; begin version for 1000000 Hz + ldd r22, Y+COM2W_IFACE_OFFS_PINMASK_CLK ; +2 +com2wWaitForClockLowMulti10Us_loop: ; 10 cycles per loop + inr r16, COM_CLK_INPUT ; +1 (if low port, +2 if high port) + and r16, r22 ; +1 + breq com2wWaitForClockLowMulti10Us_stateReached ; +1 if FALSE, +2 if TRUE + + inr r16, COM_CLK_INPUT ; +1 (if low port, +2 if high port) + and r16, r22 ; +1 + breq com2wWaitForClockLowMulti10Us_stateReached ; +1 if FALSE, +2 if TRUE + + nop ; +1 + + dec r20 ; +1 + brne com2wWaitForClockLowMulti10Us_loop ; +2 if TRUE, +1 if FALSE + clc ; +1 + ret ; +4 +com2wWaitForClockLowMulti10Us_stateReached: + sec ; +1 + ret ; +4 +; end version for 1000000 Hz +.endif + + + + + + + + + + + + + + + + .if clock > 1000000 ; begin version for > 1000000 Hz ldi r20, LOW(clock/1000000) diff --git a/avr/modules/com2w/defs.asm b/avr/modules/com2w/defs.asm index 5837e1d..7e644ea 100644 --- a/avr/modules/com2w/defs.asm +++ b/avr/modules/com2w/defs.asm @@ -11,7 +11,7 @@ #define AVR_MODULES_COM2W_DEFS_H -.equ COM2W_WAITTIME1 = 30000 +.equ COM2W_WAITTIME1 = 17000 .equ COM2W_WAITTIME2 = 10000 .equ COM2W_SKIPPING_MAXREADCOUNTER = 1 diff --git a/avr/modules/flash/io_com2w.asm b/avr/modules/flash/io_com2w.asm index 0343e7e..fe92966 100644 --- a/avr/modules/flash/io_com2w.asm +++ b/avr/modules/flash/io_com2w.asm @@ -13,7 +13,7 @@ -.equ COM2W_WAITTIME1 = 30000 +.equ COM2W_WAITTIME1 = 17000 .equ COM2W_WAITTIME2 = 10000 @@ -85,21 +85,17 @@ ioRawSendMsg_loop: ioRawWaitForValidMsg: ; wait for CLK low - ldi r19, 20 ; wait for up to 10s -ioRawWaitForValidMsg_waitLowLoop1: + ldi r17, 20 ; wait for up to 10s +ioRawWaitForValidMsg_waitLowLoop: .ifdef LED_PIN - sbi LED_PIN, LED_PINNUM ; toggle + sbi LED_PIN, LED_PINNUM ; toggle .endif - ldi r18, 5 -ioRawWaitForValidMsg_waitLowLoop2: - ldi r20, 10 ; wait for about 100us for clock low - rcall com2wWaitForClockLowMulti10Us ; R20, R22 - brcs ioRawWaitForValidMsg_recvMsg - dec r18 - brne ioRawWaitForValidMsg_waitLowLoop2 - dec r19 - brne ioRawWaitForValidMsg_waitLowLoop1 - clc ; no msg received + ldi r18, 5 ; wait up to 500ms + rcall com2wWaitForClockLowMulti100ms ; (r18, r19, r20, r22) + brcs ioRawWaitForValidMsg_recvMsg + dec r17 + brne ioRawWaitForValidMsg_waitLowLoop + clc ; no msg received rjmp ioRawWaitForValidMsg_end ioRawWaitForValidMsg_recvMsg: ; receive message @@ -112,13 +108,38 @@ ioRawWaitForValidMsg_recvMsg: ; validate CRC ldi xl, LOW(flashRecvBuffer) ldi xh, HIGH(flashRecvBuffer) - rcall NETMSG_CheckMessageInBuffer ; (R16, R17, R18, R19, R20, X) + rcall NETMSG_CheckMessageInBuffer ; (R16, R17, R18, R19, R20, X) ioRawWaitForValidMsg_end: ret ; @end +; --------------------------------------------------------------------------- +; @routine com2wWaitForClockLowMulti100ms +; +; wait for multiple of 100ms +; +; @param R18 number of 100ms to wait +; @return CFLAG set if okay (state reached), cleared on error +; @clobbers r18, r19, r20, r22 + +com2wWaitForClockLowMulti100ms: +com2wWaitForClockLowMulti100ms_loop1: + ldi r19, 100 +com2wWaitForClockLowMulti100ms_loop2: + ldi r20, 100 ; wait for 1ms for clock low + rcall com2wWaitForClockLowMulti10Us ; (R20, R22) + brcs com2wWaitForClockLowMulti100ms_ret + dec r19 + brne com2wWaitForClockLowMulti100ms_loop2 + dec r18 + brne com2wWaitForClockLowMulti100ms_loop1 + clc +com2wWaitForClockLowMulti100ms_ret: + ret +; @end + @@ -185,7 +206,7 @@ com2wSendByte: ldi r17, 8 com2wSendByte_loop: rcall com2wClkSetLow - rcall com2wWaitTime1 ; longer wait period (R22) + rcall com2wWaitTime2 ; shorter wait period (R22) lsr r16 brcs com2wSendByte_send1 rcall com2wDataSetLow @@ -193,9 +214,9 @@ com2wSendByte_loop: com2wSendByte_send1: rcall com2wDataSetHigh com2wSendByte_sent: - rcall com2wWaitTime2 ; shorter wait period (R22) + Utils_WaitNanoSecs 5000, 0, r22 ; wait for very short time to ensure data is stable when clock rises rcall com2wClkSetHigh - rcall com2wWaitTime1 ; longer wait period (R22) + rcall com2wWaitTime2 ; shorter wait period (R22) dec r17 brne com2wSendByte_loop ret @@ -267,10 +288,10 @@ com2wRecvByte: ldi r17, 8 clr r16 com2wRecvByte_loop: - ldi r20, 30 ; wait up to 300us for clock low + ldi r20, 70 ; wait up to 700us for clock low rcall com2wWaitForClockLowMulti10Us ; (R20, R22) brcc com2wRecvByte_end - ldi r20, 30 ; wait up to 300us for clock high + ldi r20, 70 ; wait up to 700us for clock high rcall com2wWaitForClockHighMulti10Us ; (R20, R22) brcc com2wRecvByte_end ; handle received bit @@ -357,30 +378,26 @@ com2wDataSetLow: ; ; @param R20 multiple of 10us to wait (e.g. "2" for "20" us) ; @return CFLAG set if okay (state reached), cleared on error -; @clobbers: r16, r20, r22 +; @clobbers: r20, r22 com2wWaitForClockLowMulti10Us: .if clock > 1000000 ; begin version for > 1000000 Hz - ldi r20, LOW(clock/1000000) - ldi r22, (1< 1000000 ; begin version for > 1000000 Hz - ldi r20, LOW(clock/1000000) - ldi r22, (1< Date: Tue, 19 Aug 2025 23:03:43 +0200 Subject: [PATCH 137/196] avr: use 16bit for brightness (actually, ADC only presents 10 bit). --- avr/modules/brightness/main.asm | 12 +++++------- avr/modules/brightness/send.asm | 2 -- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/avr/modules/brightness/main.asm b/avr/modules/brightness/main.asm index a3326b2..2ef0eab 100644 --- a/avr/modules/brightness/main.asm +++ b/avr/modules/brightness/main.asm @@ -22,7 +22,7 @@ brightnessDataBegin: brightnessTimer: .byte 1 brightnessFlags: .byte 1 - brightnessLastValue: .byte 1 + brightnessLastValue: .byte 2 brightnessDataEnd: @@ -98,11 +98,8 @@ Brightness_Every100ms_readValue: sts brightnessTimer, r16 in r16, ADCL in r17, ADCH ; read value from ADC - tst r17 - breq Brightness_Every100ms_storeValue - ldi r16, 0xff -Brightness_Every100ms_storeValue: sts brightnessLastValue, r16 + sts brightnessLastValue+1, r17 ; convert to 1/0 lds r17, brightnessFlags sbr r17, (1< Date: Tue, 19 Aug 2025 23:36:44 +0200 Subject: [PATCH 138/196] avr: increased waittimes for com2w (too fast for 1MHz nodes). --- avr/modules/com2w/defs.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/avr/modules/com2w/defs.asm b/avr/modules/com2w/defs.asm index 7e644ea..85e348e 100644 --- a/avr/modules/com2w/defs.asm +++ b/avr/modules/com2w/defs.asm @@ -11,8 +11,8 @@ #define AVR_MODULES_COM2W_DEFS_H -.equ COM2W_WAITTIME1 = 17000 -.equ COM2W_WAITTIME2 = 10000 +.equ COM2W_WAITTIME1 = 30000 +.equ COM2W_WAITTIME2 = 15000 .equ COM2W_SKIPPING_MAXREADCOUNTER = 1 .equ COM2W_SKIPPING_MAXMODECOUNTER = 20 ; stay max 2s in skipping mode From 6c3926c1e4b012b4d47d5af856f391871e4c7e20 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Tue, 19 Aug 2025 23:36:58 +0200 Subject: [PATCH 139/196] avr: added a note regarding timing. --- avr/modules/com2w/com2w.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avr/modules/com2w/com2w.asm b/avr/modules/com2w/com2w.asm index 56988d3..6b21a92 100644 --- a/avr/modules/com2w/com2w.asm +++ b/avr/modules/com2w/com2w.asm @@ -324,7 +324,7 @@ com2wSendByte_send1: rcall com2wDataSetHigh com2wSendByte_sent: Utils_WaitNanoSecs 5000, 0, r22 ; wait for very short time to ensure data is stable when clock rises - push r15 + push r15 ; TODO: check this (doesn't really ensure short HIGH time!) in r15, SREG cli ; ensure time period by disabling irqs rcall com2wClkSetHigh From 6a3f6be8a955c2a7d845386c43a233f995fee710 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Wed, 20 Aug 2025 20:48:55 +0200 Subject: [PATCH 140/196] avr: improved timing for sending bytes via com2w interface. Still quite different among devices but that's just prove that the protocol works without prior synchronisation. --- avr/modules/com2w/com2w.asm | 72 +++++++++++++++++++++++++++---------- avr/modules/com2w/defs.asm | 2 +- 2 files changed, 55 insertions(+), 19 deletions(-) diff --git a/avr/modules/com2w/com2w.asm b/avr/modules/com2w/com2w.asm index 6b21a92..91f0482 100644 --- a/avr/modules/com2w/com2w.asm +++ b/avr/modules/com2w/com2w.asm @@ -11,6 +11,41 @@ #define AVR_MODULES_COM2W_COM2W_H + +.macro M_COM2WCLKSETLOW + sbi COM_CLK_DDR, COM_CLK_PIN ; set CLK as output + cbi COM_CLK_OUTPUT, COM_CLK_PIN ; set CLK low +.endmacro + + + +.macro M_COM2WCLKSETHIGH + cbi COM_CLK_DDR, COM_CLK_PIN ; set CLK as input +.ifndef COM_CLK_PUE + cbi COM_CLK_OUTPUT, COM_CLK_PIN ; disable pullup on CLK +.endif +.endmacro + + + +.macro M_COM2WDATASETLOW + sbi COM_DATA_DDR, COM_DATA_PIN ; set DATA as output + cbi COM_DATA_OUTPUT, COM_DATA_PIN ; set DATA low +.endmacro + + + +.macro M_COM2WDATASETHIGH + cbi COM_DATA_DDR, COM_DATA_PIN ; set DATA as input +.ifndef COM_DATA_PUE + cbi COM_DATA_OUTPUT, COM_DATA_PIN ; disable pullup on DATA +.endif +.endmacro + + + + + .dseg com2w_iface: .byte COM2W_IFACE_SIZE @@ -312,27 +347,28 @@ com2wSendBytes_loop: ; @clobbers: r16, r17 (r22) com2wSendByte: - ldi r17, 8 + push r15 + in r15, SREG + ldi r17, 8 com2wSendByte_loop: - rcall com2wClkSetLow - rcall com2wWaitTime2 ; shorter wait period (R22) - lsr r16 - brcs com2wSendByte_send1 - rcall com2wDataSetLow - rjmp com2wSendByte_sent + M_COM2WCLKSETLOW + out SREG, r15 ; probably enable irqs + rcall com2wWaitTime1 ; wait for longer time (R22) + lsr r16 + brcs com2wSendByte_send1 + M_COM2WDATASETLOW + rjmp com2wSendByte_sent com2wSendByte_send1: - rcall com2wDataSetHigh + M_COM2WDATASETHIGH com2wSendByte_sent: - Utils_WaitNanoSecs 5000, 0, r22 ; wait for very short time to ensure data is stable when clock rises - push r15 ; TODO: check this (doesn't really ensure short HIGH time!) - in r15, SREG - cli ; ensure time period by disabling irqs - rcall com2wClkSetHigh - rcall com2wWaitTime2 ; shorter wait period (R22) - out SREG, r15 - pop r15 - dec r17 - brne com2wSendByte_loop + Utils_WaitNanoSecs 5000, 0, r22 ; wait for very short time to ensure data is stable when clock rises + cli ; ensure time period by disabling irqs + M_COM2WCLKSETHIGH + rcall com2wWaitTime2 ; wait for shorter time (R22) + dec r17 + brne com2wSendByte_loop + out SREG, r15 + pop r15 ret ; @end diff --git a/avr/modules/com2w/defs.asm b/avr/modules/com2w/defs.asm index 85e348e..0021199 100644 --- a/avr/modules/com2w/defs.asm +++ b/avr/modules/com2w/defs.asm @@ -11,7 +11,7 @@ #define AVR_MODULES_COM2W_DEFS_H -.equ COM2W_WAITTIME1 = 30000 +.equ COM2W_WAITTIME1 = 25000 .equ COM2W_WAITTIME2 = 15000 .equ COM2W_SKIPPING_MAXREADCOUNTER = 1 From 3a7951be16c0b37de7085d9fbcd138fcd6013a7a Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Wed, 20 Aug 2025 23:27:17 +0200 Subject: [PATCH 141/196] com2w: added some recovery code, improved protocol. after sending a byte wait for the same time when sending the last bit as with the other bits (otherwise the last bit might get lost by slower devices). --- avr/modules/com2w/com2w.asm | 45 ++++++++++++++++++++++++++++------ avr/modules/flash/io_com2w.asm | 13 +++++----- 2 files changed, 44 insertions(+), 14 deletions(-) diff --git a/avr/modules/com2w/com2w.asm b/avr/modules/com2w/com2w.asm index 91f0482..56530ad 100644 --- a/avr/modules/com2w/com2w.asm +++ b/avr/modules/com2w/com2w.asm @@ -352,8 +352,8 @@ com2wSendByte: ldi r17, 8 com2wSendByte_loop: M_COM2WCLKSETLOW - out SREG, r15 ; probably enable irqs - rcall com2wWaitTime1 ; wait for longer time (R22) + out SREG, r15 ; probably enable irqs + rcall com2wWaitTime1 ; wait for longer time (R22) lsr r16 brcs com2wSendByte_send1 M_COM2WDATASETLOW @@ -361,14 +361,16 @@ com2wSendByte_loop: com2wSendByte_send1: M_COM2WDATASETHIGH com2wSendByte_sent: - Utils_WaitNanoSecs 5000, 0, r22 ; wait for very short time to ensure data is stable when clock rises - cli ; ensure time period by disabling irqs + Utils_WaitNanoSecs 5000, 0, r22 ; wait for very short time to ensure data is stable when clock rises + cli ; ensure time period by disabling irqs M_COM2WCLKSETHIGH - rcall com2wWaitTime2 ; wait for shorter time (R22) + rcall com2wWaitTime2 ; wait for shorter time (R22) dec r17 brne com2wSendByte_loop out SREG, r15 pop r15 + rcall com2wWaitTime2 ; wait for shorter time (R22) + M_COM2WDATASETHIGH ; ensure data line is high ret ; @end @@ -435,6 +437,7 @@ com2wRecvMsg_eIo: ldi r16, NET_IFACE_OFFS_ERR_IO_LOW com2wRecvMsg_incCounterRet: rcall NET_Interface_IncCounter16 ; (R24, R25) + rcall com2wRecvByteWaitForQuietClk ; (r18, r20, r22) com2wRecvMsg_clcRet: clc com2wRecvMsg_end: @@ -443,6 +446,32 @@ com2wRecvMsg_end: +; --------------------------------------------------------------------------- +; @routine com2wRecvByteWaitForQuietClk +; +; Wait until the clock line is consistently high for 1ms. +; +; @clobbers r18, r20, r22 + +com2wRecvByteWaitForQuietClk: + ldi r18, 200 +com2wRecvByteWaitForQuietClk_loop: + ldi r20, 100 ; wait up to 1ms for clock high (R20, R22) + rcall com2wWaitForClockLowMulti10Us + brcs com2wRecvByteWaitForQuietClk_waitForLow + dec r18 + brne com2wRecvByteWaitForQuietClk_loop + rjmp com2wRecvByteWaitForQuietClk_ret +com2wRecvByteWaitForQuietClk_waitForLow: + ldi r20, 100 ; wait up to 1ms for clock low (R20, R22) + rcall com2wWaitForClockLowMulti10Us + brcc com2wRecvByteWaitForQuietClk_ret ; not low within 1ms, assume line is quiet + brne com2wRecvByteWaitForQuietClk_loop +com2wRecvByteWaitForQuietClk_ret: + ret + + + ; --------------------------------------------------------------------------- ; @routine com2wRecvByte ; @@ -455,10 +484,10 @@ com2wRecvByte: clr r16 com2wRecvByte_loop: ldi r20, 50 ; wait up to 500us for clock low - rcall com2wWaitForClockLowMulti10Us ; (R16, R20, R22) + rcall com2wWaitForClockLowMulti10Us ; (R20, R22) brcc com2wRecvByte_end - ldi r20, 50 ; wait up to 500us for clock high - rcall com2wWaitForClockHighMulti10Us ; (R16, R20, R22) + ldi r20, 100 ; wait up to 1ms for clock high + rcall com2wWaitForClockHighMulti10Us ; (R20, R22) brcc com2wRecvByte_end ; handle received bit inr r18, COM_DATA_INPUT diff --git a/avr/modules/flash/io_com2w.asm b/avr/modules/flash/io_com2w.asm index fe92966..08c835f 100644 --- a/avr/modules/flash/io_com2w.asm +++ b/avr/modules/flash/io_com2w.asm @@ -12,9 +12,8 @@ - -.equ COM2W_WAITTIME1 = 17000 -.equ COM2W_WAITTIME2 = 10000 +.equ COM2W_WAITTIME1 = 25000 +.equ COM2W_WAITTIME2 = 15000 @@ -206,7 +205,7 @@ com2wSendByte: ldi r17, 8 com2wSendByte_loop: rcall com2wClkSetLow - rcall com2wWaitTime2 ; shorter wait period (R22) + rcall com2wWaitTime2 ; shorter wait period (R22) lsr r16 brcs com2wSendByte_send1 rcall com2wDataSetLow @@ -214,11 +213,13 @@ com2wSendByte_loop: com2wSendByte_send1: rcall com2wDataSetHigh com2wSendByte_sent: - Utils_WaitNanoSecs 5000, 0, r22 ; wait for very short time to ensure data is stable when clock rises + Utils_WaitNanoSecs 5000, 0, r22 ; wait for very short time to ensure data is stable when clock rises rcall com2wClkSetHigh - rcall com2wWaitTime2 ; shorter wait period (R22) + rcall com2wWaitTime2 ; shorter wait period (R22) dec r17 brne com2wSendByte_loop + rcall com2wWaitTime2 ; shorter wait period (R22) + rcall com2wDataSetHigh ret ; @end From 08d420a8719f9f964c374e082bbc6f28e4a58440 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 23 Aug 2025 00:08:25 +0200 Subject: [PATCH 142/196] avr: added module uart_fd This module uses hardware UART of MCUs in full duplex mode. --- avr/devices/all/includes.asm | 17 + avr/devices/all/main.asm | 8 + avr/devices/all/modules.asm | 23 ++ avr/devices/t03/uartfd/main.asm | 259 ++++++++++++ avr/modules/0BUILD | 1 + avr/modules/uart_fd/0BUILD | 13 + avr/modules/uart_fd/defs.asm | 47 +++ avr/modules/uart_fd/macros.asm | 204 ++++++++++ avr/modules/uart_fd/uartfd0.asm | 687 +++++++++++++++++++++++++++++++ avr/modules/uart_fd/uartfd1.asm | 696 ++++++++++++++++++++++++++++++++ 10 files changed, 1955 insertions(+) create mode 100644 avr/devices/t03/uartfd/main.asm create mode 100644 avr/modules/uart_fd/0BUILD create mode 100644 avr/modules/uart_fd/defs.asm create mode 100644 avr/modules/uart_fd/macros.asm create mode 100644 avr/modules/uart_fd/uartfd0.asm create mode 100644 avr/modules/uart_fd/uartfd1.asm diff --git a/avr/devices/all/includes.asm b/avr/devices/all/includes.asm index e166c09..7755185 100644 --- a/avr/devices/all/includes.asm +++ b/avr/devices/all/includes.asm @@ -133,6 +133,23 @@ #endif + +#ifdef MODULES_UARTFD0 +.include "modules/uart_fd/defs.asm" +.include "modules/uart_fd/macros.asm" +.include "modules/uart_fd/uartfd0.asm" +#endif + + + +#ifdef MODULES_UARTFD1 +.include "modules/uart_fd/defs.asm" +.include "modules/uart_fd/macros.asm" +.include "modules/uart_fd/uartfd1.asm" +#endif + + + #ifdef MODULES_CLOCK .include "modules/clock/main.asm" #endif diff --git a/avr/devices/all/main.asm b/avr/devices/all/main.asm index 1615d36..5aaf331 100644 --- a/avr/devices/all/main.asm +++ b/avr/devices/all/main.asm @@ -127,6 +127,14 @@ onSystemTimerTick: bigcall TtyOnUart1_Periodically #endif +#ifdef MODULES_UARTFD0 + bigcall UARTFD0_Every100ms +#endif + +#ifdef MODULES_UARTFD1 + bigcall UARTFD1_Every100ms +#endif + #ifdef MODULES_COMONUART0 bigcall ComOnUart0_Periodically #endif diff --git a/avr/devices/all/modules.asm b/avr/devices/all/modules.asm index 36862fe..d9be262 100644 --- a/avr/devices/all/modules.asm +++ b/avr/devices/all/modules.asm @@ -73,6 +73,14 @@ initModules: bigcall TtyOnUart1_Init #endif +#ifdef MODULES_UARTFD0 + bigcall UARTFD0_Init +#endif + +#ifdef MODULES_UARTFD1 + bigcall UARTFD1_Init +#endif + #ifdef MODULES_COMONUART0 bigcall ComOnUart0_Init #endif @@ -202,6 +210,21 @@ runModules: pop r16 #endif + +#ifdef MODULES_UARTFD0 + push r16 + bigcall UARTFD0_Run + pop r16 + sbci r16, 0 +#endif + +#ifdef MODULES_UARTFD1 + push r16 + bigcall UARTFD1_Run + pop r16 + sbci r16, 0 +#endif + #ifdef MODULES_COMONUART0 push r16 bigcall ComOnUart0_Run diff --git a/avr/devices/t03/uartfd/main.asm b/avr/devices/t03/uartfd/main.asm new file mode 100644 index 0000000..ca3dbaf --- /dev/null +++ b/avr/devices/t03/uartfd/main.asm @@ -0,0 +1,259 @@ +; *************************************************************************** +; 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/tn841def.inc" ; Define device ATtiny841 +.list + +.include "../defs.asm" +.include "version.asm" +;.include "defs_all.asm" + +.include "devices/all/defs.asm" + +.include "common/calls.asm" +.include "common/utils_wait.asm" +.include "common/utils_io.asm" + + + +; *************************************************************************** +; defines + +; --------------------------------------------------------------------------- +; generic + +.equ COMONUART0_IFACENUM = 1 +.equ TTYONUART1_IFACENUM = 2 + + +; --------------------------------------------------------------------------- +; firmware settings including list of modules used + + +#define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes +#define APP_STATS_NETDEV2 +#define APP_ROUTER_NO_ADDR_MGR + +#define MODULES_CLOCK +;#define MODULES_COM +;#define MODULES_COM_WITH_ADDR_PROTO +;#define MODULES_LED +#define MODULES_LED_SIMPLE +;#define MODULES_TWI_MASTER +;#define MODULES_LCD +;#define LCD_MINIMAL_FONT +;#define MODULES_SI7021 +;#define MODULES_STATS +;#define MODULES_CNY70 +;#define MODULES_REED +;#define MODULES_OWI_MASTER +;#define MODULES_DS18B20 +;#define MODULES_MOTION +#define MODULES_NETWORK +#define MODULES_COM2W +;#define MODULES_COMONUART0 +;#define MODULES_TTYONUART1 +#define MODULES_UARTFD1 +#define APPS_STATS +;#define APPS_NETWORK +#define APPS_ROUTER + + + +.equ NET_BUFFERS_NUM = 10 +.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) + +.equ UART_HW_MSGNUMINBUF_SIZE = 8 +.equ UART_HW_MSGNUMOUTBUF_SIZE = 8 + + + +; --------------------------------------------------------------------------- +; defines for values + +.equ VALUE_ID_DS18B20_TEMP = 0x06 + +.equ VALUE_ID_LEDSIMPLE_TIMING = 0x88 +.equ VALUE_ID_ROUTER_SETRANGE = 0x89 + + + +.equ COM_DATA0_DDR = COM_DATA_DDR +.equ COM_DATA0_INPUT = COM_DATA_INPUT +.equ COM_DATA0_OUTPUT = COM_DATA_OUTPUT +.equ COM_DATA0_PUE = COM_DATA_PUE +.equ COM_DATA0_PIN = COM_DATA_PIN + +.equ COM_CLK0_DDR = COM_CLK_DDR +.equ COM_CLK0_INPUT = COM_CLK_INPUT +.equ COM_CLK0_OUTPUT = COM_CLK_OUTPUT +.equ COM_CLK0_PUE = COM_CLK_PUE +.equ COM_CLK0_PIN = COM_CLK_PIN + +.equ COM_IRQ_ADDR_CLK0 = COM_IRQ_ADDR_CLK +.equ COM_IRQ_BIT_CLK0 = COM_IRQ_BIT_CLK +.equ COM_IRQ_GIFR_CLK0 = COM_IRQ_GIFR_CLK +.equ COM_IRQ_GIMSK_CLK0 = COM_IRQ_GIMSK_CLK + + +; *************************************************************************** +; code segment + +.cseg +.org 000000 + + + +; --------------------------------------------------------------------------- +; Reset and interrupt vectors + + rjmp BOOTLOADER_ADDR ; 1: RESET Reset vector use this for flashed system + reti ; 2: INT0 External Interrupt Request 0 + rjmp com2wPcintIsr ; 3: PCINT0 Pin Change Interrupt 0 + reti ; 4: PCINT1 Pin Change Interrupt 1 + reti ; 5: WDT Watchdog Time-out + reti ; 6: TIM1_CAPT Timer/Counter1 Capture Event + reti ; 7: TIM1_COMPA (OC1A) Timer/Counter1 Compare Match A + reti ; 8: TIM1_COMPB (OC1B) Timer/Counter1 Compare Match B + reti ; 9: TIM1_OVF (OVF1) Timer/Counter1 Overflow + rjmp baseTimerIrqOC0A ; 10: TIM0_COMPA (OC0A) Timer/Counter0 Compare Match A + reti ; 11: TIM0_COMPB (OC0B) Timer/Counter0 Compare Match B + reti ; 12: TIM0_OVF (OVF0) Timer/Counter0 Overflow + reti ; 13: ANA_COMP0 Analog Comparator 0 + reti ; 14: ADC_READY ADC Conversion Complete + reti ; 15: EE_RDY (ERDY) EEPROM Ready + reti ; 16: ANA_COMP1 Analog Comparator 1 + reti ; 17: TIM2_CAPT Timer/Counter2 Capture Event + reti ; 18: TIM2_COMPA (OC2A) Timer/Counter2 Compare Match A + reti ; 19: TIM2_COMPB (OC2B) Timer/Counter2 Compare Match B + reti ; 20: TIM2_OVF (OVF2) Timer/Counter2 Overflow + reti ; 21: SPI SPI Serial Transfer Complete + reti ; 22: USART0_RXS USART0 Rx Start +; rjmp ComOnUart0_RxCharIsr ; 23: USART0_RXC USART0 Rx Complete + reti ; 23: USART0_RXC USART0 Rx Complete + reti ; 24: USART0_DRE USART0 Data Register Empty + reti ; 25: USART0_TXC USART0 Tx Complete + reti ; 26: USART1_RXS USART1 Rx Start + rjmp UARTFD1_RxCharIsr ; 27: USART1_RXC USART1 Rx Complete + rjmp UARTFD1_TxUdreIsr ; 28: USART1_DRE USART1 Data Register Empty + rjmp UARTFD1_TxCharIsr ; 29: USART1_TXC USART1 Tx Complete + reti ; 30: TWI Two-Wire-Interface + reti ; 31: RESERVED reserved + + + +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: + ldi r16, 0xf0 + sts netInterfaceData+NET_IFACE_OFFS_ADDRESS, r16 + sts netInterfaceData2+NET_IFACE_OFFS_ADDRESS, r16 + ret +; @end + + + +onEvery100ms: +onEverySecond: +onEveryMinute: +onEveryHour: +onEveryDay: + ret + + + +; --------------------------------------------------------------------------- +; @routine onEveryLoop +; +; Called on every loop (i.e. after awakening from sleep). + +onEveryLoop: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine onMessageReceived +; +; Called on every message received + +onMessageReceived: + clc + ret +; @end + + + + + + +; *************************************************************************** +; includes + +.include "devices/all/hw_tn841.asm" +.include "devices/all/includes.asm" +.include "common/debug.asm" + + + + +; --------------------------------------------------------------------------- +; defines for network interface + +.equ netInterfaceData = uartFd1_iface +.equ netInterfaceData2 = com2w_iface + + +; debug +push r18 + push r19 + rcall LedSimple_SetFastTiming + pop r19 +pop r18 + diff --git a/avr/modules/0BUILD b/avr/modules/0BUILD index 6b7dfdf..781cd54 100644 --- a/avr/modules/0BUILD +++ b/avr/modules/0BUILD @@ -31,6 +31,7 @@ uart_bitbang uart_bitbang2 uart_irq + uart_fd uart_hw bootloader f_keepup diff --git a/avr/modules/uart_fd/0BUILD b/avr/modules/uart_fd/0BUILD new file mode 100644 index 0000000..49f7dd3 --- /dev/null +++ b/avr/modules/uart_fd/0BUILD @@ -0,0 +1,13 @@ + + + + + + defs.asm + macros.asm + uartfd0.asm + + + + + diff --git a/avr/modules/uart_fd/defs.asm b/avr/modules/uart_fd/defs.asm new file mode 100644 index 0000000..a095773 --- /dev/null +++ b/avr/modules/uart_fd/defs.asm @@ -0,0 +1,47 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + +#ifndef AVR_MODULES_UARTFD_DEFS_ASM +#define AVR_MODULES_UARTFD_DEFS_ASM + + +.equ UARTFD_SKIPPING_TIME = 2 +.equ UARTFD_READ_TIMEOUT = 2 +.equ UARTFD_WRITE_TIMEOUT = 2 + + +.equ UARTFD_IFACE_STATUS_BIT_OVERRUN = 0 +.equ UARTFD_IFACE_STATUS_BIT_HWERR = 1 +.equ UARTFD_IFACE_STATUS_BIT_BADMSGSIZE = 2 +.equ UARTFD_IFACE_STATUS_BIT_SKIPPING = 3 + + + +.equ UARTFD_IFACE_SIZE_BUFFER = NET_BUFFERS_SIZE-1 + +.equ UARTFD_IFACE_OFFS_BEGIN = NET_IFACE_SIZE +.equ UARTFD_IFACE_OFFS_STATUS = UARTFD_IFACE_OFFS_BEGIN +.equ UARTFD_IFACE_OFFS_WPOS_LOW = UARTFD_IFACE_OFFS_BEGIN+1 +.equ UARTFD_IFACE_OFFS_WPOS_HIGH = UARTFD_IFACE_OFFS_BEGIN+2 +.equ UARTFD_IFACE_OFFS_WBUFLEFT = UARTFD_IFACE_OFFS_BEGIN+3 +.equ UARTFD_IFACE_OFFS_WBUFNUM = UARTFD_IFACE_OFFS_BEGIN+4 +.equ UARTFD_IFACE_OFFS_RPOS_LOW = UARTFD_IFACE_OFFS_BEGIN+5 +.equ UARTFD_IFACE_OFFS_RPOS_HIGH = UARTFD_IFACE_OFFS_BEGIN+6 +.equ UARTFD_IFACE_OFFS_RBUFUSED = UARTFD_IFACE_OFFS_BEGIN+7 +.equ UARTFD_IFACE_OFFS_RBUFLEFT = UARTFD_IFACE_OFFS_BEGIN+8 +.equ UARTFD_IFACE_OFFS_RBUFFER = UARTFD_IFACE_OFFS_BEGIN+9 +.equ UARTFD_IFACE_SIZE = UARTFD_IFACE_OFFS_RBUFFER+UARTFD_IFACE_SIZE_BUFFER + + + + +#endif + + + diff --git a/avr/modules/uart_fd/macros.asm b/avr/modules/uart_fd/macros.asm new file mode 100644 index 0000000..3e5b72e --- /dev/null +++ b/avr/modules/uart_fd/macros.asm @@ -0,0 +1,204 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + +#ifndef AVR_MODULES_UARTFD_MACROS_ASM +#define AVR_MODULES_UARTFD_MACROS_ASM + + +.macro M_UARTFD_SET_CHARFORMAT + ldi r16, (1< Date: Sat, 23 Aug 2025 00:09:01 +0200 Subject: [PATCH 143/196] avr network app: only respond to ping request if dest address matches. --- avr/apps/network/main.asm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/avr/apps/network/main.asm b/avr/apps/network/main.asm index 09ef659..e4fc8cc 100644 --- a/avr/apps/network/main.asm +++ b/avr/apps/network/main.asm @@ -189,6 +189,15 @@ appNetworkHandleRebootRequest_end: appNetworkHandlePingRequest: + ld r17, X + lds r16, (netInterfaceData+NET_IFACE_OFFS_ADDRESS) + cp r16, r17 + breq appNetworkHandlePingRequest_forMe + cpi r17, 0xff + breq appNetworkHandlePingRequest_forMe + clc + rjmp appNetworkHandlePingRequest_end +appNetworkHandlePingRequest_forMe: adiw xh:xl, NETMSG_OFFS_SRCADDR ld r17, X push r17 From 87788fa93cfb30a0a30b91bc8004eae772b4a2a7 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 23 Aug 2025 00:09:39 +0200 Subject: [PATCH 144/196] avr: wait for free CLK line on error when in flash mode --- avr/modules/flash/io_com2w.asm | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/avr/modules/flash/io_com2w.asm b/avr/modules/flash/io_com2w.asm index 08c835f..cfc9fe1 100644 --- a/avr/modules/flash/io_com2w.asm +++ b/avr/modules/flash/io_com2w.asm @@ -270,7 +270,7 @@ com2wRecvMsg_loop: rjmp com2wRecvMsg_end com2wRecvMsg_eBadSize: com2wRecvMsg_eIo: -com2wRecvMsg_clcRet: + rcall com2wRecvByteWaitForQuietClk ; (r18, r20, r22) clc com2wRecvMsg_end: ret @@ -278,6 +278,32 @@ com2wRecvMsg_end: +; --------------------------------------------------------------------------- +; @routine com2wRecvByteWaitForQuietClk +; +; Wait until the clock line is consistently high for 1ms. +; +; @clobbers r18, r20, r22 + +com2wRecvByteWaitForQuietClk: + ldi r18, 200 +com2wRecvByteWaitForQuietClk_loop: + ldi r20, 100 ; wait up to 1ms for clock high (R20, R22) + rcall com2wWaitForClockLowMulti10Us + brcs com2wRecvByteWaitForQuietClk_waitForLow + dec r18 + brne com2wRecvByteWaitForQuietClk_loop + rjmp com2wRecvByteWaitForQuietClk_ret +com2wRecvByteWaitForQuietClk_waitForLow: + ldi r20, 100 ; wait up to 1ms for clock low (R20, R22) + rcall com2wWaitForClockLowMulti10Us + brcc com2wRecvByteWaitForQuietClk_ret ; not low within 1ms, assume line is quiet + brne com2wRecvByteWaitForQuietClk_loop +com2wRecvByteWaitForQuietClk_ret: + ret + + + ; --------------------------------------------------------------------------- ; @routine com2wRecvByte ; From bae188ddeef765c825d213dece5405074678ca6c Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 23 Aug 2025 00:10:01 +0200 Subject: [PATCH 145/196] t03: added firmware using new uart_fd module. --- avr/devices/t03/0BUILD | 1 + avr/devices/t03/uartfd/0BUILD | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 avr/devices/t03/uartfd/0BUILD diff --git a/avr/devices/t03/0BUILD b/avr/devices/t03/0BUILD index b004c20..c1b8f79 100644 --- a/avr/devices/t03/0BUILD +++ b/avr/devices/t03/0BUILD @@ -6,6 +6,7 @@ boot main test + uartfd diff --git a/avr/devices/t03/uartfd/0BUILD b/avr/devices/t03/uartfd/0BUILD new file mode 100644 index 0000000..7e9dd5c --- /dev/null +++ b/avr/devices/t03/uartfd/0BUILD @@ -0,0 +1,33 @@ + + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + main.asm + + + + + + + + + + + + + + + + + From 66ac029a691eec544726e717a39f792c6d271bf1 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 25 Aug 2025 10:19:23 +0200 Subject: [PATCH 146/196] avr: introduce two more led modules. - led_signal: blink 8 status bits (short=0, long=1) - led_activity: blink for a short period after a trigger, e.g. for network activity --- avr/modules/0BUILD | 2 + avr/modules/led_activity/0BUILD | 11 +++ avr/modules/led_activity/main.asm | 90 +++++++++++++++++ avr/modules/led_signal/0BUILD | 11 +++ avr/modules/led_signal/main.asm | 156 ++++++++++++++++++++++++++++++ 5 files changed, 270 insertions(+) create mode 100644 avr/modules/led_activity/0BUILD create mode 100644 avr/modules/led_activity/main.asm create mode 100644 avr/modules/led_signal/0BUILD create mode 100644 avr/modules/led_signal/main.asm diff --git a/avr/modules/0BUILD b/avr/modules/0BUILD index 781cd54..7c9081f 100644 --- a/avr/modules/0BUILD +++ b/avr/modules/0BUILD @@ -14,7 +14,9 @@ flash lcd led + led_activity led_simple + led_signal ma_light motion owimaster diff --git a/avr/modules/led_activity/0BUILD b/avr/modules/led_activity/0BUILD new file mode 100644 index 0000000..febd367 --- /dev/null +++ b/avr/modules/led_activity/0BUILD @@ -0,0 +1,11 @@ + + + + + + main.asm + + + + + diff --git a/avr/modules/led_activity/main.asm b/avr/modules/led_activity/main.asm new file mode 100644 index 0000000..091e079 --- /dev/null +++ b/avr/modules/led_activity/main.asm @@ -0,0 +1,90 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + +.equ LED_ACTIVITY_TIME = 2 + + + +; *************************************************************************** +; data + +.dseg + +ledActivityTimer: .byte 1 + + +; *************************************************************************** +; code + +.cseg + + +LED_ACTIVITY_BEGIN: + + + +; --------------------------------------------------------------------------- +; LedActivity_Init +; +; @return CFLAG: set if okay, clear on error +; USED: R1, R2, R3, R4, R16, R17, X + +LedActivity_Init: + sbi LED_ACTIVITY_DDR, LED_ACTIVITY_PINNUM ; out + ldi r16, 50 + sts ledActivityTimer, r16 ; keep on for 5s at the beginning + sec + ret + + + +; --------------------------------------------------------------------------- +; @routine LedActivity_Every100ms @global +; +; @clobbers r16, r17 + +LedActivity_Every100ms: + lds r16, ledActivityTimer + tst r16 + breq LedActivity_Every100ms_ret + dec r16 + sts ledActivityTimer, r16 + brne LedActivity_Every100ms_ret + sbi LED_ACTIVITY_PORT, LED_ACTIVITY_PINNUM ; turn LED off +LedActivity_Every100ms_ret: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine LedActivity_Restart @global +; +; @clobbers r16 + +LedActivity_Trigger: + lds r16, ledActivityTimer + tst r16 + brne LedActivity_Trigger_ledIsOn + cbi LED_ACTIVITY_PORT, LED_ACTIVITY_PINNUM ; turn LED on +LedActivity_Trigger_ledIsOn: + ldi r16, LED_ACTIVITY_TIME + sts ledActivityTimer, r16 + ret +; @end + + + + +LED_ACTIVITY_END: +.equ MODULE_SIZE_LED_ACTIVITY = LED_ACTIVITY_END-LED_ACTIVITY_BEGIN + + + diff --git a/avr/modules/led_signal/0BUILD b/avr/modules/led_signal/0BUILD new file mode 100644 index 0000000..febd367 --- /dev/null +++ b/avr/modules/led_signal/0BUILD @@ -0,0 +1,11 @@ + + + + + + main.asm + + + + + diff --git a/avr/modules/led_signal/main.asm b/avr/modules/led_signal/main.asm new file mode 100644 index 0000000..8475d01 --- /dev/null +++ b/avr/modules/led_signal/main.asm @@ -0,0 +1,156 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + + +; *************************************************************************** +; data + +.dseg + +ledSignalTimer: .byte 1 +ledSignalFlags: .byte 1 +ledSignalRunFlags: .byte 1 +ledSignalBitCounter: .byte 1 + + +; *************************************************************************** +; code + +.cseg + + +LED_SIGNAL_BEGIN: + + + +; --------------------------------------------------------------------------- +; LedSignal_Init +; +; @return CFLAG: set if okay, clear on error +; USED: R1, R2, R3, R4, R16, R17, X + +LedSignal_Init: + sbi LED_SIGNAL_DDR, LED_SIGNAL_PINNUM ; out + clr r16 + sts ledSignalFlags, r16 + ldi r16, 100 + sts ledSignalTimer, r16 + sec + ret + + + +; --------------------------------------------------------------------------- +; @routine LedSignal_Every100ms @global +; +; @clobbers r16, r17 + +LedSignal_Every100ms: + lds r16, ledSignalTimer + dec r16 + breq LedSignal_Every100ms_timer0 + sts ledSignalTimer, r16 + cpi r16, 80 + brcs LedSignal_Every100ms_checkBit + brne LedSignal_Every100ms_ret + rcall LedSignal_Restart ; (r16, r17) + rjmp LedSignal_Every100ms_ret +LedSignal_Every100ms_checkBit: + lds r17, ledSignalRunFlags + andi r17, 1 + brne LedSignal_Every100ms_bit1 +LedSignal_Every100ms_bit0: + cpi r16, 8 + breq LedSignal_Every100ms_ledOff + rjmp LedSignal_Every100ms_ret +LedSignal_Every100ms_bit1: + cpi r16, 3 + breq LedSignal_Every100ms_ledOff + rjmp LedSignal_Every100ms_ret +LedSignal_Every100ms_ledOff: + sbi LED_SIGNAL_PORT, LED_SIGNAL_PINNUM ; off + rjmp LedSignal_Every100ms_ret +LedSignal_Every100ms_timer0: + lds r17, ledSignalBitCounter + dec r17 + brne LedSignal_Every100ms_nextBit + ldi r17, 100 + sts ledSignalTimer, r17 + rjmp LedSignal_Every100ms_ret +LedSignal_Every100ms_nextBit: + sts ledSignalBitCounter, r17 + lds r16, ledSignalRunFlags + lsr r16 + sts ledSignalRunFlags, r16 + ldi r16, 10 + sts ledSignalTimer, r16 + cbi LED_SIGNAL_PORT, LED_SIGNAL_PINNUM ; on +LedSignal_Every100ms_ret: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine LedSignal_Restart @global +; +; @clobbers r16, r17 + +LedSignal_Restart: + ldi r16, 8 + sts ledSignalBitCounter, r16 + ldi r16, 10 + sts ledSignalTimer, r16 + lds r16, ledSignalFlags + sts ledSignalRunFlags, r16 + cbi LED_SIGNAL_PORT, LED_SIGNAL_PINNUM ; on + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine LedSignal_SetFlag @global +; +; @param r16 flag mask +; @clobbers r17 + +LedSignal_SetFlag: + lds r17, ledSignalFlags + or r17, r16 + sts ledSignalFlags, r17 + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine LedSignal_ClrFlag @global +; +; @param r16 flag mask +; @clobbers r17 + +LedSignal_ClrFlag: + lds r17, ledSignalFlags + com r16 + and r17, r16 + com r16 + sts ledSignalFlags, r17 + ret +; @end + + + + +LED_SIGNAL_END: +.equ MODULE_SIZE_LED_SIGNAL = LED_SIGNAL_END-LED_SIGNAL_BEGIN + + + From 7efaf720cce1f509dbf5ecf02fc9cd63b03481f0 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 25 Aug 2025 10:20:13 +0200 Subject: [PATCH 147/196] com2w: work in COM2W_Run, not in COM2W_Every100ms --- avr/modules/com2w/com2w.asm | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/avr/modules/com2w/com2w.asm b/avr/modules/com2w/com2w.asm index 56530ad..a71e181 100644 --- a/avr/modules/com2w/com2w.asm +++ b/avr/modules/com2w/com2w.asm @@ -116,7 +116,6 @@ COM2W_Every100ms: in r15, SREG cli rcall NET_Interface_Periodically ; (R16) - rcall com2wSendNextPkg out SREG, r15 pop r15 ret @@ -124,6 +123,31 @@ COM2W_Every100ms: +; --------------------------------------------------------------------------- +; @routine COM2W_Run @global +; +; @clobbers (R16, R17, R18, R20, R22, R24, R25, X) + +COM2W_Run: + push r15 + in r15, SREG + cli + ldi yl, LOW(com2w_iface) + ldi yh, HIGH(com2w_iface) + rcall com2wSendNextPkg ; (R16, R17, R18, R20, R22, R24, R25, X) + brcs COM2W_Run_ok + pop r15 + clc + rjmp COM2W_Run_ret +COM2W_Run_ok: + pop r15 + sec +COM2W_Run_ret: + ret +; @end + + + ; --------------------------------------------------------------------------- ; @routine com2wReceiveNextPkg ; @@ -182,6 +206,9 @@ com2wReceiveNextPkg_copyLoop: brcc com2wReceiveNextPkg_eMissed ldi r16, NET_IFACE_OFFS_PACKETSIN_LOW rcall NET_Interface_IncCounter16 ; (R24, R25) +#ifdef MODULES_LED_ACTIVITY + rcall LedActivity_Trigger ; (r16) +#endif sec rjmp com2wReceiveNextPkg_end com2wReceiveNextPkg_eCrc: From 6e062d3f60a12e8b54ed34cce0771c178ea887ac Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 25 Aug 2025 10:22:05 +0200 Subject: [PATCH 148/196] improve stats reporting now again use three messages to transmit stats (much more efficient than sending single values, also more acurate). --- apps/aqhome-nodes/server.c | 68 +++++++++-- aqhome/msg/node/m_node.h | 4 +- aqhome/msg/node/m_recvstats.c | 25 ++-- aqhome/msg/node/m_recvstats.h | 1 + aqhome/msg/node/m_sendstats.c | 19 ++- aqhome/msg/node/m_sendstats.h | 1 + avr/apps/network/stats.asm | 29 ++++- avr/apps/stats/main.asm | 154 ++++++------------------ avr/modules/comproto/MESSAGES | 26 ++-- avr/modules/network/msg/defs.asm | 4 +- avr/modules/network/msg/memstats-w.asm | 8 +- avr/modules/network/msg/recvstats-w.asm | 47 ++++++-- avr/modules/network/msg/sendstats-w.asm | 34 ++++-- 13 files changed, 234 insertions(+), 186 deletions(-) diff --git a/apps/aqhome-nodes/server.c b/apps/aqhome-nodes/server.c index 320f612..89f1d18 100644 --- a/apps/aqhome-nodes/server.c +++ b/apps/aqhome-nodes/server.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -122,7 +123,10 @@ static void _forwardTtyMsgToBroker(AQH_OBJECT *o, AQH_NODE_SERVER *xo, const AQH static void _forwardValueMessageToBroker(AQH_OBJECT *o, AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg); static void _forwardDataFromSendStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg); static void _forwardDataFromRecvStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg); +static void _forwardDataFromMemStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg); static void _forwardTtyMsgToClients(AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg); +static void _publishIntWithIdx(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int idx, int vModality, const char *vUnits, int v); +static void _publishDoubleWithIdx(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int idx, int vModality, const char *vUnits, double v); static void _publishInt(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int vModality, const char *vUnits, int v); static void _publishDouble(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int vModality, const char *vUnits, double v); static void _setDeviceName(AQH_VALUE *value, uint32_t uid); @@ -827,9 +831,11 @@ void _forwardTtyMsgToBroker(AQH_OBJECT *o, AQH_NODE_SERVER *xo, const AQH_MESSAG code=AQH_NodeMessage_GetMsgType(msg); switch(code) { - case AQH_MSG_TYPE_VALUE_REPORT: _forwardValueMessageToBroker(o, xo, msg); break; + case AQH_MSG_TYPE_VALUE_REPORT: _forwardValueMessageToBroker(o, xo, msg); break; case AQH_MSG_TYPE_COMSENDSTATS: _forwardDataFromSendStatsMsgToBroker(xo, msg); break; case AQH_MSG_TYPE_COMRECVSTATS: _forwardDataFromRecvStatsMsgToBroker(xo, msg); break; + case AQH_MSG_TYPE_MEMSTATS: _forwardDataFromMemStatsMsgToBroker(xo, msg); break; + default: break; } } @@ -898,6 +904,7 @@ void _forwardDataFromSendStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_MESSAGE packetsOutInt=AQH_SendStatsMessage_GetPacketsOut(msg); if (packetsOutInt) { uint32_t uid; + int devNum; double packetsOut; double collisions; double busy; @@ -905,6 +912,7 @@ void _forwardDataFromSendStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_MESSAGE double busyPercentage=0.0; uid=AQH_SendStatsMessage_GetUid(msg); + devNum=AQH_SendStatsMessage_GetInterface(msg); packetsOut=/*(double)*/ packetsOutInt; collisions=/*(double)*/ AQH_SendStatsMessage_GetCollisions(msg); busy=/*(double)*/ AQH_SendStatsMessage_GetBusyErrors(msg); @@ -912,10 +920,10 @@ void _forwardDataFromSendStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_MESSAGE collisionsPercentage=collisions*100.0/packetsOut; busyPercentage=busy*100.0/packetsOut; - _publishInt( xo, uid, "net/packetsOut", 0, NULL, packetsOutInt); - _publishInt( xo, uid, "net/collisions", 0, NULL, (int) AQH_SendStatsMessage_GetCollisions(msg)); - _publishDouble(xo, uid, "net/collisionsPercent", 0, "%", collisionsPercentage); - _publishDouble(xo, uid, "net/busyPercent", 0, "%", busyPercentage); + _publishIntWithIdx( xo, uid, "net/packetsOut", devNum, 0, NULL, packetsOutInt); + _publishIntWithIdx( xo, uid, "net/collisions", devNum, 0, NULL, (int) AQH_SendStatsMessage_GetCollisions(msg)); + _publishDoubleWithIdx(xo, uid, "net/collisionsPercent", devNum, 0, "%", collisionsPercentage); + _publishDoubleWithIdx(xo, uid, "net/busyPercent", devNum, 0, "%", busyPercentage); } } @@ -928,13 +936,15 @@ void _forwardDataFromRecvStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_MESSAGE packetsInInt=AQH_RecvStatsMessage_GetPacketsIn(msg); if (packetsInInt) { uint32_t uid; + int devNum; double packetsIn; double crcErrors; double ioErrors; double crcErrorsPercentage=0.0; double ioErrorsPercentage=0.0; - uid=AQH_SendStatsMessage_GetUid(msg); + uid=AQH_RecvStatsMessage_GetUid(msg); + devNum=AQH_RecvStatsMessage_GetInterface(msg); packetsIn=/*(double)*/ packetsInInt; crcErrors=/*(double)*/AQH_RecvStatsMessage_GetCrcErrors(msg); ioErrors=/*(double)*/AQH_RecvStatsMessage_GetIoErrors(msg); @@ -942,16 +952,52 @@ void _forwardDataFromRecvStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_MESSAGE crcErrorsPercentage=crcErrors*100.0/packetsIn; ioErrorsPercentage=ioErrors*100.0/packetsIn; - _publishInt( xo, uid, "net/packetsIn", 0, NULL, packetsInInt); - _publishInt( xo, uid, "net/crcerrors", 0, NULL, (int) AQH_RecvStatsMessage_GetCrcErrors(msg)); - _publishInt( xo, uid, "net/ioerrors", 0, NULL, (int) AQH_RecvStatsMessage_GetIoErrors(msg)); - _publishDouble(xo, uid, "net/crcerrorsPercent", 0, "%", crcErrorsPercentage); - _publishDouble(xo, uid, "net/ioerrorsPercent", 0, "%", ioErrorsPercentage); + _publishIntWithIdx( xo, uid, "net/packetsIn", devNum, 0, NULL, packetsInInt); + _publishIntWithIdx( xo, uid, "net/crcerrors", devNum, 0, NULL, (int) AQH_RecvStatsMessage_GetCrcErrors(msg)); + _publishIntWithIdx( xo, uid, "net/ioerrors", devNum, 0, NULL, (int) AQH_RecvStatsMessage_GetIoErrors(msg)); + _publishDoubleWithIdx(xo, uid, "net/crcerrorsPercent", devNum, 0, "%", crcErrorsPercentage); + _publishDoubleWithIdx(xo, uid, "net/ioerrorsPercent", devNum, 0, "%", ioErrorsPercentage); } } +void _forwardDataFromMemStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg) +{ + uint32_t uid; + + uid=AQH_MemStatsMessage_GetUid(msg); + + _publishInt( xo, uid, "mem/buffersUsed", 0, NULL, AQH_MemStatsMessage_GetBuffersUsed(msg)); + _publishInt( xo, uid, "mem/maxBuffersUsed", 0, NULL, AQH_MemStatsMessage_GetMaxBuffersUsed(msg)); +} + + + +void _publishIntWithIdx(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int idx, int vModality, const char *vUnits, int v) +{ + GWEN_BUFFER *tbuf; + + tbuf=GWEN_Buffer_new(0, 256, 0, 1); + GWEN_Buffer_AppendArgs(tbuf, "%s%d", vPath, idx); + _publishInt(xo, uid, GWEN_Buffer_GetStart(tbuf), vModality, vUnits, v); + GWEN_Buffer_free(tbuf); +} + + + +void _publishDoubleWithIdx(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int idx, int vModality, const char *vUnits, double v) +{ + GWEN_BUFFER *tbuf; + + tbuf=GWEN_Buffer_new(0, 256, 0, 1); + GWEN_Buffer_AppendArgs(tbuf, "%s%d", vPath, idx); + _publishDouble(xo, uid, GWEN_Buffer_GetStart(tbuf), vModality, vUnits, v); + GWEN_Buffer_free(tbuf); +} + + + void _publishInt(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int vModality, const char *vUnits, int v) { _publishDouble(xo, uid, vPath, vModality, vUnits, /*(double)*/ v); diff --git a/aqhome/msg/node/m_node.h b/aqhome/msg/node/m_node.h index 151d625..954d7c7 100644 --- a/aqhome/msg/node/m_node.h +++ b/aqhome/msg/node/m_node.h @@ -29,8 +29,8 @@ #define AQH_MSG_TYPE_PING 10 #define AQH_MSG_TYPE_PONG 11 -#define AQH_MSG_TYPE_COMSENDSTATS 20 -#define AQH_MSG_TYPE_COMRECVSTATS 21 +#define AQH_MSG_TYPE_COMSENDSTATS 22 +#define AQH_MSG_TYPE_COMRECVSTATS 23 #define AQH_MSG_TYPE_TWIBUSMEMBER 30 #define AQH_MSG_TYPE_DEBUG 40 #define AQH_MSG_TYPE_VALUE 50 /* deprecated */ diff --git a/aqhome/msg/node/m_recvstats.c b/aqhome/msg/node/m_recvstats.c index bd0a02e..585c99e 100644 --- a/aqhome/msg/node/m_recvstats.c +++ b/aqhome/msg/node/m_recvstats.c @@ -19,12 +19,20 @@ #define AQH_MSG_OFFS_RECVSTATS_UID 0 /* 4 bytes */ -#define AQH_MSG_OFFS_RECVSTATS_PACKETSIN 4 /* 2 bytes */ -#define AQH_MSG_OFFS_RECVSTATS_CRCERRORS 6 /* 2 bytes */ -#define AQH_MSG_OFFS_RECVSTATS_IOERRORS 8 /* 2 bytes */ -#define AQH_MSG_OFFS_RECVSTATS_NOBUFFER 10 /* 2 bytes */ -#define AQH_MSG_OFFS_RECVSTATS_HANDLED 12 /* 2 bytes */ -#define AQH_MSG_OFFS_RECVSTATS_MISSED 14 /* 2 bytes */ +#define AQH_MSG_OFFS_RECVSTATS_IFACE 4 /* 1 byte */ +#define AQH_MSG_OFFS_RECVSTATS_PACKETSIN 5 /* 2 bytes */ +#define AQH_MSG_OFFS_RECVSTATS_CRCERRORS 7 /* 2 bytes */ +#define AQH_MSG_OFFS_RECVSTATS_IOERRORS 9 /* 2 bytes */ +#define AQH_MSG_OFFS_RECVSTATS_NOBUFFER 11 /* 2 bytes */ +#define AQH_MSG_OFFS_RECVSTATS_HANDLED 13 /* 2 bytes */ +#define AQH_MSG_OFFS_RECVSTATS_MISSED 15 /* 2 bytes */ + + + +uint8_t AQH_RecvStatsMessage_GetInterface(const AQH_MESSAGE *msg) +{ + return AQH_Message_ReadUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_IFACE, 0); +} @@ -80,12 +88,13 @@ uint16_t AQH_RecvStatsMessage_GetMissed(const AQH_MESSAGE *msg) void AQH_RecvStatsMessage_DumpToBuffer(const AQH_MESSAGE *msg, GWEN_BUFFER *dbuf, const char *sText) { GWEN_Buffer_AppendArgs(dbuf, - "0x%02x->0x%02x: RECVSTATS %s " - "(uid=0x%08x, in=%d, crc errs=%d, io errs=%d, nobuf errs=%d, handled=%d, missed=%d)\n", + "0x%02x->0x%02x: RECVSTATS %s" + "(uid=0x%08x, dev=%d, in=%d, crc errs=%d, io errs=%d, nobuf errs=%d, handled=%d, missed=%d)\n", AQH_NodeMessage_GetSourceAddress(msg), AQH_NodeMessage_GetDestAddress(msg), sText, (unsigned int) AQH_RecvStatsMessage_GetUid(msg), + AQH_RecvStatsMessage_GetInterface(msg), AQH_RecvStatsMessage_GetPacketsIn(msg), AQH_RecvStatsMessage_GetCrcErrors(msg), AQH_RecvStatsMessage_GetIoErrors(msg), diff --git a/aqhome/msg/node/m_recvstats.h b/aqhome/msg/node/m_recvstats.h index d83d04a..58968de 100644 --- a/aqhome/msg/node/m_recvstats.h +++ b/aqhome/msg/node/m_recvstats.h @@ -17,6 +17,7 @@ +AQHOME_API uint8_t AQH_RecvStatsMessage_GetInterface(const AQH_MESSAGE *msg); AQHOME_API uint32_t AQH_RecvStatsMessage_GetUid(const AQH_MESSAGE *msg); AQHOME_API uint16_t AQH_RecvStatsMessage_GetPacketsIn(const AQH_MESSAGE *msg); AQHOME_API uint16_t AQH_RecvStatsMessage_GetCrcErrors(const AQH_MESSAGE *msg); diff --git a/aqhome/msg/node/m_sendstats.c b/aqhome/msg/node/m_sendstats.c index adb436f..6f81dec 100644 --- a/aqhome/msg/node/m_sendstats.c +++ b/aqhome/msg/node/m_sendstats.c @@ -1,6 +1,6 @@ /**************************************************************************** * This file is part of the project AqHome. - * AqHome (c) by 2023 Martin Preuss, all rights reserved. + * AqHome (c) by 2025 Martin Preuss, all rights reserved. * * The license for this file can be found in the file COPYING which you * should have received along with this file. @@ -19,9 +19,17 @@ #define AQH_MSG_OFFS_SENDSTATS_UID 0 /* 4 bytes */ -#define AQH_MSG_OFFS_SENDSTATS_PACKETSOUT 4 /* 2 bytes */ -#define AQH_MSG_OFFS_SENDSTATS_COLLISIONS 6 /* 2 bytes */ -#define AQH_MSG_OFFS_SENDSTATS_BUSY 8 /* 2 bytes */ +#define AQH_MSG_OFFS_SENDSTATS_IFACE 4 /* 1 byte */ +#define AQH_MSG_OFFS_SENDSTATS_PACKETSOUT 5 /* 2 bytes */ +#define AQH_MSG_OFFS_SENDSTATS_COLLISIONS 7 /* 2 bytes */ +#define AQH_MSG_OFFS_SENDSTATS_BUSY 9 /* 2 bytes */ + + + +uint8_t AQH_SendStatsMessage_GetInterface(const AQH_MESSAGE *msg) +{ + return AQH_Message_ReadUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_IFACE, 0); +} @@ -57,11 +65,12 @@ void AQH_SendStatsMessage_DumpToBuffer(const AQH_MESSAGE *msg, GWEN_BUFFER *dbuf { if (msg) GWEN_Buffer_AppendArgs(dbuf, - "0x%02x->0x%02x: SENDSTATS %s (uid=0x%08x, out=%d, collisions=%d, busy line=%d)\n", + "0x%02x->0x%02x: SENDSTATS %s (uid=0x%08x, dev=%d, out=%d, collisions=%d, busy line=%d)\n", AQH_NodeMessage_GetSourceAddress(msg), AQH_NodeMessage_GetDestAddress(msg), sText, (unsigned int) AQH_SendStatsMessage_GetUid(msg), + AQH_SendStatsMessage_GetInterface(msg), AQH_SendStatsMessage_GetPacketsOut(msg), AQH_SendStatsMessage_GetCollisions(msg), AQH_SendStatsMessage_GetBusyErrors(msg)); diff --git a/aqhome/msg/node/m_sendstats.h b/aqhome/msg/node/m_sendstats.h index a90e00d..70ef73d 100644 --- a/aqhome/msg/node/m_sendstats.h +++ b/aqhome/msg/node/m_sendstats.h @@ -17,6 +17,7 @@ +AQHOME_API uint8_t AQH_SendStatsMessage_GetInterface(const AQH_MESSAGE *msg); AQHOME_API uint32_t AQH_SendStatsMessage_GetUid(const AQH_MESSAGE *msg); AQHOME_API uint16_t AQH_SendStatsMessage_GetPacketsOut(const AQH_MESSAGE *msg); AQHOME_API uint16_t AQH_SendStatsMessage_GetCollisions(const AQH_MESSAGE *msg); diff --git a/avr/apps/network/stats.asm b/avr/apps/network/stats.asm index c50f7f1..f7c35be 100644 --- a/avr/apps/network/stats.asm +++ b/avr/apps/network/stats.asm @@ -25,7 +25,13 @@ AppNetwork_SendTxdStats: bigcall NETMSG_SendStats_Write ; (R16, R17, R18, R19, R20, R21, Z) sbiw xh:xl, 1 pop r16 - bigcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) + push yl + push yh + ldi yl, LOW(netInterfaceData) + ldi yh, HIGH(netInterfaceData) + bigcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) + pop yh + pop yl AppNetwork_SendTxdStats_end: ret ; @end @@ -35,7 +41,7 @@ AppNetwork_SendTxdStats_end: ; --------------------------------------------------------------------------- ; @routine AppNetwork_SendRxdStats -; @param Y network interface to work with +; @param Y network interface whose stats to send ; @clobbers R16, X (R17, R18, R19, R20, R21, Z) AppNetwork_SendRxdStats: @@ -46,7 +52,13 @@ AppNetwork_SendRxdStats: bigcall NETMSG_RecvStats_Write ; (R16, R17, R18, R19, R20, R21, Z) sbiw xh:xl, 1 pop r16 - bigcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) + push yl + push yh + ldi yl, LOW(netInterfaceData) + ldi yh, HIGH(netInterfaceData) + bigcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) + pop yh + pop yl AppNetwork_SendRxdStats_end: ret ; @end @@ -54,9 +66,8 @@ AppNetwork_SendRxdStats_end: ; --------------------------------------------------------------------------- -; @routine AppNetwork_SendRxdStats +; @routine AppNetwork_SendMemStats -; @param Y network interface to work with ; @clobbers R16, X (R17, R18, R19, R20, R21, Z) AppNetwork_SendMemStats: @@ -67,7 +78,13 @@ AppNetwork_SendMemStats: bigcall NETMSG_MemStats_Write ; (R16, R17, R18, R19, R20, R21) sbiw xh:xl, 1 pop r16 - bigcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) + push yl + push yh + ldi yl, LOW(netInterfaceData) + ldi yh, HIGH(netInterfaceData) + bigcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) + pop yh + pop yl AppNetwork_SendMemStats_end: ret ; @end diff --git a/avr/apps/stats/main.asm b/avr/apps/stats/main.asm index aa7272c..d288484 100644 --- a/avr/apps/stats/main.asm +++ b/avr/apps/stats/main.asm @@ -11,7 +11,7 @@ ; *************************************************************************** ; defines -.equ APP_STATS_INTERVAL_MINS = 31 +.equ APP_STATS_INTERVAL_MINS = 10 @@ -62,10 +62,6 @@ AppStats_OnEveryMinute: ret AppStats_OnEveryMinute_noIrq: -; ldi yl, LOW(netInterfaceData) -; ldi yh, HIGH(netInterfaceData) -; rcall AppNetwork_SendRxdStats ; debug - lds r16, appStatsTimer inc r16 cpi r16, APP_STATS_INTERVAL_MINS @@ -73,71 +69,28 @@ AppStats_OnEveryMinute_noIrq: clr r16 AppStats_OnEveryMinute_store: sts appStatsTimer, r16 - ldi yl, LOW(netInterfaceData) - ldi yh, HIGH(netInterfaceData) - - ldi r17, AQHOME_VALUEID_STATS_PACKETS_IN - ldi xl, LOW(netInterfaceData) - ldi xh, HIGH(netInterfaceData) + cpi r16, 1 breq AppStats_OnEveryMinute_sendDevice + + cpi r16, 2 + breq AppStats_OnEveryMinute_sendMemStats + cpi r16, 3 - breq AppStats_OnEveryMinute_sendPacketsIn - cpi r16, 5 - breq AppStats_OnEveryMinute_sendPacketsOut - cpi r16, 6 - breq AppStats_OnEveryMinute_sendDevice - cpi r16, 7 - breq AppStats_OnEveryMinute_sendContentErrs - cpi r16, 9 - breq AppStats_OnEveryMinute_sendIoErrs - cpi r16, 10 - breq AppStats_OnEveryMinute_sendDevice - cpi r16, 11 - breq AppStats_OnEveryMinute_sendNoBufErrs - cpi r16, 13 - breq AppStats_OnEveryMinute_sendCollisionErrs - cpi r16, 14 - breq AppStats_OnEveryMinute_sendDevice - cpi r16, 15 - breq AppStats_OnEveryMinute_sendBusyErrs + breq AppStats_OnEveryMinute_sendRecvStats1 + + cpi r16, 4 + breq AppStats_OnEveryMinute_sendSendStats1 #ifdef APP_STATS_NETDEV2 - ldi r17, AQHOME_VALUEID_STATS_PACKETS_IN2 - ldi xl, LOW(netInterfaceData2) - ldi xh, HIGH(netInterfaceData2) - cpi r16, 16 - breq AppStats_OnEveryMinute_sendPacketsIn - cpi r16, 17 - breq AppStats_OnEveryMinute_sendPacketsOut - cpi r16, 18 - breq AppStats_OnEveryMinute_sendDevice - cpi r16, 19 - breq AppStats_OnEveryMinute_sendContentErrs - cpi r16, 20 - breq AppStats_OnEveryMinute_sendIoErrs - cpi r16, 21 - breq AppStats_OnEveryMinute_sendDevice - cpi r16, 22 - breq AppStats_OnEveryMinute_sendNoBufErrs - cpi r16, 23 - breq AppStats_OnEveryMinute_sendDevice - cpi r16, 24 - breq AppStats_OnEveryMinute_sendCollisionErrs - cpi r16, 25 - breq AppStats_OnEveryMinute_sendBusyErrs -#endif + cpi r16, 5 + breq AppStats_OnEveryMinute_sendRecvStats2 -#ifdef MODULES_HEAP - cpi r16, 26 - breq AppStats_OnEveryMinute_sendHeapUsed - cpi r16, 27 - breq AppStats_OnEveryMinute_sendHeapfree + cpi r16, 6 + breq AppStats_OnEveryMinute_sendSendStats2 #endif - cpi r16, 28 - breq AppStats_OnEveryMinute_sendDevice + ; add more here ret - AppStats_OnEveryMinute_sendDevice: push yl push yh @@ -152,68 +105,35 @@ AppStats_OnEveryMinute_sendDevice: pop yh pop yl ret -AppStats_OnEveryMinute_sendPacketsIn: - ldi r16, 0 - rjmp appStatsSendDeviceStat -AppStats_OnEveryMinute_sendPacketsOut: - ldi r16, 1 - rjmp appStatsSendDeviceStat -AppStats_OnEveryMinute_sendContentErrs: - ldi r16, 2 - rjmp appStatsSendDeviceStat -AppStats_OnEveryMinute_sendIoErrs: - ldi r16, 3 - rjmp appStatsSendDeviceStat -AppStats_OnEveryMinute_sendNoBufErrs: - ldi r16, 4 - rjmp appStatsSendDeviceStat -AppStats_OnEveryMinute_sendCollisionErrs: - ldi r16, 5 - rjmp appStatsSendDeviceStat -AppStats_OnEveryMinute_sendBusyErrs: - ldi r16, 6 - rjmp appStatsSendDeviceStat +AppStats_OnEveryMinute_sendMemStats: + rjmp AppNetwork_SendMemStats -#ifdef MODULES_HEAP -AppStats_OnEveryMinute_sendHeapUsed: - ldi r17, AQHOME_VALUEID_STATS_HEAP_USED - lds r18, heapUsed - lds r19, heapUsed+1 - rjmp appStatsSend16BitValue -AppStats_OnEveryMinute_sendHeapfree: - ldi r17, AQHOME_VALUEID_STATS_HEAP_FREE - lds r18, heapFree - lds r19, heapFree+1 - rjmp appStatsSend16BitValue +AppStats_OnEveryMinute_sendRecvStats1: + ldi yl, LOW(netInterfaceData) + ldi yh, HIGH(netInterfaceData) + rjmp AppNetwork_SendRxdStats + +AppStats_OnEveryMinute_sendSendStats1: + ldi yl, LOW(netInterfaceData) + ldi yh, HIGH(netInterfaceData) + rjmp AppNetwork_SendTxdStats + +#ifdef APP_STATS_NETDEV2 +AppStats_OnEveryMinute_sendRecvStats2: + ldi yl, LOW(netInterfaceData2) + ldi yh, HIGH(netInterfaceData2) + rjmp AppNetwork_SendRxdStats + +AppStats_OnEveryMinute_sendSendStats2: + ldi yl, LOW(netInterfaceData2) + ldi yh, HIGH(netInterfaceData2) + rjmp AppNetwork_SendTxdStats #endif ; @end -; --------------------------------------------------------------------------- -; @routine AppStats_OnEveryMinute @global -; -; @param r16 index into device table (e.g. 0 for NET_IFACE_OFFS_PACKETSIN_LOW) -; @param r17 offset to first value id (e.g. AQHOME_VALUEID_STATS_PACKETS_IN for device 0, -; AQHOME_VALUEID_STATS_PACKETS_IN2 for device 1) -; @param Y pointer to device to send data to -; @param X pointer to device to inspect - -appStatsSendDeviceStat: - add r17, r16 - lsl r16 - adiw xh:xl, NET_IFACE_OFFS_PACKETSIN_LOW - add xl, r16 - adc xh, r16 - sub xh, r16 - ld r18, X+ - ld r19, X - rjmp appStatsSend16BitValue -; @end - - - ; --------------------------------------------------------------------------- ; @routine AppStats_OnEveryMinute @global ; diff --git a/avr/modules/comproto/MESSAGES b/avr/modules/comproto/MESSAGES index fe9f3e6..b0172ae 100644 --- a/avr/modules/comproto/MESSAGES +++ b/avr/modules/comproto/MESSAGES @@ -165,10 +165,11 @@ Offset Length Meaning 2 1 command code 3 1 source address --------------------------------------------------------- - 4 4 UID of the sending node - 8 2 packets out - 10 2 collisions - 12 2 line busy errors + 4 1 Interface number + 5 4 UID of the sending node + 9 2 packets out + 11 2 collisions + 13 2 line busy errors --------------------------------------------------------- 14 1 CRC8 byte @@ -185,15 +186,16 @@ Offset Length Meaning 2 1 command code 3 1 source address --------------------------------------------------------- - 4 4 UID of the sending node - 8 2 packets in - 10 2 content errors (invalid msg length, CRC errors) - 12 2 io errors - 14 2 no buffer errors - 16 2 handled packets - 18 2 missed packets + 4 1 Interface number + 5 4 UID of the sending node + 9 2 packets in + 11 2 content errors (invalid msg length, CRC errors) + 13 2 io errors + 15 2 no buffer errors + 17 2 handled packets + 19 2 missed packets --------------------------------------------------------- - 20 1 CRC8 byte + 21 1 CRC8 byte diff --git a/avr/modules/network/msg/defs.asm b/avr/modules/network/msg/defs.asm index 5b2a62c..f44fced 100644 --- a/avr/modules/network/msg/defs.asm +++ b/avr/modules/network/msg/defs.asm @@ -14,8 +14,8 @@ .equ NETMSG_CMD_PING = 10 .equ NETMSG_CMD_PONG = 11 -.equ NETMSG_CMD_SENDSTATS = 20 -.equ NETMSG_CMD_RECVSTATS = 21 +.equ NETMSG_CMD_SENDSTATS = 22 +.equ NETMSG_CMD_RECVSTATS = 23 .equ NETMSG_CMD_TWIBUSMEMBER = 30 .equ NETMSG_CMD_DEBUG = 40 diff --git a/avr/modules/network/msg/memstats-w.asm b/avr/modules/network/msg/memstats-w.asm index 2bbfa66..6a71ab3 100644 --- a/avr/modules/network/msg/memstats-w.asm +++ b/avr/modules/network/msg/memstats-w.asm @@ -51,14 +51,10 @@ NETMSG_MemStats_Write: st X+, r21 .endif ; current buffers used - push xl - push xh - bigcall NET_Buffer_CountUsed ; (r16, r17, r18, X) - pop xh - pop xl + lds r16, netBuffersUsed st X+, r16 ; max buffers used - clr r16 + lds r16, netBuffersMaxUsed st X+, r16 ; no buffer errors ldd r16, Y+NET_IFACE_OFFS_ERR_NOBUF_LOW diff --git a/avr/modules/network/msg/recvstats-w.asm b/avr/modules/network/msg/recvstats-w.asm index 451c3c0..750b775 100644 --- a/avr/modules/network/msg/recvstats-w.asm +++ b/avr/modules/network/msg/recvstats-w.asm @@ -19,21 +19,52 @@ NETMSG_RecvStats_Write: ldi r16, 0xff st X+, r16 ; dest address - ldi r16, 18 ; msg code+src address+10 payload bytes + ldi r16, 19 ; msg code+src address+10 payload bytes st X+, r16 ; msg len ldi r16, NETMSG_CMD_RECVSTATS st X+, r16 ; msg code ldd r16, Y+NET_IFACE_OFFS_ADDRESS st X+, r16 ; src address - bigcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21) - adiw yh:yl, NET_IFACE_OFFS_PACKETSIN_LOW - ldi r18, 12 - bigcall Utils_Copy_SDRAM ; (R17, R18, X, Y) - sbiw yh:yl, NET_IFACE_OFFS_PACKETSIN_LOW+12 - sbiw xh:xl, 20 ; go back to beginning of message (1 byte dst addr, 1 byte length, 18 bytes payload) + ; UID + bigcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21) + ; interface number + ldd r16, Y+NET_IFACE_OFFS_IFACENUM + st X+, r16 + ; packets in + ldd r16, Y+NET_IFACE_OFFS_PACKETSIN_LOW + st X+, r16 + ldd r16, Y+NET_IFACE_OFFS_PACKETSIN_HIGH + st X+, r16 + ; content error + ldd r16, Y+NET_IFACE_OFFS_ERR_CONTENT_LOW + st X+, r16 + ldd r16, Y+NET_IFACE_OFFS_ERR_CONTENT_HIGH + st X+, r16 + ; io error + ldd r16, Y+NET_IFACE_OFFS_ERR_IO_LOW + st X+, r16 + ldd r16, Y+NET_IFACE_OFFS_ERR_IO_HIGH + st X+, r16 + ; nobuf error + ldd r16, Y+NET_IFACE_OFFS_ERR_NOBUF_LOW + st X+, r16 + ldd r16, Y+NET_IFACE_OFFS_ERR_NOBUF_HIGH + st X+, r16 + ; msgsize error + ldd r16, Y+NET_IFACE_OFFS_ERR_MSGSIZE_LOW + st X+, r16 + ldd r16, Y+NET_IFACE_OFFS_ERR_MSGSIZE_HIGH + st X+, r16 + ; missed error + ldd r16, Y+NET_IFACE_OFFS_ERR_MISSED_LOW + st X+, r16 + ldd r16, Y+NET_IFACE_OFFS_ERR_MISSED_HIGH + st X+, r16 + + sbiw xh:xl, 21 ; go back to beginning of message (1 byte dst addr, 1 byte length, 18 bytes payload) bigcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X) - sbiw xh:xl, 21 ; go back to beginning of message (1 byte dst addr, 1 byte length, 18 bytes payload, 1 byte crc) + sbiw xh:xl, 22 ; go back to beginning of message (1 byte dst addr, 1 byte length, 18 bytes payload, 1 byte crc) ret ; @end diff --git a/avr/modules/network/msg/sendstats-w.asm b/avr/modules/network/msg/sendstats-w.asm index 594b9ad..b794bcc 100644 --- a/avr/modules/network/msg/sendstats-w.asm +++ b/avr/modules/network/msg/sendstats-w.asm @@ -12,28 +12,44 @@ ; --------------------------------------------------------------------------- ; @routine NETMSG_SendStats_Write @global ; -; @param Y pointer to device to write msg for and to +; @param Y pointer to device to write msg for ; @param X pointer to buffer to write to ; @clobbers R16, R18 (R17, R19, R20, R21, Z) NETMSG_SendStats_Write: ldi r16, 0xff st X+, r16 ; dest address - ldi r16, 12 ; msg code+src address+10 payload bytes + ldi r16, 13 ; msg code+src address+11 payload bytes st X+, r16 ; msg len ldi r16, NETMSG_CMD_SENDSTATS st X+, r16 ; msg code ldd r16, Y+NET_IFACE_OFFS_ADDRESS st X+, r16 ; src address - bigcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21) - adiw yh:yl, NET_IFACE_OFFS_PACKETSOUT_LOW - ldi r18, 6 - bigcall Utils_Copy_SDRAM ; (R17, R18, X, Y) - sbiw yh:yl, NET_IFACE_OFFS_PACKETSOUT_LOW+6 - sbiw xh:xl, 14 ; go back to beginning of message (1 byte dst addr, 1 byte length, 12 bytes payload) + ; UID + bigcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21) + ; interface number + ldd r16, Y+NET_IFACE_OFFS_IFACENUM + st X+, r16 + ; packets out + ldd r16, Y+NET_IFACE_OFFS_PACKETSOUT_LOW + st X+, r16 + ldd r16, Y+NET_IFACE_OFFS_PACKETSOUT_HIGH + st X+, r16 + ; collisions + ldd r16, Y+NET_IFACE_OFFS_ERR_COLLISIONS_LOW + st X+, r16 + ldd r16, Y+NET_IFACE_OFFS_ERR_COLLISIONS_HIGH + st X+, r16 + ; busy + ldd r16, Y+NET_IFACE_OFFS_ERR_BUSY_LOW + st X+, r16 + ldd r16, Y+NET_IFACE_OFFS_ERR_BUSY_HIGH + st X+, r16 + + sbiw xh:xl, 15 ; go back to beginning of message (1 byte dst addr, 1 byte length, 13 bytes payload) bigcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X) - sbiw xh:xl, 15 ; go back to beginning of message (1 byte dst addr, 1 byte length, 12 bytes payload, 1 byte crc) + sbiw xh:xl, 16 ; go back to beginning of message (1 byte dst addr, 1 byte length, 12 bytes payload, 1 byte crc) ret ; @end From 465e750e3c5abc099ba08afea67b501ae8346af2 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 25 Aug 2025 10:22:50 +0200 Subject: [PATCH 149/196] avr: activate new led modules. --- avr/devices/all/includes.asm | 10 ++++++++++ avr/devices/all/main.asm | 10 ++++++++++ avr/devices/all/modules.asm | 23 ++++++++++++++++++++++- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/avr/devices/all/includes.asm b/avr/devices/all/includes.asm index 7755185..bbbf16e 100644 --- a/avr/devices/all/includes.asm +++ b/avr/devices/all/includes.asm @@ -161,6 +161,16 @@ #endif #endif +#ifdef MODULES_LED_SIGNAL +.include "modules/led_signal/main.asm" +#endif + + +#ifdef MODULES_LED_ACTIVITY +.include "modules/led_activity/main.asm" +#endif + + #ifdef MODULES_TWI_MASTER .include "modules/twimaster/main.asm" #endif diff --git a/avr/devices/all/main.asm b/avr/devices/all/main.asm index 5aaf331..b31182b 100644 --- a/avr/devices/all/main.asm +++ b/avr/devices/all/main.asm @@ -115,6 +115,16 @@ onSystemTimerTick: bigcall LedSimple_Every100ms #endif +#ifdef MODULES_LED_SIGNAL + bigcall LedSignal_Every100ms +#endif + + +#ifdef MODULES_LED_ACTIVITY + bigcall LedActivity_Every100ms +#endif + + #ifdef MODULES_UART_BITBANG bigcall UART_BitBang_Every100ms #endif diff --git a/avr/devices/all/modules.asm b/avr/devices/all/modules.asm index d9be262..79fda3a 100644 --- a/avr/devices/all/modules.asm +++ b/avr/devices/all/modules.asm @@ -51,7 +51,19 @@ initModules: #ifdef MODULES_LED_SIMPLE bigcall LedSimple_Init #endif - + + +#ifdef MODULES_LED_SIGNAL + bigcall LedSignal_Init +#endif + + + +#ifdef MODULES_LED_ACTIVITY + bigcall LedActivity_Init +#endif + + #ifdef MODULES_COM bigcall Com2_Init ; init COM module bigcall CPRO_Init ; init COM protocol module @@ -239,6 +251,15 @@ runModules: sbci r16, 0 #endif + +#ifdef MODULES_COM2W + push r16 + bigcall COM2W_Run + pop r16 + sbci r16, 0 +#endif + + #ifdef MODULES_COM2W0 push r16 bigcall COM2W0_Run From 127525e3ec05ab07802ff5d8751adfd197e72e11 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 25 Aug 2025 10:23:47 +0200 Subject: [PATCH 150/196] buffer: gather statistics --- avr/modules/network/buffer.asm | 37 ++++++++++++++++++++++++++++++++++ avr/modules/network/data.asm | 3 +++ 2 files changed, 40 insertions(+) diff --git a/avr/modules/network/buffer.asm b/avr/modules/network/buffer.asm index c8e54e9..f96c927 100644 --- a/avr/modules/network/buffer.asm +++ b/avr/modules/network/buffer.asm @@ -27,6 +27,11 @@ NET_Buffer_Init: ldi xl, LOW(netBuffers) ldi xh, HIGH(netBuffers) + ldi r16, NET_BUFFERS_NUM + sts netBuffersFree, r16 + clr r16 + sts netBuffersMaxUsed, r16 + sts netBuffersUsed, r16 m_fixedbuf_init NET_BUFFERS_SIZE, NET_BUFFERS_NUM ret ; @end @@ -45,13 +50,39 @@ NET_Buffer_Alloc: push r15 in r15, SREG cli + + lds r17, netBuffersFree + tst r17 + breq NET_Buffer_Alloc_error + rcall NET_Buffer_Alloc_noIrq brcc NET_Buffer_Alloc_error + lds r17, netBuffersFree + dec r17 + sts netBuffersFree, r17 + lds r17, netBuffersUsed + inc r17 + sts netBuffersUsed, r17 + push r16 + lds r16, netBuffersMaxUsed + cp r16, r17 + brcc NET_Buffer_Alloc_countersSet + sts netBuffersMaxUsed, r17 +NET_Buffer_Alloc_countersSet: +#ifdef MODULES_LED_SIGNAL + ldi r16, T03_FLAGS_ALLOC + rcall LedSignal_ClrFlag ; (R17) +#endif + pop r16 out SREG, r15 pop r15 sec ret NET_Buffer_Alloc_error: +#ifdef MODULES_LED_SIGNAL + ldi r16, T03_FLAGS_ALLOC + rcall LedSignal_SetFlag ; (R17) +#endif out SREG, r15 pop r15 clc @@ -96,6 +127,12 @@ NET_Buffer_ReleaseByAddr: rjmp NET_Buffer_ReleaseByAddr_done NET_Buffer_ReleaseByAddr_release: m_fixedbuf_release + lds r16, netBuffersFree + inc r16 + sts netBuffersFree, r16 + lds r16, netBuffersUsed + dec r16 + sts netBuffersUsed, r16 NET_Buffer_ReleaseByAddr_done: out SREG, r15 pop r15 diff --git a/avr/modules/network/data.asm b/avr/modules/network/data.asm index c3d8dea..255e372 100644 --- a/avr/modules/network/data.asm +++ b/avr/modules/network/data.asm @@ -12,6 +12,9 @@ networkDataBegin: ; buffers for incoming and outgoing messages + netBuffersUsed: .byte 1 + netBuffersMaxUsed: .byte 1 + netBuffersFree: .byte 1 netBuffers: .byte NET_BUFFERS_NUM*NET_BUFFERS_SIZE netRingBufferMsgNumIn: .byte RINGBUFFERY_SIZE+NET_MSGNUMINBUF_SIZE From 77d3a201f5786f2e97ec545cfea7618a3a516a31 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 25 Aug 2025 10:24:48 +0200 Subject: [PATCH 151/196] improved uartfd1. --- avr/modules/uart_fd/defs.asm | 4 +-- avr/modules/uart_fd/macros.asm | 35 +++++++++++++++++++--- avr/modules/uart_fd/uartfd1.asm | 52 ++++++++++++++++++++++++++++++++- 3 files changed, 84 insertions(+), 7 deletions(-) diff --git a/avr/modules/uart_fd/defs.asm b/avr/modules/uart_fd/defs.asm index a095773..e77441d 100644 --- a/avr/modules/uart_fd/defs.asm +++ b/avr/modules/uart_fd/defs.asm @@ -12,8 +12,8 @@ .equ UARTFD_SKIPPING_TIME = 2 -.equ UARTFD_READ_TIMEOUT = 2 -.equ UARTFD_WRITE_TIMEOUT = 2 +.equ UARTFD_READ_TIMEOUT = 5 +.equ UARTFD_WRITE_TIMEOUT = 5 .equ UARTFD_IFACE_STATUS_BIT_OVERRUN = 0 diff --git a/avr/modules/uart_fd/macros.asm b/avr/modules/uart_fd/macros.asm index 3e5b72e..8e4d550 100644 --- a/avr/modules/uart_fd/macros.asm +++ b/avr/modules/uart_fd/macros.asm @@ -55,7 +55,8 @@ cbr r16, (1< Date: Mon, 25 Aug 2025 10:25:53 +0200 Subject: [PATCH 152/196] use new led modules. --- avr/devices/n26/defs.asm | 9 +++++++++ avr/devices/n26/main/main.asm | 3 ++- avr/devices/n27/defs.asm | 10 ++++++++++ avr/devices/n27/main/main.asm | 3 ++- avr/devices/t03/defs.asm | 10 ++++++++++ avr/devices/t03/uartfd/main.asm | 21 +++++++++++++-------- 6 files changed, 46 insertions(+), 10 deletions(-) diff --git a/avr/devices/n26/defs.asm b/avr/devices/n26/defs.asm index 0b4a2fd..7bfd6c1 100644 --- a/avr/devices/n26/defs.asm +++ b/avr/devices/n26/defs.asm @@ -47,6 +47,15 @@ .equ LED_SIMPLE_PINNUM = PORTA3 +; --------------------------------------------------------------------------- +; LED Activity module + +.equ LED_ACTIVITY_DDR = DDRA +.equ LED_ACTIVITY_PORT = PORTA +.equ LED_ACTIVITY_PORTIN = PINA +.equ LED_ACTIVITY_PINNUM = PORTA3 + + ; --------------------------------------------------------------------------- ; COM module diff --git a/avr/devices/n26/main/main.asm b/avr/devices/n26/main/main.asm index 63abdc6..de2c1c2 100644 --- a/avr/devices/n26/main/main.asm +++ b/avr/devices/n26/main/main.asm @@ -61,7 +61,8 @@ ; #define MODULES_TIMER #define MODULES_CLOCK -#define MODULES_LED_SIMPLE +;#define MODULES_LED_SIMPLE +#define MODULES_LED_ACTIVITY #define MODULES_NETWORK ;#define MODULES_UART_BITBANG #define MODULES_COM2W diff --git a/avr/devices/n27/defs.asm b/avr/devices/n27/defs.asm index c1646cc..78787f9 100644 --- a/avr/devices/n27/defs.asm +++ b/avr/devices/n27/defs.asm @@ -48,6 +48,16 @@ +; --------------------------------------------------------------------------- +; LED Activity module + +.equ LED_ACTIVITY_DDR = DDRA +.equ LED_ACTIVITY_PORT = PORTA +.equ LED_ACTIVITY_PORTIN = PINA +.equ LED_ACTIVITY_PINNUM = PORTA3 + + + ; --------------------------------------------------------------------------- ; COM module diff --git a/avr/devices/n27/main/main.asm b/avr/devices/n27/main/main.asm index 9f9b7aa..e082309 100644 --- a/avr/devices/n27/main/main.asm +++ b/avr/devices/n27/main/main.asm @@ -61,7 +61,8 @@ ; #define MODULES_TIMER #define MODULES_CLOCK -#define MODULES_LED_SIMPLE +;#define MODULES_LED_SIMPLE +#define MODULES_LED_ACTIVITY #define MODULES_NETWORK ;#define MODULES_UART_BITBANG #define MODULES_COM2W diff --git a/avr/devices/t03/defs.asm b/avr/devices/t03/defs.asm index 14b690a..48650a8 100644 --- a/avr/devices/t03/defs.asm +++ b/avr/devices/t03/defs.asm @@ -49,6 +49,16 @@ +; --------------------------------------------------------------------------- +; LED signal module + +.equ LED_SIGNAL_DDR = DDRB +.equ LED_SIGNAL_PORT = PORTB +.equ LED_SIGNAL_PORTIN = PINB +.equ LED_SIGNAL_PINNUM = PORTB2 + + + ; --------------------------------------------------------------------------- ; COM module diff --git a/avr/devices/t03/uartfd/main.asm b/avr/devices/t03/uartfd/main.asm index ca3dbaf..9c2ed6d 100644 --- a/avr/devices/t03/uartfd/main.asm +++ b/avr/devices/t03/uartfd/main.asm @@ -51,6 +51,17 @@ .equ TTYONUART1_IFACENUM = 2 +; debug + +.equ T03_FLAGS_ALLOC = 0x01 +.equ T03_FLAGS_I1_SKIPPING = 0x02 +.equ T03_FLAGS_I1_RESTARTED = 0x04 +.equ T03_FLAGS_ADDIN = 0x08 +.equ T03_FLAGS_I1_ADDOUT = 0x10 +.equ T03_FLAGS_I2_ADDOUT = 0x20 + + + ; --------------------------------------------------------------------------- ; firmware settings including list of modules used @@ -63,7 +74,8 @@ ;#define MODULES_COM ;#define MODULES_COM_WITH_ADDR_PROTO ;#define MODULES_LED -#define MODULES_LED_SIMPLE +;#define MODULES_LED_SIMPLE +#define MODULES_LED_SIGNAL ;#define MODULES_TWI_MASTER ;#define MODULES_LCD ;#define LCD_MINIMAL_FONT @@ -250,10 +262,3 @@ onMessageReceived: .equ netInterfaceData2 = com2w_iface -; debug -push r18 - push r19 - rcall LedSimple_SetFastTiming - pop r19 -pop r18 - From ec3774c7a5ebcaf70782c1b5a5f4c57bb8f03de3 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 25 Aug 2025 11:22:54 +0200 Subject: [PATCH 153/196] fixed a bug in field order --- aqhome/msg/node/m_memstats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aqhome/msg/node/m_memstats.c b/aqhome/msg/node/m_memstats.c index bbbf073..719c7c9 100644 --- a/aqhome/msg/node/m_memstats.c +++ b/aqhome/msg/node/m_memstats.c @@ -19,8 +19,8 @@ -#define AQH_MSG_OFFS_MEMSTATS_SECONDS 0 /* 4 bytes */ -#define AQH_MSG_OFFS_MEMSTATS_UID 4 /* 4 bytes */ +#define AQH_MSG_OFFS_MEMSTATS_UID 0 /* 4 bytes */ +#define AQH_MSG_OFFS_MEMSTATS_SECONDS 4 /* 4 bytes */ #define AQH_MSG_OFFS_MEMSTATS_STACKUSAGE 8 /* 2 bytes */ #define AQH_MSG_OFFS_MEMSTATS_BUFFERSUSED 10 /* 1 byte */ #define AQH_MSG_OFFS_MEMSTATS_MAXBUFFERSUSED 11 /* 1 byte */ From 65593f95ad33fb9d186af541ebae57c52e9e95e9 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 25 Aug 2025 11:23:35 +0200 Subject: [PATCH 154/196] use led_activity module. --- avr/devices/n21/defs.asm | 10 ++++++++++ avr/devices/n21/main/main.asm | 3 ++- avr/devices/t03/defs.asm | 10 ++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/avr/devices/n21/defs.asm b/avr/devices/n21/defs.asm index 67bed89..c4f08f2 100644 --- a/avr/devices/n21/defs.asm +++ b/avr/devices/n21/defs.asm @@ -48,6 +48,16 @@ +; --------------------------------------------------------------------------- +; LED activity module + +.equ LED_ACTIVITY_DDR = DDRA +.equ LED_ACTIVITY_PORT = PORTA +.equ LED_ACTIVITY_PORTIN = PINA +.equ LED_ACTIVITY_PINNUM = PORTA3 + + + ; --------------------------------------------------------------------------- ; COM module diff --git a/avr/devices/n21/main/main.asm b/avr/devices/n21/main/main.asm index dcb1f8c..4b75f03 100644 --- a/avr/devices/n21/main/main.asm +++ b/avr/devices/n21/main/main.asm @@ -59,7 +59,8 @@ ; #define MODULES_TIMER #define MODULES_CLOCK -#define MODULES_LED_SIMPLE +;#define MODULES_LED_SIMPLE +#define MODULES_LED_ACTIVITY #define MODULES_NETWORK #define MODULES_COM2W #define MODULES_TWI_MASTER diff --git a/avr/devices/t03/defs.asm b/avr/devices/t03/defs.asm index 48650a8..d5a774a 100644 --- a/avr/devices/t03/defs.asm +++ b/avr/devices/t03/defs.asm @@ -59,6 +59,16 @@ +; --------------------------------------------------------------------------- +; LED activity module + +.equ LED_ACTIVITY_DDR = DDRB +.equ LED_ACTIVITY_PORT = PORTB +.equ LED_ACTIVITY_PORTIN = PINB +.equ LED_ACTIVITY_PINNUM = PORTB2 + + + ; --------------------------------------------------------------------------- ; COM module From 32a0ad5eae6f6ee6a3aff78a5d224dc33f58ecdf Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 25 Aug 2025 11:24:53 +0200 Subject: [PATCH 155/196] added comments, removed unused code. --- avr/modules/com2w/com2w.asm | 48 +++---------------------------------- 1 file changed, 3 insertions(+), 45 deletions(-) diff --git a/avr/modules/com2w/com2w.asm b/avr/modules/com2w/com2w.asm index a71e181..a1d4cbd 100644 --- a/avr/modules/com2w/com2w.asm +++ b/avr/modules/com2w/com2w.asm @@ -174,6 +174,7 @@ com2wReceiveNextPkg: ; msg received, alloc buffer for it rcall NET_Buffer_Alloc ; R16=buffer num (R16, R17, X) brcs com2wReceiveNextPkg_gotBuffer + ; out of memory ldi r16, NET_IFACE_OFFS_ERR_NOBUF_LOW rcall NET_Interface_IncCounter16 ; (R24, R25) rjmp com2wReceiveNextPkg_end @@ -187,8 +188,8 @@ com2wReceiveNextPkg_gotBuffer: push zh mov zl, yl mov zh, yh - adiw zh:zl, COM2W_IFACE_OFFS_BUFFER - adiw xh:xl, 1 + adiw zh:zl, COM2W_IFACE_OFFS_BUFFER ; Z=SRC + adiw xh:xl, 1 ; X=DEST ldd r18, Z+NETMSG_OFFS_MSGLEN inc r18 inc r18 @@ -232,49 +233,6 @@ com2wReceiveNextPkg_end: -#if 0 -; --------------------------------------------------------------------------- -; @routine com2wReceiveAndCheckMsg -; -; Receive a packet into buffer pointed to by X. -; Expects interrupts to be disabled. -; -; @param R18 COM address to listen to -; @param R19 max buffer size -; @param X buffer to receive to -; @return CFLAG set if msg received, cleared on error -; @clobbers R16 (R17, R18, R19, R20, R22, R24, R25) - -com2wReceiveAndCheckMsg: - push xl - push xh - rcall com2wRecvMsg ; (r16, r17, r18, r19, r20, r22, r24, r25, X) - pop xh - pop xl - brcs com2wReceiveAndCheckMsg_recvd - ; fall-through, return with CF cleared (from com2wRecvMsg) - ret -com2wReceiveAndCheckMsg_recvd: - push xl - push xh - rcall NETMSG_CheckMessageInBuffer ; (R16, R17, R18, R19, R20, X) - pop xh - pop xl - brcs com2wReceiveAndCheckMsg_msgOk - ldi r16, NET_IFACE_OFFS_ERR_CONTENT_LOW - rcall NET_Interface_IncCounter16 ; (R24, R25) - clc - ret -com2wReceiveAndCheckMsg_msgOk: - ldi r16, NET_IFACE_OFFS_PACKETSIN_LOW - rcall NET_Interface_IncCounter16 ; (R24, R25) - sec - ret -; @end -#endif - - - ; --------------------------------------------------------------------------- ; @routine com2wSendNextPkg @global ; From 5bfb49d9e184b7f0f14834b7ad5af79a242a9edb Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 25 Aug 2025 11:25:30 +0200 Subject: [PATCH 156/196] simplified code, remove unused code. --- avr/modules/network/buffer.asm | 19 ++++++------------- avr/modules/network/iface.asm | 4 ++-- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/avr/modules/network/buffer.asm b/avr/modules/network/buffer.asm index f96c927..48c8c83 100644 --- a/avr/modules/network/buffer.asm +++ b/avr/modules/network/buffer.asm @@ -69,20 +69,12 @@ NET_Buffer_Alloc: brcc NET_Buffer_Alloc_countersSet sts netBuffersMaxUsed, r17 NET_Buffer_Alloc_countersSet: -#ifdef MODULES_LED_SIGNAL - ldi r16, T03_FLAGS_ALLOC - rcall LedSignal_ClrFlag ; (R17) -#endif pop r16 out SREG, r15 pop r15 sec ret NET_Buffer_Alloc_error: -#ifdef MODULES_LED_SIGNAL - ldi r16, T03_FLAGS_ALLOC - rcall LedSignal_SetFlag ; (R17) -#endif out SREG, r15 pop r15 clc @@ -93,7 +85,7 @@ NET_Buffer_Alloc_noIrq: ldi xh, HIGH(netBuffers) m_fixedbuf_reserve NET_BUFFERS_SIZE, NET_BUFFERS_NUM brcc NET_Buffer_Alloc_end - ldi r17, (1< not in use dec r16 breq NET_Buffer_ReleaseByAddr_release - swap r16 + swap r16 ; ref counter now back in high nibble push r17 ld r17, X - andi r17, 0x0f - or r16, r17 + andi r17, 0x0f ; keep interface number + or r16, r17 ; or interface number into R16 (R16 now complete) st X, r16 pop r17 rjmp NET_Buffer_ReleaseByAddr_done diff --git a/avr/modules/network/iface.asm b/avr/modules/network/iface.asm index 1ed7baa..4313716 100644 --- a/avr/modules/network/iface.asm +++ b/avr/modules/network/iface.asm @@ -188,9 +188,9 @@ NET_Interface_IncCounter16_end: NET_Interface_SetIfaceNumInBuffer: ldd r16, Y+NET_IFACE_OFFS_IFACENUM - andi r16, (1< Date: Mon, 25 Aug 2025 11:25:53 +0200 Subject: [PATCH 157/196] use led_activity. --- avr/modules/uart_fd/uartfd1.asm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/avr/modules/uart_fd/uartfd1.asm b/avr/modules/uart_fd/uartfd1.asm index 21cfd5a..0703c48 100644 --- a/avr/modules/uart_fd/uartfd1.asm +++ b/avr/modules/uart_fd/uartfd1.asm @@ -279,9 +279,6 @@ uartFd1CheckSkipping: cbr r16, (1< Date: Mon, 25 Aug 2025 11:26:08 +0200 Subject: [PATCH 158/196] t03: use led_activity --- avr/devices/t03/uartfd/main.asm | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/avr/devices/t03/uartfd/main.asm b/avr/devices/t03/uartfd/main.asm index 9c2ed6d..4a1e1a3 100644 --- a/avr/devices/t03/uartfd/main.asm +++ b/avr/devices/t03/uartfd/main.asm @@ -53,12 +53,12 @@ ; debug -.equ T03_FLAGS_ALLOC = 0x01 -.equ T03_FLAGS_I1_SKIPPING = 0x02 -.equ T03_FLAGS_I1_RESTARTED = 0x04 -.equ T03_FLAGS_ADDIN = 0x08 -.equ T03_FLAGS_I1_ADDOUT = 0x10 -.equ T03_FLAGS_I2_ADDOUT = 0x20 +;.equ T03_FLAGS_ALLOC = 0x01 +;.equ T03_FLAGS_I1_SKIPPING = 0x02 +;.equ T03_FLAGS_I1_RESTARTED = 0x04 +;.equ T03_FLAGS_ADDIN = 0x08 +;.equ T03_FLAGS_I1_ADDOUT = 0x10 +;.equ T03_FLAGS_I2_ADDOUT = 0x20 @@ -75,7 +75,8 @@ ;#define MODULES_COM_WITH_ADDR_PROTO ;#define MODULES_LED ;#define MODULES_LED_SIMPLE -#define MODULES_LED_SIGNAL +;#define MODULES_LED_SIGNAL +#define MODULES_LED_ACTIVITY ;#define MODULES_TWI_MASTER ;#define MODULES_LCD ;#define LCD_MINIMAL_FONT From 463385a2969b01ee2206c059a52e3277fc74dff0 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 25 Aug 2025 11:26:19 +0200 Subject: [PATCH 159/196] increment version. --- avr/version.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avr/version.asm b/avr/version.asm index 91637f8..a47d749 100644 --- a/avr/version.asm +++ b/avr/version.asm @@ -11,5 +11,5 @@ .equ FIRMWARE_VERSION_MAJOR = 2 .equ FIRMWARE_VERSION_MINOR = 0 -.equ FIRMWARE_VERSION_PATCHLEVEL = 0 +.equ FIRMWARE_VERSION_PATCHLEVEL = 1 From 64854506e596ef4f411314e834e2ba46da1f3b9d Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 25 Aug 2025 14:11:57 +0200 Subject: [PATCH 160/196] fixed recvstats message handling. --- aqhome/msg/node/m_recvstats.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/aqhome/msg/node/m_recvstats.c b/aqhome/msg/node/m_recvstats.c index 585c99e..d1c00f8 100644 --- a/aqhome/msg/node/m_recvstats.c +++ b/aqhome/msg/node/m_recvstats.c @@ -18,14 +18,14 @@ #include -#define AQH_MSG_OFFS_RECVSTATS_UID 0 /* 4 bytes */ -#define AQH_MSG_OFFS_RECVSTATS_IFACE 4 /* 1 byte */ -#define AQH_MSG_OFFS_RECVSTATS_PACKETSIN 5 /* 2 bytes */ -#define AQH_MSG_OFFS_RECVSTATS_CRCERRORS 7 /* 2 bytes */ -#define AQH_MSG_OFFS_RECVSTATS_IOERRORS 9 /* 2 bytes */ -#define AQH_MSG_OFFS_RECVSTATS_NOBUFFER 11 /* 2 bytes */ -#define AQH_MSG_OFFS_RECVSTATS_HANDLED 13 /* 2 bytes */ -#define AQH_MSG_OFFS_RECVSTATS_MISSED 15 /* 2 bytes */ +#define AQH_MSG_OFFS_RECVSTATS_UID 0 /* 4 bytes */ +#define AQH_MSG_OFFS_RECVSTATS_IFACE 4 /* 1 byte */ +#define AQH_MSG_OFFS_RECVSTATS_PACKETSIN 5 /* 2 bytes */ +#define AQH_MSG_OFFS_RECVSTATS_CRCERRORS 7 /* 2 bytes */ +#define AQH_MSG_OFFS_RECVSTATS_IOERRORS 9 /* 2 bytes */ +#define AQH_MSG_OFFS_RECVSTATS_NOBUFFER 11 /* 2 bytes */ +#define AQH_MSG_OFFS_RECVSTATS_MSGSIZEERRORS 13 /* 2 bytes */ +#define AQH_MSG_OFFS_RECVSTATS_MISSED 15 /* 2 bytes */ @@ -71,9 +71,9 @@ uint16_t AQH_RecvStatsMessage_GetNoBufferErrors(const AQH_MESSAGE *msg) -uint16_t AQH_RecvStatsMessage_GetHandled(const AQH_MESSAGE *msg) +uint16_t AQH_RecvStatsMessage_GetMsgSizeErrors(const AQH_MESSAGE *msg) { - return AQH_Message_ReadUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_HANDLED, 0); + return AQH_Message_ReadUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_MSGSIZEERRORS, 0); } @@ -89,7 +89,7 @@ void AQH_RecvStatsMessage_DumpToBuffer(const AQH_MESSAGE *msg, GWEN_BUFFER *dbuf { GWEN_Buffer_AppendArgs(dbuf, "0x%02x->0x%02x: RECVSTATS %s" - "(uid=0x%08x, dev=%d, in=%d, crc errs=%d, io errs=%d, nobuf errs=%d, handled=%d, missed=%d)\n", + "(uid=0x%08x, dev=%d, in=%d, eCrc=%d, eIo=%d, eNobuf=%d, eMsgSize=%d, eMissed=%d)\n", AQH_NodeMessage_GetSourceAddress(msg), AQH_NodeMessage_GetDestAddress(msg), sText, @@ -99,7 +99,7 @@ void AQH_RecvStatsMessage_DumpToBuffer(const AQH_MESSAGE *msg, GWEN_BUFFER *dbuf AQH_RecvStatsMessage_GetCrcErrors(msg), AQH_RecvStatsMessage_GetIoErrors(msg), AQH_RecvStatsMessage_GetNoBufferErrors(msg), - AQH_RecvStatsMessage_GetHandled(msg), + AQH_RecvStatsMessage_GetMsgSizeErrors(msg), AQH_RecvStatsMessage_GetMissed(msg)); } From 41843cbab90620a35159563f0c3fb8c4287ac054 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 25 Aug 2025 14:12:39 +0200 Subject: [PATCH 161/196] avr: added forwarder app. simpler than router app, just for forwarding messages between interfaces. mainly used by t03. --- avr/apps/0BUILD | 1 + avr/apps/forwarder/0BUILD | 15 ++ avr/apps/forwarder/main.asm | 359 +++++++++++++++++++++++++++++++++++ avr/devices/all/apps.asm | 16 +- avr/devices/all/includes.asm | 8 + avr/devices/all/main.asm | 4 + 6 files changed, 402 insertions(+), 1 deletion(-) create mode 100644 avr/apps/forwarder/0BUILD create mode 100644 avr/apps/forwarder/main.asm diff --git a/avr/apps/0BUILD b/avr/apps/0BUILD index 29dc20d..3db3ca4 100644 --- a/avr/apps/0BUILD +++ b/avr/apps/0BUILD @@ -11,6 +11,7 @@ stats router hub + forwarder diff --git a/avr/apps/forwarder/0BUILD b/avr/apps/forwarder/0BUILD new file mode 100644 index 0000000..593fe80 --- /dev/null +++ b/avr/apps/forwarder/0BUILD @@ -0,0 +1,15 @@ + + + + + + + + + main.asm + + + + + + diff --git a/avr/apps/forwarder/main.asm b/avr/apps/forwarder/main.asm new file mode 100644 index 0000000..c7a5696 --- /dev/null +++ b/avr/apps/forwarder/main.asm @@ -0,0 +1,359 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + + +; *************************************************************************** +; defines + +; --------------------------------------------------------------------------- +; network interfaces + +.equ NETDEV0_IFACENUM = 1 +.equ NETDEV1_IFACENUM = 2 + + + +; *************************************************************************** +; data + +.dseg + +; nothing so far + + + +; *************************************************************************** +; code + +.cseg + +; --------------------------------------------------------------------------- +; @routine AppForwarder_Init @global + +AppForwarder_Init: + ; set interface number for NETDEV0 + ldi r16, NETDEV0_IFACENUM + sts netInterfaceData+NET_IFACE_OFFS_IFACENUM, r16 + ; set interface number for NETDEV1 + ldi r16, NETDEV1_IFACENUM + sts netInterfaceData2+NET_IFACE_OFFS_IFACENUM, r16 + sec + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine AppForwarder_EveryDay @global +; +; @clobbers R16, R17, X + +AppForwarder_EveryDay: + ldi yl, LOW(netInterfaceData) + ldi yh, HIGH(netInterfaceData) + bigcall NET_Interface_ResetStats ; (R16, R17, X) + + ldi yl, LOW(netInterfaceData2) + ldi yh, HIGH(netInterfaceData2) + bigcall NET_Interface_ResetStats ; (R16, R17, X) + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine AppForwarder_Run @global +; +; Read messages from either interface and forward to the other one. + +AppForwarder_Run: + rjmp appForwarderCheckRecvdMsg +; @end + + + +; --------------------------------------------------------------------------- +; @routine appForwarderCheckRecvdMsg +; +; Read messages from either interface and forward to the other one. +; @return CFLAG set if something done, cleared otherwise +; @clobbers any + +appForwarderCheckRecvdMsg: + rcall NET_PeekNextIncomingMsgNum ; check read queue (bufNum->r16) + brcc appForwarderCheckRecvdMsg_ret ; no msg, jmp + rcall NET_Buffer_Locate ; (R17) + push r16 + ld r16, X ; read buffer header + andi r16, 0x0f ; keep interface number (in low nibble) + rcall appForwarderGetDeviceByIfaceNum ; Y=src interface (R17) + pop r16 + brcc appForwarderCheckRecvdMsg_ret ; interface not found + adiw xh:xl, 1 ; point to message begin + + push r16 + rcall appForwarderHandleMsgAnyDev ; check for message we should handle (ping etc) + pop r16 + + ; let system handle incoming messages + push r16 + rcall appForwarderLetSysHandleMsg + pop r16 + + ; forward to other interface + ldd r17, Y+NET_IFACE_OFFS_IFACENUM + rcall appForwarderSendToOtherDev + brcc appForwarderCheckRecvdMsg_ret ; could not add, jmp + rcall NET_GetNextIncomingMsgNum ; take off the queue + sec +appForwarderCheckRecvdMsg_ret: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appForwarderHandleMsgAnyDev @global +; +; @param Y pointer to source interface for the message +; @param X pointer to received message +; @return CFLAG set if msg handled, cleared otherwise +; @clobbers any, !X + +appForwarderHandleMsgAnyDev: + push xl + push xh + rcall appForwarderHandleMsgAnyDev_savedX + pop xh + pop xl + rjmp appForwarderHandleMsgAnyDev_end +appForwarderHandleMsgAnyDev_savedX: + adiw xh:xl, NETMSG_OFFS_CMD ; maybe move ping/reboot handling to all/main.asm? + ld r16, X + sbiw xh:xl, NETMSG_OFFS_CMD + cpi r16, NETMSG_CMD_REBOOT_REQUEST + breq appForwarderHandleMsgAnyDev_handleRebootMsg + cpi r16, NETMSG_CMD_PING + breq appForwarderHandleMsgAnyDev_handlePingMsg + cpi r16, NETMSG_CMD_CLAIM_ADDRESS + breq appForwarderHandleMsgAnyDev_handleClaimAddr + rjmp appForwarderHandleMsgAnyDev_clcRet +appForwarderHandleMsgAnyDev_handleRebootMsg: + rcall appForwarderHandleRebootRequest + ret +appForwarderHandleMsgAnyDev_handlePingMsg: + rcall appForwarderHandlePingRequest + clc + ret +appForwarderHandleMsgAnyDev_handleClaimAddr: + rcall appForwarderHandleClaimAddrRequest + clc + ret +appForwarderHandleMsgAnyDev_clcRet: + clc +appForwarderHandleMsgAnyDev_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appForwarderHandleClaimAddrRequest +; +; @param X pointer to received message +; @param Y pointer to source interface for the message +; @clobbers + +appForwarderHandleClaimAddrRequest: + rcall NETMSG_Address_Read ; R18=cmd, R19=addr(R18, R19) + lds r16, netInterfaceData+NET_IFACE_OFFS_ADDRESS + cp r19, r16 + brne appForwarderHandleClaimAddrRequest_ret + ldi r18, NETMSG_CMD_DENY_ADDRESS ; deny addr + rcall appForwarderSendAddrMsg ; (R16, R17, R18, R19, R20, R21, X, Y) +appForwarderHandleClaimAddrRequest_ret: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appForwarderSendAddrMsg +; +; @param R18 command +; @param R19 address to send +; @param Y pointer to interface to send to +; @clobbers R16 (R17, R18, R19, R20, R21, X, Y) + +appForwarderSendAddrMsg: + bigcall NET_Buffer_Alloc ; (R16, R17, X) + brcc appForwarderSendAddrMsg_end + push r16 + adiw xh:xl, 1 + bigcall NETMSG_Address_Write ; (R16, R17, R18, R19, R20, R21) + sbiw xh:xl, 1 + pop r16 + bigcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) +appForwarderSendAddrMsg_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appForwarderHandleRebootRequest +; +; Doesn't return if reboot msg is valid. +; +; @param X pointer to received message + +appForwarderHandleRebootRequest: + rcall NETMSG_RebootRequestRead + brcc appForwarderHandleRebootRequest_end + ; reboot + cli + bigjmp BOOTLOADER_ADDR +appForwarderHandleRebootRequest_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appForwarderHandlePingRequest +; +; @param X pointer to received message +; @param Y pointer to source interface for the message + +appForwarderHandlePingRequest: + ld r17, X + lds r16, (netInterfaceData+NET_IFACE_OFFS_ADDRESS) + cp r16, r17 + breq appForwarderHandlePingRequest_forMe + cpi r17, 0xff + breq appForwarderHandlePingRequest_forMe + clc + rjmp appForwarderHandlePingRequest_end +appForwarderHandlePingRequest_forMe: + adiw xh:xl, NETMSG_OFFS_SRCADDR + ld r17, X + sbiw xh:xl, NETMSG_OFFS_SRCADDR + push r17 + bigcall NET_Buffer_Alloc ; (R16, R17, X) + pop r17 + brcc appForwarderHandlePingRequest_end ; jmp on error + push r16 ; buffer num + mov r16, r17 ; DEST addr + adiw xh:xl, 1 + bigcall NETMSG_Pong_Write ; (R16, R17, R18, R19, R20, X) + sbiw xh:xl, 1 + pop r16 ; buffer num + bigcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) +appForwarderHandlePingRequest_end: + ret + + + + + +; --------------------------------------------------------------------------- +; @routine appForwarderLetSysHandleMsg +; +; @param X pointer to msg to handle (point behind the buffer header!) +; @param Y pointer to source interface for the message +; @clobbers any, !X + +appForwarderLetSysHandleMsg: + ld r16, X + cpi r16, 0xff + breq appForwarderLetSysHandleMsg_forMe + lds r17, netInterfaceData+NET_IFACE_OFFS_ADDRESS + cp r16, r17 + brne appForwarderLetSysHandleMsg_end +appForwarderLetSysHandleMsg_forMe: + push xl + push xh + rcall onMessageReceived + pop xh + pop xl + push xl + push xh + rcall mainModulesOnPacketReceived + pop xh + pop xl + push xl + push xh + rcall mainAppsOnPacketReceived + pop xh + pop xl +appForwarderLetSysHandleMsg_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appForwarderSendToOtherDev +; @param r16 buffer num +; @param r17 src interface num + +appForwarderSendToOtherDev: + ldi yl, LOW(netInterfaceData) + ldi yh, HIGH(netInterfaceData) + ldd r18, Y+NET_IFACE_OFFS_IFACENUM + andi r18, 0x0f + cp r18, r17 + breq appForwarderSendToAllDevsBut_check2 + bigcall NET_Interface_AddOutgoingMsgNum ; (R17, R18, X) + rjmp appForwarderSendToOtherDev_ret +appForwarderSendToAllDevsBut_check2: + ldi yl, LOW(netInterfaceData2) + ldi yh, HIGH(netInterfaceData2) + ldd r18, Y+NET_IFACE_OFFS_IFACENUM + andi r18, 0x0f + cp r18, r17 + breq appForwarderSendToOtherDev_ret + bigcall NET_Interface_AddOutgoingMsgNum ; (R17, R18, X) +appForwarderSendToOtherDev_ret: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine appForwarderGetDeviceByIfaceNum +; +; @param r16 interface number +; @return CFLAG set if interface found (cleared otherwise) +; @return Y pointer to interface with given number +; @clobbers r17 + +appForwarderGetDeviceByIfaceNum: + ldi yl, LOW(netInterfaceData) + ldi yh, HIGH(netInterfaceData) + ldd r17, Y+NET_IFACE_OFFS_IFACENUM + cp r16, r17 + breq appForwarderGetDeviceByIfaceNum_secRet + ldi yl, LOW(netInterfaceData2) + ldi yh, HIGH(netInterfaceData2) + ldd r17, Y+NET_IFACE_OFFS_IFACENUM + cp r16, r17 + breq appForwarderGetDeviceByIfaceNum_secRet + clc + rjmp appForwarderGetDeviceByIfaceNum_ret +appForwarderGetDeviceByIfaceNum_secRet: + sec +appForwarderGetDeviceByIfaceNum_ret: + ret +; @end + + + + diff --git a/avr/devices/all/apps.asm b/avr/devices/all/apps.asm index 1cc7ebe..ca63ec3 100644 --- a/avr/devices/all/apps.asm +++ b/avr/devices/all/apps.asm @@ -37,6 +37,10 @@ initApps: bigcall AppHub_Init #endif +#ifdef APPS_FORWARDER + bigcall AppForwarder_Init +#endif + #ifdef APPS_MOTION bigcall AppMotion_Init #endif @@ -79,7 +83,17 @@ runApps: #endif #ifdef APPS_HUB - bigcall AppHub_Run + push r16 + bigcall AppHub_Run + pop r16 + sbci r16, 0 ; decrease r16 only if CFLAG set +#endif + +#ifdef APPS_FORWARDER + push r16 + bigcall AppForwarder_Run + pop r16 + sbci r16, 0 ; decrease r16 only if CFLAG set #endif ; add more modules here diff --git a/avr/devices/all/includes.asm b/avr/devices/all/includes.asm index bbbf16e..e765f78 100644 --- a/avr/devices/all/includes.asm +++ b/avr/devices/all/includes.asm @@ -336,6 +336,14 @@ #endif +#ifdef APPS_FORWARDER +.include "apps/forwarder/main.asm" +.include "modules/network/msg/reboot-r.asm" +.include "modules/network/msg/reboot-d.asm" +.include "modules/network/msg/pong-w.asm" +#endif + + #ifdef APPS_REPORTSENSORS .include "apps/reportsensors/data.asm" .include "apps/reportsensors/main.asm" diff --git a/avr/devices/all/main.asm b/avr/devices/all/main.asm index b31182b..0e5d96e 100644 --- a/avr/devices/all/main.asm +++ b/avr/devices/all/main.asm @@ -250,6 +250,10 @@ sysOnEveryDay: bigcall AppRouter_EveryDay #endif +#ifdef APPS_FORWARDER + bigcall AppForwarder_EveryDay +#endif + bigjmp onEveryDay ; @end From 86741a0e5051ada56a8b104f8a496f29da4c919c Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 25 Aug 2025 14:13:08 +0200 Subject: [PATCH 162/196] t03: use forwarder app. --- avr/devices/t03/uartfd/main.asm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/avr/devices/t03/uartfd/main.asm b/avr/devices/t03/uartfd/main.asm index 4a1e1a3..81bb6fd 100644 --- a/avr/devices/t03/uartfd/main.asm +++ b/avr/devices/t03/uartfd/main.asm @@ -94,7 +94,8 @@ #define MODULES_UARTFD1 #define APPS_STATS ;#define APPS_NETWORK -#define APPS_ROUTER +;#define APPS_ROUTER +#define APPS_FORWARDER From 809439fd26edfb2bbc08b8638d28b8564afb8091 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 1 Sep 2025 23:20:38 +0200 Subject: [PATCH 163/196] aqhome-nodes: handle new statistics messages. --- apps/aqhome-nodes/server.c | 70 +++++++++++++---------------------- aqhome/msg/node/m_recvstats.h | 2 +- 2 files changed, 27 insertions(+), 45 deletions(-) diff --git a/apps/aqhome-nodes/server.c b/apps/aqhome-nodes/server.c index 89f1d18..2e191e9 100644 --- a/apps/aqhome-nodes/server.c +++ b/apps/aqhome-nodes/server.c @@ -126,7 +126,6 @@ static void _forwardDataFromRecvStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_ static void _forwardDataFromMemStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg); static void _forwardTtyMsgToClients(AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg); static void _publishIntWithIdx(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int idx, int vModality, const char *vUnits, int v); -static void _publishDoubleWithIdx(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int idx, int vModality, const char *vUnits, double v); static void _publishInt(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int vModality, const char *vUnits, int v); static void _publishDouble(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int vModality, const char *vUnits, double v); static void _setDeviceName(AQH_VALUE *value, uint32_t uid); @@ -905,25 +904,20 @@ void _forwardDataFromSendStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_MESSAGE if (packetsOutInt) { uint32_t uid; int devNum; - double packetsOut; - double collisions; - double busy; - double collisionsPercentage=0.0; - double busyPercentage=0.0; uid=AQH_SendStatsMessage_GetUid(msg); devNum=AQH_SendStatsMessage_GetInterface(msg); - packetsOut=/*(double)*/ packetsOutInt; - collisions=/*(double)*/ AQH_SendStatsMessage_GetCollisions(msg); - busy=/*(double)*/ AQH_SendStatsMessage_GetBusyErrors(msg); - collisionsPercentage=collisions*100.0/packetsOut; - busyPercentage=busy*100.0/packetsOut; - - _publishIntWithIdx( xo, uid, "net/packetsOut", devNum, 0, NULL, packetsOutInt); - _publishIntWithIdx( xo, uid, "net/collisions", devNum, 0, NULL, (int) AQH_SendStatsMessage_GetCollisions(msg)); - _publishDoubleWithIdx(xo, uid, "net/collisionsPercent", devNum, 0, "%", collisionsPercentage); - _publishDoubleWithIdx(xo, uid, "net/busyPercent", devNum, 0, "%", busyPercentage); + if (devNum==0) { + _publishInt(xo, uid, "net/packetsOut", 0, NULL, packetsOutInt); + _publishInt(xo, uid, "net/collisions", 0, NULL, (int) AQH_SendStatsMessage_GetCollisions(msg)); + _publishInt(xo, uid, "net/busy", 0, NULL, (int) AQH_SendStatsMessage_GetBusyErrors(msg)); + } + else { + _publishIntWithIdx(xo, uid, "net/packetsOut", devNum, 0, NULL, packetsOutInt); + _publishIntWithIdx(xo, uid, "net/collisions", devNum, 0, NULL, (int) AQH_SendStatsMessage_GetCollisions(msg)); + _publishIntWithIdx(xo, uid, "net/busy", devNum, 0, NULL, (int) AQH_SendStatsMessage_GetBusyErrors(msg)); + } } } @@ -937,26 +931,26 @@ void _forwardDataFromRecvStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_MESSAGE if (packetsInInt) { uint32_t uid; int devNum; - double packetsIn; - double crcErrors; - double ioErrors; - double crcErrorsPercentage=0.0; - double ioErrorsPercentage=0.0; uid=AQH_RecvStatsMessage_GetUid(msg); devNum=AQH_RecvStatsMessage_GetInterface(msg); - packetsIn=/*(double)*/ packetsInInt; - crcErrors=/*(double)*/AQH_RecvStatsMessage_GetCrcErrors(msg); - ioErrors=/*(double)*/AQH_RecvStatsMessage_GetIoErrors(msg); - crcErrorsPercentage=crcErrors*100.0/packetsIn; - ioErrorsPercentage=ioErrors*100.0/packetsIn; - - _publishIntWithIdx( xo, uid, "net/packetsIn", devNum, 0, NULL, packetsInInt); - _publishIntWithIdx( xo, uid, "net/crcerrors", devNum, 0, NULL, (int) AQH_RecvStatsMessage_GetCrcErrors(msg)); - _publishIntWithIdx( xo, uid, "net/ioerrors", devNum, 0, NULL, (int) AQH_RecvStatsMessage_GetIoErrors(msg)); - _publishDoubleWithIdx(xo, uid, "net/crcerrorsPercent", devNum, 0, "%", crcErrorsPercentage); - _publishDoubleWithIdx(xo, uid, "net/ioerrorsPercent", devNum, 0, "%", ioErrorsPercentage); + if (devNum==0) { + _publishInt(xo, uid, "net/packetsIn", 0, NULL, packetsInInt); + _publishInt(xo, uid, "net/crcErrors", 0, NULL, (int) AQH_RecvStatsMessage_GetCrcErrors(msg)); + _publishInt(xo, uid, "net/ioErrors", 0, NULL, (int) AQH_RecvStatsMessage_GetIoErrors(msg)); + _publishInt(xo, uid, "net/nobufferErrors", 0, NULL, (int) AQH_RecvStatsMessage_GetNoBufferErrors(msg)); + _publishInt(xo, uid, "net/msgSizeErrors", 0, NULL, (int) AQH_RecvStatsMessage_GetMsgSizeErrors(msg)); + _publishInt(xo, uid, "net/missed", 0, NULL, (int) AQH_RecvStatsMessage_GetMissed(msg)); + } + else { + _publishIntWithIdx(xo, uid, "net/packetsIn", devNum, 0, NULL, packetsInInt); + _publishIntWithIdx(xo, uid, "net/crcErrors", devNum, 0, NULL, (int) AQH_RecvStatsMessage_GetCrcErrors(msg)); + _publishIntWithIdx(xo, uid, "net/ioErrors", devNum, 0, NULL, (int) AQH_RecvStatsMessage_GetIoErrors(msg)); + _publishIntWithIdx(xo, uid, "net/nobufferErrors", devNum, 0, NULL, (int) AQH_RecvStatsMessage_GetNoBufferErrors(msg)); + _publishIntWithIdx(xo, uid, "net/msgSizeErrors", devNum, 0, NULL, (int) AQH_RecvStatsMessage_GetMsgSizeErrors(msg)); + _publishIntWithIdx(xo, uid, "net/missed", devNum, 0, NULL, (int) AQH_RecvStatsMessage_GetMissed(msg)); + } } } @@ -986,18 +980,6 @@ void _publishIntWithIdx(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, in -void _publishDoubleWithIdx(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int idx, int vModality, const char *vUnits, double v) -{ - GWEN_BUFFER *tbuf; - - tbuf=GWEN_Buffer_new(0, 256, 0, 1); - GWEN_Buffer_AppendArgs(tbuf, "%s%d", vPath, idx); - _publishDouble(xo, uid, GWEN_Buffer_GetStart(tbuf), vModality, vUnits, v); - GWEN_Buffer_free(tbuf); -} - - - void _publishInt(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int vModality, const char *vUnits, int v) { _publishDouble(xo, uid, vPath, vModality, vUnits, /*(double)*/ v); diff --git a/aqhome/msg/node/m_recvstats.h b/aqhome/msg/node/m_recvstats.h index 58968de..c6dcbbe 100644 --- a/aqhome/msg/node/m_recvstats.h +++ b/aqhome/msg/node/m_recvstats.h @@ -23,7 +23,7 @@ AQHOME_API uint16_t AQH_RecvStatsMessage_GetPacketsIn(const AQH_MESSAGE *msg); AQHOME_API uint16_t AQH_RecvStatsMessage_GetCrcErrors(const AQH_MESSAGE *msg); AQHOME_API uint16_t AQH_RecvStatsMessage_GetIoErrors(const AQH_MESSAGE *msg); AQHOME_API uint16_t AQH_RecvStatsMessage_GetNoBufferErrors(const AQH_MESSAGE *msg); -AQHOME_API uint16_t AQH_RecvStatsMessage_GetHandled(const AQH_MESSAGE *msg); +AQHOME_API uint16_t AQH_RecvStatsMessage_GetMsgSizeErrors(const AQH_MESSAGE *msg); AQHOME_API uint16_t AQH_RecvStatsMessage_GetMissed(const AQH_MESSAGE *msg); AQHOME_API void AQH_RecvStatsMessage_DumpToBuffer(const AQH_MESSAGE *msg, GWEN_BUFFER *dbuf, const char *sText); From 246d00a2207141198a1fad3bf7836c842d9a3698 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 1 Sep 2025 23:21:25 +0200 Subject: [PATCH 164/196] avr: allow for big flash roms. --- avr/apps/hub/main.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avr/apps/hub/main.asm b/avr/apps/hub/main.asm index 7779153..fd8aac3 100644 --- a/avr/apps/hub/main.asm +++ b/avr/apps/hub/main.asm @@ -622,7 +622,7 @@ appHubHandleRecvdMsg: ; let other apps and modules handle message push xl push xh - rcall mainHandleMessages + bigcall mainHandleMessages pop xh pop xl pop r18 From 9600be78a556c0d495954a5154a5f844f9a24749 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 1 Sep 2025 23:21:52 +0200 Subject: [PATCH 165/196] more work on m644p. --- avr/devices/all/hw_m644p.asm | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/avr/devices/all/hw_m644p.asm b/avr/devices/all/hw_m644p.asm index ccb7f71..f681530 100644 --- a/avr/devices/all/hw_m644p.asm +++ b/avr/devices/all/hw_m644p.asm @@ -103,13 +103,11 @@ systemSetupTimer0: ; setup timer for IRQ every 100ms ldi r16, 1 sts baseTimerModuleReloadValue, r16 sts baseTimerModuleTickCounter, r16 -.endif -; ; Settings for clock 8Mhz ; use timer0 with OCR0=78 (irq every 9.984 millisecs), baseTimerModuleReloadValue 10 ; -.if clock == 8000000 +.elif clock == 8000000 ; CMP interrupt about every 10ms ldi r16, 78-1 outr OCR0A, r16 @@ -117,6 +115,24 @@ systemSetupTimer0: ; setup timer for IRQ every 100ms ldi r16, 10 sts baseTimerModuleReloadValue, r16 sts baseTimerModuleTickCounter, r16 +.elif clock == 10000000 + ; CMP-A interrupt about every 10ms + ldi r16, 98-1 ; (10,000,000/1024)/10 = 97.65625 + outr OCR0A, r16 + + ldi r16, 10 + sts baseTimerModuleReloadValue, r16 + sts baseTimerModuleTickCounter, r16 +.elif clock == 20000000 + ; CMP-A interrupt about every 5ms + ldi r16, 98-1 + outr OCR0A, r16 + + ldi r16, 20 + sts baseTimerModuleReloadValue, r16 + sts baseTimerModuleTickCounter, r16 +.else + .error "Unhandled clock frequency" .endif ldi r16, (1< Date: Mon, 1 Sep 2025 23:22:21 +0200 Subject: [PATCH 166/196] n21: don't send ADC values. --- avr/devices/n21/main/main.asm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/avr/devices/n21/main/main.asm b/avr/devices/n21/main/main.asm index 4b75f03..6b6639a 100644 --- a/avr/devices/n21/main/main.asm +++ b/avr/devices/n21/main/main.asm @@ -47,7 +47,7 @@ ; --------------------------------------------------------------------------- ; generic -.equ NET_BUFFERS_NUM = 6 +.equ NET_BUFFERS_NUM = 10 .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) @@ -184,10 +184,11 @@ onEveryDay: onEveryMinute: - lds r16, tcrt1kLastValue - ldi r17, VALUE_ID_ADC - ldi r22, AQHOME_VALUETYPE_UNKNOWN ; VALUE TYPE - rjmp Main_Send8BitValueReport +; lds r16, tcrt1kLastValue +; ldi r17, VALUE_ID_ADC +; ldi r22, AQHOME_VALUETYPE_UNKNOWN ; VALUE TYPE +; rcall Main_Send8BitValueReport + ret From 5ae7f821e4a90704c3638cec631449a1a7032bf3 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 1 Sep 2025 23:22:57 +0200 Subject: [PATCH 167/196] s03: more work. --- avr/devices/s03/defs.asm | 10 ++++++++++ avr/devices/s03/main/main.asm | 10 +++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/avr/devices/s03/defs.asm b/avr/devices/s03/defs.asm index b284a31..2079869 100644 --- a/avr/devices/s03/defs.asm +++ b/avr/devices/s03/defs.asm @@ -61,6 +61,16 @@ +; --------------------------------------------------------------------------- +; LED activity module + +.equ LED_ACTIVITY_DDR = DDRB +.equ LED_ACTIVITY_PORT = PORTB +.equ LED_ACTIVITY_PORTIN = PINB +.equ LED_ACTIVITY_PINNUM = PORTB1 + + + ; --------------------------------------------------------------------------- ; COM module diff --git a/avr/devices/s03/main/main.asm b/avr/devices/s03/main/main.asm index c8773f1..35a9e4d 100644 --- a/avr/devices/s03/main/main.asm +++ b/avr/devices/s03/main/main.asm @@ -36,7 +36,7 @@ .equ NET_BUFFERS_NUM = 96 .equ NET_MSGNUMINBUF_SIZE = 64 ; max buffer nums in ringbuffer (global incoming) .equ NET_IFACE_OUTMSGBUF_SIZE = 16 ; max buffer nums in ringbuffer (per interface outbound) -.equ COM2WN_IO_RINGBUFFER_SIZE = 128 +.equ COM2WN_IO_RINGBUFFER_SIZE = 240 @@ -44,12 +44,14 @@ ; firmware settings including list of modules used #define MAIN_WITHOUT_MSG_HANDLING ; message handling done here +#define APP_STATS_NETDEV2 ; #define MODULES_TIMER #define MODULES_CLOCK ;#define MODULES_XRAM ;#define MODULES_HEAP #define MODULES_LED_SIMPLE +#define MODULES_LED_ACTIVITY #define MODULES_NETWORK #define MODULES_COM2WN ;#define MODULES_COMONUART0 @@ -74,7 +76,7 @@ ;#define APPS_NETWORK ;#define APPS_MOTION ;#define APPS_REPORTSENSORS -;#define APPS_STATS +#define APPS_STATS #define APPS_HUB @@ -217,6 +219,7 @@ onEveryLoop: .include "devices/all/hw_m644p.asm" .include "devices/all/includes.asm" +;.include "modules/network/msg/device-w.asm" ;.include "common/debug.asm" ;.include "modules/lcd2/font/font2.asm" @@ -236,7 +239,8 @@ onEveryLoop: ;.equ netInterfaceData = netUartIface ;.equ netInterfaceData = uart_bitbang_iface -.equ netInterfaceData = com2w0_iface +.equ netInterfaceData = com2w6_iface +.equ netInterfaceData2 = com2w5_iface From 3270a71cb0a54afa7d45b3bfaead413a324f4c14 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 1 Sep 2025 23:23:30 +0200 Subject: [PATCH 168/196] com2w: simplified module. --- avr/modules/com2w/com2w.asm | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/avr/modules/com2w/com2w.asm b/avr/modules/com2w/com2w.asm index a1d4cbd..8545059 100644 --- a/avr/modules/com2w/com2w.asm +++ b/avr/modules/com2w/com2w.asm @@ -10,6 +10,8 @@ #ifndef AVR_MODULES_COM2W_COM2W_H #define AVR_MODULES_COM2W_COM2W_H +; only currently working com2w module! + .macro M_COM2WCLKSETLOW @@ -210,7 +212,6 @@ com2wReceiveNextPkg_copyLoop: #ifdef MODULES_LED_ACTIVITY rcall LedActivity_Trigger ; (r16) #endif - sec rjmp com2wReceiveNextPkg_end com2wReceiveNextPkg_eCrc: push r16 @@ -226,7 +227,6 @@ com2wReceiveNextPkg_eMissed: ; fall-through to release buffer com2wReceiveNextPkg_relBuffer: rcall NET_Buffer_ReleaseByNum ; (R16, X) - clc com2wReceiveNextPkg_end: ret ; @end @@ -370,7 +370,6 @@ com2wSendByte_sent: ; Receive a packet into buffer pointed to by X. ; Expects interrupts to be disabled. ; -; @param R18 COM address to listen to ; @param R19 max buffer size ; @param X buffer to receive to ; @return CFLAG set if msg received, cleared on error (see R16) @@ -378,30 +377,16 @@ com2wSendByte_sent: ; @clobbers r16, r17, r18, r19, r20, r22, r24, r25, X com2wRecvMsg: - mov r21, r18 ; address + ; check buffer size + subi r19, 2 + brcs com2wRecvMsg_eBadSize ; read destination address rcall com2wRecvByte ; (r17, r18, r20, r22) brcc com2wRecvMsg_eIo - ; check destination address -rjmp com2wRecvMsg_forMe ; DEBUG: don't check address - cp r16, r21 - breq com2wRecvMsg_forMe - cpi r16, 0xff - breq com2wRecvMsg_forMe - clr r16 - rjmp com2wRecvMsg_clcRet -com2wRecvMsg_forMe: - ; store in buffer - subi r19, 1 - brcs com2wRecvMsg_eBadSize st X+, r16 - ; read remaining msg size rcall com2wRecvByte ; (r17, r18, r20, r22) brcc com2wRecvMsg_eIo - ; store in buffer - subi r19, 1 - brcs com2wRecvMsg_eBadSize st X+, r16 inc r16 ; account for CRC byte sub r19, r16 @@ -468,10 +453,10 @@ com2wRecvByte: ldi r17, 8 clr r16 com2wRecvByte_loop: - ldi r20, 50 ; wait up to 500us for clock low + ldi r20, 100 ; wait up to 1ms for clock low rcall com2wWaitForClockLowMulti10Us ; (R20, R22) brcc com2wRecvByte_end - ldi r20, 100 ; wait up to 1ms for clock high + ldi r20, 100 ; wait up to 1ms for clock high rcall com2wWaitForClockHighMulti10Us ; (R20, R22) brcc com2wRecvByte_end ; handle received bit From 81669a5442a3d5099de407ad5340e3100f14ca5c Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 1 Sep 2025 23:24:15 +0200 Subject: [PATCH 169/196] avr: first try irq driven com2w interface. probably doesn't work like that but that's for later. --- avr/modules/com2w/com2wi.asm | 579 +++++++++++++++++++++++++++++++++++ 1 file changed, 579 insertions(+) create mode 100644 avr/modules/com2w/com2wi.asm diff --git a/avr/modules/com2w/com2wi.asm b/avr/modules/com2w/com2wi.asm new file mode 100644 index 0000000..aa66cfc --- /dev/null +++ b/avr/modules/com2w/com2wi.asm @@ -0,0 +1,579 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + +; work in progress! + +#ifndef AVR_MODULES_COM2W_COM2WI_H +#define AVR_MODULES_COM2W_COM2WI_H + + +.equ COM2WI_BUFFER_SIZE = NET_BUFFERS_SIZE-1 + +.equ COM2WI_R_MAX_WAIT_HI_TIME = 50 ; max 1ms +.equ COM2WI_S_MAX_WAIT_HI_TIME = 50 ; max 1ms +.equ COM2WI_S_MAX_WAIT_LO_TIME = 50 ; max 1ms + + + +.equ COM2WI_STATE_IDLE = 0 + +.equ COM2WI_STATE_R_WAITFORCLOCKLO = 1 +.equ COM2WI_STATE_R_WAITFORCLOCKHI = 2 +.equ COM2WI_STATE_R_MSGRECVD = 3 + +.equ COM2WI_STATE_S_WAITFORCLOCKLO = 4 +.equ COM2WI_STATE_S_WAITFORCLOCKHI = 5 + +.equ COM2WI_STATE_W_WAITFREELINE = 6 +.equ COM2WI_STATE_W_SENDCLOCKLO = 7 +.equ COM2WI_STATE_W_SENDCLOCKHI = 8 + +.equ COM2WI_STATE_W_WAITBETWEENBITS = 9 +.equ COM2WI_STATE_W_WAITBETWEENBYTES = 10 +.equ COM2WI_STATE_W_MSGSENT = 11 + +.equ COM2WI_STATE_COUNT = 12 + + + +.equ COM2WI_IFACE_OFFS_BEGIN = NET_IFACE_SIZE +.equ COM2WI_IFACE_OFFS_STATE = COM2WI_IFACE_OFFS_BEGIN+0 +.equ COM2WI_IFACE_OFFS_STATETIMER = COM2WI_IFACE_OFFS_BEGIN+1 +.equ COM2WI_IFACE_OFFS_STATECOUNTER = COM2WI_IFACE_OFFS_BEGIN+2 +.equ COM2WI_IFACE_OFFS_PINMASK_CLK = COM2WI_IFACE_OFFS_BEGIN+3 +.equ COM2WI_IFACE_OFFS_PINMASK_DATA = COM2WI_IFACE_OFFS_BEGIN+4 +.equ COM2WI_IFACE_OFFS_BITCOUNTER = COM2WI_IFACE_OFFS_BEGIN+5 +.equ COM2WI_IFACE_OFFS_CURRBYTE = COM2WI_IFACE_OFFS_BEGIN+6 +.equ COM2WI_IFACE_OFFS_BUFPOS_LOW = COM2WI_IFACE_OFFS_BEGIN+7 +.equ COM2WI_IFACE_OFFS_BUFPOS_HIGH = COM2WI_IFACE_OFFS_BEGIN+8 +.equ COM2WI_IFACE_OFFS_BUFUSED = COM2WI_IFACE_OFFS_BEGIN+9 +.equ COM2WI_IFACE_OFFS_BUFLEFT = COM2WI_IFACE_OFFS_BEGIN+10 +.equ COM2WI_IFACE_OFFS_BUFFER = COM2WI_IFACE_OFFS_BEGIN+11 +.equ COM2WI_IFACE_SIZE = COM2WI_IFACE_OFFS_BUFFER+COM2WI_BUFFER_SIZE + + + + +; --------------------------------------------------------------------------- +; @macro mCOM2WI_INIT +; +; @param @0 interface number (beginning with 0) + +.macro mCOM2WI_INIT + ldi yl, LOW(com2wi@0_iface) + ldi yh, HIGH(com2wi@0_iface) + rcall com2wiInit + ldi r16, COM_MASK_CLK@0 + std Y+COM2WI_IFACE_OFFS_PINMASK_CLK, r16 + ldi r16, COM_MASK_DATA@0 + std Y+COM2WI_IFACE_OFFS_PINMASK_DATA, r16 + ldi r16, COM_MASK_IRQ@0 + std Y+COM2WI_IFACE_OFFS_PINMASK_IRQ, r16 +.endmacro +; @end + + + + + +.dseg + + + +com2wi0_iface: .byte COM2WI_IFACE_SIZE + + + +.cseg + + + +; --------------------------------------------------------------------------- +; @routine COM2WI_Init + +COM2WI_Init: + mCOM2WI_INIT 0 + + rcall com2wiSetupTimer1 + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine com2wiInit + +com2wiInit: + rcall com2wiSetupLines + + ldi r16, COM2WI_STATE_IDLE + std Y+COM2WI_IFACE_OFFS_STATE, r16 + + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine com2wiSetupLines + +com2wiSetupLines: + ; setup CLK line (as input, disable internal pull-up resistor) +.ifdef COM_CLK_PUE + ldd r16, Y+COM2WI_IFACE_OFFS_PINMASK_CLK + com r16 + inr r17, COM_CLK_PUE + and r17, r16 + outr COM_CLK_PUE, r17 +.endif + rcall com2wiClkSetHigh + + ; setup DATA line (as input, disable internal pull-up resistor) +.ifdef COM_DATA_PUE + ldd r16, Y+COM2WI_IFACE_OFFS_PINMASK_DATA + com r16 + inr r17, COM_DATA_PUE + and r17, r16 + outr COM_DATA_PUE, r17 +.endif + rcall com2wiDataSetHigh + + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine com2wiSetupTimer1 +; +; setup timer for IRQ every 20us + +com2wiSetupTimer1: + ; CTC mode, no prescaler, OCR1A=100 (every 20us at 20MHz) + ldi r16, 0 + outr TCCR1A, r16 ; WGM11=0, WGM10=0 + ldi r16, (0< Date: Mon, 1 Sep 2025 23:25:02 +0200 Subject: [PATCH 170/196] avr: more work on com2wn module. --- avr/modules/com2w/com2wn_data.asm | 1 + avr/modules/com2w/com2wn_init.asm | 6 ++- avr/modules/com2w/com2wn_irq.asm | 18 ++++++++ avr/modules/com2w/com2wn_recv.asm | 4 +- avr/modules/com2w/com2wn_run.asm | 17 ++++--- avr/modules/com2w/com2wn_wait.asm | 75 ------------------------------- 6 files changed, 38 insertions(+), 83 deletions(-) diff --git a/avr/modules/com2w/com2wn_data.asm b/avr/modules/com2w/com2wn_data.asm index 6b92875..d28d19b 100644 --- a/avr/modules/com2w/com2wn_data.asm +++ b/avr/modules/com2w/com2wn_data.asm @@ -17,6 +17,7 @@ com2wnIoRingBuffer: .byte RINGBUFFERY_SIZE+COM2WN_IO_RINGBUFFER_SIZE com2wnIoCurrentClockStates: .byte 1 com2wnIoLastClockStates: .byte 1 +com2wnIoDisabledClockMask: .byte 1 com2wnIoFlags: .byte 1 diff --git a/avr/modules/com2w/com2wn_init.asm b/avr/modules/com2w/com2wn_init.asm index 4af9982..f9f97a9 100644 --- a/avr/modules/com2w/com2wn_init.asm +++ b/avr/modules/com2w/com2wn_init.asm @@ -51,6 +51,7 @@ COM2WN_Init: clr r16 sts com2wnIoFlags, r16 + sts com2wnIoDisabledClockMask, r16 ldi yl, LOW(com2wnIoRingBuffer) ldi yh, HIGH(com2wnIoRingBuffer) @@ -85,6 +86,8 @@ COM2WN_Init: mCOM2WN_INIT 7 .endif + rcall com2wnSetupIrq + ret ; @end @@ -100,8 +103,7 @@ com2wnInit: rcall com2wSetMode ; (R17) rcall com2wSetupLines - rcall com2wnSetupIrq - + rcall com2wnEnableClkIrq ret ; @end diff --git a/avr/modules/com2w/com2wn_irq.asm b/avr/modules/com2w/com2wn_irq.asm index 3f5fb31..db5409c 100644 --- a/avr/modules/com2w/com2wn_irq.asm +++ b/avr/modules/com2w/com2wn_irq.asm @@ -46,6 +46,13 @@ com2wnSetupIrq: com2wnEnableClkIrq: push r16 push r17 + ; clear this interfaces CLK bit in com2wnIoDisabledClockMask + ldd r16, Y+COM2W_IFACE_OFFS_PINMASK_CLK + com r16 + lds r17, com2wnIoDisabledClockMask + and r17, r16 + sts com2wnIoDisabledClockMask, r17 + ; enable pin change irq ldd r16, Y+COM2W_IFACE_OFFS_PINMASK_IRQ inr r17, COM_IRQ_ADDR_CLK or r17, r16 @@ -70,6 +77,13 @@ com2wnDisableClkIrq: inr r17, COM_IRQ_ADDR_CLK and r17, r16 ; clear bit for clock line outr COM_IRQ_ADDR_CLK, r17 + + ; set this interfaces CLK bit in com2wnIoDisabledClockMask + ldd r16, Y+COM2W_IFACE_OFFS_PINMASK_CLK + lds r17, com2wnIoDisabledClockMask + or r17, r16 + sts com2wnIoDisabledClockMask, r17 + pop r17 pop r16 ret @@ -93,6 +107,8 @@ COM2WN_ClkChangeIsr: push r16 inr r16, COM_CLK_INPUT ; read clk state early push r17 + lds r17, com2wnIoDisabledClockMask ; mask disabled interfaces + or r16, r17 push r18 push xl push xh @@ -125,6 +141,8 @@ COM2WN_ClkChangeIsr_popRet: inr r16, COM_CLK_INPUT ; read clk state early inr r17, COM_DATA_INPUT ; read data state early push r18 + lds r18, com2wnIoDisabledClockMask ; mask disabled interfaces + or r16, r18 push xl push xh push yl diff --git a/avr/modules/com2w/com2wn_recv.asm b/avr/modules/com2w/com2wn_recv.asm index 4e60e59..011871a 100644 --- a/avr/modules/com2w/com2wn_recv.asm +++ b/avr/modules/com2w/com2wn_recv.asm @@ -120,6 +120,9 @@ com2wnReadNextBit_end: ; @clobbers r16, r17, r18, X com2wnByteRecvd: +push r16 + rcall LedActivity_Trigger +pop r16 ldd xl, Y+COM2W_IFACE_OFFS_BUFPOS_LOW ldd xh, Y+COM2W_IFACE_OFFS_BUFPOS_HIGH ldd r17, Y+COM2W_IFACE_OFFS_BUFLEFT @@ -165,7 +168,6 @@ com2wnByteRecvd_overflow: ldi r16, NET_IFACE_OFFS_ERR_MISSED_LOW rjmp com2wnByteRecvd_error com2wnByteRecvd_eMsgSize: - ldi r16, NET_IFACE_OFFS_ERR_MSGSIZE_LOW com2wnByteRecvd_error: push r24 diff --git a/avr/modules/com2w/com2wn_run.asm b/avr/modules/com2w/com2wn_run.asm index a3e377b..c6f9141 100644 --- a/avr/modules/com2w/com2wn_run.asm +++ b/avr/modules/com2w/com2wn_run.asm @@ -170,11 +170,16 @@ com2wnLowLevelRun_loop: ; loop through all interfaces and r21, r18 ; CLK for interface changed? breq com2wnLowLevelRun_nextIface push r16 - push r18 - push r19 - rcall com2wnActOnClock ; (r16, r17, r18, X) - pop r19 - pop r18 + push r17 + push r18 + push r19 + and r16, r20 ; only keep CLK mask for current interface + ldd r20, Y+COM2W_IFACE_OFFS_PINMASK_DATA + and r17, r20 ; only keep DATA mask for current interface + rcall com2wnActOnClock ; (r16, r17, r18, X) + pop r19 + pop r18 + pop r17 pop r16 com2wnLowLevelRun_nextIface: ldi r20, COM2W_IFACE_SIZE @@ -265,6 +270,8 @@ com2wnStartReading: std Y+COM2W_IFACE_OFFS_BUFLEFT, r16 clr r16 std Y+COM2W_IFACE_OFFS_BUFUSED, r16 + std Y+COM2W_IFACE_OFFS_BITCOUNTER, r16 + std Y+COM2W_IFACE_OFFS_CURRBYTE, r16 ldi r16, COM2W_MODE_READING rcall com2wSetMode ; (R17) ret diff --git a/avr/modules/com2w/com2wn_wait.asm b/avr/modules/com2w/com2wn_wait.asm index 365589f..58cebcd 100644 --- a/avr/modules/com2w/com2wn_wait.asm +++ b/avr/modules/com2w/com2wn_wait.asm @@ -163,81 +163,6 @@ com2wWaitForClockLowMulti10Us_stateReached: - - - - - - - - - - -.if clock > 1000000 -; begin version for > 1000000 Hz - ldi r20, LOW(clock/1000000) - ldd r22, Y+COM2W_IFACE_OFFS_PINMASK_CLK ; +2 -com2wWaitForClockLowMulti10Us_loop0: - push r20 ; +2 -com2wWaitForClockLowMulti10Us_loop: ; 10 cycles per loop - inr r16, COM_CLK_INPUT ; +1 (if low port, +2 if high port) - and r16, r22 ; +1 - breq com2wWaitForClockLowMulti10Us_stateReached ; +1 if FALSE, +2 if TRUE - - inr r16, COM_CLK_INPUT ; +1 (if low port, +2 if high port) - and r16, r22 ; +1 - breq com2wWaitForClockLowMulti10Us_stateReached ; +1 if FALSE, +2 if TRUE - - nop ; +1 - - dec r20 ; +1 - brne com2wWaitForClockLowMulti10Us_loop ; +2 if TRUE, +1 if FALSE - pop r20 ; +2 - dec r20 ; +1 - brne com2wWaitForClockLowMulti10Us_loop0 ; +1 if FALSE, +2 if TRUE - clc ; +1 - ret ; +4 -com2wWaitForClockLowMulti10Us_stateReached: - pop r20 - sec ; +1 - ret ; +4 -; end version for > 1000000 Hz -.elif clock < 1000000 - .error "Clock speed too low" -.else -; begin version for 1000000 Hz - ldd r22, Y+COM2W_IFACE_OFFS_PINMASK_CLK ; +2 -com2wWaitForClockLowMulti10Us_loop: ; 10 cycles per loop - inr r16, COM_CLK_INPUT ; +1 (if low port, +2 if high port) - and r16, r22 ; +1 - breq com2wWaitForClockLowMulti10Us_stateReached ; +1 if FALSE, +2 if TRUE - - inr r16, COM_CLK_INPUT ; +1 (if low port, +2 if high port) - and r16, r22 ; +1 - breq com2wWaitForClockLowMulti10Us_stateReached ; +1 if FALSE, +2 if TRUE - - nop ; +1 - - dec r20 ; +1 - brne com2wWaitForClockLowMulti10Us_loop ; +2 if TRUE, +1 if FALSE - clc ; +1 - ret ; +4 -com2wWaitForClockLowMulti10Us_stateReached: - sec ; +1 - ret ; +4 -; end version for 1000000 Hz -.endif -; @end - - - - - - - - - - #endif ; AVR_MODULES_COM2W_COM2WN_WAIT_H From eac37b99271f9afa7698f638037dbeb1f190f9e0 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 1 Sep 2025 23:25:20 +0200 Subject: [PATCH 171/196] com2w: increase buffer size. --- avr/modules/com2w/defs.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avr/modules/com2w/defs.asm b/avr/modules/com2w/defs.asm index 0021199..56b9a12 100644 --- a/avr/modules/com2w/defs.asm +++ b/avr/modules/com2w/defs.asm @@ -44,7 +44,7 @@ .equ COM2W_BUFFER_SIZE = NET_BUFFERS_SIZE-1 -.equ COM2W_IO_RINGBUFFER_SIZE = 32 +.equ COM2W_IO_RINGBUFFER_SIZE = 128 .equ COM2W_IO_FLAGS_BIT_OVR = 7 .equ COM2W_MODE_IDLE = 0 From 1612065d8a7e043159ffa8f86b52c237cb8ecf91 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 1 Sep 2025 23:25:39 +0200 Subject: [PATCH 172/196] uartfd1: add comment. --- avr/modules/uart_fd/uartfd1.asm | 1 + 1 file changed, 1 insertion(+) diff --git a/avr/modules/uart_fd/uartfd1.asm b/avr/modules/uart_fd/uartfd1.asm index 0703c48..54803c7 100644 --- a/avr/modules/uart_fd/uartfd1.asm +++ b/avr/modules/uart_fd/uartfd1.asm @@ -474,6 +474,7 @@ uartFd1FinishReading_copyLoop: st X+, r18 dec r17 brne uartFd1FinishReading_copyLoop + ; add new buffer to incoming list rcall NET_AddIncomingMsgNum brcs uartFd1FinishReading_msgSaved rcall NET_Buffer_ReleaseByNum ; (R16, X) From 33cae3ab26e2996086b575ac8c54ce1b7db8d135 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 6 Sep 2025 00:36:54 +0200 Subject: [PATCH 173/196] incremented version. --- 0BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/0BUILD b/0BUILD index 6876dd2..d0a892b 100644 --- a/0BUILD +++ b/0BUILD @@ -2,7 +2,7 @@ - + $(project_name) $(project_vmajor).$(project_vminor).$(project_vpatchlevel) From eb27d223fb187c177617dd620bc036ae4df50585 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 6 Sep 2025 00:37:39 +0200 Subject: [PATCH 174/196] aqhome-tool: added command "devicestate". --- apps/aqhome-tool/data/0BUILD | 2 + apps/aqhome-tool/data/devicestate.c | 260 ++++++++++++++++++++++++++++ apps/aqhome-tool/data/devicestate.h | 21 +++ apps/aqhome-tool/main.c | 2 + 4 files changed, 285 insertions(+) create mode 100644 apps/aqhome-tool/data/devicestate.c create mode 100644 apps/aqhome-tool/data/devicestate.h diff --git a/apps/aqhome-tool/data/0BUILD b/apps/aqhome-tool/data/0BUILD index 359c2f9..ed2824c 100644 --- a/apps/aqhome-tool/data/0BUILD +++ b/apps/aqhome-tool/data/0BUILD @@ -43,6 +43,7 @@ setdata.h moddevice.h watch.h + devicestate.h @@ -58,6 +59,7 @@ setdata.c moddevice.c watch.c + devicestate.c diff --git a/apps/aqhome-tool/data/devicestate.c b/apps/aqhome-tool/data/devicestate.c new file mode 100644 index 0000000..c6f9dcb --- /dev/null +++ b/apps/aqhome-tool/data/devicestate.c @@ -0,0 +1,260 @@ +/**************************************************************************** + * This file is part of the project AqHome. + * AqHome (c) by 2025 Martin Preuss, all rights reserved. + * + * The license for this file can be found in the file COPYING which you + * should have received along with this file. + ****************************************************************************/ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "./devicestate.h" +#include "../utils.h" + +#include "aqhome/aqhome.h" +#include "aqhome/dataclient/client.h" +#include "aqhome/msg/ipc/m_ipc.h" +#include "aqhome/msg/ipc/m_ipc_result.h" +#include "aqhome/msg/ipc/data/m_ipcd.h" +#include "aqhome/msg/ipc/data/m_ipcd_getdata.h" +#include "aqhome/msg/ipc/data/m_ipcd_multidata.h" +#include "aqhome/dataclient/client.h" + +#include +#include +#include +#include +#include + +#include + + + +/* ------------------------------------------------------------------------------------------------ + * defs + * ------------------------------------------------------------------------------------------------ + */ + +#define I18S(msg) msg +#define I18N(msg) GWEN_I18N_Translate(PACKAGE, msg) + +#define A_ARG GWEN_ARGS_FLAGS_HAS_ARGUMENT +#define A_END (GWEN_ARGS_FLAGS_HELP | GWEN_ARGS_FLAGS_LAST) +#define A_CHAR GWEN_ArgsType_Char +#define A_INT GWEN_ArgsType_Int + + + +/* ------------------------------------------------------------------------------------------------ + * forward declarations + * ------------------------------------------------------------------------------------------------ + */ + +static int _runCommand(AQH_DATACLIENT *dc); +static void _handleDevice(AQH_DATACLIENT *dc, const AQH_DEVICE *device); +static void _handleValue(AQH_DATACLIENT *dc, const AQH_DEVICE *device, const AQH_VALUE *value); +static void _printDataPoints(const uint64_t *dataPoints, uint32_t numValues); +static void _printSingleDataPoint(uint64_t timestamp, double data); + + + + +/* ------------------------------------------------------------------------------------------------ + * code + * ------------------------------------------------------------------------------------------------ + */ + +int AQH_Tool_DeviceState(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv) +{ + AQH_EVENT_LOOP *eventLoop; + AQH_DATACLIENT *dc; + int rv; + const GWEN_ARGS args[]= { + /* flags type name min max s long short_descr, long_descr */ + { A_ARG, A_CHAR, "brokerAddress", 0, 1, "t", "tcpaddress", I18S("TCP address to connect to [127.0.0.1]"), NULL}, + { A_ARG, A_INT, "brokerPort", 0, 1, "P", "tcpport", I18S("Specify the TCP port to listen on"), NULL}, + { A_ARG, A_INT, "timeout", 0, 1, "T", NULL, I18S("Specify timeout in seconds for response"), NULL}, + { A_ARG, A_CHAR, "brokerClientId", 0, 1, "c", "clientid", I18S("Specify CLIENTID"), NULL}, + { A_ARG, A_CHAR, "userId", 0, 1, "u", "userid", I18S("Specify user id"), NULL}, + { A_ARG, A_CHAR, "password", 0, 1, "p", "password", I18S("Specify service password"), NULL}, + { A_ARG, A_CHAR, "device", 1, 1, "d", "device", I18S("device name"), NULL}, + { A_ARG, A_INT, "numOfDatapoints", 0, 1, "n", NULL, I18S("Get up to n datapoints"), NULL}, + { A_END, A_INT, "help", 0, 0, "h", "help", I18S("Show this help screen"), NULL} + }; + + eventLoop=AQH_EventLoop_new(); + dc=AQH_DataClient_new(eventLoop, AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION); + + rv=AQH_DataClient_ReadLocalArgs(dc, dbGlobalArgs, args, argc, argv); + if (rv<0) { + DBG_ERROR(NULL, "here (%d)", rv); + AQH_DataClient_free(dc); + AQH_EventLoop_free(eventLoop); + return 2; + } + + rv=AQH_DataClient_ConnectWithArgs(dc, 0); + if (rv<0) { + DBG_ERROR(NULL, "Error connecting (%d)", rv); + AQH_DataClient_free(dc); + AQH_EventLoop_free(eventLoop); + return 2; + } + + rv=_runCommand(dc); + if (rv<0) { + DBG_ERROR(NULL, "Error running (%d)", rv); + AQH_DataClient_free(dc); + AQH_EventLoop_free(eventLoop); + return 2; + } + + AQH_DataClient_free(dc); + AQH_EventLoop_free(eventLoop); + return 0; +} + + + +int _runCommand(AQH_DATACLIENT *dc) +{ + GWEN_DB_NODE *dbLocalArgs; + const char *deviceName; + AQH_DEVICE_LIST *deviceList; + AQH_DEVICE *device; + + dbLocalArgs=AQH_DataClient_GetDbLocalArgs(dc); + deviceName=GWEN_DB_GetCharValue(dbLocalArgs, "device", 0, "*"); + + deviceList=AQH_DataClient_GetDevices(dc); + if (deviceList==NULL) { + DBG_ERROR(NULL, "Error getting devices"); + return GWEN_ERROR_GENERIC; + } + + device=AQH_Device_List_First(deviceList); + while(device) { + const char *s; + + s=AQH_Device_GetNameForSystem(device); + if (s && *s && -1!=GWEN_Text_ComparePattern(s, deviceName, 0)) { + _handleDevice(dc, device); + } + + device=AQH_Device_List_Next(device); + } + + AQH_Device_List_free(deviceList); + + return 0; +} + + + +void _handleDevice(AQH_DATACLIENT *dc, const AQH_DEVICE *device) +{ + AQH_VALUE_LIST *valueList; + const char *devName; + const char *roomName; + const char *location; + const char *descr; + + devName=AQH_Device_GetNameForSystem(device); + roomName=AQH_Device_GetRoomName(device); + location=AQH_Device_GetLocation(device); + descr=AQH_Device_GetDescription(device); + + fprintf(stdout, "%s (room: %s, loc: %s, descr: %s)\n", + devName, + roomName?roomName:"--", + location?location:"--", + descr?descr:"--"); + valueList=AQH_DataClient_GetValues(dc, devName, 0); + if (valueList) { + const AQH_VALUE *value; + + value=AQH_Value_List_First(valueList); + while(value) { + if (AQH_Value_GetValueType(value)==AQH_ValueType_Sensor) + _handleValue(dc, device, value); + value=AQH_Value_List_Next(value); + } + } + + AQH_Value_List_free(valueList); +} + + + +void _handleValue(AQH_DATACLIENT *dc, const AQH_DEVICE *device, const AQH_VALUE *value) +{ + GWEN_DB_NODE *dbLocalArgs; + const char *valueName; + int numDataPoints; + + dbLocalArgs=AQH_DataClient_GetDbLocalArgs(dc); + numDataPoints=GWEN_DB_GetIntValue(dbLocalArgs, "numOfDatapoints", 0, 5); + + valueName=AQH_Value_GetName(value); + if (valueName && -1==GWEN_Text_ComparePattern(valueName, "stats_*", 0)) { + const char *valueNameForSystem; + uint64_t *dataPoints; + uint64_t recvdNum; + + valueNameForSystem=AQH_Value_GetNameForSystem(value); + fprintf(stdout, " %s: ", valueName?valueName:""); + + dataPoints=malloc(numDataPoints*sizeof(uint64_t)*2); + + recvdNum=AQH_DataClient_GetLastData(dc, valueNameForSystem, dataPoints, numDataPoints); + if (recvdNum>0) + _printDataPoints(dataPoints, recvdNum); + + free(dataPoints); + fprintf(stdout, "\n"); + } +} + + + +void _printDataPoints(const uint64_t *dataPoints, uint32_t numValues) +{ + uint32_t i; + + for(i=0; i + + + +int AQH_Tool_DeviceState(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv); + + +#endif + diff --git a/apps/aqhome-tool/main.c b/apps/aqhome-tool/main.c index a13cb83..ba251fe 100644 --- a/apps/aqhome-tool/main.c +++ b/apps/aqhome-tool/main.c @@ -23,6 +23,7 @@ #include "./data/setdata.h" #include "./data/moddevice.h" #include "./data/watch.h" +#include "./data/devicestate.h" #include #include @@ -101,6 +102,7 @@ int main(int argc, char **argv) GWEN_FE_DAH("setdata", AQH_Tool_SetData, I18N("Set data for a value on the data server (e.g. a switch or thermostat)")), GWEN_FE_DAH("moddevice", AQH_Tool_ModDevice, I18N("Modify a device on the data server")), GWEN_FE_DAH("watch", AQH_Tool_Watch, I18N("Watch and print changes of values on the data server")), + GWEN_FE_DAH("devicestate", AQH_Tool_DeviceState, I18N("Show state of devices")), GWEN_FE_END(), }; const GWEN_FUNCS *func; From 21830321f792f15d4bc81312cd523aa935cd3683 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 6 Sep 2025 00:37:57 +0200 Subject: [PATCH 175/196] dataclient: fixed a typo. --- aqhome/dataclient/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aqhome/dataclient/client.c b/aqhome/dataclient/client.c index d590a5d..578db7b 100644 --- a/aqhome/dataclient/client.c +++ b/aqhome/dataclient/client.c @@ -467,7 +467,7 @@ uint64_t _handleDataResponses(AQH_DATACLIENT *dc, uint64_t *dataPtr, uint64_t ma break; } else if (code==AQH_MSGTYPE_IPC_DATA_RESULT) { - DBG_ERROR(NULL, "Server Error: %d", AQH_IpcMessageResult_GetResult(tagList)); + DBG_INFO(NULL, "Server Error: %d", AQH_IpcMessageResult_GetResult(tagList)); GWEN_Tag16_List_free(tagList); AQH_Message_free(msgIn); return 0; @@ -538,7 +538,7 @@ int AQH_DataClient_ConnectWithArgs(AQH_DATACLIENT *dc, uint32_t flags) brokerPort=GWEN_DB_GetIntValue(dc->dbLocalArgs, "brokerPort", 0, -1); if (brokerPort<0) - brokerPort=GWEN_DB_GetIntValue(dc->dbLocalArgs, "ConfigFile/brokerPort", 0, 45456); + brokerPort=GWEN_DB_GetIntValue(dc->dbLocalArgs, "ConfigFile/brokerPort", 0, 1899); userId=GWEN_DB_GetCharValue(dc->dbLocalArgs, "userId", 0, NULL); passwd=GWEN_DB_GetCharValue(dc->dbLocalArgs, "password", 0, NULL); From a256c6261c1cebbafc931b7ad21bbd5220a153e6 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 6 Sep 2025 00:38:08 +0200 Subject: [PATCH 176/196] decreased verbosity. --- aqhome/ipc2/ipc_endpoint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aqhome/ipc2/ipc_endpoint.c b/aqhome/ipc2/ipc_endpoint.c index dcca205..d8dfd9e 100644 --- a/aqhome/ipc2/ipc_endpoint.c +++ b/aqhome/ipc2/ipc_endpoint.c @@ -79,7 +79,7 @@ AQH_MESSAGE *AQH_IpcEndpoint_WaitForResponseMsg(AQH_OBJECT *ipcEndpoint, uint32_ uint16_t code; code=AQH_IpcMessage_GetCode(msg); - DBG_ERROR(NULL, "Received unexpected message %d (%x), ignoring", code, code); + DBG_DEBUG(NULL, "Received unexpected message %d (%x), ignoring", code, code); AQH_Message_free(msg); } } From 9d59bf31e686be2a363831338491568f6b03a81f Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 6 Sep 2025 00:38:26 +0200 Subject: [PATCH 177/196] avr: reduce number of stats messages. --- avr/apps/stats/main.asm | 61 ++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 38 deletions(-) diff --git a/avr/apps/stats/main.asm b/avr/apps/stats/main.asm index d288484..0e6a419 100644 --- a/avr/apps/stats/main.asm +++ b/avr/apps/stats/main.asm @@ -11,7 +11,7 @@ ; *************************************************************************** ; defines -.equ APP_STATS_INTERVAL_MINS = 10 +.equ APP_STATS_INTERVAL_MINS = 30 @@ -70,28 +70,10 @@ AppStats_OnEveryMinute_noIrq: AppStats_OnEveryMinute_store: sts appStatsTimer, r16 - cpi r16, 1 - breq AppStats_OnEveryMinute_sendDevice - - cpi r16, 2 - breq AppStats_OnEveryMinute_sendMemStats - - cpi r16, 3 - breq AppStats_OnEveryMinute_sendRecvStats1 - - cpi r16, 4 - breq AppStats_OnEveryMinute_sendSendStats1 - -#ifdef APP_STATS_NETDEV2 - cpi r16, 5 - breq AppStats_OnEveryMinute_sendRecvStats2 - - cpi r16, 6 - breq AppStats_OnEveryMinute_sendSendStats2 -#endif - ; add more here - ret -AppStats_OnEveryMinute_sendDevice: + mov r17, r16 + andi r17, 3 + brne AppStats_OnEveryMinute_sendStats + ; send device announcement push yl push yh ldi yl, LOW(netInterfaceData) @@ -104,6 +86,24 @@ AppStats_OnEveryMinute_sendDevice: #endif pop yh pop yl +AppStats_OnEveryMinute_sendStats: + cpi r16, 2 + breq AppStats_OnEveryMinute_sendMemStats + + cpi r16, 3 + breq AppStats_OnEveryMinute_sendRecvStats1 + + cpi r16, 5 + breq AppStats_OnEveryMinute_sendSendStats1 + +#ifdef APP_STATS_NETDEV2 + cpi r16, 6 + breq AppStats_OnEveryMinute_sendRecvStats2 + + cpi r16, 7 + breq AppStats_OnEveryMinute_sendSendStats2 +#endif + ; add more here ret AppStats_OnEveryMinute_sendMemStats: rjmp AppNetwork_SendMemStats @@ -134,18 +134,3 @@ AppStats_OnEveryMinute_sendSendStats2: -; --------------------------------------------------------------------------- -; @routine AppStats_OnEveryMinute @global -; -; @param R17 value id -; @param R19:R18 value - -appStatsSend16BitValue: - ldi r20, 1 - clr r21 - ldi r22, AQHOME_VALUETYPE_STATS - bigjmp Main_SendValueReport -; @end - - - From 3b916facf468e87a56f707188a62a59e7d387711 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 6 Sep 2025 00:38:43 +0200 Subject: [PATCH 178/196] avr: added device n28. --- avr/devices/0BUILD | 2 + avr/devices/n28/.gitignore | 2 + avr/devices/n28/0BUILD | 21 ++++ avr/devices/n28/README | 13 ++ avr/devices/n28/aqua_n28.xml | 17 +++ avr/devices/n28/boot/0BUILD | 32 +++++ avr/devices/n28/boot/boot.asm | 129 ++++++++++++++++++++ avr/devices/n28/defs.asm | 131 ++++++++++++++++++++ avr/devices/n28/main/0BUILD | 34 ++++++ avr/devices/n28/main/data.asm | 14 +++ avr/devices/n28/main/main.asm | 221 ++++++++++++++++++++++++++++++++++ 11 files changed, 616 insertions(+) create mode 100644 avr/devices/n28/.gitignore create mode 100644 avr/devices/n28/0BUILD create mode 100644 avr/devices/n28/README create mode 100644 avr/devices/n28/aqua_n28.xml create mode 100644 avr/devices/n28/boot/0BUILD create mode 100644 avr/devices/n28/boot/boot.asm create mode 100644 avr/devices/n28/defs.asm create mode 100644 avr/devices/n28/main/0BUILD create mode 100644 avr/devices/n28/main/data.asm create mode 100644 avr/devices/n28/main/main.asm diff --git a/avr/devices/0BUILD b/avr/devices/0BUILD index be0570c..81d626e 100644 --- a/avr/devices/0BUILD +++ b/avr/devices/0BUILD @@ -33,10 +33,12 @@ n25 n26 n27 + n28 r05 r06 s03 t03 + t04 diff --git a/avr/devices/n28/.gitignore b/avr/devices/n28/.gitignore new file mode 100644 index 0000000..8e0618c --- /dev/null +++ b/avr/devices/n28/.gitignore @@ -0,0 +1,2 @@ +*.eep.hex +*.obj diff --git a/avr/devices/n28/0BUILD b/avr/devices/n28/0BUILD new file mode 100644 index 0000000..a2d9bae --- /dev/null +++ b/avr/devices/n28/0BUILD @@ -0,0 +1,21 @@ + + + + + + boot + main + + + + defs.asm + README + + + + aqua_n28.xml + + + + + diff --git a/avr/devices/n28/README b/avr/devices/n28/README new file mode 100644 index 0000000..c6733c4 --- /dev/null +++ b/avr/devices/n28/README @@ -0,0 +1,13 @@ + +N28 +=== + +- Role: Door sensor with temp sensor +- MCU: AtTiny84 +- Connection: RJ45 +- Predecessor: N21, N16 +- Periphery: + - door sensor (TCRT1000) + - TWI interface + - SI7021 temperature and humidity sensor + \ No newline at end of file diff --git a/avr/devices/n28/aqua_n28.xml b/avr/devices/n28/aqua_n28.xml new file mode 100644 index 0000000..700fa28 --- /dev/null +++ b/avr/devices/n28/aqua_n28.xml @@ -0,0 +1,17 @@ + + + AQUA + N + 28 + + + + + + + + + + + + diff --git a/avr/devices/n28/boot/0BUILD b/avr/devices/n28/boot/0BUILD new file mode 100644 index 0000000..95d031c --- /dev/null +++ b/avr/devices/n28/boot/0BUILD @@ -0,0 +1,32 @@ + + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + boot.asm + + + + + + + + + + + + + + + + diff --git a/avr/devices/n28/boot/boot.asm b/avr/devices/n28/boot/boot.asm new file mode 100644 index 0000000..cd8ec3e --- /dev/null +++ b/avr/devices/n28/boot/boot.asm @@ -0,0 +1,129 @@ +; *************************************************************************** +; 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 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_com2w.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" + + +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/n28/main/data.asm b/avr/devices/n28/main/data.asm new file mode 100644 index 0000000..31ccc2f --- /dev/null +++ b/avr/devices/n28/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/n28/main/main.asm b/avr/devices/n28/main/main.asm new file mode 100644 index 0000000..39a6848 --- /dev/null +++ b/avr/devices/n28/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 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 "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 = 10 +.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_TIMER +#define MODULES_CLOCK +;#define MODULES_LED_SIMPLE +#define MODULES_LED_ACTIVITY +#define MODULES_NETWORK +#define MODULES_COM2W +#define MODULES_TWI_MASTER +;#define MODULES_LCD +;#define LCD_MINIMAL_FONT +#define MODULES_SI7021 +;#define MODULES_STATS +;#define MODULES_OWI_MASTER +;#define MODULES_DS18B20 +;#define MODULES_MOTION +#define MODULES_TCRT1000 +;#define MODULES_CCS811 + +#define APPS_NETWORK +;#define APPS_MOTION +#define APPS_DOOR +#define APPS_REPORTSENSORS +#define APPS_STATS + + + +; --------------------------------------------------------------------------- +; defines for values + +.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_MOTION = 0x07 +.equ VALUE_ID_TCRT1K = 0x08 + +;.equ VALUE_ID_REED_CONF = 0x81 + +.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 com2wPcintIsr ; 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: +onEveryHour: +onEveryDay: + ret +; @end + + + +onEveryMinute: +; lds r16, tcrt1kLastValue +; ldi r17, VALUE_ID_ADC +; ldi r22, AQHOME_VALUETYPE_UNKNOWN ; VALUE TYPE +; rcall Main_Send8BitValueReport + 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" + + + +; --------------------------------------------------------------------------- +; defines for network interface + +.equ netInterfaceData = com2w_iface + + From 36195f88e08837ec318a1ea3681469c8c78e43ca Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 6 Sep 2025 00:39:08 +0200 Subject: [PATCH 179/196] r05: added missing defs. --- avr/devices/r05/main/main.asm | 3 +++ avr/devices/r05/test/main.asm | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/avr/devices/r05/main/main.asm b/avr/devices/r05/main/main.asm index 8a48ebe..01ec7f5 100644 --- a/avr/devices/r05/main/main.asm +++ b/avr/devices/r05/main/main.asm @@ -48,6 +48,8 @@ ; --------------------------------------------------------------------------- ; generic +.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) ; --------------------------------------------------------------------------- @@ -56,6 +58,7 @@ #define MAIN_WITHOUT_MSG_HANDLING ; message handling in AppRouter! #define APP_STATS_NETDEV2 ; send stats for 2nd device +#define COM_ACCEPT_ALL_DEST ; accept all messages! #define MODULES_CLOCK #define MODULES_LED_SIMPLE diff --git a/avr/devices/r05/test/main.asm b/avr/devices/r05/test/main.asm index 6abe2ca..3a090fc 100644 --- a/avr/devices/r05/test/main.asm +++ b/avr/devices/r05/test/main.asm @@ -50,6 +50,9 @@ .equ COMONUART0_IFACENUM = 1 .equ COMONUART1_IFACENUM = 2 +.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 @@ -57,6 +60,7 @@ ;#define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes ;#define APP_STATS_NETDEV2 +#define COM_ACCEPT_ALL_DEST ; accept all messages! #define MODULES_CLOCK ;#define MODULES_COM From 0989543b1b4abec8244839993d518ae0949b48d2 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 6 Sep 2025 00:39:50 +0200 Subject: [PATCH 180/196] avr: accept all dest addresses on routers/forwarders. --- avr/devices/r06/main/main.asm | 2 ++ avr/devices/s03/main/main.asm | 1 + avr/devices/t03/main/main.asm | 1 + avr/devices/t03/test/main.asm | 1 + avr/devices/t03/uartfd/main.asm | 1 + 5 files changed, 6 insertions(+) diff --git a/avr/devices/r06/main/main.asm b/avr/devices/r06/main/main.asm index 10fb474..a1ffb17 100644 --- a/avr/devices/r06/main/main.asm +++ b/avr/devices/r06/main/main.asm @@ -60,6 +60,8 @@ ; --------------------------------------------------------------------------- ; firmware settings including list of modules used +#define COM_ACCEPT_ALL_DEST ; accept all messages! + ; #define MODULES_TIMER #define MODULES_CLOCK #define MODULES_LED_SIMPLE diff --git a/avr/devices/s03/main/main.asm b/avr/devices/s03/main/main.asm index 35a9e4d..2f82a98 100644 --- a/avr/devices/s03/main/main.asm +++ b/avr/devices/s03/main/main.asm @@ -45,6 +45,7 @@ #define MAIN_WITHOUT_MSG_HANDLING ; message handling done here #define APP_STATS_NETDEV2 +#define COM_ACCEPT_ALL_DEST ; accept all messages! ; #define MODULES_TIMER #define MODULES_CLOCK diff --git a/avr/devices/t03/main/main.asm b/avr/devices/t03/main/main.asm index 9580fc8..3512966 100644 --- a/avr/devices/t03/main/main.asm +++ b/avr/devices/t03/main/main.asm @@ -57,6 +57,7 @@ #define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes #define APP_STATS_NETDEV2 +#define COM_ACCEPT_ALL_DEST ; accept all messages! #define MODULES_CLOCK ;#define MODULES_COM diff --git a/avr/devices/t03/test/main.asm b/avr/devices/t03/test/main.asm index 79b7a06..3aeae6c 100644 --- a/avr/devices/t03/test/main.asm +++ b/avr/devices/t03/test/main.asm @@ -58,6 +58,7 @@ #define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes #define APP_STATS_NETDEV2 #define APP_ROUTER_NO_ADDR_MGR +#define COM_ACCEPT_ALL_DEST ; accept all messages! #define MODULES_CLOCK ;#define MODULES_COM diff --git a/avr/devices/t03/uartfd/main.asm b/avr/devices/t03/uartfd/main.asm index 81bb6fd..5ce57ac 100644 --- a/avr/devices/t03/uartfd/main.asm +++ b/avr/devices/t03/uartfd/main.asm @@ -69,6 +69,7 @@ #define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes #define APP_STATS_NETDEV2 #define APP_ROUTER_NO_ADDR_MGR +#define COM_ACCEPT_ALL_DEST ; accept all messages! #define MODULES_CLOCK ;#define MODULES_COM From 80ca6e0ac5ec3bfae06e4bcda3e92dc2f274b6ee Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 6 Sep 2025 00:40:09 +0200 Subject: [PATCH 181/196] avr: added t04. --- avr/devices/t04/.gitignore | 2 + avr/devices/t04/0BUILD | 22 +++ avr/devices/t04/README | 13 ++ avr/devices/t04/aqua_t04.xml | 11 ++ avr/devices/t04/boot/0BUILD | 32 +++++ avr/devices/t04/boot/boot.asm | 150 +++++++++++++++++++++ avr/devices/t04/defs.asm | 110 +++++++++++++++ avr/devices/t04/main/0BUILD | 33 +++++ avr/devices/t04/main/main.asm | 246 ++++++++++++++++++++++++++++++++++ 9 files changed, 619 insertions(+) create mode 100644 avr/devices/t04/.gitignore create mode 100644 avr/devices/t04/0BUILD create mode 100644 avr/devices/t04/README create mode 100644 avr/devices/t04/aqua_t04.xml create mode 100644 avr/devices/t04/boot/0BUILD create mode 100644 avr/devices/t04/boot/boot.asm create mode 100644 avr/devices/t04/defs.asm create mode 100644 avr/devices/t04/main/0BUILD create mode 100644 avr/devices/t04/main/main.asm diff --git a/avr/devices/t04/.gitignore b/avr/devices/t04/.gitignore new file mode 100644 index 0000000..8e0618c --- /dev/null +++ b/avr/devices/t04/.gitignore @@ -0,0 +1,2 @@ +*.eep.hex +*.obj diff --git a/avr/devices/t04/0BUILD b/avr/devices/t04/0BUILD new file mode 100644 index 0000000..2775440 --- /dev/null +++ b/avr/devices/t04/0BUILD @@ -0,0 +1,22 @@ + + + + + + boot + main + + + + aqua_t04.xml + + + + defs.asm + README + + + + + + diff --git a/avr/devices/t04/README b/avr/devices/t04/README new file mode 100644 index 0000000..0d2ffb6 --- /dev/null +++ b/avr/devices/t04/README @@ -0,0 +1,13 @@ + +T04 +=== + +- Role: COM-PC-Interface +- MCU: AtTiny841 +- Connection: RJ45 +- Predecessor: none +- UART: UARTFD0, COM2W +- Periphery: + - OWI interface + - DS18B20 temperature sensor + diff --git a/avr/devices/t04/aqua_t04.xml b/avr/devices/t04/aqua_t04.xml new file mode 100644 index 0000000..4f7ffd9 --- /dev/null +++ b/avr/devices/t04/aqua_t04.xml @@ -0,0 +1,11 @@ + + + AQUA + T + 4 + + + + + + diff --git a/avr/devices/t04/boot/0BUILD b/avr/devices/t04/boot/0BUILD new file mode 100644 index 0000000..e5e0cd5 --- /dev/null +++ b/avr/devices/t04/boot/0BUILD @@ -0,0 +1,32 @@ + + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + boot.asm + + + + + + + + + + + + + + + + diff --git a/avr/devices/t04/boot/boot.asm b/avr/devices/t04/boot/boot.asm new file mode 100644 index 0000000..2f9fa66 --- /dev/null +++ b/avr/devices/t04/boot/boot.asm @@ -0,0 +1,150 @@ +; *************************************************************************** +; 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 +.equ clock=8000000 ; Define the clock frequency + +.nolist +.include "include/tn841def.inc" ; Define device ATtiny841 +.list + +.include "version.asm" +.include "../defs.asm" +.include "devices/all/defs.asm" + +.include "common/calls.asm" +.include "common/utils_wait.asm" + + + +; *************************************************************************** +; defines + + +;#define COM_ACCEPT_ALL_DEST 1 + + + +; --------------------------------------------------------------------------- +; LED + +.equ LED_DDR = DDRB +.equ LED_PORT = PORTB +.equ LED_PIN = PINB +.equ LED_PINNUM = PORTB2 + + +; *************************************************************************** +; code segment + +.cseg +.org 0x0000 + + + +; --------------------------------------------------------------------------- +; Reset and interrupt vectors + + rjmp main ; 1: RESET Reset vector use this for flashed system + reti ; 2: INT0 External Interrupt Request 0 + reti ; 3: PCINT0 Pin Change Interrupt 0 + reti ; 4: PCINT1 Pin Change Interrupt 1 + reti ; 5: WDT Watchdog Time-out + reti ; 6: TIM1_CAPT Timer/Counter1 Capture Event + reti ; 7: TIM1_COMPA (OC1A) Timer/Counter1 Compare Match A + reti ; 8: TIM1_COMPB (OC1B) Timer/Counter1 Compare Match B + reti ; 9: TIM1_OVF (OVF1) Timer/Counter1 Overflow + reti ; 10: TIM0_COMPA (OC0A) Timer/Counter0 Compare Match A + reti ; 11: TIM0_COMPB (OC0B) Timer/Counter0 Compare Match B + reti ; 12: TIM0_OVF (OVF0) Timer/Counter0 Overflow + reti ; 13: ANA_COMP0 Analog Comparator 0 + reti ; 14: ADC_READY ADC Conversion Complete + reti ; 15: EE_RDY (ERDY) EEPROM Ready + reti ; 16: ANA_COMP1 Analog Comparator 1 + reti ; 17: TIM2_CAPT Timer/Counter2 Capture Event + reti ; 18: TIM2_COMPA (OC2A) Timer/Counter2 Compare Match A + reti ; 19: TIM2_COMPB (OC2B) Timer/Counter2 Compare Match B + reti ; 20: TIM2_OVF (OVF2) Timer/Counter2 Overflow + reti ; 21: SPI SPI Serial Transfer Complete + reti ; 22: USART0_RXS USART0 Rx Start + reti ; 23: USART0_RXC USART0 Rx Complete + reti ; 24: USART0_DRE USART0 Data Register Empty + reti ; 25: USART0_TXC USART0 Tx Complete + reti ; 26: USART1_RXS USART1 Rx Start + reti ; 27: USART1_RXC USART1 Rx Complete + reti ; 28: USART1_DRE USART1 Data Register Empty + reti ; 29: USART1_TXC USART1 Tx Complete + reti ; 30: TWI Two-Wire-Interface + reti ; 31: RESERVED reserved + + + +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_uart0.asm" +.include "modules/flash/io_uart_all.asm" +.include "modules/flash/flashxp.asm" +.include "modules/flash/flash4p.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 == 1000000 + ldi r17, 0xd8 + ldi r16, (1< + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + main.asm + + + + + + + + + + + + + + + + + diff --git a/avr/devices/t04/main/main.asm b/avr/devices/t04/main/main.asm new file mode 100644 index 0000000..b292af4 --- /dev/null +++ b/avr/devices/t04/main/main.asm @@ -0,0 +1,246 @@ +; *************************************************************************** +; 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/tn841def.inc" ; Define device ATtiny841 +.list + +.include "../defs.asm" +.include "version.asm" +;.include "defs_all.asm" + +.include "devices/all/defs.asm" + +.include "common/calls.asm" +.include "common/utils_wait.asm" +.include "common/utils_io.asm" + + + +; *************************************************************************** +; defines + +; --------------------------------------------------------------------------- +; generic + +.equ COMONUART0_IFACENUM = 1 +.equ TTYONUART0_IFACENUM = 2 + + +; debug + +;.equ T03_FLAGS_ALLOC = 0x01 +;.equ T03_FLAGS_I1_SKIPPING = 0x02 +;.equ T03_FLAGS_I1_RESTARTED = 0x04 +;.equ T03_FLAGS_ADDIN = 0x08 +;.equ T03_FLAGS_I1_ADDOUT = 0x10 +;.equ T03_FLAGS_I2_ADDOUT = 0x20 + + + +; --------------------------------------------------------------------------- +; firmware settings including list of modules used + + +#define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes +#define COM_ACCEPT_ALL_DEST ; accept all messages! +#define APP_STATS_NETDEV2 +#define APP_ROUTER_NO_ADDR_MGR + +#define MODULES_CLOCK +;#define MODULES_COM +;#define MODULES_COM_WITH_ADDR_PROTO +;#define MODULES_LED +;#define MODULES_LED_SIMPLE +;#define MODULES_LED_SIGNAL +#define MODULES_LED_ACTIVITY +;#define MODULES_TWI_MASTER +;#define MODULES_LCD +;#define LCD_MINIMAL_FONT +;#define MODULES_SI7021 +;#define MODULES_STATS +;#define MODULES_CNY70 +;#define MODULES_REED +;#define MODULES_OWI_MASTER +;#define MODULES_DS18B20 +;#define MODULES_MOTION +#define MODULES_NETWORK +#define MODULES_COM2W +;#define MODULES_COMONUART0 +;#define MODULES_TTYONUART1 +#define MODULES_UARTFD0 +#define APPS_STATS +;#define APPS_NETWORK +;#define APPS_ROUTER +#define APPS_FORWARDER + + + +.equ NET_BUFFERS_NUM = 10 +.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) + + + + +; --------------------------------------------------------------------------- +; defines for values + +.equ VALUE_ID_DS18B20_TEMP = 0x06 + +.equ VALUE_ID_LEDSIMPLE_TIMING = 0x88 +.equ VALUE_ID_ROUTER_SETRANGE = 0x89 + + + +; *************************************************************************** +; code segment + +.cseg +.org 000000 + + + +; --------------------------------------------------------------------------- +; Reset and interrupt vectors + + rjmp BOOTLOADER_ADDR ; 1: RESET Reset vector use this for flashed system + reti ; 2: INT0 External Interrupt Request 0 + rjmp com2wPcintIsr ; 3: PCINT0 Pin Change Interrupt 0 + reti ; 4: PCINT1 Pin Change Interrupt 1 + reti ; 5: WDT Watchdog Time-out + reti ; 6: TIM1_CAPT Timer/Counter1 Capture Event + reti ; 7: TIM1_COMPA (OC1A) Timer/Counter1 Compare Match A + reti ; 8: TIM1_COMPB (OC1B) Timer/Counter1 Compare Match B + reti ; 9: TIM1_OVF (OVF1) Timer/Counter1 Overflow + rjmp baseTimerIrqOC0A ; 10: TIM0_COMPA (OC0A) Timer/Counter0 Compare Match A + reti ; 11: TIM0_COMPB (OC0B) Timer/Counter0 Compare Match B + reti ; 12: TIM0_OVF (OVF0) Timer/Counter0 Overflow + reti ; 13: ANA_COMP0 Analog Comparator 0 + reti ; 14: ADC_READY ADC Conversion Complete + reti ; 15: EE_RDY (ERDY) EEPROM Ready + reti ; 16: ANA_COMP1 Analog Comparator 1 + reti ; 17: TIM2_CAPT Timer/Counter2 Capture Event + reti ; 18: TIM2_COMPA (OC2A) Timer/Counter2 Compare Match A + reti ; 19: TIM2_COMPB (OC2B) Timer/Counter2 Compare Match B + reti ; 20: TIM2_OVF (OVF2) Timer/Counter2 Overflow + reti ; 21: SPI SPI Serial Transfer Complete + reti ; 22: USART0_RXS USART0 Rx Start + rjmp UARTFD0_RxCharIsr ; 23: USART0_RXC USART0 Rx Complete + rjmp UARTFD0_TxUdreIsr ; 24: USART0_DRE USART0 Data Register Empty + rjmp UARTFD0_TxCharIsr ; 25: USART0_TXC USART0 Tx Complete + reti ; 26: USART1_RXS USART1 Rx Start + reti ; 27: USART1_RXC USART1 Rx Complete + reti ; 28: USART1_DRE USART1 Data Register Empty + reti ; 29: USART1_TXC USART1 Tx Complete + reti ; 30: TWI Two-Wire-Interface + reti ; 31: RESERVED reserved + + + +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: + ldi r16, 0xf0 + sts netInterfaceData+NET_IFACE_OFFS_ADDRESS, r16 + sts netInterfaceData2+NET_IFACE_OFFS_ADDRESS, r16 + ret +; @end + + + +onEvery100ms: +onEverySecond: +onEveryMinute: +onEveryHour: +onEveryDay: + ret + + + +; --------------------------------------------------------------------------- +; @routine onEveryLoop +; +; Called on every loop (i.e. after awakening from sleep). + +onEveryLoop: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine onMessageReceived +; +; Called on every message received + +onMessageReceived: + clc + ret +; @end + + + + + + +; *************************************************************************** +; includes + +.include "devices/all/hw_tn841.asm" +.include "devices/all/includes.asm" +.include "common/debug.asm" + + + + +; --------------------------------------------------------------------------- +; defines for network interface + +.equ netInterfaceData = uartFd0_iface +.equ netInterfaceData2 = com2w_iface + + From 808a7c4258a0958ca00106af35c4ee5920ec7b98 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 6 Sep 2025 00:40:42 +0200 Subject: [PATCH 182/196] com2w: check COM_ACCEPT_ALL_DEST --- avr/modules/com2w/com2w.asm | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/avr/modules/com2w/com2w.asm b/avr/modules/com2w/com2w.asm index 8545059..5ecfbb0 100644 --- a/avr/modules/com2w/com2w.asm +++ b/avr/modules/com2w/com2w.asm @@ -162,7 +162,6 @@ com2wReceiveNextPkg: mov xl, yl mov xh, yh adiw xh:xl, COM2W_IFACE_OFFS_BUFFER - ldd r18, Y+NET_IFACE_OFFS_ADDRESS ldi r19, COM2W_BUFFER_SIZE rcall com2wRecvMsg ; (r16, r17, r18, r19, r20, r22, r24, r25, X) brcc com2wReceiveNextPkg_end @@ -173,6 +172,25 @@ com2wReceiveNextPkg: rcall NETMSG_CheckMessageInBuffer ; (R16, R17, R18, R19, R20, X) brcc com2wReceiveNextPkg_eCrc +#ifndef COM_ACCEPT_ALL_DEST + ; check destination addr + mov xl, yl + mov xh, yh + adiw xh:xl, COM2W_IFACE_OFFS_BUFFER + adiw xh:xl, NETMSG_OFFS_DESTADDR + ld r16, X ; read destination address + cpi r16, 0xff + breq com2wReceiveNextPkg_forMe + ldd r17, Y+NET_IFACE_OFFS_ADDRESS + cp r16, r17 + breq com2wReceiveNextPkg_forMe + ; packet not for me, but correctly received, inc counter, but don't light LED + ldi r16, NET_IFACE_OFFS_PACKETSIN_LOW + rcall NET_Interface_IncCounter16 ; (R24, R25) + rjmp com2wReceiveNextPkg_end +#endif + +com2wReceiveNextPkg_forMe: ; msg received, alloc buffer for it rcall NET_Buffer_Alloc ; R16=buffer num (R16, R17, X) brcs com2wReceiveNextPkg_gotBuffer From 6c1e8a45ffaa3ee2d07fc2a1fa9c8ff1bc59bb8e Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 6 Sep 2025 00:41:17 +0200 Subject: [PATCH 183/196] com2wn: only trigger led if LED_ACTIVITY is defined. --- avr/modules/com2w/com2wn_recv.asm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/avr/modules/com2w/com2wn_recv.asm b/avr/modules/com2w/com2wn_recv.asm index 011871a..ab0b943 100644 --- a/avr/modules/com2w/com2wn_recv.asm +++ b/avr/modules/com2w/com2wn_recv.asm @@ -120,9 +120,11 @@ com2wnReadNextBit_end: ; @clobbers r16, r17, r18, X com2wnByteRecvd: +#ifdef MODULES_LED_ACTIVITY push r16 rcall LedActivity_Trigger pop r16 +#endif ldd xl, Y+COM2W_IFACE_OFFS_BUFPOS_LOW ldd xh, Y+COM2W_IFACE_OFFS_BUFPOS_HIGH ldd r17, Y+COM2W_IFACE_OFFS_BUFLEFT From 4a74a9990f3b9ccfb29f3f075ffe5f5f893316b8 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 6 Sep 2025 00:41:58 +0200 Subject: [PATCH 184/196] minor fixes. --- avr/modules/flash/io_uart0.asm | 31 +++++++++++++++++++++++++++++++ avr/modules/flash/io_uart_all.asm | 7 ------- 2 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 avr/modules/flash/io_uart0.asm diff --git a/avr/modules/flash/io_uart0.asm b/avr/modules/flash/io_uart0.asm new file mode 100644 index 0000000..8934246 --- /dev/null +++ b/avr/modules/flash/io_uart0.asm @@ -0,0 +1,31 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + + +.equ UART_REG_UDR = UDR0 +.equ UART_REG_UCSRA = UCSR0A +.equ UART_REG_UCSRB = UCSR0B +.equ UART_REG_UCSRC = UCSR0C +.equ UART_REG_UBRRL = UBRR0L +.equ UART_REG_UBRRH = UBRR0H + +.equ UART_BIT_UCSZ0 = UCSZ00 +.equ UART_BIT_UDRE = UDRE0 +.equ UART_BIT_RXC = RXC0 +.equ UART_BIT_TXC = TXC0 +.equ UART_BIT_FE = FE0 +.equ UART_BIT_DOR = DOR0 +.equ UART_BIT_UPE = UPE0 +.equ UART_BIT_RXEN = RXEN0 +.equ UART_BIT_TXEN = TXEN0 + + + + diff --git a/avr/modules/flash/io_uart_all.asm b/avr/modules/flash/io_uart_all.asm index 118d900..e772ba5 100644 --- a/avr/modules/flash/io_uart_all.asm +++ b/avr/modules/flash/io_uart_all.asm @@ -46,13 +46,6 @@ ioRawInit: ori r16, (1< Date: Sat, 6 Sep 2025 00:42:20 +0200 Subject: [PATCH 185/196] uartfd1: fixed typos. --- avr/modules/uart_fd/uartfd1.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/avr/modules/uart_fd/uartfd1.asm b/avr/modules/uart_fd/uartfd1.asm index 54803c7..0de632d 100644 --- a/avr/modules/uart_fd/uartfd1.asm +++ b/avr/modules/uart_fd/uartfd1.asm @@ -41,8 +41,8 @@ UARTFD1_Init: std Y+UARTFD_IFACE_OFFS_RBUFLEFT, r16 std Y+UARTFD_IFACE_OFFS_STATUS, r16 - M_UARTFD_SET_BAUDRATE 0 - M_UARTFD_SET_CHARFORMAT 0 + M_UARTFD_SET_BAUDRATE 1 + M_UARTFD_SET_CHARFORMAT 1 ; always receive! rcall uartFd1StartReading From 2d15091b0cf5db7cd9108a5d27e5d1d519da2d5c Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 6 Sep 2025 00:42:49 +0200 Subject: [PATCH 186/196] avr: updated uartfd0 (copied from uartfd1) --- avr/modules/uart_fd/uartfd0.asm | 79 ++++++++++++++++++++++++++++----- 1 file changed, 68 insertions(+), 11 deletions(-) diff --git a/avr/modules/uart_fd/uartfd0.asm b/avr/modules/uart_fd/uartfd0.asm index b10ab20..d4834cf 100644 --- a/avr/modules/uart_fd/uartfd0.asm +++ b/avr/modules/uart_fd/uartfd0.asm @@ -12,9 +12,10 @@ + .dseg -uartFd0_iface: .bytes UARTFD_IFACE_SIZE +uartFd0_iface: .byte UARTFD_IFACE_SIZE @@ -34,13 +35,16 @@ UARTFD0_Init: std Y+UARTFD_IFACE_OFFS_WBUFNUM, r16 clr r16 std Y+UARTFD_IFACE_OFFS_WBUFLEFT, r16 + std Y+UARTFD_IFACE_OFFS_RBUFUSED, r16 std Y+UARTFD_IFACE_OFFS_RBUFLEFT, r16 + std Y+UARTFD_IFACE_OFFS_STATUS, r16 M_UARTFD_SET_BAUDRATE 0 M_UARTFD_SET_CHARFORMAT 0 ; always receive! + rcall uartFd0StartReading rcall uartFd0StartRx ret @@ -73,11 +77,20 @@ UARTFD0_Run: ldi yh, HIGH(uartFd0_iface) clr r22 - rcall uartFd0RunRead ; (r16, r17, r18, r19, r20, r24, r25, X, Z) - sbci r22, 0 + push r15 + in r15, SREG + + cli ; disable irqs + rcall uartFd0RunRead ; (r16, r17, r18, r19, r20, r24, r25, X, Z) + sbci r22, 0 + out SREG, r15 ; probably enable irqs + + cli ; disable irqs + rcall uartFd0RunWrite ; (r16, r17, r18, r19, r24, r25, X) + sbci r22, 0 - rcall uartFd0RunWrite ; (r16, r17, r18, r19, r24, r25, X) - sbci r22, 0 + out SREG, r15 ; probably enable irqs + pop r15 tst r22 clc @@ -202,7 +215,8 @@ uartFd0RunRead: rcall uartFd0CheckOverrun ; (r16, r24, r25) rcall uartFd0CheckHwErr ; (r16, r24, r25) rcall uartFd0CheckBadMsgSize ; (r16, r24, r25) - rcall uartFd0CheckSkipping ; (R16, X) + rcall uartFd0CheckSkipping ; (r16, X) + rcall uartFd0SetSkippingSignal ; (r16, r17) ; clear error flags ldd r16, Y+UARTFD_IFACE_OFFS_STATUS @@ -218,17 +232,41 @@ uartFd0RunRead: +; --------------------------------------------------------------------------- +; @routine uartFd0SetSkippingSignal +; +; @param Y pointer to interface data in SRAM +; @clobbers r16 (r17) + +uartFd0SetSkippingSignal: +#ifdef MODULES_LED_SIGNAL + ldd r16, Y+UARTFD_IFACE_OFFS_STATUS + andi r16, (1< Date: Sat, 6 Sep 2025 00:43:05 +0200 Subject: [PATCH 187/196] added flash instructions for n28 and t04. --- flashnode.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/flashnode.sh b/flashnode.sh index 6370233..2b9adf8 100755 --- a/flashnode.sh +++ b/flashnode.sh @@ -93,6 +93,13 @@ case $NODE in EFUSE_ARG="-U efuse:w:0xFE:m" FILE_ARG="-U flash:w:./0-build/avr/devices/n27/boot/n27_boot.hex" ;; + n28) + DEVICE_ARG="-p t84" + 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/n28/boot/n28_boot.hex" + ;; r04) DEVICE_ARG="-p t841" HFUSE_ARG="-U hfuse:w:0xD7:m" @@ -121,6 +128,13 @@ case $NODE in EFUSE_ARG="-U efuse:w:0xFE:m" FILE_ARG="-U flash:w:./0-build/avr/devices/t03/boot/t03_boot.hex" ;; + t04) + DEVICE_ARG="-p t841" + 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/t04/boot/t04_boot.hex" + ;; *) echo "Unknown node $NODE". exit 1 From 51d55128a90b96eb0b2f413aeb158e95d8bba340 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 7 Sep 2025 01:43:13 +0200 Subject: [PATCH 188/196] Decreased verbosity. --- aqhome/ipc2/tcpd_object.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aqhome/ipc2/tcpd_object.c b/aqhome/ipc2/tcpd_object.c index b0ed405..6153ff0 100644 --- a/aqhome/ipc2/tcpd_object.c +++ b/aqhome/ipc2/tcpd_object.c @@ -176,17 +176,17 @@ int _handleSocketReady(AQH_OBJECT *o) { AQH_TCPD_OBJECT *xo; - DBG_INFO(NULL, "Socket ready"); + DBG_DEBUG(NULL, "Socket ready"); xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQH_TCPD_OBJECT, o); if (xo) { int clientSk; clientSk=_acceptConnection(xo->fdSocket); if (clientSk<0) { - DBG_ERROR(AQH_LOGDOMAIN, "here (%d)", clientSk); + DBG_INFO(AQH_LOGDOMAIN, "here (%d)", clientSk); } else { - DBG_INFO(AQH_LOGDOMAIN, "New connection"); + DBG_NOTICE(AQH_LOGDOMAIN, "New connection"); if (0==AQH_Object_EmitSignal(o, AQH_TCPD_OBJECT_SIGNAL_NEWCONN, clientSk, NULL)) { DBG_ERROR(AQH_LOGDOMAIN, "New connection not handled"); close(clientSk); From d1b67a4819f0f219b5f1087c7fbf18126c1435bf Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 7 Sep 2025 01:43:31 +0200 Subject: [PATCH 189/196] devicestate: add valuename for improved filtering. --- apps/aqhome-tool/data/devicestate.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/aqhome-tool/data/devicestate.c b/apps/aqhome-tool/data/devicestate.c index c6f9dcb..2b7a9b8 100644 --- a/apps/aqhome-tool/data/devicestate.c +++ b/apps/aqhome-tool/data/devicestate.c @@ -54,7 +54,7 @@ static int _runCommand(AQH_DATACLIENT *dc); static void _handleDevice(AQH_DATACLIENT *dc, const AQH_DEVICE *device); -static void _handleValue(AQH_DATACLIENT *dc, const AQH_DEVICE *device, const AQH_VALUE *value); +static void _handleValue(AQH_DATACLIENT *dc, const AQH_VALUE *value); static void _printDataPoints(const uint64_t *dataPoints, uint32_t numValues); static void _printSingleDataPoint(uint64_t timestamp, double data); @@ -80,6 +80,7 @@ int AQH_Tool_DeviceState(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv) { A_ARG, A_CHAR, "userId", 0, 1, "u", "userid", I18S("Specify user id"), NULL}, { A_ARG, A_CHAR, "password", 0, 1, "p", "password", I18S("Specify service password"), NULL}, { A_ARG, A_CHAR, "device", 1, 1, "d", "device", I18S("device name"), NULL}, + { A_ARG, A_CHAR, "valueName", 0, 1, "N", "valuename", I18S("Value name for device(e.g. LIGHT)"), NULL}, { A_ARG, A_INT, "numOfDatapoints", 0, 1, "n", NULL, I18S("Get up to n datapoints"), NULL}, { A_END, A_INT, "help", 0, 0, "h", "help", I18S("Show this help screen"), NULL} }; @@ -178,7 +179,7 @@ void _handleDevice(AQH_DATACLIENT *dc, const AQH_DEVICE *device) value=AQH_Value_List_First(valueList); while(value) { if (AQH_Value_GetValueType(value)==AQH_ValueType_Sensor) - _handleValue(dc, device, value); + _handleValue(dc, value); value=AQH_Value_List_Next(value); } } @@ -188,17 +189,21 @@ void _handleDevice(AQH_DATACLIENT *dc, const AQH_DEVICE *device) -void _handleValue(AQH_DATACLIENT *dc, const AQH_DEVICE *device, const AQH_VALUE *value) +void _handleValue(AQH_DATACLIENT *dc, const AQH_VALUE *value) { GWEN_DB_NODE *dbLocalArgs; + const char *wantedValueName; const char *valueName; int numDataPoints; dbLocalArgs=AQH_DataClient_GetDbLocalArgs(dc); numDataPoints=GWEN_DB_GetIntValue(dbLocalArgs, "numOfDatapoints", 0, 5); + wantedValueName=GWEN_DB_GetCharValue(dbLocalArgs, "valueName", 0, "*"); valueName=AQH_Value_GetName(value); - if (valueName && -1==GWEN_Text_ComparePattern(valueName, "stats_*", 0)) { + if (valueName && + -1==GWEN_Text_ComparePattern(valueName, "stats_*", 0) && + -1!=GWEN_Text_ComparePattern(valueName, wantedValueName, 0)) { const char *valueNameForSystem; uint64_t *dataPoints; uint64_t recvdNum; From 85e66c352d1eb57340b31eb37fda73658882b13d Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 7 Sep 2025 01:44:05 +0200 Subject: [PATCH 190/196] n26, n27: use slow blinking LED_SIMPLE module instead of LED_ACTIVITY. --- avr/devices/n26/defs.asm | 2 +- avr/devices/n26/main/main.asm | 4 ++-- avr/devices/n27/defs.asm | 2 +- avr/devices/n27/main/main.asm | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/avr/devices/n26/defs.asm b/avr/devices/n26/defs.asm index 7bfd6c1..6909188 100644 --- a/avr/devices/n26/defs.asm +++ b/avr/devices/n26/defs.asm @@ -40,7 +40,7 @@ ; LED module .equ LED_SIMPLE_ONTIME = 1 ; shorter -.equ LED_SIMPLE_OFFTIME = 50 ; longer +.equ LED_SIMPLE_OFFTIME = 99 ; longer .equ LED_SIMPLE_DDR = DDRA .equ LED_SIMPLE_PORT = PORTA .equ LED_SIMPLE_PORTIN = PINA diff --git a/avr/devices/n26/main/main.asm b/avr/devices/n26/main/main.asm index de2c1c2..b35bdac 100644 --- a/avr/devices/n26/main/main.asm +++ b/avr/devices/n26/main/main.asm @@ -61,8 +61,8 @@ ; #define MODULES_TIMER #define MODULES_CLOCK -;#define MODULES_LED_SIMPLE -#define MODULES_LED_ACTIVITY +#define MODULES_LED_SIMPLE +;#define MODULES_LED_ACTIVITY #define MODULES_NETWORK ;#define MODULES_UART_BITBANG #define MODULES_COM2W diff --git a/avr/devices/n27/defs.asm b/avr/devices/n27/defs.asm index 78787f9..346503b 100644 --- a/avr/devices/n27/defs.asm +++ b/avr/devices/n27/defs.asm @@ -40,7 +40,7 @@ ; LED module .equ LED_SIMPLE_ONTIME = 1 ; shorter -.equ LED_SIMPLE_OFFTIME = 50 ; longer +.equ LED_SIMPLE_OFFTIME = 99 ; longer .equ LED_SIMPLE_DDR = DDRA .equ LED_SIMPLE_PORT = PORTA .equ LED_SIMPLE_PORTIN = PINA diff --git a/avr/devices/n27/main/main.asm b/avr/devices/n27/main/main.asm index e082309..dbaecad 100644 --- a/avr/devices/n27/main/main.asm +++ b/avr/devices/n27/main/main.asm @@ -61,8 +61,8 @@ ; #define MODULES_TIMER #define MODULES_CLOCK -;#define MODULES_LED_SIMPLE -#define MODULES_LED_ACTIVITY +#define MODULES_LED_SIMPLE +;#define MODULES_LED_ACTIVITY #define MODULES_NETWORK ;#define MODULES_UART_BITBANG #define MODULES_COM2W From 9a1c5799aada04d36753ece74ec73c3cffb0620a Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 7 Sep 2025 11:48:35 +0200 Subject: [PATCH 191/196] decreased verbosity. --- apps/aqhome-nodes/r_getnodes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/aqhome-nodes/r_getnodes.c b/apps/aqhome-nodes/r_getnodes.c index 28c8d8d..cfc791e 100644 --- a/apps/aqhome-nodes/r_getnodes.c +++ b/apps/aqhome-nodes/r_getnodes.c @@ -54,7 +54,7 @@ void AQH_NodeServer_HandleGetNodes(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESS AQH_Endpoint_GetNextMessageId(ep), AQH_IpcMessage_GetMsgId(msg), niNext?0:AQH_MSGNODE_GETDEVICES_RSP_FLAGS_LASTMSG, ni); AQH_Endpoint_AddMsgOut(ep, outMsg); - DBG_ERROR(NULL, "Messages in clients out queue: %d", AQH_Message_List_GetCount(AQH_Endpoint_GetMsgOutList(ep))); + DBG_DEBUG(NULL, "Messages in clients out queue: %d", AQH_Message_List_GetCount(AQH_Endpoint_GetMsgOutList(ep))); ni=niNext; } } From ffaa27ca240a64c208a886cd487eff25a6757916 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 7 Sep 2025 11:48:55 +0200 Subject: [PATCH 192/196] aqhome-data: limit number of open files. --- aqhome/data/storage.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/aqhome/data/storage.c b/aqhome/data/storage.c index 561cbf8..8315828 100644 --- a/aqhome/data/storage.c +++ b/aqhome/data/storage.c @@ -23,7 +23,7 @@ #define AQH_STORAGE_DATAPOINTS_STEPS 128 - +#define AQH_STORAGE_MAXOPENFILES 128 /* ------------------------------------------------------------------------------------------------ @@ -650,6 +650,16 @@ AQH_DATAFILE *_getDataFileByValueId(AQH_STORAGE *sto, uint64_t valueId) DBG_ERROR(AQH_LOGDOMAIN, "Error opening/creating datafile for valueId \"%lu\"", (unsigned long int) valueId); return NULL; } + if (AQH_DataFile_List_GetCount(sto->dataFileList)>=AQH_STORAGE_MAXOPENFILES) { + AQH_DATAFILE *dfLast; + + dfLast=AQH_DataFile_List_Last(sto->dataFileList); + if (dfLast) { + AQH_DataFile_Close(dfLast); + AQH_DataFile_List_Del(dfLast); + AQH_DataFile_free(dfLast); + } + } DBG_DEBUG(AQH_LOGDOMAIN, "Adding datafile for valueId \"%lu\" to list", (unsigned long int) valueId); AQH_DataFile_List_Add(df, sto->dataFileList); } @@ -661,8 +671,17 @@ AQH_DATAFILE *_getDataFileByValueId(AQH_STORAGE *sto, uint64_t valueId) AQH_DATAFILE *_findDataFileByValueId(const AQH_STORAGE *sto, uint64_t valueId) { - if (sto && sto->dataFileList) - return AQH_DataFile_List_GetByValueId(sto->dataFileList, valueId); + if (sto && sto->dataFileList) { + AQH_DATAFILE *df; + + df=AQH_DataFile_List_GetByValueId(sto->dataFileList, valueId); + if (df) { + /* move to front of list */ + AQH_DataFile_List_Del(df); + AQH_DataFile_List_Insert(df, sto->dataFileList); + return df; + } + } return NULL; } From 3926b01b13eea6bedb5becfb2fc849153ad04154 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 7 Sep 2025 11:49:39 +0200 Subject: [PATCH 193/196] remove old stats from device info files. --- avr/devices/c01/aqua_c01.xml | 12 ------------ avr/devices/c02/aqua_c02.xml | 12 ------------ avr/devices/n14/aqua_n14.xml | 8 -------- avr/devices/n21/aqua_n21.xml | 8 -------- avr/devices/n24/aqua_n24.xml | 10 ---------- avr/devices/n25/aqua_n25.xml | 10 ---------- avr/devices/n26/aqua_n26.xml | 10 ---------- avr/devices/n27/aqua_n27.xml | 13 ------------- avr/devices/r05/aqua_r05.xml | 20 -------------------- avr/devices/r06/aqua_r06.xml | 11 +---------- 10 files changed, 1 insertion(+), 113 deletions(-) diff --git a/avr/devices/c01/aqua_c01.xml b/avr/devices/c01/aqua_c01.xml index 6181e0c..4114850 100644 --- a/avr/devices/c01/aqua_c01.xml +++ b/avr/devices/c01/aqua_c01.xml @@ -7,18 +7,6 @@ - - - - - - - - - - - - diff --git a/avr/devices/c02/aqua_c02.xml b/avr/devices/c02/aqua_c02.xml index 521b5d0..bb9caa6 100644 --- a/avr/devices/c02/aqua_c02.xml +++ b/avr/devices/c02/aqua_c02.xml @@ -7,18 +7,6 @@ - - - - - - - - - - - - diff --git a/avr/devices/n14/aqua_n14.xml b/avr/devices/n14/aqua_n14.xml index c74f8df..b59ccfa 100644 --- a/avr/devices/n14/aqua_n14.xml +++ b/avr/devices/n14/aqua_n14.xml @@ -15,14 +15,6 @@ - - - - - - - - diff --git a/avr/devices/n21/aqua_n21.xml b/avr/devices/n21/aqua_n21.xml index 5a59b8c..f3ff989 100644 --- a/avr/devices/n21/aqua_n21.xml +++ b/avr/devices/n21/aqua_n21.xml @@ -11,14 +11,6 @@ - - - - - - - - diff --git a/avr/devices/n24/aqua_n24.xml b/avr/devices/n24/aqua_n24.xml index 6cee19c..489d1a1 100644 --- a/avr/devices/n24/aqua_n24.xml +++ b/avr/devices/n24/aqua_n24.xml @@ -13,16 +13,6 @@ - - - - - - - - - - diff --git a/avr/devices/n25/aqua_n25.xml b/avr/devices/n25/aqua_n25.xml index 470ff46..87b925a 100644 --- a/avr/devices/n25/aqua_n25.xml +++ b/avr/devices/n25/aqua_n25.xml @@ -15,16 +15,6 @@ - - - - - - - - - - diff --git a/avr/devices/n26/aqua_n26.xml b/avr/devices/n26/aqua_n26.xml index 33515b5..c163295 100644 --- a/avr/devices/n26/aqua_n26.xml +++ b/avr/devices/n26/aqua_n26.xml @@ -8,16 +8,6 @@ - - - - - - - - - - diff --git a/avr/devices/n27/aqua_n27.xml b/avr/devices/n27/aqua_n27.xml index 26b7ef5..5ec46d0 100644 --- a/avr/devices/n27/aqua_n27.xml +++ b/avr/devices/n27/aqua_n27.xml @@ -8,21 +8,8 @@ - - - - - - - - - - - - - diff --git a/avr/devices/r05/aqua_r05.xml b/avr/devices/r05/aqua_r05.xml index 3e7ac14..f03902f 100644 --- a/avr/devices/r05/aqua_r05.xml +++ b/avr/devices/r05/aqua_r05.xml @@ -7,26 +7,6 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/avr/devices/r06/aqua_r06.xml b/avr/devices/r06/aqua_r06.xml index f0fc612..212b756 100644 --- a/avr/devices/r06/aqua_r06.xml +++ b/avr/devices/r06/aqua_r06.xml @@ -5,16 +5,7 @@ 6 - - - - - - - - - - + From 552cd5b2ae27e2eaab2a889b85c164878adbf024 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 7 Sep 2025 11:50:11 +0200 Subject: [PATCH 194/196] moved device info files to their respective device folders. --- avr/devices/n16/0BUILD | 4 ++++ avr/devices/n16/aqua_n16.xml | 17 +++++++++++++++++ avr/devices/t03/0BUILD | 4 ++++ avr/devices/t03/aqua_t03.xml | 13 +++++++++++++ devices/nodes/0BUILD | 2 -- devices/nodes/aqua_n16.xml | 27 --------------------------- devices/nodes/aqua_t03.xml | 33 --------------------------------- 7 files changed, 38 insertions(+), 62 deletions(-) create mode 100644 avr/devices/n16/aqua_n16.xml create mode 100644 avr/devices/t03/aqua_t03.xml delete mode 100644 devices/nodes/aqua_n16.xml delete mode 100644 devices/nodes/aqua_t03.xml diff --git a/avr/devices/n16/0BUILD b/avr/devices/n16/0BUILD index be449f6..e54b57e 100644 --- a/avr/devices/n16/0BUILD +++ b/avr/devices/n16/0BUILD @@ -7,6 +7,10 @@ main + + aqua_n16.xml + + defs.asm README diff --git a/avr/devices/n16/aqua_n16.xml b/avr/devices/n16/aqua_n16.xml new file mode 100644 index 0000000..6a574de --- /dev/null +++ b/avr/devices/n16/aqua_n16.xml @@ -0,0 +1,17 @@ + + + AQUA + N + 16 + + + + + + + + + + + + diff --git a/avr/devices/t03/0BUILD b/avr/devices/t03/0BUILD index c1b8f79..ba832c8 100644 --- a/avr/devices/t03/0BUILD +++ b/avr/devices/t03/0BUILD @@ -9,6 +9,10 @@ uartfd + + aqua_t03.xml + + defs.asm README diff --git a/avr/devices/t03/aqua_t03.xml b/avr/devices/t03/aqua_t03.xml new file mode 100644 index 0000000..3d539ca --- /dev/null +++ b/avr/devices/t03/aqua_t03.xml @@ -0,0 +1,13 @@ + + + AQUA + T + 3 + + + + + + + + diff --git a/devices/nodes/0BUILD b/devices/nodes/0BUILD index 4c7b1e3..ed2e335 100644 --- a/devices/nodes/0BUILD +++ b/devices/nodes/0BUILD @@ -6,13 +6,11 @@ aqua_n11.xml aqua_n12.xml aqua_n15.xml - aqua_n16.xml aqua_n17.xml aqua_n18.xml aqua_n19.xml aqua_n20.xml aqua_n22.xml - aqua_t03.xml diff --git a/devices/nodes/aqua_n16.xml b/devices/nodes/aqua_n16.xml deleted file mode 100644 index 4f18f70..0000000 --- a/devices/nodes/aqua_n16.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - AQUA - N - 16 - - - - - - - - - - - - - - - - - - - - - - diff --git a/devices/nodes/aqua_t03.xml b/devices/nodes/aqua_t03.xml deleted file mode 100644 index 1ca7901..0000000 --- a/devices/nodes/aqua_t03.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - AQUA - T - 3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - From fbda9cf228d96b9db1629558137e3639acb00ac6 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 7 Sep 2025 11:50:21 +0200 Subject: [PATCH 195/196] n28 has no motion sensor. --- avr/devices/n28/aqua_n28.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/avr/devices/n28/aqua_n28.xml b/avr/devices/n28/aqua_n28.xml index 700fa28..1c13607 100644 --- a/avr/devices/n28/aqua_n28.xml +++ b/avr/devices/n28/aqua_n28.xml @@ -8,7 +8,6 @@ - From 9685e4586160303ddf39f54fd7cf4f54d0938782 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 7 Sep 2025 11:50:33 +0200 Subject: [PATCH 196/196] incremented version number. --- 0BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/0BUILD b/0BUILD index d0a892b..160de7f 100644 --- a/0BUILD +++ b/0BUILD @@ -2,7 +2,7 @@ - + $(project_name) $(project_vmajor).$(project_vminor).$(project_vpatchlevel)