Compare commits
24 Commits
mp-2025_05
...
1.0.2-alph
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f537849a9 | ||
|
|
e6d0118ff3 | ||
|
|
ff7d47e155 | ||
|
|
8ae50a8d60 | ||
|
|
08411d9430 | ||
|
|
9bd3182bd5 | ||
|
|
c45eb6cca2 | ||
|
|
b229b39ab8 | ||
|
|
87b5e01581 | ||
|
|
8188f33345 | ||
|
|
7403b6650b | ||
|
|
6bbf2ba788 | ||
|
|
06b0ed8551 | ||
|
|
ada19028e0 | ||
|
|
1e5de0da23 | ||
|
|
bb14dd4c22 | ||
|
|
188e7da379 | ||
|
|
982c9bd649 | ||
|
|
fec37bd221 | ||
|
|
120e3e1e6b | ||
|
|
8d1661d8e4 | ||
|
|
18f61f4d63 | ||
|
|
be74442e7f | ||
|
|
061119819f |
@@ -58,6 +58,7 @@ static AQH_MESSAGE *_createRequestMessage(AQH_OBJECT *o, uint32_t msgId);
|
|||||||
static int _handleResponseMessage(AQH_OBJECT *o, const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList, int first);
|
static int _handleResponseMessage(AQH_OBJECT *o, const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList, int first);
|
||||||
static void _printNode(const AQH_NODE_INFO *ni, int printAll);
|
static void _printNode(const AQH_NODE_INFO *ni, int printAll);
|
||||||
static void _printUintAsTextOrHex(uint32_t u, int bits);
|
static void _printUintAsTextOrHex(uint32_t u, int bits);
|
||||||
|
static void _printDeviceIdAsTextOrHex(uint32_t u, int version);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -163,9 +164,7 @@ void _printNode(const AQH_NODE_INFO *ni, int printAll)
|
|||||||
_printUintAsTextOrHex(u, 32);
|
_printUintAsTextOrHex(u, 32);
|
||||||
fprintf(stdout, ":");
|
fprintf(stdout, ":");
|
||||||
u=AQH_NodeInfo_GetDeviceType(ni);
|
u=AQH_NodeInfo_GetDeviceType(ni);
|
||||||
_printUintAsTextOrHex(u, 16);
|
_printDeviceIdAsTextOrHex(u, AQH_NodeInfo_GetDeviceVersion(ni));
|
||||||
u=AQH_NodeInfo_GetDeviceVersion(ni);
|
|
||||||
fprintf(stdout, " v%d.%d", (u>>8) & 0xff, u & 0xff);
|
|
||||||
u=AQH_NodeInfo_GetFirmwareVersion(ni);
|
u=AQH_NodeInfo_GetFirmwareVersion(ni);
|
||||||
fprintf(stdout, ", firmware=%d.%d.%d (%d), ",
|
fprintf(stdout, ", firmware=%d.%d.%d (%d), ",
|
||||||
(u>>16) & 0xff, (u>>8) & 0xff, u & 0xff, (u>>24) & 0xff);
|
(u>>16) & 0xff, (u>>8) & 0xff, u & 0xff, (u>>24) & 0xff);
|
||||||
@@ -189,6 +188,36 @@ void _printNode(const AQH_NODE_INFO *ni, int printAll)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void _printDeviceIdAsTextOrHex(uint32_t u, int version)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
uint8_t d;
|
||||||
|
int hasNonPrintable=0;
|
||||||
|
int hasPrintable=0;
|
||||||
|
|
||||||
|
for (i=0; i<16; i+=8) {
|
||||||
|
d=((u>>i) & 0xff);
|
||||||
|
if (d==0) { /* undecided */
|
||||||
|
}
|
||||||
|
else if (isalnum(d))
|
||||||
|
hasPrintable=1;
|
||||||
|
else
|
||||||
|
hasNonPrintable=1;
|
||||||
|
}
|
||||||
|
if (hasNonPrintable || !hasPrintable)
|
||||||
|
fprintf(stdout, "%02x v%d.%d", u, (version>>8) & 0xff, version & 0xff);
|
||||||
|
else {
|
||||||
|
for (i=0; i<16; i+=8) {
|
||||||
|
d=((u>>i) & 0xff);
|
||||||
|
|
||||||
|
fprintf(stdout, "%c", d?d:' ');
|
||||||
|
}
|
||||||
|
fprintf(stdout, "%2d (%d)", (version>>8) & 0xff, version & 0xff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void _printUintAsTextOrHex(uint32_t u, int bits)
|
void _printUintAsTextOrHex(uint32_t u, int bits)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ appNetworkHandleRebootRequest:
|
|||||||
brcc appNetworkHandleRebootRequest_end
|
brcc appNetworkHandleRebootRequest_end
|
||||||
; reboot
|
; reboot
|
||||||
cli
|
cli
|
||||||
rjmp BOOTLOADER_ADDR
|
bigjmp BOOTLOADER_ADDR
|
||||||
appNetworkHandleRebootRequest_end:
|
appNetworkHandleRebootRequest_end:
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
@@ -249,7 +249,7 @@ appNetworkHandleStateHaveAddress2:
|
|||||||
cli
|
cli
|
||||||
ldi xl, LOW(EEPROM_OFFS_COMADDR)
|
ldi xl, LOW(EEPROM_OFFS_COMADDR)
|
||||||
ldi xh, HIGH(EEPROM_OFFS_COMADDR)
|
ldi xh, HIGH(EEPROM_OFFS_COMADDR)
|
||||||
rcall Utils_WriteEepromIncr ; write address to EEPROM
|
bigcall Utils_WriteEepromIncr ; write address to EEPROM
|
||||||
out SREG, r15
|
out SREG, r15
|
||||||
pop r15
|
pop r15
|
||||||
appNetworkHandleStateHaveAddress2_end:
|
appNetworkHandleStateHaveAddress2_end:
|
||||||
@@ -451,7 +451,7 @@ appNetworkGetAddressFromEeprom:
|
|||||||
cli
|
cli
|
||||||
ldi xl, LOW(EEPROM_OFFS_COMADDR)
|
ldi xl, LOW(EEPROM_OFFS_COMADDR)
|
||||||
ldi xh, HIGH(EEPROM_OFFS_COMADDR)
|
ldi xh, HIGH(EEPROM_OFFS_COMADDR)
|
||||||
rcall Utils_ReadEepromIncr ; (R16)
|
bigcall Utils_ReadEepromIncr ; (R16)
|
||||||
out SREG, r15
|
out SREG, r15
|
||||||
pop r15
|
pop r15
|
||||||
ret
|
ret
|
||||||
|
|||||||
@@ -62,9 +62,9 @@ AppStats_OnEveryMinute:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
AppStats_OnEveryMinute_noIrq:
|
AppStats_OnEveryMinute_noIrq:
|
||||||
ldi yl, LOW(netInterfaceData)
|
; ldi yl, LOW(netInterfaceData)
|
||||||
ldi yh, HIGH(netInterfaceData)
|
; ldi yh, HIGH(netInterfaceData)
|
||||||
rcall AppNetwork_SendRxdStats ; debug
|
; rcall AppNetwork_SendRxdStats ; debug
|
||||||
|
|
||||||
lds r16, appStatsTimer
|
lds r16, appStatsTimer
|
||||||
inc r16
|
inc r16
|
||||||
@@ -162,7 +162,7 @@ appStatsSend16BitValue:
|
|||||||
ldi r20, 1
|
ldi r20, 1
|
||||||
clr r21
|
clr r21
|
||||||
ldi r22, AQHOME_VALUETYPE_STATS
|
ldi r22, AQHOME_VALUETYPE_STATS
|
||||||
rjmp Main_SendValueReport
|
bigjmp Main_SendValueReport
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
30
avr/common/calls.asm
Normal file
30
avr/common/calls.asm
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
; ***************************************************************************
|
||||||
|
; 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. *
|
||||||
|
; ***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.macro bigcall
|
||||||
|
.if FLASHEND >= 0x1000
|
||||||
|
call @0
|
||||||
|
.else
|
||||||
|
rcall @0
|
||||||
|
.endif
|
||||||
|
.endmacro
|
||||||
|
|
||||||
|
|
||||||
|
.macro bigjmp
|
||||||
|
.if FLASHEND >= 0x1000
|
||||||
|
jmp @0
|
||||||
|
.else
|
||||||
|
rjmp @0
|
||||||
|
.endif
|
||||||
|
.endmacro
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -38,6 +38,8 @@ DEBUG2:
|
|||||||
; @clobbers (R16, R18, R22, R24, R25)
|
; @clobbers (R16, R18, R22, R24, R25)
|
||||||
|
|
||||||
blinkLed:
|
blinkLed:
|
||||||
|
sbi LED_SIMPLE_DDR, LED_SIMPLE_PINNUM ; out
|
||||||
|
blinkLed_loop:
|
||||||
cbi LED_SIMPLE_PORT, LED_SIMPLE_PINNUM ; on
|
cbi LED_SIMPLE_PORT, LED_SIMPLE_PINNUM ; on
|
||||||
mov r22, r20
|
mov r22, r20
|
||||||
rcall waitForMultiple100ms ; (R252
|
rcall waitForMultiple100ms ; (R252
|
||||||
@@ -45,7 +47,7 @@ blinkLed:
|
|||||||
mov r22, r21
|
mov r22, r21
|
||||||
rcall waitForMultiple100ms ; (R22)
|
rcall waitForMultiple100ms ; (R22)
|
||||||
dec r19
|
dec r19
|
||||||
brne blinkLed
|
brne blinkLed_loop
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@@ -74,7 +76,7 @@ waitFor10ms:
|
|||||||
ldi r22, 100
|
ldi r22, 100
|
||||||
waitFor10ms_loop:
|
waitFor10ms_loop:
|
||||||
push r22
|
push r22
|
||||||
rcall Utils_WaitFor100MicroSecs
|
bigcall Utils_WaitFor100MicroSecs
|
||||||
pop r22
|
pop r22
|
||||||
dec r22
|
dec r22
|
||||||
brne waitFor10ms_loop
|
brne waitFor10ms_loop
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
<subdirs>
|
<subdirs>
|
||||||
all
|
all
|
||||||
c01
|
c01
|
||||||
|
c02
|
||||||
n16
|
n16
|
||||||
n20
|
n20
|
||||||
n21
|
n21
|
||||||
|
|||||||
@@ -26,27 +26,27 @@ initApps:
|
|||||||
#ifdef APPS_NETWORK
|
#ifdef APPS_NETWORK
|
||||||
ldi yl, LOW(netInterfaceData)
|
ldi yl, LOW(netInterfaceData)
|
||||||
ldi yh, HIGH(netInterfaceData)
|
ldi yh, HIGH(netInterfaceData)
|
||||||
rcall AppNetwork_Init
|
bigcall AppNetwork_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef APPS_MOTION
|
#ifdef APPS_MOTION
|
||||||
rcall AppMotion_Init
|
bigcall AppMotion_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef APPS_DOOR
|
#ifdef APPS_DOOR
|
||||||
rcall AppDoor_Init
|
bigcall AppDoor_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef APPS_REPORTSENSORS
|
#ifdef APPS_REPORTSENSORS
|
||||||
rcall AppReportSensors_Init
|
bigcall AppReportSensors_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef APPS_STATS
|
#ifdef APPS_STATS
|
||||||
rcall AppStats_Init
|
bigcall AppStats_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef APPS_MA_LIGHT
|
#ifdef APPS_MA_LIGHT
|
||||||
rcall AppMotionLight_Init
|
bigcall AppMotionLight_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
; done
|
; done
|
||||||
@@ -78,11 +78,11 @@ mainAppsOnPacketReceived:
|
|||||||
; handle messages
|
; handle messages
|
||||||
ldi yl, LOW(netInterfaceData)
|
ldi yl, LOW(netInterfaceData)
|
||||||
ldi yh, HIGH(netInterfaceData)
|
ldi yh, HIGH(netInterfaceData)
|
||||||
rcall AppNetwork_HandleMsg
|
bigcall AppNetwork_HandleMsg
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef APPS_MA_LIGHT
|
#ifdef APPS_MA_LIGHT
|
||||||
rcall AppMotionLight_OnPacketReceived
|
bigcall AppMotionLight_OnPacketReceived
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
; add more here
|
; add more here
|
||||||
|
|||||||
136
avr/devices/all/hw_m644p.asm
Normal file
136
avr/devices/all/hw_m644p.asm
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
; ***************************************************************************
|
||||||
|
; 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 AtMega 644P devices
|
||||||
|
|
||||||
|
|
||||||
|
.cseg
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine systemInitHardware
|
||||||
|
;
|
||||||
|
|
||||||
|
systemInitHardware:
|
||||||
|
; set all ports as inputs and enable internal pull-up resistors
|
||||||
|
ldi r16, 0xff
|
||||||
|
clr r17
|
||||||
|
|
||||||
|
out DDRA, r17 ; all input
|
||||||
|
out PORTA, r16 ; enable pull-up on all
|
||||||
|
|
||||||
|
out DDRB, r17 ; all input
|
||||||
|
out PORTB, r16 ; enable pull-up on all
|
||||||
|
|
||||||
|
out DDRC, r17 ; all input
|
||||||
|
out PORTC, r16 ; enable pull-up on all
|
||||||
|
|
||||||
|
out DDRD, r17 ; all input
|
||||||
|
out PORTD, r16 ; enable pull-up on all
|
||||||
|
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine systemSetSpeed
|
||||||
|
;
|
||||||
|
|
||||||
|
systemSetSpeed:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine systemSleep
|
||||||
|
;
|
||||||
|
|
||||||
|
systemSleep:
|
||||||
|
; only modify SE, SM2, SM1 and SM0
|
||||||
|
cli
|
||||||
|
|
||||||
|
inr r16, SMCR
|
||||||
|
cbr r16, (1<<SE) | (0<<SM2) | (0<<SM1) | (0<<SM0)
|
||||||
|
outr SMCR, r16
|
||||||
|
|
||||||
|
sei ; make sure interrupts really are enabled
|
||||||
|
|
||||||
|
inr r16, SMCR ; enable sleep mode
|
||||||
|
sbr r16, (1<<SE)
|
||||||
|
outr SMCR, r16
|
||||||
|
|
||||||
|
sleep ; sleep, wait for interrupt
|
||||||
|
|
||||||
|
inr r16, SMCR ; disable sleep mode
|
||||||
|
cbr r16, (1<<SE)
|
||||||
|
outr SMCR, r16
|
||||||
|
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine systemSetupTimer0
|
||||||
|
;
|
||||||
|
|
||||||
|
systemSetupTimer0: ; setup timer for IRQ every 100ms
|
||||||
|
ldi r16, (1<<WGM01) | (0<<WGM00) ; Prescaler 1024, CTC mode
|
||||||
|
outr TCCR0A, r16
|
||||||
|
|
||||||
|
ldi r16, (1<<CS02) | (0<<CS01) | (1<<CS00) | (0<<WGM02) ; Prescaler 1024, CTC mode
|
||||||
|
outr TCCR0B, r16
|
||||||
|
|
||||||
|
;
|
||||||
|
; Settings for clock 1Mhz (default)
|
||||||
|
; use timer0 with OCR0A=98-1 (irq every 97.65625 millisecs), baseTimerModuleReloadValue 1
|
||||||
|
;
|
||||||
|
.if clock == 1000000
|
||||||
|
; CMP-A interrupt about every 100ms
|
||||||
|
ldi r16, 98-1 ; (1,000,000/1024)/10 = 97.65625
|
||||||
|
outr OCR0A, r16
|
||||||
|
|
||||||
|
ldi r16, 1
|
||||||
|
sts baseTimerModuleReloadValue, r16
|
||||||
|
sts baseTimerModuleTickCounter, r16
|
||||||
|
.endif
|
||||||
|
|
||||||
|
;
|
||||||
|
; Settings for clock 8Mhz
|
||||||
|
; use timer0 with OCR0=78 (irq every 9.984 millisecs), baseTimerModuleReloadValue 10
|
||||||
|
;
|
||||||
|
.if clock == 8000000
|
||||||
|
; CMP interrupt about every 10ms
|
||||||
|
ldi r16, 78-1
|
||||||
|
outr OCR0A, r16
|
||||||
|
|
||||||
|
ldi r16, 10
|
||||||
|
sts baseTimerModuleReloadValue, r16
|
||||||
|
sts baseTimerModuleTickCounter, r16
|
||||||
|
.endif
|
||||||
|
|
||||||
|
ldi r16, (1<<OCF0A) ; clear pending interrupts
|
||||||
|
outr TIFR0, r16
|
||||||
|
|
||||||
|
inr r16, TIMSK0
|
||||||
|
sbr r16, (1<<OCIE0A) ; Timer/Counter0 Output Compare Match A Interrupt Enable
|
||||||
|
outr TIMSK0, r16
|
||||||
|
.endif
|
||||||
|
|
||||||
|
sec
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -72,13 +72,14 @@ systemSleep:
|
|||||||
; only modify SE, SM1 and SM0
|
; only modify SE, SM1 and SM0
|
||||||
cli
|
cli
|
||||||
in r16, MCUCR
|
in r16, MCUCR
|
||||||
ldi r17, (1<<SE) | (1<<SM1) | (1<<SM0)
|
cbr r16, (1<<SE) | (1<<SM1) | (1<<SM0)
|
||||||
neg r17
|
out MCUCR, r16
|
||||||
and r16, r17
|
sbr r16, (1<<SE) | (0<<SM1) | (0<<SM0) ; sleep mode "idle", enable
|
||||||
ori r16, (1<<SE) ; sleep mode "idle", enable
|
|
||||||
out MCUCR, r16
|
out MCUCR, r16
|
||||||
sei ; make sure interrupts really are enabled
|
sei ; make sure interrupts really are enabled
|
||||||
sleep ; sleep, wait for interrupt
|
sleep ; sleep, wait for interrupt
|
||||||
|
cbr r16, (1<<SE) | (1<<SM1) | (1<<SM0)
|
||||||
|
out MCUCR, r16
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
@@ -90,7 +91,7 @@ systemSleep:
|
|||||||
;
|
;
|
||||||
|
|
||||||
systemSetupTimer0: ; setup timer for IRQ every 100ms
|
systemSetupTimer0: ; setup timer for IRQ every 100ms
|
||||||
ldi r16, (1<<CS02) | (0<<CS01) | (1<<CS00) ; Prescaler 1024
|
ldi r16, (0<<WGM02) | (1<<CS02) | (0<<CS01) | (1<<CS00) ; Prescaler 1024
|
||||||
out TCCR0B, r16
|
out TCCR0B, r16
|
||||||
|
|
||||||
ldi r16, (1<<WGM01) | (0<<WGM00) ; CTC mode
|
ldi r16, (1<<WGM01) | (0<<WGM00) ; CTC mode
|
||||||
@@ -125,19 +126,12 @@ systemSetupTimer0: ; setup timer for IRQ every 100ms
|
|||||||
|
|
||||||
|
|
||||||
ldi r16, (1<<OCF0A) ; clear pending interrupts
|
ldi r16, (1<<OCF0A) ; clear pending interrupts
|
||||||
.ifdef TIFR0
|
|
||||||
out TIFR0, r16
|
out TIFR0, r16
|
||||||
.else
|
|
||||||
out TIFR, r16
|
|
||||||
.endif
|
|
||||||
|
|
||||||
ldi r16, (1<<OCIE0A) ; Timer/Counter0 Output Compare Match A Interrupt Enable
|
ldi r16, (1<<OCIE0A) ; Timer/Counter0 Output Compare Match A Interrupt Enable
|
||||||
.ifdef TIMSK0
|
|
||||||
out TIMSK0, r16
|
out TIMSK0, r16
|
||||||
.else
|
|
||||||
out TIMSK, r16
|
sec
|
||||||
.endif
|
|
||||||
sec
|
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
; code
|
; code
|
||||||
|
|
||||||
@@ -31,16 +32,16 @@ main:
|
|||||||
|
|
||||||
; rcall watchdogOff ; turn off watchdog timer (sometimes it stays on after reboot)
|
; rcall watchdogOff ; turn off watchdog timer (sometimes it stays on after reboot)
|
||||||
|
|
||||||
rcall systemSetSpeed
|
bigcall systemSetSpeed
|
||||||
rcall systemInitHardware
|
bigcall systemInitHardware
|
||||||
rcall Utils_Init
|
bigcall Utils_Init
|
||||||
rcall Utils_SetupUid
|
bigcall Utils_SetupUid
|
||||||
rcall initModules
|
bigcall initModules
|
||||||
rcall initApps
|
bigcall initApps
|
||||||
rcall Utils_InitialWait
|
bigcall Utils_InitialWait
|
||||||
sei ; Enable interrupts
|
sei ; Enable interrupts
|
||||||
|
|
||||||
rcall onSystemStart
|
bigcall onSystemStart
|
||||||
|
|
||||||
#ifdef MODULES_LED
|
#ifdef MODULES_LED
|
||||||
ldi xl, LOW(blinkPattern) ; debug: set blink pattern
|
ldi xl, LOW(blinkPattern) ; debug: set blink pattern
|
||||||
@@ -53,11 +54,11 @@ main:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
main_loop:
|
main_loop:
|
||||||
rcall systemSleep ; system-dependant
|
bigcall systemSleep ; system-dependant
|
||||||
rcall runModules
|
bigcall runModules
|
||||||
rcall runApps
|
bigcall runApps
|
||||||
|
|
||||||
rcall onEveryLoop ; call into main app
|
bigcall onEveryLoop ; call into main app
|
||||||
|
|
||||||
#ifdef MODULES_NETWORK
|
#ifdef MODULES_NETWORK
|
||||||
#ifndef MAIN_WITHOUT_MSG_HANDLING
|
#ifndef MAIN_WITHOUT_MSG_HANDLING
|
||||||
@@ -69,7 +70,7 @@ main_loop:
|
|||||||
|
|
||||||
main_loop_reboot:
|
main_loop_reboot:
|
||||||
cli
|
cli
|
||||||
rjmp BOOTLOADER_ADDR
|
bigjmp BOOTLOADER_ADDR
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
|
|
||||||
@@ -80,53 +81,53 @@ main_loop_reboot:
|
|||||||
; Called every 100ms. No arguments, no results.
|
; Called every 100ms. No arguments, no results.
|
||||||
|
|
||||||
onSystemTimerTick:
|
onSystemTimerTick:
|
||||||
rcall onEvery100ms
|
bigcall onEvery100ms
|
||||||
|
|
||||||
#ifdef MODULES_CLOCK
|
#ifdef MODULES_CLOCK
|
||||||
rcall Clock_Every100ms ; generates calls to onEverySecond/Minute/Hour/Day
|
bigcall Clock_Every100ms ; generates calls to onEverySecond/Minute/Hour/Day
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_LED_SIMPLE
|
#ifdef MODULES_LED_SIMPLE
|
||||||
rcall LedSimple_Every100ms
|
bigcall LedSimple_Every100ms
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_UART_BITBANG
|
#ifdef MODULES_UART_BITBANG
|
||||||
rcall UART_BitBang_Every100ms
|
bigcall UART_BitBang_Every100ms
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_UART_HW
|
#ifdef MODULES_UART_HW
|
||||||
rcall NET_Uart_Every100ms
|
bigcall NET_Uart_Every100ms
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_TTYONUART1
|
#ifdef MODULES_TTYONUART1
|
||||||
rcall TtyOnUart1_Periodically
|
bigcall TtyOnUart1_Periodically
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_COMONUART0
|
#ifdef MODULES_COMONUART0
|
||||||
rcall ComOnUart0_Periodically
|
bigcall ComOnUart0_Periodically
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_TCRT1000
|
#ifdef MODULES_TCRT1000
|
||||||
rcall TCRT1K_Every100ms
|
bigcall TCRT1K_Every100ms
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef APPS_NETWORK
|
#ifdef APPS_NETWORK
|
||||||
ldi yl, LOW(netInterfaceData)
|
ldi yl, LOW(netInterfaceData)
|
||||||
ldi yh, HIGH(netInterfaceData)
|
ldi yh, HIGH(netInterfaceData)
|
||||||
rcall AppNetwork_Every100ms
|
bigcall AppNetwork_Every100ms
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef APPS_MOTION
|
#ifdef APPS_MOTION
|
||||||
rcall AppMotion_Every100ms
|
bigcall AppMotion_Every100ms
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef APPS_DOOR
|
#ifdef APPS_DOOR
|
||||||
rcall AppDoor_Every100ms
|
bigcall AppDoor_Every100ms
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef APPS_MA_LIGHT
|
#ifdef APPS_MA_LIGHT
|
||||||
rcall AppMotionLight_Every100ms
|
bigcall AppMotionLight_Every100ms
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ret
|
ret
|
||||||
@@ -138,32 +139,32 @@ onSystemTimerTick:
|
|||||||
|
|
||||||
sysOnEverySecond:
|
sysOnEverySecond:
|
||||||
#ifdef MODULES_DS18B20
|
#ifdef MODULES_DS18B20
|
||||||
rcall Ds18b20_OnEverySecond
|
bigcall Ds18b20_OnEverySecond
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef APPS_REPORTSENSORS
|
#ifdef APPS_REPORTSENSORS
|
||||||
rcall AppReportSensors_OnEverySecond
|
bigcall AppReportSensors_OnEverySecond
|
||||||
#endif
|
#endif
|
||||||
rjmp onEverySecond
|
bigjmp onEverySecond
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
|
|
||||||
sysOnEveryMinute:
|
sysOnEveryMinute:
|
||||||
#ifdef APPS_STATS
|
#ifdef APPS_STATS
|
||||||
rcall AppStats_OnEveryMinute
|
bigcall AppStats_OnEveryMinute
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rjmp onEveryMinute
|
bigjmp onEveryMinute
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
|
|
||||||
sysOnEveryHour:
|
sysOnEveryHour:
|
||||||
rjmp onEveryHour
|
bigjmp onEveryHour
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
|
|
||||||
sysOnEveryDay:
|
sysOnEveryDay:
|
||||||
rjmp onEveryDay
|
bigjmp onEveryDay
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -175,17 +176,17 @@ sysOnEveryDay:
|
|||||||
; @routine mainHandleMessages
|
; @routine mainHandleMessages
|
||||||
|
|
||||||
mainHandleMessages:
|
mainHandleMessages:
|
||||||
rcall NET_GetNextIncomingMsgNum ; R16=msg num
|
bigcall NET_GetNextIncomingMsgNum ; R16=msg num
|
||||||
brcc mainHandleMessages_end
|
brcc mainHandleMessages_end
|
||||||
rcall NET_Buffer_Locate ; X=buffer addr (R17)
|
bigcall NET_Buffer_Locate ; X=buffer addr (R17)
|
||||||
adiw xh:xl, 1
|
adiw xh:xl, 1
|
||||||
|
|
||||||
push r16
|
push r16
|
||||||
rcall onMessageReceived
|
bigcall onMessageReceived
|
||||||
rcall mainModulesOnPacketReceived
|
bigcall mainModulesOnPacketReceived
|
||||||
rcall mainAppsOnPacketReceived
|
bigcall mainAppsOnPacketReceived
|
||||||
pop r16
|
pop r16
|
||||||
rcall NET_Buffer_ReleaseByNum
|
bigcall NET_Buffer_ReleaseByNum
|
||||||
sec
|
sec
|
||||||
mainHandleMessages_end:
|
mainHandleMessages_end:
|
||||||
ret
|
ret
|
||||||
|
|||||||
@@ -22,22 +22,22 @@
|
|||||||
; Call init functions of the used modules. Add your routine calls here.
|
; Call init functions of the used modules. Add your routine calls here.
|
||||||
|
|
||||||
initModules:
|
initModules:
|
||||||
rcall BaseTimer_Init ; unconditionally call this
|
bigcall BaseTimer_Init ; unconditionally call this
|
||||||
|
|
||||||
#ifdef MODULES_HEAP
|
#ifdef MODULES_HEAP
|
||||||
rcall Heap_Init
|
bigcall Heap_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_CLOCK
|
#ifdef MODULES_CLOCK
|
||||||
rcall Clock_Init
|
bigcall Clock_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_TIMER
|
#ifdef MODULES_TIMER
|
||||||
rcall Timer_Init
|
bigcall Timer_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_XRAM
|
#ifdef MODULES_XRAM
|
||||||
rcall XRAM_Init
|
bigcall XRAM_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_LED
|
#ifdef MODULES_LED
|
||||||
@@ -45,107 +45,107 @@ initModules:
|
|||||||
ldi zh, HIGH(ledA3Flash)
|
ldi zh, HIGH(ledA3Flash)
|
||||||
ldi yl, LOW(ledA3Sram)
|
ldi yl, LOW(ledA3Sram)
|
||||||
ldi yh, HIGH(ledA3Sram)
|
ldi yh, HIGH(ledA3Sram)
|
||||||
rcall Led_Init
|
bigcall Led_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_LED_SIMPLE
|
#ifdef MODULES_LED_SIMPLE
|
||||||
rcall LedSimple_Init
|
bigcall LedSimple_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_COM
|
#ifdef MODULES_COM
|
||||||
rcall Com2_Init ; init COM module
|
bigcall Com2_Init ; init COM module
|
||||||
rcall CPRO_Init ; init COM protocol module
|
bigcall CPRO_Init ; init COM protocol module
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_NETWORK
|
#ifdef MODULES_NETWORK
|
||||||
rcall NET_Init
|
bigcall NET_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_UART_BITBANG
|
#ifdef MODULES_UART_BITBANG
|
||||||
rcall UART_BitBang_Init
|
bigcall UART_BitBang_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_UART_HW
|
#ifdef MODULES_UART_HW
|
||||||
rcall NET_Uart_Init
|
bigcall NET_Uart_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_TTYONUART1
|
#ifdef MODULES_TTYONUART1
|
||||||
rcall TtyOnUart1_Init
|
bigcall TtyOnUart1_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_COMONUART0
|
#ifdef MODULES_COMONUART0
|
||||||
rcall ComOnUart0_Init
|
bigcall ComOnUart0_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_MOTION
|
#ifdef MODULES_MOTION
|
||||||
rcall Motion_Init
|
bigcall Motion_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_TWI_MASTER
|
#ifdef MODULES_TWI_MASTER
|
||||||
rcall TWI_Master_Init
|
bigcall TWI_Master_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_OWI_MASTER
|
#ifdef MODULES_OWI_MASTER
|
||||||
rcall OwiMaster_Init
|
bigcall OwiMaster_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_SPI_HW
|
#ifdef MODULES_SPI_HW
|
||||||
rcall SPIHW_Init
|
bigcall SPIHW_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_LCD
|
#ifdef MODULES_LCD
|
||||||
rcall LCD_Init
|
bigcall LCD_Init
|
||||||
#endif
|
#endif
|
||||||
#ifdef MODULES_BMP280
|
#ifdef MODULES_BMP280
|
||||||
rcall BMP280_Init
|
bigcall BMP280_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_SI7021
|
#ifdef MODULES_SI7021
|
||||||
rcall SI7021_Init
|
bigcall SI7021_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_SGP30
|
#ifdef MODULES_SGP30
|
||||||
rcall SGP30_Init
|
bigcall SGP30_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_SGP40
|
#ifdef MODULES_SGP40
|
||||||
rcall SGP40_Init
|
bigcall SGP40_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_DS18B20
|
#ifdef MODULES_DS18B20
|
||||||
rcall Ds18b20_Init
|
bigcall Ds18b20_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_STATS
|
#ifdef MODULES_STATS
|
||||||
rcall Stats_Init
|
bigcall Stats_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_CNY70
|
#ifdef MODULES_CNY70
|
||||||
rcall CNY70_Init
|
bigcall CNY70_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_REED
|
#ifdef MODULES_REED
|
||||||
rcall REED_Init
|
bigcall REED_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_SK6812
|
#ifdef MODULES_SK6812
|
||||||
rcall SK6812_Init
|
bigcall SK6812_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_MOTION_LIGHT
|
#ifdef MODULES_MOTION_LIGHT
|
||||||
rcall MotionLight_Init
|
bigcall MotionLight_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_TCRT1000
|
#ifdef MODULES_TCRT1000
|
||||||
rcall TCRT1K_Init
|
bigcall TCRT1K_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_CCS811
|
#ifdef MODULES_CCS811
|
||||||
rcall CCS811_Init
|
bigcall CCS811_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_ILI9341
|
#ifdef MODULES_ILI9341
|
||||||
rcall ILI9341_Init
|
bigcall ILI9341_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -167,14 +167,14 @@ initModules:
|
|||||||
; USED: depending on called routines
|
; USED: depending on called routines
|
||||||
|
|
||||||
runModules:
|
runModules:
|
||||||
rcall BaseTimer_Run
|
bigcall BaseTimer_Run
|
||||||
|
|
||||||
#ifdef MODULES_COM
|
#ifdef MODULES_COM
|
||||||
; COM module (call until carry flag cleared but at most 10 times to not starve other modules)
|
; COM module (call until carry flag cleared but at most 10 times to not starve other modules)
|
||||||
ldi r16, 10
|
ldi r16, 10
|
||||||
runModules_Com:
|
runModules_Com:
|
||||||
push r16
|
push r16
|
||||||
rcall Com2_Run
|
bigcall Com2_Run
|
||||||
pop r16
|
pop r16
|
||||||
brcc runModules_ComEnd
|
brcc runModules_ComEnd
|
||||||
dec r16
|
dec r16
|
||||||
@@ -183,23 +183,23 @@ runModules_ComEnd:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_TTYONUART1
|
#ifdef MODULES_TTYONUART1
|
||||||
rcall TtyOnUart1_Run
|
bigcall TtyOnUart1_Run
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_COMONUART0
|
#ifdef MODULES_COMONUART0
|
||||||
rcall ComOnUart0_Run
|
bigcall ComOnUart0_Run
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_STATS
|
#ifdef MODULES_STATS
|
||||||
rcall Stats_Run
|
bigcall Stats_Run
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_REED
|
#ifdef MODULES_REED
|
||||||
rcall REED_Run
|
bigcall REED_Run
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_CNY70
|
#ifdef MODULES_CNY70
|
||||||
rcall CNY70_Run
|
bigcall CNY70_Run
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_MOTION_LIGHT
|
#ifdef MODULES_MOTION_LIGHT
|
||||||
@@ -220,12 +220,12 @@ runModules_ComEnd:
|
|||||||
mainModulesOnPacketReceived:
|
mainModulesOnPacketReceived:
|
||||||
|
|
||||||
#ifdef MODULES_SK6812
|
#ifdef MODULES_SK6812
|
||||||
rcall SK6812_OnPacketReceived
|
bigcall SK6812_OnPacketReceived
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_LED_SIMPLE
|
#ifdef MODULES_LED_SIMPLE
|
||||||
#ifdef MODULES_NETWORK
|
#ifdef MODULES_NETWORK
|
||||||
rcall LedSimple_OnPacketReceived
|
bigcall LedSimple_OnPacketReceived
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,9 @@
|
|||||||
.list
|
.list
|
||||||
|
|
||||||
.include "../defs.asm"
|
.include "../defs.asm"
|
||||||
.include "defs_all.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
|
||||||
|
.include "common/calls.asm"
|
||||||
.include "common/utils_wait.asm"
|
.include "common/utils_wait.asm"
|
||||||
.include "common/utils_io.asm"
|
.include "common/utils_io.asm"
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,11 @@
|
|||||||
.equ COM_BIT_LENGTH = 52000 ; 104000ns=9600, 52000ns=19200, 26000ns=38400
|
.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_HALFBIT_LENGTH = 26000 ; see https://de.wikipedia.org/wiki/Universal_Asynchronous_Receiver_Transmitter
|
||||||
|
|
||||||
|
.equ COM_DATA_DDR = DDRD
|
||||||
|
.equ COM_DATA_INPUT = PIND
|
||||||
|
.equ COM_DATA_OUTPUT = PORTD
|
||||||
|
.equ COM_DATA_PIN = PORTD0
|
||||||
|
|
||||||
.equ COM_ATTN_DDR = DDRD
|
.equ COM_ATTN_DDR = DDRD
|
||||||
.equ COM_ATTN_INPUT = PIND
|
.equ COM_ATTN_INPUT = PIND
|
||||||
.equ COM_ATTN_OUTPUT = PORTD
|
.equ COM_ATTN_OUTPUT = PORTD
|
||||||
|
|||||||
@@ -56,7 +56,8 @@
|
|||||||
#define MODULES_LED_SIMPLE
|
#define MODULES_LED_SIMPLE
|
||||||
#define MODULES_NETWORK
|
#define MODULES_NETWORK
|
||||||
;#define MODULES_COMONUART0
|
;#define MODULES_COMONUART0
|
||||||
#define MODULES_UART_HW
|
;#define MODULES_UART_HW
|
||||||
|
#define MODULES_UART_BITBANG
|
||||||
#define MODULES_SPI_HW
|
#define MODULES_SPI_HW
|
||||||
#define MODULES_ILI9341
|
#define MODULES_ILI9341
|
||||||
;#define MODULES_FONT_8X8
|
;#define MODULES_FONT_8X8
|
||||||
@@ -117,7 +118,8 @@
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; Reset and interrupt vectors
|
; Reset and interrupt vectors
|
||||||
rjmp BOOTLOADER_ADDR ; 1: Reset vector RESET
|
rjmp BOOTLOADER_ADDR ; 1: Reset vector RESET
|
||||||
rjmp NetUart_AttnChangeIsr ; 2: INT0 External Interrupt Request 0
|
; rjmp NetUart_AttnChangeIsr ; 2: INT0 External Interrupt Request 0
|
||||||
|
rjmp UART_BitBang_PcintIsr ; 2: INT0 External Interrupt Request 0
|
||||||
reti ; 3: INT1 External Interrupt Request 1
|
reti ; 3: INT1 External Interrupt Request 1
|
||||||
reti ; 4: TIMER1_CAPT Timer/Counter1 Capture Event
|
reti ; 4: TIMER1_CAPT Timer/Counter1 Capture Event
|
||||||
reti ; 5: TIMER1_COMPA Timer/Counter1 Compare Match A
|
reti ; 5: TIMER1_COMPA Timer/Counter1 Compare Match A
|
||||||
@@ -216,7 +218,8 @@ onEveryLoop:
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; defines for network interface
|
; defines for network interface
|
||||||
|
|
||||||
.equ netInterfaceData = netUartIface
|
;.equ netInterfaceData = netUartIface
|
||||||
|
.equ netInterfaceData = uart_bitbang_iface
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2
avr/devices/c02/.gitignore
vendored
Normal file
2
avr/devices/c02/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*.eep.hex
|
||||||
|
*.obj
|
||||||
22
avr/devices/c02/0BUILD
Normal file
22
avr/devices/c02/0BUILD
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml?>
|
||||||
|
|
||||||
|
<gwbuild>
|
||||||
|
|
||||||
|
<subdirs>
|
||||||
|
boot
|
||||||
|
main
|
||||||
|
</subdirs>
|
||||||
|
|
||||||
|
<data dist="true" install="$(datadir)/aqhome/devices/nodes">
|
||||||
|
aqua_c02.xml
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<extradist>
|
||||||
|
defs.asm
|
||||||
|
README
|
||||||
|
</extradist>
|
||||||
|
|
||||||
|
|
||||||
|
</gwbuild>
|
||||||
|
|
||||||
|
|
||||||
10
avr/devices/c02/README
Normal file
10
avr/devices/c02/README
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
C01
|
||||||
|
===
|
||||||
|
|
||||||
|
- Role: Controller with Display
|
||||||
|
- MCU: AtMega 644P
|
||||||
|
- Connection: RJ45
|
||||||
|
- Periphery:
|
||||||
|
- Display with SPI
|
||||||
|
|
||||||
24
avr/devices/c02/aqua_c02.xml
Normal file
24
avr/devices/c02/aqua_c02.xml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
<device name="aqua_c02" driver="nodes">
|
||||||
|
<manufacturer>AQUA</manufacturer>
|
||||||
|
<devicetype>C</devicetype>
|
||||||
|
<deviceversion>2</deviceversion>
|
||||||
|
|
||||||
|
<values>
|
||||||
|
<value name="LEDTIMING" id="0x88" type="actor" dataType="uint16" />
|
||||||
|
|
||||||
|
<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_heap_used" id="0xe7" type="sensor" dataType="uint16" denom="1" />
|
||||||
|
<value name="stats_heap_free" id="0xe8" type="sensor" dataType="uint16" denom="1" />
|
||||||
|
<value name="stats_noram_errors" id="0xe9" type="sensor" dataType="uint16" denom="1" />
|
||||||
|
|
||||||
|
</values>
|
||||||
|
|
||||||
|
</device>
|
||||||
32
avr/devices/c02/boot/0BUILD
Normal file
32
avr/devices/c02/boot/0BUILD
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml?>
|
||||||
|
|
||||||
|
<gwbuild>
|
||||||
|
|
||||||
|
<target type="AvrHexFile" name="c02_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>
|
||||||
|
|
||||||
|
|
||||||
160
avr/devices/c02/boot/boot.asm
Normal file
160
avr/devices/c02/boot/boot.asm
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
; ***************************************************************************
|
||||||
|
; Source file for base system node on AtMega 644P
|
||||||
|
;
|
||||||
|
; This is for the maintenance system (i.e. the flash loader).
|
||||||
|
;
|
||||||
|
; All definitions and changes should go into this file.
|
||||||
|
; ***************************************************************************
|
||||||
|
|
||||||
|
.equ clock=8000000 ; Define the clock frequency
|
||||||
|
|
||||||
|
.nolist
|
||||||
|
.include "include/m644Pdef.inc" ; Define device ATmega8515
|
||||||
|
.list
|
||||||
|
|
||||||
|
.include "../defs.asm"
|
||||||
|
.include "devices/all/defs.asm"
|
||||||
|
|
||||||
|
.include "common/calls.asm"
|
||||||
|
.include "common/utils_wait.asm"
|
||||||
|
.include "common/utils_io.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; defines
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; generic
|
||||||
|
|
||||||
|
|
||||||
|
.equ NET_BUFFERS_NUM = 6
|
||||||
|
.equ NET_BUFFERS_SIZE = 32
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; firmware settings
|
||||||
|
|
||||||
|
.equ FIRMWARE_VERSION_MAJOR = 0
|
||||||
|
.equ FIRMWARE_VERSION_MINOR = 0
|
||||||
|
.equ FIRMWARE_VERSION_PATCHLEVEL = 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; LED
|
||||||
|
|
||||||
|
.equ LED_DDR = DDRD
|
||||||
|
.equ LED_PORT = PORTD
|
||||||
|
.equ LED_PIN = PIND
|
||||||
|
.equ LED_PINNUM = PORTD4
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; code segment
|
||||||
|
|
||||||
|
.cseg
|
||||||
|
.org 0x0000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; Reset and interrupt vectors
|
||||||
|
jmp main ; 1: Reset vector RESET
|
||||||
|
jmp irqNotSet ; 2: INT0 External Interrupt Request 0
|
||||||
|
jmp irqNotSet ; 3: INT1 External Interrupt Request 1
|
||||||
|
jmp irqNotSet ; 4: INT2 External Interrupt Request 2
|
||||||
|
jmp irqNotSet ; 5: PCINT0 Pin Change Interrupt Request 0
|
||||||
|
jmp irqNotSet ; 6: PCINT1 Pin Change Interrupt Request 1
|
||||||
|
jmp irqNotSet ; 7: PCINT2 Pin Change Interrupt Request 2
|
||||||
|
jmp irqNotSet ; 8: PCINT3 Pin Change Interrupt Request 3
|
||||||
|
jmp irqNotSet ; 9: WDT Watchdog Time-out Interrupt
|
||||||
|
jmp irqNotSet ; 10: TIMER2_COMPA Timer/Counter2 Compare Match A
|
||||||
|
jmp irqNotSet ; 11: TIMER2_COMPB Timer/Counter2 Compare Match B
|
||||||
|
jmp irqNotSet ; 12: TIMER2_OVF Timer/Counter2 Overflow
|
||||||
|
jmp irqNotSet ; 13: TIMER1_CAPT Timer/Counter1 Capture Event
|
||||||
|
jmp irqNotSet ; 14: TIMER1_COMPA Timer/Counter1 Compare Match A
|
||||||
|
jmp irqNotSet ; 15: TIMER1_COMPB Timer/Counter1 Compare Match B
|
||||||
|
jmp irqNotSet ; 16: TIMER1_OVF Timer/Counter1 Overflow
|
||||||
|
jmp irqNotSet ; 17: TIMER0_COMPA Timer/Counter0 Compare Match A
|
||||||
|
jmp irqNotSet ; 18: TIMER0_COMPB Timer/Counter0 Compare Match B
|
||||||
|
jmp irqNotSet ; 19: TIMER0_OVF Timer/Counter0 Overflow
|
||||||
|
jmp irqNotSet ; 20: SPI_STC Serial Transfer Complete
|
||||||
|
jmp irqNotSet ; 21: USART0_RXC USART0 Rx Complete
|
||||||
|
jmp irqNotSet ; 22: USART0_UDRE USART0 Data Register Empty
|
||||||
|
jmp irqNotSet ; 23: USART0_TXC USART0 Tx Complete
|
||||||
|
jmp irqNotSet ; 24: ANA_COMP Analog Comparator
|
||||||
|
jmp irqNotSet ; 25: ADC ADC Conversion Complete
|
||||||
|
jmp irqNotSet ; 26: EE_RDY EEPROM Ready
|
||||||
|
jmp irqNotSet ; 27: TWI 2-Wire Interface
|
||||||
|
jmp irqNotSet ; 28: SPM_RDY Store Program Memory Ready
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; Device Info Block
|
||||||
|
|
||||||
|
devInfoBlock: ; 12 bytes
|
||||||
|
devInfoManufacturer: .db 'A', 'Q', 'U', 'A'
|
||||||
|
devInfoId: .db DEVICEINFO_ID, 0
|
||||||
|
devInfoVersion: .db DEVICEINFO_VERSION, DEVICEINFO_REVISION ; version, revision
|
||||||
|
firmwareVersion: .db FIRMWARE_VARIANT_BOOT, FIRMWARE_VERSION_MAJOR
|
||||||
|
.db FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCHLEVEL
|
||||||
|
|
||||||
|
firmwareStart:
|
||||||
|
jmp main ; will be overwritten when flashing
|
||||||
|
|
||||||
|
irqNotSet:
|
||||||
|
reti
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; main code
|
||||||
|
|
||||||
|
|
||||||
|
.org BOOTLOADER_ADDR
|
||||||
|
|
||||||
|
|
||||||
|
main:
|
||||||
|
; ldi r16, 0xb0 ; orig: a0
|
||||||
|
; out OSCCAL, r16
|
||||||
|
jmp bootLoader ; this routine is in modules/bootloader/main.asm
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; includes
|
||||||
|
|
||||||
|
.include "common/wait_10us.asm"
|
||||||
|
.include "common/utils_copy_from_flash.asm"
|
||||||
|
.include "common/utils_copy_sdram.asm"
|
||||||
|
|
||||||
|
.include "modules/flash/defs.asm"
|
||||||
|
.include "modules/flash/eeprom.asm"
|
||||||
|
.include "modules/flash/io.asm"
|
||||||
|
.include "modules/flash/io_attn.asm"
|
||||||
|
.include "modules/flash/io_bitbang.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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
175
avr/devices/c02/defs.asm
Normal file
175
avr/devices/c02/defs.asm
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
; ***************************************************************************
|
||||||
|
; copyright : (C) 2025 by Martin Preuss
|
||||||
|
; email : martin@libchipcard.de
|
||||||
|
;
|
||||||
|
; ***************************************************************************
|
||||||
|
; * This file is part of the project "AqHome". *
|
||||||
|
; * Please see toplevel file COPYING of that project for license details. *
|
||||||
|
; ***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
;
|
||||||
|
; AtMega644
|
||||||
|
; --------
|
||||||
|
; DSPLED PB0 1 40 PA0 DEV0
|
||||||
|
; DC PB1 2 39 PA1 DEV1
|
||||||
|
; INT2 PB2 3 38 PA2 DEV2
|
||||||
|
; DSPRES PB3 4 37 PA3 PA3
|
||||||
|
; SS PB4 5 36 PA4 PA4
|
||||||
|
; MOSI PB5 6 35 PA5
|
||||||
|
; MISO PB6 7 34 PA6
|
||||||
|
; SCK PB7 8 33 PA7
|
||||||
|
; /RESET 9 32 AREF
|
||||||
|
; VCC 10 31 GND
|
||||||
|
; GND 11 30 AVCC
|
||||||
|
; XTAL2 12 29 PC7
|
||||||
|
; XTAL1 13 28 PC6
|
||||||
|
; RXD PD0 14 27 PC5
|
||||||
|
; TXD PD1 15 26 PC4
|
||||||
|
; ATTN PD2 16 25 PC3
|
||||||
|
; INT1 PD3 17 24 PC2
|
||||||
|
; LED PD4 18 23 PC1
|
||||||
|
; PD5 19 22 PC0
|
||||||
|
; PD6 20 21 PD7
|
||||||
|
; --------
|
||||||
|
;
|
||||||
|
; ***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.equ BOOTLOADER_ADDR = 0x7c00
|
||||||
|
|
||||||
|
.equ FIRMWARE_VARIANT_BOOT = 0
|
||||||
|
.equ FIRMWARE_VARIANT_TEMP_WINDOW = 1
|
||||||
|
|
||||||
|
.equ DEVICEINFO_ID = 'C'
|
||||||
|
.equ DEVICEINFO_VERSION = 2
|
||||||
|
.equ DEVICEINFO_REVISION = 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; LED module
|
||||||
|
|
||||||
|
.equ LED_SIMPLE_ONTIME = 1 ; shorter
|
||||||
|
.equ LED_SIMPLE_OFFTIME = 50 ; longer
|
||||||
|
.equ LED_SIMPLE_DDR = DDRD
|
||||||
|
.equ LED_SIMPLE_PORT = PORTD
|
||||||
|
.equ LED_SIMPLE_PORTIN = PIND
|
||||||
|
.equ LED_SIMPLE_PINNUM = PORTD4
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; COM module
|
||||||
|
|
||||||
|
.equ COM_BIT_LENGTH = 52000 ; 104000ns=9600, 52000ns=19200, 26000ns=38400
|
||||||
|
.equ COM_HALFBIT_LENGTH = 26000 ; see https://de.wikipedia.org/wiki/Universal_Asynchronous_Receiver_Transmitter
|
||||||
|
|
||||||
|
.equ COM_DATA_DDR = DDRD
|
||||||
|
.equ COM_DATA_INPUT = PIND
|
||||||
|
.equ COM_DATA_OUTPUT = PORTD
|
||||||
|
.equ COM_DATA_PIN = PORTD0
|
||||||
|
|
||||||
|
.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 = EIMSK
|
||||||
|
.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 = DDRA
|
||||||
|
.equ SPIHW_SS0_OUTPUT = PORTA
|
||||||
|
.equ SPIHW_SS0_INPUT = PORTA
|
||||||
|
.equ SPIHW_SS0_PIN = PORTA0
|
||||||
|
|
||||||
|
.equ SPIHW_SS1_DDR = DDRA
|
||||||
|
.equ SPIHW_SS1_OUTPUT = PORTA
|
||||||
|
.equ SPIHW_SS1_INPUT = PORTA
|
||||||
|
.equ SPIHW_SS1_PIN = PORTA1
|
||||||
|
|
||||||
|
.equ SPIHW_SS2_DDR = DDRA
|
||||||
|
.equ SPIHW_SS2_OUTPUT = PORTA
|
||||||
|
.equ SPIHW_SS2_INPUT = PORTA
|
||||||
|
.equ SPIHW_SS2_PIN = PORTA2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; 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 = DDRB
|
||||||
|
.equ ILI9341_DC_OUTPUT = PORTB
|
||||||
|
.equ ILI9341_DC_INPUT = PORTB
|
||||||
|
.equ ILI9341_DC_PIN = PORTB1
|
||||||
|
|
||||||
|
.equ ILI9341_LED_DDR = DDRB
|
||||||
|
.equ ILI9341_LED_OUTPUT = PORTB
|
||||||
|
.equ ILI9341_LED_INPUT = PORTB
|
||||||
|
.equ ILI9341_LED_PIN = PORTB0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; 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
|
||||||
|
|
||||||
|
|
||||||
34
avr/devices/c02/main/0BUILD
Normal file
34
avr/devices/c02/main/0BUILD
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?xml?>
|
||||||
|
|
||||||
|
<gwbuild>
|
||||||
|
|
||||||
|
<target type="AvrHexFile" name="c02_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>
|
||||||
|
data.asm
|
||||||
|
</extradist>
|
||||||
|
|
||||||
|
|
||||||
|
</gwbuild>
|
||||||
|
|
||||||
|
|
||||||
14
avr/devices/c02/main/data.asm
Normal file
14
avr/devices/c02/main/data.asm
Normal file
@@ -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
|
||||||
|
|
||||||
|
|
||||||
240
avr/devices/c02/main/main.asm
Normal file
240
avr/devices/c02/main/main.asm
Normal file
@@ -0,0 +1,240 @@
|
|||||||
|
; ***************************************************************************
|
||||||
|
; copyright : (C) 2025 by Martin Preuss
|
||||||
|
; email : martin@libchipcard.de
|
||||||
|
;
|
||||||
|
; ***************************************************************************
|
||||||
|
; * This file is part of the project "AqHome". *
|
||||||
|
; * Please see toplevel file COPYING of that project for license details. *
|
||||||
|
; ***************************************************************************
|
||||||
|
|
||||||
|
;.equ clock=1000000 ; Define the clock frequency
|
||||||
|
.equ clock=8000000 ; Define the clock frequency
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.nolist
|
||||||
|
.include "include/m644Pdef.inc" ; Define device ATmega644P
|
||||||
|
.list
|
||||||
|
|
||||||
|
.include "version.asm"
|
||||||
|
.include "../defs.asm"
|
||||||
|
.include "./data.asm"
|
||||||
|
|
||||||
|
.include "devices/all/defs.asm"
|
||||||
|
.include "common/calls.asm"
|
||||||
|
.include "common/utils_wait.asm"
|
||||||
|
.include "common/utils_io.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; defines
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; generic
|
||||||
|
|
||||||
|
.equ NET_BUFFERS_NUM = 8
|
||||||
|
.equ NET_BUFFERS_SIZE = 32
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; heap
|
||||||
|
|
||||||
|
.equ HEAP_START = SRAM_START+0x200
|
||||||
|
.equ HEAP_SIZE = SRAM_SIZE-HEAP_START
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; firmware settings including list of modules used
|
||||||
|
|
||||||
|
; #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_UART_BITBANG
|
||||||
|
#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
|
||||||
|
jmp BOOTLOADER_ADDR ; 1: Reset vector RESET
|
||||||
|
jmp UART_BitBang_PcintIsr ; 2: INT0 External Interrupt Request 0
|
||||||
|
jmp irqNotSet ; 3: INT1 External Interrupt Request 1
|
||||||
|
jmp irqNotSet ; 4: INT2 External Interrupt Request 2
|
||||||
|
jmp irqNotSet ; 5: PCINT0 Pin Change Interrupt Request 0
|
||||||
|
jmp irqNotSet ; 6: PCINT1 Pin Change Interrupt Request 1
|
||||||
|
jmp irqNotSet ; 7: PCINT2 Pin Change Interrupt Request 2
|
||||||
|
jmp irqNotSet ; 8: PCINT3 Pin Change Interrupt Request 3
|
||||||
|
jmp irqNotSet ; 9: WDT Watchdog Time-out Interrupt
|
||||||
|
jmp irqNotSet ; 10: TIMER2_COMPA Timer/Counter2 Compare Match A
|
||||||
|
jmp irqNotSet ; 11: TIMER2_COMPB Timer/Counter2 Compare Match B
|
||||||
|
jmp irqNotSet ; 12: TIMER2_OVF Timer/Counter2 Overflow
|
||||||
|
jmp irqNotSet ; 13: TIMER1_CAPT Timer/Counter1 Capture Event
|
||||||
|
jmp irqNotSet ; 14: TIMER1_COMPA Timer/Counter1 Compare Match A
|
||||||
|
jmp irqNotSet ; 15: TIMER1_COMPB Timer/Counter1 Compare Match B
|
||||||
|
jmp irqNotSet ; 16: TIMER1_OVF Timer/Counter1 Overflow
|
||||||
|
jmp baseTimerIrqOC0A ; 17: TIMER0_COMPA Timer/Counter0 Compare Match A
|
||||||
|
jmp irqNotSet ; 18: TIMER0_COMPB Timer/Counter0 Compare Match B
|
||||||
|
jmp irqNotSet ; 19: TIMER0_OVF Timer/Counter0 Overflow
|
||||||
|
jmp irqNotSet ; 20: SPI_STC Serial Transfer Complete
|
||||||
|
jmp irqNotSet ; 21: USART0_RXC USART0 Rx Complete
|
||||||
|
jmp irqNotSet ; 22: USART0_UDRE USART0 Data Register Empty
|
||||||
|
jmp irqNotSet ; 23: USART0_TXC USART0 Tx Complete
|
||||||
|
jmp irqNotSet ; 24: ANA_COMP Analog Comparator
|
||||||
|
jmp irqNotSet ; 25: ADC ADC Conversion Complete
|
||||||
|
jmp irqNotSet ; 26: EE_RDY EEPROM Ready
|
||||||
|
jmp irqNotSet ; 27: TWI 2-Wire Interface
|
||||||
|
jmp irqNotSet ; 28: SPM_RDY Store Program Memory Ready
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
devInfoBlock: ; 12 bytes
|
||||||
|
devInfoManufacturer: .db 'A', 'Q', 'U', 'A'
|
||||||
|
devInfoId: .db DEVICEINFO_ID, 0
|
||||||
|
devInfoVersion: .db DEVICEINFO_VERSION, DEVICEINFO_REVISION ; version, revision
|
||||||
|
firmwareVersion: .db FIRMWARE_VARIANT_TEMP_WINDOW, FIRMWARE_VERSION_MAJOR
|
||||||
|
.db FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCHLEVEL
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine firmwareStart @global
|
||||||
|
|
||||||
|
firmwareStart:
|
||||||
|
rjmp main
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
irqNotSet:
|
||||||
|
reti
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine onSystemStart
|
||||||
|
|
||||||
|
onSystemStart:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine onMessageReceived
|
||||||
|
;
|
||||||
|
; Called on every message received
|
||||||
|
|
||||||
|
onMessageReceived:
|
||||||
|
clc
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine onEvery100ms
|
||||||
|
;
|
||||||
|
; Called every 100ms. Add your routine calls here. No arguments, no results.
|
||||||
|
|
||||||
|
onEvery100ms:
|
||||||
|
onEverySecond:
|
||||||
|
onEveryMinute:
|
||||||
|
onEveryHour:
|
||||||
|
onEveryDay:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine onEveryLoop
|
||||||
|
;
|
||||||
|
; Called on every loop (i.e. after awakening from sleep).
|
||||||
|
;
|
||||||
|
onEveryLoop:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; includes
|
||||||
|
|
||||||
|
.include "devices/all/hw_m644p.asm"
|
||||||
|
.include "devices/all/includes.asm"
|
||||||
|
|
||||||
|
.include "common/debug.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; defines for network interface
|
||||||
|
|
||||||
|
;.equ netInterfaceData = netUartIface
|
||||||
|
.equ netInterfaceData = uart_bitbang_iface
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -16,25 +16,16 @@
|
|||||||
.include "../defs.asm"
|
.include "../defs.asm"
|
||||||
.include "devices/all/defs.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
|
||||||
|
.include "common/calls.asm"
|
||||||
|
.include "common/utils_wait.asm"
|
||||||
|
;.include "modules/com2/defs.asm"
|
||||||
|
;.include "modules/comproto/defs.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
; defines
|
; defines
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; generic
|
|
||||||
|
|
||||||
.include "common/utils_wait.asm"
|
|
||||||
.include "modules/com2/defs.asm"
|
|
||||||
.include "modules/comproto/defs.asm"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; firmware settings
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; LED
|
; LED
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,8 @@
|
|||||||
.include "../defs.asm"
|
.include "../defs.asm"
|
||||||
|
|
||||||
.include "devices/all/defs.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
|
||||||
|
.include "common/calls.asm"
|
||||||
.include "common/utils_wait.asm"
|
.include "common/utils_wait.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,26 +16,14 @@
|
|||||||
.include "./defs.asm"
|
.include "./defs.asm"
|
||||||
.include "devices/all/defs.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
|
||||||
|
.include "common/calls.asm"
|
||||||
|
.include "common/utils_wait.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
; defines
|
; defines
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; generic
|
|
||||||
|
|
||||||
.include "common/utils_wait.asm"
|
|
||||||
.include "modules/com2/defs.asm"
|
|
||||||
.include "modules/comproto/defs.asm"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; firmware settings
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; LED
|
; LED
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
.include "./defs.asm"
|
.include "./defs.asm"
|
||||||
.include "devices/all/defs.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
|
||||||
|
.include "common/calls.asm"
|
||||||
.include "common/utils_wait.asm"
|
.include "common/utils_wait.asm"
|
||||||
|
|
||||||
|
|
||||||
@@ -57,10 +58,10 @@
|
|||||||
#define MODULES_LED_SIMPLE
|
#define MODULES_LED_SIMPLE
|
||||||
#define MODULES_NETWORK
|
#define MODULES_NETWORK
|
||||||
#define MODULES_UART_BITBANG
|
#define MODULES_UART_BITBANG
|
||||||
;#define MODULES_TWI_MASTER
|
#define MODULES_TWI_MASTER
|
||||||
;#define MODULES_LCD
|
;#define MODULES_LCD
|
||||||
;#define LCD_MINIMAL_FONT
|
;#define LCD_MINIMAL_FONT
|
||||||
;#define MODULES_SI7021
|
#define MODULES_SI7021
|
||||||
;#define MODULES_STATS
|
;#define MODULES_STATS
|
||||||
;#define MODULES_OWI_MASTER
|
;#define MODULES_OWI_MASTER
|
||||||
;#define MODULES_DS18B20
|
;#define MODULES_DS18B20
|
||||||
@@ -71,7 +72,7 @@
|
|||||||
#define APPS_NETWORK
|
#define APPS_NETWORK
|
||||||
;#define APPS_MOTION
|
;#define APPS_MOTION
|
||||||
;#define APPS_DOOR
|
;#define APPS_DOOR
|
||||||
;#define APPS_REPORTSENSORS
|
#define APPS_REPORTSENSORS
|
||||||
#define APPS_STATS
|
#define APPS_STATS
|
||||||
|
|
||||||
|
|
||||||
@@ -201,6 +202,9 @@ onEveryLoop:
|
|||||||
.include "devices/all/hw_tn84.asm"
|
.include "devices/all/hw_tn84.asm"
|
||||||
.include "devices/all/includes.asm"
|
.include "devices/all/includes.asm"
|
||||||
|
|
||||||
|
;.include "common/debug.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -16,24 +16,14 @@
|
|||||||
.include "../defs.asm"
|
.include "../defs.asm"
|
||||||
.include "devices/all/defs.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
|
||||||
|
.include "common/calls.asm"
|
||||||
|
.include "common/utils_wait.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
; defines
|
; defines
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; generic
|
|
||||||
|
|
||||||
.include "common/utils_wait.asm"
|
|
||||||
.include "modules/com2/defs.asm"
|
|
||||||
.include "modules/comproto/defs.asm"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; firmware settings
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; LED
|
; LED
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
.include "./data.asm"
|
.include "./data.asm"
|
||||||
|
|
||||||
.include "devices/all/defs.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
.include "common/calls.asm"
|
||||||
.include "common/utils_wait.asm"
|
.include "common/utils_wait.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,22 +18,15 @@
|
|||||||
.include "../defs.asm"
|
.include "../defs.asm"
|
||||||
.include "devices/all/defs.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
|
||||||
|
.include "common/calls.asm"
|
||||||
|
|
||||||
; ***************************************************************************
|
|
||||||
; defines
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; generic
|
|
||||||
|
|
||||||
.include "common/utils_wait.asm"
|
.include "common/utils_wait.asm"
|
||||||
.include "modules/com2/defs.asm"
|
.include "modules/com2/defs.asm"
|
||||||
.include "modules/comproto/defs.asm"
|
.include "modules/comproto/defs.asm"
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; firmware settings
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; defines
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
;.include "./data.asm"
|
;.include "./data.asm"
|
||||||
|
|
||||||
.include "devices/all/defs.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
|
||||||
|
.include "common/calls.asm"
|
||||||
.include "common/utils_wait.asm"
|
.include "common/utils_wait.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
.include "../defs.asm"
|
.include "../defs.asm"
|
||||||
.include "devices/all/defs.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
|
||||||
|
.include "common/calls.asm"
|
||||||
|
.include "common/utils_wait.asm"
|
||||||
|
|
||||||
|
|
||||||
#define COM_ACCEPT_ALL_DEST
|
#define COM_ACCEPT_ALL_DEST
|
||||||
|
|
||||||
@@ -24,18 +27,6 @@
|
|||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
; defines
|
; defines
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; generic
|
|
||||||
|
|
||||||
.include "common/utils_wait.asm"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; firmware settings
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; LED
|
; LED
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
.include "./data.asm"
|
.include "./data.asm"
|
||||||
|
|
||||||
.include "devices/all/defs.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
.include "common/calls.asm"
|
||||||
.include "common/utils_wait.asm"
|
.include "common/utils_wait.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
|
|
||||||
.include "version.asm"
|
.include "version.asm"
|
||||||
.include "../defs.asm"
|
.include "../defs.asm"
|
||||||
|
|
||||||
|
.include "common/calls.asm"
|
||||||
.include "devices/all/defs.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
.include "version.asm"
|
.include "version.asm"
|
||||||
.include "devices/all/defs.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
.include "common/calls.asm"
|
||||||
.include "common/utils_wait.asm"
|
.include "common/utils_wait.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<gwbuild>
|
<gwbuild>
|
||||||
|
|
||||||
<target type="AvrHexFile" name="n22_boot" >
|
<target type="AvrHexFile" name="n25_boot" >
|
||||||
|
|
||||||
<includes type="avrasm" >
|
<includes type="avrasm" >
|
||||||
-I $(builddir)
|
-I $(builddir)
|
||||||
|
|||||||
@@ -18,24 +18,14 @@
|
|||||||
.include "../defs.asm"
|
.include "../defs.asm"
|
||||||
.include "devices/all/defs.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
|
||||||
|
.include "common/calls.asm"
|
||||||
|
.include "common/utils_wait.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
; defines
|
; defines
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; generic
|
|
||||||
|
|
||||||
.include "common/utils_wait.asm"
|
|
||||||
.include "modules/com2/defs.asm"
|
|
||||||
.include "modules/comproto/defs.asm"
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; firmware settings
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; LED
|
; LED
|
||||||
|
|
||||||
@@ -56,21 +46,24 @@
|
|||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; Reset and interrupt vectors
|
; Reset and interrupt vectors
|
||||||
rjmp main ; Reset vector
|
|
||||||
reti ; EXT_INT0
|
rjmp main ; 1: Reset vector
|
||||||
reti ; PCI0
|
reti ; 2: EXT_INT0
|
||||||
reti ; OC1A
|
reti ; 3: PCI0
|
||||||
reti ; OVF1
|
reti ; 4: PCI1
|
||||||
reti ; OVF0
|
reti ; 5: WDT
|
||||||
reti ; ERDY
|
reti ; 6: TIM1_CAPT
|
||||||
reti ; ACI
|
reti ; 7: TIM1_COMPA
|
||||||
reti ; ADCC
|
reti ; 8: TIM1_COMPB
|
||||||
reti ; OC1B
|
reti ; 9: TIM1_OVF
|
||||||
reti ; OC0A
|
reti ; 10: TIM0_COMPA
|
||||||
reti ; OC0B
|
reti ; 11: TIM0_COMPB
|
||||||
reti ; WATCHDOG
|
reti ; 12: TIM0_OVF
|
||||||
reti ; USI_STR
|
reti ; 13: ANA_COMP
|
||||||
reti ; USI_OVF
|
reti ; 14: ADC
|
||||||
|
reti ; 15: EE_RDY
|
||||||
|
reti ; 16: USI_STR
|
||||||
|
reti ; 17: USI_OVF
|
||||||
|
|
||||||
devInfoBlock: ; 12 bytes
|
devInfoBlock: ; 12 bytes
|
||||||
devInfoManufacturer: .db 'A', 'Q', 'U', 'A'
|
devInfoManufacturer: .db 'A', 'Q', 'U', 'A'
|
||||||
@@ -79,7 +72,8 @@ devInfoVersion: .db DEVICEINFO_VERSION, DEVICEINFO_REVISION ; v
|
|||||||
firmwareVersion: .db FIRMWARE_VARIANT_BOOT, FIRMWARE_VERSION_MAJOR
|
firmwareVersion: .db FIRMWARE_VARIANT_BOOT, FIRMWARE_VERSION_MAJOR
|
||||||
.db FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCHLEVEL
|
.db FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCHLEVEL
|
||||||
|
|
||||||
firmwareStart: rjmp main ; will be overwritten when flashing
|
firmwareStart:
|
||||||
|
rjmp main ; will be overwritten when flashing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<gwbuild>
|
<gwbuild>
|
||||||
|
|
||||||
<target type="AvrHexFile" name="n22_firmware" >
|
<target type="AvrHexFile" name="n25_firmware" >
|
||||||
|
|
||||||
<includes type="avrasm" >
|
<includes type="avrasm" >
|
||||||
-I $(builddir)
|
-I $(builddir)
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
;.include "./data.asm"
|
;.include "./data.asm"
|
||||||
|
|
||||||
.include "devices/all/defs.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
|
||||||
|
.include "common/calls.asm"
|
||||||
.include "common/utils_wait.asm"
|
.include "common/utils_wait.asm"
|
||||||
|
|
||||||
|
|
||||||
@@ -95,21 +97,27 @@
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; Reset and interrupt vectors
|
; Reset and interrupt vectors
|
||||||
|
|
||||||
rjmp BOOTLOADER_ADDR ; Reset vector ; use this for flashed system
|
rjmp BOOTLOADER_ADDR ; 1: Reset vector ; use this for flashed system
|
||||||
reti ; EXT_INT0
|
reti ; 2: EXT_INT0
|
||||||
rjmp UART_BitBang_PcintIsr ; PCI0
|
#ifdef MODULES_UART_BITBANG
|
||||||
reti ; OC1A
|
rjmp UART_BitBang_PcintIsr ; 3: PCI0
|
||||||
reti ; OVF1
|
#else
|
||||||
reti ; OVF0
|
reti ; 3: PCI0
|
||||||
reti ; ERDY
|
#endif
|
||||||
reti ; ACI
|
reti ; 4: PCI1
|
||||||
reti ; ADCC
|
reti ; 5: WDT
|
||||||
reti ; OC1B
|
reti ; 6: TIM1_CAPT
|
||||||
rjmp baseTimerIrqOC0A ; OC0A
|
reti ; 7: TIM1_COMPA
|
||||||
reti ; OC0B
|
reti ; 8: TIM1_COMPB
|
||||||
reti ; WATCHDOG
|
reti ; 9: TIM1_OVF
|
||||||
reti ; USI_STR
|
rjmp baseTimerIrqOC0A ; 10: TIM0_COMPA
|
||||||
reti ; USI_OVF
|
reti ; 11: TIM0_COMPB
|
||||||
|
reti ; 12: TIM0_OVF
|
||||||
|
reti ; 13: ANA_COMP
|
||||||
|
reti ; 14: ADC
|
||||||
|
reti ; 15: EE_RDY
|
||||||
|
reti ; 16: USI_STR
|
||||||
|
reti ; 17: USI_OVF
|
||||||
|
|
||||||
|
|
||||||
devInfoBlock: ; 12 bytes
|
devInfoBlock: ; 12 bytes
|
||||||
@@ -163,12 +171,14 @@ onEveryDay:
|
|||||||
|
|
||||||
onEverySecond:
|
onEverySecond:
|
||||||
ret
|
ret
|
||||||
|
#if 0
|
||||||
; debug
|
; debug
|
||||||
ldi r19, 0x00 ; G
|
ldi r19, 0x00 ; G
|
||||||
ldi r18, 0xff ; R
|
ldi r18, 0xff ; R
|
||||||
ldi r20, 0x55 ; B
|
ldi r20, 0x55 ; B
|
||||||
ldi r21, 0xaa ; W
|
ldi r21, 0xaa ; W
|
||||||
rcall SK6812_SetAllColor ; r23 (r16, r17)
|
rcall SK6812_SetAllColor ; r23 (r16, r17)
|
||||||
|
#endif
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@@ -191,14 +201,16 @@ onEveryLoop:
|
|||||||
|
|
||||||
.include "devices/all/hw_tn84.asm"
|
.include "devices/all/hw_tn84.asm"
|
||||||
.include "devices/all/includes.asm"
|
.include "devices/all/includes.asm"
|
||||||
.include "common/debug.asm"
|
;.include "common/debug.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; defines for network interface
|
; defines for network interface
|
||||||
|
|
||||||
|
#ifdef MODULES_UART_BITBANG
|
||||||
.equ netInterfaceData = uart_bitbang_iface
|
.equ netInterfaceData = uart_bitbang_iface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,28 +13,18 @@
|
|||||||
.include "include/tn841def.inc" ; Define device ATtiny841
|
.include "include/tn841def.inc" ; Define device ATtiny841
|
||||||
.list
|
.list
|
||||||
|
|
||||||
|
.include "version.asm"
|
||||||
.include "../defs.asm"
|
.include "../defs.asm"
|
||||||
.include "defs_all.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
|
||||||
|
.include "common/calls.asm"
|
||||||
|
.include "common/utils_wait.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
; defines
|
; defines
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; generic
|
|
||||||
|
|
||||||
.include "common/utils_wait.asm"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; firmware settings
|
|
||||||
|
|
||||||
.equ FIRMWARE_VERSION_MAJOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_MINOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_PATCHLEVEL = 1
|
|
||||||
|
|
||||||
|
|
||||||
;#define COM_ACCEPT_ALL_DEST 1
|
;#define COM_ACCEPT_ALL_DEST 1
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,8 @@
|
|||||||
;.include "defs_all.asm"
|
;.include "defs_all.asm"
|
||||||
|
|
||||||
.include "devices/all/defs.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
|
||||||
|
.include "common/calls.asm"
|
||||||
.include "common/utils_wait.asm"
|
.include "common/utils_wait.asm"
|
||||||
.include "common/utils_io.asm"
|
.include "common/utils_io.asm"
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,8 @@ bootLoader_startFirmware:
|
|||||||
ldi r20, 4 ; on time
|
ldi r20, 4 ; on time
|
||||||
ldi r21, 1 ; off time
|
ldi r21, 1 ; off time
|
||||||
rcall bootLoaderBlinkLed
|
rcall bootLoaderBlinkLed
|
||||||
rjmp firmwareStart
|
bigjmp firmwareStart
|
||||||
|
|
||||||
bootLoader_waitAndRestartBootLoader:
|
bootLoader_waitAndRestartBootLoader:
|
||||||
ldi r19, 3 ; loop count
|
ldi r19, 3 ; loop count
|
||||||
ldi r20, 1 ; on time
|
ldi r20, 1 ; on time
|
||||||
|
|||||||
@@ -42,13 +42,14 @@ flash1pMegaWritePage:
|
|||||||
ldi xl, LOW(flashPageBuffer)
|
ldi xl, LOW(flashPageBuffer)
|
||||||
ldi xh, HIGH(flashPageBuffer)
|
ldi xh, HIGH(flashPageBuffer)
|
||||||
ldi r24, LOW(PAGESIZE)
|
ldi r24, LOW(PAGESIZE)
|
||||||
|
ldi r25, HIGH(PAGESIZE)
|
||||||
flash1pMegaWritePages_loop:
|
flash1pMegaWritePages_loop:
|
||||||
ld r0, X+ ; read source data from buffer (low)
|
ld r0, X+ ; read source data from buffer (low)
|
||||||
ld r1, X+ ; read source data from buffer (high)
|
ld r1, X+ ; read source data from buffer (high)
|
||||||
ldi r20, (1<<SPMEN) ; enable next SPM, write R1:R0 into temp page buffer
|
ldi r20, (1<<SPMEN) ; enable next SPM, write R1:R0 into temp page buffer
|
||||||
rcall flashDoSpm ; (R16)
|
rcall flashDoSpm ; (R16)
|
||||||
adiw zh:zl, 2
|
adiw zh:zl, 2
|
||||||
dec r24
|
sbiw r25:r24, 1
|
||||||
brne flash1pMegaWritePages_loop
|
brne flash1pMegaWritePages_loop
|
||||||
|
|
||||||
subi zl, LOW(PAGESIZE*2) ; point back to begin of page
|
subi zl, LOW(PAGESIZE*2) ; point back to begin of page
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
; * Please see toplevel file COPYING of that project for license details. *
|
; * Please see toplevel file COPYING of that project for license details. *
|
||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
|
|
||||||
|
; Code for large pagesizes (128 and larger)
|
||||||
|
|
||||||
|
|
||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
; code
|
; code
|
||||||
@@ -92,7 +94,7 @@ flashWriteData:
|
|||||||
flashWriteData_beginPage:
|
flashWriteData_beginPage:
|
||||||
rcall flashBeginPage ; (r16, r24, r25, X)
|
rcall flashBeginPage ; (r16, r24, r25, X)
|
||||||
flashWriteData_calcPosAndLength:
|
flashWriteData_calcPosAndLength:
|
||||||
rcall flashCalcPosAndLength ; r18=bytes_to_write, x=pos_in_buffer (r24, r25)
|
rcall flashCalcPosAndLength ; r18=bytes_to_write, x=pos_in_buffer (r19, r24, r25)
|
||||||
; X=abs pos in buffer, r18=bytes to read, r17=bytes initially requested
|
; X=abs pos in buffer, r18=bytes to read, r17=bytes initially requested
|
||||||
; prepare data for return
|
; prepare data for return
|
||||||
sub r17, r18 ; r17 holds remainder
|
sub r17, r18 ; r17 holds remainder
|
||||||
@@ -117,24 +119,30 @@ flashWriteData_copyLoop:
|
|||||||
; @param R17 number of bytes to write
|
; @param R17 number of bytes to write
|
||||||
; @return X absolute write position inside buffer
|
; @return X absolute write position inside buffer
|
||||||
; @return R18 bytes to write
|
; @return R18 bytes to write
|
||||||
; @clobbers r24, r25
|
; @clobbers r19, r24, r25
|
||||||
|
|
||||||
flashCalcPosAndLength:
|
flashCalcPosAndLength:
|
||||||
; calc offset into buffer
|
; calc offset into buffer
|
||||||
mov r24, zl
|
mov r24, zl
|
||||||
andi r24, (FLASH_PAGESIZE-1) ; r24=rel pos inside buffer
|
mov r25, zh
|
||||||
ldi r25, FLASH_PAGESIZE
|
andi r24, LOW(FLASH_PAGESIZE-1)
|
||||||
sub r25, r24 ; r25=bytes left inside page
|
andi r25, HIGH(FLASH_PAGESIZE-1) ; R25:r24=pos inside page
|
||||||
mov r18, r17
|
ldi r18, LOW(FLASH_PAGESIZE)
|
||||||
cp r25, r17 ; bytes to read > bytes left in page?
|
ldi r19, HIGH(FLASH_PAGESIZE)
|
||||||
brcc flashCalcPosAndLength_l1 ; no: jump
|
sub r18, r24
|
||||||
mov r18, r25 ; yes: cut r18 to number of bytes left in page
|
sbc r19, r25 ; R19:R18=FLASH_PAGESIZE-relPos
|
||||||
flashCalcPosAndLength_l1:
|
tst r19 ; high byte zero?
|
||||||
ldi xl, LOW(flashPageBuffer) ; set X to pos within page buffer
|
breq flashCalcPosAndLength_8bit ; yes, already 8-bit
|
||||||
|
ldi r18, 255 ; clip size to 8 bit
|
||||||
|
flashCalcPosAndLength_8bit:
|
||||||
|
cp r17, r18 ; r18>r17?
|
||||||
|
brcc flashCalcPosAndLength_sizeOk ; nope: jump
|
||||||
|
mov r18, r17 ; clip r18 to size requested
|
||||||
|
flashCalcPosAndLength_sizeOk: ; r18=bytes to write
|
||||||
|
ldi xl, LOW(flashPageBuffer) ; set X to pos within page buffer
|
||||||
ldi xh, HIGH(flashPageBuffer)
|
ldi xh, HIGH(flashPageBuffer)
|
||||||
add xl, r24
|
add xl, r24
|
||||||
adc xh, r24
|
adc xh, r25
|
||||||
sub xh, r24
|
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
@@ -245,17 +253,17 @@ flashEndPage_write:
|
|||||||
; @routine flashReadPageIntoSram
|
; @routine flashReadPageIntoSram
|
||||||
;
|
;
|
||||||
; @param Z Address to read from (byte address as for LPM!)
|
; @param Z Address to read from (byte address as for LPM!)
|
||||||
; @clobbers r16, r24, X, Z
|
; @clobbers r16, r24, r25, X, Z
|
||||||
|
|
||||||
flashReadPageIntoSram:
|
flashReadPageIntoSram:
|
||||||
ldi xl, LOW(flashPageBuffer)
|
ldi xl, LOW(flashPageBuffer)
|
||||||
ldi xh, HIGH(flashPageBuffer)
|
ldi xh, HIGH(flashPageBuffer)
|
||||||
ldi r24, LOW(FLASH_PAGESIZE)
|
ldi r24, LOW(FLASH_PAGESIZE)
|
||||||
|
ldi r25, HIGH(FLASH_PAGESIZE)
|
||||||
flashReadPageIntoSram_loop:
|
flashReadPageIntoSram_loop:
|
||||||
lpm r16, Z+
|
lpm r16, Z+
|
||||||
st X+, r16
|
st X+, r16
|
||||||
; adiw ZH:ZL, 1
|
sbiw r25:r24, 1
|
||||||
dec r24
|
|
||||||
brne flashReadPageIntoSram_loop
|
brne flashReadPageIntoSram_loop
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ ioRawReceivePacketIntoBuffer:
|
|||||||
breq ioRawReceivePacketIntoBuffer_acceptAddr
|
breq ioRawReceivePacketIntoBuffer_acceptAddr
|
||||||
cpi r16, 0xff
|
cpi r16, 0xff
|
||||||
breq ioRawReceivePacketIntoBuffer_acceptAddr
|
breq ioRawReceivePacketIntoBuffer_acceptAddr
|
||||||
ldi r16, COM2_ERROR_NOTFORME
|
clr r16 ; not for me
|
||||||
rjmp ioRawReceivePacketIntoBuffer_error ; clc/ret
|
rjmp ioRawReceivePacketIntoBuffer_error ; clc/ret
|
||||||
#endif
|
#endif
|
||||||
ioRawReceivePacketIntoBuffer_acceptAddr:
|
ioRawReceivePacketIntoBuffer_acceptAddr:
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ NETMSG_Device_Write:
|
|||||||
ldi zh, HIGH(devInfoBlock*2) ; 6-17: devInfoBlock
|
ldi zh, HIGH(devInfoBlock*2) ; 6-17: devInfoBlock
|
||||||
ldi zl, LOW(devInfoBlock*2)
|
ldi zl, LOW(devInfoBlock*2)
|
||||||
ldi r18, 12
|
ldi r18, 12
|
||||||
rcall Utils_CopyFromFlash ; (R17, R18, X, Z)
|
bigcall Utils_CopyFromFlash ; (R17, R18, X, Z)
|
||||||
sbiw xh:xl, 20 ; go back to beginning of message (1 byte dst addr, 1 byte length, 18 bytes payload)
|
sbiw xh:xl, 20 ; go back to beginning of message (1 byte dst addr, 1 byte length, 18 bytes payload)
|
||||||
rcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X)
|
rcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X)
|
||||||
sbiw xh:xl, 21 ; go back to beginning of message (1 byte dst addr, 1 byte length, 18 bytes payload, 1 byte crc)
|
sbiw xh:xl, 21 ; go back to beginning of message (1 byte dst addr, 1 byte length, 18 bytes payload, 1 byte crc)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ NETMSG_RecvStats_Write:
|
|||||||
rcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21)
|
rcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21)
|
||||||
adiw yh:yl, NET_IFACE_OFFS_PACKETSIN_LOW
|
adiw yh:yl, NET_IFACE_OFFS_PACKETSIN_LOW
|
||||||
ldi r18, 12
|
ldi r18, 12
|
||||||
rcall Utils_Copy_SDRAM ; (R17, R18, X, Y)
|
bigcall Utils_Copy_SDRAM ; (R17, R18, X, Y)
|
||||||
sbiw yh:yl, NET_IFACE_OFFS_PACKETSIN_LOW+12
|
sbiw yh:yl, NET_IFACE_OFFS_PACKETSIN_LOW+12
|
||||||
|
|
||||||
sbiw xh:xl, 20 ; go back to beginning of message (1 byte dst addr, 1 byte length, 18 bytes payload)
|
sbiw xh:xl, 20 ; go back to beginning of message (1 byte dst addr, 1 byte length, 18 bytes payload)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ NETMSG_SendStats_Write:
|
|||||||
rcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21)
|
rcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21)
|
||||||
adiw yh:yl, NET_IFACE_OFFS_PACKETSOUT_LOW
|
adiw yh:yl, NET_IFACE_OFFS_PACKETSOUT_LOW
|
||||||
ldi r18, 6
|
ldi r18, 6
|
||||||
rcall Utils_Copy_SDRAM ; (R17, R18, X, Y)
|
bigcall Utils_Copy_SDRAM ; (R17, R18, X, Y)
|
||||||
sbiw yh:yl, NET_IFACE_OFFS_PACKETSOUT_LOW+6
|
sbiw yh:yl, NET_IFACE_OFFS_PACKETSOUT_LOW+6
|
||||||
|
|
||||||
sbiw xh:xl, 14 ; go back to beginning of message (1 byte dst addr, 1 byte length, 12 bytes payload)
|
sbiw xh:xl, 14 ; go back to beginning of message (1 byte dst addr, 1 byte length, 12 bytes payload)
|
||||||
|
|||||||
@@ -104,33 +104,28 @@ uartBitbang_SendByte_loop: ; 11 for low bit
|
|||||||
uartBitbang_SendByte_setLow:
|
uartBitbang_SendByte_setLow:
|
||||||
sbi COM_DATA_DDR, COM_DATA_PIN ; +2 set DATA as output
|
sbi COM_DATA_DDR, COM_DATA_PIN ; +2 set DATA as output
|
||||||
cbi COM_DATA_OUTPUT, COM_DATA_PIN ; +2 set DATA low
|
cbi COM_DATA_OUTPUT, COM_DATA_PIN ; +2 set DATA low
|
||||||
Utils_WaitNanoSecs COM_BIT_LENGTH, 11, r22
|
rjmp uartBitbang_SendByte_wait ; +2
|
||||||
rjmp uartBitbang_SendByte_loopEnd ; +2
|
|
||||||
uartBitbang_SendByte_setHigh:
|
uartBitbang_SendByte_setHigh:
|
||||||
cbi COM_DATA_DDR, COM_DATA_PIN ; +2 set DATA as input, pullup R makes it ONE
|
cbi COM_DATA_DDR, COM_DATA_PIN ; +2 set DATA as input, pullup R makes it ONE
|
||||||
nop ; +1 (to make pin change available)
|
cbi COM_DATA_OUTPUT, COM_DATA_PIN ; +2 disable internal pullup for DATA
|
||||||
Utils_WaitNanoSecs COM_HALFBIT_LENGTH, 0, r22 ; wait for half a bit length for line to safely settle
|
nop ; +1
|
||||||
sbis COM_DATA_INPUT, COM_DATA_PIN ; +1 if no skip, +2 if skipped
|
nop ; +1
|
||||||
rjmp uartBitbang_SendByte_error ; +2 if error (collision: we wanted line to be high but it is low)
|
uartBitbang_SendByte_wait:
|
||||||
Utils_WaitNanoSecs COM_HALFBIT_LENGTH, 11, r22
|
Utils_WaitNanoSecs COM_BIT_LENGTH, 12, r22
|
||||||
cbi COM_DATA_DDR, COM_DATA_PIN ; +2 set DATA as input, pullup R makes it ONE
|
|
||||||
Utils_WaitNanoSecs COM_BIT_LENGTH, 8, r22
|
|
||||||
uartBitbang_SendByte_loopEnd:
|
uartBitbang_SendByte_loopEnd:
|
||||||
dec r21 ; +1
|
dec r21 ; +1
|
||||||
brne uartBitbang_SendByte_loop ; +2, sum per loop: 11 cycles
|
brne uartBitbang_SendByte_loop ; +2, sum per loop: 11 cycles
|
||||||
; send stopbit
|
; send stopbit
|
||||||
cbi COM_DATA_DDR, COM_DATA_PIN ; +2 set DATA as input, pullup R makes it ONE
|
cbi COM_DATA_DDR, COM_DATA_PIN ; +2 set DATA as input, pullup R makes it ONE
|
||||||
Utils_WaitNanoSecs COM_BIT_LENGTH, 0, r22 ; wait for one bit length
|
cbi COM_DATA_OUTPUT, COM_DATA_PIN ; +2 disable internal pullup for DATA
|
||||||
|
Utils_WaitNanoSecs COM_BIT_LENGTH, 1, r22 ; wait for one bit length
|
||||||
sec
|
sec
|
||||||
ret
|
ret
|
||||||
|
|
||||||
uartBitbang_SendByte_error:
|
|
||||||
clc
|
|
||||||
ret
|
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; @routine uartBitbangReceiveByte
|
; @routine uartBitbangReceiveByte
|
||||||
;
|
;
|
||||||
@@ -139,28 +134,40 @@ uartBitbang_SendByte_error:
|
|||||||
;
|
;
|
||||||
; @return CFLAG set if okay, clear otherwise
|
; @return CFLAG set if okay, clear otherwise
|
||||||
; @return R16 byte received
|
; @return R16 byte received
|
||||||
; @clobbers R16, R20, R21, R22 (R17)
|
; @clobbers R16, R17, R20, R21, R22
|
||||||
|
|
||||||
uartBitbang_ReceiveByte:
|
uartBitbang_ReceiveByte:
|
||||||
cbi COM_DATA_DDR, COM_DATA_PIN ; set DATA port as input
|
cbi COM_DATA_DDR, COM_DATA_PIN ; set DATA port as input
|
||||||
cbi COM_DATA_OUTPUT, COM_DATA_PIN ; disable internal pullup for RXD
|
cbi COM_DATA_OUTPUT, COM_DATA_PIN ; disable internal pullup for RXD
|
||||||
ldi r21, 8 ; bits left
|
ldi r21, 8 ; bits left
|
||||||
clr r20 ; byte currently receiving
|
clr r20 ; byte currently receiving
|
||||||
|
|
||||||
; wait for startbit
|
; wait for startbit
|
||||||
rcall uartBitbang_WaitForDataLow ; (R17, R22)
|
ldi r16, 10
|
||||||
brcc uartBitbang_ReceiveByte_error
|
uartBitbang_ReceiveByte_loopStartBit1:
|
||||||
Utils_WaitNanoSecs COM_HALFBIT_LENGTH, 10, r22 ; goto middle of startbit to maximize sync stability
|
ldi r17, 100 ; wait for 100us
|
||||||
|
uartBitbang_ReceiveByte_loopStartBit2:
|
||||||
|
sbis COM_DATA_INPUT, COM_DATA_PIN
|
||||||
|
rjmp uartBitbang_ReceiveByte_gotStartBit
|
||||||
|
Utils_WaitNanoSecs 1000, 0, r22 ; wait for 1us
|
||||||
|
dec r17
|
||||||
|
brne uartBitbang_ReceiveByte_loopStartBit2
|
||||||
|
dec r16
|
||||||
|
brne uartBitbang_ReceiveByte_loopStartBit1
|
||||||
|
rjmp uartBitbang_ReceiveByte_error
|
||||||
|
uartBitbang_ReceiveByte_gotStartBit:
|
||||||
|
Utils_WaitNanoSecs COM_HALFBIT_LENGTH, 0, r22 ; goto middle of startbit to maximize sync stability (4)
|
||||||
uartBitbang_ReceiveByte_loop:
|
uartBitbang_ReceiveByte_loop:
|
||||||
Utils_WaitNanoSecs COM_BIT_LENGTH, 8, r22 ; 8 cycles used in the complete loop between waits
|
Utils_WaitNanoSecs COM_BIT_LENGTH, 8, r22 ; 8 cycles used in the complete loop between waits
|
||||||
sec ; +1
|
sec ; +1
|
||||||
sbic COM_DATA_INPUT, COM_DATA_PIN ; LOW: +2, HIGH: +1
|
sbic COM_DATA_INPUT, COM_DATA_PIN ; LOW: +2, HIGH: +1
|
||||||
rjmp uartBitbang_ReceiveByte_shiftIn ; HIGH: +2, rjmp, use set CFLAG
|
rjmp uartBitbang_ReceiveByte_shiftIn ; HIGH: +2, rjmp, use set CFLAG
|
||||||
clc ; LOW: +1
|
clc ; LOW: +1
|
||||||
uartBitbang_ReceiveByte_shiftIn:
|
uartBitbang_ReceiveByte_shiftIn:
|
||||||
ror r20 ; +1
|
ror r20 ; +1
|
||||||
dec r21 ; +1
|
dec r21 ; +1
|
||||||
brne uartBitbang_ReceiveByte_loop ; +2, sum per loop: 8 cycles
|
brne uartBitbang_ReceiveByte_loop ; +2, sum per loop: 8 cycles
|
||||||
rcall uartBitbang_WaitForDataHigh ; wait for start of stopbit
|
rcall uartBitbang_WaitForDataHigh ; wait for start of stopbit
|
||||||
brcc uartBitbang_ReceiveByte_error
|
brcc uartBitbang_ReceiveByte_error
|
||||||
mov r16, r20
|
mov r16, r20
|
||||||
sec
|
sec
|
||||||
@@ -204,50 +211,6 @@ uartBitbang_WaitForDataHigh:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; @routine uartBitbang_WaitForAttnHigh
|
|
||||||
;
|
|
||||||
; Wait up to 1ms for data pin to become high
|
|
||||||
; @return CFLAG set if okay, clear otherwise
|
|
||||||
; @clobbers R17, R22
|
|
||||||
|
|
||||||
uartBitbang_WaitForAttnHigh:
|
|
||||||
cbi COM_ATTN_DDR, COM_ATTN_PIN ; set ATTN port as input
|
|
||||||
cbi COM_ATTN_OUTPUT, COM_ATTN_PIN ; disable internal pullup for ATTN
|
|
||||||
UART_BB_M_WAIT_FOR_PIN_HIGH COM_ATTN_INPUT, COM_ATTN_PIN
|
|
||||||
ret
|
|
||||||
; @end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; @routine uartBitbang_AcquireBus
|
|
||||||
;
|
|
||||||
; Reserve bus if free (otherwise return error)
|
|
||||||
; Expects interrupts to be disabled.
|
|
||||||
;
|
|
||||||
; @return CFLAG set if okay (bus acquired), cleared on error
|
|
||||||
; @clobbers: none
|
|
||||||
|
|
||||||
uartBitbang_AcquireBus:
|
|
||||||
; check for ATTN line: busy?
|
|
||||||
cbi COM_ATTN_DDR, COM_ATTN_PIN ; set ATTN as input
|
|
||||||
cbi COM_ATTN_OUTPUT, COM_ATTN_PIN ; disable pullup on ATTN
|
|
||||||
nop ; needed to sample current input
|
|
||||||
sbis COM_ATTN_INPUT, COM_ATTN_PIN ; ATTN low?
|
|
||||||
rjmp uartBitbang_AcquireBus_busy ; jump if it is
|
|
||||||
sbi COM_ATTN_DDR, COM_ATTN_PIN ; set ATTN as output
|
|
||||||
cbi COM_ATTN_OUTPUT, COM_ATTN_PIN ; set ATTN low
|
|
||||||
sec
|
|
||||||
ret
|
|
||||||
uartBitbang_AcquireBus_busy:
|
|
||||||
clc
|
|
||||||
ret
|
|
||||||
; @end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; @routine uartBitbang_WaitForOneBitLength
|
; @routine uartBitbang_WaitForOneBitLength
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -20,6 +20,35 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; macros
|
||||||
|
|
||||||
|
|
||||||
|
.macro mUartBitbangSetupInt0
|
||||||
|
inr r16, MCUCR
|
||||||
|
cbr r16, (1<<ISC01) | (1<<ISC00)
|
||||||
|
sbr r16, (1<<ISC01) | (0<<ISC00) ; falling edge of ATTN
|
||||||
|
outr MCUCR, r16
|
||||||
|
; sbr r16, (0<<ISC01) | (0<<ISC00) ; low level triggers
|
||||||
|
inr r16, COM_IRQ_ADDR_ATTN ; enable irq for ATTN line
|
||||||
|
sbr r16, (1<<COM_IRQ_BIT_ATTN)
|
||||||
|
outr COM_IRQ_ADDR_ATTN, r16
|
||||||
|
.endmacro
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.macro mUartBitbangSetupPci
|
||||||
|
sbi COM_IRQ_ADDR_ATTN, COM_IRQ_BIT_ATTN ; enable pin change irq for ATTN line
|
||||||
|
in r16, GIMSK ; enable pin change irq PCIE0 or PCIE1
|
||||||
|
ori r16, (1<<COM_IRQ_GIMSK_ATTN)
|
||||||
|
out GIMSK, R16
|
||||||
|
ldi r16, (1<<COM_IRQ_GIFR_ATTN) ; clear pending irq by writing 1 to ATTN bit
|
||||||
|
out GIFR, r16
|
||||||
|
.endmacro
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
; data
|
; data
|
||||||
|
|
||||||
@@ -49,12 +78,30 @@ UART_BitBang_Init:
|
|||||||
rcall NET_Interface_Init ; (R16, R17, X)
|
rcall NET_Interface_Init ; (R16, R17, X)
|
||||||
|
|
||||||
; init hw
|
; init hw
|
||||||
|
cbi COM_DATA_DDR, COM_DATA_PIN ; set TXD port as input
|
||||||
|
cbi COM_DATA_OUTPUT, COM_DATA_PIN ; disable internal pullup for DATA
|
||||||
|
cbi COM_ATTN_DDR, COM_ATTN_PIN ; set ATTN port as input
|
||||||
|
cbi COM_ATTN_OUTPUT, COM_ATTN_PIN ; disable internal pullup for ATTN
|
||||||
|
|
||||||
|
; enable IRQ
|
||||||
|
.ifdef INT0
|
||||||
|
.if COM_IRQ_BIT_ATTN == INT0
|
||||||
|
mUartBitbangSetupInt0
|
||||||
|
.else
|
||||||
|
mUartBitbangSetupPci
|
||||||
|
.endif
|
||||||
|
.else
|
||||||
|
mUartBitbangSetupPci
|
||||||
|
.endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
sbi COM_IRQ_ADDR_ATTN, COM_IRQ_BIT_ATTN ; enable pin change irq for ATTN line
|
sbi COM_IRQ_ADDR_ATTN, COM_IRQ_BIT_ATTN ; enable pin change irq for ATTN line
|
||||||
in r16, GIMSK ; enable pin change irq PCIE0 or PCIE1
|
in r16, GIMSK ; enable pin change irq PCIE0 or PCIE1
|
||||||
ori r16, (1<<COM_IRQ_GIMSK_ATTN)
|
ori r16, (1<<COM_IRQ_GIMSK_ATTN)
|
||||||
out GIMSK, R16
|
out GIMSK, R16
|
||||||
ldi r16, (1<<COM_IRQ_GIFR_ATTN) ; clear pending irq by writing 1 to ATTN bit
|
ldi r16, (1<<COM_IRQ_GIFR_ATTN) ; clear pending irq by writing 1 to ATTN bit
|
||||||
out GIFR, r16
|
out GIFR, r16
|
||||||
|
#endif
|
||||||
|
|
||||||
sec
|
sec
|
||||||
ret
|
ret
|
||||||
@@ -72,6 +119,7 @@ UART_BitBang_Fini:
|
|||||||
cbi COM_DATA_DDR, COM_DATA_PIN ; set TXD port as input
|
cbi COM_DATA_DDR, COM_DATA_PIN ; set TXD port as input
|
||||||
cbi COM_ATTN_DDR, COM_ATTN_PIN ; set ATTN port as input
|
cbi COM_ATTN_DDR, COM_ATTN_PIN ; set ATTN port as input
|
||||||
|
|
||||||
|
#if 0
|
||||||
cbi COM_IRQ_ADDR_ATTN, COM_IRQ_BIT_ATTN ; disable pin change irq for ATTN line
|
cbi COM_IRQ_ADDR_ATTN, COM_IRQ_BIT_ATTN ; disable pin change irq for ATTN line
|
||||||
in r16, GIMSK ; enable pin change irq PCIE0 or PCIE1
|
in r16, GIMSK ; enable pin change irq PCIE0 or PCIE1
|
||||||
andi r16, ~(1<<COM_IRQ_GIMSK_ATTN)
|
andi r16, ~(1<<COM_IRQ_GIMSK_ATTN)
|
||||||
@@ -79,6 +127,8 @@ UART_BitBang_Fini:
|
|||||||
|
|
||||||
ldi r16, (1<<COM_IRQ_GIFR_ATTN) ; clear pending irq by writing 1 to ATTN bit
|
ldi r16, (1<<COM_IRQ_GIFR_ATTN) ; clear pending irq by writing 1 to ATTN bit
|
||||||
out GIFR, r16
|
out GIFR, r16
|
||||||
|
#endif
|
||||||
|
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
@@ -123,16 +173,12 @@ uartBitBang_sendNextPkg:
|
|||||||
rcall NET_Buffer_Locate ; get pointer to buffer (R17)
|
rcall NET_Buffer_Locate ; get pointer to buffer (R17)
|
||||||
brcc uartBitBang_sendNextPkg_end
|
brcc uartBitBang_sendNextPkg_end
|
||||||
adiw xh:xl, 1 ; skip buffer header
|
adiw xh:xl, 1 ; skip buffer header
|
||||||
rcall uartBitbang_SendMsg ; (R16, R17, R21, R22, X)
|
rcall uartBitbang_SendMsg ; (R16, R17, R21, R22, R24, R25, X)
|
||||||
brcc uartBitBang_sendNextPkg_error
|
brcc uartBitBang_sendNextPkg_end
|
||||||
rcall NET_Interface_GetNextOutgoingMsgNum ; remove from stack (R17, R18, X)
|
rcall NET_Interface_GetNextOutgoingMsgNum ; remove from stack (R17, R18, X)
|
||||||
rcall NET_Buffer_ReleaseByNum ; release buffer (R16, X)
|
rcall NET_Buffer_ReleaseByNum ; release buffer (R16, X)
|
||||||
ldi r16, NET_IFACE_OFFS_PACKETSOUT_LOW
|
|
||||||
rcall NET_Interface_IncCounter16 ; (R24, R25)
|
|
||||||
sec
|
sec
|
||||||
rjmp uartBitBang_sendNextPkg_end
|
rjmp uartBitBang_sendNextPkg_end
|
||||||
uartBitBang_sendNextPkg_error:
|
|
||||||
rcall NET_Interface_IncCounter16 ; (R24, R25)
|
|
||||||
uartBitBang_sendNextPkg_end:
|
uartBitBang_sendNextPkg_end:
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ uartBitbang_RawReceiveMsg:
|
|||||||
breq uartBitbang_RawReceiveMsg_forMe
|
breq uartBitbang_RawReceiveMsg_forMe
|
||||||
cpi r16, 0xff
|
cpi r16, 0xff
|
||||||
breq uartBitbang_RawReceiveMsg_forMe
|
breq uartBitbang_RawReceiveMsg_forMe
|
||||||
clr r16
|
clr r16 ; not for me
|
||||||
rjmp uartBitbang_RawReceiveMsg_clcRet
|
rjmp uartBitbang_RawReceiveMsg_clcRet
|
||||||
uartBitbang_RawReceiveMsg_forMe:
|
uartBitbang_RawReceiveMsg_forMe:
|
||||||
subi r19, 1
|
subi r19, 1
|
||||||
@@ -87,10 +87,10 @@ uartBitbang_RawReceiveMsg_forMe:
|
|||||||
; read size of msg payload (e.g. number of msg bytes following minus CRC byte)
|
; read size of msg payload (e.g. number of msg bytes following minus CRC byte)
|
||||||
rcall uartBitbang_ReceiveByte ; read byte (R16, R17, R20, R21, R22)
|
rcall uartBitbang_ReceiveByte ; read byte (R16, R17, R20, R21, R22)
|
||||||
brcc uartBitbang_RawReceiveMsg_eIo
|
brcc uartBitbang_RawReceiveMsg_eIo
|
||||||
inc r16 ; account for crc byte
|
|
||||||
subi r19, 1
|
subi r19, 1
|
||||||
brcs uartBitbang_RawReceiveMsg_eBadSize
|
brcs uartBitbang_RawReceiveMsg_eBadSize
|
||||||
st X+, r16 ; store msg payload size
|
st X+, r16 ; store msg payload size
|
||||||
|
inc r16 ; account for crc byte
|
||||||
sub r19, r16 ; check msg size against remaining buffer size
|
sub r19, r16 ; check msg size against remaining buffer size
|
||||||
brcs uartBitbang_RawReceiveMsg_eBadSize
|
brcs uartBitbang_RawReceiveMsg_eBadSize
|
||||||
mov r19, r16
|
mov r19, r16
|
||||||
@@ -128,16 +128,38 @@ uartBitbang_RawReceiveMsg_end:
|
|||||||
; @param X ptr to buffer to send
|
; @param X ptr to buffer to send
|
||||||
; @return CFLAGS set if okay, cleared otherwise (index of error variable in R16)
|
; @return CFLAGS set if okay, cleared otherwise (index of error variable in R16)
|
||||||
; @return R16 index of error variable (if CFLAGS cleared)
|
; @return R16 index of error variable (if CFLAGS cleared)
|
||||||
; @clobbers R16, R22 (R17, R21, X)
|
; @clobbers R16 (R17, R21, R22, R24, R25, X)
|
||||||
|
|
||||||
uartBitbang_SendMsg:
|
uartBitbang_SendMsg:
|
||||||
rcall uartBitbang_AcquireBus
|
rcall uartBitbang_AcquireBus
|
||||||
brcc uartBitbang_SendMsg_lineBusyError
|
brcc uartBitbang_SendMsg_lineBusyError
|
||||||
|
|
||||||
rcall uartBitbang_WaitForOneBitLength ; wait for one bit duration (R22)
|
|
||||||
rcall uartBitbang_WaitForOneBitLength ; wait for one bit duration (R22)
|
rcall uartBitbang_WaitForOneBitLength ; wait for one bit duration (R22)
|
||||||
rcall uartBitbang_WaitForOneBitLength ; wait for one bit duration (R22)
|
rcall uartBitbang_WaitForOneBitLength ; wait for one bit duration (R22)
|
||||||
|
|
||||||
|
rcall uartBitbang_RawSendMsg ; (R16, R17, R21, R22, R24, R25, X)
|
||||||
|
cbi COM_ATTN_DDR, COM_ATTN_PIN ; release ATTN line (by setting direction to IN)
|
||||||
|
ret
|
||||||
|
uartBitbang_SendMsg_lineBusyError:
|
||||||
|
ldi r16, NET_IFACE_OFFS_ERR_BUSY_LOW
|
||||||
|
rcall NET_Interface_IncCounter16 ; (R24, R25)
|
||||||
|
clc
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine uartBitbang_RawSendMsg
|
||||||
|
;
|
||||||
|
; Send packet over wire.
|
||||||
|
;
|
||||||
|
; @param X ptr to buffer to send
|
||||||
|
; @return CFLAGS set if okay, cleared otherwise (index of error variable in R16)
|
||||||
|
; @return R16 index of error variable (if CFLAGS cleared)
|
||||||
|
; @clobbers R16, R17 (R21, R22, R24, R25, X)
|
||||||
|
|
||||||
|
uartBitbang_RawSendMsg:
|
||||||
adiw xh:xl, NETMSG_OFFS_MSGLEN
|
adiw xh:xl, NETMSG_OFFS_MSGLEN
|
||||||
ld r17, X
|
ld r17, X
|
||||||
sbiw xh:xl, NETMSG_OFFS_MSGLEN
|
sbiw xh:xl, NETMSG_OFFS_MSGLEN
|
||||||
@@ -145,25 +167,68 @@ uartBitbang_SendMsg:
|
|||||||
inc r17 ; account for msglen byte
|
inc r17 ; account for msglen byte
|
||||||
inc r17 ; account for crc byte
|
inc r17 ; account for crc byte
|
||||||
|
|
||||||
uartBitbang_SendMsg_loop:
|
uartBitbang_RawSendMsg_loop:
|
||||||
rcall uartBitbang_WaitForOneBitLength ; wait for one bit duration (R22)
|
rcall uartBitbang_WaitForOneBitLength ; wait for one bit duration (R22)
|
||||||
|
|
||||||
ld r16, X+
|
ld r16, X+
|
||||||
rcall uartBitbang_SendByte ; send byte (R16, R21, R22)
|
rcall uartBitbang_SendByte ; send byte (R16, R21, R22)
|
||||||
brcc uartBitbang_SendMsg_releaseBusRet
|
brcc uartBitbang_RawSendMsg_ioError
|
||||||
dec r17
|
dec r17
|
||||||
brne uartBitbang_SendMsg_loop
|
brne uartBitbang_RawSendMsg_loop
|
||||||
|
ldi r16, NET_IFACE_OFFS_PACKETSOUT_LOW
|
||||||
|
rcall NET_Interface_IncCounter16 ; (R24, R25)
|
||||||
sec
|
sec
|
||||||
uartBitbang_SendMsg_releaseBusRet:
|
|
||||||
cbi COM_ATTN_DDR, COM_ATTN_PIN ; release ATTN line (by setting direction to IN)
|
|
||||||
brcc uartBitbang_SendMsg_ioError
|
|
||||||
; packet successfully sent
|
|
||||||
ret
|
ret
|
||||||
uartBitbang_SendMsg_ioError:
|
uartBitbang_RawSendMsg_ioError:
|
||||||
ldi r16, NET_IFACE_OFFS_ERR_COLLISIONS_LOW
|
ldi r16, NET_IFACE_OFFS_ERR_COLLISIONS_LOW
|
||||||
|
rcall NET_Interface_IncCounter16 ; (R24, R25)
|
||||||
|
clc
|
||||||
ret
|
ret
|
||||||
uartBitbang_SendMsg_lineBusyError:
|
; @end
|
||||||
ldi r16, NET_IFACE_OFFS_ERR_BUSY_LOW
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine uartBitbang_WaitForAttnHigh
|
||||||
|
;
|
||||||
|
; Wait up to 1ms for data pin to become high
|
||||||
|
; @return CFLAG set if okay, clear otherwise
|
||||||
|
; @clobbers R17, R22
|
||||||
|
|
||||||
|
uartBitbang_WaitForAttnHigh:
|
||||||
|
cbi COM_ATTN_DDR, COM_ATTN_PIN ; set ATTN port as input
|
||||||
|
cbi COM_ATTN_OUTPUT, COM_ATTN_PIN ; disable internal pullup for ATTN
|
||||||
|
UART_BB_M_WAIT_FOR_PIN_HIGH COM_ATTN_INPUT, COM_ATTN_PIN
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine uartBitbang_AcquireBus
|
||||||
|
;
|
||||||
|
; Reserve bus if free (otherwise return error)
|
||||||
|
; Expects interrupts to be disabled.
|
||||||
|
;
|
||||||
|
; @return CFLAG set if okay (bus acquired), cleared on error
|
||||||
|
; @clobbers: none
|
||||||
|
|
||||||
|
uartBitbang_AcquireBus:
|
||||||
|
; check for ATTN line: busy?
|
||||||
|
cbi COM_ATTN_DDR, COM_ATTN_PIN ; set ATTN as input
|
||||||
|
cbi COM_ATTN_OUTPUT, COM_ATTN_PIN ; disable pullup on ATTN
|
||||||
|
nop ; needed to sample current input
|
||||||
|
sbis COM_ATTN_INPUT, COM_ATTN_PIN ; ATTN low?
|
||||||
|
rjmp uartBitbang_AcquireBus_busy ; jump if it is
|
||||||
|
sbi COM_ATTN_DDR, COM_ATTN_PIN ; set ATTN as output
|
||||||
|
cbi COM_ATTN_OUTPUT, COM_ATTN_PIN ; set ATTN low
|
||||||
|
sec
|
||||||
|
ret
|
||||||
|
uartBitbang_AcquireBus_busy:
|
||||||
|
clc
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
|
|||||||
@@ -305,7 +305,8 @@ l_overrun_%:
|
|||||||
ldi r16, NET_IFACE_OFFS_ERR_MISSED_LOW
|
ldi r16, NET_IFACE_OFFS_ERR_MISSED_LOW
|
||||||
l_incCounterAndEnterSkipping_%:
|
l_incCounterAndEnterSkipping_%:
|
||||||
ldi r17, UART_HW_READMODE_SKIPPING
|
ldi r17, UART_HW_READMODE_SKIPPING
|
||||||
ldi r16, NET_IFACE_OFFS_HANDLED_LOW
|
std Y+UART_HW_IFACE_OFFS_READMODE, r17 ; set read mode
|
||||||
|
rjmp l_end_%
|
||||||
l_incCounterAndEnterMode_%:
|
l_incCounterAndEnterMode_%:
|
||||||
rcall NET_Interface_IncCounter16 ; (R24, R25)
|
rcall NET_Interface_IncCounter16 ; (R24, R25)
|
||||||
std Y+UART_HW_IFACE_OFFS_READMODE, r17 ; set read mode
|
std Y+UART_HW_IFACE_OFFS_READMODE, r17 ; set read mode
|
||||||
|
|||||||
@@ -11,5 +11,5 @@
|
|||||||
|
|
||||||
.equ FIRMWARE_VERSION_MAJOR = 1
|
.equ FIRMWARE_VERSION_MAJOR = 1
|
||||||
.equ FIRMWARE_VERSION_MINOR = 0
|
.equ FIRMWARE_VERSION_MINOR = 0
|
||||||
.equ FIRMWARE_VERSION_PATCHLEVEL = 0
|
.equ FIRMWARE_VERSION_PATCHLEVEL = 2
|
||||||
|
|
||||||
|
|||||||
16
flashnode.sh
16
flashnode.sh
@@ -16,6 +16,13 @@ case $NODE in
|
|||||||
LFUSE_ARG="-U lfuse:w:0xE4:m"
|
LFUSE_ARG="-U lfuse:w:0xE4:m"
|
||||||
FILE_ARG="-U flash:w:./0-build/avr/devices/c01/boot/c01_boot.hex"
|
FILE_ARG="-U flash:w:./0-build/avr/devices/c01/boot/c01_boot.hex"
|
||||||
;;
|
;;
|
||||||
|
c02)
|
||||||
|
DEVICE_ARG="-p m644p"
|
||||||
|
HFUSE_ARG="-U hfuse:w:0xD5:m"
|
||||||
|
LFUSE_ARG="-U lfuse:w:0xE2:m"
|
||||||
|
EFUSE_ARG="-U efuse:w:0xFF:m"
|
||||||
|
FILE_ARG="-U flash:w:./0-build/avr/devices/c02/boot/c02_boot.hex"
|
||||||
|
;;
|
||||||
n16)
|
n16)
|
||||||
DEVICE_ARG="-p t84"
|
DEVICE_ARG="-p t84"
|
||||||
HFUSE_ARG="-U hfuse:w:0xD7:m"
|
HFUSE_ARG="-U hfuse:w:0xD7:m"
|
||||||
@@ -56,7 +63,14 @@ case $NODE in
|
|||||||
HFUSE_ARG="-U hfuse:w:0xD7:m"
|
HFUSE_ARG="-U hfuse:w:0xD7:m"
|
||||||
LFUSE_ARG=""
|
LFUSE_ARG=""
|
||||||
EFUSE_ARG="-U efuse:w:0xFE:m"
|
EFUSE_ARG="-U efuse:w:0xFE:m"
|
||||||
FILE_ARG="-U flash:w:./0-build/avr/devices/n23/boot/n23_boot.hex"
|
FILE_ARG="-U flash:w:./0-build/avr/devices/n24/boot/n24_boot.hex"
|
||||||
|
;;
|
||||||
|
n25)
|
||||||
|
DEVICE_ARG="-p t84"
|
||||||
|
HFUSE_ARG="-U hfuse:w:0xD7:m"
|
||||||
|
LFUSE_ARG=""
|
||||||
|
EFUSE_ARG="-U efuse:w:0xFE:m"
|
||||||
|
FILE_ARG="-U flash:w:./0-build/avr/devices/n25/boot/n25_boot.hex"
|
||||||
;;
|
;;
|
||||||
t03)
|
t03)
|
||||||
DEVICE_ARG="-p t841"
|
DEVICE_ARG="-p t841"
|
||||||
|
|||||||
Reference in New Issue
Block a user