OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [io/] [serial/] [current/] [tests/] [flow2.c] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//        flow2.c
4
//
5
//        Test duplex receive and send with flow control.
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under    
14
// the terms of the GNU General Public License as published by the Free     
15
// Software Foundation; either version 2 or (at your option) any later      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
21
// for more details.                                                        
22
//
23
// You should have received a copy of the GNU General Public License        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
//==========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):     jskov,jlarmour
43
// Contributors:  
44
// Date:          2000-07-27
45
// Description:   Test the duplex receive and send capabilities of 
46
//                the serial driver with flow control.
47
// Requirements:  This test requires the ser_filter on the host side.
48
// 
49
//####DESCRIPTIONEND####
50
 
51
#include <pkgconf/system.h>
52
 
53
#include <cyg/infra/testcase.h>         // test macros
54
#include <cyg/infra/cyg_ass.h>          // assertion macros
55
 
56
#ifdef CYGPKG_KERNEL
57
# include <pkgconf/kernel.h>
58
#endif
59
#ifdef CYGPKG_IO_SERIAL
60
# include <pkgconf/io_serial.h>
61
#endif
62
 
63
// Package requirements
64
#ifndef CYGPKG_IO_SERIAL
65
# define NA_MSG "Requires I/O serial package"
66
#elif !defined(CYGFUN_KERNEL_API_C)
67
# define NA_MSG "Requires kernel C API"
68
#elif !defined(CYGPKG_IO_SERIAL_FLOW_CONTROL)
69
# define NA_MSG "Requires serial flow control"
70
#endif
71
 
72
#ifdef NA_MSG
73
void
74
cyg_start( void )
75
{
76
    CYG_TEST_INIT();
77
    CYG_TEST_NA( NA_MSG);
78
}
79
#else
80
 
81
#include <cyg/hal/hal_arch.h>           // CYGNUM_HAL_STACK_SIZE_TYPICAL
82
#include <cyg/kernel/kapi.h>
83
unsigned char stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
84
cyg_thread thread_data;
85
cyg_handle_t thread_handle;
86
 
87
#include "ser_test_protocol.inl"
88
 
89
 
90
//---------------------------------------------------------------------------
91
// run the tests
92
 
93
static void
94
run_tests( cyg_io_handle_t ser_handle )
95
{
96
    // Start slowly, then go for max size.
97
    {
98
        test_binary(ser_handle,             16, MODE_DUPLEX_ECHO);
99
        test_binary(ser_handle,            128, MODE_DUPLEX_ECHO);
100
        test_binary(ser_handle,            256, MODE_DUPLEX_ECHO);
101
        test_binary(ser_handle,           1024, MODE_DUPLEX_ECHO);
102
    }
103
}
104
 
105
//---------------------------------------------------------------------------
106
// Serial test main function.
107
 
108
void
109
serial_test( void )
110
{
111
    cyg_io_handle_t ser_handle;
112
    cyg_ser_cfg_t *cfg=&test_configs[0];
113
    cyg_ser_cfg_t new_cfg;
114
    int count = sizeof(test_configs) / sizeof(cyg_ser_cfg_t);
115
    int i;
116
 
117
    test_open_ser(&ser_handle);
118
 
119
    // We need the filter for this test.
120
    test_ping(ser_handle);
121
 
122
    // Choose the configuration with the fastest baud rate, to be most
123
    // provocative. Start at 1 coz cfg already points at 0
124
    for (i=1; i<count; i++) {
125
        if (cfg->baud_rate < test_configs[i].baud_rate)
126
            cfg=&test_configs[i];
127
    }
128
 
129
    // Set flow control from configuration
130
    // Choose software first
131
 
132
#ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_SOFTWARE
133
    CYG_TEST_INFO("Setting software flow control");
134
 
135
    new_cfg = *cfg;
136
    new_cfg.flags |= CYGNUM_SERIAL_FLOW_XONXOFF_RX |
137
                     CYGNUM_SERIAL_FLOW_XONXOFF_TX;
138
    if (ENOERR == change_config(ser_handle, &new_cfg))
139
        run_tests( ser_handle );
140
#endif
141
 
142
    // hardware flow control
143
#ifdef CYGOPT_IO_SERIAL_FLOW_CONTROL_HW
144
    CYG_TEST_INFO("Setting RTS/CTS hardware flow control");
145
 
146
    new_cfg = *cfg;
147
    new_cfg.flags |= CYGNUM_SERIAL_FLOW_RTSCTS_RX|CYGNUM_SERIAL_FLOW_RTSCTS_TX;
148
    if (ENOERR == change_config(ser_handle, &new_cfg))
149
        run_tests( ser_handle );
150
 
151
    CYG_TEST_INFO("Setting DSR/DTR hardware flow control");
152
 
153
    new_cfg = *cfg;
154
    new_cfg.flags |= CYGNUM_SERIAL_FLOW_DSRDTR_RX|CYGNUM_SERIAL_FLOW_DSRDTR_TX;
155
    if (ENOERR == change_config(ser_handle, &new_cfg))
156
        run_tests( ser_handle );
157
#endif
158
 
159
    CYG_TEST_PASS_FINISH("flow2 test OK");
160
}
161
 
162
void
163
cyg_start(void)
164
{
165
    CYG_TEST_INIT();
166
    cyg_thread_create(10,                   // Priority - just a number
167
                      (cyg_thread_entry_t*)serial_test,         // entry
168
                      0,                    // 
169
                      "serial_thread",     // Name
170
                      &stack[0],            // Stack
171
                      CYGNUM_HAL_STACK_SIZE_TYPICAL,           // Size
172
                      &thread_handle,       // Handle
173
                      &thread_data          // Thread data structure
174
        );
175
    cyg_thread_resume(thread_handle);
176
    cyg_scheduler_start();
177
}
178
 
179
#endif // ifndef NA_MSG
180
 
181
// EOF flow2.c

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.