equal
deleted
inserted
replaced
3 * m a i l b o x . c |
3 * m a i l b o x . c |
4 * |
4 * |
5 * Mailbox functionality. |
5 * Mailbox functionality. |
6 * |
6 * |
7 * $Id$ |
7 * $Id$ |
|
8 * |
|
9 * Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
|
10 * |
|
11 * This file is part of the IgH EtherCAT Master. |
|
12 * |
|
13 * The IgH EtherCAT Master is free software; you can redistribute it |
|
14 * and/or modify it under the terms of the GNU General Public License |
|
15 * as published by the Free Software Foundation; version 2 of the License. |
|
16 * |
|
17 * The IgH EtherCAT Master is distributed in the hope that it will be |
|
18 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 * GNU General Public License for more details. |
|
21 * |
|
22 * You should have received a copy of the GNU General Public License |
|
23 * along with the IgH EtherCAT Master; if not, write to the Free Software |
|
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
8 * |
25 * |
9 *****************************************************************************/ |
26 *****************************************************************************/ |
10 |
27 |
11 #include <linux/slab.h> |
28 #include <linux/slab.h> |
12 #include <linux/delay.h> |
29 #include <linux/delay.h> |
18 /*****************************************************************************/ |
35 /*****************************************************************************/ |
19 |
36 |
20 /** |
37 /** |
21 Prepares a mailbox-send command. |
38 Prepares a mailbox-send command. |
22 \return pointer to mailbox command data |
39 \return pointer to mailbox command data |
|
40 \ingroup Slave |
23 */ |
41 */ |
24 |
42 |
25 uint8_t *ec_slave_mbox_prepare_send(ec_slave_t *slave, /**< slave */ |
43 uint8_t *ec_slave_mbox_prepare_send(ec_slave_t *slave, /**< slave */ |
26 uint8_t type, /**< mailbox protocol */ |
44 uint8_t type, /**< mailbox protocol */ |
27 size_t size /**< size of the data */ |
45 size_t size /**< size of the data */ |
58 /*****************************************************************************/ |
76 /*****************************************************************************/ |
59 |
77 |
60 /** |
78 /** |
61 Prepares a command for checking the mailbox state. |
79 Prepares a command for checking the mailbox state. |
62 \return 0 in case of success, else < 0 |
80 \return 0 in case of success, else < 0 |
|
81 \ingroup Slave |
63 */ |
82 */ |
64 |
83 |
65 int ec_slave_mbox_prepare_check(ec_slave_t *slave /**< slave */) |
84 int ec_slave_mbox_prepare_check(ec_slave_t *slave /**< slave */) |
66 { |
85 { |
67 ec_command_t *command = &slave->mbox_command; |
86 ec_command_t *command = &slave->mbox_command; |
76 /*****************************************************************************/ |
95 /*****************************************************************************/ |
77 |
96 |
78 /** |
97 /** |
79 Processes a mailbox state checking command. |
98 Processes a mailbox state checking command. |
80 \return 0 in case of success, else < 0 |
99 \return 0 in case of success, else < 0 |
|
100 \ingroup Slave |
81 */ |
101 */ |
82 |
102 |
83 int ec_slave_mbox_check(const ec_slave_t *slave /**< slave */) |
103 int ec_slave_mbox_check(const ec_slave_t *slave /**< slave */) |
84 { |
104 { |
85 return EC_READ_U8(slave->mbox_command.data + 5) & 8 ? 1 : 0; |
105 return EC_READ_U8(slave->mbox_command.data + 5) & 8 ? 1 : 0; |
88 /*****************************************************************************/ |
108 /*****************************************************************************/ |
89 |
109 |
90 /** |
110 /** |
91 Prepares a command to fetch mailbox data. |
111 Prepares a command to fetch mailbox data. |
92 \return 0 in case of success, else < 0 |
112 \return 0 in case of success, else < 0 |
|
113 \ingroup Slave |
93 */ |
114 */ |
94 |
115 |
95 int ec_slave_mbox_prepare_fetch(ec_slave_t *slave /**< slave */) |
116 int ec_slave_mbox_prepare_fetch(ec_slave_t *slave /**< slave */) |
96 { |
117 { |
97 ec_command_t *command = &slave->mbox_command; |
118 ec_command_t *command = &slave->mbox_command; |
105 /*****************************************************************************/ |
126 /*****************************************************************************/ |
106 |
127 |
107 /** |
128 /** |
108 Processes received mailbox data. |
129 Processes received mailbox data. |
109 \return pointer to the received data |
130 \return pointer to the received data |
|
131 \ingroup Slave |
110 */ |
132 */ |
111 |
133 |
112 uint8_t *ec_slave_mbox_fetch(ec_slave_t *slave, /**< slave */ |
134 uint8_t *ec_slave_mbox_fetch(ec_slave_t *slave, /**< slave */ |
113 uint8_t type, /**< expected mailbox protocol */ |
135 uint8_t type, /**< expected mailbox protocol */ |
114 size_t *size /**< size of the received data */ |
136 size_t *size /**< size of the received data */ |
137 /*****************************************************************************/ |
159 /*****************************************************************************/ |
138 |
160 |
139 /** |
161 /** |
140 Sends a mailbox command and waits for its reception. |
162 Sends a mailbox command and waits for its reception. |
141 \return pointer to the received data |
163 \return pointer to the received data |
|
164 \ingroup Slave |
142 */ |
165 */ |
143 |
166 |
144 uint8_t *ec_slave_mbox_simple_io(ec_slave_t *slave, /**< slave */ |
167 uint8_t *ec_slave_mbox_simple_io(ec_slave_t *slave, /**< slave */ |
145 size_t *size /**< size of the received data */ |
168 size_t *size /**< size of the received data */ |
146 ) |
169 ) |
163 /*****************************************************************************/ |
186 /*****************************************************************************/ |
164 |
187 |
165 /** |
188 /** |
166 Waits for the reception of a mailbox command. |
189 Waits for the reception of a mailbox command. |
167 \return pointer to the received data |
190 \return pointer to the received data |
|
191 \ingroup Slave |
168 */ |
192 */ |
169 |
193 |
170 uint8_t *ec_slave_mbox_simple_receive(ec_slave_t *slave, /**< slave */ |
194 uint8_t *ec_slave_mbox_simple_receive(ec_slave_t *slave, /**< slave */ |
171 uint8_t type, /**< expected protocol */ |
195 uint8_t type, /**< expected protocol */ |
172 size_t *size /**< received data size */ |
196 size_t *size /**< received data size */ |