Stefan Schuermans commited on 2019-05-01 21:00:49
Showing 6 changed files, with 66 additions and 3 deletions.
... | ... |
@@ -62,7 +62,7 @@ SRC = $(TARGET).c |
62 | 62 |
# uncomment the following: |
63 | 63 |
SRC += app_bbm.c app_cfg.c apps.c apps_tools.c \ |
64 | 64 |
arp.c bus.c cf.c checksum.c config.c dhcp.c dosfs.c dosfs_user.c \ |
65 |
- eeprom.c ethernet.c http.c icmp.c ip.c random.c rtl8019.c \ |
|
65 |
+ eeprom.c ethernet.c http.c icmp.c ip.c mcuf_in.c random.c rtl8019.c \ |
|
66 | 66 |
ser115200.c ser62500.c status.c tasks.c tcp.c timing.c uart.c udp.c \ |
67 | 67 |
xtea.c |
68 | 68 |
|
... | ... |
@@ -10,6 +10,7 @@ |
10 | 10 |
#include "app_bbm.h" |
11 | 11 |
#include "debug.h" |
12 | 12 |
#include "dosfs.h" |
13 |
+#include "mcuf_in.h" |
|
13 | 14 |
#include "nethelp.h" |
14 | 15 |
#include "udp.h" |
15 | 16 |
#include "ser115200.h" |
... | ... |
@@ -244,9 +245,10 @@ static void AppBbmProcFrame(AppBbmState *state) |
244 | 245 |
UdpSend((unsigned char *)&pack, sizeof(pack)); |
245 | 246 |
} |
246 | 247 |
|
247 |
- // serial output 115200 8N1 |
|
248 |
- if (state->ser115k2) |
|
248 |
+ // serial output 115200 8N1 (if MCUF input is not active) |
|
249 |
+ if (state->ser115k2 && ! McufInIsActive()) { |
|
249 | 250 |
Ser115200Send((unsigned char *)&pack.mcuf, sizeof(pack.mcuf)); |
251 |
+ } |
|
250 | 252 |
|
251 | 253 |
// frame duration not more than one second |
252 | 254 |
if (duration <= 1000) { |
... | ... |
@@ -0,0 +1,34 @@ |
1 |
+/* flaneth - flash and ethernet |
|
2 |
+ Copyright (C) 2007-2012 Stefan Schuermans <stefan@blinkenarea.org> |
|
3 |
+ Copyleft: GNU public license V2 - http://www.gnu.org/copyleft/gpl.html |
|
4 |
+ a BlinkenArea project - http://www.blinkenarea.org/ */ |
|
5 |
+ |
|
6 |
+#include "mcuf_in.h" |
|
7 |
+#include "ser115200.h" |
|
8 |
+ |
|
9 |
+#define MCUF_IN_TIMEOUT 25 // 25 * 200ms = 5s |
|
10 |
+ |
|
11 |
+static unsigned int McufInTimeout = 0; |
|
12 |
+ |
|
13 |
+// check if MCUF input is active |
|
14 |
+int McufInIsActive(void) |
|
15 |
+{ |
|
16 |
+ return McufInTimeout > 0; // MCUF input active if timeout is greater zero |
|
17 |
+} |
|
18 |
+ |
|
19 |
+// tick procedure - call every 200ms |
|
20 |
+void McufInTick200(void) |
|
21 |
+{ |
|
22 |
+ // time out active MCUF input after 5s |
|
23 |
+ if (McufInTimeout > 0) { |
|
24 |
+ --McufInTimeout; |
|
25 |
+ } |
|
26 |
+} |
|
27 |
+ |
|
28 |
+// process a received MCUF packet |
|
29 |
+void McufInRecv(unsigned char *pData, unsigned short Length) |
|
30 |
+{ |
|
31 |
+ McufInTimeout = MCUF_IN_TIMEOUT; // MCUF input is active now |
|
32 |
+ Ser115200Send(pData, Length); |
|
33 |
+} |
|
34 |
+ |
... | ... |
@@ -0,0 +1,18 @@ |
1 |
+/* flaneth - flash and ethernet |
|
2 |
+ Copyright (C) 2007-2012 Stefan Schuermans <stefan@blinkenarea.org> |
|
3 |
+ Copyleft: GNU public license V2 - http://www.gnu.org/copyleft/gpl.html |
|
4 |
+ a BlinkenArea project - http://www.blinkenarea.org/ */ |
|
5 |
+ |
|
6 |
+#ifndef INC_mcuf_in |
|
7 |
+#define INC_mcuf_in |
|
8 |
+ |
|
9 |
+// check if MCUF input is active |
|
10 |
+extern int McufInIsActive(void); |
|
11 |
+ |
|
12 |
+// tick procedure - call every 200ms |
|
13 |
+extern void McufInTick200(void); |
|
14 |
+ |
|
15 |
+// process a received MCUF packet |
|
16 |
+extern void McufInRecv(unsigned char *pData, unsigned short Length); |
|
17 |
+ |
|
18 |
+#endif // #ifdef INC_mcuf_in |
... | ... |
@@ -11,6 +11,7 @@ |
11 | 11 |
#include "cf.h" |
12 | 12 |
#include "dhcp.h" |
13 | 13 |
#include "ip.h" |
14 |
+#include "mcuf_in.h" |
|
14 | 15 |
#include "random.h" |
15 | 16 |
#include "rtl8019.h" |
16 | 17 |
#include "status.h" |
... | ... |
@@ -111,6 +112,8 @@ void TimingTask(void) // (extern) |
111 | 112 |
case 3: |
112 | 113 |
IpTick200(); |
113 | 114 |
break; |
115 |
+ case 4: |
|
116 |
+ McufInTick200(); |
|
114 | 117 |
case 5: |
115 | 118 |
//RtlTick200(); |
116 | 119 |
break; |
... | ... |
@@ -10,6 +10,7 @@ |
10 | 10 |
#include "ethernet.h" |
11 | 11 |
#include "ip.h" |
12 | 12 |
#include "macros.h" |
13 |
+#include "mcuf_in.h" |
|
13 | 14 |
#include "nethelp.h" |
14 | 15 |
#include "ser62500.h" |
15 | 16 |
#include "udp.h" |
... | ... |
@@ -124,6 +125,11 @@ void UdpRecv(unsigned char *pData, unsigned short Length) // (extern) |
124 | 125 |
case 68: |
125 | 126 |
DhcpRecv(pData, Length); |
126 | 127 |
break; |
128 |
+ // MCUF -> to serial port |
|
129 |
+ case 2323: |
|
130 |
+ McufInRecv(pData + sizeof(struct UdpPacket), |
|
131 |
+ Length - sizeof(struct UdpPacket)); |
|
132 |
+ break; |
|
127 | 133 |
// serial output with 62500 baud in 9N2 protocol |
128 | 134 |
case 62500: |
129 | 135 |
Ser62500Send9N2(pData + sizeof(struct UdpPacket), |
130 | 136 |