t03: use comonuart0 from uart_hw2
This commit is contained in:
@@ -54,16 +54,28 @@
|
|||||||
|
|
||||||
.equ COM_BIT_LENGTH = 52000 ; 104000ns=9600, 52000ns=19200, 26000ns=38400
|
.equ COM_BIT_LENGTH = 52000 ; 104000ns=9600, 52000ns=19200, 26000ns=38400
|
||||||
|
|
||||||
.equ COM_ATTN_DDR = DDRA
|
.equ COM_ATTN0_DDR = DDRA
|
||||||
.equ COM_ATTN_INPUT = PINA
|
.equ COM_ATTN0_INPUT = PINA
|
||||||
.equ COM_ATTN_OUTPUT = PORTA
|
.equ COM_ATTN0_OUTPUT = PORTA
|
||||||
.equ COM_ATTN_PUE = PUEA
|
.equ COM_ATTN0_PUE = PUEA
|
||||||
.equ COM_ATTN_PIN = PORTA0
|
.equ COM_ATTN0_PIN = PORTA0
|
||||||
|
|
||||||
.equ COM_IRQ_ADDR_ATTN = PCMSK0
|
.equ COM_IRQ_ADDR_ATTN0 = PCMSK0
|
||||||
.equ COM_IRQ_BIT_ATTN = PCINT0 ; bit 0 in PCMSK0
|
.equ COM_IRQ_BIT_ATTN0 = PCINT0 ; bit 0 in PCMSK0
|
||||||
.equ COM_IRQ_GIFR_ATTN = PCIF0
|
.equ COM_IRQ_GIFR_ATTN0 = PCIF0
|
||||||
.equ COM_IRQ_GIMSK_ATTN = PCIE0
|
.equ COM_IRQ_GIMSK_ATTN0 = PCIE0
|
||||||
|
|
||||||
|
; compatibility
|
||||||
|
.equ COM_ATTN_DDR = COM_ATTN0_DDR
|
||||||
|
.equ COM_ATTN_INPUT = COM_ATTN0_INPUT
|
||||||
|
.equ COM_ATTN_OUTPUT = COM_ATTN0_OUTPUT
|
||||||
|
.equ COM_ATTN_PUE = COM_ATTN0_PUE
|
||||||
|
.equ COM_ATTN_PIN = COM_ATTN0_PIN
|
||||||
|
|
||||||
|
.equ COM_IRQ_ADDR_ATTN = COM_IRQ_ADDR_ATTN0
|
||||||
|
.equ COM_IRQ_BIT_ATTN = COM_IRQ_BIT_ATTN0
|
||||||
|
.equ COM_IRQ_GIFR_ATTN = COM_IRQ_GIFR_ATTN0
|
||||||
|
.equ COM_IRQ_GIMSK_ATTN = COM_IRQ_GIMSK_ATTN0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -47,12 +47,16 @@
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; generic
|
; generic
|
||||||
|
|
||||||
|
.equ COMONUART0_IFACENUM = 1
|
||||||
|
.equ TTYONUART1_IFACENUM = 2
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; firmware settings including list of modules used
|
; firmware settings including list of modules used
|
||||||
|
|
||||||
|
|
||||||
#define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes
|
#define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes
|
||||||
|
#define APP_STATS_NETDEV2
|
||||||
|
|
||||||
#define MODULES_CLOCK
|
#define MODULES_CLOCK
|
||||||
;#define MODULES_COM
|
;#define MODULES_COM
|
||||||
@@ -70,13 +74,14 @@
|
|||||||
;#define MODULES_DS18B20
|
;#define MODULES_DS18B20
|
||||||
;#define MODULES_MOTION
|
;#define MODULES_MOTION
|
||||||
#define MODULES_NETWORK
|
#define MODULES_NETWORK
|
||||||
#define MODULES_TTYONUART1
|
|
||||||
#define MODULES_COMONUART0
|
#define MODULES_COMONUART0
|
||||||
|
#define MODULES_TTYONUART1
|
||||||
#define APPS_STATS
|
#define APPS_STATS
|
||||||
|
#define APPS_NETWORK
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.equ NET_BUFFERS_NUM = 8
|
.equ NET_BUFFERS_NUM = 10
|
||||||
.equ NET_BUFFERS_SIZE = 32
|
.equ NET_BUFFERS_SIZE = 32
|
||||||
|
|
||||||
.equ UART_HW_MSGNUMINBUF_SIZE = 8
|
.equ UART_HW_MSGNUMINBUF_SIZE = 8
|
||||||
@@ -87,6 +92,8 @@
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; defines for values
|
; defines for values
|
||||||
|
|
||||||
|
.equ VALUE_ID_DS18B20_TEMP = 0x06
|
||||||
|
|
||||||
.equ VALUE_ID_LEDSIMPLE_TIMING = 0x88
|
.equ VALUE_ID_LEDSIMPLE_TIMING = 0x88
|
||||||
|
|
||||||
|
|
||||||
@@ -103,7 +110,7 @@
|
|||||||
|
|
||||||
rjmp BOOTLOADER_ADDR ; 1: RESET Reset vector use this for flashed system
|
rjmp BOOTLOADER_ADDR ; 1: RESET Reset vector use this for flashed system
|
||||||
reti ; 2: INT0 External Interrupt Request 0
|
reti ; 2: INT0 External Interrupt Request 0
|
||||||
rjmp ComOnUart0_AttnChangeIsr ; 3: PCINT0 Pin Change Interrupt 0
|
rjmp ComOnUart0AttnChangeIsr ; 3: PCINT0 Pin Change Interrupt 0
|
||||||
reti ; 4: PCINT1 Pin Change Interrupt 1
|
reti ; 4: PCINT1 Pin Change Interrupt 1
|
||||||
reti ; 5: WDT Watchdog Time-out
|
reti ; 5: WDT Watchdog Time-out
|
||||||
reti ; 6: TIM1_CAPT Timer/Counter1 Capture Event
|
reti ; 6: TIM1_CAPT Timer/Counter1 Capture Event
|
||||||
@@ -157,15 +164,18 @@ firmwareStart:
|
|||||||
; @routine onSystemStart
|
; @routine onSystemStart
|
||||||
|
|
||||||
onSystemStart:
|
onSystemStart:
|
||||||
|
; set interface number for UART0
|
||||||
|
ldi r16, COMONUART0_IFACENUM
|
||||||
|
sts comOnUart0_iface+NET_IFACE_OFFS_IFACENUM, r16
|
||||||
|
; set interface number for UART1
|
||||||
|
ldi r16, TTYONUART1_IFACENUM
|
||||||
|
sts ttyOnUart1_iface+NET_IFACE_OFFS_IFACENUM, r16
|
||||||
|
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
onEvery100ms:
|
onEvery100ms:
|
||||||
onEverySecond:
|
onEverySecond:
|
||||||
onEveryMinute:
|
onEveryMinute:
|
||||||
@@ -213,16 +223,14 @@ checkRecvdMsg:
|
|||||||
push xl
|
push xl
|
||||||
push xh
|
push xh
|
||||||
adiw xh:xl, 1
|
adiw xh:xl, 1
|
||||||
rcall onMessageReceived
|
rcall letSysHandleMsg
|
||||||
rcall mainModulesOnPacketReceived
|
|
||||||
rcall mainAppsOnPacketReceived
|
|
||||||
pop xh
|
pop xh
|
||||||
pop xl
|
pop xl
|
||||||
pop r16
|
pop r16
|
||||||
|
|
||||||
; forward to other interface
|
; forward to other interface
|
||||||
ld r17, X
|
ld r17, X
|
||||||
andi r17, (NET_IFACE_BUFFER_IFACENUM1_BIT | NET_IFACE_BUFFER_IFACENUM0_BIT)
|
andi r17, (1<<NET_IFACE_BUFFER_IFACENUM1_BIT) | (1<<NET_IFACE_BUFFER_IFACENUM0_BIT)
|
||||||
rcall reverseInterfaceNum ; (R17)
|
rcall reverseInterfaceNum ; (R17)
|
||||||
; ldi r17, TTYONUART1_IFACENUM ; DEBUG: send everything to uart1 to test that code first
|
; ldi r17, TTYONUART1_IFACENUM ; DEBUG: send everything to uart1 to test that code first
|
||||||
rcall addMsgToInterface
|
rcall addMsgToInterface
|
||||||
@@ -235,6 +243,35 @@ checkRecvdMsg_end:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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
|
; @routine reverseInterfaceNum
|
||||||
;
|
;
|
||||||
@@ -243,6 +280,7 @@ checkRecvdMsg_end:
|
|||||||
; @clobbers r17
|
; @clobbers r17
|
||||||
|
|
||||||
reverseInterfaceNum:
|
reverseInterfaceNum:
|
||||||
|
andi r17, (1<<NET_IFACE_BUFFER_IFACENUM1_BIT) | (1<<NET_IFACE_BUFFER_IFACENUM0_BIT)
|
||||||
cpi r17, COMONUART0_IFACENUM
|
cpi r17, COMONUART0_IFACENUM
|
||||||
brne reverseInterfaceNum_notUart0
|
brne reverseInterfaceNum_notUart0
|
||||||
ldi r17, TTYONUART1_IFACENUM
|
ldi r17, TTYONUART1_IFACENUM
|
||||||
@@ -261,19 +299,19 @@ reverseInterfaceNum_notUart0:
|
|||||||
|
|
||||||
addMsgToInterface:
|
addMsgToInterface:
|
||||||
cpi r17, COMONUART0_IFACENUM
|
cpi r17, COMONUART0_IFACENUM
|
||||||
brne addMsgToInterface_notUart0
|
breq addMsgToInterface_toUart0
|
||||||
|
cpi r17, TTYONUART1_IFACENUM
|
||||||
|
breq addMsgToInterface_toUart1
|
||||||
|
clc
|
||||||
|
ret
|
||||||
|
addMsgToInterface_toUart0:
|
||||||
ldi yl, LOW(comOnUart0_iface)
|
ldi yl, LOW(comOnUart0_iface)
|
||||||
ldi yh, HIGH(comOnUart0_iface)
|
ldi yh, HIGH(comOnUart0_iface)
|
||||||
rjmp NET_Interface_AddOutgoingMsgNum ; try to add msg to interface
|
rjmp NET_Interface_AddOutgoingMsgNum ; try to add msg to interface
|
||||||
addMsgToInterface_notUart0:
|
addMsgToInterface_toUart1:
|
||||||
cpi r17, TTYONUART1_IFACENUM
|
|
||||||
brne addMsgToInterface_end
|
|
||||||
ldi yl, LOW(ttyOnUart1_iface)
|
ldi yl, LOW(ttyOnUart1_iface)
|
||||||
ldi yh, HIGH(ttyOnUart1_iface)
|
ldi yh, HIGH(ttyOnUart1_iface)
|
||||||
rjmp NET_Interface_AddOutgoingMsgNum ; try to add msg to interface
|
rjmp NET_Interface_AddOutgoingMsgNum ; try to add msg to interface
|
||||||
addMsgToInterface_end:
|
|
||||||
clc
|
|
||||||
ret
|
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
|
|
||||||
@@ -286,6 +324,7 @@ addMsgToInterface_end:
|
|||||||
|
|
||||||
.include "devices/all/hw_tn841.asm"
|
.include "devices/all/hw_tn841.asm"
|
||||||
.include "devices/all/includes.asm"
|
.include "devices/all/includes.asm"
|
||||||
|
.include "common/debug.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -293,7 +332,6 @@ addMsgToInterface_end:
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; defines for network interface
|
; defines for network interface
|
||||||
|
|
||||||
.equ netInterfaceData = ttyOnUart1_iface
|
.equ netInterfaceData = ttyOnUart1_iface
|
||||||
|
.equ netInterfaceData2 = comOnUart0_iface
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user