diff --git a/aqhome-nodes.sh b/aqhome-nodes.sh index 7152686..78b9ca0 100755 --- a/aqhome-nodes.sh +++ b/aqhome-nodes.sh @@ -11,3 +11,4 @@ export LD_LIBRARY_PATH="0-build/aqhome/:$LD_LIBRARY_PATH" # 0-build/apps/aqhomed/aqhomed -l aqhome.log -db aqhome.db -p aqhomed.pid -W /tmp/aqhome/aqhomed -ma 192.168.117.192 -mp 1883 -t 127.0.0.1 --mqttclientid=AQHOMEMQTTLOGTEST1 0-build/apps/aqhome-nodes/aqhome-nodes -N -l aqhome-nodes.log -db aqhome-nodes.db -p aqhome-nodes.pid -t 127.0.0.1 -ba 127.0.0.1 "$@" +#0-build/apps/aqhome-nodes/aqhome-nodes -l aqhome-nodes.log -db aqhome-nodes.db -p aqhome-nodes.pid -t 127.0.0.1 -ba 127.0.0.1 "$@" diff --git a/avr/apps/door/main.asm b/avr/apps/door/main.asm index ef0bb46..da436e9 100644 --- a/avr/apps/door/main.asm +++ b/avr/apps/door/main.asm @@ -49,7 +49,7 @@ AppDoor_Init: ldi yl, LOW(appDoorValSchedData) ldi yh, HIGH(appDoorValSchedData) rcall ValueScheduler_Init - ldi r16, (1< diff --git a/avr/common/list.asm b/avr/common/list.asm new file mode 100644 index 0000000..93240ed --- /dev/null +++ b/avr/common/list.asm @@ -0,0 +1,166 @@ +; *************************************************************************** +; 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_H +#define AQH_AVR_COMMON_LIST_H + + +; --------------------------------------------------------------------------- +; This code implements a simple single-linked list. +; It assumes that the first 2 bytes of an object managed by this code contain +; a 2 byte pointer to the next object. +; --------------------------------------------------------------------------- + + + + +; *************************************************************************** +; defs + +.equ LIST_OFFS_NEXT_LO = 0 +.equ LIST_OFFS_NEXT_HI = 1 +.equ LIST_SIZE = 2 + + + + + +; *************************************************************************** +; code + +.cseg + + + +; --------------------------------------------------------------------------- +; @routine List_InitObject @global +; +; Reset list object fields. +; @param Y pointer to object +; @clobbers r16 + +List_InitObject: + 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 +; @clobbers none + +List_GetNextObject: + ldd xl, Y+LIST_OFFS_NEXT_LO + ldd xh, Y+LIST_OFFS_NEXT_HI + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine List_GetLastObject + +; @param X pointer to one object in a list +; @return X pointer to last object which has an empty NEXT pointer +; @clobbers r16, r17, X, Y + +List_GetLastObject: + clr yl + clr yh + rjmp List_GetPredecessorFor +; @end + + + +; --------------------------------------------------------------------------- +; @routine List_GetPredecessorFor + +; @param Y pointer to this object +; @param X pointer to first object in a list +; @return X pointer to object whose NEXT pointer points to the given object (or NULL) +; @clobbers r16, r17, X + +List_GetPredecessorFor: + mov r16, xl + or r16, xh + breq List_GetPredecessorFor_ret + ld r16, X+ + ld r17, X+ + cp r16, yl + brne List_GetPredecessorFor_next + cp r17, yh + breq List_GetLastObject_haveIt +List_GetPredecessorFor_next: + mov xl, r16 + mov xh, r17 + rjmp List_GetPredecessorFor +List_GetPredecessorFor_haveIt: + sbiw xh:xl, 1 +List_GetPredecessorFor_ret: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine List_AddObject + +; @param X pointer to first object in a list +; @param Y pointer to object to add +; @clobbers r16, r17, x + +List_AddObject: + push yl + push yh + 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 + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine List_UnlinkObject + +; @param X pointer to first object in a list +; @param Y pointer to object to remove +; @clobbers r16, r17, x + +List_UnlinkObject: + push yl + push yh + rcall List_GetPredecessorFor ; (r16, r17, X) + pop yh + pop yl + mov r16, xl + or r16, xh + breq List_UnlinkObject_ret + ldd r16, Y+LIST_OFFS_NEXT_LO ; get this->NEXT + ldd r17, Y+LIST_OFFS_NEXT_HI + st X+, r16 ; store as NEXT in predecessor + st X, r17 + clr r16 ; set this->NEXT to NULL + std Y+LIST_OFFS_NEXT_LO, r16 + std Y+LIST_OFFS_NEXT_HI, r16 +List_UnlinkObject_ret: + ret +; @end + + + +#endif ; AQH_AVR_COMMON_LIST_H diff --git a/avr/common/ringbuffer_y.asm b/avr/common/ringbuffer_y.asm index 7eba828..e4e2ec9 100644 --- a/avr/common/ringbuffer_y.asm +++ b/avr/common/ringbuffer_y.asm @@ -119,7 +119,7 @@ RingBufferY_Reset: ; @routine RingBufferY_ReadByteGuarded ; ; @return CFLAG on success, cleared on error -; @param r16 byte to write +; @return r16 byte read ; @param Y pointer to start of interface data ; @clobbers R17, R18, X diff --git a/avr/common/tree.asm b/avr/common/tree.asm new file mode 100644 index 0000000..38e197a --- /dev/null +++ b/avr/common/tree.asm @@ -0,0 +1,192 @@ +; *************************************************************************** +; 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_TREE_H +#define AQH_AVR_COMMON_TREE_H + + + + +; *************************************************************************** +; 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_SIZE = TREE_OFFS_LIST+LIST_SIZE+4 + + + + +; *************************************************************************** +; code + +.cseg + + + +; --------------------------------------------------------------------------- +; @routine Tree_InitObject @global + +; @param Y pointer to object to add +; @clobbers r16 + +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 + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine Tree_GetParentObject @global + +; @param Y pointer to object +; @return X pointer to parent object +; @clobbers none + +Tree_GetParentObject: + ldd xl, Y+TREE_OFFS_WPARENT_LO + ldd xh, Y+TREE_OFFS_WPARENT_HI + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine Tree_GetFirstChildObject @global + +; @param Y pointer to object +; @return X pointer to first child object +; @clobbers none + +Tree_GetFirstChildObject: + ldd xl, Y+TREE_OFFS_WCHILD_LO + ldd xh, Y+TREE_OFFS_WCHILD_HI + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine Tree_GetObjectBelow @global + +; @param Y pointer to object +; @return X pointer to object below (or NULL) +; @clobbers r16 + +Tree_GetObjectBelow: + push yl + push yh + rcall treeGetObjectBelow + pop yh + pop yl + ret + +treeGetObjectBelow: + rcall Tree_GetFirstChildObject + mov r16, xl + or r16, xh + brne treeGetObjectBelow_ret ; got one + rcall List_GetNextObject + mov r16, xl + or r16, xh + brne treeGetObjectBelow_ret ; got one + rcall Tree_GetParentObject + mov r16, xl + or r16, xh + breq treeGetObjectBelow_ret ; no parent + mov yl, xl + mov yh, xh + rjmp treeGetObjectBelow ; try with parent +treeGetObjectBelow_ret: + ret +; @end + + + + +; --------------------------------------------------------------------------- +; @routine Tree_AddChildObject @global + +; @param X pointer to parent to add to +; @param Y pointer to object to add +; @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 + 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, yl + sbiw xh:xl, WID_OFFS_TREE+TREE_OFFS_WCHILD_LO + ret +Tree_AddChildObject_addToChildList: + mov xl, r16 + mov xh, r17 + rjmp List_AddObject +; @end + + + +; --------------------------------------------------------------------------- +; @routine Tree_UnlinkObject @global + +; @param Y pointer to object to remove +; @clobbers r16, r17, x + +Tree_UnlinkObject: + ldd xl, Y+TREE_OFFS_WPARENT_LO + ldd xh, Y+TREE_OFFS_WPARENT_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 + ld r16, X+ + ld r17, X + cp r16, yl ; same as THIS? + brne Tree_UnlinkObject_inList ; nope, need to check childList + cp r17, yh + 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 + ldd r16, Y+TREE_OFFS_LIST+LIST_OFFS_NEXT_LO + st -X, r16 + rjmp Tree_UnlinkObject_clrParentAndSibling +Tree_UnlinkObject_inList: + mov xl, r16 + mov xh, r17 + 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+LIST_OFFS_NEXT_LO, r16 + std Y+LIST_OFFS_NEXT_HI, r16 ; clear this->NEXT +Tree_UnlinkObject_ret: + ret +; @end + + + + +#endif ; AQH_AVR_COMMON_TREE_H + diff --git a/avr/common/utils.asm b/avr/common/utils.asm index e297b9b..d8db6a8 100644 --- a/avr/common/utils.asm +++ b/avr/common/utils.asm @@ -269,7 +269,11 @@ Utils_IncrementCounter16: ; MODIFIED REGISTERS: R16 Utils_ReadEepromIncr: +.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 Utils_ReadEepromIncr out EEARH, xh ; set EEPROM address out EEARL, xl @@ -293,15 +297,29 @@ Utils_ReadEepromIncr: ; MODIFIED REGISTERS: R17 Utils_WriteEepromIncr: +.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 Utils_WriteEepromIncr +.ifdef EEPM1 ldi r17, (0< all + c01 n16 n21 n22 diff --git a/avr/devices/all/0BUILD b/avr/devices/all/0BUILD index b63c66d..72eda57 100644 --- a/avr/devices/all/0BUILD +++ b/avr/devices/all/0BUILD @@ -9,6 +9,7 @@ hw_tn84.asm hw_tn85.asm hw_tn841.asm + hw_m8515.asm includes.asm main.asm modules.asm diff --git a/avr/devices/all/defs.asm b/avr/devices/all/defs.asm index ae0861a..c3b0a1d 100644 --- a/avr/devices/all/defs.asm +++ b/avr/devices/all/defs.asm @@ -40,7 +40,8 @@ .equ EEPROM_OFFS_SEED = 10 ; 2 bytes -.equ EEPROM_OFFS_REED_CONF = 12 ; 1 byte (plus one byte reserved) +.equ EEPROM_OFFS_OSCCAL_SLOW = 12 ; 1 byte +.equ EEPROM_OFFS_OSCCAL_FAST = 13 ; 1 byte .equ EEPROM_OFFS_MAL_CONF_ONTIME = 14 ; 2 bytes .equ EEPROM_OFFS_MAL_CONF_SRC1_ADDR = 16 ; 1 byte diff --git a/avr/devices/all/hw_m8515.asm b/avr/devices/all/hw_m8515.asm new file mode 100644 index 0000000..040bc8e --- /dev/null +++ b/avr/devices/all/hw_m8515.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. * +; *************************************************************************** + +; Hardware routine for AtTiny 84 devices + + +.cseg + + +; --------------------------------------------------------------------------- +; @routine systemInitHardware +; + +systemInitHardware: + ; set all ports as inputs and enable internal pull-up resistors + ldi r16, 0xff + clr r17 +.ifdef PORTA + out DDRA, r17 ; all input + out PORTA, r16 ; enable pull-up on all +.endif + +.ifdef PORTB + out DDRB, r17 ; all input + out PORTB, r16 ; enable pull-up on all +.endif + +.ifdef PORTC + out DDRC, r17 ; all input + out PORTC, r16 ; enable pull-up on all +.endif + +.ifdef PORTD + out DDRD, r17 ; all input + out PORTD, r16 ; enable pull-up on all +.endif + +.ifdef PORTE + out DDRE, r17 ; all input + out PORTE, r16 ; enable pull-up on all +.endif + + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine systemSetSpeed +; + +systemSetSpeed: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine systemSleep +; + +systemSleep: + ; only modify SE, SM2, SM1 and SM0 + cli + + M_IO_READ r16, MCUCR + cbr r16, (1< + + + + + boot + main + + + + aqua_c01.xml + + + + defs.asm + README + + + + + + diff --git a/avr/devices/c01/README b/avr/devices/c01/README new file mode 100644 index 0000000..0513f8f --- /dev/null +++ b/avr/devices/c01/README @@ -0,0 +1,10 @@ + +C01 +=== + +- Role: Controller with Display +- MCU: AtMega 8515 +- Connection: RJ45 +- Periphery: + - Display with SPI + diff --git a/avr/devices/c01/aqua_c01.xml b/avr/devices/c01/aqua_c01.xml new file mode 100644 index 0000000..4ea15e0 --- /dev/null +++ b/avr/devices/c01/aqua_c01.xml @@ -0,0 +1,11 @@ + + + AQUA + N + 1 + + + + + + diff --git a/avr/devices/c01/boot/0BUILD b/avr/devices/c01/boot/0BUILD new file mode 100644 index 0000000..bfe939f --- /dev/null +++ b/avr/devices/c01/boot/0BUILD @@ -0,0 +1,32 @@ + + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + boot.asm + + + + + + + + + + + + + + + + diff --git a/avr/devices/c01/boot/boot.asm b/avr/devices/c01/boot/boot.asm new file mode 100644 index 0000000..5b123b0 --- /dev/null +++ b/avr/devices/c01/boot/boot.asm @@ -0,0 +1,146 @@ +; *************************************************************************** +; Source file for base system node on AtMega 8515 +; +; This is for the maintenance system (i.e. the flash loader). +; +; All definitions and changes should go into this file. +; *************************************************************************** + +.equ clock=8000000 ; Define the clock frequency + +.nolist +.include "include/m8515def.inc" ; Define device ATmega8515 +.list + +.include "../defs.asm" +.include "defs_all.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 = DDRE +.equ LED_PORT = PORTE +.equ LED_PIN = PINE +.equ LED_PINNUM = PORTE2 + + + + + +; *************************************************************************** +; code segment + +.cseg +.org 0x0000 + + + +; --------------------------------------------------------------------------- +; Reset and interrupt vectors + rjmp main ; 1: Reset vector RESET + reti ; 2: INT0 External Interrupt Request 0 + reti ; 3: INT1 External Interrupt Request 1 + reti ; 4: TIMER1_CAPT Timer/Counter1 Capture Event + reti ; 5: TIMER1_COMPA Timer/Counter1 Compare Match A + reti ; 6: TIMER1_COMPB Timer/Counter1 Compare Match B + reti ; 7: TIMER1_OVF Timer/Counter1 Overflow + reti ; 8: TIMER0_OVF Timer/Counter0 Overflow + reti ; 9: SPI_STC Serial Transfer Complete + reti ; 10: USART_RXC USART Rx Complete + reti ; 11: USART_UDRE USART Data Register Empty + reti ; 12: USART_TXC USART Tx Complete + reti ; 13: ANA_COMP Analog Comparator + reti ; 14: INT2 External Interrupt Request 2 + reti ; 15: TIMER0_COMP Timer/Counter0 Compare Match + reti ; 16: EE_RDY EEPROM Ready + reti ; 17: 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: + rjmp main ; will be overwritten when flashing + + + +; *************************************************************************** +; main code + + +.org BOOTLOADER_ADDR + + +main: + ldi r16, 0xb0 ; orig: a0 + out OSCCAL, r16 + 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_uart.asm" +.include "modules/flash/io_uart_all_attn.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/c01/defs.asm b/avr/devices/c01/defs.asm new file mode 100644 index 0000000..21fed9d --- /dev/null +++ b/avr/devices/c01/defs.asm @@ -0,0 +1,170 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + +; *************************************************************************** +; +; AtMega8515 +; -------- +; DEV0 (T0) PB0 1 40 VCC +; DEV1 (T1) PB1 2 39 PA0 (AD0) SRAM +; DEV2 (AIN0) PB2 3 38 PA1 (AD1) SRAM +; D_RES (AIN1) PB3 4 37 PA2 (AD2) SRAM +; SPI (SS) PB4 5 36 PA3 (AD3) SRAM +; SPI (MOSI) PB5 6 35 PA4 (AD4) SRAM +; SPI (MISO) PB6 7 34 PA5 (AD5) SRAM +; SPI (SCK) PB7 8 33 PA6 (AD6) SRAM +; /RESET 9 32 PA7 (AD7) SRAM +; UART (RXD) PD0 10 31 PE0 (INT2) +; UART (TXD) PD1 11 30 PE1 (ALE) SRAM +; ATTN (INT0) PD2 12 29 PE2 (OC1B) LED +; T-IRQ (INT1) PD3 13 28 PC7 (A15) SRAM +; D-DC (XCK) PD4 14 27 PC6 (A14) SRAM +; D_BACKLIGHT (OC1A) PD5 15 26 PC5 (A13) SRAM +; SRAM (/WR) PD6 16 25 PC4 (A12) SRAM +; SRAM (/RD) PD7 17 24 PC3 (A11) SRAM +; XTAL2 18 23 PC2 (A10) SRAM +; XTAL1 19 22 PC1 (A9) SRAM +; GND 20 21 PC0 (A8) SRAM +; -------- +; +; *************************************************************************** + + + +.equ BOOTLOADER_ADDR = 0xc00 + +.equ FIRMWARE_VARIANT_BOOT = 0 +.equ FIRMWARE_VARIANT_TEMP_WINDOW = 1 + +.equ DEVICEINFO_ID = 'C' +.equ DEVICEINFO_VERSION = 1 +.equ DEVICEINFO_REVISION = 0 + + + +; --------------------------------------------------------------------------- +; LED module + +.equ LED_SIMPLE_ONTIME = 1 ; shorter +.equ LED_SIMPLE_OFFTIME = 50 ; longer +.equ LED_SIMPLE_DDR = DDRE +.equ LED_SIMPLE_PORT = PORTE +.equ LED_SIMPLE_PORTIN = PINE +.equ LED_SIMPLE_PINNUM = PORTE2 + + + +; --------------------------------------------------------------------------- +; 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_ATTN_DDR = DDRD +.equ COM_ATTN_INPUT = PIND +.equ COM_ATTN_OUTPUT = PORTD +.equ COM_ATTN_PIN = PORTD2 + +.equ COM_IRQ_ADDR_ATTN = GICR +.equ COM_IRQ_BIT_ATTN = INT0 +.equ COM_IRQ_GIFR_ATTN = INTF0 +;.equ COM_IRQ_GIMSK_ATTN = PCIE0 + + + +; --------------------------------------------------------------------------- +; SPI hardware module + +.equ SPIHW_SS_DDR = DDRB +.equ SPIHW_SS_INPUT = PINB +.equ SPIHW_SS_OUTPUT = PORTB +.equ SPIHW_SS_PIN = PORTB4 + +.equ SPIHW_MOSI_DDR = DDRB +.equ SPIHW_MOSI_INPUT = PINB +.equ SPIHW_MOSI_OUTPUT = PORTB +.equ SPIHW_MOSI_PIN = PORTB5 + +.equ SPIHW_MISO_DDR = DDRB +.equ SPIHW_MISO_INPUT = PINB +.equ SPIHW_MISO_OUTPUT = PORTB +.equ SPIHW_MISO_PIN = PORTB6 + +.equ SPIHW_SCK_DDR = DDRB +.equ SPIHW_SCK_INPUT = PINB +.equ SPIHW_SCK_OUTPUT = PORTB +.equ SPIHW_SCK_PIN = PORTB7 + +.equ SPIHW_SS0_DDR = DDRB +.equ SPIHW_SS0_OUTPUT = PORTB +.equ SPIHW_SS0_INPUT = PORTB +.equ SPIHW_SS0_PIN = PORTB0 + +.equ SPIHW_SS1_DDR = DDRB +.equ SPIHW_SS1_OUTPUT = PORTB +.equ SPIHW_SS1_INPUT = PORTB +.equ SPIHW_SS1_PIN = PORTB1 + +.equ SPIHW_SS2_DDR = DDRB +.equ SPIHW_SS2_OUTPUT = PORTB +.equ SPIHW_SS2_INPUT = PORTB +.equ SPIHW_SS2_PIN = PORTB2 + + + +; --------------------------------------------------------------------------- +; ILI9341 module + +.equ ILI9341_DEVICENUM = 0 +.equ ILI9341_DSP_WIDTH = 320 +.equ ILI9341_DSP_HEIGHT = 240 + +.equ ILI9341_RESET_DDR = DDRB +.equ ILI9341_RESET_OUTPUT = PORTB +.equ ILI9341_RESET_INPUT = PORTB +.equ ILI9341_RESET_PIN = PORTB3 + +.equ ILI9341_DC_DDR = DDRD +.equ ILI9341_DC_OUTPUT = PORTD +.equ ILI9341_DC_INPUT = PORTD +.equ ILI9341_DC_PIN = PORTD4 + +.equ ILI9341_LED_DDR = DDRD +.equ ILI9341_LED_OUTPUT = PORTD +.equ ILI9341_LED_INPUT = PORTD +.equ ILI9341_LED_PIN = PORTD5 + + + +; --------------------------------------------------------------------------- +; ComOnUart module + +.equ USART0_DATAREG = UDR +.equ UCSR0A = UCSRA +.equ UCSR0B = UCSRB +.equ UCSR0C = UCSRC +.equ UBRR0L = UBRRL +.equ UBRR0H = UBRRH + +.equ UCSZ00 = UCSZ0 +.equ UCSZ01 = UCSZ1 +.equ UDRE0 = UDRE +.equ RXC0 = RXC +.equ TXC0 = TXC +.equ FE0 = FE +.equ DOR0 = DOR +.equ UPE0 = UPE +.equ RXEN0 = RXEN +.equ TXEN0 = TXEN +.equ USBS0 = USBS +.equ RXCIE0 = RXCIE +.equ UDRIE0 = UDRIE + + diff --git a/avr/devices/c01/main/0BUILD b/avr/devices/c01/main/0BUILD new file mode 100644 index 0000000..51b5e7d --- /dev/null +++ b/avr/devices/c01/main/0BUILD @@ -0,0 +1,34 @@ + + + + + + + + -I $(builddir) + -I $(srcdir) + -I $(topsrcdir)/avr + -I $(topbuilddir)/avr + + + + + main.asm + + + + + + + + + + + + data.asm + + + + + + diff --git a/avr/devices/c01/main/data.asm b/avr/devices/c01/main/data.asm new file mode 100644 index 0000000..31ccc2f --- /dev/null +++ b/avr/devices/c01/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/c01/main/main.asm b/avr/devices/c01/main/main.asm new file mode 100644 index 0000000..ba8eb22 --- /dev/null +++ b/avr/devices/c01/main/main.asm @@ -0,0 +1,226 @@ +; *************************************************************************** +; 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=8000000 ; Define the clock frequency + + + +.nolist +.include "include/m8515def.inc" ; Define device ATmega8515 +.list + +.include "../defs.asm" +.include "./data.asm" + +.include "devices/all/defs.asm" +.include "common/utils_wait.asm" +.include "common/utils_io.asm" + + + +; *************************************************************************** +; defines + +; --------------------------------------------------------------------------- +; generic + +.equ NET_BUFFERS_NUM = 8 +.equ NET_BUFFERS_SIZE = 32 + + + +; --------------------------------------------------------------------------- +; heap + +.equ HEAP_START = 0x260 +.equ HEAP_SIZE = 32768-0x260 + + + + +; --------------------------------------------------------------------------- +; 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_CLOCK +#define MODULES_XRAM +#define MODULES_HEAP +#define MODULES_LED_SIMPLE +#define MODULES_NETWORK +;#define MODULES_COMONUART0 +#define MODULES_UART_HW +#define MODULES_SPI_HW +#define MODULES_ILI9341 +;#define MODULES_FONT_8X8 +#define MODULES_FONT_6X8 +;#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 + rjmp BOOTLOADER_ADDR ; 1: Reset vector RESET + rjmp NetUart_AttnChangeIsr ; 2: INT0 External Interrupt Request 0 + reti ; 3: INT1 External Interrupt Request 1 + reti ; 4: TIMER1_CAPT Timer/Counter1 Capture Event + reti ; 5: TIMER1_COMPA Timer/Counter1 Compare Match A + reti ; 6: TIMER1_COMPB Timer/Counter1 Compare Match B + reti ; 7: TIMER1_OVF Timer/Counter1 Overflow + reti ; 8: TIMER0_OVF Timer/Counter0 Overflow + reti ; 9: SPI_STC Serial Transfer Complete + reti ; 10: USART_RXC USART Rx Complete + reti ; 11: USART_UDRE USART Data Register Empty + reti ; 12: USART_TXC USART Tx Complete + reti ; 13: ANA_COMP Analog Comparator + reti ; 14: INT2 External Interrupt Request 2 + rjmp baseTimerIrqOC0A ; 15: TIMER0_COMP Timer/Counter0 Compare Match + reti ; 16: EE_RDY EEPROM Ready + reti ; 17: 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 + + + +; --------------------------------------------------------------------------- +; @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_m8515.asm" +.include "devices/all/includes.asm" + +.include "common/debug.asm" + + + +; --------------------------------------------------------------------------- +; defines for network interface + +.equ netInterfaceData = netUartIface + + + diff --git a/avr/devices/n21/README b/avr/devices/n21/README index 98c2591..55a3d2c 100644 --- a/avr/devices/n21/README +++ b/avr/devices/n21/README @@ -5,6 +5,7 @@ N21 - Role: Door sensor with temp and motion detection - MCU: AtTiny84 - Connection: RJ45 +- Predecessor: N16 - Periphery: - PIR sensor (AMN31112) - door sensor (TCRT1000) diff --git a/avr/devices/n21/main/main.asm b/avr/devices/n21/main/main.asm index c9c0c62..a2e0325 100644 --- a/avr/devices/n21/main/main.asm +++ b/avr/devices/n21/main/main.asm @@ -97,6 +97,8 @@ ;.equ VALUE_ID_REED_CONF = 0x81 +.equ VALUE_ID_LEDSIMPLE_TIMING = 0x88 + ; *************************************************************************** diff --git a/avr/devices/n23/boot/boot.asm b/avr/devices/n23/boot/boot.asm index 7d74df3..807f5c3 100644 --- a/avr/devices/n23/boot/boot.asm +++ b/avr/devices/n23/boot/boot.asm @@ -27,8 +27,6 @@ ; generic .include "common/utils_wait.asm" -.include "modules/com2/defs.asm" -.include "modules/comproto/defs.asm" diff --git a/avr/devices/t03/boot/boot.asm b/avr/devices/t03/boot/boot.asm index 1a83579..2e59e88 100644 --- a/avr/devices/t03/boot/boot.asm +++ b/avr/devices/t03/boot/boot.asm @@ -25,8 +25,6 @@ ; generic .include "common/utils_wait.asm" -.include "modules/com2/defs.asm" -.include "modules/comproto/defs.asm" @@ -131,6 +129,7 @@ main: .include "modules/flash/eeprom.asm" .include "modules/flash/io.asm" .include "modules/flash/io_uart1.asm" +.include "modules/flash/io_uart_all.asm" .include "modules/flash/flashxp.asm" .include "modules/flash/flash4p.asm" .include "modules/flash/flashprocess.asm" diff --git a/avr/devices/t03/defs.asm b/avr/devices/t03/defs.asm index 2b6374a..75a19f4 100644 --- a/avr/devices/t03/defs.asm +++ b/avr/devices/t03/defs.asm @@ -77,4 +77,9 @@ .equ OWI_PINNUM = PORTA7 +; --------------------------------------------------------------------------- +; ComOnUart module + +.equ USART0_DATAREG = UDR0 +.equ USART1_DATAREG = UDR1 diff --git a/avr/devices/t03/main/main.asm b/avr/devices/t03/main/main.asm index 6fdd478..a37e92f 100644 --- a/avr/devices/t03/main/main.asm +++ b/avr/devices/t03/main/main.asm @@ -32,6 +32,9 @@ .include "../defs.asm" .include "defs_all.asm" +.include "common/utils_wait.asm" +.include "common/utils_io.asm" + ; *************************************************************************** @@ -41,9 +44,6 @@ ; generic -.include "common/utils_wait.asm" - - ; --------------------------------------------------------------------------- ; firmware settings including list of modules used diff --git a/avr/modules/0BUILD b/avr/modules/0BUILD index 16da38b..d2ca36a 100644 --- a/avr/modules/0BUILD +++ b/avr/modules/0BUILD @@ -35,6 +35,8 @@ bootloader f_keepup valsched + xram + heap diff --git a/avr/modules/basetimer/main.asm b/avr/modules/basetimer/main.asm index 7b83e17..077defc 100644 --- a/avr/modules/basetimer/main.asm +++ b/avr/modules/basetimer/main.asm @@ -51,55 +51,7 @@ BaseTimer_Init: ; setup timer for IRQ every 100ms ldi r17, (baseTimerModuleData_end-baseTimerModuleData) rcall Utils_FillSram - ldi r16, (1< diff --git a/avr/modules/flash/eeprom.asm b/avr/modules/flash/eeprom.asm index 5c6f909..a215953 100644 --- a/avr/modules/flash/eeprom.asm +++ b/avr/modules/flash/eeprom.asm @@ -21,7 +21,11 @@ ; REGS: R16 flashReadEepromIncr: +.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 flashReadEepromIncr out EEARH, xh ; set EEPROM address out EEARL, xl diff --git a/avr/modules/flash/flash1p.asm b/avr/modules/flash/flash1p.asm index 9e64ffc..ba5c6c0 100644 --- a/avr/modules/flash/flash1p.asm +++ b/avr/modules/flash/flash1p.asm @@ -56,6 +56,17 @@ flash1pWritePages_loop: ; transfer data from temporary page buffer into FLASH memory ldi r20, (1< 7 per loop, max about 1000 - clc ; 1 - ret ; 4 -ioRawWaitForData_gotit: - sec ; 1 - ret ; 4 -; @end +.equ UART_REG_UDR = UDR1 +.equ UART_REG_UCSRA = UCSR1A +.equ UART_REG_UCSRB = UCSR1B +.equ UART_REG_UCSRC = UCSR1C +.equ UART_REG_UBRRL = UBRR1L +.equ UART_REG_UBRRH = UBRR1H + +.equ UART_BIT_UCSZ0 = UCSZ10 +.equ UART_BIT_UDRE = UDRE1 +.equ UART_BIT_RXC = RXC1 +.equ UART_BIT_TXC = TXC1 +.equ UART_BIT_FE = FE1 +.equ UART_BIT_DOR = DOR1 +.equ UART_BIT_UPE = UPE1 +.equ UART_BIT_RXEN = RXEN1 +.equ UART_BIT_TXEN = TXEN1 diff --git a/avr/modules/flash/io_uart_all.asm b/avr/modules/flash/io_uart_all.asm new file mode 100644 index 0000000..118d900 --- /dev/null +++ b/avr/modules/flash/io_uart_all.asm @@ -0,0 +1,387 @@ +; *************************************************************************** +; 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 ioRawInit +; Send a message +; +; @clobbers r16, r17 + +ioRawInit: + ; set baudrate +.if clock == 8000000 + ldi r16, 25 ; (19.2Kb/s at 8MHz) + ldi r17, 0 +.endif + +.if clock == 1000000 + ldi r16, 3 ; (19.2Kb/s at 1MHz) + ldi r17, 0 +.endif + + sts UART_REG_UBRRH, r17 + sts UART_REG_UBRRL, r16 + + ; set character format (asynchronous USART, 8-bit, one stop bit, no parity) + ldi r16, (3< 7 per loop, max about 1000 + clc ; 1 + ret ; 4 +ioRawWaitForData_gotit: + sec ; 1 + ret ; 4 +; @end + + + + diff --git a/avr/modules/flash/io_uart_all_attn.asm b/avr/modules/flash/io_uart_all_attn.asm new file mode 100644 index 0000000..740f3bc --- /dev/null +++ b/avr/modules/flash/io_uart_all_attn.asm @@ -0,0 +1,500 @@ +; *************************************************************************** +; 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 ioRawInit +; Send a message +; +; @clobbers r16, r17 + +ioRawInit: + ; set baudrate +.if clock == 8000000 + ldi r16, 25 ; (19.2Kb/s at 8MHz) + ldi r17, 0 +.endif + +.if clock == 1000000 + ldi r16, 3 ; (19.2Kb/s at 1MHz) + ldi r17, 0 +.endif + + M_IO_WRITE UART_REG_UBRRH, r17 + M_IO_WRITE UART_REG_UBRRL, r16 + + ; set character format (asynchronous USART, 8-bit, one stop bit, no parity) +.ifdef URSEL + ldi r16, (1< 7 per loop, max about 1000 + clc ; 1 + ret ; 4 +ioRawWaitForData_gotit: + sec ; 1 + ret ; 4 +; @end + + + + diff --git a/avr/modules/heap/0BUILD b/avr/modules/heap/0BUILD new file mode 100644 index 0000000..febd367 --- /dev/null +++ b/avr/modules/heap/0BUILD @@ -0,0 +1,11 @@ + + + + + + main.asm + + + + + diff --git a/avr/modules/heap/main.asm b/avr/modules/heap/main.asm new file mode 100644 index 0000000..177ddbb --- /dev/null +++ b/avr/modules/heap/main.asm @@ -0,0 +1,317 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + +; Needed vars: +; - HEAP_START +; - HEAP_SIZE + + +.equ HEAP_HEADER_BIT_USED = 1 + + +.dseg + +heapPtr: .byte 2 +heapUsed: .byte 2 +heapFree: .byte 2 +heapDblFree: .byte 1 + + + + +.cseg + + + +; --------------------------------------------------------------------------- +; @routine Heap_Init + +Heap_Init: + ldi xl, LOW(HEAP_START) + ldi xh, HIGH(HEAP_START) + ldi r24, LOW((HEAP_SIZE-6) & 0xfffc) ; size minus chunk header, chunk footer, start, end + ldi r25, HIGH((HEAP_SIZE-6) & 0xfffc) ; we allocate multiples of 4 bytes + clr r16 + sts heapUsed, r16 + sts heapUsed+1, r16 + st X+, r16 ; write start header + st X+, r16 + sts heapPtr, xl ; store global vars + sts heapPtr+1, xl + sts heapFree, r24 + sts heapFree+1, r25 + st X+, r24 ; store header of first chunk + st X+, r25 + add xl, r24 + adc xh, r25 + st X+, r24 ; store footer of first chunk + st X+, r25 + st X+, r16 ; write end footer + sec + ret +; @end + + + + +; --------------------------------------------------------------------------- +; @routine heapAllocFirstFit +; +; @param r25:r24 number of bytes to alloc +; @return CFLAG set of okay, cleared otherwise +; @return X start of allocated memory + +heapAllocFirstFit: + adiw r25:r24, 3 ; align size to next multiple of 4 + andi r24, 0xfc ; mask lower two bits + + lds xl, heapPtr + lds xh, heapPtr+1 + +heapAllocFirstFit_loop: + ld r18, X+ ; read chunk header + ld r19, X+ + mov r16, r18 ; heap end reached? + or r16, r19 + breq heapAllocFirstFit_memFull + sbrc r17, HEAP_HEADER_BIT_USED + rjmp heapAllocFirstFit_next ; jump if used + ; current chunk free, check size + mov r16, r18 + mov r17, r19 + sub r16, r24 + sbc r17, r25 ; r17:r16=remainder + brcs heapAllocFirstFit_next ; too small + rcall heapUseChunk + sec + ret +heapAllocFirstFit_next: + add xl, r18 + adc xh, r19 + adiw xh:xl, 2 ; skip footer + rjmp heapAllocFirstFit_loop + +heapAllocFirstFit_memFull: + clc + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine heapAdjustStatsAlloc +; +; @param r25:r24 size of allocated chunk +; @clobbers r16, r17 + +heapAdjustStatsAlloc: + ; adjust heapUsed + lds r16, heapUsed + lds r17, heapUsed+1 + add r16, r24 + adc r17, r25 + sts heapUsed, r16 + sts heapUsed+1, r17 + + ; adjust heapFree + lds r16, heapFree + lds r17, heapFree+1 + sub r16, r24 + sbc r17, r25 + sts heapFree, r16 + sts heapFree+1, r17 + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine heapAdjustStatsFree +; +; @param r25:r24 size of released chunk +; @clobbers r16, r17 + +heapAdjustStatsFree: + ; adjust heapUsed + lds r16, heapUsed + lds r17, heapUsed+1 + sub r16, r24 + sbc r17, r25 + sts heapUsed, r16 + sts heapUsed+1, r17 + + ; adjust heapFree + lds r16, heapFree + lds r17, heapFree+1 + add r16, r24 + adc r17, r25 + sts heapFree, r16 + sts heapFree+1, r17 + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine Heap_Free +; +; @param X pointer to previously allocated data +; @clobbers r16, r17, r24, r25, X + +Heap_Free: + sbiw xh:xl, 2 ; go back to chunk header + ld r24, X+ ; read allocated size (and USED bit) + ld r25, X+ + sbrs r24, HEAP_HEADER_BIT_USED + rjmp Heap_Free_dblFree ; not in use (double free!!) + cbr r24, (1< + + + + + defs.asm + font8x8.asm + font6x8.asm + font1.asm + font2.asm + + + + + diff --git a/avr/modules/lcd2/font/defs.asm b/avr/modules/lcd2/font/defs.asm new file mode 100644 index 0000000..d2908c3 --- /dev/null +++ b/avr/modules/lcd2/font/defs.asm @@ -0,0 +1,26 @@ +; *************************************************************************** +; 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_FONT_DEFS +#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 + + + +#endif + + diff --git a/avr/modules/lcd2/font/font1.asm b/avr/modules/lcd2/font/font1.asm new file mode 100644 index 0000000..7fd4710 --- /dev/null +++ b/avr/modules/lcd2/font/font1.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. * +; *************************************************************************** + + +; *************************************************************************** +; 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 + + + +font1_8x8: +; header + .dw font8x8MonoRenderCharacter ; renderFn + .db 128, 0 ; needed buffer size + .db 8, 8 ; width, height of chars + .db 32, 64 ; first char, num of chars in font +; data (8x8_horizontal_LSB_2) + .db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ; 0x20 + .db 0x0C,0x1E,0x1E,0x0C,0x0C,0x00,0x0C,0x00, ; 0x21 + .db 0x36,0x36,0x36,0x00,0x00,0x00,0x00,0x00, ; 0x22 + .db 0x36,0x36,0x7F,0x36,0x7F,0x36,0x36,0x00, ; 0x23 + .db 0x0C,0x3E,0x03,0x1E,0x30,0x1F,0x0C,0x00, ; 0x24 + .db 0x00,0x63,0x33,0x18,0x0C,0x66,0x63,0x00, ; 0x25 + .db 0x1C,0x36,0x1C,0x6E,0x3B,0x33,0x6E,0x00, ; 0x26 + .db 0x06,0x06,0x03,0x00,0x00,0x00,0x00,0x00, ; 0x27 + .db 0x18,0x0C,0x06,0x06,0x06,0x0C,0x18,0x00, ; 0x28 + .db 0x06,0x0C,0x18,0x18,0x18,0x0C,0x06,0x00, ; 0x29 + .db 0x00,0x66,0x3C,0xFF,0x3C,0x66,0x00,0x00, ; 0x2A + .db 0x00,0x0C,0x0C,0x3F,0x0C,0x0C,0x00,0x00, ; 0x2B + .db 0x00,0x00,0x00,0x00,0x00,0x0E,0x0C,0x06, ; 0x2C + .db 0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00, ; 0x2D + .db 0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x00, ; 0x2E + .db 0x60,0x30,0x18,0x0C,0x06,0x03,0x01,0x00, ; 0x2F + .db 0x1E,0x33,0x3B,0x3F,0x37,0x33,0x1E,0x00, ; 0x30 + .db 0x0C,0x0F,0x0C,0x0C,0x0C,0x0C,0x3F,0x00, ; 0x31 + .db 0x1E,0x33,0x30,0x1C,0x06,0x33,0x3F,0x00, ; 0x32 + .db 0x1E,0x33,0x30,0x1C,0x30,0x33,0x1E,0x00, ; 0x33 + .db 0x38,0x3C,0x36,0x33,0x7F,0x30,0x30,0x00, ; 0x34 + .db 0x3F,0x03,0x1F,0x30,0x30,0x33,0x1E,0x00, ; 0x35 + .db 0x1C,0x06,0x03,0x1F,0x33,0x33,0x1E,0x00, ; 0x36 + .db 0x3F,0x33,0x30,0x18,0x0C,0x06,0x06,0x00, ; 0x37 + .db 0x1E,0x33,0x33,0x1E,0x33,0x33,0x1E,0x00, ; 0x38 + .db 0x1E,0x33,0x33,0x3E,0x30,0x18,0x0E,0x00, ; 0x39 + .db 0x00,0x00,0x0C,0x0C,0x00,0x0C,0x0C,0x00, ; 0x3A + .db 0x00,0x00,0x0C,0x0C,0x00,0x0E,0x0C,0x06, ; 0x3B + .db 0x18,0x0C,0x06,0x03,0x06,0x0C,0x18,0x00, ; 0x3C + .db 0x00,0x00,0x3F,0x00,0x3F,0x00,0x00,0x00, ; 0x3D + .db 0x06,0x0C,0x18,0x30,0x18,0x0C,0x06,0x00, ; 0x3E + .db 0x1E,0x33,0x30,0x18,0x0C,0x00,0x0C,0x00, ; 0x3F + .db 0x3E,0x63,0x7B,0x7B,0x7B,0x03,0x1E,0x00, ; 0x40 + .db 0x0C,0x1E,0x33,0x33,0x3F,0x33,0x33,0x00, ; 0x41 + .db 0x3F,0x66,0x66,0x3E,0x66,0x66,0x3F,0x00, ; 0x42 + .db 0x3C,0x66,0x03,0x03,0x03,0x66,0x3C,0x00, ; 0x43 + .db 0x3F,0x36,0x66,0x66,0x66,0x36,0x3F,0x00, ; 0x44 + .db 0x7F,0x46,0x16,0x1E,0x16,0x46,0x7F,0x00, ; 0x45 + .db 0x7F,0x46,0x16,0x1E,0x16,0x06,0x0F,0x00, ; 0x46 + .db 0x3C,0x66,0x03,0x03,0x73,0x66,0x7C,0x00, ; 0x47 + .db 0x33,0x33,0x33,0x3F,0x33,0x33,0x33,0x00, ; 0x48 + .db 0x1E,0x0C,0x0C,0x0C,0x0C,0x0C,0x1E,0x00, ; 0x49 + .db 0x78,0x30,0x30,0x30,0x33,0x33,0x1E,0x00, ; 0x4A + .db 0x67,0x66,0x36,0x1E,0x36,0x66,0x67,0x00, ; 0x4B + .db 0x0F,0x06,0x06,0x06,0x46,0x66,0x7F,0x00, ; 0x4C + .db 0x63,0x77,0x7F,0x6B,0x63,0x63,0x63,0x00, ; 0x4D + .db 0x63,0x67,0x6F,0x7B,0x73,0x63,0x63,0x00, ; 0x4E + .db 0x1C,0x36,0x63,0x63,0x63,0x36,0x1C,0x00, ; 0x4F + .db 0x3F,0x66,0x66,0x3E,0x06,0x06,0x0F,0x00, ; 0x50 + .db 0x1E,0x33,0x33,0x33,0x3B,0x1E,0x38,0x00, ; 0x51 + .db 0x3F,0x66,0x66,0x3E,0x1E,0x36,0x67,0x00, ; 0x52 + .db 0x1E,0x33,0x07,0x1C,0x38,0x33,0x1E,0x00, ; 0x53 + .db 0x3F,0x2D,0x0C,0x0C,0x0C,0x0C,0x1E,0x00, ; 0x54 + .db 0x33,0x33,0x33,0x33,0x33,0x33,0x3F,0x00, ; 0x55 + .db 0x33,0x33,0x33,0x33,0x33,0x1E,0x0C,0x00, ; 0x56 + .db 0x63,0x63,0x63,0x6B,0x7F,0x77,0x63,0x00, ; 0x57 + .db 0x63,0x63,0x36,0x1C,0x36,0x63,0x63,0x00, ; 0x58 + .db 0x33,0x33,0x33,0x1E,0x0C,0x0C,0x1E,0x00, ; 0x59 + .db 0x7F,0x33,0x19,0x0C,0x46,0x63,0x7F,0x00, ; 0x5A + .db 0x1E,0x06,0x06,0x06,0x06,0x06,0x1E,0x00, ; 0x5B + .db 0x03,0x06,0x0C,0x18,0x30,0x60,0x40,0x00, ; 0x5C + .db 0x1E,0x18,0x18,0x18,0x18,0x18,0x1E,0x00, ; 0x5D + .db 0x08,0x1C,0x36,0x63,0x00,0x00,0x00,0x00, ; 0x5E + .db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF ; 0x5F + + + diff --git a/avr/modules/lcd2/font/font2.asm b/avr/modules/lcd2/font/font2.asm new file mode 100644 index 0000000..6c6ec79 --- /dev/null +++ b/avr/modules/lcd2/font/font2.asm @@ -0,0 +1,179 @@ +; *************************************************************************** +; 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 + + + +font2_6x8: +; header + .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 +; 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 +.db 0x00,0x14,0x3E,0x14,0x14,0x3E,0x14,0x00, ; 0x23 +.db 0x04,0x1C,0x02,0x0C,0x10,0x0E,0x08,0x00, ; 0x24 +.db 0x26,0x26,0x10,0x08,0x04,0x32,0x32,0x00, ; 0x25 +.db 0x04,0x0A,0x0A,0x04,0x2A,0x12,0x2C,0x00, ; 0x26 +.db 0x0C,0x0C,0x04,0x00,0x00,0x00,0x00,0x00, ; 0x27 +.db 0x08,0x04,0x04,0x04,0x04,0x04,0x08,0x00, ; 0x28 +.db 0x04,0x08,0x08,0x08,0x08,0x08,0x04,0x00, ; 0x29 +.db 0x00,0x14,0x1C,0x3E,0x1C,0x14,0x00,0x00, ; 0x2A +.db 0x00,0x08,0x08,0x3E,0x08,0x08,0x00,0x00, ; 0x2B +.db 0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x04, ; 0x2C +.db 0x00,0x00,0x00,0x3E,0x00,0x00,0x00,0x00, ; 0x2D +.db 0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x00, ; 0x2E +.db 0x00,0x20,0x10,0x08,0x04,0x02,0x00,0x00, ; 0x2F +.db 0x1C,0x22,0x32,0x2A,0x26,0x22,0x1C,0x00, ; 0x30 +.db 0x08,0x0C,0x08,0x08,0x08,0x08,0x1C,0x00, ; 0x31 +.db 0x1C,0x22,0x20,0x18,0x04,0x02,0x3E,0x00, ; 0x32 +.db 0x1C,0x22,0x20,0x1C,0x20,0x22,0x1C,0x00, ; 0x33 +.db 0x10,0x18,0x14,0x12,0x3E,0x10,0x10,0x00, ; 0x34 +.db 0x3E,0x02,0x02,0x1E,0x20,0x22,0x1C,0x00, ; 0x35 +.db 0x18,0x04,0x02,0x1E,0x22,0x22,0x1C,0x00, ; 0x36 +.db 0x3E,0x20,0x10,0x08,0x04,0x04,0x04,0x00, ; 0x37 +.db 0x1C,0x22,0x22,0x1C,0x22,0x22,0x1C,0x00, ; 0x38 +.db 0x1C,0x22,0x22,0x3C,0x20,0x10,0x0C,0x00, ; 0x39 +.db 0x00,0x00,0x0C,0x0C,0x00,0x0C,0x0C,0x00, ; 0x3A +.db 0x00,0x00,0x0C,0x0C,0x00,0x0C,0x0C,0x04, ; 0x3B +.db 0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x00, ; 0x3C +.db 0x00,0x00,0x3E,0x00,0x00,0x3E,0x00,0x00, ; 0x3D +.db 0x04,0x08,0x10,0x20,0x10,0x08,0x04,0x00, ; 0x3E +.db 0x1C,0x22,0x20,0x18,0x08,0x00,0x08,0x00, ; 0x3F +.db 0x1C,0x22,0x3A,0x2A,0x3A,0x02,0x1C,0x00, ; 0x40 +.db 0x1C,0x22,0x22,0x22,0x3E,0x22,0x22,0x00, ; 0x41 +.db 0x1E,0x22,0x22,0x1E,0x22,0x22,0x1E,0x00, ; 0x42 +.db 0x1C,0x22,0x02,0x02,0x02,0x22,0x1C,0x00, ; 0x43 +.db 0x1E,0x22,0x22,0x22,0x22,0x22,0x1E,0x00, ; 0x44 +.db 0x3E,0x02,0x02,0x1E,0x02,0x02,0x3E,0x00, ; 0x45 +.db 0x3E,0x02,0x02,0x1E,0x02,0x02,0x02,0x00, ; 0x46 +.db 0x1C,0x22,0x02,0x3A,0x22,0x22,0x3C,0x00, ; 0x47 +.db 0x22,0x22,0x22,0x3E,0x22,0x22,0x22,0x00, ; 0x48 +.db 0x1C,0x08,0x08,0x08,0x08,0x08,0x1C,0x00, ; 0x49 +.db 0x20,0x20,0x20,0x20,0x22,0x22,0x1C,0x00, ; 0x4A +.db 0x22,0x12,0x0A,0x06,0x0A,0x12,0x22,0x00, ; 0x4B +.db 0x02,0x02,0x02,0x02,0x02,0x02,0x3E,0x00, ; 0x4C +.db 0x22,0x36,0x2A,0x22,0x22,0x22,0x22,0x00, ; 0x4D +.db 0x22,0x26,0x2A,0x32,0x22,0x22,0x22,0x00, ; 0x4E +.db 0x1C,0x22,0x22,0x22,0x22,0x22,0x1C,0x00, ; 0x4F +.db 0x1E,0x22,0x22,0x1E,0x02,0x02,0x02,0x00, ; 0x50 +.db 0x1C,0x22,0x22,0x22,0x2A,0x12,0x2C,0x00, ; 0x51 +.db 0x1E,0x22,0x22,0x1E,0x12,0x22,0x22,0x00, ; 0x52 +.db 0x1C,0x22,0x02,0x1C,0x20,0x22,0x1C,0x00, ; 0x53 +.db 0x3E,0x08,0x08,0x08,0x08,0x08,0x08,0x00, ; 0x54 +.db 0x22,0x22,0x22,0x22,0x22,0x22,0x1C,0x00, ; 0x55 +.db 0x22,0x22,0x22,0x22,0x22,0x14,0x08,0x00, ; 0x56 +.db 0x22,0x22,0x2A,0x2A,0x2A,0x2A,0x14,0x00, ; 0x57 +.db 0x22,0x22,0x14,0x08,0x14,0x22,0x22,0x00, ; 0x58 +.db 0x22,0x22,0x22,0x14,0x08,0x08,0x08,0x00, ; 0x59 +.db 0x1E,0x10,0x08,0x04,0x02,0x02,0x1E,0x00, ; 0x5A +.db 0x1C,0x04,0x04,0x04,0x04,0x04,0x1C,0x00, ; 0x5B +.db 0x00,0x02,0x04,0x08,0x10,0x20,0x00,0x00, ; 0x5C +.db 0x1C,0x10,0x10,0x10,0x10,0x10,0x1C,0x00, ; 0x5D +.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 + + diff --git a/avr/modules/lcd2/font/font6x8.asm b/avr/modules/lcd2/font/font6x8.asm new file mode 100644 index 0000000..50b5696 --- /dev/null +++ b/avr/modules/lcd2/font/font6x8.asm @@ -0,0 +1,96 @@ +; *************************************************************************** +; 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 font6x8RenderCharacter + +; @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 r16, r17, r24, r25, x + +font6x8MonoRenderCharacter: + push zl + push zh + adiw zh:zl, FONT_OFFS_WIDTH + lpm r18, Z+ ; char width in pixels + lpm r19, Z ; char height in pixels + sbiw zh:zl, FONT_OFFS_WIDTH+1 + rcall font6x8GetCharPosInFont ; (r16, r17, r24, r25, z) + mov r25, r19 ; height in pixels +font6x8MonoRenderCharacter_loop1: + mov r24, r18 ; width in pixels + lpm r17, Z+ +font6x8MonoRenderCharacter_loop2: + lsr r17 + brcs font6x8MonoRenderCharacter_writeForeground + st X+, r0 + st X+, r1 + rjmp font6x8MonoRenderCharacter_loop2end +font6x8MonoRenderCharacter_writeForeground: + st X+, r2 + st X+, r3 +font6x8MonoRenderCharacter_loop2end: + dec r24 + brne font6x8MonoRenderCharacter_loop2 + dec r25 + brne font6x8MonoRenderCharacter_loop1 + pop zh + pop zl + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine font6x8GetCharPosInFont (same as font8x8GetCharPosInFont!) + +; @param R16 character to write +; @param Z pointer to font +; @return Z pointer to begin of char data +; @clobbers r16, r17, r24, r25, z + +font6x8GetCharPosInFont: + 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 font6x8GetCharPosInFont_ret + cp r16, r25 + brcc font6x8GetCharPosInFont_ret + mov r24, r16 + clr r25 + lsl r24 ; x2 + rol r25 + lsl r24 ; x4 + rol r25 + lsl r24 ; x8 + rol r25 + add zl, r24 + adc zh, r25 +font6x8GetCharPosInFont_ret: + ret +; @end + + + diff --git a/avr/modules/lcd2/font/font8x8.asm b/avr/modules/lcd2/font/font8x8.asm new file mode 100644 index 0000000..f33a2dc --- /dev/null +++ b/avr/modules/lcd2/font/font8x8.asm @@ -0,0 +1,94 @@ +; *************************************************************************** +; 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 font8x8RenderCharacter + +; @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, r24, r25, x + +font8x8MonoRenderCharacter: + push zl + push zh + rcall font8x8GetCharPosInFont8x8 ; (r17, r24, r25, z) + ldi r25, 8 ; 8 bytes +font8x8MonoRenderCharacter_loop1: + ldi r24, 8 ; 8 bits + lpm r17, Z+ +font8x8MonoRenderCharacter_loop2: + lsr r17 + brcs font8x8MonoRenderCharacter_writeForeground + st X+, r0 + st X+, r1 + rjmp font8x8MonoRenderCharacter_loop2end +font8x8MonoRenderCharacter_writeForeground: + st X+, r2 + st X+, r3 +font8x8MonoRenderCharacter_loop2end: + dec r24 + brne font8x8MonoRenderCharacter_loop2 + dec r25 + brne font8x8MonoRenderCharacter_loop1 + ldi r18, 8 + ldi r19, 8 + pop zh + pop zl + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine font8x8GetCharPosInFont8x8 + +; @param R16 character to write +; @param Z pointer to font +; @return Z pointer to begin of char data +; @clobbers r17, r24, r25, z + +font8x8GetCharPosInFont8x8: + 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 font8x8GetCharPosInFont8x8_ret + cp r16, r25 + brcc font8x8GetCharPosInFont8x8_ret + mov r24, r16 + clr r25 + lsl r24 ; x2 + rol r25 + lsl r24 ; x4 + rol r25 + lsl r24 ; x8 + rol r25 + add zl, r24 + adc zh, r25 +font8x8GetCharPosInFont8x8_ret: + ret +; @end + + + diff --git a/avr/modules/lcd2/ili9341/0BUILD b/avr/modules/lcd2/ili9341/0BUILD new file mode 100644 index 0000000..febd367 --- /dev/null +++ b/avr/modules/lcd2/ili9341/0BUILD @@ -0,0 +1,11 @@ + + + + + + main.asm + + + + + diff --git a/avr/modules/lcd2/ili9341/defs.asm b/avr/modules/lcd2/ili9341/defs.asm new file mode 100644 index 0000000..aa37ed7 --- /dev/null +++ b/avr/modules/lcd2/ili9341/defs.asm @@ -0,0 +1,61 @@ + + + +#define ILI9341_FRAMERATE_61_HZ 0x1F +#define ILI9341_FRAMERATE_63_HZ 0x1E +#define ILI9341_FRAMERATE_65_HZ 0x1D +#define ILI9341_FRAMERATE_68_HZ 0x1C +#define ILI9341_FRAMERATE_70_HZ 0x1B +#define ILI9341_FRAMERATE_73_HZ 0x1A +#define ILI9341_FRAMERATE_76_HZ 0x19 +#define ILI9341_FRAMERATE_79_HZ 0x18 +#define ILI9341_FRAMERATE_83_HZ 0x17 +#define ILI9341_FRAMERATE_86_HZ 0x16 +#define ILI9341_FRAMERATE_90_HZ 0x15 +#define ILI9341_FRAMERATE_95_HZ 0x14 +#define ILI9341_FRAMERATE_100_HZ 0x13 +#define ILI9341_FRAMERATE_106_HZ 0x12 +#define ILI9341_FRAMERATE_112_HZ 0x11 +#define ILI9341_FRAMERATE_119_HZ 0x10 + +#define ILI9341_MADCTL_MY 0x80 ; row address order +#define ILI9341_MADCTL_MX 0x40 ; column address order +#define ILI9341_MADCTL_MV 0x20 ; row/column exchange +#define ILI9341_MADCTL_ML 0x10 ; vertical refresh order +#define ILI9341_MADCTL_RGB 0x00 ; RGB color order +#define ILI9341_MADCTL_BGR 0x08 ; BGR color order +#define ILI9341_MADCTL_MH 0x04 ; horizontal refresh order + + +#define ILI9341_CMD_CASET 0x2A +#define ILI9341_CMD_PASET 0x2B +#define ILI9341_CMD_RAMWR 0x2C +#define ILI9341_CMD_RAMRD 0x2E + +#define ILI9341_CMD_COLORSET 0x2d +#define ILI9341_CMD_SETDSPBRIGHTNESS 0x51 +#define ILI9341_CMD_WRITECTLDISPLAY 0x53 + + + +.equ WIN_OFFS_BGCOLOR_LOW = 0 +.equ WIN_OFFS_BGCOLOR_HIGH = 1 + +.equ WIN_OFFS_FGCOLOR_LOW = 2 +.equ WIN_OFFS_FGCOLOR_HIGH = 3 + +.equ WIN_OFFS_WIDTH_LOW = 4 +.equ WIN_OFFS_WIDTH_HIGH = 5 + +.equ WIN_OFFS_HEIGHT_LOW = 6 +.equ WIN_OFFS_HEIGHT_HIGH = 7 + +.equ WIN_OFFS_ABS_X_LOW = 8 +.equ WIN_OFFS_ABS_X_HIGH = 9 + +.equ WIN_OFFS_REL_X_LOW = 10 +.equ WIN_OFFS_REL_X_HIGH = 11 + + + + diff --git a/avr/modules/lcd2/ili9341/graphops.asm b/avr/modules/lcd2/ili9341/graphops.asm new file mode 100644 index 0000000..22aa62a --- /dev/null +++ b/avr/modules/lcd2/ili9341/graphops.asm @@ -0,0 +1,336 @@ +; *************************************************************************** +; 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 ili9341SetAddressWindow +; +; @param r5:r4 X0 +; @param r7:r6 Y0 +; @param r9:r8 W +; @param r11:r10 H +; @clobbers R16, r20, r21 + +ili9341SetAddressWindow: + ; calc XEnd (=X+W-1) + mov r20, r8 + mov r21, r9 + add r20, r4 + adc r21, r5 + subi r20, 1 + sbci r21, 0 + + ; send column address + ldi r16, ILI9341_CMD_CASET + rcall ili9341SendCommand + ; X0 + mov r16, r5 + rcall ili9341SendData + mov r16, r4 + rcall ili9341SendData + ; X1 + mov r16, r21 + rcall ili9341SendData + mov r16, r20 + rcall ili9341SendData + + ; calc YEnd (=Y+H-1) + mov r20, r10 + mov r21, r11 + add r20, r6 + adc r21, r7 + subi r20, 1 + sbci r21, 0 + + ; send row address + ldi r16, ILI9341_CMD_PASET + rcall ili9341SendCommand + ; Y0 + mov r16, r7 + rcall ili9341SendData + mov r16, r6 + rcall ili9341SendData + ; Y1 + mov r16, r21 + rcall ili9341SendData + mov r16, r20 + rcall ili9341SendData + + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine ILI9341_FillRect +; @param r3:r2 color +; @param r5:r4 X0 +; @param r7:r6 Y0 +; @param r9:r8 X1/W +; @param r11:r10 Y1/H + +ILI9341_FillRect: + push r15 + in r15, SREG + cli + + rcall ili9341BeginSpi ; (R16, R17) + rcall ili9341SetAddressWindow ; (R16, r20, r21) + + mov r18, r2 ; color + mov r19, r3 + mov r22, r10 ; H low + mov r23, r11 ; H high + ldi r16, ILI9341_CMD_RAMWR ; start writing ro RAM + rcall ili9341SendCommand + + cbi SPIHW_SS_OUTPUT, SPIHW_SS_PIN ; SS low + sbi ILI9341_DC_OUTPUT, ILI9341_DC_PIN ; D high (DATA) +ILI9341_FillRect_loopH: + mov r24, r8 ; W low + mov r25, r9 ; W high +ILI9341_FillRect_loopW: + mov r16, r19 + rcall SPIHW_MasterTransfer + mov r16, r18 + rcall SPIHW_MasterTransfer + sbiw r25:r24, 1 + brne ILI9341_FillRect_loopW + mov r24, r22 ; H low + mov r25, r23 ; H high + sbiw r25:r24, 1 ; dec + mov r22, r24 ; save in r23:r22 + mov r23, r25 + brne ILI9341_FillRect_loopH + sbi SPIHW_SS_OUTPUT, SPIHW_SS_PIN ; SS high + rcall ili9341EndSpi + out SREG, r15 + pop r15 + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine ili9341BitBlit + +; @param r5:r4 X (dest) +; @param r7:r6 Y (dest) +; @param r9:r8 W +; @param r11:r10 H +; @param X source data pointer (RAM) +; @clobbers r16, r22, r23, r24, r25, X (r17, r20, r21) + +ili9341BitBlit: + push r15 + in r15, SREG + cli + + rcall ili9341BeginSpi ; (r16, r17) + rcall ili9341SetAddressWindow ; (R16, R20, R21) + + ldi r16, ILI9341_CMD_RAMWR ; start writing ro RAM + rcall ili9341SendCommand + + mov r22, r10 + mov r23, r11 + cbi SPIHW_SS_OUTPUT, SPIHW_SS_PIN ; SS low + sbi ILI9341_DC_OUTPUT, ILI9341_DC_PIN ; D high (DATA) +ili9341BitBlit_loopH: + mov r24, r8 + mov r25, r9 +ili9341BitBlit_loopW: + ld r18, X+ + ld r19, X+ + mov r16, r19 + rcall SPIHW_MasterTransfer ; (R16) + mov r16, r18 + rcall SPIHW_MasterTransfer ; (R16) + sbiw r25:r24, 1 + brne ili9341BitBlit_loopW + mov r24, r22 + mov r25, r23 + sbiw r25:r24, 1 + mov r22, r24 + mov r23, r25 + brne ili9341BitBlit_loopH + sbi SPIHW_SS_OUTPUT, SPIHW_SS_PIN ; SS high + rcall ili9341EndSpi ; (R16) + out SREG, r15 + pop r15 + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine ili9341BitBlitStretch2 + +; @param r5:r4 X (dest) +; @param r7:r6 Y (dest) +; @param r9:r8 W +; @param r11:r10 H +; @param X source data pointer (RAM) +; @clobbers r16, r22, r23, r24, r25, X (r17, r18, r19, r20, r21) + +ili9341BitBlitStretch2: + push r15 + in r15, SREG + cli + + push r8 + push r9 + push r10 + push r11 + ; width + lsl r8 ; x2 + rol r9 + ; height + lsl r10 ; x2 + rol r11 + + rcall ili9341BeginSpi ; (r16, r17) + rcall ili9341SetAddressWindow ; (R16, R20, R21) + pop r11 + pop r10 + pop r9 + pop r8 + ldi r16, ILI9341_CMD_RAMWR ; start writing ro RAM + rcall ili9341SendCommand + + mov r22, r10 + mov r23, r11 + cbi SPIHW_SS_OUTPUT, SPIHW_SS_PIN ; SS low + sbi ILI9341_DC_OUTPUT, ILI9341_DC_PIN ; D high (DATA) + ldi r17, 2 +ili9341BitBlitStretch2_loopH: + mov r20, xl ; preserve for next run + mov r21, xh + rcall ili9341BitBlitStretchNWriteLine ; (r16, r17, r18, r19, r24, r25, X) + mov xl, r20 + mov xh, r21 + rcall ili9341BitBlitStretchNWriteLine ; (r16, r17, r18, r19, r24, r25, X) + mov r24, r22 + mov r25, r23 + sbiw r25:r24, 1 + mov r22, r24 + mov r23, r25 + brne ili9341BitBlitStretch2_loopH + sbi SPIHW_SS_OUTPUT, SPIHW_SS_PIN ; SS high + rcall ili9341EndSpi ; (R16) + out SREG, r15 + pop r15 + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine ili9341BitBlitStretch4 + +; @param r5:r4 X (dest) +; @param r7:r6 Y (dest) +; @param r9:r8 W +; @param r11:r10 H +; @param X source data pointer (RAM) +; @clobbers r16, r22, r23, r24, r25, X (r17, r20, r21) + +ili9341BitBlitStretch4: + push r15 + in r15, SREG + cli + + push r8 + push r9 + push r10 + push r11 + ; width + lsl r8 ; x2 + rol r9 + lsl r8 ; x4 + rol r9 + ; height + lsl r10 ; x2 + rol r11 + lsl r10 ; x4 + rol r11 + + rcall ili9341BeginSpi ; (r16, r17) + rcall ili9341SetAddressWindow ; (R16, R20, R21) + pop r11 + pop r10 + pop r9 + pop r8 + ldi r16, ILI9341_CMD_RAMWR ; start writing ro RAM + rcall ili9341SendCommand + + mov r22, r10 + mov r23, r11 + ldi r17, 4 + cbi SPIHW_SS_OUTPUT, SPIHW_SS_PIN ; SS low + sbi ILI9341_DC_OUTPUT, ILI9341_DC_PIN ; D high (DATA) +ili9341BitBlitStretch4_loopH: + mov r20, xl ; preserve for next run + mov r21, xh + rcall ili9341BitBlitStretchNWriteLine ; (r16, r17, r18, r19, r24, r25, X) + mov xl, r20 + mov xh, r21 + rcall ili9341BitBlitStretchNWriteLine ; (r16, r17, r18, r19, r24, r25, X) + mov xl, r20 + mov xh, r21 + rcall ili9341BitBlitStretchNWriteLine ; (r16, r17, r18, r19, r24, r25, X) + mov xl, r20 + mov xh, r21 + rcall ili9341BitBlitStretchNWriteLine ; (r16, r17, r18, r19, r24, r25, X) + mov r24, r22 + mov r25, r23 + sbiw r25:r24, 1 + mov r22, r24 + mov r23, r25 + brne ili9341BitBlitStretch4_loopH + sbi SPIHW_SS_OUTPUT, SPIHW_SS_PIN ; SS high + rcall ili9341EndSpi ; (R16) + out SREG, r15 + pop r15 + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine ili9341BitBlitStretchNWriteLine + +; @param r9:r8 width +; @param r17 repeat factor +; @param X source position of line +; @clobbers r16, r17, r18, r19, r24, r25, X + +ili9341BitBlitStretchNWriteLine: + mov r24, r8 + mov r25, r9 +ili9341BitBlitStretchNWriteLine_loop1: + ld r18, X+ + ld r19, X+ + push r17 +ili9341BitBlitStretchNWriteLine_loop2: + mov r16, r19 + rcall SPIHW_MasterTransfer ; (R16) + mov r16, r18 + rcall SPIHW_MasterTransfer ; (R16) + dec r17 + brne ili9341BitBlitStretchNWriteLine_loop2 + pop r17 + sbiw r25:r24, 1 + brne ili9341BitBlitStretchNWriteLine_loop1 + ret +; @end + + + + diff --git a/avr/modules/lcd2/ili9341/io_spi.asm b/avr/modules/lcd2/ili9341/io_spi.asm new file mode 100644 index 0000000..a91629a --- /dev/null +++ b/avr/modules/lcd2/ili9341/io_spi.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. * +; *************************************************************************** + +; generally we use the following parameters here: +; @param r1:r0 background color +; @param r3:r2 foreground color +; @param r5:r4 X0 +; @param r7:r6 Y0 +; @param r9:r8 X1/W +; @param r11:r10 Y1/H + + +; *************************************************************************** +; defines + +.equ ILI9341_SPIMODE = (0< + + + + + main.asm + + + + + diff --git a/avr/modules/lcd2/xpt2046/main.asm b/avr/modules/lcd2/xpt2046/main.asm new file mode 100644 index 0000000..4e899e5 --- /dev/null +++ b/avr/modules/lcd2/xpt2046/main.asm @@ -0,0 +1,11 @@ +; *************************************************************************** +; 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. * +; *************************************************************************** + + + diff --git a/avr/modules/network/msg/defs.asm b/avr/modules/network/msg/defs.asm index 89d978e..e5b8c3d 100644 --- a/avr/modules/network/msg/defs.asm +++ b/avr/modules/network/msg/defs.asm @@ -63,6 +63,10 @@ +; --------------------------------------------------------------------------- +; special addresses + +.equ NET_MAINTENANCE_ADDR = 0xc1 diff --git a/avr/modules/network/msg/memstats-w.asm b/avr/modules/network/msg/memstats-w.asm index 00ac3a0..7317936 100644 --- a/avr/modules/network/msg/memstats-w.asm +++ b/avr/modules/network/msg/memstats-w.asm @@ -35,6 +35,12 @@ NETMSG_MemStats_Write: st X+, r16 st X+, r16 ; stack used +.ifdef MODULES_XRAM + lds r20, xramLastAddress + lds r21, xramLastAddress+1 + st X+, r20 + st X+, r21 +.else ldi r20, LOW(RAMEND) ldi r21, HIGH(RAMEND) in r17, SPL @@ -43,6 +49,7 @@ NETMSG_MemStats_Write: in r17, SPH sbc r21, r17 st X+, r21 +.endif ; current buffers used push xl push xh diff --git a/avr/modules/spi_hw/0BUILD b/avr/modules/spi_hw/0BUILD new file mode 100644 index 0000000..febd367 --- /dev/null +++ b/avr/modules/spi_hw/0BUILD @@ -0,0 +1,11 @@ + + + + + + main.asm + + + + + diff --git a/avr/modules/spi_hw/main.asm b/avr/modules/spi_hw/main.asm new file mode 100644 index 0000000..ea6fd7b --- /dev/null +++ b/avr/modules/spi_hw/main.asm @@ -0,0 +1,202 @@ +; *************************************************************************** +; 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 + +.equ SPIHW_MODE_SPEED0_BIT = 0 ; 00=CLK/4, 01=CLK/16 +.equ SPIHW_MODE_SPEED1_BIT = 1 ; 10=CLK/64, 11=CLK/128 +.equ SPIHW_MODE_DOUBLESPEED_BIT = 2 ; 1=double speed from SPIHW_MODE_SPEED0/1_BIT +.equ SPIHW_MODE_DATAORDER_BIT = 3 ; 1=LSB first, 0=MSB first +.equ SPIHW_MODE_CPOL_BIT = 4 ; 0=leading edge rising/trailing edge falling +.equ SPIHW_MODE_CPHA_BIT = 5 ; 0=sample on leading edge, setup on trailing edge + + + +; *************************************************************************** +; data + +.dseg + + + +; *************************************************************************** +; code + +.cseg + + + +; --------------------------------------------------------------------------- +; @routine SPIHW_Init @global +; + +SPIHW_Init: + sbi SPIHW_SS0_DDR, SPIHW_SS0_PIN ; SS0= output + sbi SPIHW_SS1_DDR, SPIHW_SS1_PIN ; SS1= output + sbi SPIHW_SS2_DDR, SPIHW_SS2_PIN ; SS2= output + sec + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine SPIHW_Fini @global +; + +SPIHW_Fini: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine SPIHW_MasterStart @global +; +; Start SPI hardware master with the given mode (see @ref SPIHW_MODE_SPEED0_BIT +; and others). + +; @param r16 mode +; @param r17 device num (0-7) +; @clobbers r17 + +SPIHW_MasterStart: + ; setup pins + sbi SPIHW_SS_DDR, SPIHW_SS_PIN ; SS : output + sbi SPIHW_MOSI_DDR, SPIHW_MOSI_PIN ; MOSI: output + cbi SPIHW_MISO_DDR, SPIHW_MISO_PIN ; MISO: input + sbi SPIHW_SCK_DDR, SPIHW_SCK_PIN ; SCK: output + + ; select device + sbi SPIHW_SS_OUTPUT, SPIHW_SS_PIN ; SS high + rcall spiHwSelectDevice ; (none) +; cbi SPIHW_SS_OUTPUT, SPIHW_SS_PIN ; SS low + + ; setup SPCR + clr r17 + sbrc r16, SPIHW_MODE_DATAORDER_BIT + sbr r17, (1< 7 per loop, max about 1000 + clc ; 1 + ret ; 4 +uartWaitForData_gotit: + sec ; 1 + ret ; 4 +; @end + + + + + +; --------------------------------------------------------------------------- +; @routine UART_StartRx @global +; +; @clobbers R16 + +UART_StartRx: + M_IO_READ r16, UCSRA ; clear errors + cbr r16, (1< + + + + + main.asm + + + + + diff --git a/avr/modules/xram/main.asm b/avr/modules/xram/main.asm new file mode 100644 index 0000000..44cd65e --- /dev/null +++ b/avr/modules/xram/main.asm @@ -0,0 +1,106 @@ +; *************************************************************************** +; 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 + + + +; *************************************************************************** +; data + +.dseg + +xramLastAddress: .byte 2 + + + + + +; *************************************************************************** +; code + +.cseg + + + +; --------------------------------------------------------------------------- +; @routine XRAM_Init @global +; + +XRAM_Init: + clr r16 + sts xramLastAddress, r16 + sts xramLastAddress+1, r16 + + M_IO_READ r16, MCUCR + sbr r16, (1<