added node r05.
This commit is contained in:
@@ -37,6 +37,8 @@
|
||||
n25
|
||||
n26
|
||||
n27
|
||||
r04
|
||||
r05
|
||||
t03
|
||||
</subdirs>
|
||||
|
||||
|
||||
2
avr/devices/r05/.gitignore
vendored
Normal file
2
avr/devices/r05/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*.eep.hex
|
||||
*.obj
|
||||
23
avr/devices/r05/0BUILD
Normal file
23
avr/devices/r05/0BUILD
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml?>
|
||||
|
||||
<gwbuild>
|
||||
|
||||
<subdirs>
|
||||
boot
|
||||
main
|
||||
test
|
||||
</subdirs>
|
||||
|
||||
<extradist>
|
||||
defs.asm
|
||||
README
|
||||
</extradist>
|
||||
|
||||
<data dist="true" install="$(datadir)/aqhome/devices/nodes">
|
||||
aqua_r05.xml
|
||||
</data>
|
||||
|
||||
|
||||
</gwbuild>
|
||||
|
||||
|
||||
0
avr/devices/r05/README
Normal file
0
avr/devices/r05/README
Normal file
24
avr/devices/r05/aqua_r05.xml
Normal file
24
avr/devices/r05/aqua_r05.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
<device name="aqua_r05" driver="nodes">
|
||||
<manufacturer>AQUA</manufacturer>
|
||||
<devicetype>R</devicetype>
|
||||
<deviceversion>5</deviceversion>
|
||||
|
||||
<values>
|
||||
<value name="DS18B20_TEMP" id="0x06" type="sensor" dataType="rational" modality="temperature" units="C" denom="16" />
|
||||
|
||||
<value name="stats_packets_in" id="0xe0" type="sensor" dataType="uint16" denom="1" />
|
||||
<value name="stats_packets_out" id="0xe1" type="sensor" dataType="uint16" denom="1" />
|
||||
<value name="stats_content_errors" id="0xe2" type="sensor" dataType="uint16" denom="1" />
|
||||
<value name="stats_io_errors" id="0xe3" type="sensor" dataType="uint16" denom="1" />
|
||||
<value name="stats_nobuf_errors" id="0xe4" type="sensor" dataType="uint16" denom="1" />
|
||||
<value name="stats_collision_errors" id="0xe5" type="sensor" dataType="uint16" denom="1" />
|
||||
<value name="stats_busy_errors" id="0xe6" type="sensor" dataType="uint16" denom="1" />
|
||||
|
||||
<value name="stats_packets2_in" id="0xe9" type="sensor" dataType="uint16" denom="1" />
|
||||
<value name="stats_packets2_out" id="0xe9" type="sensor" dataType="uint16" denom="1" />
|
||||
|
||||
<value name="LEDTIMING" id="0x88" type="actor" dataType="uint16" />
|
||||
</values>
|
||||
|
||||
</device>
|
||||
32
avr/devices/r05/boot/0BUILD
Normal file
32
avr/devices/r05/boot/0BUILD
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml?>
|
||||
|
||||
<gwbuild>
|
||||
|
||||
<target type="AvrHexFile" name="r05_boot" >
|
||||
|
||||
<includes type="avrasm" >
|
||||
-I $(builddir)
|
||||
-I $(srcdir)
|
||||
-I $(topsrcdir)/avr
|
||||
-I $(topbuilddir)/avr
|
||||
</includes>
|
||||
|
||||
|
||||
<sources type="avrasm" >
|
||||
boot.asm
|
||||
</sources>
|
||||
|
||||
|
||||
</target>
|
||||
|
||||
|
||||
<subdirs>
|
||||
</subdirs>
|
||||
|
||||
<extradist>
|
||||
</extradist>
|
||||
|
||||
|
||||
</gwbuild>
|
||||
|
||||
|
||||
151
avr/devices/r05/boot/boot.asm
Normal file
151
avr/devices/r05/boot/boot.asm
Normal file
@@ -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<<CLKPS1) | (1<<CLKPS0) ; SUT=0, CLKPS=0011b
|
||||
sts CCP, r17
|
||||
sts CLKPR, r16
|
||||
.endif
|
||||
|
||||
.if clock == 8000000
|
||||
ldi r17, 0xd8
|
||||
clr r16 ; SUT=0, CLKPS=0
|
||||
sts CCP, r17
|
||||
sts CLKPR, r16
|
||||
.endif
|
||||
ret
|
||||
|
||||
|
||||
|
||||
134
avr/devices/r05/defs.asm
Normal file
134
avr/devices/r05/defs.asm
Normal file
@@ -0,0 +1,134 @@
|
||||
; ***************************************************************************
|
||||
; 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. *
|
||||
; ***************************************************************************
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
;
|
||||
; AtTiny 841
|
||||
; -------
|
||||
; VCC 1 14 GND
|
||||
; PB0 2 13 PA0 ATTN0
|
||||
; ATTN1 PB1 3 12 PA1 TXD0 (UART0)
|
||||
; /RESET PB3 4 11 PA2 RXD0 (UART0)
|
||||
; 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]
|
||||
; -------
|
||||
;
|
||||
; when using ATTN1: LED=PA3, ATTN1=PB2 !!
|
||||
; ***************************************************************************
|
||||
|
||||
|
||||
|
||||
.equ BOOTLOADER_ADDR = 0xd00
|
||||
|
||||
.equ FIRMWARE_VARIANT_BOOT = 0
|
||||
.equ FIRMWARE_VARIANT_TEMP_WINDOW = 1
|
||||
|
||||
.equ DEVICEINFO_ID = 'R'
|
||||
.equ DEVICEINFO_VERSION = 5
|
||||
.equ DEVICEINFO_REVISION = 0
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; 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
|
||||
|
||||
; 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_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_ATTN0 = PCMSK0
|
||||
.equ COM_IRQ_BIT_ATTN0 = PCINT0 ; bit 0 in PCMSK0
|
||||
.equ COM_IRQ_GIFR_ATTN0 = PCIF0
|
||||
.equ COM_IRQ_GIMSK_ATTN0 = PCIE0
|
||||
|
||||
|
||||
; settings for comOnUart1
|
||||
.equ COM_ATTN1_DDR = DDRB
|
||||
.equ COM_ATTN1_INPUT = PINB
|
||||
.equ COM_ATTN1_OUTPUT = PORTB
|
||||
.equ COM_ATTN1_PUE = PUEB
|
||||
.equ COM_ATTN1_PIN = PORTB1
|
||||
|
||||
.equ COM_IRQ_ADDR_ATTN1 = PCMSK1
|
||||
.equ COM_IRQ_BIT_ATTN1 = PCINT9 ; bit PCINT9 in PCMSK1
|
||||
.equ COM_IRQ_GIFR_ATTN1 = PCIF1
|
||||
.equ COM_IRQ_GIMSK_ATTN1 = PCIE1
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; 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 = PORTA3
|
||||
|
||||
.equ TWI_DDR_SDA = DDRB
|
||||
.equ TWI_PORT_SDA = PORTB
|
||||
.equ TWI_PIN_SDA = PINB
|
||||
.equ TWI_PINNUM_SDA = PORTB0
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; 1-Wire Master
|
||||
;
|
||||
|
||||
.equ OWI_DDR = DDRA
|
||||
.equ OWI_PORTOUT = PORTA
|
||||
.equ OWI_PORTIN = PINA
|
||||
.equ OWI_PINNUM = PORTA7
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; ComOnUart module
|
||||
|
||||
.equ USART0_DATAREG = UDR0
|
||||
.equ USART1_DATAREG = UDR1
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; LCD module
|
||||
|
||||
.equ LCD_TWI_ADDRESS = 0x3c
|
||||
|
||||
|
||||
|
||||
|
||||
33
avr/devices/r05/main/0BUILD
Normal file
33
avr/devices/r05/main/0BUILD
Normal file
@@ -0,0 +1,33 @@
|
||||
<?xml?>
|
||||
|
||||
<gwbuild>
|
||||
|
||||
<target type="AvrHexFile" name="r05_firmware" >
|
||||
|
||||
<includes type="avrasm" >
|
||||
-I $(builddir)
|
||||
-I $(srcdir)
|
||||
-I $(topsrcdir)/avr
|
||||
-I $(topbuilddir)/avr
|
||||
</includes>
|
||||
|
||||
|
||||
<sources type="avrasm" >
|
||||
main.asm
|
||||
</sources>
|
||||
|
||||
|
||||
</target>
|
||||
|
||||
|
||||
|
||||
<subdirs>
|
||||
</subdirs>
|
||||
|
||||
<extradist>
|
||||
</extradist>
|
||||
|
||||
|
||||
</gwbuild>
|
||||
|
||||
|
||||
347
avr/devices/r05/main/main.asm
Normal file
347
avr/devices/r05/main/main.asm
Normal file
@@ -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<<NET_IFACE_BUFFER_IFACENUM1_BIT) | (1<<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
|
||||
|
||||
|
||||
|
||||
#ifdef APPS_STATS
|
||||
sendPacketsIface2In:
|
||||
ldi yl, LOW(netInterfaceData)
|
||||
ldi yh, HIGH(netInterfaceData)
|
||||
ldi r17, AQHOME_VALUEID_STATS_PACKETS_IN2
|
||||
lds r18, comOnUart1_iface+NET_IFACE_OFFS_PACKETSIN_LOW
|
||||
lds r19, comOnUart1_iface+NET_IFACE_OFFS_PACKETSIN_HIGH
|
||||
rjmp appStatsSend16BitValue
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; includes
|
||||
|
||||
.include "devices/all/hw_tn841.asm"
|
||||
.include "devices/all/includes.asm"
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; defines for network interface
|
||||
|
||||
.equ netInterfaceData = comOnUart0_iface
|
||||
|
||||
|
||||
|
||||
33
avr/devices/r05/test/0BUILD
Normal file
33
avr/devices/r05/test/0BUILD
Normal file
@@ -0,0 +1,33 @@
|
||||
<?xml?>
|
||||
|
||||
<gwbuild>
|
||||
|
||||
<target type="AvrHexFile" name="r05_test" >
|
||||
|
||||
<includes type="avrasm" >
|
||||
-I $(builddir)
|
||||
-I $(srcdir)
|
||||
-I $(topsrcdir)/avr
|
||||
-I $(topbuilddir)/avr
|
||||
</includes>
|
||||
|
||||
|
||||
<sources type="avrasm" >
|
||||
main.asm
|
||||
</sources>
|
||||
|
||||
|
||||
</target>
|
||||
|
||||
|
||||
|
||||
<subdirs>
|
||||
</subdirs>
|
||||
|
||||
<extradist>
|
||||
</extradist>
|
||||
|
||||
|
||||
</gwbuild>
|
||||
|
||||
|
||||
242
avr/devices/r05/test/main.asm
Normal file
242
avr/devices/r05/test/main.asm
Normal file
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user