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

Subversion Repositories openrisc

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

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//        serial5.c
4
//
5
//        Test data duplex receive and send.
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
44
// Contributors:  jskov
45
// Date:          1999-03-19
46
// Description:   Test the duplex receive and send capabilities of 
47
//                the serial driver.
48
// Requirements:  This test requires the ser_filter on the host side.
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
// Package requirements
57
#if defined(CYGPKG_IO_SERIAL) && defined(CYGPKG_KERNEL)
58
 
59
#include <pkgconf/kernel.h>
60
 
61
// Package option requirements
62
#if defined(CYGFUN_KERNEL_API_C)
63
 
64
#include <cyg/hal/hal_arch.h>           // CYGNUM_HAL_STACK_SIZE_TYPICAL
65
#include <cyg/kernel/kapi.h>
66
unsigned char stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
67
cyg_thread thread_data;
68
cyg_handle_t thread_handle;
69
 
70
#include "ser_test_protocol.inl"
71
 
72
//---------------------------------------------------------------------------
73
// Serial test main function.
74
void
75
serial_test( void )
76
{
77
    cyg_io_handle_t ser_handle;
78
 
79
    test_open_ser(&ser_handle);
80
 
81
    // We need the filter for this test.
82
    test_ping(ser_handle);
83
 
84
 
85
#if (CYGINT_IO_SERIAL_TEST_SKIP_38400 > 0)
86
    {
87
        // The board is too slow to run the driver in interrupt mode
88
        // at the default 38400 baud when doing this test, so run it
89
        // at a slower rate.
90
        cyg_ser_cfg_t slow_cfg = {
91
            CYGNUM_SERIAL_BAUD_19200, CYGNUM_SERIAL_WORD_LENGTH_8,
92
            CYGNUM_SERIAL_STOP_1, CYGNUM_SERIAL_PARITY_NONE,
93
            CYGNUM_SERIAL_FLOW_NONE };
94
 
95
        CYG_TEST_INFO("Reducing baud rate to 19200");
96
        change_config(ser_handle, &slow_cfg);
97
    }
98
#endif
99
 
100
    // Start out slow, then go for many tests. Each cycle causes
101
    // 512 bytes to be sent over the wire.
102
    test_binary(ser_handle,    1, MODE_DUPLEX_ECHO);
103
    test_binary(ser_handle,    2, MODE_DUPLEX_ECHO);
104
    test_binary(ser_handle,    5, MODE_DUPLEX_ECHO);
105
 
106
#if 0 // Disable these until the ser_filter produces status output.
107
    test_binary(ser_handle,  128, MODE_DUPLEX_ECHO);
108
    test_binary(ser_handle,  512, MODE_DUPLEX_ECHO);
109
    test_binary(ser_handle, 1024, MODE_DUPLEX_ECHO);
110
#endif
111
 
112
    CYG_TEST_PASS_FINISH("serial5 test OK");
113
}
114
 
115
void
116
cyg_start(void)
117
{
118
    CYG_TEST_INIT();
119
    cyg_thread_create(10,                   // Priority - just a number
120
                      (cyg_thread_entry_t*)serial_test,         // entry
121
                      0,                    // 
122
                      "serial_thread",     // Name
123
                      &stack[0],            // Stack
124
                      CYGNUM_HAL_STACK_SIZE_TYPICAL,           // Size
125
                      &thread_handle,       // Handle
126
                      &thread_data          // Thread data structure
127
        );
128
    cyg_thread_resume(thread_handle);
129
    cyg_scheduler_start();
130
}
131
 
132
#else // CYGFUN_KERNEL_API_C
133
#define N_A_MSG "Needs kernel C API"
134
#endif
135
 
136
#else // CYGPKG_IO_SERIAL && CYGPKG_KERNEL
137
#define N_A_MSG "Needs IO/serial and Kernel"
138
#endif
139
 
140
#ifdef N_A_MSG
141
void
142
cyg_start( void )
143
{
144
    CYG_TEST_INIT();
145
    CYG_TEST_NA( N_A_MSG);
146
}
147
#endif // N_A_MSG
148
// EOF serial5.c

powered by: WebSVN 2.1.0

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