Stefan Schuermans commited on 2012-05-06 20:04:32
Showing 11 changed files, with 194 additions and 7 deletions.
... | ... |
@@ -63,7 +63,7 @@ SRC = $(TARGET).c |
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 | 65 |
eeprom.c ethernet.c http.c icmp.c ip.c random.c rtl8019.c \ |
66 |
- ser62500.c status.c tasks.c tcp.c timing.c uart.c udp.c \ |
|
66 |
+ ser115200.c ser62500.c status.c tasks.c tcp.c timing.c uart.c udp.c \ |
|
67 | 67 |
xtea.c |
68 | 68 |
|
69 | 69 |
# You can also wrap lines by appending a backslash to the end of the line: |
... | ... |
@@ -79,7 +79,7 @@ SRC += app_bbm.c app_cfg.c apps.c apps_tools.c \ |
79 | 79 |
# Even though the DOS/Win* filesystem matches both .s and .S the same, |
80 | 80 |
# it will preserve the spelling of the filenames, and gcc itself does |
81 | 81 |
# care about how the name is spelled on its command-line. |
82 |
-ASRC = ser62500_asm.S |
|
82 |
+ASRC = ser115200_asm.S ser62500_asm.S |
|
83 | 83 |
|
84 | 84 |
|
85 | 85 |
# List any extra directories to look for include files here. |
... | ... |
@@ -12,6 +12,7 @@ |
12 | 12 |
#include "dosfs.h" |
13 | 13 |
#include "nethelp.h" |
14 | 14 |
#include "udp.h" |
15 |
+#include "ser115200.h" |
|
15 | 16 |
#include "timing.h" |
16 | 17 |
|
17 | 18 |
///< BBM file header |
... | ... |
@@ -243,6 +244,10 @@ static void AppBbmProcFrame(AppBbmState *state) |
243 | 244 |
UdpSend((unsigned char *)&pack, sizeof(pack)); |
244 | 245 |
} |
245 | 246 |
|
247 |
+ // serial output 115200 8N1 |
|
248 |
+ if (state->ser115k2) |
|
249 |
+ Ser115200Send((unsigned char *)&pack.mcuf, sizeof(pack.mcuf)); |
|
250 |
+ |
|
246 | 251 |
// frame duration not more than one second |
247 | 252 |
if (duration <= 1000) { |
248 | 253 |
// wait for frame duration |
... | ... |
@@ -282,6 +287,7 @@ void AppBbmInit(AppBbmState *state) // (extern) |
282 | 287 |
state->isInit = 0; |
283 | 288 |
|
284 | 289 |
// get destination address for MCUF frames |
290 |
+ { |
|
285 | 291 |
char filename[12]; |
286 | 292 |
sprintf(filename, "bbm%hhu/addr", state->no); |
287 | 293 |
if (AppsToolsReadIp(*state->sectorBuf, state->vi, |
... | ... |
@@ -294,6 +300,7 @@ void AppBbmInit(AppBbmState *state) // (extern) |
294 | 300 |
state->haveAddr = 0; |
295 | 301 |
debug_app_bbm_printf("%hhu: no address", state->no); |
296 | 302 |
} |
303 |
+ } |
|
297 | 304 |
|
298 | 305 |
// get destination port for MCUF frames |
299 | 306 |
if (state->haveAddr) { |
... | ... |
@@ -305,6 +312,16 @@ void AppBbmInit(AppBbmState *state) // (extern) |
305 | 312 |
debug_app_bbm_printf("%hhu: port %hu", state->no, state->port); |
306 | 313 |
} |
307 | 314 |
|
315 |
+ // check if serial output 115200 8N1 is requested |
|
316 |
+ { |
|
317 |
+ char filename[13], serDummy[3]; |
|
318 |
+ sprintf(filename, "bbm%hhu/115k2", state->no); |
|
319 |
+ state->ser115k2 = AppsToolsReadStr(*state->sectorBuf, state->vi, filename, |
|
320 |
+ serDummy, sizeof(serDummy)) == 0; |
|
321 |
+ debug_app_bbm_printf("%hhu: serial output 115200 8N1: %c", |
|
322 |
+ state->no, state->ser115k2 ? 'Y' : 'n'); |
|
323 |
+ } |
|
324 |
+ |
|
308 | 325 |
// initialize internal state |
309 | 326 |
state->idxFile = 0; |
310 | 327 |
state->haveFile = 0; |
... | ... |
@@ -20,6 +20,7 @@ typedef struct app_bbm_state { |
20 | 20 |
char haveAddr; ///< if destination address for MCUF is known |
21 | 21 |
unsigned char addr[4]; ///< destination address for MCUF packets |
22 | 22 |
unsigned short port; ///< destination port for MCUF packets |
23 |
+ char ser115k2; ///< if serial output 115200 8N1 is requested |
|
23 | 24 |
unsigned int idxFile; ///< index of file to open next |
24 | 25 |
char haveFile; ///< if a file is open |
25 | 26 |
FILEINFO fi; ///< information about open file |
... | ... |
@@ -113,13 +113,16 @@ void AppsRun(void) // (extern) |
113 | 113 |
// initialize applications |
114 | 114 |
AppBbmState bbm0 = { .sectorBuf = §orBuf, .vi = &vi, .no = 0 }; |
115 | 115 |
AppBbmState bbm1 = { .sectorBuf = §orBuf, .vi = &vi, .no = 1 }; |
116 |
+ AppBbmState bbm2 = { .sectorBuf = §orBuf, .vi = &vi, .no = 2 }; |
|
116 | 117 |
AppBbmInit(&bbm0); |
117 | 118 |
AppBbmInit(&bbm1); |
119 |
+ AppBbmInit(&bbm2); |
|
118 | 120 |
|
119 | 121 |
// run applications |
120 | 122 |
while (CfIsPresent()) { |
121 | 123 |
AppBbmRun(&bbm0); |
122 | 124 |
AppBbmRun(&bbm1); |
125 |
+ AppBbmRun(&bbm2); |
|
123 | 126 |
Tasks(); |
124 | 127 |
} |
125 | 128 |
} |
... | ... |
@@ -15,6 +15,7 @@ |
15 | 15 |
#include "http.h" |
16 | 16 |
#include "random.h" |
17 | 17 |
#include "rtl8019.h" |
18 |
+#include "ser115200.h" |
|
18 | 19 |
#include "status.h" |
19 | 20 |
#include "tasks.h" |
20 | 21 |
#include "tcp.h" |
... | ... |
@@ -79,6 +80,7 @@ int main(void) |
79 | 80 |
CfInit(); |
80 | 81 |
RtlInit(); |
81 | 82 |
StatusInit(); |
83 |
+ Ser115200Init(); |
|
82 | 84 |
TimingInit(); |
83 | 85 |
|
84 | 86 |
// initialize high level modules |
... | ... |
@@ -0,0 +1,28 @@ |
1 |
+/* flaneth - flash and ethernet |
|
2 |
+ Copyright (C) 2007-2012 Stefan Schuermans <stefan@schuermans.info> |
|
3 |
+ Copyleft: GNU public license V2 - http://www.gnu.org/copyleft/gpl.html |
|
4 |
+ a BlinkenArea project - http://www.blinkenarea.org/ */ |
|
5 |
+ |
|
6 |
+#include <avr/io.h> |
|
7 |
+#include <avr/wdt.h> |
|
8 |
+ |
|
9 |
+#include "ser115200.h" |
|
10 |
+ |
|
11 |
+// initialize |
|
12 |
+void Ser115200Init(void) // (extern) |
|
13 |
+{ |
|
14 |
+ DDRD |= 1 << 3; |
|
15 |
+ PORTD |= 1 << 3; |
|
16 |
+} |
|
17 |
+ |
|
18 |
+// send data with 115200 baud in 8N1 protocol |
|
19 |
+void Ser115200Send(unsigned char *ptr, unsigned short len) |
|
20 |
+{ |
|
21 |
+ while (len > 0) { |
|
22 |
+ wdt_reset(); |
|
23 |
+ Ser115200Out(*ptr); |
|
24 |
+ ++ptr; |
|
25 |
+ --len; |
|
26 |
+ } |
|
27 |
+} |
|
28 |
+ |
... | ... |
@@ -0,0 +1,19 @@ |
1 |
+/* flaneth - flash and ethernet |
|
2 |
+ Copyright (C) 2007-2012 Stefan Schuermans <stefan@schuermans.info> |
|
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_ser115200 |
|
7 |
+#define INC_ser115200 |
|
8 |
+ |
|
9 |
+// initialize |
|
10 |
+extern void Ser115200Init(void); |
|
11 |
+ |
|
12 |
+// send data with 115200 baud in 8N1 protocol |
|
13 |
+extern void Ser115200Send(unsigned char *ptr, unsigned short len); |
|
14 |
+ |
|
15 |
+// output a byte item with 115200 baud in 8N1 protocol |
|
16 |
+extern void Ser115200Out(unsigned char val); |
|
17 |
+ |
|
18 |
+#endif // #ifdef INC_ser115200 |
|
19 |
+ |
... | ... |
@@ -0,0 +1,118 @@ |
1 |
+; flaneth - flash and ethernet |
|
2 |
+; Copyright (C) 2007-2012 Stefan Schuermans <stefan@schuermans.info> |
|
3 |
+; Copyleft: GNU public license V2 - http://www.gnu.org/copyleft/gpl.html |
|
4 |
+; a BlinkenArea project - http://www.blinkenarea.org/ */ |
|
5 |
+ |
|
6 |
+ |
|
7 |
+#include <avr/io.h> |
|
8 |
+ |
|
9 |
+.section .text |
|
10 |
+ |
|
11 |
+ |
|
12 |
+ |
|
13 |
+; output = PD3 |
|
14 |
+ |
|
15 |
+ |
|
16 |
+ |
|
17 |
+; output a byte item with 115200 baud in 8N1 protocol |
|
18 |
+; extern void Ser115200Out(unsigned char val); |
|
19 |
+.global Ser115200Out |
|
20 |
+.func Ser115200Out |
|
21 |
+Ser115200Out: |
|
22 |
+ push R17 |
|
23 |
+ push R16 |
|
24 |
+ |
|
25 |
+ ; parameters: R24=val |
|
26 |
+ |
|
27 |
+ in R17,SREG-0x20 ; interrupts off |
|
28 |
+ cli |
|
29 |
+ |
|
30 |
+ clt ; start bit |
|
31 |
+ in R16,PORTD-0x20 |
|
32 |
+ bld R16,3 |
|
33 |
+ out PORTD-0x20,R16 |
|
34 |
+ |
|
35 |
+ rcall wait135 |
|
36 |
+ |
|
37 |
+ bst R24,0 ; bit 0 |
|
38 |
+ in R16,PORTD-0x20 |
|
39 |
+ bld R16,3 |
|
40 |
+ out PORTD-0x20,R16 |
|
41 |
+ |
|
42 |
+ rcall wait135 |
|
43 |
+ |
|
44 |
+ bst R24,1 ; bit 1 |
|
45 |
+ in R16,PORTD-0x20 |
|
46 |
+ bld R16,3 |
|
47 |
+ out PORTD-0x20,R16 |
|
48 |
+ |
|
49 |
+ rcall wait135 |
|
50 |
+ |
|
51 |
+ bst R24,2 ; bit 2 |
|
52 |
+ in R16,PORTD-0x20 |
|
53 |
+ bld R16,3 |
|
54 |
+ out PORTD-0x20,R16 |
|
55 |
+ |
|
56 |
+ rcall wait135 |
|
57 |
+ |
|
58 |
+ bst R24,3 ; bit 3 |
|
59 |
+ in R16,PORTD-0x20 |
|
60 |
+ bld R16,3 |
|
61 |
+ out PORTD-0x20,R16 |
|
62 |
+ |
|
63 |
+ rcall wait135 |
|
64 |
+ |
|
65 |
+ bst R24,4 ; bit 4 |
|
66 |
+ in R16,PORTD-0x20 |
|
67 |
+ bld R16,3 |
|
68 |
+ out PORTD-0x20,R16 |
|
69 |
+ |
|
70 |
+ rcall wait135 |
|
71 |
+ |
|
72 |
+ bst R24,5 ; bit 5 |
|
73 |
+ in R16,PORTD-0x20 |
|
74 |
+ bld R16,3 |
|
75 |
+ out PORTD-0x20,R16 |
|
76 |
+ |
|
77 |
+ rcall wait135 |
|
78 |
+ |
|
79 |
+ bst R24,6 ; bit 6 |
|
80 |
+ in R16,PORTD-0x20 |
|
81 |
+ bld R16,3 |
|
82 |
+ out PORTD-0x20,R16 |
|
83 |
+ |
|
84 |
+ rcall wait135 |
|
85 |
+ |
|
86 |
+ bst R24,7 ; bit 7 |
|
87 |
+ in R16,PORTD-0x20 |
|
88 |
+ bld R16,3 |
|
89 |
+ out PORTD-0x20,R16 |
|
90 |
+ |
|
91 |
+ rcall wait135 |
|
92 |
+ |
|
93 |
+ set ; stop bit |
|
94 |
+ in R16,PORTD-0x20 |
|
95 |
+ bld R16,3 |
|
96 |
+ out PORTD-0x20,R16 |
|
97 |
+ |
|
98 |
+ rcall wait135 |
|
99 |
+ |
|
100 |
+ out SREG-0x20,R17 ; restore interrupt state |
|
101 |
+ |
|
102 |
+ pop R16 |
|
103 |
+ pop R17 |
|
104 |
+ ret |
|
105 |
+.endfunc |
|
106 |
+ |
|
107 |
+ |
|
108 |
+ |
|
109 |
+; wait 135 cycles (including rcall and ret) |
|
110 |
+wait135: |
|
111 |
+ nop ; 2 cycles |
|
112 |
+ nop |
|
113 |
+ ldi R16, 42 ; 1 cycle, N := 42 |
|
114 |
+wait_loop: |
|
115 |
+ dec R16 ; N cycles |
|
116 |
+ brne wait_loop ; 2N-1 cycles |
|
117 |
+ ret ; 7 cycles (including rcall) |
|
118 |
+ |
... | ... |
@@ -1,7 +1,7 @@ |
1 |
-; 8BitAmEthernet - serial output 250kbps |
|
2 |
-; version 0.4.0 date 2006-04-13 |
|
3 |
-; Copyright 2005-2006 Stefan Schuermans <1stein@schuermans.info> |
|
4 |
-; Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html |
|
1 |
+; flaneth - flash and ethernet |
|
2 |
+; Copyright (C) 2007-2012 Stefan Schuermans <stefan@schuermans.info> |
|
3 |
+; Copyleft: GNU public license V2 - http://www.gnu.org/copyleft/gpl.html |
|
4 |
+; a BlinkenArea project - http://www.blinkenarea.org/ */ |
|
5 | 5 |
|
6 | 6 |
|
7 | 7 |
#include <avr/io.h> |
... | ... |
@@ -16,7 +16,6 @@ |
16 | 16 |
|
17 | 17 |
; output a data item with 62500 baud in 9N2 protocol |
18 | 18 |
; extern void Ser62500Out9N2( unsigned short item ); |
19 |
-; extern void SerialOutput( unsigned char value ); |
|
20 | 19 |
.global Ser62500Out9N2 |
21 | 20 |
.func Ser62500Out9N2 |
22 | 21 |
Ser62500Out9N2: |
23 | 22 |