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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [io/] [serial/] [v2_0/] [tests/] [flow2.c] - Blame information for rev 174

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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