comparison packages/io/serial/current/tests/serial5.c @ 2:443894e2e912 ecos-v1_2_1-release

Block commit of eCos version 1.2.1
author jlarmour
date Tue, 11 May 1999 12:24:34 +0000
parents
children 641b639be825
comparison
equal deleted inserted replaced
1:72f549f0d891 2:443894e2e912
1 //==========================================================================
2 //
3 // serial5.c
4 //
5 // Test data duplex receive and send.
6 //
7 //==========================================================================
8 //####COPYRIGHTBEGIN####
9 //
10 // -------------------------------------------
11 // The contents of this file are subject to the Cygnus eCos Public License
12 // Version 1.0 (the "License"); you may not use this file except in
13 // compliance with the License. You may obtain a copy of the License at
14 // http://sourceware.cygnus.com/ecos
15 //
16 // Software distributed under the License is distributed on an "AS IS"
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
18 // License for the specific language governing rights and limitations under
19 // the License.
20 //
21 // The Original Code is eCos - Embedded Cygnus Operating System, released
22 // September 30, 1998.
23 //
24 // The Initial Developer of the Original Code is Cygnus. Portions created
25 // by Cygnus are Copyright (C) 1998, 1999 Cygnus Solutions.
26 // All Rights Reserved.
27 // -------------------------------------------
28 //
29 //####COPYRIGHTEND####
30 //==========================================================================
31 //#####DESCRIPTIONBEGIN####
32 //
33 // Author(s): jskov
34 // Contributors: jskov
35 // Date: 1999-03-19
36 // Description: Test the duplex receive and send capabilities of
37 // the serial driver.
38 // Requirements: This test requires the ser_filter on the host side.
39 //####DESCRIPTIONEND####
40
41 #include <pkgconf/system.h>
42
43 #include <cyg/infra/testcase.h> // test macros
44 #include <cyg/infra/cyg_ass.h> // assertion macros
45
46 #if defined(CYGPKG_IO_SERIAL) && defined(CYGPKG_KERNEL)
47
48 #ifdef CYGPKG_KERNEL
49 #include <pkgconf/kernel.h>
50 #ifdef CYGFUN_KERNEL_API_C
51 #include <cyg/hal/hal_arch.h> // CYGNUM_HAL_STACK_SIZE_TYPICAL
52 #include <cyg/kernel/kapi.h>
53 unsigned char stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
54 cyg_thread thread_data;
55 cyg_handle_t thread_handle;
56 #endif
57 #endif
58
59 #include "ser_test_protocol.inl"
60
61 //---------------------------------------------------------------------------
62 // Serial test main function.
63 void
64 serial_test( void )
65 {
66 cyg_io_handle_t ser_handle;
67
68 test_open_ser(&ser_handle);
69
70 // We need the filter for this test.
71 test_ping(ser_handle);
72
73 #if defined(CYGPKG_HAL_ARM_AEB)
74 {
75 // The AEB board is too slow to run the driver in interrupt mode
76 // at the default 38400 baud when doing this test.
77 cyg_ser_cfg_t arm_aeb_cfg = {
78 CYGNUM_SERIAL_BAUD_9600, CYGNUM_SERIAL_WORD_LENGTH_8,
79 CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_NONE };
80
81 change_config(ser_handle, &arm_aeb_cfg);
82 }
83 #endif
84
85 // Start out slow, then go for many tests. Each cycle causes
86 // 512 bytes to be sent over the wire.
87 test_binary(ser_handle, 1, MODE_DUPLEX_ECHO);
88 test_binary(ser_handle, 2, MODE_DUPLEX_ECHO);
89 test_binary(ser_handle, 5, MODE_DUPLEX_ECHO);
90
91 #if 0 // Disable these until the ser_filter produces status output.
92 test_binary(ser_handle, 128, MODE_DUPLEX_ECHO);
93 test_binary(ser_handle, 512, MODE_DUPLEX_ECHO);
94 test_binary(ser_handle, 1024, MODE_DUPLEX_ECHO);
95 #endif
96
97 CYG_TEST_PASS_FINISH("serial5 test OK");
98 }
99
100 void
101 cyg_start(void)
102 {
103 CYG_TEST_INIT();
104 #ifdef CYGFUN_KERNEL_API_C
105 cyg_thread_create(10, // Priority - just a number
106 (cyg_thread_entry_t*)serial_test, // entry
107 0, //
108 "serial_thread", // Name
109 &stack[0], // Stack
110 CYGNUM_HAL_STACK_SIZE_TYPICAL, // Size
111 &thread_handle, // Handle
112 &thread_data // Thread data structure
113 );
114 cyg_thread_resume(thread_handle);
115 cyg_scheduler_start();
116 #else
117 serial_test();
118 #endif
119 }
120
121 #else // ifdef CYGPKG_IO_SERIAL
122
123 void
124 cyg_start(void)
125 {
126 CYG_TEST_INIT();
127 CYG_TEST_NA("Requires serial device driver and kernel");
128 }
129
130 #endif
131 // EOF serial5.c