cleanup build system.
This commit is contained in:
@@ -24,14 +24,6 @@
|
||||
;.equ clock=1000000 ; Define the clock frequency
|
||||
.equ clock=8000000 ; Define the clock frequency
|
||||
|
||||
;.equ SEND_DEVICE_EVERY = 3000
|
||||
.equ SEND_DEVICE_EVERY = 3000 ; every 5mins
|
||||
.equ SEND_STATS_EVERY = 3100 ; about every 5mins
|
||||
;.equ SEND_STATS_EVERY = 300 ; every 30s
|
||||
;.equ SEND_DEBUG_EVERY = 110
|
||||
|
||||
;#define WITH_SEND_DEBUG
|
||||
|
||||
|
||||
.nolist
|
||||
.include "include/tn841def.inc" ; Define device ATtiny841
|
||||
@@ -60,7 +52,9 @@
|
||||
.equ FIRMWARE_VERSION_PATCHLEVEL = 1
|
||||
|
||||
|
||||
;#define MODULES_TIMER
|
||||
#define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes
|
||||
|
||||
#define MODULES_CLOCK
|
||||
;#define MODULES_COM
|
||||
;#define MODULES_COM_WITH_ADDR_PROTO
|
||||
;#define MODULES_LED
|
||||
@@ -75,6 +69,11 @@
|
||||
;#define MODULES_OWI_MASTER
|
||||
;#define MODULES_DS18B20
|
||||
;#define MODULES_MOTION
|
||||
#define MODULES_NETWORK
|
||||
#define MODULES_TTYONUART1
|
||||
#define MODULES_COMONUART0
|
||||
#define APPS_STATS
|
||||
|
||||
|
||||
|
||||
.equ NET_BUFFERS_NUM = 8
|
||||
@@ -138,375 +137,80 @@ firmwareVersion: .db FIRMWARE_VARIANT_TEMP_WINDOW, FIRMWARE_VERSION_MAJOR
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine firmwareStart @global
|
||||
|
||||
firmwareStart:
|
||||
cli
|
||||
; setup stack
|
||||
.ifdef SPH ; if SPH is defined
|
||||
ldi r16, High(RAMEND)
|
||||
out SPH, r16 ; init MSB stack pointer
|
||||
.endif
|
||||
ldi r16, Low(RAMEND)
|
||||
out SPL, r16 ; init LSB stack pointer
|
||||
rjmp main
|
||||
; @end
|
||||
|
||||
rcall systemSetSpeed
|
||||
rcall initHardware
|
||||
; rcall watchdogOff ; turn off watchdog timer (sometimes it stays on after reboot)
|
||||
|
||||
rcall Utils_Init
|
||||
rcall Utils_SetupUid
|
||||
|
||||
rcall initModules
|
||||
|
||||
sbi LED_SIMPLE_DDR, LED_SIMPLE_PINNUM ; out
|
||||
sbi LED_SIMPLE_PORT, LED_SIMPLE_PINNUM ; off
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine onSystemStart
|
||||
|
||||
sei
|
||||
main_loop:
|
||||
rcall BaseTimer_Run
|
||||
rcall TtyOnUart1_Run
|
||||
rcall ComOnUart0_Run
|
||||
|
||||
; check incoming msg
|
||||
rcall checkRecvdMsg
|
||||
; rcall freeRecvdMsg
|
||||
|
||||
; only modify SE, SM1 and SM0
|
||||
cli
|
||||
in r16, MCUCR
|
||||
ldi r17, (1<<SE) | (1<<SM1) | (1<<SM0)
|
||||
neg r17
|
||||
and r16, r17
|
||||
ori r16, (1<<SE) ; sleep mode "idle", enable
|
||||
out MCUCR, r16
|
||||
sei ; make sure interrupts really are enabled
|
||||
sleep ; sleep, wait for interrupt
|
||||
|
||||
rjmp main_loop
|
||||
onSystemStart:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
onEvery100ms:
|
||||
onEverySecond:
|
||||
onEveryMinute:
|
||||
onEveryHour:
|
||||
onEveryDay:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every 100ms. Add your routine calls here. No arguments, no results.
|
||||
; @routine onEveryLoop
|
||||
;
|
||||
; Called on every loop (i.e. after awakening from sleep).
|
||||
|
||||
onSystemTimerTick:
|
||||
#ifdef MODULES_LED_SIMPLE
|
||||
rcall LedSimple_Every100ms
|
||||
#endif
|
||||
rcall TtyOnUart1_Periodically
|
||||
rcall ComOnUart0_Periodically
|
||||
#ifdef WITH_SEND_DEBUG
|
||||
rcall sendDebug
|
||||
#endif
|
||||
; rcall maybeSendDeviceMsg
|
||||
rcall maybeSendTStatsMsg
|
||||
rcall maybeSendRStatsMsg
|
||||
rcall maybeSendMStatsMsg
|
||||
ret
|
||||
|
||||
|
||||
|
||||
initHardware:
|
||||
; set all ports as inputs and enable internal pull-up resistors
|
||||
ldi r16, 0xff
|
||||
clr r17
|
||||
.ifdef PORTA
|
||||
out DDRA, r17 ; all input
|
||||
sts PUEA, r16 ; enable pull-up on all
|
||||
.endif
|
||||
|
||||
.ifdef PORTB
|
||||
out DDRB, r17 ; all input
|
||||
sts PUEB, r16 ; enable pull-up on all
|
||||
.endif
|
||||
|
||||
.ifdef PORTC
|
||||
out DDRC, r17 ; all input
|
||||
sts PUEC, r16 ; enable pull-up on all
|
||||
.endif
|
||||
onEveryLoop:
|
||||
rcall checkRecvdMsg
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
initModules:
|
||||
rcall BaseTimer_Init
|
||||
rcall LedSimple_Init
|
||||
rcall NET_Init
|
||||
rcall TtyOnUart1_Init
|
||||
ldi r16, 0xfe
|
||||
sts ttyOnUart1_iface+NET_IFACE_OFFS_ADDRESS, r16
|
||||
rcall ComOnUart0_Init
|
||||
|
||||
ldi r16, LOW(SEND_DEVICE_EVERY)
|
||||
sts deviceCounter, r16
|
||||
ldi r16, HIGH(SEND_DEVICE_EVERY)
|
||||
sts deviceCounter+1, r16
|
||||
|
||||
ldi r16, LOW(SEND_STATS_EVERY)
|
||||
sts sendTStatsCounter, r16
|
||||
ldi r16, HIGH(SEND_STATS_EVERY)
|
||||
sts sendTStatsCounter+1, r16
|
||||
|
||||
ldi r16, LOW(SEND_STATS_EVERY+10)
|
||||
sts sendRStatsCounter, r16
|
||||
ldi r16, HIGH(SEND_STATS_EVERY+10)
|
||||
sts sendRStatsCounter+1, r16
|
||||
|
||||
ldi r16, LOW(SEND_STATS_EVERY+20)
|
||||
sts sendMStatsCounter, r16
|
||||
ldi r16, HIGH(SEND_STATS_EVERY+20)
|
||||
sts sendMStatsCounter+1, r16
|
||||
|
||||
#ifdef WITH_SEND_DEBUG
|
||||
ldi r16, LOW(SEND_DEBUG_EVERY)
|
||||
sts debugMsgCounter, r16
|
||||
ldi r16, HIGH(SEND_DEBUG_EVERY)
|
||||
sts debugMsgCounter+1, r16
|
||||
#endif
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine onMessageReceived
|
||||
;
|
||||
; Called on every message received
|
||||
|
||||
onMessageReceived:
|
||||
clc
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; includes
|
||||
|
||||
.include "common/utils.asm"
|
||||
.include "common/utils_wait.asm"
|
||||
.include "common/utils_wait_fixed.asm"
|
||||
.include "common/utils_copy_from_flash.asm"
|
||||
.include "common/utils_copy_sdram.asm"
|
||||
.include "common/m_ringbuffer_y.asm"
|
||||
.include "common/ringbuffer_y.asm"
|
||||
.include "common/m_fixedbuffers.asm"
|
||||
.include "modules/basetimer/main.asm"
|
||||
.include "modules/led_simple/main.asm"
|
||||
.include "modules/network/defs.asm"
|
||||
.include "modules/network/buffer.asm"
|
||||
.include "modules/network/data.asm"
|
||||
.include "modules/network/main.asm"
|
||||
.include "modules/network/iface.asm"
|
||||
.include "modules/network/msg/defs.asm"
|
||||
.include "modules/network/msg/common.asm"
|
||||
.include "modules/network/msg/crc.asm"
|
||||
.include "modules/network/msg/device-w.asm"
|
||||
.include "modules/network/msg/sendstats-w.asm"
|
||||
.include "modules/network/msg/recvstats-w.asm"
|
||||
.include "modules/network/msg/memstats-w.asm"
|
||||
.include "modules/network/msg/debug-w.asm"
|
||||
|
||||
.include "modules/uart_hw/defs.asm"
|
||||
.include "modules/uart_hw/lowlevel.asm"
|
||||
.include "modules/uart_hw/m_lowlevel_uart.asm"
|
||||
.include "modules/uart_hw/ttyonuart1.asm"
|
||||
.include "modules/uart_hw/comonuart0.asm"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
maybeSendDeviceMsg:
|
||||
ldi yl, LOW(ttyOnUart1_iface)
|
||||
ldi yh, HIGH(ttyOnUart1_iface)
|
||||
|
||||
lds r24, deviceCounter
|
||||
lds r25, deviceCounter+1
|
||||
sbiw r25:r24, 1
|
||||
brne maybeSendDeviceMsg_storeCounter
|
||||
; send device msg
|
||||
rcall NET_Buffer_Alloc ; (R16, R17, X)
|
||||
brcc maybeSendDeviceMsg_end
|
||||
push r16
|
||||
adiw xh:xl, 1
|
||||
rcall NETMSG_Device_Write ; (R16, R17, R18, R19, R20, R21, Z)
|
||||
sbiw xh:xl, 1
|
||||
pop r16
|
||||
rcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X)
|
||||
brcc maybeSendDeviceMsg_end
|
||||
; reset counter
|
||||
maybeSendDeviceMsg_resetCounter:
|
||||
ldi r24, LOW(SEND_DEVICE_EVERY)
|
||||
ldi r25, HIGH(SEND_DEVICE_EVERY)
|
||||
maybeSendDeviceMsg_storeCounter:
|
||||
sts deviceCounter, r24
|
||||
sts deviceCounter+1, r25
|
||||
maybeSendDeviceMsg_end:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
maybeSendTStatsMsg:
|
||||
ldi yl, LOW(ttyOnUart1_iface)
|
||||
ldi yh, HIGH(ttyOnUart1_iface)
|
||||
|
||||
lds r24, sendTStatsCounter
|
||||
lds r25, sendTStatsCounter+1
|
||||
sbiw r25:r24, 1
|
||||
brne maybeSendTStatsMsg_storeCounter
|
||||
|
||||
rcall sendTStatsForUart0ToUart1
|
||||
|
||||
; reset counter
|
||||
maybeSendTStatsMsg_resetCounter:
|
||||
ldi r24, LOW(SEND_STATS_EVERY)
|
||||
ldi r25, HIGH(SEND_STATS_EVERY)
|
||||
maybeSendTStatsMsg_storeCounter:
|
||||
sts sendTStatsCounter, r24
|
||||
sts sendTStatsCounter+1, r25
|
||||
maybeSendTStatsMsg_end:
|
||||
ret
|
||||
|
||||
|
||||
sendTStatsForUart0ToUart1:
|
||||
push yl
|
||||
push yh
|
||||
; send device msg
|
||||
rcall NET_Buffer_Alloc ; (R16, R17, X)
|
||||
brcc sendTStatsForUart0ToUart1_end
|
||||
push r16
|
||||
ldi yl, LOW(comOnUart0_iface)
|
||||
ldi yh, HIGH(comOnUart0_iface)
|
||||
adiw xh:xl, 1
|
||||
rcall NETMSG_SendStats_Write ; (R16, R17, R18, R19, R20, R21, Z)
|
||||
sbiw xh:xl, 1
|
||||
pop r16
|
||||
ldi yl, LOW(ttyOnUart1_iface)
|
||||
ldi yh, HIGH(ttyOnUart1_iface)
|
||||
rcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X)
|
||||
sendTStatsForUart0ToUart1_end:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
|
||||
|
||||
|
||||
maybeSendRStatsMsg:
|
||||
ldi yl, LOW(ttyOnUart1_iface)
|
||||
ldi yh, HIGH(ttyOnUart1_iface)
|
||||
|
||||
lds r24, sendRStatsCounter
|
||||
lds r25, sendRStatsCounter+1
|
||||
sbiw r25:r24, 1
|
||||
brne maybeSendRStatsMsg_storeCounter
|
||||
|
||||
rcall sendRStatsForUart0ToUart1
|
||||
; rcall sendRStatsForUart1ToUart1
|
||||
|
||||
; reset counter
|
||||
maybeSendRStatsMsg_resetCounter:
|
||||
ldi r24, LOW(SEND_STATS_EVERY)
|
||||
ldi r25, HIGH(SEND_STATS_EVERY)
|
||||
maybeSendRStatsMsg_storeCounter:
|
||||
sts sendRStatsCounter, r24
|
||||
sts sendRStatsCounter+1, r25
|
||||
maybeSendRStatsMsg_end:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
sendRStatsForUart0ToUart1:
|
||||
push yl
|
||||
push yh
|
||||
; send device msg
|
||||
rcall NET_Buffer_Alloc ; (R16, R17, X)
|
||||
brcc sendRStatsForUart0ToUart1_end
|
||||
push r16
|
||||
ldi yl, LOW(comOnUart0_iface)
|
||||
ldi yh, HIGH(comOnUart0_iface)
|
||||
adiw xh:xl, 1
|
||||
rcall NETMSG_RecvStats_Write ; (R16, R17, R18, R19, R20, R21, Z)
|
||||
sbiw xh:xl, 1
|
||||
pop r16
|
||||
ldi yl, LOW(ttyOnUart1_iface)
|
||||
ldi yh, HIGH(ttyOnUart1_iface)
|
||||
rcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X)
|
||||
sendRStatsForUart0ToUart1_end:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
|
||||
|
||||
|
||||
sendRStatsForUart1ToUart1:
|
||||
push yl
|
||||
push yh
|
||||
ldi yl, LOW(ttyOnUart1_iface)
|
||||
ldi yh, HIGH(ttyOnUart1_iface)
|
||||
; send device msg
|
||||
rcall NET_Buffer_Alloc ; (R16, R17, X)
|
||||
brcc sendRStatsForUart1ToUart1_end
|
||||
push r16
|
||||
adiw xh:xl, 1
|
||||
rcall NETMSG_RecvStats_Write ; (R16, R17, R18, R19, R20, R21, Z)
|
||||
sbiw xh:xl, 1
|
||||
pop r16
|
||||
rcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X)
|
||||
sendRStatsForUart1ToUart1_end:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
|
||||
|
||||
|
||||
maybeSendMStatsMsg:
|
||||
ldi yl, LOW(ttyOnUart1_iface)
|
||||
ldi yh, HIGH(ttyOnUart1_iface)
|
||||
|
||||
lds r24, sendMStatsCounter
|
||||
lds r25, sendMStatsCounter+1
|
||||
sbiw r25:r24, 1
|
||||
brne maybeSendMStatsMsg_storeCounter
|
||||
; send device msg
|
||||
rcall NET_Buffer_Alloc ; (R16, R17, X)
|
||||
; brcc maybeSendTStatsMsg_resetCounter
|
||||
brcc maybeSendMStatsMsg_end
|
||||
push r16
|
||||
adiw xh:xl, 1
|
||||
rcall NETMSG_MemStats_Write ; (R16, R17, R18, R19, R20, R21)
|
||||
sbiw xh:xl, 1
|
||||
pop r16
|
||||
rcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X)
|
||||
brcc maybeSendMStatsMsg_end
|
||||
; reset counter
|
||||
maybeSendMStatsMsg_resetCounter:
|
||||
ldi r24, LOW(SEND_STATS_EVERY)
|
||||
ldi r25, HIGH(SEND_STATS_EVERY)
|
||||
maybeSendMStatsMsg_storeCounter:
|
||||
sts sendMStatsCounter, r24
|
||||
sts sendMStatsCounter+1, r25
|
||||
maybeSendMStatsMsg_end:
|
||||
ret
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine checkRecvdMsg
|
||||
;
|
||||
; Read messages from either interface and forward to the other one.
|
||||
|
||||
checkRecvdMsg:
|
||||
rcall NET_PeekNextIncomingMsgNum ; check read queue (bufNum->r16)
|
||||
brcc checkRecvdMsg_end ; no msg, jmp
|
||||
rcall NET_Buffer_Locate ; (R17)
|
||||
; let system handle incoming messages
|
||||
push xl
|
||||
push xh
|
||||
rcall onMessageReceived
|
||||
rcall mainModulesOnPacketReceived
|
||||
rcall mainAppsOnPacketReceived
|
||||
pop xh
|
||||
pop xl
|
||||
|
||||
; forward to other interface
|
||||
ld r17, X
|
||||
andi r17, (NET_IFACE_BUFFER_IFACENUM1_BIT | NET_IFACE_BUFFER_IFACENUM0_BIT)
|
||||
rcall reverseInterfaceNum ; (R17)
|
||||
@@ -517,20 +221,15 @@ checkRecvdMsg:
|
||||
rjmp checkRecvdMsg
|
||||
checkRecvdMsg_end:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
freeRecvdMsg:
|
||||
rcall NET_GetNextIncomingMsgNum ; take off the queue
|
||||
brcc freeRecvdMsg_end
|
||||
rcall NET_Buffer_ReleaseByNum ; delete
|
||||
freeRecvdMsg_end:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; @return r17 reversed interface number
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine reverseInterfaceNum
|
||||
;
|
||||
; @param r17 buffer num
|
||||
; @return r17 reversed interface number
|
||||
; @clobbers r17
|
||||
|
||||
reverseInterfaceNum:
|
||||
@@ -545,6 +244,8 @@ reverseInterfaceNum_notUart0:
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine addMsgToInterface
|
||||
; @param r16 buffer num
|
||||
; @param r17 interface num
|
||||
|
||||
@@ -566,184 +267,23 @@ addMsgToInterface_end:
|
||||
; @end
|
||||
|
||||
|
||||
#ifdef WITH_SEND_DEBUG
|
||||
sendDebug:
|
||||
ldi yl, LOW(ttyOnUart1_iface)
|
||||
ldi yh, HIGH(ttyOnUart1_iface)
|
||||
|
||||
lds r24, debugMsgCounter
|
||||
lds r25, debugMsgCounter+1
|
||||
sbiw r25:r24, 1
|
||||
brne sendDebug_storeCounter
|
||||
; send device msg
|
||||
rcall NET_Buffer_Alloc ; (R16, R17, X)
|
||||
brcc sendDebug_end
|
||||
push r16
|
||||
adiw xh:xl, 1
|
||||
rcall writeDebugMsg
|
||||
sbiw xh:xl, 1
|
||||
pop r16
|
||||
rcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X)
|
||||
brcc sendDebug_end
|
||||
; reset counter
|
||||
sendDebug_resetCounter:
|
||||
ldi r24, LOW(SEND_DEBUG_EVERY)
|
||||
ldi r25, HIGH(SEND_DEBUG_EVERY)
|
||||
sendDebug_storeCounter:
|
||||
sts debugMsgCounter, r24
|
||||
sts debugMsgCounter+1, r25
|
||||
sendDebug_end:
|
||||
ret
|
||||
|
||||
|
||||
writeDebugMsg:
|
||||
push yl
|
||||
push yh
|
||||
ldi yl, LOW(netBuffers)
|
||||
ldi yh, HIGH(netBuffers)
|
||||
|
||||
rcall writeBufferInfoToRegs
|
||||
mov r0, r17
|
||||
mov r1, r18
|
||||
adiw yh:yl, NET_BUFFERS_SIZE
|
||||
|
||||
rcall writeBufferInfoToRegs
|
||||
mov r2, r17
|
||||
mov r3, r18
|
||||
adiw yh:yl, NET_BUFFERS_SIZE
|
||||
|
||||
rcall writeBufferInfoToRegs
|
||||
mov r4, r17
|
||||
mov r5, r18
|
||||
adiw yh:yl, NET_BUFFERS_SIZE
|
||||
|
||||
rcall writeBufferInfoToRegs
|
||||
mov r6, r17
|
||||
mov r7, r18
|
||||
adiw yh:yl, NET_BUFFERS_SIZE
|
||||
|
||||
rcall writeBufferInfoToRegs
|
||||
mov r8, r17
|
||||
mov r9, r18
|
||||
adiw yh:yl, NET_BUFFERS_SIZE
|
||||
|
||||
rcall writeBufferInfoToRegs
|
||||
mov r10, r17
|
||||
mov r11, r18
|
||||
adiw yh:yl, NET_BUFFERS_SIZE
|
||||
|
||||
clr r12
|
||||
clr r13
|
||||
|
||||
push xl
|
||||
push xh
|
||||
rcall NET_Buffer_CountUsed
|
||||
pop xh
|
||||
pop xl
|
||||
mov r14, r16
|
||||
pop yh
|
||||
pop yl
|
||||
|
||||
rcall NETMSG_Debug_Write ; (R16, R17, R18, R19, R20, R21, Z)
|
||||
ret
|
||||
|
||||
|
||||
|
||||
writeBufferInfoToRegs:
|
||||
ldi r17, 0xff
|
||||
ldi r18, 0xff
|
||||
ld r16, Y
|
||||
andi r16, 0x80
|
||||
breq writeBufferInfoToRegs_end
|
||||
ldd r17, Y+(1+2) ; cmd code
|
||||
ldd r18, Y+(1+3) ; source addr
|
||||
writeBufferInfoToRegs_end:
|
||||
ret
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
DEBUG1:
|
||||
ldi r19, 10
|
||||
ldi r20, 2
|
||||
ldi r21, 8
|
||||
rcall blinkLed
|
||||
rjmp DEBUG1
|
||||
|
||||
|
||||
DEBUG2:
|
||||
ldi r19, 50
|
||||
ldi r20, 1
|
||||
ldi r21, 1
|
||||
rcall blinkLed
|
||||
rjmp DEBUG2
|
||||
|
||||
|
||||
|
||||
; @param r19 loop count
|
||||
; @param r20 on time
|
||||
; @param r21 off time
|
||||
; @clobbers (R16, R18, R22, R24, R25)
|
||||
|
||||
blinkLed:
|
||||
cbi LED_SIMPLE_PORT, LED_SIMPLE_PINNUM ; on
|
||||
mov r22, r20
|
||||
rcall waitForMultiple100ms ; (R252
|
||||
sbi LED_SIMPLE_PORT, LED_SIMPLE_PINNUM ; off
|
||||
mov r22, r21
|
||||
rcall waitForMultiple100ms ; (R22)
|
||||
dec r19
|
||||
brne blinkLed
|
||||
ret
|
||||
|
||||
|
||||
; @param r22 number of 100ms periods to wait
|
||||
waitForMultiple100ms:
|
||||
waitForMultiple100ms_loop:
|
||||
push r22
|
||||
rcall waitFor100ms
|
||||
pop r22
|
||||
dec r22
|
||||
brne waitForMultiple100ms_loop
|
||||
ret
|
||||
|
||||
|
||||
waitFor100ms:
|
||||
ldi r22, 10
|
||||
waitFor100ms_loop:
|
||||
push r22
|
||||
rcall waitFor10ms
|
||||
pop r22
|
||||
dec r22
|
||||
brne waitFor100ms_loop
|
||||
ret
|
||||
|
||||
waitFor10ms:
|
||||
ldi r22, 100
|
||||
waitFor10ms_loop:
|
||||
push r22
|
||||
rcall Utils_WaitFor100MicroSecs
|
||||
pop r22
|
||||
dec r22
|
||||
brne waitFor10ms_loop
|
||||
ret
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data in SRAM
|
||||
; includes
|
||||
|
||||
.dseg
|
||||
|
||||
programRamBegin:
|
||||
flashUid: .byte 4
|
||||
deviceCounter: .byte 2
|
||||
sendTStatsCounter: .byte 2
|
||||
sendRStatsCounter: .byte 2
|
||||
sendMStatsCounter: .byte 2
|
||||
#ifdef WITH_SEND_DEBUG
|
||||
debugMsgCounter: .byte 2
|
||||
#endif
|
||||
programRamEnd:
|
||||
.include "devices/all/hw_tn841.asm"
|
||||
.include "devices/all/includes.asm"
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; defines for network interface
|
||||
|
||||
.equ netInterfaceData = ttyOnUart1_iface
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user