Compare commits
38 Commits
mp-2025_05
...
mp-2025_05
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b8cb929b7 | ||
|
|
f1c858e3a7 | ||
|
|
3fc7eff424 | ||
|
|
36050b14c5 | ||
|
|
fa6acd8e52 | ||
|
|
dbf7f76baa | ||
|
|
18be337160 | ||
|
|
0bd6ef8db4 | ||
|
|
7fb1722c70 | ||
|
|
279d92e338 | ||
|
|
a26dd6f2a5 | ||
|
|
785e4ef28c | ||
|
|
dff347bcb7 | ||
|
|
619ac1564e | ||
|
|
581eeff996 | ||
|
|
b4e747c3db | ||
|
|
04dec73988 | ||
|
|
af75532ba7 | ||
|
|
335163f887 | ||
|
|
b3274466a3 | ||
|
|
064e84f5e8 | ||
|
|
18bc231951 | ||
|
|
9a19bf739d | ||
|
|
9e6feecb88 | ||
|
|
baf77ed182 | ||
|
|
b2f7232422 | ||
|
|
961568f721 | ||
|
|
042db13994 | ||
|
|
ba434d88a2 | ||
|
|
d32e2f4b81 | ||
|
|
e40139fee2 | ||
|
|
d8612a01ca | ||
|
|
474e63c395 | ||
|
|
ceaeb756fb | ||
|
|
603a8e93d0 | ||
|
|
4fdfd77a54 | ||
|
|
6b5f5e877d | ||
|
|
77bb64fbb6 |
@@ -117,6 +117,26 @@ void _handleMsgValue(AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg)
|
|||||||
if (ni==NULL) {
|
if (ni==NULL) {
|
||||||
DBG_INFO(AQH_LOGDOMAIN, "Error handling message");
|
DBG_INFO(AQH_LOGDOMAIN, "Error handling message");
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
uint8_t valueId;
|
||||||
|
uint16_t val;
|
||||||
|
|
||||||
|
val=AQH_ValueMessage_GetValueNom(msg);
|
||||||
|
valueId=AQH_ValueMessage_GetValueId(msg);
|
||||||
|
|
||||||
|
switch(valueId) {
|
||||||
|
case AQH_ENDPOINT_VID_STATS_PACKETS_IN: AQH_NodeInfo_SetStatsPacketsIn(ni, val); AQH_NodeDb_SetModified(xo->nodeDb); break;
|
||||||
|
case AQH_ENDPOINT_VID_STATS_PACKETS_OUT: AQH_NodeInfo_SetStatsPacketsOut(ni, val); AQH_NodeDb_SetModified(xo->nodeDb); break;
|
||||||
|
case AQH_ENDPOINT_VID_STATS_ERRS_CONTENT: AQH_NodeInfo_SetStatsCrcErrors(ni, val); AQH_NodeDb_SetModified(xo->nodeDb); break;
|
||||||
|
case AQH_ENDPOINT_VID_STATS_ERRS_IO: AQH_NodeInfo_SetStatsIoErrors(ni, val); AQH_NodeDb_SetModified(xo->nodeDb); break;
|
||||||
|
case AQH_ENDPOINT_VID_STATS_ERRS_NOBUF: break;
|
||||||
|
case AQH_ENDPOINT_VID_STATS_ERRS_COLLISIONS: AQH_NodeInfo_SetStatsCollisions(ni, val); AQH_NodeDb_SetModified(xo->nodeDb); break;
|
||||||
|
case AQH_ENDPOINT_VID_STATS_ERRS_BUSY: AQH_NodeInfo_SetStatsBusy(ni, val); AQH_NodeDb_SetModified(xo->nodeDb); break;
|
||||||
|
case AQH_ENDPOINT_VID_STATS_HEAP_USED: break;
|
||||||
|
case AQH_ENDPOINT_VID_STATS_HEAP_FREE: break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -145,11 +165,13 @@ void _handleMsgComSendStat(AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg)
|
|||||||
if (ni==NULL) {
|
if (ni==NULL) {
|
||||||
DBG_INFO(AQH_LOGDOMAIN, "Error handling message");
|
DBG_INFO(AQH_LOGDOMAIN, "Error handling message");
|
||||||
}
|
}
|
||||||
AQH_NodeInfo_SetStatsPacketsOut(ni, AQH_SendStatsMessage_GetPacketsOut(msg));
|
else {
|
||||||
AQH_NodeInfo_SetStatsCollisions(ni, AQH_SendStatsMessage_GetCollisions(msg));
|
AQH_NodeInfo_SetStatsPacketsOut(ni, AQH_SendStatsMessage_GetPacketsOut(msg));
|
||||||
AQH_NodeInfo_SetStatsBusy(ni, AQH_SendStatsMessage_GetBusyErrors(msg));
|
AQH_NodeInfo_SetStatsCollisions(ni, AQH_SendStatsMessage_GetCollisions(msg));
|
||||||
AQH_NodeDb_SetModified(xo->nodeDb);
|
AQH_NodeInfo_SetStatsBusy(ni, AQH_SendStatsMessage_GetBusyErrors(msg));
|
||||||
_updateTimestampLastChange(ni);
|
AQH_NodeDb_SetModified(xo->nodeDb);
|
||||||
|
_updateTimestampLastChange(ni);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,18 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define AQH_ENDPOINT_VID_STATS_PACKETS_IN 0xe0
|
||||||
|
#define AQH_ENDPOINT_VID_STATS_PACKETS_OUT 0xe1
|
||||||
|
#define AQH_ENDPOINT_VID_STATS_ERRS_CONTENT 0xe2
|
||||||
|
#define AQH_ENDPOINT_VID_STATS_ERRS_IO 0xe3
|
||||||
|
#define AQH_ENDPOINT_VID_STATS_ERRS_NOBUF 0xe4
|
||||||
|
#define AQH_ENDPOINT_VID_STATS_ERRS_COLLISIONS 0xe5
|
||||||
|
#define AQH_ENDPOINT_VID_STATS_ERRS_BUSY 0xe6
|
||||||
|
#define AQH_ENDPOINT_VID_STATS_HEAP_USED 0xe7
|
||||||
|
#define AQH_ENDPOINT_VID_STATS_HEAP_FREE 0xe8
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AQH_OBJECT *AQH_NodeServer_new(AQH_EVENT_LOOP *eventLoop);
|
AQH_OBJECT *AQH_NodeServer_new(AQH_EVENT_LOOP *eventLoop);
|
||||||
int AQH_NodeServer_Init(AQH_OBJECT *o, int argc, char **argv);
|
int AQH_NodeServer_Init(AQH_OBJECT *o, int argc, char **argv);
|
||||||
void AQH_NodeServer_Fini(AQH_OBJECT *o);
|
void AQH_NodeServer_Fini(AQH_OBJECT *o);
|
||||||
|
|||||||
@@ -170,7 +170,13 @@ void _printNode(const AQH_NODE_INFO *ni, int printAll)
|
|||||||
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);
|
||||||
if (ts)
|
if (ts)
|
||||||
fprintf(stdout, "last seen %s, ", GWEN_Timestamp_GetString(ts));
|
fprintf(stdout, "last seen %04d/%02d/%02d-%02d:%02d:%02d, ",
|
||||||
|
GWEN_Timestamp_GetYear(ts),
|
||||||
|
GWEN_Timestamp_GetMonth(ts),
|
||||||
|
GWEN_Timestamp_GetDay(ts),
|
||||||
|
GWEN_Timestamp_GetHour(ts),
|
||||||
|
GWEN_Timestamp_GetMinute(ts),
|
||||||
|
GWEN_Timestamp_GetSecond(ts));
|
||||||
fprintf(stdout, "pkg out: %d, pkg in: %d, collisions: %d, busy: %d, crc: %d, io: %d\n",
|
fprintf(stdout, "pkg out: %d, pkg in: %d, collisions: %d, busy: %d, crc: %d, io: %d\n",
|
||||||
AQH_NodeInfo_GetStatsPacketsOut(ni),
|
AQH_NodeInfo_GetStatsPacketsOut(ni),
|
||||||
AQH_NodeInfo_GetStatsPacketsIn(ni),
|
AQH_NodeInfo_GetStatsPacketsIn(ni),
|
||||||
|
|||||||
@@ -261,6 +261,12 @@ int AQH_ValueModality_fromString(const char *s)
|
|||||||
return AQH_ValueModality_RGBW;
|
return AQH_ValueModality_RGBW;
|
||||||
else if (strcasecmp(s, "motion")==0)
|
else if (strcasecmp(s, "motion")==0)
|
||||||
return AQH_ValueModality_Motion;
|
return AQH_ValueModality_Motion;
|
||||||
|
else if (strcasecmp(s, "co2")==0)
|
||||||
|
return AQH_ValueModality_Co2;
|
||||||
|
else if (strcasecmp(s, "tvoc")==0)
|
||||||
|
return AQH_ValueModality_TVOC;
|
||||||
|
else if (strcasecmp(s, "stats")==0)
|
||||||
|
return AQH_ValueModality_Stats;
|
||||||
}
|
}
|
||||||
return AQH_ValueModality_Unknown;
|
return AQH_ValueModality_Unknown;
|
||||||
}
|
}
|
||||||
@@ -276,6 +282,9 @@ const char *AQH_ValueModality_toString(int i)
|
|||||||
case AQH_ValueModality_RGB: return "rgb";
|
case AQH_ValueModality_RGB: return "rgb";
|
||||||
case AQH_ValueModality_RGBW: return "rgbw";
|
case AQH_ValueModality_RGBW: return "rgbw";
|
||||||
case AQH_ValueModality_Motion: return "motion";
|
case AQH_ValueModality_Motion: return "motion";
|
||||||
|
case AQH_ValueModality_Co2: return "co2";
|
||||||
|
case AQH_ValueModality_TVOC: return "tvoc";
|
||||||
|
case AQH_ValueModality_Stats: return "stats";
|
||||||
case AQH_ValueModality_Unknown:
|
case AQH_ValueModality_Unknown:
|
||||||
default: return "unknown";
|
default: return "unknown";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,10 @@ enum {
|
|||||||
AQH_ValueModality_Door,
|
AQH_ValueModality_Door,
|
||||||
AQH_ValueModality_RGB,
|
AQH_ValueModality_RGB,
|
||||||
AQH_ValueModality_RGBW,
|
AQH_ValueModality_RGBW,
|
||||||
AQH_ValueModality_Motion
|
AQH_ValueModality_Motion,
|
||||||
|
AQH_ValueModality_Co2,
|
||||||
|
AQH_ValueModality_TVOC,
|
||||||
|
AQH_ValueModality_Stats
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,36 +21,36 @@ This app can watch for up to two node-value pairs.
|
|||||||
----------------
|
----------------
|
||||||
|
|
||||||
RGB Value for activated light:
|
RGB Value for activated light:
|
||||||
aqhome-tool setValue -N nodes/XXXXXXXX/MALRGBWVALUE -v GRWB
|
aqhome-tool setdata -N nodes/XXXXXXXX/MALRGBWVALUE -v GRWB
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
Set color of LED strip to blue (half intensity)
|
Set color of LED strip to blue (half intensity)
|
||||||
aqhome-tool setValue -N nodes/12345678/MALRGBWVALUE -v 0x80
|
aqhome-tool setdata -N nodes/12345678/MALRGBWVALUE -v 0x80
|
||||||
|
|
||||||
|
|
||||||
1.2 MALONTIME
|
1.2 MALONTIME
|
||||||
-------------
|
-------------
|
||||||
On-Time after activation:
|
On-Time after activation:
|
||||||
aqhome-tool setValue -N nodes/XXXXXXXX/MALONTIME TIME_IN_1/10_SECS
|
aqhome-tool setdata -N nodes/XXXXXXXX/MALONTIME TIME_IN_1/10_SECS
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
Keep light on after activation for 20 seconds
|
Keep light on after activation for 20 seconds
|
||||||
aqhome-tool setValue -N nodes/12345678/MALONTIME -v 200
|
aqhome-tool setdata -N nodes/12345678/MALONTIME -v 200
|
||||||
|
|
||||||
|
|
||||||
1.3. MALSOURCE1, MALSOURCE2
|
1.3. MALSOURCE1, MALSOURCE2
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
Sources for Motion Messages:
|
Sources for Motion Messages:
|
||||||
aqhome-tool setValue -N nodes/XXXXXXXX/MALSOURCE1 -v VVNN
|
aqhome-tool setdata -N nodes/XXXXXXXX/MALSOURCE1 -v VVNN
|
||||||
aqhome-tool setValue -N nodes/XXXXXXXX/MALSOURCE2 -v VVNN
|
aqhome-tool setdata -N nodes/XXXXXXXX/MALSOURCE2 -v VVNN
|
||||||
|
|
||||||
VVNN is a 16-bit value, lower 8 bit contain the source node address, higher 8 bit contain the
|
VVNN is a 16-bit value, lower 8 bit contain the source node address, higher 8 bit contain the
|
||||||
value id to react to.
|
value id to react to.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
React to value report messages with value id 7 from node with address 2
|
React to value report messages with value id 7 from node with address 2
|
||||||
aqhome-tool setValue -N nodes/12345678/MALSOURCE1 -v 0x0702
|
aqhome-tool setdata -N nodes/12345678/MALSOURCE1 -v 0x0702
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -111,6 +111,8 @@ AppNetwork_HandleMsg:
|
|||||||
sbiw xh:xl, NETMSG_OFFS_CMD
|
sbiw xh:xl, NETMSG_OFFS_CMD
|
||||||
cpi r16, NETMSG_CMD_REBOOT_REQUEST
|
cpi r16, NETMSG_CMD_REBOOT_REQUEST
|
||||||
breq AppNetwork_HandleMsg_handleRebootMsg
|
breq AppNetwork_HandleMsg_handleRebootMsg
|
||||||
|
cpi r16, NETMSG_CMD_PING
|
||||||
|
breq AppNetwork_HandleMsg_handlePingMsg
|
||||||
cpi r16, NETMSG_CMD_NEED_ADDRESS
|
cpi r16, NETMSG_CMD_NEED_ADDRESS
|
||||||
brcs AppNetwork_HandleMsg_clcRet ; lower than "HAVE_NEED"
|
brcs AppNetwork_HandleMsg_clcRet ; lower than "HAVE_NEED"
|
||||||
cpi r16, NETMSG_CMD_ADDRESS_RANGE
|
cpi r16, NETMSG_CMD_ADDRESS_RANGE
|
||||||
@@ -138,6 +140,13 @@ AppNetwork_HandleMsg_handleRebootMsg:
|
|||||||
pop xh
|
pop xh
|
||||||
pop xl
|
pop xl
|
||||||
ret
|
ret
|
||||||
|
AppNetwork_HandleMsg_handlePingMsg:
|
||||||
|
push xl
|
||||||
|
push xh
|
||||||
|
rcall appNetworkHandlePingRequest
|
||||||
|
pop xh
|
||||||
|
pop xl
|
||||||
|
ret
|
||||||
AppNetwork_HandleMsg_clcRet:
|
AppNetwork_HandleMsg_clcRet:
|
||||||
clc
|
clc
|
||||||
ret
|
ret
|
||||||
@@ -162,6 +171,26 @@ appNetworkHandleRebootRequest_end:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
appNetworkHandlePingRequest:
|
||||||
|
adiw xh:xl, NETMSG_OFFS_SRCADDR
|
||||||
|
ld r17, X
|
||||||
|
push r17
|
||||||
|
rcall NET_Buffer_Alloc ; (R16, R17, X)
|
||||||
|
pop r17
|
||||||
|
brcc appNetworkHandlePingRequest_end ; jmp on error
|
||||||
|
push r16 ; buffer num
|
||||||
|
mov r16, r17 ; DEST addr
|
||||||
|
adiw xh:xl, 1
|
||||||
|
ldi yl, LOW(netInterfaceData)
|
||||||
|
ldi yh, HIGH(netInterfaceData)
|
||||||
|
rcall NETMSG_Pong_Write ; (R16, R17, R18, R19, R20, X)
|
||||||
|
sbiw xh:xl, 1
|
||||||
|
pop r16 ; buffer num
|
||||||
|
rcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X)
|
||||||
|
appNetworkHandlePingRequest_end:
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
appNetworkTimerTable:
|
appNetworkTimerTable:
|
||||||
rjmp appNetworkHandleStateInitialWait
|
rjmp appNetworkHandleStateInitialWait
|
||||||
@@ -233,7 +262,6 @@ appNetworkHandleStateUp:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; @routine appNetworkSendMsgNextState
|
; @routine appNetworkSendMsgNextState
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
; defines
|
; defines
|
||||||
|
|
||||||
.equ APP_STATS_INTERVAL_MINS = 10
|
.equ APP_STATS_INTERVAL_MINS = 11
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -53,6 +53,19 @@ AppStats_Fini:
|
|||||||
;
|
;
|
||||||
|
|
||||||
AppStats_OnEveryMinute:
|
AppStats_OnEveryMinute:
|
||||||
|
push r15
|
||||||
|
in r15, SREG
|
||||||
|
cli
|
||||||
|
rcall AppStats_OnEveryMinute_noIrq
|
||||||
|
out SREG, r15
|
||||||
|
pop r15
|
||||||
|
ret
|
||||||
|
|
||||||
|
AppStats_OnEveryMinute_noIrq:
|
||||||
|
ldi yl, LOW(netInterfaceData)
|
||||||
|
ldi yh, HIGH(netInterfaceData)
|
||||||
|
rcall AppNetwork_SendRxdStats ; debug
|
||||||
|
|
||||||
lds r16, appStatsTimer
|
lds r16, appStatsTimer
|
||||||
inc r16
|
inc r16
|
||||||
cpi r16, APP_STATS_INTERVAL_MINS
|
cpi r16, APP_STATS_INTERVAL_MINS
|
||||||
@@ -63,22 +76,93 @@ AppStats_OnEveryMinute_store:
|
|||||||
ldi yl, LOW(netInterfaceData)
|
ldi yl, LOW(netInterfaceData)
|
||||||
ldi yh, HIGH(netInterfaceData)
|
ldi yh, HIGH(netInterfaceData)
|
||||||
cpi r16, 1
|
cpi r16, 1
|
||||||
breq AppStats_OnEveryMinute_sendRxdStats
|
|
||||||
cpi r16, 2
|
|
||||||
breq AppStats_OnEveryMinute_sendTxdStats
|
|
||||||
cpi r16, 3
|
|
||||||
breq AppStats_OnEveryMinute_sendDevice
|
breq AppStats_OnEveryMinute_sendDevice
|
||||||
|
cpi r16, 2
|
||||||
|
breq AppStats_OnEveryMinute_sendPacketsIn
|
||||||
|
cpi r16, 3
|
||||||
|
breq AppStats_OnEveryMinute_sendPacketsOut
|
||||||
cpi r16, 4
|
cpi r16, 4
|
||||||
breq AppStats_OnEveryMinute_sendMemStats
|
breq AppStats_OnEveryMinute_sendContentErrs
|
||||||
ret
|
cpi r16, 5
|
||||||
AppStats_OnEveryMinute_sendTxdStats:
|
breq AppStats_OnEveryMinute_sendIoErrs
|
||||||
rjmp AppNetwork_SendTxdStats
|
cpi r16, 6
|
||||||
AppStats_OnEveryMinute_sendRxdStats:
|
breq AppStats_OnEveryMinute_sendNoBufErrs
|
||||||
rjmp AppNetwork_SendRxdStats
|
cpi r16, 7
|
||||||
AppStats_OnEveryMinute_sendMemStats:
|
breq AppStats_OnEveryMinute_sendCollisionErrs
|
||||||
rjmp AppNetwork_SendMemStats
|
cpi r16, 8
|
||||||
|
breq AppStats_OnEveryMinute_sendBusyErrs
|
||||||
|
#ifdef MODULES_HEAP
|
||||||
|
cpi r16, 9
|
||||||
|
breq AppStats_OnEveryMinute_sendHeapUsed
|
||||||
|
cpi r16, 10
|
||||||
|
breq AppStats_OnEveryMinute_sendHeapfree
|
||||||
|
#endif
|
||||||
|
|
||||||
AppStats_OnEveryMinute_sendDevice:
|
AppStats_OnEveryMinute_sendDevice:
|
||||||
rjmp AppNetwork_SendDevice
|
rjmp AppNetwork_SendDevice
|
||||||
|
|
||||||
|
AppStats_OnEveryMinute_sendPacketsIn:
|
||||||
|
ldi r17, AQHOME_VALUEID_STATS_PACKETS_IN
|
||||||
|
ldd r18, Y+NET_IFACE_OFFS_PACKETSIN_LOW
|
||||||
|
ldd r19, Y+NET_IFACE_OFFS_PACKETSIN_HIGH
|
||||||
|
rjmp appStatsSend16BitValue
|
||||||
|
AppStats_OnEveryMinute_sendPacketsOut:
|
||||||
|
ldi r17, AQHOME_VALUEID_STATS_PACKETS_OUT
|
||||||
|
ldd r18, Y+NET_IFACE_OFFS_PACKETSOUT_LOW
|
||||||
|
ldd r19, Y+NET_IFACE_OFFS_PACKETSOUT_HIGH
|
||||||
|
rjmp appStatsSend16BitValue
|
||||||
|
AppStats_OnEveryMinute_sendContentErrs:
|
||||||
|
ldi r17, AQHOME_VALUEID_STATS_ERRS_CONTENT
|
||||||
|
ldd r18, Y+NET_IFACE_OFFS_ERR_CONTENT_LOW
|
||||||
|
ldd r19, Y+NET_IFACE_OFFS_ERR_CONTENT_HIGH
|
||||||
|
rjmp appStatsSend16BitValue
|
||||||
|
AppStats_OnEveryMinute_sendIoErrs:
|
||||||
|
ldi r17, AQHOME_VALUEID_STATS_ERRS_IO
|
||||||
|
ldd r18, Y+NET_IFACE_OFFS_ERR_IO_LOW
|
||||||
|
ldd r19, Y+NET_IFACE_OFFS_ERR_IO_HIGH
|
||||||
|
rjmp appStatsSend16BitValue
|
||||||
|
AppStats_OnEveryMinute_sendNoBufErrs:
|
||||||
|
ldi r17, AQHOME_VALUEID_STATS_ERRS_NOBUF
|
||||||
|
ldd r18, Y+NET_IFACE_OFFS_ERR_NOBUF_LOW
|
||||||
|
ldd r19, Y+NET_IFACE_OFFS_ERR_NOBUF_HIGH
|
||||||
|
rjmp appStatsSend16BitValue
|
||||||
|
AppStats_OnEveryMinute_sendCollisionErrs:
|
||||||
|
ldi r17, AQHOME_VALUEID_STATS_ERRS_COLLISIONS
|
||||||
|
ldd r18, Y+NET_IFACE_OFFS_ERR_COLLISIONS_LOW
|
||||||
|
ldd r19, Y+NET_IFACE_OFFS_ERR_COLLISIONS_HIGH
|
||||||
|
rjmp appStatsSend16BitValue
|
||||||
|
AppStats_OnEveryMinute_sendBusyErrs:
|
||||||
|
ldi r17, AQHOME_VALUEID_STATS_ERRS_BUSY
|
||||||
|
ldd r18, Y+NET_IFACE_OFFS_ERR_BUSY_LOW
|
||||||
|
ldd r19, Y+NET_IFACE_OFFS_ERR_BUSY_HIGH
|
||||||
|
rjmp appStatsSend16BitValue
|
||||||
|
#ifdef MODULES_HEAP
|
||||||
|
AppStats_OnEveryMinute_sendHeapUsed:
|
||||||
|
ldi r17, AQHOME_VALUEID_STATS_HEAP_USED
|
||||||
|
lds r18, heapUsed
|
||||||
|
lds r19, heapUsed+1
|
||||||
|
rjmp appStatsSend16BitValue
|
||||||
|
AppStats_OnEveryMinute_sendHeapfree:
|
||||||
|
ldi r17, AQHOME_VALUEID_STATS_HEAP_FREE
|
||||||
|
lds r18, heapFree
|
||||||
|
lds r19, heapFree+1
|
||||||
|
rjmp appStatsSend16BitValue
|
||||||
|
#endif
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine AppStats_OnEveryMinute @global
|
||||||
|
;
|
||||||
|
; @param R17 value id
|
||||||
|
; @param R19:R18 value
|
||||||
|
|
||||||
|
appStatsSend16BitValue:
|
||||||
|
ldi r20, 1
|
||||||
|
clr r21
|
||||||
|
ldi r22, AQHOME_VALUETYPE_STATS
|
||||||
|
rjmp Main_SendValueReport
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,10 @@
|
|||||||
utils_wait.asm
|
utils_wait.asm
|
||||||
utils_wait_fixed.asm
|
utils_wait_fixed.asm
|
||||||
utils_wait_pin.asm
|
utils_wait_pin.asm
|
||||||
|
wait_100us.asm
|
||||||
|
wait_10us.asm
|
||||||
|
wait_1ms.asm
|
||||||
|
wait_50us.asm
|
||||||
watchdog.asm
|
watchdog.asm
|
||||||
list.asm
|
list.asm
|
||||||
tree.asm
|
tree.asm
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
; * Please see toplevel file COPYING of that project for license details. *
|
; * Please see toplevel file COPYING of that project for license details. *
|
||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
|
|
||||||
|
#if 0
|
||||||
; M_IO_READ DEST, SRC
|
; M_IO_READ DEST, SRC
|
||||||
.macro M_IO_READ
|
.macro M_IO_READ
|
||||||
.if @1 < 64
|
.if @1 < 64
|
||||||
@@ -27,3 +27,26 @@
|
|||||||
sts @0, @1
|
sts @0, @1
|
||||||
.endif
|
.endif
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
; inr DEST, SRC
|
||||||
|
.macro inr
|
||||||
|
.if @1 < 64
|
||||||
|
in @0, @1
|
||||||
|
.else
|
||||||
|
lds @0, @1
|
||||||
|
.endif
|
||||||
|
.endmacro
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; outr DEST, SRC
|
||||||
|
.macro outr
|
||||||
|
.if @0 < 64
|
||||||
|
out @0, @1
|
||||||
|
.else
|
||||||
|
sts @0, @1
|
||||||
|
.endif
|
||||||
|
.endmacro
|
||||||
|
|||||||
@@ -8,84 +8,10 @@
|
|||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
.include "common/wait_100us.asm"
|
||||||
|
.include "common/wait_10us.asm"
|
||||||
; ---------------------------------------------------------------------------
|
.include "common/wait_1ms.asm"
|
||||||
; @routine Utils_WaitFor10MicroSecs @global
|
.include "common/wait_50us.asm"
|
||||||
;
|
|
||||||
; wait for 10 microsecs (minus cycles for call and ret).
|
|
||||||
;
|
|
||||||
; @clobbers r22
|
|
||||||
|
|
||||||
Utils_WaitFor10MicroSecs:
|
|
||||||
Utils_WaitNanoSecs 10000, 7, r22 ; wait for 10us (minus RCALL and RET)
|
|
||||||
ret
|
|
||||||
; @end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; @routine Utils_WaitFor50MicroSecs @global
|
|
||||||
;
|
|
||||||
; wait for 50 microsecs (minus cycles for call and ret).
|
|
||||||
;
|
|
||||||
; @clobbers r22
|
|
||||||
|
|
||||||
Utils_WaitFor50MicroSecs:
|
|
||||||
Utils_WaitNanoSecs 50000, 7, r22 ; wait for 50us (minus RCALL and RET)
|
|
||||||
ret
|
|
||||||
; @end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; @routine Utils_WaitFor100MicroSecs @global
|
|
||||||
;
|
|
||||||
; wait for about 100 microsecs.
|
|
||||||
;
|
|
||||||
; @clobbers r22
|
|
||||||
|
|
||||||
Utils_WaitFor100MicroSecs:
|
|
||||||
rcall Utils_WaitFor50MicroSecs
|
|
||||||
rcall Utils_WaitFor50MicroSecs
|
|
||||||
ret
|
|
||||||
; @end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; @routine Utils_WaitFor1MilliSec @global
|
|
||||||
;
|
|
||||||
; wait for about 1ms.
|
|
||||||
;
|
|
||||||
; @clobbers r22
|
|
||||||
|
|
||||||
Utils_WaitFor1MilliSec:
|
|
||||||
push r21
|
|
||||||
ldi r21, 10
|
|
||||||
Utils_WaitFor1MilliSec_loop:
|
|
||||||
rcall Utils_WaitFor100MicroSecs ; (R22)
|
|
||||||
dec r21
|
|
||||||
brne Utils_WaitFor1MilliSec_loop
|
|
||||||
pop r21
|
|
||||||
ret
|
|
||||||
; @end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; @routine Utils_WaitForMilliSecs @global
|
|
||||||
;
|
|
||||||
; wait for given amount of milliseconds
|
|
||||||
; @param r16 number of millisecs to wait
|
|
||||||
; @clobbers r22
|
|
||||||
|
|
||||||
Utils_WaitForMilliSecs:
|
|
||||||
rcall Utils_WaitFor100MicroSecs ; (R22)
|
|
||||||
dec r16
|
|
||||||
brne Utils_WaitForMilliSecs
|
|
||||||
ret
|
|
||||||
; @end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
27
avr/common/wait_100us.asm
Normal file
27
avr/common/wait_100us.asm
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
; ***************************************************************************
|
||||||
|
; copyright : (C) 2023 by Martin Preuss
|
||||||
|
; email : martin@libchipcard.de
|
||||||
|
;
|
||||||
|
; ***************************************************************************
|
||||||
|
; * This file is part of the project "AqHome". *
|
||||||
|
; * Please see toplevel file COPYING of that project for license details. *
|
||||||
|
; ***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine Utils_WaitFor100MicroSecs @global
|
||||||
|
;
|
||||||
|
; wait for about 100 microsecs.
|
||||||
|
;
|
||||||
|
; @clobbers r22
|
||||||
|
|
||||||
|
Utils_WaitFor100MicroSecs:
|
||||||
|
rcall Utils_WaitFor50MicroSecs
|
||||||
|
rcall Utils_WaitFor50MicroSecs
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
25
avr/common/wait_10us.asm
Normal file
25
avr/common/wait_10us.asm
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
; ***************************************************************************
|
||||||
|
; copyright : (C) 2023 by Martin Preuss
|
||||||
|
; email : martin@libchipcard.de
|
||||||
|
;
|
||||||
|
; ***************************************************************************
|
||||||
|
; * This file is part of the project "AqHome". *
|
||||||
|
; * Please see toplevel file COPYING of that project for license details. *
|
||||||
|
; ***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine Utils_WaitFor10MicroSecs @global
|
||||||
|
;
|
||||||
|
; wait for 10 microsecs (minus cycles for call and ret).
|
||||||
|
;
|
||||||
|
; @clobbers r22
|
||||||
|
|
||||||
|
Utils_WaitFor10MicroSecs:
|
||||||
|
Utils_WaitNanoSecs 10000, 7, r22 ; wait for 10us (minus RCALL and RET)
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
47
avr/common/wait_1ms.asm
Normal file
47
avr/common/wait_1ms.asm
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
; ***************************************************************************
|
||||||
|
; copyright : (C) 2023 by Martin Preuss
|
||||||
|
; email : martin@libchipcard.de
|
||||||
|
;
|
||||||
|
; ***************************************************************************
|
||||||
|
; * This file is part of the project "AqHome". *
|
||||||
|
; * Please see toplevel file COPYING of that project for license details. *
|
||||||
|
; ***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine Utils_WaitFor1MilliSec @global
|
||||||
|
;
|
||||||
|
; wait for about 1ms.
|
||||||
|
;
|
||||||
|
; @clobbers r22
|
||||||
|
|
||||||
|
Utils_WaitFor1MilliSec:
|
||||||
|
push r21
|
||||||
|
ldi r21, 10
|
||||||
|
Utils_WaitFor1MilliSec_loop:
|
||||||
|
rcall Utils_WaitFor100MicroSecs ; (R22)
|
||||||
|
dec r21
|
||||||
|
brne Utils_WaitFor1MilliSec_loop
|
||||||
|
pop r21
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine Utils_WaitForMilliSecs @global
|
||||||
|
;
|
||||||
|
; wait for given amount of milliseconds
|
||||||
|
; @param r16 number of millisecs to wait
|
||||||
|
; @clobbers r22
|
||||||
|
|
||||||
|
Utils_WaitForMilliSecs:
|
||||||
|
rcall Utils_WaitFor100MicroSecs ; (R22)
|
||||||
|
dec r16
|
||||||
|
brne Utils_WaitForMilliSecs
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
24
avr/common/wait_50us.asm
Normal file
24
avr/common/wait_50us.asm
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
; ***************************************************************************
|
||||||
|
; copyright : (C) 2023 by Martin Preuss
|
||||||
|
; email : martin@libchipcard.de
|
||||||
|
;
|
||||||
|
; ***************************************************************************
|
||||||
|
; * This file is part of the project "AqHome". *
|
||||||
|
; * Please see toplevel file COPYING of that project for license details. *
|
||||||
|
; ***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine Utils_WaitFor50MicroSecs @global
|
||||||
|
;
|
||||||
|
; wait for 50 microsecs (minus cycles for call and ret).
|
||||||
|
;
|
||||||
|
; @clobbers r22
|
||||||
|
|
||||||
|
Utils_WaitFor50MicroSecs:
|
||||||
|
Utils_WaitNanoSecs 50000, 7, r22 ; wait for 50us (minus RCALL and RET)
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
; * Please see toplevel file COPYING of that project for license details. *
|
; * Please see toplevel file COPYING of that project for license details. *
|
||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
|
|
||||||
|
.error "Dont include this, use devices/all/defs.asm instead"
|
||||||
|
|
||||||
|
|
||||||
.equ AQHOME_VALUETYPE_UNKNOWN = 0
|
.equ AQHOME_VALUETYPE_UNKNOWN = 0
|
||||||
|
|||||||
@@ -26,10 +26,12 @@
|
|||||||
all
|
all
|
||||||
c01
|
c01
|
||||||
n16
|
n16
|
||||||
|
n20
|
||||||
n21
|
n21
|
||||||
n22
|
n22
|
||||||
n23
|
n23
|
||||||
n24
|
n24
|
||||||
|
n25
|
||||||
t03
|
t03
|
||||||
</subdirs>
|
</subdirs>
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
; * Please see toplevel file COPYING of that project for license details. *
|
; * Please see toplevel file COPYING of that project for license details. *
|
||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; Value types
|
; Value types
|
||||||
|
|
||||||
@@ -20,6 +19,22 @@
|
|||||||
.equ AQHOME_VALUETYPE_MOTION = 6
|
.equ AQHOME_VALUETYPE_MOTION = 6
|
||||||
.equ AQHOME_VALUETYPE_CO2 = 7
|
.equ AQHOME_VALUETYPE_CO2 = 7
|
||||||
.equ AQHOME_VALUETYPE_TVOC = 8
|
.equ AQHOME_VALUETYPE_TVOC = 8
|
||||||
|
.equ AQHOME_VALUETYPE_STATS = 9
|
||||||
|
|
||||||
|
|
||||||
|
; Value Ids
|
||||||
|
|
||||||
|
.equ AQHOME_VALUEID_STATS_PACKETS_IN = 0xe0
|
||||||
|
.equ AQHOME_VALUEID_STATS_PACKETS_OUT = 0xe1
|
||||||
|
.equ AQHOME_VALUEID_STATS_ERRS_CONTENT = 0xe2
|
||||||
|
.equ AQHOME_VALUEID_STATS_ERRS_IO = 0xe3
|
||||||
|
.equ AQHOME_VALUEID_STATS_ERRS_NOBUF = 0xe4
|
||||||
|
.equ AQHOME_VALUEID_STATS_ERRS_COLLISIONS = 0xe5
|
||||||
|
.equ AQHOME_VALUEID_STATS_ERRS_BUSY = 0xe6
|
||||||
|
.equ AQHOME_VALUEID_STATS_HEAP_USED = 0xe7
|
||||||
|
.equ AQHOME_VALUEID_STATS_HEAP_FREE = 0xe8
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -69,25 +69,25 @@ systemSleep:
|
|||||||
; only modify SE, SM2, SM1 and SM0
|
; only modify SE, SM2, SM1 and SM0
|
||||||
cli
|
cli
|
||||||
|
|
||||||
M_IO_READ r16, MCUCR
|
inr r16, MCUCR
|
||||||
cbr r16, (1<<SE) | (1<<SM2) | (1<<SM1)
|
cbr r16, (1<<SE) | (1<<SM2) | (1<<SM1)
|
||||||
M_IO_WRITE MCUCR, r16
|
outr MCUCR, r16
|
||||||
|
|
||||||
M_IO_READ r16, EMCUCR
|
inr r16, EMCUCR
|
||||||
cbr r16, (1<<SM0)
|
cbr r16, (1<<SM0)
|
||||||
M_IO_WRITE EMCUCR, r16
|
outr EMCUCR, r16
|
||||||
|
|
||||||
sei ; make sure interrupts really are enabled
|
sei ; make sure interrupts really are enabled
|
||||||
|
|
||||||
M_IO_READ r16, MCUCR ; enable sleep mode
|
inr r16, MCUCR ; enable sleep mode
|
||||||
sbr r16, (1<<SE)
|
sbr r16, (1<<SE)
|
||||||
M_IO_WRITE MCUCR, r16
|
outr MCUCR, r16
|
||||||
|
|
||||||
sleep ; sleep, wait for interrupt
|
sleep ; sleep, wait for interrupt
|
||||||
|
|
||||||
M_IO_READ r16, MCUCR ; disable sleep mode
|
inr r16, MCUCR ; disable sleep mode
|
||||||
cbr r16, (1<<SE)
|
cbr r16, (1<<SE)
|
||||||
M_IO_WRITE MCUCR, r16
|
outr MCUCR, r16
|
||||||
|
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
@@ -140,13 +140,13 @@ systemSetupTimer0: ; setup timer for IRQ every 100ms
|
|||||||
.endif
|
.endif
|
||||||
|
|
||||||
.ifdef TIMSK0
|
.ifdef TIMSK0
|
||||||
M_IO_READ r16, TIMSK0
|
inr r16, TIMSK0
|
||||||
sbr r16, (1<<OCIE0) ; Timer/Counter0 Output Compare Match A Interrupt Enable
|
sbr r16, (1<<OCIE0) ; Timer/Counter0 Output Compare Match A Interrupt Enable
|
||||||
M_IO_WRITE TIMSK0, r16
|
outr TIMSK0, r16
|
||||||
.else
|
.else
|
||||||
M_IO_READ r16, TIMSK
|
inr r16, TIMSK
|
||||||
sbr r16, (1<<OCIE0) ; Timer/Counter0 Output Compare Match A Interrupt Enable
|
sbr r16, (1<<OCIE0) ; Timer/Counter0 Output Compare Match A Interrupt Enable
|
||||||
M_IO_WRITE TIMSK, r16
|
outr TIMSK, r16
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
sec
|
sec
|
||||||
|
|||||||
@@ -54,7 +54,8 @@
|
|||||||
#ifdef MODULES_UART_BITBANG
|
#ifdef MODULES_UART_BITBANG
|
||||||
.include "modules/uart_bitbang2/defs.asm"
|
.include "modules/uart_bitbang2/defs.asm"
|
||||||
.include "modules/uart_bitbang2/iface.asm"
|
.include "modules/uart_bitbang2/iface.asm"
|
||||||
.include "modules/uart_bitbang2/lowlevel.asm"
|
.include "modules/uart_bitbang2/bytelevel.asm"
|
||||||
|
.include "modules/uart_bitbang2/msglevel.asm"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_UART_HW
|
#ifdef MODULES_UART_HW
|
||||||
@@ -196,6 +197,7 @@
|
|||||||
.include "apps/network/main.asm"
|
.include "apps/network/main.asm"
|
||||||
.include "modules/network/msg/reboot-d.asm"
|
.include "modules/network/msg/reboot-d.asm"
|
||||||
.include "modules/network/msg/reboot-r.asm"
|
.include "modules/network/msg/reboot-r.asm"
|
||||||
|
.include "modules/network/msg/pong-w.asm"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,24 @@
|
|||||||
|
|
||||||
<device name="aqua_c01" driver="nodes">
|
<device name="aqua_c01" driver="nodes">
|
||||||
<manufacturer>AQUA</manufacturer>
|
<manufacturer>AQUA</manufacturer>
|
||||||
<devicetype>N</devicetype>
|
<devicetype>C</devicetype>
|
||||||
<deviceversion>1</deviceversion>
|
<deviceversion>1</deviceversion>
|
||||||
|
|
||||||
<values>
|
<values>
|
||||||
<value name="LEDTIMING" id="0x88" type="actor" dataType="uint16" />
|
<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>
|
</values>
|
||||||
|
|
||||||
</device>
|
</device>
|
||||||
|
|||||||
@@ -115,16 +115,19 @@ main:
|
|||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
; includes
|
; includes
|
||||||
|
|
||||||
.include "common/utils_wait_fixed.asm"
|
.include "common/wait_10us.asm"
|
||||||
.include "common/utils_copy_from_flash.asm"
|
.include "common/utils_copy_from_flash.asm"
|
||||||
.include "common/utils_copy_sdram.asm"
|
.include "common/utils_copy_sdram.asm"
|
||||||
|
|
||||||
.include "modules/flash/defs.asm"
|
.include "modules/flash/defs.asm"
|
||||||
.include "modules/flash/eeprom.asm"
|
.include "modules/flash/eeprom.asm"
|
||||||
.include "modules/flash/io.asm"
|
.include "modules/flash/io.asm"
|
||||||
.include "modules/flash/io_attn.asm"
|
;.include "modules/flash/io_attn.asm"
|
||||||
.include "modules/flash/io_uart.asm"
|
.include "modules/flash/io_uart.asm"
|
||||||
.include "modules/flash/io_uart_all_attn.asm"
|
;.include "modules/flash/io_uart_all_attn.asm"
|
||||||
|
|
||||||
|
.include "modules/flash/io_uart_attn_small.asm"
|
||||||
|
|
||||||
.include "modules/flash/flash1pmega.asm"
|
.include "modules/flash/flash1pmega.asm"
|
||||||
.include "modules/flash/flashxp.asm"
|
.include "modules/flash/flashxp.asm"
|
||||||
.include "modules/flash/flashprocess.asm"
|
.include "modules/flash/flashprocess.asm"
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
.include "include/m8515def.inc" ; Define device ATmega8515
|
.include "include/m8515def.inc" ; Define device ATmega8515
|
||||||
.list
|
.list
|
||||||
|
|
||||||
|
.include "version.asm"
|
||||||
.include "../defs.asm"
|
.include "../defs.asm"
|
||||||
.include "./data.asm"
|
.include "./data.asm"
|
||||||
|
|
||||||
@@ -48,11 +49,6 @@
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; firmware settings including list of modules used
|
; firmware settings including list of modules used
|
||||||
|
|
||||||
.equ FIRMWARE_VERSION_MAJOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_MINOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_PATCHLEVEL = 1
|
|
||||||
|
|
||||||
|
|
||||||
; #define MODULES_TIMER
|
; #define MODULES_TIMER
|
||||||
#define MODULES_CLOCK
|
#define MODULES_CLOCK
|
||||||
#define MODULES_XRAM
|
#define MODULES_XRAM
|
||||||
|
|||||||
@@ -12,8 +12,9 @@
|
|||||||
.include "include/tn84def.inc" ; Define device ATtiny84
|
.include "include/tn84def.inc" ; Define device ATtiny84
|
||||||
.list
|
.list
|
||||||
|
|
||||||
|
.include "version.asm"
|
||||||
.include "../defs.asm"
|
.include "../defs.asm"
|
||||||
.include "defs_all.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -32,10 +33,6 @@
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; firmware settings
|
; firmware settings
|
||||||
|
|
||||||
.equ FIRMWARE_VERSION_MAJOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_MINOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_PATCHLEVEL = 1
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
.include "include/tn84def.inc" ; Define device ATtiny84
|
.include "include/tn84def.inc" ; Define device ATtiny84
|
||||||
.list
|
.list
|
||||||
|
|
||||||
|
.include "version.asm"
|
||||||
.include "../defs.asm"
|
.include "../defs.asm"
|
||||||
|
|
||||||
.include "devices/all/defs.asm"
|
.include "devices/all/defs.asm"
|
||||||
@@ -51,11 +52,6 @@
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; firmware settings including list of modules used
|
; firmware settings including list of modules used
|
||||||
|
|
||||||
.equ FIRMWARE_VERSION_MAJOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_MINOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_PATCHLEVEL = 1
|
|
||||||
|
|
||||||
|
|
||||||
#define MODULES_CLOCK
|
#define MODULES_CLOCK
|
||||||
#define MODULES_LED_SIMPLE
|
#define MODULES_LED_SIMPLE
|
||||||
#define MODULES_NETWORK
|
#define MODULES_NETWORK
|
||||||
|
|||||||
@@ -12,8 +12,9 @@
|
|||||||
.include "include/tn84def.inc" ; Define device ATtiny84
|
.include "include/tn84def.inc" ; Define device ATtiny84
|
||||||
.list
|
.list
|
||||||
|
|
||||||
|
.include "version.asm"
|
||||||
.include "./defs.asm"
|
.include "./defs.asm"
|
||||||
.include "defs_all.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -32,9 +33,6 @@
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; firmware settings
|
; firmware settings
|
||||||
|
|
||||||
.equ FIRMWARE_VERSION_MAJOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_MINOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_PATCHLEVEL = 1
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -113,6 +111,7 @@ main:
|
|||||||
.include "modules/flash/io_attn.asm"
|
.include "modules/flash/io_attn.asm"
|
||||||
.include "modules/flash/io_bitbang.asm"
|
.include "modules/flash/io_bitbang.asm"
|
||||||
.include "modules/flash/flash1p.asm"
|
.include "modules/flash/flash1p.asm"
|
||||||
|
.include "modules/flash/flashxp.asm"
|
||||||
.include "modules/flash/flashprocess.asm"
|
.include "modules/flash/flashprocess.asm"
|
||||||
.include "modules/flash/wait.asm"
|
.include "modules/flash/wait.asm"
|
||||||
.include "modules/bootloader/main.asm"
|
.include "modules/bootloader/main.asm"
|
||||||
@@ -121,7 +120,6 @@ main:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
systemSetSpeed:
|
systemSetSpeed:
|
||||||
.if clock == 8000000
|
.if clock == 8000000
|
||||||
ldi r16, (1<<CLKPCE)
|
ldi r16, (1<<CLKPCE)
|
||||||
|
|||||||
@@ -30,8 +30,11 @@
|
|||||||
.include "include/tn84def.inc" ; Define device ATtiny84
|
.include "include/tn84def.inc" ; Define device ATtiny84
|
||||||
.list
|
.list
|
||||||
|
|
||||||
|
.include "version.asm"
|
||||||
.include "./defs.asm"
|
.include "./defs.asm"
|
||||||
.include "defs_all.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
|
||||||
|
.include "common/utils_wait.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -41,31 +44,37 @@
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; generic
|
; generic
|
||||||
|
|
||||||
|
.equ NET_BUFFERS_NUM = 4
|
||||||
|
.equ NET_BUFFERS_SIZE = 32
|
||||||
|
|
||||||
.include "common/utils_wait.asm"
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; firmware settings including list of modules used
|
; firmware settings including list of modules used
|
||||||
|
|
||||||
.equ FIRMWARE_VERSION_MAJOR = 0
|
; #define MODULES_TIMER
|
||||||
.equ FIRMWARE_VERSION_MINOR = 0
|
#define MODULES_CLOCK
|
||||||
.equ FIRMWARE_VERSION_PATCHLEVEL = 1
|
|
||||||
|
|
||||||
|
|
||||||
#define MODULES_TIMER
|
|
||||||
#define MODULES_COM
|
|
||||||
#define MODULES_COM_WITH_ADDR_PROTO
|
|
||||||
#define MODULES_LED_SIMPLE
|
#define MODULES_LED_SIMPLE
|
||||||
#define MODULES_TWI_MASTER
|
#define MODULES_NETWORK
|
||||||
|
#define MODULES_UART_BITBANG
|
||||||
|
;#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
|
||||||
#define MODULES_MOTION
|
;#define MODULES_MOTION
|
||||||
#define MODULES_CCS811
|
;#define MODULES_TCRT1000
|
||||||
|
;#define MODULES_CCS811
|
||||||
|
|
||||||
|
#define APPS_NETWORK
|
||||||
|
;#define APPS_MOTION
|
||||||
|
;#define APPS_DOOR
|
||||||
|
;#define APPS_REPORTSENSORS
|
||||||
|
#define APPS_STATS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; defines for values
|
; defines for values
|
||||||
@@ -86,6 +95,8 @@
|
|||||||
|
|
||||||
.equ VALUE_ID_DEBUG = 0x7f
|
.equ VALUE_ID_DEBUG = 0x7f
|
||||||
|
|
||||||
|
.equ VALUE_ID_LEDSIMPLE_TIMING = 0x88
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
@@ -102,7 +113,7 @@
|
|||||||
; rjmp main ; Reset vector
|
; rjmp main ; Reset vector
|
||||||
rjmp BOOTLOADER_ADDR ; Reset vector ; use this for flashed system
|
rjmp BOOTLOADER_ADDR ; Reset vector ; use this for flashed system
|
||||||
reti ; EXT_INT0
|
reti ; EXT_INT0
|
||||||
rjmp uartBitbangIsrPcint0 ; PCI0
|
rjmp UART_BitBang_PcintIsr ; PCI0
|
||||||
reti ; PCI1
|
reti ; PCI1
|
||||||
reti ; WATCHDOG
|
reti ; WATCHDOG
|
||||||
reti ; ICP1
|
reti ; ICP1
|
||||||
@@ -126,351 +137,82 @@ devInfoVersion: .db DEVICEINFO_VERSION, DEVICEINFO_REVISION ; v
|
|||||||
firmwareVersion: .db FIRMWARE_VARIANT_TEMP_WINDOW, FIRMWARE_VERSION_MAJOR
|
firmwareVersion: .db FIRMWARE_VARIANT_TEMP_WINDOW, FIRMWARE_VERSION_MAJOR
|
||||||
.db FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCHLEVEL
|
.db FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCHLEVEL
|
||||||
|
|
||||||
firmwareStart: rjmp main
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine firmwareStart @global
|
||||||
|
|
||||||
|
firmwareStart:
|
||||||
|
rjmp main
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine onSystemStart
|
||||||
|
|
||||||
|
onSystemStart:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine onMessageReceived
|
||||||
|
;
|
||||||
|
; Called on every message received
|
||||||
|
|
||||||
|
onMessageReceived:
|
||||||
|
clc
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine onEvery100ms
|
||||||
|
;
|
||||||
|
; Called every 100ms. Add your routine calls here. No arguments, no results.
|
||||||
|
|
||||||
|
onEvery100ms:
|
||||||
|
onEverySecond:
|
||||||
|
onEveryMinute:
|
||||||
|
onEveryHour:
|
||||||
|
onEveryDay:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine onEveryLoop
|
||||||
|
;
|
||||||
|
; Called on every loop (i.e. after awakening from sleep).
|
||||||
|
;
|
||||||
|
onEveryLoop:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
; includes
|
; includes
|
||||||
|
|
||||||
.include "common/utils.asm"
|
.include "devices/all/hw_tn84.asm"
|
||||||
.include "common/utils_wait_fixed.asm"
|
.include "devices/all/includes.asm"
|
||||||
.include "common/utils_copy_from_flash.asm"
|
|
||||||
.include "common/utils_copy_sdram.asm"
|
|
||||||
.include "common/crc8.asm"
|
|
||||||
|
|
||||||
.include "modules/basetimer/main.asm"
|
|
||||||
|
|
||||||
#ifdef MODULES_TIMER
|
|
||||||
.include "modules/timer/main.asm"
|
|
||||||
#endif
|
|
||||||
#ifdef MODULES_LED
|
|
||||||
.include "modules/led/main.asm"
|
|
||||||
#endif
|
|
||||||
#ifdef MODULES_LED_SIMPLE
|
|
||||||
.include "modules/led_simple/main.asm"
|
|
||||||
#endif
|
|
||||||
#ifdef MODULES_COM
|
|
||||||
.include "modules/com2/defs.asm"
|
|
||||||
.include "modules/com2/main.asm"
|
|
||||||
.include "modules/com2/buffer.asm"
|
|
||||||
.include "modules/uart_bitbang/defs.asm"
|
|
||||||
.include "modules/uart_bitbang/main.asm"
|
|
||||||
.include "modules/uart_bitbang/bytelevel.asm"
|
|
||||||
.include "modules/uart_bitbang/packetlevel.asm"
|
|
||||||
#ifdef MODULES_COM_WITH_ADDR_PROTO
|
|
||||||
.include "modules/comproto/defs.asm"
|
|
||||||
.include "modules/comproto/main.asm"
|
|
||||||
.include "modules/comproto/addr.asm"
|
|
||||||
.include "modules/comproto/msg_recvstats.asm"
|
|
||||||
.include "modules/comproto/msg_sendstats.asm"
|
|
||||||
.include "modules/comproto/msg_sysstats.asm"
|
|
||||||
.include "modules/comproto/msg_memstats.asm"
|
|
||||||
.include "modules/comproto/msg_pong.asm"
|
|
||||||
.include "modules/comproto/msg_value.asm"
|
|
||||||
.include "modules/comproto/msg_device.asm"
|
|
||||||
.include "modules/comproto/msg_reboot.asm"
|
|
||||||
#endif
|
|
||||||
#ifdef MODULES_LCD
|
|
||||||
.include "modules/com2/screen.asm"
|
|
||||||
.include "modules/comproto/screen.asm"
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#ifdef MODULES_TWI_MASTER
|
|
||||||
.include "modules/twimaster/main.asm"
|
|
||||||
#endif
|
|
||||||
#ifdef MODULES_OWI_MASTER
|
|
||||||
.include "modules/owimaster/main.asm"
|
|
||||||
#endif
|
|
||||||
#ifdef MODULES_LCD
|
|
||||||
.include "modules/lcd/main.asm"
|
|
||||||
#endif
|
|
||||||
#ifdef MODULES_SI7021
|
|
||||||
.include "modules/si7021/main.asm"
|
|
||||||
#endif
|
|
||||||
#ifdef MODULES_DS18B20
|
|
||||||
.include "modules/ds18b20/main.asm"
|
|
||||||
#endif
|
|
||||||
#ifdef MODULES_STATS
|
|
||||||
.include "modules/stats/main.asm"
|
|
||||||
#endif
|
|
||||||
#ifdef MODULES_CNY70
|
|
||||||
.include "modules/cny70/main.asm"
|
|
||||||
#endif
|
|
||||||
#ifdef MODULES_REED
|
|
||||||
.include "modules/reed/main.asm"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef MODULES_MOTION
|
|
||||||
.include "modules/motion/main.asm"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef MODULES_CCS811
|
|
||||||
.include "modules/ccs811/main.asm"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
; test
|
|
||||||
;#include "modules/uart_irq/defs.asm"
|
|
||||||
;#include "modules/uart_irq/iface.asm"
|
|
||||||
;#include "modules/uart_irq/iface1.asm"
|
|
||||||
|
|
||||||
|
|
||||||
; ***************************************************************************
|
|
||||||
; data in SRAM
|
|
||||||
|
|
||||||
.dseg
|
|
||||||
|
|
||||||
programRamBegin:
|
|
||||||
#ifdef MODULES_LCD
|
|
||||||
screenCounter: .byte 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
programRamEnd:
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef MODULES_LCD
|
|
||||||
sramTimerWriteStats: .byte 2
|
|
||||||
sramTimerScreen: .byte 2
|
|
||||||
#endif
|
|
||||||
#ifdef MODULES_SI7021
|
|
||||||
sramTimerSI7021Measure: .byte 2
|
|
||||||
sramTimerSI7021SendTemp: .byte 2
|
|
||||||
sramTimerSI7021SendHumidity: .byte 2
|
|
||||||
#endif
|
|
||||||
#ifdef MODULES_CNY70
|
|
||||||
sramTimerCny70SendAdc: .byte 2
|
|
||||||
#endif
|
|
||||||
#ifdef MODULES_LCD
|
|
||||||
sramPeriodicalLcdMark: .byte 2
|
|
||||||
#endif
|
|
||||||
#ifdef MODULES_DS18B20
|
|
||||||
sramDs18b20Timer: .byte 2
|
|
||||||
sramSendDs18b20TempTimer: .byte 2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef MODULES_CCS811
|
|
||||||
sramCcs811Timer: .byte 2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
; ***************************************************************************
|
|
||||||
; data in FLASH
|
|
||||||
|
|
||||||
.cseg
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; timer list
|
; defines for network interface
|
||||||
|
|
||||||
|
.equ netInterfaceData = uart_bitbang_iface
|
||||||
timerList:
|
|
||||||
; SRAM variable/counter routine flags secs (0=don't start or restart)
|
|
||||||
#ifdef MODULES_COM_WITH_ADDR_PROTO
|
|
||||||
.dw cproAddresModeTimer, CPRO_Address_OnTimer, 0, 0 ; (no restart)
|
|
||||||
#endif
|
|
||||||
#ifdef MODULES_STATS
|
|
||||||
.dw statsSendTimer, Stats_Timer, TIMER_FLAGS_IF_ADDR, 9000 ; every 15m
|
|
||||||
#endif
|
|
||||||
#ifdef MODULES_LCD
|
|
||||||
; .dw sramPeriodicalLcdMark, periodicalLcdMark, 0, 20 ; every 2s
|
|
||||||
; .dw sramTimerWriteStats, writeStats, 0, 100
|
|
||||||
.dw sramTimerScreen, printScreen, TIMER_FLAGS_IF_ADDR, 50 ; every 5s
|
|
||||||
#endif
|
|
||||||
#ifdef MODULES_SI7021
|
|
||||||
.dw sramTimerSI7021Measure, SI7021_OnTimer, 0, 300 ; every 30s
|
|
||||||
.dw sramTimerSI7021SendTemp, sendSI7021Temp, TIMER_FLAGS_IF_ADDR, 600 ; every 60s
|
|
||||||
.dw sramTimerSI7021SendHumidity, sendSI7021Humidity, TIMER_FLAGS_IF_ADDR, 600 ; every 60s
|
|
||||||
#endif
|
|
||||||
#ifdef MODULES_CNY70
|
|
||||||
.dw sramTimerCny70SendAdc, CNY70_OnTimer, TIMER_FLAGS_IF_ADDR, 50 ; every 5s
|
|
||||||
#endif
|
|
||||||
#ifdef MODULES_DS18B20
|
|
||||||
.dw sramDs18b20Timer, Ds18b20_OnTimer, 0, 300 ; every 30s
|
|
||||||
.dw sramSendDs18b20TempTimer, sendDs18b20Temp, TIMER_FLAGS_IF_ADDR, 600 ; every 60s
|
|
||||||
#endif
|
|
||||||
#ifdef MODULES_CCS811
|
|
||||||
.dw sramCcs811Timer, CCS811_OnTimer, 0, 10 ; every 1s
|
|
||||||
#endif
|
|
||||||
.dw 0 ; end of list
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.include "main_all.asm"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
systemSetSpeed:
|
|
||||||
.if clock == 8000000
|
|
||||||
ldi r16, (1<<CLKPCE)
|
|
||||||
ldi r17, 0
|
|
||||||
out CLKPR, r16
|
|
||||||
out CLKPR, r17
|
|
||||||
.endif
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
systemSetBootSpeed:
|
|
||||||
.if clock == 8000000
|
|
||||||
ldi r16, (1<<CLKPCE)
|
|
||||||
ldi r17, (1<<CLKPS1) | (1<<CLKPS0)
|
|
||||||
out CLKPR, r16
|
|
||||||
out CLKPR, r17
|
|
||||||
.endif
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; Called on first time run, i.e. on system start. No arguments, no results.
|
|
||||||
|
|
||||||
onSystemStart:
|
|
||||||
ldi xh, HIGH(programRamBegin)
|
|
||||||
ldi xl, LOW(programRamBegin)
|
|
||||||
clr r16
|
|
||||||
ldi r17, (programRamEnd-programRamBegin)
|
|
||||||
rcall Utils_FillSram
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef MODULES_LCD
|
|
||||||
|
|
||||||
printScreen:
|
|
||||||
lds r16, screenCounter
|
|
||||||
tst r16
|
|
||||||
brne printScreen_l1
|
|
||||||
rcall CPRO_Screen
|
|
||||||
rjmp printScreen_counter
|
|
||||||
printScreen_l1:
|
|
||||||
cpi r16, 1
|
|
||||||
brne printScreen_l2
|
|
||||||
rcall COM2_Screen_RecvStats
|
|
||||||
rjmp printScreen_counter
|
|
||||||
printScreen_l2:
|
|
||||||
; cpi r16, 2
|
|
||||||
; brne printScreen_l3
|
|
||||||
; rcall COM2_Screen_SendStats
|
|
||||||
; rjmp printScreen_counter
|
|
||||||
printScreen_l3:
|
|
||||||
; add more screens here
|
|
||||||
|
|
||||||
printScreen_counter:
|
|
||||||
lds r16, screenCounter
|
|
||||||
inc r16
|
|
||||||
cpi r16, 2 ; number of screens
|
|
||||||
brcs printScreen_store
|
|
||||||
clr r16
|
|
||||||
printScreen_store:
|
|
||||||
sts screenCounter, r16
|
|
||||||
printScreen_end:
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
;periodicalLcdMark:
|
|
||||||
; rcall printTimerMark
|
|
||||||
; ret
|
|
||||||
|
|
||||||
|
|
||||||
;writeStats:
|
|
||||||
; rcall printSendStats
|
|
||||||
; ret
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef MODULES_SI7021
|
|
||||||
|
|
||||||
sendSI7021Humidity:
|
|
||||||
rcall SI7021_SendHumidity
|
|
||||||
brcs sendSI7021Humidity_okay
|
|
||||||
; set timer to 1s to retry later
|
|
||||||
ldi xl, LOW(sramTimerSI7021SendHumidity)
|
|
||||||
ldi xh, HIGH(sramTimerSI7021SendHumidity)
|
|
||||||
rjmp Timer_SetValueTo1s
|
|
||||||
sendSI7021Humidity_okay:
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
sendSI7021Temp:
|
|
||||||
rcall SI7021_SendTemp
|
|
||||||
brcs sendSI7021Temp_okay
|
|
||||||
; set timer to 1s to retry later
|
|
||||||
ldi xl, LOW(sramTimerSI7021SendTemp)
|
|
||||||
ldi xh, HIGH(sramTimerSI7021SendTemp)
|
|
||||||
rjmp Timer_SetValueTo1s
|
|
||||||
sendSI7021Temp_okay:
|
|
||||||
ret
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef MODULES_DS18B20
|
|
||||||
sendDs18b20Temp:
|
|
||||||
rcall Ds18b20_SendTemp
|
|
||||||
brcs sendDs18b20Temp_okay
|
|
||||||
; set timer to 1s to retry later
|
|
||||||
ldi xl, LOW(sramSendDs18b20TempTimer)
|
|
||||||
ldi xh, HIGH(sramSendDs18b20TempTimer)
|
|
||||||
rjmp Timer_SetValueTo1s
|
|
||||||
sendDs18b20Temp_okay:
|
|
||||||
ret
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; Called every 100ms. Add your routine calls here. No arguments, no results.
|
|
||||||
|
|
||||||
onEvery100ms:
|
|
||||||
#ifdef MODULES_LED_SIMPLE
|
|
||||||
rcall LedSimple_Every100ms
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef MODULES_REED
|
|
||||||
rcall REED_Every100ms
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef MODULES_MOTION
|
|
||||||
rcall Motion_Every100ms
|
|
||||||
#endif
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; @routine onPacketReceived:
|
|
||||||
;
|
|
||||||
; Called after a packet was received via COM module. Add your routine calls here.
|
|
||||||
;
|
|
||||||
; The packet will be released in any case after return from this call.
|
|
||||||
;
|
|
||||||
; @return CFLAG set if message handled, cleared otherwise
|
|
||||||
; @param X pointer to received buffer
|
|
||||||
; @clobbers all
|
|
||||||
|
|
||||||
onPacketReceived:
|
|
||||||
#ifdef MODULES_MOTION_LIGHT
|
|
||||||
rcall MotionLight_OnPacketReceived
|
|
||||||
brcs onPacketReceived_end
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef MODULES_SK6812
|
|
||||||
rcall SK6812_OnPacketReceived
|
|
||||||
brcs onPacketReceived_end
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef MODULES_REED
|
|
||||||
rcall REED_OnPacketReceived
|
|
||||||
brcs onPacketReceived_end
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef MODULES_COM
|
|
||||||
rcall CPRO_OnPacketReceived
|
|
||||||
brcs onPacketReceived_end
|
|
||||||
#endif
|
|
||||||
|
|
||||||
clc
|
|
||||||
onPacketReceived_end:
|
|
||||||
ret
|
|
||||||
; @end
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
.include "include/tn84def.inc" ; Define device ATtiny84
|
.include "include/tn84def.inc" ; Define device ATtiny84
|
||||||
.list
|
.list
|
||||||
|
|
||||||
|
.include "version.asm"
|
||||||
.include "../defs.asm"
|
.include "../defs.asm"
|
||||||
.include "devices/all/defs.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
|
||||||
@@ -32,10 +33,6 @@
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; firmware settings
|
; firmware settings
|
||||||
|
|
||||||
.equ FIRMWARE_VERSION_MAJOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_MINOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_PATCHLEVEL = 1
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
.include "include/tn84def.inc" ; Define device ATtiny84
|
.include "include/tn84def.inc" ; Define device ATtiny84
|
||||||
.list
|
.list
|
||||||
|
|
||||||
|
.include "version.asm"
|
||||||
.include "../defs.asm"
|
.include "../defs.asm"
|
||||||
.include "./data.asm"
|
.include "./data.asm"
|
||||||
|
|
||||||
@@ -53,11 +54,6 @@
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; firmware settings including list of modules used
|
; firmware settings including list of modules used
|
||||||
|
|
||||||
.equ FIRMWARE_VERSION_MAJOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_MINOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_PATCHLEVEL = 1
|
|
||||||
|
|
||||||
|
|
||||||
; #define MODULES_TIMER
|
; #define MODULES_TIMER
|
||||||
#define MODULES_CLOCK
|
#define MODULES_CLOCK
|
||||||
#define MODULES_LED_SIMPLE
|
#define MODULES_LED_SIMPLE
|
||||||
|
|||||||
@@ -14,8 +14,9 @@
|
|||||||
.include "include/tn85def.inc" ; Define device ATtiny85
|
.include "include/tn85def.inc" ; Define device ATtiny85
|
||||||
.list
|
.list
|
||||||
|
|
||||||
|
.include "version.asm"
|
||||||
.include "../defs.asm"
|
.include "../defs.asm"
|
||||||
.include "defs_all.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -33,9 +34,6 @@
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; firmware settings
|
; firmware settings
|
||||||
|
|
||||||
.equ FIRMWARE_VERSION_MAJOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_MINOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_PATCHLEVEL = 1
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
.include "include/tn85def.inc" ; Define device ATtiny85
|
.include "include/tn85def.inc" ; Define device ATtiny85
|
||||||
.list
|
.list
|
||||||
|
|
||||||
|
.include "version.asm"
|
||||||
.include "../defs.asm"
|
.include "../defs.asm"
|
||||||
;.include "./data.asm"
|
;.include "./data.asm"
|
||||||
|
|
||||||
@@ -44,11 +45,6 @@
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; firmware settings including list of modules used
|
; firmware settings including list of modules used
|
||||||
|
|
||||||
.equ FIRMWARE_VERSION_MAJOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_MINOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_PATCHLEVEL = 1
|
|
||||||
|
|
||||||
|
|
||||||
#define MODULES_CLOCK
|
#define MODULES_CLOCK
|
||||||
#define MODULES_LED_SIMPLE
|
#define MODULES_LED_SIMPLE
|
||||||
#define MODULES_NETWORK
|
#define MODULES_NETWORK
|
||||||
|
|||||||
@@ -12,6 +12,18 @@
|
|||||||
<value name="SGP30_TVOC" id="0x09" type="sensor" dataType="rational" modality="tvoc" denom="1" />
|
<value name="SGP30_TVOC" id="0x09" type="sensor" dataType="rational" modality="tvoc" denom="1" />
|
||||||
<value name="SGP30_CO2" id="0x0a" type="sensor" dataType="rational" modality="co2" denom="1" />
|
<value name="SGP30_CO2" id="0x0a" type="sensor" dataType="rational" modality="co2" denom="1" />
|
||||||
|
|
||||||
|
<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" />
|
||||||
|
|
||||||
<value name="LEDTIMING" id="0x88" type="actor" dataType="uint16" />
|
<value name="LEDTIMING" id="0x88" type="actor" dataType="uint16" />
|
||||||
</values>
|
</values>
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,9 @@
|
|||||||
.include "include/tn84def.inc" ; Define device ATtiny84
|
.include "include/tn84def.inc" ; Define device ATtiny84
|
||||||
.list
|
.list
|
||||||
|
|
||||||
|
.include "version.asm"
|
||||||
.include "../defs.asm"
|
.include "../defs.asm"
|
||||||
.include "defs_all.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
|
||||||
|
|
||||||
#define COM_ACCEPT_ALL_DEST
|
#define COM_ACCEPT_ALL_DEST
|
||||||
@@ -33,10 +34,6 @@
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; firmware settings
|
; firmware settings
|
||||||
|
|
||||||
.equ FIRMWARE_VERSION_MAJOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_MINOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_PATCHLEVEL = 1
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
.include "include/tn84def.inc" ; Define device ATtiny84
|
.include "include/tn84def.inc" ; Define device ATtiny84
|
||||||
.list
|
.list
|
||||||
|
|
||||||
|
.include "version.asm"
|
||||||
.include "../defs.asm"
|
.include "../defs.asm"
|
||||||
.include "./data.asm"
|
.include "./data.asm"
|
||||||
|
|
||||||
@@ -55,11 +56,6 @@
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; firmware settings including list of modules used
|
; firmware settings including list of modules used
|
||||||
|
|
||||||
.equ FIRMWARE_VERSION_MAJOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_MINOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_PATCHLEVEL = 1
|
|
||||||
|
|
||||||
|
|
||||||
; #define MODULES_TIMER
|
; #define MODULES_TIMER
|
||||||
#define MODULES_CLOCK
|
#define MODULES_CLOCK
|
||||||
#define MODULES_LED_SIMPLE
|
#define MODULES_LED_SIMPLE
|
||||||
|
|||||||
@@ -12,6 +12,18 @@
|
|||||||
<value name="SGP30_TVOC" id="0x09" type="sensor" dataType="rational" modality="tvoc" denom="1" />
|
<value name="SGP30_TVOC" id="0x09" type="sensor" dataType="rational" modality="tvoc" denom="1" />
|
||||||
<value name="SGP30_CO2" id="0x0a" type="sensor" dataType="rational" modality="co2" denom="1" />
|
<value name="SGP30_CO2" id="0x0a" type="sensor" dataType="rational" modality="co2" denom="1" />
|
||||||
|
|
||||||
|
<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" />
|
||||||
|
|
||||||
<value name="LEDTIMING" id="0x88" type="actor" dataType="uint16" />
|
<value name="LEDTIMING" id="0x88" type="actor" dataType="uint16" />
|
||||||
</values>
|
</values>
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
|
; ***************************************************************************
|
||||||
|
; copyright : (C) 2025 by Martin Preuss
|
||||||
|
; email : martin@libchipcard.de
|
||||||
|
;
|
||||||
|
; ***************************************************************************
|
||||||
|
; * This file is part of the project "AqHome". *
|
||||||
|
; * Please see toplevel file COPYING of that project for license details. *
|
||||||
|
; ***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
; Source file for base system node on AtTiny 84
|
; Source file for base system node on AtTiny 84
|
||||||
;
|
;
|
||||||
@@ -12,8 +22,9 @@
|
|||||||
.include "include/tn84def.inc" ; Define device ATtiny84
|
.include "include/tn84def.inc" ; Define device ATtiny84
|
||||||
.list
|
.list
|
||||||
|
|
||||||
|
.include "version.asm"
|
||||||
.include "../defs.asm"
|
.include "../defs.asm"
|
||||||
.include "defs_all.asm"
|
.include "devices/all/defs.asm"
|
||||||
|
|
||||||
|
|
||||||
#define COM_ACCEPT_ALL_DEST
|
#define COM_ACCEPT_ALL_DEST
|
||||||
@@ -35,10 +46,6 @@
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; firmware settings
|
; firmware settings
|
||||||
|
|
||||||
.equ FIRMWARE_VERSION_MAJOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_MINOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_PATCHLEVEL = 1
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -13,10 +13,10 @@
|
|||||||
; AtTiny84
|
; AtTiny84
|
||||||
; --------
|
; --------
|
||||||
; VCC 1 14 GND
|
; VCC 1 14 GND
|
||||||
; PB0 2 13 PA0 AUX-A0
|
; AUX-PB0 PB0 2 13 PA0 AUX-PA0
|
||||||
; PIR PB1 3 12 PA1 COM-DATA
|
; PIR PB1 3 12 PA1 COM-DATA
|
||||||
; /RESET PB3 4 11 PA2
|
; /RESET PB3 4 11 PA2 AUX-PA2
|
||||||
; AUX-B2 PB2 5 10 PA3 LED
|
; PB2 5 10 PA3 LED
|
||||||
; COM_ATTN PA7 6 9 PA4 TWI-SCL
|
; COM_ATTN PA7 6 9 PA4 TWI-SCL
|
||||||
; TWI-SDA PA6 7 8 PA5
|
; TWI-SDA PA6 7 8 PA5
|
||||||
; --------
|
; --------
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
.include "../defs.asm"
|
.include "../defs.asm"
|
||||||
.include "./data.asm"
|
.include "./data.asm"
|
||||||
|
|
||||||
|
.include "version.asm"
|
||||||
.include "devices/all/defs.asm"
|
.include "devices/all/defs.asm"
|
||||||
.include "common/utils_wait.asm"
|
.include "common/utils_wait.asm"
|
||||||
|
|
||||||
@@ -55,11 +56,6 @@
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; firmware settings including list of modules used
|
; firmware settings including list of modules used
|
||||||
|
|
||||||
.equ FIRMWARE_VERSION_MAJOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_MINOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_PATCHLEVEL = 1
|
|
||||||
|
|
||||||
|
|
||||||
; #define MODULES_TIMER
|
; #define MODULES_TIMER
|
||||||
#define MODULES_CLOCK
|
#define MODULES_CLOCK
|
||||||
#define MODULES_LED_SIMPLE
|
#define MODULES_LED_SIMPLE
|
||||||
|
|||||||
2
avr/devices/n25/.gitignore
vendored
Normal file
2
avr/devices/n25/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*.eep.hex
|
||||||
|
*.obj
|
||||||
21
avr/devices/n25/0BUILD
Normal file
21
avr/devices/n25/0BUILD
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml?>
|
||||||
|
|
||||||
|
<gwbuild>
|
||||||
|
|
||||||
|
<subdirs>
|
||||||
|
boot
|
||||||
|
main
|
||||||
|
</subdirs>
|
||||||
|
|
||||||
|
<data dist="true" install="$(datadir)/aqhome/devices/nodes">
|
||||||
|
aqua_n25.xml
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<extradist>
|
||||||
|
defs.asm
|
||||||
|
README
|
||||||
|
</extradist>
|
||||||
|
|
||||||
|
|
||||||
|
</gwbuild>
|
||||||
|
|
||||||
18
avr/devices/n25/README
Normal file
18
avr/devices/n25/README
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
N25
|
||||||
|
===
|
||||||
|
|
||||||
|
- Role: LED strip controller
|
||||||
|
- MCU: AtTiny84
|
||||||
|
- Connection: RJ45
|
||||||
|
- Predecessor: N22, N16
|
||||||
|
- UART: uart_bitbang2
|
||||||
|
- Periphery:
|
||||||
|
- LED strip connection (SK6812)
|
||||||
|
- OWI interface
|
||||||
|
- DS18B20 temperature sensor
|
||||||
|
- Apps:
|
||||||
|
- NETWORK: Basic network functionality (address setup etc.)
|
||||||
|
- REPORTSENSORS: report sensor data from temperature sensor etc.
|
||||||
|
- STATS : periodically send stats data
|
||||||
|
- MA_LIGHT : motion activated light
|
||||||
33
avr/devices/n25/aqua_n25.xml
Normal file
33
avr/devices/n25/aqua_n25.xml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
<device name="aqua_n25" driver="nodes">
|
||||||
|
<manufacturer>AQUA</manufacturer>
|
||||||
|
<devicetype>N</devicetype>
|
||||||
|
<deviceversion>25</deviceversion>
|
||||||
|
|
||||||
|
<values>
|
||||||
|
<value name="DS18B20_TEMP" id="0x06" type="sensor" dataType="rational" modality="temperature" units="C" denom="16" />
|
||||||
|
|
||||||
|
<value name="NUMLEDS" id="0x82" type="actor" dataType="int" />
|
||||||
|
<value name="RGBWVALUE" id="0x83" type="actor" dataType="dword" />
|
||||||
|
|
||||||
|
<value name="MALRGBWVALUE" id="0x84" type="actor" dataType="dword" />
|
||||||
|
<value name="MALONTIME" id="0x85" type="actor" dataType="uint16" />
|
||||||
|
<value name="MALSOURCE1" id="0x86" type="actor" dataType="uint16" />
|
||||||
|
<value name="MALSOURCE2" id="0x87" 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" />
|
||||||
|
|
||||||
|
<value name="LEDTIMING" id="0x88" type="actor" dataType="uint16" />
|
||||||
|
</values>
|
||||||
|
|
||||||
|
</device>
|
||||||
32
avr/devices/n25/boot/0BUILD
Normal file
32
avr/devices/n25/boot/0BUILD
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml?>
|
||||||
|
|
||||||
|
<gwbuild>
|
||||||
|
|
||||||
|
<target type="AvrHexFile" name="n22_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>
|
||||||
|
|
||||||
|
|
||||||
136
avr/devices/n25/boot/boot.asm
Normal file
136
avr/devices/n25/boot/boot.asm
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
; ***************************************************************************
|
||||||
|
; Source file for base system node on AtTiny 84
|
||||||
|
;
|
||||||
|
; This is for the maintenance system (i.e. the flash loader).
|
||||||
|
;
|
||||||
|
; All definitions and changes should go into this file.
|
||||||
|
;
|
||||||
|
;
|
||||||
|
; ***************************************************************************
|
||||||
|
|
||||||
|
.equ clock=1000000 ; Define the clock frequency
|
||||||
|
|
||||||
|
.nolist
|
||||||
|
.include "include/tn84def.inc" ; Define device ATtiny84
|
||||||
|
.list
|
||||||
|
|
||||||
|
.include "version.asm"
|
||||||
|
.include "../defs.asm"
|
||||||
|
.include "devices/all/defs.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; defines
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; generic
|
||||||
|
|
||||||
|
.include "common/utils_wait.asm"
|
||||||
|
.include "modules/com2/defs.asm"
|
||||||
|
.include "modules/comproto/defs.asm"
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; firmware settings
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; LED
|
||||||
|
|
||||||
|
.equ LED_DDR = DDRA
|
||||||
|
.equ LED_PORT = PORTA
|
||||||
|
.equ LED_PIN = PINA
|
||||||
|
.equ LED_PINNUM = PORTA3
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; code segment
|
||||||
|
|
||||||
|
.cseg
|
||||||
|
.org 0x0000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; Reset and interrupt vectors
|
||||||
|
rjmp main ; Reset vector
|
||||||
|
reti ; EXT_INT0
|
||||||
|
reti ; PCI0
|
||||||
|
reti ; OC1A
|
||||||
|
reti ; OVF1
|
||||||
|
reti ; OVF0
|
||||||
|
reti ; ERDY
|
||||||
|
reti ; ACI
|
||||||
|
reti ; ADCC
|
||||||
|
reti ; OC1B
|
||||||
|
reti ; OC0A
|
||||||
|
reti ; OC0B
|
||||||
|
reti ; WATCHDOG
|
||||||
|
reti ; USI_STR
|
||||||
|
reti ; USI_OVF
|
||||||
|
|
||||||
|
devInfoBlock: ; 12 bytes
|
||||||
|
devInfoManufacturer: .db 'A', 'Q', 'U', 'A'
|
||||||
|
devInfoId: .db DEVICEINFO_ID, 0
|
||||||
|
devInfoVersion: .db DEVICEINFO_VERSION, DEVICEINFO_REVISION ; version, revision
|
||||||
|
firmwareVersion: .db FIRMWARE_VARIANT_BOOT, FIRMWARE_VERSION_MAJOR
|
||||||
|
.db FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCHLEVEL
|
||||||
|
|
||||||
|
firmwareStart: rjmp main ; will be overwritten when flashing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; main code
|
||||||
|
|
||||||
|
|
||||||
|
.org BOOTLOADER_ADDR
|
||||||
|
|
||||||
|
|
||||||
|
main:
|
||||||
|
rjmp bootLoader ; this routine is in modules/bootloader/main.asm
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; includes
|
||||||
|
|
||||||
|
.include "common/utils_wait_fixed.asm"
|
||||||
|
.include "common/utils_copy_from_flash.asm"
|
||||||
|
.include "common/utils_copy_sdram.asm"
|
||||||
|
|
||||||
|
.include "modules/flash/defs.asm"
|
||||||
|
.include "modules/flash/eeprom.asm"
|
||||||
|
.include "modules/flash/io.asm"
|
||||||
|
.include "modules/flash/io_attn.asm"
|
||||||
|
.include "modules/flash/io_bitbang.asm"
|
||||||
|
.include "modules/flash/flashxp.asm"
|
||||||
|
.include "modules/flash/flash1p.asm"
|
||||||
|
.include "modules/flash/flashprocess.asm"
|
||||||
|
.include "modules/flash/wait.asm"
|
||||||
|
.include "modules/bootloader/main.asm"
|
||||||
|
.include "modules/network/msg/defs.asm"
|
||||||
|
.include "modules/network/msg/crc.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
systemSetSpeed:
|
||||||
|
.if clock == 8000000
|
||||||
|
ldi r16, (1<<CLKPCE)
|
||||||
|
ldi r17, 0
|
||||||
|
out CLKPR, r16
|
||||||
|
out CLKPR, r17
|
||||||
|
.endif
|
||||||
|
|
||||||
|
.if clock == 1000000
|
||||||
|
ldi r16, (1<<CLKPCE)
|
||||||
|
ldi r17, (1<<CLKPS1) | (1<<CLKPS0)
|
||||||
|
out CLKPR, r16
|
||||||
|
out CLKPR, r17
|
||||||
|
.endif
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
90
avr/devices/n25/defs.asm
Normal file
90
avr/devices/n25/defs.asm
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
; ***************************************************************************
|
||||||
|
; 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. *
|
||||||
|
; ***************************************************************************
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
;
|
||||||
|
; AtTiny84
|
||||||
|
; --------
|
||||||
|
; VCC 1 14 GND
|
||||||
|
; OWI PB0 2 13 PA0
|
||||||
|
; PB1 3 12 PA1 COM-DATA
|
||||||
|
; PB3 4 11 PA2
|
||||||
|
; PB2 5 10 PA3 LED
|
||||||
|
; COM_ATTN PA7 6 9 PA4 LED_CLK
|
||||||
|
; LED_DATA PA6 7 8 PA5
|
||||||
|
; --------
|
||||||
|
;
|
||||||
|
; ***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.equ BOOTLOADER_ADDR = 0xd00
|
||||||
|
|
||||||
|
|
||||||
|
.equ FIRMWARE_VARIANT_BOOT = 0
|
||||||
|
.equ FIRMWARE_VARIANT_LEDSTRIPS = 1
|
||||||
|
|
||||||
|
.equ DEVICEINFO_ID = 'N'
|
||||||
|
.equ DEVICEINFO_VERSION = 25
|
||||||
|
.equ DEVICEINFO_REVISION = 0
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; LED module
|
||||||
|
|
||||||
|
.equ LED_SIMPLE_ONTIME = 1
|
||||||
|
.equ LED_SIMPLE_OFFTIME = 50
|
||||||
|
.equ LED_SIMPLE_DDR = DDRA
|
||||||
|
.equ LED_SIMPLE_PORT = PORTA
|
||||||
|
.equ LED_SIMPLE_PORTIN = PINA
|
||||||
|
.equ LED_SIMPLE_PINNUM = PORTA3
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; 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 = DDRA
|
||||||
|
.equ COM_DATA_INPUT = PINA
|
||||||
|
.equ COM_DATA_OUTPUT = PORTA
|
||||||
|
.equ COM_DATA_PIN = PORTA1
|
||||||
|
|
||||||
|
.equ COM_ATTN_DDR = DDRA
|
||||||
|
.equ COM_ATTN_INPUT = PINA
|
||||||
|
.equ COM_ATTN_OUTPUT = PORTA
|
||||||
|
.equ COM_ATTN_PIN = PORTA7
|
||||||
|
|
||||||
|
.equ COM_IRQ_ADDR_ATTN = PCMSK0
|
||||||
|
.equ COM_IRQ_BIT_ATTN = PCINT7 ; bit 7 in PCMSK0 (PCINT7)
|
||||||
|
.equ COM_IRQ_GIFR_ATTN = PCIF0
|
||||||
|
.equ COM_IRQ_GIMSK_ATTN = PCIE0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; 1-Wire Master
|
||||||
|
;
|
||||||
|
|
||||||
|
.equ OWI_DDR = DDRB
|
||||||
|
.equ OWI_PORTOUT = PORTB
|
||||||
|
.equ OWI_PORTIN = PINB
|
||||||
|
.equ OWI_PINNUM = PORTB0
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; SK6812
|
||||||
|
|
||||||
|
.equ SK6812_DDR = DDRA
|
||||||
|
.equ SK6812_PORT = PORTA
|
||||||
|
.equ SK6812_PINNUM = PORTA6
|
||||||
|
|
||||||
|
|
||||||
33
avr/devices/n25/main/0BUILD
Normal file
33
avr/devices/n25/main/0BUILD
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?xml?>
|
||||||
|
|
||||||
|
<gwbuild>
|
||||||
|
|
||||||
|
<target type="AvrHexFile" name="n22_firmware" >
|
||||||
|
|
||||||
|
<includes type="avrasm" >
|
||||||
|
-I $(builddir)
|
||||||
|
-I $(srcdir)
|
||||||
|
-I $(topsrcdir)/avr
|
||||||
|
-I $(topbuilddir)/avr
|
||||||
|
</includes>
|
||||||
|
|
||||||
|
|
||||||
|
<sources type="avrasm" >
|
||||||
|
main.asm
|
||||||
|
</sources>
|
||||||
|
|
||||||
|
|
||||||
|
</target>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<subdirs>
|
||||||
|
</subdirs>
|
||||||
|
|
||||||
|
<extradist>
|
||||||
|
</extradist>
|
||||||
|
|
||||||
|
|
||||||
|
</gwbuild>
|
||||||
|
|
||||||
|
|
||||||
205
avr/devices/n25/main/main.asm
Normal file
205
avr/devices/n25/main/main.asm
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
; ***************************************************************************
|
||||||
|
; copyright : (C) 2025 by Martin Preuss
|
||||||
|
; email : martin@libchipcard.de
|
||||||
|
;
|
||||||
|
; ***************************************************************************
|
||||||
|
; * This file is part of the project "AqHome". *
|
||||||
|
; * Please see toplevel file COPYING of that project for license details. *
|
||||||
|
; ***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; Source file for LED controller node on AtTiny 84
|
||||||
|
;
|
||||||
|
; This is for the full system (i.e. not the boot loader).
|
||||||
|
; ***************************************************************************
|
||||||
|
|
||||||
|
.equ clock=8000000 ; Define the clock frequency
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.nolist
|
||||||
|
.include "include/tn84def.inc" ; Define device ATtiny84
|
||||||
|
.list
|
||||||
|
|
||||||
|
.include "version.asm"
|
||||||
|
.include "../defs.asm"
|
||||||
|
;.include "./data.asm"
|
||||||
|
|
||||||
|
.include "devices/all/defs.asm"
|
||||||
|
.include "common/utils_wait.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; defines
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; generic
|
||||||
|
|
||||||
|
.equ NET_BUFFERS_NUM = 6
|
||||||
|
.equ NET_BUFFERS_SIZE = 32
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; firmware settings including list of modules used
|
||||||
|
|
||||||
|
|
||||||
|
#define MODULES_CLOCK
|
||||||
|
#define MODULES_LED_SIMPLE
|
||||||
|
#define MODULES_NETWORK
|
||||||
|
#define MODULES_UART_BITBANG
|
||||||
|
#define MODULES_OWI_MASTER
|
||||||
|
#define MODULES_DS18B20
|
||||||
|
#define MODULES_SK6812
|
||||||
|
;#define MODULES_MOTION_LIGHT
|
||||||
|
|
||||||
|
#define APPS_NETWORK
|
||||||
|
#define APPS_REPORTSENSORS
|
||||||
|
#define APPS_STATS
|
||||||
|
#define APPS_MA_LIGHT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; defines for modules
|
||||||
|
|
||||||
|
;.equ VALUE_ID_SI7021_TEMP = 0x01
|
||||||
|
;.equ VALUE_ID_SI7021_HUM = 0x02
|
||||||
|
|
||||||
|
;.equ VALUE_ID_ADC = 0x03
|
||||||
|
;.equ VALUE_ID_REED1 = 0x04
|
||||||
|
;.equ VALUE_ID_REED2 = 0x05
|
||||||
|
.equ VALUE_ID_DS18B20_TEMP = 0x06
|
||||||
|
|
||||||
|
;.equ VALUE_ID_REED_CONF = 0x81
|
||||||
|
.equ VALUE_ID_LED_NUMLEDS = 0x82
|
||||||
|
.equ VALUE_ID_LED_RGBW_VALUE = 0x83
|
||||||
|
.equ VALUE_ID_MAL_RGBW_VALUE = 0x84
|
||||||
|
.equ VALUE_ID_MAL_ONTIME = 0x85
|
||||||
|
.equ VALUE_ID_MAL_SOURCE1 = 0x86
|
||||||
|
.equ VALUE_ID_MAL_SOURCE2 = 0x87
|
||||||
|
|
||||||
|
.equ VALUE_ID_LEDSIMPLE_TIMING = 0x88
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; code segment
|
||||||
|
|
||||||
|
.cseg
|
||||||
|
.org 000000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; Reset and interrupt vectors
|
||||||
|
|
||||||
|
rjmp BOOTLOADER_ADDR ; Reset vector ; use this for flashed system
|
||||||
|
reti ; EXT_INT0
|
||||||
|
rjmp UART_BitBang_PcintIsr ; PCI0
|
||||||
|
reti ; OC1A
|
||||||
|
reti ; OVF1
|
||||||
|
reti ; OVF0
|
||||||
|
reti ; ERDY
|
||||||
|
reti ; ACI
|
||||||
|
reti ; ADCC
|
||||||
|
reti ; OC1B
|
||||||
|
rjmp baseTimerIrqOC0A ; OC0A
|
||||||
|
reti ; OC0B
|
||||||
|
reti ; WATCHDOG
|
||||||
|
reti ; USI_STR
|
||||||
|
reti ; USI_OVF
|
||||||
|
|
||||||
|
|
||||||
|
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_LEDSTRIPS, FIRMWARE_VERSION_MAJOR
|
||||||
|
.db FIRMWARE_VERSION_MINOR, FIRMWARE_VERSION_PATCHLEVEL
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine firmwareStart @global
|
||||||
|
|
||||||
|
firmwareStart:
|
||||||
|
rjmp main
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine onSystemStart
|
||||||
|
|
||||||
|
onSystemStart:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine onMessageReceived
|
||||||
|
;
|
||||||
|
; Called on every message received
|
||||||
|
|
||||||
|
onMessageReceived:
|
||||||
|
clc
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine onEvery100ms
|
||||||
|
;
|
||||||
|
; Called every 100ms. Add your routine calls here. No arguments, no results.
|
||||||
|
|
||||||
|
onEvery100ms:
|
||||||
|
onEveryMinute:
|
||||||
|
onEveryHour:
|
||||||
|
onEveryDay:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
onEverySecond:
|
||||||
|
ret
|
||||||
|
; debug
|
||||||
|
ldi r19, 0x00 ; G
|
||||||
|
ldi r18, 0xff ; R
|
||||||
|
ldi r20, 0x55 ; B
|
||||||
|
ldi r21, 0xaa ; W
|
||||||
|
rcall SK6812_SetAllColor ; r23 (r16, r17)
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine onEveryLoop
|
||||||
|
;
|
||||||
|
; Called on every loop (i.e. after awakening from sleep).
|
||||||
|
;
|
||||||
|
onEveryLoop:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; includes
|
||||||
|
|
||||||
|
.include "devices/all/hw_tn84.asm"
|
||||||
|
.include "devices/all/includes.asm"
|
||||||
|
.include "common/debug.asm"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; defines for network interface
|
||||||
|
|
||||||
|
.equ netInterfaceData = uart_bitbang_iface
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -30,8 +30,10 @@
|
|||||||
.list
|
.list
|
||||||
|
|
||||||
.include "../defs.asm"
|
.include "../defs.asm"
|
||||||
.include "defs_all.asm"
|
.include "version.asm"
|
||||||
|
;.include "defs_all.asm"
|
||||||
|
|
||||||
|
.include "devices/all/defs.asm"
|
||||||
.include "common/utils_wait.asm"
|
.include "common/utils_wait.asm"
|
||||||
.include "common/utils_io.asm"
|
.include "common/utils_io.asm"
|
||||||
|
|
||||||
@@ -47,10 +49,6 @@
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; firmware settings including list of modules used
|
; firmware settings including list of modules used
|
||||||
|
|
||||||
.equ FIRMWARE_VERSION_MAJOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_MINOR = 0
|
|
||||||
.equ FIRMWARE_VERSION_PATCHLEVEL = 1
|
|
||||||
|
|
||||||
|
|
||||||
#define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes
|
#define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ bootLoader:
|
|||||||
sbi LED_DDR, LED_PINNUM ; out
|
sbi LED_DDR, LED_PINNUM ; out
|
||||||
sbi LED_PORT, LED_PINNUM ; off
|
sbi LED_PORT, LED_PINNUM ; off
|
||||||
|
|
||||||
ldi r19, 20 ; loop count
|
ldi r19, 10 ; loop count
|
||||||
ldi r20, 2 ; on time
|
ldi r20, 2 ; on time
|
||||||
ldi r21, 2 ; off time
|
ldi r21, 2 ; off time
|
||||||
rcall bootLoaderBlinkLed
|
rcall bootLoaderBlinkLed
|
||||||
@@ -66,13 +66,13 @@ bootLoader:
|
|||||||
brcc bootLoader_waitAndRestartBootLoader
|
brcc bootLoader_waitAndRestartBootLoader
|
||||||
; try to start firmware
|
; try to start firmware
|
||||||
bootLoader_startFirmware:
|
bootLoader_startFirmware:
|
||||||
ldi r19, 10 ; loop count
|
ldi r19, 6 ; loop count
|
||||||
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
|
rjmp firmwareStart
|
||||||
bootLoader_waitAndRestartBootLoader:
|
bootLoader_waitAndRestartBootLoader:
|
||||||
ldi r19, 5 ; loop count
|
ldi r19, 3 ; loop count
|
||||||
ldi r20, 1 ; on time
|
ldi r20, 1 ; on time
|
||||||
ldi r21, 8 ; off time
|
ldi r21, 8 ; off time
|
||||||
rcall bootLoaderBlinkLed
|
rcall bootLoaderBlinkLed
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ ioRecvMsg:
|
|||||||
pop xl
|
pop xl
|
||||||
brcs ioRecvMsg_end
|
brcs ioRecvMsg_end
|
||||||
ioRecvMsg_error:
|
ioRecvMsg_error:
|
||||||
rcall ioRecvSkipMessage ; skip remainder of the message
|
; rcall ioRecvSkipMessage ; skip remainder of the message
|
||||||
clc
|
clc
|
||||||
ioRecvMsg_end:
|
ioRecvMsg_end:
|
||||||
ret
|
ret
|
||||||
@@ -267,6 +267,7 @@ ioRecvMsg_end:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; @routine ioRecvSkipMessage
|
; @routine ioRecvSkipMessage
|
||||||
;
|
;
|
||||||
@@ -299,6 +300,7 @@ ioRecvFlush:
|
|||||||
M_IO_READ r16, UART_REG_UDR ; read data byte
|
M_IO_READ r16, UART_REG_UDR ; read data byte
|
||||||
rjmp ioRecvFlush
|
rjmp ioRecvFlush
|
||||||
; @end
|
; @end
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -322,9 +324,9 @@ ioRawRecvMsg:
|
|||||||
; read first two bytes
|
; read first two bytes
|
||||||
ldi r17, 2 ; 2 bytes: address byte, msg len
|
ldi r17, 2 ; 2 bytes: address byte, msg len
|
||||||
add r19, r17
|
add r19, r17
|
||||||
rcall ioRawRecvBytes ; (r16, r17, r18, r22)
|
rcall ioRawRecvBytes ; (r16, r17, r20, r22)
|
||||||
brcc ioRawRecvMsg_error
|
brcc ioRawRecvMsg_error
|
||||||
cp r16, r20 ; check size
|
cp r16, r18 ; check size
|
||||||
brcc ioRawRecvMsg_error
|
brcc ioRawRecvMsg_error
|
||||||
inc r16 ; account for checksum byte
|
inc r16 ; account for checksum byte
|
||||||
; read remaining bytes including checksum byte
|
; read remaining bytes including checksum byte
|
||||||
@@ -475,7 +477,7 @@ ioRawWaitForData10ms_gotit:
|
|||||||
; @routine ioRawWaitForData1000Cycles
|
; @routine ioRawWaitForData1000Cycles
|
||||||
;
|
;
|
||||||
; Wait for incoming data for max 1000 clock cycles
|
; Wait for incoming data for max 1000 clock cycles
|
||||||
; (about 1ms at 1MHz, 0.125 at 8MHz)
|
; (about 1ms at 1MHz, 0.125ms at 8MHz)
|
||||||
;
|
;
|
||||||
; @return CFLAG set if okay (packet received), cleared on error
|
; @return CFLAG set if okay (packet received), cleared on error
|
||||||
; @clobbers: r20, r22
|
; @clobbers: r20, r22
|
||||||
|
|||||||
592
avr/modules/flash/io_uart_attn_small.asm
Normal file
592
avr/modules/flash/io_uart_attn_small.asm
Normal file
@@ -0,0 +1,592 @@
|
|||||||
|
; ***************************************************************************
|
||||||
|
; copyright : (C) 2025 by Martin Preuss
|
||||||
|
; email : martin@libchipcard.de
|
||||||
|
;
|
||||||
|
; ***************************************************************************
|
||||||
|
; * This file is part of the project "AqHome". *
|
||||||
|
; * Please see toplevel file COPYING of that project for license details. *
|
||||||
|
; ***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; code
|
||||||
|
|
||||||
|
|
||||||
|
.cseg
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ioRawInit
|
||||||
|
; Send a message
|
||||||
|
;
|
||||||
|
; @clobbers r16, r17
|
||||||
|
|
||||||
|
ioRawInit:
|
||||||
|
; set baudrate
|
||||||
|
.if clock == 8000000
|
||||||
|
ldi r16, 25 ; (19.2Kb/s at 8MHz)
|
||||||
|
ldi r17, 0
|
||||||
|
.endif
|
||||||
|
|
||||||
|
.if clock == 1000000
|
||||||
|
ldi r16, 3 ; (19.2Kb/s at 1MHz)
|
||||||
|
ldi r17, 0
|
||||||
|
.endif
|
||||||
|
|
||||||
|
outr UART_REG_UBRRH, r17
|
||||||
|
outr UART_REG_UBRRL, r16
|
||||||
|
|
||||||
|
; set character format (asynchronous USART, 8-bit, one stop bit, no parity)
|
||||||
|
.ifdef URSEL
|
||||||
|
ldi r16, (1<<URSEL) | (1<<UART_BIT_USBS) | (3<<UART_BIT_UCSZ0)
|
||||||
|
.else
|
||||||
|
ldi r16, (1<<UART_BIT_USBS)|(3<<UART_BIT_UCSZ0)
|
||||||
|
.endif
|
||||||
|
; ldi r16, (1<<UART_BIT_UCSZ0) | (1<<UART_BIT_UCSZ1)
|
||||||
|
outr UART_REG_UCSRC, r16
|
||||||
|
|
||||||
|
cbi COM_ATTN_DDR, COM_ATTN_PIN ; set ATTN port as input
|
||||||
|
|
||||||
|
.ifdef COM_ATTN_PUE
|
||||||
|
inr r16, COM_ATTN_PUE
|
||||||
|
cbr r16, COM_ATTN_PIN ; disable pullup on ATTN
|
||||||
|
outr COM_ATTN_PUE, r16
|
||||||
|
.else
|
||||||
|
cbi COM_ATTN_OUTPUT, COM_ATTN_PIN ; disable internal pullup for ATTN
|
||||||
|
.endif
|
||||||
|
|
||||||
|
ret
|
||||||
|
;@end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ioRawSendMsg
|
||||||
|
; Send a message
|
||||||
|
;
|
||||||
|
; @clobbers r16, r17, X
|
||||||
|
|
||||||
|
ioRawSendMsg:
|
||||||
|
ldi xl, LOW(flashSendBuffer)
|
||||||
|
ldi xh, HIGH(flashSendBuffer)
|
||||||
|
rcall ioRawSendMsgWithAttn
|
||||||
|
brcc ioRawSendMsg
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ioRawSendMsgWithAttn
|
||||||
|
;
|
||||||
|
; @param X buffer to send
|
||||||
|
; @return CFLAG: set if okay (packet sent), cleared on error
|
||||||
|
; @clobbers r16, r17 (X)
|
||||||
|
|
||||||
|
ioRawSendMsgWithAttn:
|
||||||
|
cbi COM_ATTN_DDR, COM_ATTN_PIN ; set ATTN as input
|
||||||
|
nop
|
||||||
|
|
||||||
|
ldi r16, 0xff ; wait for ATTN high
|
||||||
|
ldi r20, 2 ; 2s
|
||||||
|
rcall ioRawWaitForAttnSeconds
|
||||||
|
brcc ioRawSendMsgWithAttn_ret
|
||||||
|
|
||||||
|
sbi COM_ATTN_DDR, COM_ATTN_PIN ; set ATTN as output
|
||||||
|
cbi COM_ATTN_OUTPUT, COM_ATTN_PIN ; set ATTN low
|
||||||
|
|
||||||
|
rcall ioRawWaitForOneBitLength ; wait for one bit duration (R22)
|
||||||
|
rcall ioRawWaitForOneBitLength ; wait for one bit duration (R22)
|
||||||
|
|
||||||
|
rcall ioRawSendMsgHandleTransceiver ; (r16, r17, X)
|
||||||
|
cbi COM_ATTN_DDR, COM_ATTN_PIN ; release ATTN line (by setting direction to IN)
|
||||||
|
|
||||||
|
ioRawSendMsgWithAttn_ret:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ioRawSendMsgHandleTransceiver
|
||||||
|
; Enable transceiver, send packet, disable transceiver.
|
||||||
|
;
|
||||||
|
; @param X buffer to send
|
||||||
|
; @return CFLAG: set if okay (packet sent), cleared on error
|
||||||
|
; @clobbers r16 (r17, X)
|
||||||
|
|
||||||
|
ioRawSendMsgHandleTransceiver:
|
||||||
|
; enable transceiver
|
||||||
|
inr r16, UART_REG_UCSRB
|
||||||
|
sbr r16,(1<<UART_BIT_TXEN) ; enable transmit
|
||||||
|
outr UART_REG_UCSRB, r16
|
||||||
|
rcall ioRawSendMsgDirect
|
||||||
|
; disable transceiver
|
||||||
|
inr r16, UART_REG_UCSRB
|
||||||
|
cbr r16,(1<<UART_BIT_TXEN) ; disable transmit
|
||||||
|
outr UART_REG_UCSRB, r16
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ioRawSendMsgDirect
|
||||||
|
; Send packet.
|
||||||
|
;
|
||||||
|
; @param X buffer to send
|
||||||
|
; @return CFLAG: set if okay (packet sent), cleared on error
|
||||||
|
; @clobbers r16, r17, X
|
||||||
|
|
||||||
|
ioRawSendMsgDirect:
|
||||||
|
adiw xh:xl, 1
|
||||||
|
ld r17, X ; read msg size
|
||||||
|
sbiw xh:xl, 1
|
||||||
|
ldi r16, 3 ; add DEST, LEN, CRC bytes
|
||||||
|
add r17, r16
|
||||||
|
ioRawSendMsgDirect_loop:
|
||||||
|
; wait until transceiver ready
|
||||||
|
inr r16, UART_REG_UCSRA
|
||||||
|
sbrs r16, UART_BIT_UDRE
|
||||||
|
rjmp ioRawSendMsgDirect_loop
|
||||||
|
; clear TXC flag by sending a 1
|
||||||
|
sbr r16, (1<<UART_BIT_TXC)
|
||||||
|
outr UART_REG_UCSRA, r16
|
||||||
|
; write byte to uart data register
|
||||||
|
ld r16, X+
|
||||||
|
outr UART_REG_UDR, r16
|
||||||
|
dec r17
|
||||||
|
brne ioRawSendMsgDirect_loop
|
||||||
|
; wait until all data send (i.e. send buffer empty and all bits shifted out)
|
||||||
|
ioRawSendMsgDirect_loopComplete:
|
||||||
|
inr r16, UART_REG_UCSRA
|
||||||
|
sbrs r16, UART_BIT_TXC
|
||||||
|
rjmp ioRawSendMsgDirect_loopComplete
|
||||||
|
sec
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ioRawWaitForValidMsg
|
||||||
|
; Wait for valid incoming msg
|
||||||
|
;
|
||||||
|
; @return CFLAG set if okay (packet received), cleared on error
|
||||||
|
; @clobbers: r16, r17, r18 (r19, r22, X)
|
||||||
|
|
||||||
|
ioRawWaitForValidMsg:
|
||||||
|
; ATTN handling
|
||||||
|
cbi COM_ATTN_DDR, COM_ATTN_PIN ; set ATTN as input
|
||||||
|
nop
|
||||||
|
|
||||||
|
ldi r16, 0xff ; wait for ATTN high
|
||||||
|
ldi r20, 2 ; 2s
|
||||||
|
rcall ioRawWaitForAttnSeconds
|
||||||
|
brcc ioRawSendMsgWithAttn_ret
|
||||||
|
|
||||||
|
ldi r16, 0x00 ; wait for ATTN low
|
||||||
|
ldi r20, 10 ; 10s
|
||||||
|
rcall ioRawWaitForAttnSeconds
|
||||||
|
brcc ioRawSendMsgWithAttn_ret
|
||||||
|
|
||||||
|
; actual receiption
|
||||||
|
ldi xl, LOW(flashRecvBuffer)
|
||||||
|
ldi xh, HIGH(flashRecvBuffer)
|
||||||
|
ldi r18, FLASH_RECVBUFFER_MAXLEN-3 ; maximum accepted msglen byte
|
||||||
|
rcall ioRecvMsgHandleReceiver ; (r16, r17, r18, r19, r20, r22)
|
||||||
|
brcs ioRawWaitForValidMsg_packetReceived
|
||||||
|
; ATTN handling again
|
||||||
|
ldi r16, 0xff ; wait for ATTN high
|
||||||
|
ldi r20, 10 ; 5s
|
||||||
|
rcall ioRawWaitForAttnSeconds
|
||||||
|
clc
|
||||||
|
ret
|
||||||
|
ioRawWaitForValidMsg_packetReceived:
|
||||||
|
; ATTN handling again
|
||||||
|
ldi r16, 0xff ; wait for ATTN high
|
||||||
|
ldi r20, 10 ; 5s
|
||||||
|
rcall ioRawWaitForAttnSeconds
|
||||||
|
brcc ioRawWaitForValidMsg_end
|
||||||
|
ldi xl, LOW(flashRecvBuffer)
|
||||||
|
ldi xh, HIGH(flashRecvBuffer)
|
||||||
|
rcall NETMSG_CheckMessageInBuffer
|
||||||
|
ioRawWaitForValidMsg_end:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ioRecvMsgHandleReceiver
|
||||||
|
;
|
||||||
|
; Turn receiver on, receive message, turn receiver off.
|
||||||
|
; @return CFLAG set if okay, cleared on error
|
||||||
|
; @param r18 max accepted msglen size (buffersize-3)
|
||||||
|
; @param X buffer to receive to
|
||||||
|
; @clobbers r16 (r17, r18, r19, r20, r22)
|
||||||
|
|
||||||
|
ioRecvMsgHandleReceiver:
|
||||||
|
; enable receiver
|
||||||
|
inr r16, UART_REG_UCSRB
|
||||||
|
sbr r16,(1<<UART_BIT_RXEN) ; enable receive
|
||||||
|
outr UART_REG_UCSRB, r16
|
||||||
|
rcall ioRecvMsg
|
||||||
|
inr r16, UART_REG_UCSRB
|
||||||
|
cbr r16,(1<<UART_BIT_RXEN) ; disable receive
|
||||||
|
outr UART_REG_UCSRB, r16
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ioRecvMsg
|
||||||
|
;
|
||||||
|
; Wait for next message, if received check validity.
|
||||||
|
; On error skip the currently received message.
|
||||||
|
;
|
||||||
|
; @return CFLAG set if okay, cleared on error
|
||||||
|
; @param r18 max accepted msglen size (buffersize-3)
|
||||||
|
; @param R20 max number of secs to wait for incoming message
|
||||||
|
; @param X buffer to receive to
|
||||||
|
; @clobbers (r16, r17, r18, r19, r20, r22)
|
||||||
|
|
||||||
|
ioRecvMsg:
|
||||||
|
rcall ioRawRecvMsg ; (r16, r17, r18, r19, r20, r22)
|
||||||
|
brcc ioRecvMsg_error
|
||||||
|
push xl
|
||||||
|
push xh
|
||||||
|
rcall NETMSG_CheckMessageInBuffer ; (R16, R17, R18, R19, R20, X)
|
||||||
|
pop xh
|
||||||
|
pop xl
|
||||||
|
brcs ioRecvMsg_end
|
||||||
|
ioRecvMsg_error:
|
||||||
|
; rcall ioRecvSkipMessage ; skip remainder of the message
|
||||||
|
clc
|
||||||
|
ioRecvMsg_end:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ioRawRecvMsg
|
||||||
|
;
|
||||||
|
; @return CFLAG set if okay, cleared on error
|
||||||
|
; @param r18 max accepted msglen size (buffersize-3)
|
||||||
|
; @param X buffer to receive to
|
||||||
|
; @clobbers r16, r17, r19 (r18, r20, r22)
|
||||||
|
|
||||||
|
ioRawRecvMsg:
|
||||||
|
inr r19, UART_REG_UCSRA
|
||||||
|
cbr r19, (1<<UART_BIT_FE) | (1<<UART_BIT_DOR) | (1<<UART_BIT_UPE)
|
||||||
|
outr UART_REG_UCSRA, r19 ; clear errors
|
||||||
|
; wait for begin of message
|
||||||
|
rcall ioRawWaitForData1s ; (r20, r22)
|
||||||
|
brcc ioRawRecvMsg_end
|
||||||
|
clr r19 ; bytecounter
|
||||||
|
; read first two bytes
|
||||||
|
ldi r17, 2 ; 2 bytes: address byte, msg len
|
||||||
|
add r19, r17
|
||||||
|
rcall ioRawRecvBytes ; (r16, r17, r20, r22)
|
||||||
|
brcc ioRawRecvMsg_error
|
||||||
|
cp r16, r18 ; check size
|
||||||
|
brcc ioRawRecvMsg_error
|
||||||
|
inc r16 ; account for checksum byte
|
||||||
|
; read remaining bytes including checksum byte
|
||||||
|
mov r17, r16
|
||||||
|
add r19, r17
|
||||||
|
rcall ioRawRecvBytes ; (r16, r17, r18, r22)
|
||||||
|
brcc ioRawRecvMsg_error
|
||||||
|
sub xl, r19 ; let X point back to begin of message
|
||||||
|
sbc xh, r19
|
||||||
|
add xh, r19
|
||||||
|
sec
|
||||||
|
ret
|
||||||
|
ioRawRecvMsg_error:
|
||||||
|
clc
|
||||||
|
ioRawRecvMsg_end:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ioRawRecvBytes
|
||||||
|
;
|
||||||
|
; @return CFLAG set if okay (data available), cleared on error
|
||||||
|
; @return r16 last byte received
|
||||||
|
; @param r17 number of bytes to read
|
||||||
|
; @param x buffer to receive to
|
||||||
|
; @clobbers r16, r17 (r20, r22)
|
||||||
|
|
||||||
|
ioRawRecvBytes:
|
||||||
|
rcall ioRawRecvByteWithin10ms ; (r20, r22)
|
||||||
|
brcc ioRawRecvBytes_end
|
||||||
|
st X+, r16
|
||||||
|
dec r17
|
||||||
|
brne ioRawRecvBytes
|
||||||
|
sec
|
||||||
|
ioRawRecvBytes_end:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ioRawRecvByteWithin10ms
|
||||||
|
;
|
||||||
|
; Wait up to 10ms for incoming byte and read it.
|
||||||
|
;
|
||||||
|
; @return CFLAG set if okay (data available), cleared on error
|
||||||
|
; @return r16 byte received (if CFLAG set)
|
||||||
|
; @clobbers: r20, r22
|
||||||
|
|
||||||
|
ioRawRecvByteWithin10ms:
|
||||||
|
rcall ioRawWaitForData10ms ; (R20, R22)
|
||||||
|
brcc ioRawRecvByteWithin10ms_end
|
||||||
|
inr r16, UART_REG_UCSRA ; check for errors
|
||||||
|
andi r16, (1<<UART_BIT_FE) | (1<<UART_BIT_DOR) | (1<<UART_BIT_UPE)
|
||||||
|
brne ioRawRecvByteWithin10ms_error
|
||||||
|
inr r16, UART_REG_UDR ; read data byte
|
||||||
|
sec
|
||||||
|
ret
|
||||||
|
ioRawRecvByteWithin10ms_error:
|
||||||
|
clc
|
||||||
|
ioRawRecvByteWithin10ms_end:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ioRawWaitForDataSeconds
|
||||||
|
;
|
||||||
|
; Wait for incoming data for max given seconds
|
||||||
|
;
|
||||||
|
; @return CFLAG set if okay (data available), cleared on error
|
||||||
|
; @param r20 maximum number of seconds to wait
|
||||||
|
; @clobbers: r20, r22
|
||||||
|
|
||||||
|
ioRawWaitForDataSeconds:
|
||||||
|
ioRawWaitForDataSeconds_loop:
|
||||||
|
push r20
|
||||||
|
rcall ioRawWaitForData1s ; (r20, r22)
|
||||||
|
pop r20
|
||||||
|
brcs ioRawWaitForDataSeconds_gotit
|
||||||
|
sbi LED_PIN, LED_PINNUM ; toggle (doen't work on AtMega8515)
|
||||||
|
dec r20
|
||||||
|
brne ioRawWaitForDataSeconds_loop
|
||||||
|
clc
|
||||||
|
ioRawWaitForDataSeconds_gotit:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ioRawWaitForData1s
|
||||||
|
;
|
||||||
|
; Wait for incoming data for max 1s
|
||||||
|
;
|
||||||
|
; @return CFLAG set if okay (data available), cleared on error
|
||||||
|
; @clobbers: r20, r22
|
||||||
|
|
||||||
|
ioRawWaitForData1s:
|
||||||
|
ldi r20, 100
|
||||||
|
ioRawWaitForData1s_loop:
|
||||||
|
push r20
|
||||||
|
rcall ioRawWaitForData10ms ; (R20, R22)
|
||||||
|
pop r20
|
||||||
|
brcs ioRawWaitForData1s_gotit
|
||||||
|
dec r20
|
||||||
|
brne ioRawWaitForData1s_loop
|
||||||
|
clc
|
||||||
|
ioRawWaitForData1s_gotit:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ioRawWaitForData10ms
|
||||||
|
;
|
||||||
|
; Wait for incoming data for max 10 milliseconds.
|
||||||
|
;
|
||||||
|
; @return CFLAG set if okay (data available), cleared on error
|
||||||
|
; @clobbers: r20, r22
|
||||||
|
|
||||||
|
ioRawWaitForData10ms:
|
||||||
|
.if clock == 8000000
|
||||||
|
ldi r20, 80
|
||||||
|
.endif
|
||||||
|
.if clock == 1000000
|
||||||
|
ldi r20, 10
|
||||||
|
.endif
|
||||||
|
ioRawWaitForData10ms_loop:
|
||||||
|
push r20
|
||||||
|
rcall ioRawWaitForData1000Cycles ; (r20, r22)
|
||||||
|
pop r20
|
||||||
|
brcs ioRawWaitForData10ms_gotit
|
||||||
|
dec r20
|
||||||
|
brne ioRawWaitForData10ms_loop
|
||||||
|
clc
|
||||||
|
ioRawWaitForData10ms_gotit:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ioRawWaitForData1000Cycles
|
||||||
|
;
|
||||||
|
; Wait for incoming data for max 1000 clock cycles
|
||||||
|
; (about 1ms at 1MHz, 0.125ms at 8MHz)
|
||||||
|
;
|
||||||
|
; @return CFLAG set if okay (packet received), cleared on error
|
||||||
|
; @clobbers: r20, r22
|
||||||
|
|
||||||
|
ioRawWaitForData1000Cycles:
|
||||||
|
ldi r20, 140 ; 1
|
||||||
|
ioRawWaitForData_loop:
|
||||||
|
inr r22, UART_REG_UCSRA ; 2
|
||||||
|
sbrc r22, UART_BIT_RXC ; 2/3
|
||||||
|
rjmp ioRawWaitForData_gotit ; 2
|
||||||
|
dec r20 ; 1
|
||||||
|
brne ioRawWaitForData_loop ; 1/2 -> 7 per loop, max about 1000
|
||||||
|
clc ; 1
|
||||||
|
ret ; 4
|
||||||
|
ioRawWaitForData_gotit:
|
||||||
|
sec ; 1
|
||||||
|
ret ; 4
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ioRawWaitForAttnSeconds
|
||||||
|
;
|
||||||
|
; Wait for ATTN state max given seconds
|
||||||
|
;
|
||||||
|
; @return CFLAG set if okay (data available), cleared on error
|
||||||
|
; @param R16 expected state (0xff for high, 0 for low)
|
||||||
|
; @param r20 maximum number of seconds to wait
|
||||||
|
; @clobbers: r20, r22
|
||||||
|
|
||||||
|
ioRawWaitForAttnSeconds:
|
||||||
|
ioRawWaitForAttnSeconds_loop:
|
||||||
|
push r20
|
||||||
|
rcall ioRawWaitForAttn1s ; (r20, r22)
|
||||||
|
pop r20
|
||||||
|
brcs ioRawWaitForAttnSeconds_gotit
|
||||||
|
sbi LED_PIN, LED_PINNUM ; toggle (doen't work on AtMega8515)
|
||||||
|
dec r20
|
||||||
|
brne ioRawWaitForAttnSeconds_loop
|
||||||
|
clc
|
||||||
|
ioRawWaitForAttnSeconds_gotit:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ioRawWaitForAttn1s
|
||||||
|
;
|
||||||
|
; Wait for ATTN state for max 1s
|
||||||
|
;
|
||||||
|
; @param R16 expected state (0xff for high, 0 for low)
|
||||||
|
; @return CFLAG set if okay (ATTN state reached), cleared on error
|
||||||
|
; @clobbers: r20, r22
|
||||||
|
|
||||||
|
ioRawWaitForAttn1s:
|
||||||
|
ldi r20, 100
|
||||||
|
ioRawWaitForAttn1s_loop:
|
||||||
|
push r20
|
||||||
|
rcall ioRawWaitForAttn10ms ; (R20, R22)
|
||||||
|
pop r20
|
||||||
|
brcs ioRawWaitForAttn1s_gotit
|
||||||
|
dec r20
|
||||||
|
brne ioRawWaitForAttn1s_loop
|
||||||
|
clc
|
||||||
|
ioRawWaitForAttn1s_gotit:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ioRawWaitForAttn10ms
|
||||||
|
;
|
||||||
|
; Wait for ATTN state for max 10 milliseconds.
|
||||||
|
;
|
||||||
|
; @param R16 expected state (0xff for high, 0 for low)
|
||||||
|
; @return CFLAG set if okay (ATTN state reached), cleared on error
|
||||||
|
; @clobbers: r20, r22
|
||||||
|
|
||||||
|
ioRawWaitForAttn10ms:
|
||||||
|
.if clock == 8000000
|
||||||
|
ldi r20, 80
|
||||||
|
.endif
|
||||||
|
.if clock == 1000000
|
||||||
|
ldi r20, 10
|
||||||
|
.endif
|
||||||
|
ioRawWaitForAttn10ms_loop:
|
||||||
|
push r20
|
||||||
|
rcall ioRawWaitForAttn1000Cycles ; (r20, r22)
|
||||||
|
pop r20
|
||||||
|
brcs ioRawWaitForAttn10ms_gotit
|
||||||
|
dec r20
|
||||||
|
brne ioRawWaitForAttn10ms_loop
|
||||||
|
clc
|
||||||
|
ioRawWaitForAttn10ms_gotit:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ioRawWaitForAttnState1000Cycles
|
||||||
|
;
|
||||||
|
; Wait for ATTN state for max 1000 clock cycles
|
||||||
|
; (about 1ms at 1MHz, 0.125ms at 8MHz)
|
||||||
|
;
|
||||||
|
; @param R16 expected state (0xff for high, 0 for low)
|
||||||
|
; @return CFLAG set if okay (packet received), cleared on error
|
||||||
|
; @clobbers: r20, r22
|
||||||
|
|
||||||
|
ioRawWaitForAttn1000Cycles:
|
||||||
|
ldi r20, 90 ; 1
|
||||||
|
ioRawWaitForAttn1000Cycles_loop:
|
||||||
|
push r17 ; +2
|
||||||
|
in r17, COM_ATTN_INPUT ; +1
|
||||||
|
eor r17, r16 ; +1
|
||||||
|
andi r17, (1<<COM_ATTN_PIN) ; +1
|
||||||
|
pop r17 ; +2
|
||||||
|
breq ioRawWaitForAttn1000Cycles_stateReached ; +1
|
||||||
|
dec r20 ; +1
|
||||||
|
brne ioRawWaitForAttn1000Cycles_loop ; +2
|
||||||
|
clc
|
||||||
|
ret
|
||||||
|
ioRawWaitForAttn1000Cycles_stateReached:
|
||||||
|
sec
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ioRawWaitForOneBitLength
|
||||||
|
;
|
||||||
|
; wait for one bit length (minus cycles for call and ret).
|
||||||
|
;
|
||||||
|
; @clobbers r22
|
||||||
|
|
||||||
|
ioRawWaitForOneBitLength:
|
||||||
|
Utils_WaitNanoSecs COM_BIT_LENGTH, 7, r22 ; wait for one bit duration (minus RCALL/RET)
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -7,16 +7,27 @@
|
|||||||
; * Please see toplevel file COPYING of that project for license details. *
|
; * Please see toplevel file COPYING of that project for license details. *
|
||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
; Needed vars:
|
; Needed vars:
|
||||||
; - HEAP_START
|
; - HEAP_START
|
||||||
; - HEAP_SIZE
|
; - HEAP_SIZE
|
||||||
|
|
||||||
|
|
||||||
.equ HEAP_HEADER_BIT_USED = 1
|
; ***************************************************************************
|
||||||
|
; defines
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.equ HEAP_HEADER_BIT_USED = 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; data
|
||||||
|
|
||||||
.dseg
|
.dseg
|
||||||
|
|
||||||
|
|
||||||
heapPtr: .byte 2
|
heapPtr: .byte 2
|
||||||
heapUsed: .byte 2
|
heapUsed: .byte 2
|
||||||
heapFree: .byte 2
|
heapFree: .byte 2
|
||||||
@@ -24,6 +35,8 @@ heapDblFree: .byte 1
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; code
|
||||||
|
|
||||||
.cseg
|
.cseg
|
||||||
|
|
||||||
@@ -43,7 +56,7 @@ Heap_Init:
|
|||||||
st X+, r16 ; write start header
|
st X+, r16 ; write start header
|
||||||
st X+, r16
|
st X+, r16
|
||||||
sts heapPtr, xl ; store global vars
|
sts heapPtr, xl ; store global vars
|
||||||
sts heapPtr+1, xl
|
sts heapPtr+1, xh
|
||||||
sts heapFree, r24
|
sts heapFree, r24
|
||||||
sts heapFree+1, r25
|
sts heapFree+1, r25
|
||||||
st X+, r24 ; store header of first chunk
|
st X+, r24 ; store header of first chunk
|
||||||
@@ -80,9 +93,10 @@ heapAllocFirstFit_loop:
|
|||||||
mov r16, r18 ; heap end reached?
|
mov r16, r18 ; heap end reached?
|
||||||
or r16, r19
|
or r16, r19
|
||||||
breq heapAllocFirstFit_memFull
|
breq heapAllocFirstFit_memFull
|
||||||
sbrc r17, HEAP_HEADER_BIT_USED
|
sbrc r18, HEAP_HEADER_BIT_USED
|
||||||
rjmp heapAllocFirstFit_next ; jump if used
|
rjmp heapAllocFirstFit_next ; jump if used
|
||||||
; current chunk free, check size
|
; current chunk free, check size
|
||||||
|
andi r18, 0xfc
|
||||||
mov r16, r18
|
mov r16, r18
|
||||||
mov r17, r19
|
mov r17, r19
|
||||||
sub r16, r24
|
sub r16, r24
|
||||||
@@ -92,6 +106,7 @@ heapAllocFirstFit_loop:
|
|||||||
sec
|
sec
|
||||||
ret
|
ret
|
||||||
heapAllocFirstFit_next:
|
heapAllocFirstFit_next:
|
||||||
|
andi r18, 0xfc
|
||||||
add xl, r18
|
add xl, r18
|
||||||
adc xh, r19
|
adc xh, r19
|
||||||
adiw xh:xl, 2 ; skip footer
|
adiw xh:xl, 2 ; skip footer
|
||||||
@@ -215,15 +230,20 @@ heapCoalecseUp:
|
|||||||
; read footer of preceeding chunk
|
; read footer of preceeding chunk
|
||||||
ld r25, -X
|
ld r25, -X
|
||||||
ld r24, -X
|
ld r24, -X
|
||||||
; R25:R24=footer of preceeding chunk (i.e. size of previous chunk)
|
; R25:R24=footer of preceeding chunk (i.e. size of previous chunk), X points to previous footer
|
||||||
mov r16, r24 ; check: beginning of heap reached (header==0x0000)?
|
mov r16, r24 ; check: beginning of heap reached (header==0x0000)?
|
||||||
or r16, r25
|
or r16, r25
|
||||||
breq heapCoalecseUp_ret ; yes, jump
|
breq heapCoalecseUp_ret ; yes, jump
|
||||||
sbrc r24, HEAP_HEADER_BIT_USED ; block used?
|
sbrc r24, HEAP_HEADER_BIT_USED ; block used?
|
||||||
rjmp heapCoalecseUp_ret ; jump if used
|
rjmp heapCoalecseUp_ret ; jump if used
|
||||||
; previous chunk also free, coalesce, X points to current chunk header
|
; previous chunk also free, coalesce, X points to current chunk header
|
||||||
|
adiw xh:xl, 2
|
||||||
|
; skip footer
|
||||||
ld r16, X+
|
ld r16, X+
|
||||||
ld r17, X+
|
ld r17, X+
|
||||||
|
sbrc r16, HEAP_HEADER_BIT_USED ; current block used?
|
||||||
|
rjmp heapCoalecseUp_ret ; jump if used
|
||||||
|
|
||||||
; X now points to beginning of current chunk's data, R17:r16=size of current chunk, R25:R24=size of previous chunk
|
; X now points to beginning of current chunk's data, R17:r16=size of current chunk, R25:R24=size of previous chunk
|
||||||
; to go to start of previous chunk header: sub this chunk header, previous chunk footer, previous chunk header and previous data
|
; to go to start of previous chunk header: sub this chunk header, previous chunk footer, previous chunk header and previous data
|
||||||
sbiw xh:xl, 6
|
sbiw xh:xl, 6
|
||||||
@@ -260,10 +280,10 @@ heapCoalecseUp_ret:
|
|||||||
; @clobbers
|
; @clobbers
|
||||||
|
|
||||||
heapUseChunk:
|
heapUseChunk:
|
||||||
push xh
|
push xl
|
||||||
push xl
|
push xh
|
||||||
tst r17
|
tst r17
|
||||||
breq heapUseChunk_split
|
brne heapUseChunk_split
|
||||||
cpi r16, 8 ; at least 8 bytes left?
|
cpi r16, 8 ; at least 8 bytes left?
|
||||||
brcs heapUseChunk_directAlloc ; nope, use full chunk
|
brcs heapUseChunk_directAlloc ; nope, use full chunk
|
||||||
heapUseChunk_split:
|
heapUseChunk_split:
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ ILI9341_Init:
|
|||||||
mov r0, r16
|
mov r0, r16
|
||||||
mov r1, r16
|
mov r1, r16
|
||||||
|
|
||||||
|
#if 0
|
||||||
; set Xpos
|
; set Xpos
|
||||||
ldi r16, LOW(100)
|
ldi r16, LOW(100)
|
||||||
mov r4, r16
|
mov r4, r16
|
||||||
@@ -129,6 +130,7 @@ ILI9341_Init:
|
|||||||
|
|
||||||
ldi r16, 'E'
|
ldi r16, 'E'
|
||||||
rcall ili9341_WriteCharacterX4At
|
rcall ili9341_WriteCharacterX4At
|
||||||
|
#endif
|
||||||
|
|
||||||
sec
|
sec
|
||||||
ret
|
ret
|
||||||
|
|||||||
@@ -142,3 +142,132 @@ ili9341JumpToFontRenderFn:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine textNibbleToAscii
|
||||||
|
;
|
||||||
|
; Convert a nibble to an ASCII char.
|
||||||
|
; @return R16 ASCII representation of that nibble (e.g. '0' for 0)
|
||||||
|
; @param R16 byte (in bits 0-3)
|
||||||
|
; @clobbers r16, r17
|
||||||
|
|
||||||
|
textNibbleToAscii:
|
||||||
|
andi r16, 0xf
|
||||||
|
cpi r16, 10
|
||||||
|
brcs textNibbleToAscii_l1
|
||||||
|
ldi r17, 7
|
||||||
|
add r16, r17
|
||||||
|
textNibbleToAscii_l1:
|
||||||
|
ldi r17, '0'
|
||||||
|
add r16, r17
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine ili9341_WriteCharacterX4At
|
||||||
|
|
||||||
|
; @param R16 byte to write
|
||||||
|
; @param r5:r4 X
|
||||||
|
; @param r7:r6 Y
|
||||||
|
; @param r1:r0 background color
|
||||||
|
; @param r3:r2 foreground color
|
||||||
|
; @param Z pointer to font (byte address for LPM!)
|
||||||
|
; @param X pointer to RAM to store data to
|
||||||
|
; @return r5:r4 new X (advanced by character width)
|
||||||
|
; @clobbers r16, r17, r18, r19, r24, r25, x, z
|
||||||
|
|
||||||
|
|
||||||
|
ili9341_WriteHexByte:
|
||||||
|
push r16
|
||||||
|
swap r16
|
||||||
|
rcall textNibbleToAscii ; write high nibble (r16, r17)
|
||||||
|
push xl
|
||||||
|
push xh
|
||||||
|
rcall ili9341_WriteCharacterX2At ; (r16, r17, r18, r19, r20, r24, r25, x, z)
|
||||||
|
pop xh
|
||||||
|
pop xl
|
||||||
|
pop r16
|
||||||
|
rcall textNibbleToAscii ; write high nibble (r16, r17)
|
||||||
|
rcall ili9341_WriteCharacterX2At ; (r16, r17, r18, r19, r20, r24, r25, x, z)
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Debug_WriteHexByte:
|
||||||
|
push r16
|
||||||
|
; set Xpos
|
||||||
|
ldi r16, LOW(50)
|
||||||
|
mov r4, r16
|
||||||
|
ldi r16, HIGH(50)
|
||||||
|
mov r5, r16
|
||||||
|
|
||||||
|
; setYpos
|
||||||
|
ldi r16, LOW(200)
|
||||||
|
mov r6, r16
|
||||||
|
ldi r16, HIGH(200)
|
||||||
|
mov r7, r16
|
||||||
|
|
||||||
|
; set font pos
|
||||||
|
ldi zl, LOW(font2_6x8*2)
|
||||||
|
ldi zh, HIGH(font2_6x8*2)
|
||||||
|
|
||||||
|
; set buffer pos
|
||||||
|
; ldi xl, LOW(ILI9341_buffer)
|
||||||
|
; ldi xh, HIGH(ILI9341_buffer)
|
||||||
|
ldi xl, LOW(0x260)
|
||||||
|
ldi xh, HIGH(0x260)
|
||||||
|
pop r16
|
||||||
|
rjmp ili9341_WriteHexByte
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; @param X=ptr
|
||||||
|
; @param r17 size
|
||||||
|
Debug_WriteHexBuffer:
|
||||||
|
; set Xpos
|
||||||
|
ldi r16, LOW(50)
|
||||||
|
mov r4, r16
|
||||||
|
ldi r16, HIGH(50)
|
||||||
|
mov r5, r16
|
||||||
|
|
||||||
|
; setYpos
|
||||||
|
ldi r16, LOW(200)
|
||||||
|
mov r6, r16
|
||||||
|
ldi r16, HIGH(200)
|
||||||
|
mov r7, r16
|
||||||
|
|
||||||
|
; set foreground color
|
||||||
|
ldi r16, 0b00000000 ; black
|
||||||
|
mov r2, r16
|
||||||
|
mov r3, r16
|
||||||
|
|
||||||
|
; set font
|
||||||
|
ldi zl, LOW(font2_6x8*2)
|
||||||
|
ldi zh, HIGH(font2_6x8*2)
|
||||||
|
|
||||||
|
Debug_WriteHexBuffer_loop:
|
||||||
|
push r17
|
||||||
|
ld r16, X+
|
||||||
|
push xl
|
||||||
|
push xh
|
||||||
|
ldi xl, LOW(0x260)
|
||||||
|
ldi xh, HIGH(0x260)
|
||||||
|
rcall ili9341_WriteHexByte
|
||||||
|
|
||||||
|
ldi r16, 32
|
||||||
|
rcall ili9341_WriteCharacterX2At ; (r16, r17, r18, r19, r24, r25, x, z)
|
||||||
|
pop xh
|
||||||
|
pop xl
|
||||||
|
pop r17
|
||||||
|
dec r17
|
||||||
|
brne Debug_WriteHexBuffer_loop
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,37 +11,42 @@
|
|||||||
#define AQH_AVR_WIN_H
|
#define AQH_AVR_WIN_H
|
||||||
|
|
||||||
|
|
||||||
; tree/list info
|
; tree/list data
|
||||||
.equ WID_OFFS_TREE = 0
|
.equ OBJ_OFFS_TREE = 0
|
||||||
|
|
||||||
; signal handler
|
; object data
|
||||||
.equ WID_OFFS_HANDLERFN_LO = WID_OFFS_TREE+TREE_SIZE
|
.equ OBJ_OFFS_OBJECT = OBJ_OFFS_TREE+TREE_SIZE
|
||||||
.equ WID_OFFS_HANDLERFN_HI = WID_OFFS_HANDLERFN_LO+1
|
.equ OBJ_OFFS_HANDLERFN_LO = OBJ_OFFS_OBJECT
|
||||||
|
.equ OBJ_OFFS_HANDLERFN_HI = OBJ_OFFS_OBJECT+1
|
||||||
|
.equ OBJ_OFFS_LINKS_LO = OBJ_OFFS_OBJECT+2
|
||||||
|
.equ OBJ_OFFS_LINKS_HI = OBJ_OFFS_OBJECT+3
|
||||||
|
.equ OBJ_OFFS_TIMERS_LO = OBJ_OFFS_OBJECT+4
|
||||||
|
.equ OBJ_OFFS_TIMERS_HI = OBJ_OFFS_OBJECT+5
|
||||||
|
.equ OBJ_OFFS_OPTIONS = OBJ_OFFS_OBJECT+6
|
||||||
|
.equ OBJ_OFFS_SIZE = OBJ_OFFS_OBJECT+7
|
||||||
|
|
||||||
; widget description
|
; widget data
|
||||||
.equ WID_OFFS_WIDGET_INFO = WID_OFFS_HANDLERFN_HI+1
|
.equ WID_OFFS_WIDGET = OBJ_OFFS_SIZE
|
||||||
.equ WID_OFFS_OPTIONS1 = WID_OFFS_WIDGET_INFO+0
|
.equ WID_OFFS_OPTIONS1 = WID_OFFS_WIDGET+0
|
||||||
.equ WID_OFFS_OPTIONS2 = WID_OFFS_WIDGET_INFO+1
|
.equ WID_OFFS_OPTIONS2 = WID_OFFS_WIDGET+1
|
||||||
.equ WID_OFFS_ABS_X_LO = WID_OFFS_WIDGET_INFO+2
|
.equ WID_OFFS_ABS_X = WID_OFFS_WIDGET+2
|
||||||
.equ WID_OFFS_ABS_X_HI = WID_OFFS_WIDGET_INFO+3
|
.equ WID_OFFS_ABS_Y = WID_OFFS_WIDGET+3
|
||||||
.equ WID_OFFS_ABS_Y_LO = WID_OFFS_WIDGET_INFO+4
|
.equ WID_OFFS_REL_X = WID_OFFS_WIDGET+4
|
||||||
.equ WID_OFFS_ABS_Y_HI = WID_OFFS_WIDGET_INFO+5
|
.equ WID_OFFS_REL_Y = WID_OFFS_WIDGET+5
|
||||||
.equ WID_OFFS_REL_X_LO = WID_OFFS_WIDGET_INFO+6
|
.equ WID_OFFS_WIDTH = WID_OFFS_WIDGET+6
|
||||||
.equ WID_OFFS_REL_X_HI = WID_OFFS_WIDGET_INFO+7
|
.equ WID_OFFS_HEIGHT = WID_OFFS_WIDGET+7
|
||||||
.equ WID_OFFS_REL_Y_LO = WID_OFFS_WIDGET_INFO+8
|
.equ WID_OFFS_BG_COL_LO = WID_OFFS_WIDGET+8
|
||||||
.equ WID_OFFS_REL_Y_HI = WID_OFFS_WIDGET_INFO+9
|
.equ WID_OFFS_BG_COL_HI = WID_OFFS_WIDGET+9
|
||||||
.equ WID_OFFS_WIDTH_LO = WID_OFFS_WIDGET_INFO+10
|
.equ WID_OFFS_FG_COL_LO = WID_OFFS_WIDGET+10
|
||||||
.equ WID_OFFS_WIDTH_HI = WID_OFFS_WIDGET_INFO+11
|
.equ WID_OFFS_FG_COL_HI = WID_OFFS_WIDGET+11
|
||||||
.equ WID_OFFS_HEIGHT_LO = WID_OFFS_WIDGET_INFO+12
|
.equ WID_OFFS_FONT_LO = WID_OFFS_WIDGET+12
|
||||||
.equ WID_OFFS_HEIGHT_HI = WID_OFFS_WIDGET_INFO+13
|
.equ WID_OFFS_FONT_HI = WID_OFFS_WIDGET+13
|
||||||
.equ WID_OFFS_BG_COL_LO = WID_OFFS_WIDGET_INFO+14
|
.equ WID_OFFS_BORDER_TOP = WID_OFFS_WIDGET+14
|
||||||
.equ WID_OFFS_BG_COL_HI = WID_OFFS_WIDGET_INFO+15
|
.equ WID_OFFS_BORDER_BOT = WID_OFFS_WIDGET+15
|
||||||
.equ WID_OFFS_FG_COL_LO = WID_OFFS_WIDGET_INFO+16
|
.equ WID_OFFS_BORDER_LEFT = WID_OFFS_WIDGET+16
|
||||||
.equ WID_OFFS_FG_COL_HI = WID_OFFS_WIDGET_INFO+17
|
.equ WID_OFFS_BORDER_RIGHT = WID_OFFS_WIDGET+17
|
||||||
.equ WID_OFFS_FONT_LO = WID_OFFS_WIDGET_INFO+18
|
|
||||||
.equ WID_OFFS_FONT_HI = WID_OFFS_WIDGET_INFO+19
|
|
||||||
|
|
||||||
.equ WID_SIZE = WID_OFFS_WIDGET_INFO+20
|
.equ WID_SIZE = WID_OFFS_WIDGET+18
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -51,11 +56,58 @@
|
|||||||
.equ WID_OPTIONS1_BIT_STRETCH_X = 2
|
.equ WID_OPTIONS1_BIT_STRETCH_X = 2
|
||||||
.equ WID_OPTIONS1_BIT_STRETCH_Y = 3
|
.equ WID_OPTIONS1_BIT_STRETCH_Y = 3
|
||||||
|
|
||||||
.equ WID_OPTIONS1_BIT_ALIGN_LEFT = 4
|
.equ WID_OPTIONS1_BIT_ALIGN_RIGHT = 4
|
||||||
.equ WID_OPTIONS1_BIT_ALIGN_RIGHT = 5
|
.equ WID_OPTIONS1_BIT_ALIGN_BOTTOM = 5
|
||||||
|
|
||||||
|
.equ WID_OPTIONS1_BIT_EQUAL_WIDTH = 6
|
||||||
|
.equ WID_OPTIONS1_BIT_EQUAL_HEIGHT = 7
|
||||||
|
|
||||||
|
|
||||||
|
; Signals
|
||||||
|
|
||||||
|
.equ OBJ_SIGNAL_CREATED = 0
|
||||||
|
.equ OBJ_SIGNAL_DESTROY = 1
|
||||||
|
.equ OBJ_SIGNAL_GETVALUE = 2
|
||||||
|
.equ OBJ_SIGNAL_SETVALUE = 3
|
||||||
|
.equ OBJ_SIGNAL_TIMER = 4
|
||||||
|
.equ OBJ_SIGNAL_NEXTFREE = 5
|
||||||
|
|
||||||
|
.equ WID_SIGNAL_SHOW = OBJ_SIGNAL_NEXTFREE
|
||||||
|
.equ WID_SIGNAL_HIDE = OBJ_SIGNAL_NEXTFREE+1
|
||||||
|
.equ WID_SIGNAL_UPDATE = OBJ_SIGNAL_NEXTFREE+2
|
||||||
|
.equ WID_SIGNAL_LAYOUT = OBJ_SIGNAL_NEXTFREE+3
|
||||||
|
.equ WID_SIGNAL_TOUCH = OBJ_SIGNAL_NEXTFREE+4
|
||||||
|
.equ WID_SIGNAL_MOUSE = OBJ_SIGNAL_NEXTFREE+5
|
||||||
|
.equ WID_SIGNAL_KEY = OBJ_SIGNAL_NEXTFREE+6
|
||||||
|
.equ WID_SIGNAL_NEXTFREE = OBJ_SIGNAL_NEXTFREE+7
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; Links
|
||||||
|
|
||||||
|
.equ OBJ_LINK_OFFS_LIST = 0
|
||||||
|
.equ OBJ_LINK_OFFS_SIGNAL = LIST_SIZE
|
||||||
|
.equ OBJ_LINK_OFFS_SLOT = LIST_SIZE+1
|
||||||
|
.equ OBJ_LINK_OFFS_TARGET_LO = LIST_SIZE+2
|
||||||
|
.equ OBJ_LINK_OFFS_TARGET_HI = LIST_SIZE+3
|
||||||
|
.equ OBJ_LINK_SIZE = LIST_SIZE+4
|
||||||
|
; fns:
|
||||||
|
; - removeLinksTo()
|
||||||
|
; - addLink()
|
||||||
|
; - removeLinks()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.equ TIMER_OFFS_LIST = 0
|
||||||
|
.equ TIMER_OFFS_TIMER = LIST_SIZE
|
||||||
|
.equ TIMER_OFFS_VALUE_LO = TIMER_OFFS_TIMER
|
||||||
|
.equ TIMER_OFFS_VALUE_LO = TIMER_OFFS_TIMER+1
|
||||||
|
.equ TIMER_OFFS_RELOAD_LO = TIMER_OFFS_TIMER+2
|
||||||
|
.equ TIMER_OFFS_RELOAD_HI = TIMER_OFFS_TIMER+3
|
||||||
|
.equ TIMER_OFFS_OPTIONS = TIMER_OFFS_TIMER+4
|
||||||
|
.equ TIMER_SIZE = TIMER_OFFS_TIMER+5
|
||||||
|
|
||||||
|
|
||||||
.equ WID_OPTIONS1_BIT_ALIGN_TOP = 6
|
|
||||||
.equ WID_OPTIONS1_BIT_ALIGN_BOTTOM = 7
|
|
||||||
|
|
||||||
|
|
||||||
#endif ; AQH_AVR_WIN_H
|
#endif ; AQH_AVR_WIN_H
|
||||||
|
|||||||
@@ -40,8 +40,8 @@
|
|||||||
.equ NET_IFACE_OFFS_ERR_IO_HIGH = 15
|
.equ NET_IFACE_OFFS_ERR_IO_HIGH = 15
|
||||||
.equ NET_IFACE_OFFS_ERR_NOBUF_LOW = 16
|
.equ NET_IFACE_OFFS_ERR_NOBUF_LOW = 16
|
||||||
.equ NET_IFACE_OFFS_ERR_NOBUF_HIGH = 17
|
.equ NET_IFACE_OFFS_ERR_NOBUF_HIGH = 17
|
||||||
.equ NET_IFACE_OFFS_HANDLED_LOW = 18
|
.equ NET_IFACE_OFFS_ERR_MSGSIZE_LOW = 18
|
||||||
.equ NET_IFACE_OFFS_HANDLED_HIGH = 19
|
.equ NET_IFACE_OFFS_ERR_MSGSIZE_HIGH = 19
|
||||||
.equ NET_IFACE_OFFS_ERR_MISSED_LOW = 20
|
.equ NET_IFACE_OFFS_ERR_MISSED_LOW = 20
|
||||||
.equ NET_IFACE_OFFS_ERR_MISSED_HIGH = 21
|
.equ NET_IFACE_OFFS_ERR_MISSED_HIGH = 21
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
debug-w.asm
|
debug-w.asm
|
||||||
device-w.asm
|
device-w.asm
|
||||||
memstats-w.asm
|
memstats-w.asm
|
||||||
|
pong-w.asm
|
||||||
reboot-d.asm
|
reboot-d.asm
|
||||||
reboot-r.asm
|
reboot-r.asm
|
||||||
recvstats-w.asm
|
recvstats-w.asm
|
||||||
|
|||||||
37
avr/modules/network/msg/pong-w.asm
Normal file
37
avr/modules/network/msg/pong-w.asm
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
; ***************************************************************************
|
||||||
|
; copyright : (C) 2025 by Martin Preuss
|
||||||
|
; email : martin@libchipcard.de
|
||||||
|
;
|
||||||
|
; ***************************************************************************
|
||||||
|
; * This file is part of the project "AqHome". *
|
||||||
|
; * Please see toplevel file COPYING of that project for license details. *
|
||||||
|
; ***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine NETMSG_Pong_Write @global
|
||||||
|
;
|
||||||
|
; @param R16 dest addr
|
||||||
|
; @param Y pointer to device to write msg for and to
|
||||||
|
; @param X pointer to buffer to write to
|
||||||
|
; @clobbers R16 (R17, R18, R19, R20, R21, Z)
|
||||||
|
|
||||||
|
NETMSG_Pong_Write:
|
||||||
|
st X+, r16 ; dest address
|
||||||
|
ldi r16, 6 ; msg code+src address+4 payload bytes
|
||||||
|
st X+, r16 ; msg len
|
||||||
|
ldi r16, NETMSG_CMD_PONG
|
||||||
|
st X+, r16 ; msg code
|
||||||
|
ldd r16, Y+NET_IFACE_OFFS_ADDRESS
|
||||||
|
st X+, r16 ; src address
|
||||||
|
rcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21)
|
||||||
|
|
||||||
|
sbiw xh:xl, 8 ; go back to beginning of message (1 byte dst addr, 1 byte length, 6 bytes payload)
|
||||||
|
rcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X)
|
||||||
|
sbiw xh:xl, 9 ; go back to beginning of message (1 byte dst addr, 1 byte length, 6 bytes payload, 1 byte crc)
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -93,13 +93,13 @@ SPIHW_MasterStart:
|
|||||||
sbrc r16, SPIHW_MODE_SPEED1_BIT
|
sbrc r16, SPIHW_MODE_SPEED1_BIT
|
||||||
sbr r17, (1<<SPR1)
|
sbr r17, (1<<SPR1)
|
||||||
sbr r17, (1<<SPE) | (1<<MSTR)
|
sbr r17, (1<<SPE) | (1<<MSTR)
|
||||||
M_IO_WRITE SPCR, r17
|
outr SPCR, r17
|
||||||
|
|
||||||
; setup SPSR
|
; setup SPSR
|
||||||
clr r17
|
clr r17
|
||||||
sbrc r16, SPIHW_MODE_DOUBLESPEED_BIT
|
sbrc r16, SPIHW_MODE_DOUBLESPEED_BIT
|
||||||
sbr r17, (1<<SPI2X)
|
sbr r17, (1<<SPI2X)
|
||||||
M_IO_WRITE SPSR, r17
|
outr SPSR, r17
|
||||||
|
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
@@ -115,9 +115,9 @@ SPIHW_MasterStart:
|
|||||||
|
|
||||||
SPIHW_MasterStop:
|
SPIHW_MasterStop:
|
||||||
; sbi SPIHW_SS_OUTPUT, SPIHW_SS_PIN ; SS high
|
; sbi SPIHW_SS_OUTPUT, SPIHW_SS_PIN ; SS high
|
||||||
M_IO_READ r16, SPCR
|
inr r16, SPCR
|
||||||
cbr r16, (1<<SPE)
|
cbr r16, (1<<SPE)
|
||||||
M_IO_WRITE SPCR, r16
|
outr SPCR, r16
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ SPIHW_MasterTransfer:
|
|||||||
; @clobbers none
|
; @clobbers none
|
||||||
|
|
||||||
SPIHW_MasterSendByte:
|
SPIHW_MasterSendByte:
|
||||||
M_IO_WRITE SPDR, r16
|
outr SPDR, r16
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
@@ -191,10 +191,10 @@ SPIHW_MasterSendByte:
|
|||||||
; @clobbers none
|
; @clobbers none
|
||||||
|
|
||||||
SPIHW_WaitForTransferComplete:
|
SPIHW_WaitForTransferComplete:
|
||||||
M_IO_READ r16, SPSR
|
inr r16, SPSR
|
||||||
sbrs r16, SPIF
|
sbrs r16, SPIF
|
||||||
rjmp SPIHW_WaitForTransferComplete
|
rjmp SPIHW_WaitForTransferComplete
|
||||||
M_IO_READ r16, SPDR
|
inr r16, SPDR
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,11 @@
|
|||||||
<gwbuild>
|
<gwbuild>
|
||||||
|
|
||||||
<extradist>
|
<extradist>
|
||||||
|
bytelevel.asm
|
||||||
defs.asm
|
defs.asm
|
||||||
iface.asm
|
iface.asm
|
||||||
lowlevel.asm
|
|
||||||
main.asm
|
main.asm
|
||||||
|
msglevel.asm
|
||||||
</extradist>
|
</extradist>
|
||||||
|
|
||||||
</gwbuild>
|
</gwbuild>
|
||||||
|
|||||||
@@ -10,7 +10,9 @@
|
|||||||
|
|
||||||
|
|
||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
; code
|
; macros
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; @macro UART_BB_M_WAIT_FOR_PIN_LOW IN_REG_DATA, IN_PINNUM
|
; @macro UART_BB_M_WAIT_FOR_PIN_LOW IN_REG_DATA, IN_PINNUM
|
||||||
@@ -66,7 +68,10 @@ l_end:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; code
|
||||||
|
|
||||||
|
.cseg
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
@@ -93,7 +98,7 @@ uartBitbang_SendByte:
|
|||||||
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, 1, r22 ; wait for one bit duration
|
Utils_WaitNanoSecs COM_BIT_LENGTH, 1, r22 ; wait for one bit duration
|
||||||
; send data bits
|
; send data bits
|
||||||
uartBitbang_SendByte_loop: ; 9 for low bit
|
uartBitbang_SendByte_loop: ; 11 for low bit
|
||||||
lsr r16 ; 1+ bit to send -> CARRY
|
lsr r16 ; 1+ bit to send -> CARRY
|
||||||
brcs uartBitbang_SendByte_setHigh ; HI: +2, LO: +1
|
brcs uartBitbang_SendByte_setHigh ; HI: +2, LO: +1
|
||||||
uartBitbang_SendByte_setLow:
|
uartBitbang_SendByte_setLow:
|
||||||
@@ -108,9 +113,11 @@ uartBitbang_SendByte_setHigh:
|
|||||||
sbis COM_DATA_INPUT, COM_DATA_PIN ; +1 if no skip, +2 if skipped
|
sbis COM_DATA_INPUT, COM_DATA_PIN ; +1 if no skip, +2 if skipped
|
||||||
rjmp uartBitbang_SendByte_error ; +2 if error (collision: we wanted line to be high but it is low)
|
rjmp uartBitbang_SendByte_error ; +2 if error (collision: we wanted line to be high but it is low)
|
||||||
Utils_WaitNanoSecs COM_HALFBIT_LENGTH, 11, r22
|
Utils_WaitNanoSecs COM_HALFBIT_LENGTH, 11, 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: 10 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
|
Utils_WaitNanoSecs COM_BIT_LENGTH, 0, r22 ; wait for one bit length
|
||||||
@@ -214,116 +221,6 @@ uartBitbang_WaitForAttnHigh:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; @routine uartBitbang_ReceivePacketIntoBuffer
|
|
||||||
;
|
|
||||||
; Receive a packet into buffer pointed to by X.
|
|
||||||
; Expects interrupts to be disabled.
|
|
||||||
;
|
|
||||||
; @param R16 COM address to listen to
|
|
||||||
; @param R17 maximum value for accepted msg data (i.e. buffersize minus 3)
|
|
||||||
; @param X buffer to receive to
|
|
||||||
; @return CFLAG set if okay (packet received), cleared on error
|
|
||||||
; @return R16 error code if CFLAG is cleared (COM2_ERROR_NOTFORME, COM2_ERROR_IOERROR, COM2_ERROR_DATAERROR)
|
|
||||||
; @clobbers: r16, r17, r18, X (r19, r20, r21, r22)
|
|
||||||
|
|
||||||
uartBitbang_ReceivePacketIntoBuffer:
|
|
||||||
mov r18, r17
|
|
||||||
push r16
|
|
||||||
; read destination address
|
|
||||||
rcall uartBitbang_ReceiveByte ; read byte (R16, R17, R20, R21, R22)
|
|
||||||
pop r17 ; pop from R16 to R17
|
|
||||||
brcc uartBitbang_ReceivePacketIntoBuffer_ioError
|
|
||||||
#ifndef COM_ACCEPT_ALL_DEST ; accept every destination address
|
|
||||||
; compare destination address (accept "FF" and own address)
|
|
||||||
cp r16, r17
|
|
||||||
breq uartBitbang_ReceivePacketIntoBuffer_acceptAddr
|
|
||||||
cpi r16, 0xff
|
|
||||||
breq uartBitbang_ReceivePacketIntoBuffer_acceptAddr
|
|
||||||
clr r16
|
|
||||||
rjmp uartBitbang_ReceivePacketIntoBuffer_error ; clc/ret
|
|
||||||
#endif
|
|
||||||
uartBitbang_ReceivePacketIntoBuffer_acceptAddr:
|
|
||||||
st X+, r16 ; store dest address, lock buffer
|
|
||||||
; read msg length
|
|
||||||
rcall uartBitbang_ReceiveByte ; read packet length (R16, R17, R20, R21, R22)
|
|
||||||
brcc uartBitbang_ReceivePacketIntoBuffer_ioError
|
|
||||||
st X+, r16
|
|
||||||
cp r16, r18 ; (COM2_BUFFER_SIZE-3)
|
|
||||||
brcc uartBitbang_ReceivePacketIntoBuffer_contentError ; packet too long
|
|
||||||
inc r16 ; account for checksum byte
|
|
||||||
mov r17, r16
|
|
||||||
uartBitbang_ReceivePacketIntoBuffer_loop:
|
|
||||||
push r17
|
|
||||||
rcall uartBitbang_ReceiveByte ; read byte (R16, R17, R20, R21, R22)
|
|
||||||
pop r17
|
|
||||||
brcc uartBitbang_ReceivePacketIntoBuffer_ioError
|
|
||||||
st X+, r16
|
|
||||||
dec r17
|
|
||||||
brne uartBitbang_ReceivePacketIntoBuffer_loop
|
|
||||||
sec
|
|
||||||
ret
|
|
||||||
uartBitbang_ReceivePacketIntoBuffer_ioError:
|
|
||||||
ldi r16, NET_IFACE_OFFS_ERR_IO_LOW
|
|
||||||
rjmp uartBitbang_ReceivePacketIntoBuffer_error
|
|
||||||
uartBitbang_ReceivePacketIntoBuffer_contentError:
|
|
||||||
ldi r16, NET_IFACE_OFFS_ERR_CONTENT_LOW
|
|
||||||
uartBitbang_ReceivePacketIntoBuffer_error:
|
|
||||||
clc
|
|
||||||
ret
|
|
||||||
; @end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; @routine uartBitbang_SendPacket
|
|
||||||
;
|
|
||||||
; Send packet over wire, handle ATTN line.
|
|
||||||
;
|
|
||||||
; @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, R22 (R17, R21, X)
|
|
||||||
|
|
||||||
uartBitbang_SendPacket:
|
|
||||||
rcall uartBitbang_AcquireBus
|
|
||||||
brcc uartBitbang_SendPacket_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)
|
|
||||||
|
|
||||||
adiw xh:xl, NETMSG_OFFS_MSGLEN
|
|
||||||
ld r17, X
|
|
||||||
sbiw xh:xl, NETMSG_OFFS_MSGLEN
|
|
||||||
inc r17 ; account for dest addr
|
|
||||||
inc r17 ; account for msglen byte
|
|
||||||
inc r17 ; account for crc byte
|
|
||||||
|
|
||||||
uartBitbang_SendPacket_loop:
|
|
||||||
ld r16, X+
|
|
||||||
rcall uartBitbang_SendByte ; send byte (R16, R21, R22)
|
|
||||||
brcc uartBitbang_SendPacket_releaseBusRet
|
|
||||||
dec r17
|
|
||||||
brne uartBitbang_SendPacket_loop
|
|
||||||
sec
|
|
||||||
uartBitbang_SendPacket_releaseBusRet:
|
|
||||||
cbi COM_ATTN_DDR, COM_ATTN_PIN ; release ATTN line (by setting direction to IN)
|
|
||||||
brcc uartBitbang_SendPacket_ioError
|
|
||||||
; packet successfully sent
|
|
||||||
ret
|
|
||||||
uartBitbang_SendPacket_ioError:
|
|
||||||
ldi r16, NET_IFACE_OFFS_ERR_COLLISIONS_LOW
|
|
||||||
ret
|
|
||||||
uartBitbang_SendPacket_lineBusyError:
|
|
||||||
ldi r16, NET_IFACE_OFFS_ERR_BUSY_LOW
|
|
||||||
ret
|
|
||||||
; @end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; @routine uartBitbang_AcquireBus
|
; @routine uartBitbang_AcquireBus
|
||||||
;
|
;
|
||||||
@@ -366,3 +263,4 @@ uartBitbang_WaitForOneBitLength:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -25,8 +25,7 @@
|
|||||||
|
|
||||||
.dseg
|
.dseg
|
||||||
|
|
||||||
uart_bitbang_iface: .byte NET_IFACE_SIZE
|
uart_bitbang_iface: .byte NET_IFACE_SIZE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -124,7 +123,7 @@ 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_SendPacket ; (R16, R17, R21, R22, X)
|
rcall uartBitbang_SendMsg ; (R16, R17, R21, R22, X)
|
||||||
brcc uartBitBang_sendNextPkg_error
|
brcc uartBitBang_sendNextPkg_error
|
||||||
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)
|
||||||
@@ -145,73 +144,38 @@ uartBitBang_sendNextPkg_end:
|
|||||||
;
|
;
|
||||||
; Receive packet.
|
; Receive packet.
|
||||||
;
|
;
|
||||||
; @return CFLAG set if okay (packet received), cleared on error
|
; @param Y pointer to start of interface data
|
||||||
; @clobbers R16, R17, X (R18, R19, R20, R21, R22, R24, R25)
|
; @clobbers R16, R17, R18, R19, R20, R21, R22, R24, R25, X
|
||||||
|
|
||||||
uartBitbang_receiveNextPkg:
|
uartBitbang_receiveNextPkg:
|
||||||
rcall NET_Buffer_Alloc ; (R16, R17, X)
|
rcall NET_Buffer_Alloc ; R16=buffer num (R16, R17, X)
|
||||||
brcs uartBitbang_receiveNextPkg_gotBuffer
|
brcs uartBitbang_receiveNextPkg_gotBuffer
|
||||||
ldi r16, NET_IFACE_OFFS_ERR_NOBUF_LOW
|
ldi r16, NET_IFACE_OFFS_ERR_NOBUF_LOW
|
||||||
rcall NET_Interface_IncCounter16 ; (R24, R25)
|
rcall NET_Interface_IncCounter16 ; (R24, R25)
|
||||||
clc
|
|
||||||
rjmp uartBitbang_receiveNextPkg_end
|
rjmp uartBitbang_receiveNextPkg_end
|
||||||
uartBitbang_receiveNextPkg_gotBuffer:
|
uartBitbang_receiveNextPkg_gotBuffer:
|
||||||
push r16 ; buffer number
|
push r16 ; buffer number
|
||||||
adiw xh:xl, 1
|
adiw xh:xl, 1
|
||||||
rcall uartBitbang_receiveAndCheckPkg ; (r16, r17, r18, r19, r20, r21, r22, X)
|
ldd r18, Y+NET_IFACE_OFFS_ADDRESS
|
||||||
pop r17 ; pop buffer number to R17
|
ldi r19, NET_BUFFERS_SIZE-1
|
||||||
brcs uartBitbang_receiveNextPkg_gotPkg
|
rcall uartBitbang_ReceiveAndCheckMsg ; (R16, R17, R19, R20, R21, R22, R24, R25)
|
||||||
tst r16 ; error code=0: pkg not for me
|
pop r16
|
||||||
breq uartBitbang_receiveNextPkg_RelBuffer
|
brcc uartBitbang_receiveNextPkg_relBuffer
|
||||||
uartBitbang_receiveNextPkg_incCntRelBuffer:
|
|
||||||
rcall NET_Interface_IncCounter16 ; (R24, R25)
|
|
||||||
uartBitbang_receiveNextPkg_RelBuffer:
|
|
||||||
mov r16, r17
|
|
||||||
rcall NET_Buffer_ReleaseByNum ; (R16, X)
|
|
||||||
clc
|
|
||||||
rjmp uartBitbang_receiveNextPkg_end
|
|
||||||
uartBitbang_receiveNextPkg_gotPkg:
|
|
||||||
mov r16, r17
|
|
||||||
rcall NET_AddIncomingMsgNum ; (R17, R18, X)
|
rcall NET_AddIncomingMsgNum ; (R17, R18, X)
|
||||||
ldi r16, NET_IFACE_OFFS_ERR_NOBUF_LOW
|
brcs uartBitbang_receiveNextPkg_end
|
||||||
brcc uartBitbang_receiveNextPkg_incCntRelBuffer
|
push r16
|
||||||
ldi r16, NET_IFACE_OFFS_PACKETSIN_LOW
|
ldi r16, NET_IFACE_OFFS_ERR_MISSED_LOW
|
||||||
rcall NET_Interface_IncCounter16 ; (R24, R25)
|
rcall NET_Interface_IncCounter16 ; (R24, R25)
|
||||||
sec
|
pop r16
|
||||||
|
; fall-through to release buffer
|
||||||
|
uartBitbang_receiveNextPkg_relBuffer:
|
||||||
|
rcall NET_Buffer_ReleaseByNum ; (R16, X)
|
||||||
uartBitbang_receiveNextPkg_end:
|
uartBitbang_receiveNextPkg_end:
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; @routine uartBitbang_receiveAndCheckPkg
|
|
||||||
;
|
|
||||||
; Receive a packet into buffer pointed to by X and CRC check it.
|
|
||||||
; Expects interrupts to be disabled.
|
|
||||||
;
|
|
||||||
; @param X buffer to receive to
|
|
||||||
; @param Y pointer to start of interface data
|
|
||||||
; @return CFLAG set if okay (packet received), cleared on error
|
|
||||||
; @return R16 error var offset if CFLAG is cleared
|
|
||||||
; @clobbers: r16 (r17, r18, r19, r20, r21, r22, X)
|
|
||||||
|
|
||||||
uartBitbang_receiveAndCheckPkg:
|
|
||||||
ldd r16, Y+NET_IFACE_OFFS_ADDRESS
|
|
||||||
ldi r17, (NET_BUFFERS_SIZE-2)
|
|
||||||
push xl
|
|
||||||
push xh
|
|
||||||
rcall uartBitbang_ReceivePacketIntoBuffer ; (r16, r17, r18, r19, r20, r21, r22, X)
|
|
||||||
pop xh
|
|
||||||
pop xl
|
|
||||||
brcc uartBitbang_receiveAndCheckPkg_end
|
|
||||||
rcall NETMSG_CheckMessageInBuffer ; (R16, R17, R18, R19, R20, X)
|
|
||||||
ldi r16, NET_IFACE_OFFS_ERR_CONTENT_LOW
|
|
||||||
uartBitbang_receiveAndCheckPkg_end:
|
|
||||||
ret
|
|
||||||
; @end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
175
avr/modules/uart_bitbang2/msglevel.asm
Normal file
175
avr/modules/uart_bitbang2/msglevel.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. *
|
||||||
|
; ***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; code
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine uartBitbang_ReceiveAndCheckMsg
|
||||||
|
;
|
||||||
|
; Receive a packet into buffer pointed to by X.
|
||||||
|
; Expects interrupts to be disabled.
|
||||||
|
;
|
||||||
|
; @param R18 COM address to listen to
|
||||||
|
; @param R19 max buffer size
|
||||||
|
; @param X buffer to receive to
|
||||||
|
; @return CFLAG set if msg received, cleared on error
|
||||||
|
; @clobbers R16, R19 (R17, R20, R21, R22, R24, R25)
|
||||||
|
|
||||||
|
uartBitbang_ReceiveAndCheckMsg:
|
||||||
|
push xl
|
||||||
|
push xh
|
||||||
|
rcall uartBitbang_RawReceiveMsg ; (R16, R17, R19, R20, R21, R22, R24, R25, X)
|
||||||
|
pop xh
|
||||||
|
pop xl
|
||||||
|
brcs uartBitbang_ReceiveAndCheckMsg_recvd
|
||||||
|
; fall-through, return with CF cleared (from uartBitbang_RawReceiveMsg)
|
||||||
|
ret
|
||||||
|
uartBitbang_ReceiveAndCheckMsg_recvd:
|
||||||
|
push xl
|
||||||
|
push xh
|
||||||
|
rcall NETMSG_CheckMessageInBuffer ; (R16, R17, R18, R19, R20, X)
|
||||||
|
pop xh
|
||||||
|
pop xl
|
||||||
|
brcs uartBitbang_ReceiveAndCheckMsg_msgOk
|
||||||
|
ldi r16, NET_IFACE_OFFS_ERR_CONTENT_LOW
|
||||||
|
rcall NET_Interface_IncCounter16 ; (R24, R25)
|
||||||
|
clc
|
||||||
|
ret
|
||||||
|
uartBitbang_ReceiveAndCheckMsg_msgOk:
|
||||||
|
ldi r16, NET_IFACE_OFFS_PACKETSIN_LOW
|
||||||
|
rcall NET_Interface_IncCounter16 ; (R24, R25)
|
||||||
|
sec
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine uartBitbang_RawReceiveMsg
|
||||||
|
;
|
||||||
|
; Receive a packet into buffer pointed to by X.
|
||||||
|
; Expects interrupts to be disabled.
|
||||||
|
;
|
||||||
|
; @param R18 COM address to listen to
|
||||||
|
; @param R19 max buffer size
|
||||||
|
; @param X buffer to receive to
|
||||||
|
; @return CFLAG set if msg received, cleared on error (see R16)
|
||||||
|
; @return R16 if CFLAG cleared: 0=message not for this node, otherwise error
|
||||||
|
; @clobbers R16, R19 (R17, R20, R21, R22, R24, R25, X)
|
||||||
|
|
||||||
|
uartBitbang_RawReceiveMsg:
|
||||||
|
cpi r19, 3
|
||||||
|
brcs uartBitbang_RawReceiveMsg_eBadSize
|
||||||
|
; read destination address
|
||||||
|
rcall uartBitbang_ReceiveByte ; read byte (R16, R17, R20, R21, R22)
|
||||||
|
brcc uartBitbang_RawReceiveMsg_eIo
|
||||||
|
cp r16, r18
|
||||||
|
breq uartBitbang_RawReceiveMsg_forMe
|
||||||
|
cpi r16, 0xff
|
||||||
|
breq uartBitbang_RawReceiveMsg_forMe
|
||||||
|
clr r16
|
||||||
|
rjmp uartBitbang_RawReceiveMsg_clcRet
|
||||||
|
uartBitbang_RawReceiveMsg_forMe:
|
||||||
|
subi r19, 1
|
||||||
|
brcs uartBitbang_RawReceiveMsg_eBadSize
|
||||||
|
st X+, r16
|
||||||
|
; 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)
|
||||||
|
brcc uartBitbang_RawReceiveMsg_eIo
|
||||||
|
inc r16 ; account for crc byte
|
||||||
|
subi r19, 1
|
||||||
|
brcs uartBitbang_RawReceiveMsg_eBadSize
|
||||||
|
st X+, r16 ; store msg payload size
|
||||||
|
sub r19, r16 ; check msg size against remaining buffer size
|
||||||
|
brcs uartBitbang_RawReceiveMsg_eBadSize
|
||||||
|
mov r19, r16
|
||||||
|
uartBitbang_RawReceiveMsg_loop:
|
||||||
|
rcall uartBitbang_ReceiveByte ; read byte (R16, R17, R20, R21, R22)
|
||||||
|
brcc uartBitbang_RawReceiveMsg_eIo
|
||||||
|
st X+, r16 ; store msg
|
||||||
|
dec r19
|
||||||
|
brne uartBitbang_RawReceiveMsg_loop
|
||||||
|
sec
|
||||||
|
rjmp uartBitbang_RawReceiveMsg_end
|
||||||
|
uartBitbang_RawReceiveMsg_eBadSize:
|
||||||
|
ldi r16, NET_IFACE_OFFS_ERR_MSGSIZE_LOW
|
||||||
|
rjmp uartBitbang_RawReceiveMsg_incCounterRet
|
||||||
|
uartBitbang_RawReceiveMsg_eIo:
|
||||||
|
ldi r16, NET_IFACE_OFFS_ERR_IO_LOW
|
||||||
|
uartBitbang_RawReceiveMsg_incCounterRet:
|
||||||
|
rcall NET_Interface_IncCounter16 ; (R24, R25)
|
||||||
|
uartBitbang_RawReceiveMsg_clcRet:
|
||||||
|
clc
|
||||||
|
uartBitbang_RawReceiveMsg_end:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine uartBitbang_SendMsg
|
||||||
|
;
|
||||||
|
; Send packet over wire, handle ATTN line.
|
||||||
|
;
|
||||||
|
; @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, R22 (R17, R21, X)
|
||||||
|
|
||||||
|
uartBitbang_SendMsg:
|
||||||
|
rcall uartBitbang_AcquireBus
|
||||||
|
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)
|
||||||
|
|
||||||
|
adiw xh:xl, NETMSG_OFFS_MSGLEN
|
||||||
|
ld r17, X
|
||||||
|
sbiw xh:xl, NETMSG_OFFS_MSGLEN
|
||||||
|
inc r17 ; account for dest addr
|
||||||
|
inc r17 ; account for msglen byte
|
||||||
|
inc r17 ; account for crc byte
|
||||||
|
|
||||||
|
uartBitbang_SendMsg_loop:
|
||||||
|
rcall uartBitbang_WaitForOneBitLength ; wait for one bit duration (R22)
|
||||||
|
|
||||||
|
ld r16, X+
|
||||||
|
rcall uartBitbang_SendByte ; send byte (R16, R21, R22)
|
||||||
|
brcc uartBitbang_SendMsg_releaseBusRet
|
||||||
|
dec r17
|
||||||
|
brne uartBitbang_SendMsg_loop
|
||||||
|
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
|
||||||
|
uartBitbang_SendMsg_ioError:
|
||||||
|
ldi r16, NET_IFACE_OFFS_ERR_COLLISIONS_LOW
|
||||||
|
ret
|
||||||
|
uartBitbang_SendMsg_lineBusyError:
|
||||||
|
ldi r16, NET_IFACE_OFFS_ERR_BUSY_LOW
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -23,10 +23,13 @@
|
|||||||
ATTN_Init:
|
ATTN_Init:
|
||||||
.ifdef INT0
|
.ifdef INT0
|
||||||
.if COM_IRQ_BIT_ATTN == INT0
|
.if COM_IRQ_BIT_ATTN == INT0
|
||||||
M_IO_READ r16, MCUCR
|
inr r16, MCUCR
|
||||||
cbr r16, (1<<ISC01) | (1<<ISC00)
|
cbr r16, (1<<ISC01) | (1<<ISC00)
|
||||||
sbr r16, (1<<ISC01) | (0<<ISC00) ; falling edge of ATTN
|
sbr r16, (1<<ISC01) | (0<<ISC00) ; falling edge of ATTN
|
||||||
|
outr MCUCR, r16
|
||||||
; sbr r16, (0<<ISC01) | (0<<ISC00) ; low level triggers
|
; sbr r16, (0<<ISC01) | (0<<ISC00) ; low level triggers
|
||||||
|
.endif
|
||||||
|
.endif
|
||||||
|
|
||||||
rcall ATTN_SetHighEnableIrq
|
rcall ATTN_SetHighEnableIrq
|
||||||
|
|
||||||
@@ -44,9 +47,9 @@ ATTN_Init:
|
|||||||
ATTN_SetLowDisableIrq:
|
ATTN_SetLowDisableIrq:
|
||||||
.ifdef INT0
|
.ifdef INT0
|
||||||
.if COM_IRQ_BIT_ATTN == INT0
|
.if COM_IRQ_BIT_ATTN == INT0
|
||||||
M_IO_READ r16, COM_IRQ_ADDR_ATTN ; disable irq for ATTN line
|
inr r16, COM_IRQ_ADDR_ATTN ; disable irq for ATTN line
|
||||||
cbr r16, (1<<COM_IRQ_BIT_ATTN)
|
cbr r16, (1<<COM_IRQ_BIT_ATTN)
|
||||||
M_IO_WRITE COM_IRQ_ADDR_ATTN, r16
|
outr COM_IRQ_ADDR_ATTN, r16
|
||||||
.endif
|
.endif
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
@@ -73,9 +76,9 @@ ATTN_SetHighEnableIrq:
|
|||||||
|
|
||||||
.ifdef INT0
|
.ifdef INT0
|
||||||
.if COM_IRQ_BIT_ATTN == INT0
|
.if COM_IRQ_BIT_ATTN == INT0
|
||||||
M_IO_READ r16, COM_IRQ_ADDR_ATTN ; enable irq for ATTN line
|
inr r16, COM_IRQ_ADDR_ATTN ; enable irq for ATTN line
|
||||||
sbr r16, (1<<COM_IRQ_BIT_ATTN)
|
sbr r16, (1<<COM_IRQ_BIT_ATTN)
|
||||||
M_IO_WRITE COM_IRQ_ADDR_ATTN, r16
|
outr COM_IRQ_ADDR_ATTN, r16
|
||||||
.endif
|
.endif
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
|
|||||||
@@ -171,6 +171,10 @@ netUartRecvPacket_haveBuf:
|
|||||||
rcall UART_StopRx ; (R16)
|
rcall UART_StopRx ; (R16)
|
||||||
sec
|
sec
|
||||||
ret
|
ret
|
||||||
|
netUartRecvPacket_noAddMsg:
|
||||||
|
rcall NET_Buffer_ReleaseByNum ; (R16, X)
|
||||||
|
ldi r16, NET_IFACE_OFFS_ERR_MISSED_LOW
|
||||||
|
rjmp netUartRecvPacket_incCounterRet
|
||||||
netUartRecvPacket_releaseBufRet:
|
netUartRecvPacket_releaseBufRet:
|
||||||
rcall NET_Buffer_ReleaseByNum ; (R16, X)
|
rcall NET_Buffer_ReleaseByNum ; (R16, X)
|
||||||
ldi r16, NET_IFACE_OFFS_ERR_NOBUF_LOW
|
ldi r16, NET_IFACE_OFFS_ERR_NOBUF_LOW
|
||||||
@@ -212,13 +216,14 @@ netUartRecvPacketIntoX:
|
|||||||
sec
|
sec
|
||||||
ret
|
ret
|
||||||
netUartRecvPacketIntoX_handleError:
|
netUartRecvPacketIntoX_handleError:
|
||||||
mov r17, r16
|
cpi r16, UART_ERROR_IO
|
||||||
cpi r17, UART_ERROR_IO
|
breq netUartRecvPacketIntoX_ioError
|
||||||
ldi r16, NET_IFACE_OFFS_ERR_IO_LOW
|
cpi r16, UART_ERROR_CONTENT
|
||||||
breq netUartRecvPacketIntoX_incCounterRetNc
|
|
||||||
cpi r17, UART_ERROR_CONTENT
|
|
||||||
breq netUartRecvPacketIntoX_contentError
|
breq netUartRecvPacketIntoX_contentError
|
||||||
rjmp netUartRecvPacketIntoX_retNc
|
rjmp netUartRecvPacketIntoX_retNc
|
||||||
|
netUartRecvPacketIntoX_ioError:
|
||||||
|
ldi r16, NET_IFACE_OFFS_ERR_IO_LOW
|
||||||
|
rjmp netUartRecvPacketIntoX_incCounterRetNc
|
||||||
netUartRecvPacketIntoX_contentError:
|
netUartRecvPacketIntoX_contentError:
|
||||||
ldi r16, NET_IFACE_OFFS_ERR_CONTENT_LOW
|
ldi r16, NET_IFACE_OFFS_ERR_CONTENT_LOW
|
||||||
netUartRecvPacketIntoX_incCounterRetNc:
|
netUartRecvPacketIntoX_incCounterRetNc:
|
||||||
|
|||||||
@@ -38,16 +38,17 @@ UART_Init:
|
|||||||
ldi r17, 0
|
ldi r17, 0
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
M_IO_WRITE UBRRH, r17
|
outr UBRRH, r17
|
||||||
M_IO_WRITE UBRRL, r16
|
outr UBRRL, r16
|
||||||
|
|
||||||
; set character format
|
; set character format
|
||||||
.ifdef URSEL
|
.ifdef URSEL
|
||||||
ldi r16, (1<<URSEL) | (1<<USBS) | (1<<UCSZ1) | (1<<UCSZ0)
|
; ldi r16, (1<<URSEL) | (1<<USBS) | (1<<UCSZ1) | (1<<UCSZ0)
|
||||||
|
ldi r16, (1<<URSEL) | (1<<USBS) | (3<<UCSZ0)
|
||||||
.else
|
.else
|
||||||
ldi r16, (1<<USBS) | (1<<UCSZ1) | (1<<UCSZ0)
|
ldi r16, (1<<USBS) | (1<<UCSZ1) | (1<<UCSZ0)
|
||||||
.endif
|
.endif
|
||||||
M_IO_WRITE UCSRC, r16
|
outr UCSRC, r16
|
||||||
|
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
@@ -69,16 +70,16 @@ UART_SendBytes:
|
|||||||
|
|
||||||
; send bytes
|
; send bytes
|
||||||
UART_SendBytes_loop1:
|
UART_SendBytes_loop1:
|
||||||
M_IO_READ r16, UCSRA
|
inr r16, UCSRA
|
||||||
sbrs r16, UDRE
|
sbrs r16, UDRE
|
||||||
rjmp UART_SendBytes_loop1
|
rjmp UART_SendBytes_loop1
|
||||||
ld r16, X+
|
ld r16, X+
|
||||||
M_IO_WRITE UDR, r16
|
outr UDR, r16
|
||||||
dec r17
|
dec r17
|
||||||
brne UART_SendBytes_loop1
|
brne UART_SendBytes_loop1
|
||||||
; wait until all data sent
|
; wait until all data sent
|
||||||
UART_SendBytes_loop2:
|
UART_SendBytes_loop2:
|
||||||
M_IO_READ r16, UCSRA
|
inr r16, UCSRA
|
||||||
sbrs r16, TXC
|
sbrs r16, TXC
|
||||||
rjmp UART_SendBytes_loop2
|
rjmp UART_SendBytes_loop2
|
||||||
rcall UART_StopTx
|
rcall UART_StopTx
|
||||||
@@ -100,7 +101,7 @@ UART_SendBytes_secRet:
|
|||||||
UART_RecvPacket:
|
UART_RecvPacket:
|
||||||
cpi r17, 3
|
cpi r17, 3
|
||||||
brcs UART_RecvPacket_invalid
|
brcs UART_RecvPacket_invalid
|
||||||
rcall uartRecvByteWithin10ms ; recv destination address
|
rcall uartRecvByteWithin10ms ; recv destination address (R16)
|
||||||
brcc UART_RecvPacket_ioError
|
brcc UART_RecvPacket_ioError
|
||||||
cp r16, r18
|
cp r16, r18
|
||||||
breq UART_RecvPacket_forMe
|
breq UART_RecvPacket_forMe
|
||||||
@@ -158,10 +159,10 @@ uartRecvByteWithin10ms:
|
|||||||
pop r22
|
pop r22
|
||||||
pop r20
|
pop r20
|
||||||
brcc uartRecvByteWithin10ms_end
|
brcc uartRecvByteWithin10ms_end
|
||||||
M_IO_READ r16, UCSRA ; check for errors
|
inr r16, UCSRA ; check for errors
|
||||||
andi r16, (1<<FE) | (1<<DOR)
|
andi r16, (1<<FE) | (1<<DOR)
|
||||||
brne uartRecvByteWithin10ms_error
|
brne uartRecvByteWithin10ms_error
|
||||||
M_IO_READ r16, UDR ; read data byte
|
inr r16, UDR ; read data byte
|
||||||
sec
|
sec
|
||||||
ret
|
ret
|
||||||
uartRecvByteWithin10ms_error:
|
uartRecvByteWithin10ms_error:
|
||||||
@@ -213,7 +214,7 @@ uartWaitForData10ms_gotit:
|
|||||||
uartWaitForData1000Cycles:
|
uartWaitForData1000Cycles:
|
||||||
ldi r20, 140 ; 1
|
ldi r20, 140 ; 1
|
||||||
uartWaitForData_loop:
|
uartWaitForData_loop:
|
||||||
M_IO_READ r22, UCSRA ; 2
|
inr r22, UCSRA ; 2
|
||||||
sbrc r22, RXC ; 2/3
|
sbrc r22, RXC ; 2/3
|
||||||
rjmp uartWaitForData_gotit ; 2
|
rjmp uartWaitForData_gotit ; 2
|
||||||
dec r20 ; 1
|
dec r20 ; 1
|
||||||
@@ -235,14 +236,14 @@ uartWaitForData_gotit:
|
|||||||
; @clobbers R16
|
; @clobbers R16
|
||||||
|
|
||||||
UART_StartRx:
|
UART_StartRx:
|
||||||
M_IO_READ r16, UCSRA ; clear errors
|
inr r16, UCSRA ; clear errors
|
||||||
cbr r16, (1<<FE) | (1<<DOR) | (1<<UPE)
|
cbr r16, (1<<FE) | (1<<DOR) | (1<<UPE)
|
||||||
sbr r16, (1<<RXC)
|
sbr r16, (1<<RXC)
|
||||||
M_IO_WRITE UCSRA, r16
|
outr UCSRA, r16
|
||||||
|
|
||||||
M_IO_READ r16, UCSRB
|
inr r16, UCSRB
|
||||||
sbr r16, (1<<RXEN) ; enable receive
|
sbr r16, (1<<RXEN) ; enable receive
|
||||||
M_IO_WRITE UCSRB, r16
|
outr UCSRB, r16
|
||||||
|
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
@@ -255,9 +256,9 @@ UART_StartRx:
|
|||||||
; @clobbers R16
|
; @clobbers R16
|
||||||
|
|
||||||
UART_StopRx:
|
UART_StopRx:
|
||||||
M_IO_READ r16, UCSRB
|
inr r16, UCSRB
|
||||||
cbr r16, (1<<RXCIE | (1<<RXEN)) ; disable RX complete interrupt, disable receive
|
cbr r16, (1<<RXCIE | (1<<RXEN)) ; disable RX complete interrupt, disable receive
|
||||||
M_IO_WRITE UCSRB, r16
|
outr UCSRB, r16
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
@@ -270,13 +271,13 @@ UART_StopRx:
|
|||||||
; @clobbers R16
|
; @clobbers R16
|
||||||
|
|
||||||
UART_StartTx:
|
UART_StartTx:
|
||||||
M_IO_READ r16, UCSRA
|
inr r16, UCSRA
|
||||||
sbr r16, (1<<TXC) ; clear TXC interrupt
|
sbr r16, (1<<TXC) ; clear TXC interrupt
|
||||||
M_IO_WRITE UCSRA, r16
|
outr UCSRA, r16
|
||||||
|
|
||||||
M_IO_READ r16, UCSRB
|
inr r16, UCSRB
|
||||||
sbr r16, (1<<TXEN) ; enable transceive
|
sbr r16, (1<<TXEN) ; enable transceive
|
||||||
M_IO_WRITE UCSRB, r16
|
outr UCSRB, r16
|
||||||
|
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
@@ -290,9 +291,9 @@ UART_StartTx:
|
|||||||
; @clobbers R16
|
; @clobbers R16
|
||||||
|
|
||||||
UART_StopTx:
|
UART_StopTx:
|
||||||
M_IO_READ r16, UCSRB
|
inr r16, UCSRB
|
||||||
cbr r16, (1<<UDRIE) | (1<<TXC) | (1<<TXEN) ; disable TX UDRE and TXC1 interrupt, enable transceive
|
cbr r16, (1<<UDRIE) | (1<<TXC) | (1<<TXEN) ; disable TX UDRE and TXC1 interrupt, enable transceive
|
||||||
M_IO_WRITE UCSRB, r16
|
outr UCSRB, r16
|
||||||
|
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|||||||
@@ -40,9 +40,9 @@ XRAM_Init:
|
|||||||
sts xramLastAddress, r16
|
sts xramLastAddress, r16
|
||||||
sts xramLastAddress+1, r16
|
sts xramLastAddress+1, r16
|
||||||
|
|
||||||
M_IO_READ r16, MCUCR
|
inr r16, MCUCR
|
||||||
sbr r16, (1<<SRE)
|
sbr r16, (1<<SRE)
|
||||||
M_IO_WRITE MCUCR, r16
|
outr MCUCR, r16
|
||||||
|
|
||||||
rcall xramWritePattern
|
rcall xramWritePattern
|
||||||
rcall xramVerifyPattern
|
rcall xramVerifyPattern
|
||||||
|
|||||||
15
avr/version.asm
Normal file
15
avr/version.asm
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
; ***************************************************************************
|
||||||
|
; 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 FIRMWARE_VERSION_MAJOR = 1
|
||||||
|
.equ FIRMWARE_VERSION_MINOR = 0
|
||||||
|
.equ FIRMWARE_VERSION_PATCHLEVEL = 0
|
||||||
|
|
||||||
@@ -10,6 +10,18 @@
|
|||||||
<value name="MOTION" id="0x07" type="sensor" dataType="rational" modality="motion" denom="1" />
|
<value name="MOTION" id="0x07" type="sensor" dataType="rational" modality="motion" denom="1" />
|
||||||
<value name="DOOR" id="0x08" type="sensor" dataType="rational" modality="door" denom="1" />
|
<value name="DOOR" id="0x08" type="sensor" dataType="rational" modality="door" denom="1" />
|
||||||
|
|
||||||
|
<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" />
|
||||||
|
|
||||||
<value name="LEDTIMING" id="0x88" type="actor" dataType="uint16" />
|
<value name="LEDTIMING" id="0x88" type="actor" dataType="uint16" />
|
||||||
</values>
|
</values>
|
||||||
|
|
||||||
|
|||||||
16
flashnode.sh
16
flashnode.sh
@@ -16,12 +16,26 @@ 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"
|
||||||
;;
|
;;
|
||||||
|
n16)
|
||||||
|
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/n16/boot/n16_boot.hex"
|
||||||
|
;;
|
||||||
|
n20)
|
||||||
|
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/n20/n20_boot.hex"
|
||||||
|
;;
|
||||||
n21)
|
n21)
|
||||||
DEVICE_ARG="-p t84"
|
DEVICE_ARG="-p t84"
|
||||||
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="-U flash:w:./0-build/avr/devices/n21/boot/n21_boot.hex"
|
FILE_ARG="-U flash:w:./0-build/avr/devices/n21/boot/n21_boot.hex"
|
||||||
;;
|
;;
|
||||||
n22)
|
n22)
|
||||||
DEVICE_ARG="-p t85"
|
DEVICE_ARG="-p t85"
|
||||||
|
|||||||
Reference in New Issue
Block a user