author | Florian Pose <fp@igh-essen.com> |
Wed, 02 Aug 2006 16:39:39 +0000 | |
branch | stable-1.0 |
changeset 1625 | 49d577ddcb08 |
parent 1624 | 9dc190591c0f |
permissions | -rw-r--r-- |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
1618
5cff10efb927
MERGE trunk -r355:360 -> branches/stable-1.0 (Doxygen, INSTALL, and GPLv2)
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
5 |
* Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
5cff10efb927
MERGE trunk -r355:360 -> branches/stable-1.0 (Doxygen, INSTALL, and GPLv2)
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
6 |
* |
5cff10efb927
MERGE trunk -r355:360 -> branches/stable-1.0 (Doxygen, INSTALL, and GPLv2)
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
5cff10efb927
MERGE trunk -r355:360 -> branches/stable-1.0 (Doxygen, INSTALL, and GPLv2)
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
8 |
* |
5cff10efb927
MERGE trunk -r355:360 -> branches/stable-1.0 (Doxygen, INSTALL, and GPLv2)
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it |
5cff10efb927
MERGE trunk -r355:360 -> branches/stable-1.0 (Doxygen, INSTALL, and GPLv2)
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
10 |
* and/or modify it under the terms of the GNU General Public License |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
1618
diff
changeset
|
11 |
* as published by the Free Software Foundation; either version 2 of the |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
1618
diff
changeset
|
12 |
* License, or (at your option) any later version. |
1618
5cff10efb927
MERGE trunk -r355:360 -> branches/stable-1.0 (Doxygen, INSTALL, and GPLv2)
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
13 |
* |
5cff10efb927
MERGE trunk -r355:360 -> branches/stable-1.0 (Doxygen, INSTALL, and GPLv2)
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
14 |
* The IgH EtherCAT Master is distributed in the hope that it will be |
5cff10efb927
MERGE trunk -r355:360 -> branches/stable-1.0 (Doxygen, INSTALL, and GPLv2)
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
15 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
5cff10efb927
MERGE trunk -r355:360 -> branches/stable-1.0 (Doxygen, INSTALL, and GPLv2)
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5cff10efb927
MERGE trunk -r355:360 -> branches/stable-1.0 (Doxygen, INSTALL, and GPLv2)
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
17 |
* GNU General Public License for more details. |
5cff10efb927
MERGE trunk -r355:360 -> branches/stable-1.0 (Doxygen, INSTALL, and GPLv2)
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
18 |
* |
5cff10efb927
MERGE trunk -r355:360 -> branches/stable-1.0 (Doxygen, INSTALL, and GPLv2)
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
19 |
* You should have received a copy of the GNU General Public License |
5cff10efb927
MERGE trunk -r355:360 -> branches/stable-1.0 (Doxygen, INSTALL, and GPLv2)
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
20 |
* along with the IgH EtherCAT Master; if not, write to the Free Software |
5cff10efb927
MERGE trunk -r355:360 -> branches/stable-1.0 (Doxygen, INSTALL, and GPLv2)
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
21 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
5cff10efb927
MERGE trunk -r355:360 -> branches/stable-1.0 (Doxygen, INSTALL, and GPLv2)
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
22 |
* |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
1618
diff
changeset
|
23 |
* The right to use EtherCAT Technology is granted and comes free of |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
1618
diff
changeset
|
24 |
* charge under condition of compatibility of product made by |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
1618
diff
changeset
|
25 |
* Licensee. People intending to distribute/sell products based on the |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
1618
diff
changeset
|
26 |
* code, have to sign an agreement to guarantee that products using |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
1618
diff
changeset
|
27 |
* software based on IgH EtherCAT master stay compatible with the actual |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
1618
diff
changeset
|
28 |
* EtherCAT specification (which are released themselves as an open |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
1618
diff
changeset
|
29 |
* standard) as the (only) precondition to have the right to use EtherCAT |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
1618
diff
changeset
|
30 |
* Technology, IP and trade marks. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
1618
diff
changeset
|
31 |
* |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
*****************************************************************************/ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
|
1618
5cff10efb927
MERGE trunk -r355:360 -> branches/stable-1.0 (Doxygen, INSTALL, and GPLv2)
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
34 |
/** |
5cff10efb927
MERGE trunk -r355:360 -> branches/stable-1.0 (Doxygen, INSTALL, and GPLv2)
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
35 |
\file |
5cff10efb927
MERGE trunk -r355:360 -> branches/stable-1.0 (Doxygen, INSTALL, and GPLv2)
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
36 |
Mailbox functionality. |
5cff10efb927
MERGE trunk -r355:360 -> branches/stable-1.0 (Doxygen, INSTALL, and GPLv2)
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
37 |
*/ |
5cff10efb927
MERGE trunk -r355:360 -> branches/stable-1.0 (Doxygen, INSTALL, and GPLv2)
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
38 |
|
5cff10efb927
MERGE trunk -r355:360 -> branches/stable-1.0 (Doxygen, INSTALL, and GPLv2)
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
39 |
/*****************************************************************************/ |
5cff10efb927
MERGE trunk -r355:360 -> branches/stable-1.0 (Doxygen, INSTALL, and GPLv2)
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
40 |
|
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
#include <linux/slab.h> |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
#include <linux/delay.h> |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
#include "mailbox.h" |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
45 |
#include "datagram.h" |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
#include "master.h" |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
/*****************************************************************************/ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
49 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
/** |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
51 |
Prepares a mailbox-send datagram. |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
52 |
\return pointer to mailbox datagram data |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
53 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
54 |
|
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
55 |
uint8_t *ec_slave_mbox_prepare_send(const ec_slave_t *slave, /**< slave */ |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
56 |
ec_datagram_t *datagram, /**< datagram */ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
57 |
uint8_t type, /**< mailbox protocol */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
58 |
size_t size /**< size of the data */ |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
59 |
) |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
60 |
{ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
61 |
size_t total_size; |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
62 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
63 |
if (unlikely(!slave->sii_mailbox_protocols)) { |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
64 |
EC_ERR("Slave %i does not support mailbox communication!\n", |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
65 |
slave->ring_position); |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
66 |
return NULL; |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
67 |
} |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
68 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
69 |
total_size = size + 6; |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
70 |
if (unlikely(total_size > slave->sii_rx_mailbox_size)) { |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
71 |
EC_ERR("Data size does not fit in mailbox!\n"); |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
72 |
return NULL; |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
} |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
74 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
75 |
if (ec_datagram_npwr(datagram, slave->station_address, |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
76 |
slave->sii_rx_mailbox_offset, |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
77 |
slave->sii_rx_mailbox_size)) |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
78 |
return NULL; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
79 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
80 |
EC_WRITE_U16(datagram->data, size); // mailbox service data length |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
81 |
EC_WRITE_U16(datagram->data + 2, slave->station_address); // station addr. |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
82 |
EC_WRITE_U8 (datagram->data + 4, 0x00); // channel & priority |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
83 |
EC_WRITE_U8 (datagram->data + 5, type); // underlying protocol type |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
84 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
85 |
return datagram->data + 6; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
86 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
87 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
88 |
/*****************************************************************************/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
89 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
90 |
/** |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
91 |
Prepares a datagram for checking the mailbox state. |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
92 |
\return 0 in case of success, else < 0 |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
93 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
94 |
|
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
95 |
int ec_slave_mbox_prepare_check(const ec_slave_t *slave, /**< slave */ |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
96 |
ec_datagram_t *datagram /**< datagram */ |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
97 |
) |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
98 |
{ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
99 |
// FIXME: second sync manager? |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
100 |
if (ec_datagram_nprd(datagram, slave->station_address, 0x808, 8)) |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
return -1; |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
102 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
103 |
return 0; |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
104 |
} |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
105 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
106 |
/*****************************************************************************/ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
107 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
108 |
/** |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
109 |
Processes a mailbox state checking datagram. |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
110 |
\return 0 in case of success, else < 0 |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
111 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
112 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
113 |
int ec_slave_mbox_check(const ec_datagram_t *datagram /**< datagram */) |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
114 |
{ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
115 |
return EC_READ_U8(datagram->data + 5) & 8 ? 1 : 0; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
116 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
117 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
118 |
/*****************************************************************************/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
119 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
120 |
/** |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
121 |
Prepares a datagram to fetch mailbox data. |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
122 |
\return 0 in case of success, else < 0 |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
123 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
124 |
|
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
125 |
int ec_slave_mbox_prepare_fetch(const ec_slave_t *slave, /**< slave */ |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
126 |
ec_datagram_t *datagram /**< datagram */ |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
127 |
) |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
128 |
{ |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
129 |
if (ec_datagram_nprd(datagram, slave->station_address, |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
130 |
slave->sii_tx_mailbox_offset, |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
131 |
slave->sii_tx_mailbox_size)) return -1; |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
132 |
return 0; |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
133 |
} |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
134 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
135 |
/*****************************************************************************/ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
136 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
137 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
138 |
Processes received mailbox data. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
139 |
\return pointer to the received data |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
140 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
141 |
|
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
142 |
uint8_t *ec_slave_mbox_fetch(const ec_slave_t *slave, /**< slave */ |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
143 |
ec_datagram_t *datagram, /**< datagram */ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
144 |
uint8_t type, /**< expected mailbox protocol */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
145 |
size_t *size /**< size of the received data */ |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
146 |
) |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
{ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
148 |
size_t data_size; |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
149 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
150 |
if ((EC_READ_U8(datagram->data + 5) & 0x0F) != type) { |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
151 |
EC_ERR("Unexpected mailbox protocol 0x%02X (exp.: 0x%02X) at" |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
152 |
" slave %i!\n", EC_READ_U8(datagram->data + 5), type, |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
153 |
slave->ring_position); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
154 |
return NULL; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
155 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
156 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
157 |
if ((data_size = EC_READ_U16(datagram->data)) > |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
158 |
slave->sii_tx_mailbox_size - 6) { |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
159 |
EC_ERR("Currupt mailbox response detected!\n"); |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
160 |
return NULL; |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
161 |
} |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
162 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
163 |
*size = data_size; |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
164 |
return datagram->data + 6; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
165 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
166 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
167 |
/*****************************************************************************/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
168 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
169 |
/** |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
170 |
Sends a mailbox datagram and waits for its reception. |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
171 |
\return pointer to the received data |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
172 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
173 |
|
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
174 |
uint8_t *ec_slave_mbox_simple_io(const ec_slave_t *slave, /**< slave */ |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
175 |
ec_datagram_t *datagram, /**< datagram */ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
176 |
size_t *size /**< size of the received data */ |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
177 |
) |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
178 |
{ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
179 |
uint8_t type; |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
180 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
181 |
type = EC_READ_U8(datagram->data + 5); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
182 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
183 |
if (unlikely(ec_master_simple_io(slave->master, datagram))) { |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
184 |
EC_ERR("Mailbox checking failed on slave %i!\n", |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
185 |
slave->ring_position); |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
186 |
return NULL; |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
187 |
} |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
188 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
189 |
return ec_slave_mbox_simple_receive(slave, datagram, type, size); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
190 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
191 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
192 |
/*****************************************************************************/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
193 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
194 |
/** |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
195 |
Waits for the reception of a mailbox datagram. |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
196 |
\return pointer to the received data |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
197 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
198 |
|
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
199 |
uint8_t *ec_slave_mbox_simple_receive(const ec_slave_t *slave, /**< slave */ |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
200 |
ec_datagram_t *datagram, /**< datagram */ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
201 |
uint8_t type, /**< expected protocol */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
202 |
size_t *size /**< received data size */ |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
203 |
) |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
204 |
{ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
205 |
cycles_t start, end, timeout; |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
206 |
|
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
207 |
start = get_cycles(); |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
208 |
timeout = (cycles_t) 100 * cpu_khz; // 100ms |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
209 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
210 |
while (1) |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
211 |
{ |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
212 |
if (ec_slave_mbox_prepare_check(slave, datagram)) return NULL; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
213 |
if (unlikely(ec_master_simple_io(slave->master, datagram))) { |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
214 |
EC_ERR("Mailbox checking failed on slave %i!\n", |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
215 |
slave->ring_position); |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
216 |
return NULL; |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
217 |
} |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
218 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
219 |
end = get_cycles(); |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
220 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
221 |
if (ec_slave_mbox_check(datagram)) |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
222 |
break; // proceed with receiving data |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
223 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
224 |
if ((end - start) >= timeout) { |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
225 |
EC_ERR("Mailbox check - Slave %i timed out.\n", |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
226 |
slave->ring_position); |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
227 |
return NULL; |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
228 |
} |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
229 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
230 |
udelay(100); |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
231 |
} |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
232 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
233 |
if (ec_slave_mbox_prepare_fetch(slave, datagram)) return NULL; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
234 |
if (unlikely(ec_master_simple_io(slave->master, datagram))) { |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
235 |
EC_ERR("Mailbox receiving failed on slave %i!\n", |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
236 |
slave->ring_position); |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
237 |
return NULL; |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
238 |
} |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
239 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
240 |
if (unlikely(slave->master->debug_level) > 1) |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
241 |
EC_DBG("Mailbox receive took %ius.\n", |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
242 |
((unsigned int) (end - start) * 1000 / cpu_khz)); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
243 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
244 |
return ec_slave_mbox_fetch(slave, datagram, type, size); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
245 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
246 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
247 |
/*****************************************************************************/ |