annotate packages/devs/can/loop/current/tests/can_callback.c @ 2424:4c366bd69cd5

* tests/can_overrun1.c (can0_thread): Fix the length of the data in the message. Add a delay to allow the CAN device to process the packets. * test/can_txcevent.c: (can0_thread): Add a delay to allow the CAN device to process the packet.s * src/loop_can.c (FIFO_SIZE): Changed to one more than the TX queue size. If it is less, the loopback tests don't pass because packets don't get transmitted.
author asl
date Tue, 28 Aug 2007 15:56:03 +0000
parents 51899a482fdd
children 74dbf4c3f2e1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2421
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
1 //==========================================================================
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
2 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
3 // can_callback.c
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
4 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
5 // CAN driver test of callback on event
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
6 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
7 //==========================================================================
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
8 //####ECOSGPLCOPYRIGHTBEGIN####
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
9 // -------------------------------------------
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
10 // This file is part of eCos, the Embedded Configurable Operating System.
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
12 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
13 // eCos is free software; you can redistribute it and/or modify it under
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
14 // the terms of the GNU General Public License as published by the Free
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
15 // Software Foundation; either version 2 or (at your option) any later version.
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
16 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
17 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
18 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
19 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
20 // for more details.
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
21 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
22 // You should have received a copy of the GNU General Public License along
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
23 // with eCos; if not, write to the Free Software Foundation, Inc.,
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
24 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
25 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
26 // As a special exception, if other files instantiate templates or use macros
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
27 // or inline functions from this file, or you compile this file and link it
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
28 // with other works to produce a work based on this file, this file does not
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
29 // by itself cause the resulting work to be covered by the GNU General Public
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
30 // License. However the source code for this file must still be made available
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
31 // in accordance with section (3) of the GNU General Public License.
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
32 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
33 // This exception does not invalidate any other reasons why a work based on
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
34 // this file might be covered by the GNU General Public License.
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
35 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
36 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
37 // at http://sources.redhat.com/ecos/ecos-license/
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
38 // -------------------------------------------
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
39 //####ECOSGPLCOPYRIGHTEND####
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
40 //==========================================================================
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
41 //#####DESCRIPTIONBEGIN####
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
42 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
43 // Author(s): Uwe Kindler, Alexey Shusharin
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
44 // Contributors: Uwe Kindler, Alexey Shusharin
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
45 // Date: 2007-08-23
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
46 // Description: CAN driver test of callback on event
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
47 //####DESCRIPTIONEND####
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
48
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
49
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
50 //===========================================================================
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
51 // INCLUDES
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
52 //===========================================================================
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
53 #include <pkgconf/system.h>
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
54
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
55 #include <cyg/infra/testcase.h> // test macros
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
56 #include <cyg/infra/cyg_ass.h> // assertion macros
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
57 #include <cyg/infra/diag.h>
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
58
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
59 // Package requirements
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
60 #if defined(CYGPKG_IO_CAN) && defined(CYGPKG_KERNEL)
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
61
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
62 #include <pkgconf/kernel.h>
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
63 #include <cyg/io/io.h>
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
64 #include <cyg/io/canio.h>
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
65
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
66 // Package option requirements
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
67 #if defined(CYGFUN_KERNEL_API_C)
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
68
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
69 #include <cyg/hal/hal_arch.h> // CYGNUM_HAL_STACK_SIZE_TYPICAL
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
70 #include <cyg/kernel/kapi.h>
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
71
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
72 // Package option requirements
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
73 #if defined(CYGOPT_IO_CAN_SUPPORT_CALLBACK)
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
74
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
75 //===========================================================================
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
76 // DATA TYPES
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
77 //===========================================================================
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
78 typedef struct st_thread_data
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
79 {
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
80 cyg_thread obj;
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
81 long stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
82 cyg_handle_t hdl;
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
83 } thread_data_t;
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
84
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
85
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
86 //===========================================================================
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
87 // LOCAL DATA
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
88 //===========================================================================
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
89 cyg_thread_entry_t can_thread;
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
90 thread_data_t can_thread_data;
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
91
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
92 cyg_mutex_t can_lock;
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
93 cyg_cond_t can_wait;
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
94
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
95 cyg_io_handle_t hCAN0;
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
96 cyg_io_handle_t hCAN1;
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
97
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
98 //===========================================================================
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
99 // LOCAL FUNCTIONS
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
100 //===========================================================================
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
101 #include "can_test_aux.inl" // include CAN test auxiliary functions
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
102
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
103
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
104 //===========================================================================
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
105 // CALLBACK FUNCTION
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
106 //===========================================================================
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
107
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
108 static void callback_func(cyg_uint16 flags, CYG_ADDRWORD data)
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
109 {
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
110 if (data == ((CYG_ADDRWORD) hCAN0) && (flags & CYGNUM_CAN_EVENT_RX))
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
111 {
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
112 // Wake up thread
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
113 cyg_cond_signal(&can_wait);
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
114 }
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
115 }
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
116
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
117 //===========================================================================
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
118 // READER THREAD
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
119 //===========================================================================
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
120 void can_thread(cyg_addrword_t data)
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
121 {
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
122 cyg_uint32 len;
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
123 cyg_can_callback_cfg callback_cfg;
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
124 cyg_can_message tx_msg;
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
125 cyg_bool_t wait_res;
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
126
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
127 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
128 // open CAN0 device driver
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
129 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
130 if (ENOERR != cyg_io_lookup("/dev/can0", &hCAN0))
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
131 {
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
132 CYG_TEST_FAIL_FINISH("Error opening /dev/can0");
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
133 }
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
134
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
135 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
136 // open CAN1 device driver
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
137 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
138 if (ENOERR != cyg_io_lookup("/dev/can1", &hCAN1))
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
139 {
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
140 CYG_TEST_FAIL_FINISH("Error opening /dev/can1");
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
141 }
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
142
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
143 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
144 // configure CAN0 callback
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
145 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
146 len = sizeof(callback_cfg);
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
147 callback_cfg.flag_mask = 0xFFFF;
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
148 callback_cfg.data = (CYG_ADDRWORD) hCAN0;
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
149 callback_cfg.callback_func = callback_func;
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
150
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
151 if (ENOERR != cyg_io_set_config(hCAN0, CYG_IO_SET_CONFIG_CAN_CALLBACK,
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
152 &callback_cfg, &len))
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
153 {
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
154 CYG_TEST_FAIL_FINISH("Error writing config of /dev/can0");
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
155 }
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
156
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
157 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
158 // transmit message from CAN1 to CAN0
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
159 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
160 tx_msg.id = 0x001;
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
161 tx_msg.ext = CYGNUM_CAN_ID_STD;
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
162 tx_msg.rtr = CYGNUM_CAN_FRAME_DATA;
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
163 tx_msg.dlc = 0;
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
164 len = sizeof(tx_msg);
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
165
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
166 if (ENOERR != cyg_io_write(hCAN1, &tx_msg, &len))
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
167 {
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
168 CYG_TEST_FAIL_FINISH("Error writing message to /dev/can1");
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
169 }
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
170
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
171 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
172 // Wait CAN0 callback
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
173 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
174 cyg_mutex_lock(&can_lock);
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
175
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
176 wait_res = cyg_cond_timed_wait(&can_wait, 100);
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
177
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
178 cyg_mutex_unlock(&can_lock);
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
179
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
180 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
181 // If result of wait is a signal operation, test is successed
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
182 // If timeout - test is failed, because callback_func() hasn't been
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
183 // called with correct parameters
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
184 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
185 if(wait_res)
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
186 {
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
187 CYG_TEST_PASS_FINISH("can_callback test OK");
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
188 }
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
189 else
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
190 {
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
191 CYG_TEST_FAIL_FINISH("can_callback test FAILED");
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
192 }
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
193 }
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
194
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
195
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
196 void
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
197 cyg_start(void)
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
198 {
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
199 CYG_TEST_INIT();
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
200
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
201 cyg_mutex_init(&can_lock);
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
202 cyg_cond_init(&can_wait, &can_lock);
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
203
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
204 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
205 // create the main thread
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
206 //
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
207 cyg_thread_create(4, can_thread,
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
208 (cyg_addrword_t) 0,
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
209 "can_thread",
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
210 (void *) can_thread_data.stack,
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
211 1024 * sizeof(long),
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
212 &can_thread_data.hdl,
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
213 &can_thread_data.obj);
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
214
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
215 cyg_thread_resume(can_thread_data.hdl);
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
216
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
217 cyg_scheduler_start();
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
218 }
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
219
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
220 #else // #if defined(CYGOPT_IO_CAN_SUPPORT_CALLBACK)
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
221 #define N_A_MSG "Needs callback support"
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
222 #endif
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
223
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
224 #else // CYGFUN_KERNEL_API_C
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
225 #define N_A_MSG "Needs kernel C API"
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
226 #endif
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
227
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
228 #else // CYGPKG_IO_CAN && CYGPKG_KERNEL
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
229 #define N_A_MSG "Needs IO/CAN and Kernel"
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
230 #endif
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
231
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
232 #ifdef N_A_MSG
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
233 void
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
234 cyg_start( void )
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
235 {
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
236 CYG_TEST_INIT();
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
237 CYG_TEST_NA( N_A_MSG);
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
238 }
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
239 #endif // N_A_MSG
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
240
51899a482fdd * doc/synth_test.ecm: Import file for running the tests on synth.
asl
parents:
diff changeset
241 // EOF can_callback.c