1 /****************************************************************************** |
1 /****************************************************************************** |
2 * |
2 * |
3 * $Id$ |
3 * $Id$ |
4 * |
4 * |
5 * Copyright (C) 2008 Olav Zarges, imc Messsysteme GmbH |
5 * Copyright (C) 2008 Olav Zarges, imc Messsysteme GmbH |
|
6 * 2009-2012 Florian Pose <fp@igh-essen.com> |
6 * |
7 * |
7 * This file is part of the IgH EtherCAT Master. |
8 * This file is part of the IgH EtherCAT Master. |
8 * |
9 * |
9 * The IgH EtherCAT Master is free software; you can redistribute it and/or |
10 * The IgH EtherCAT Master is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU General Public License version 2, as |
11 * modify it under the terms of the GNU General Public License version 2, as |
48 typedef struct ec_fsm_foe ec_fsm_foe_t; /**< \see ec_fsm_foe */ |
49 typedef struct ec_fsm_foe ec_fsm_foe_t; /**< \see ec_fsm_foe */ |
49 |
50 |
50 /** Finite state machines for the CANopen-over-EtherCAT protocol. |
51 /** Finite state machines for the CANopen-over-EtherCAT protocol. |
51 */ |
52 */ |
52 struct ec_fsm_foe { |
53 struct ec_fsm_foe { |
53 ec_slave_t *slave; /**< slave the FSM runs on */ |
54 ec_slave_t *slave; /**< Slave the FSM runs on. */ |
54 ec_datagram_t *datagram; /**< datagram used in the state machine */ |
55 unsigned int retries; /**< Retries upon datagram timeout */ |
55 unsigned int retries; /**< retries upon datagram timeout */ |
|
56 |
56 |
57 void (*state)(ec_fsm_foe_t *); /**< FoE state function */ |
57 void (*state)(ec_fsm_foe_t *, ec_datagram_t *); /**< FoE state function. */ |
|
58 ec_datagram_t *datagram; /**< Datagram used in previous step. */ |
58 unsigned long jiffies_start; /**< FoE timestamp. */ |
59 unsigned long jiffies_start; /**< FoE timestamp. */ |
59 uint8_t subindex; /**< current subindex */ |
60 uint8_t subindex; /**< Current subindex. */ |
60 ec_foe_request_t *request; /**< FoE request */ |
61 ec_foe_request_t *request; /**< FoE request. */ |
61 uint8_t toggle; /**< toggle bit for segment commands */ |
62 uint8_t toggle; /**< Toggle bit for segment commands. */ |
62 |
63 |
63 uint8_t *tx_buffer; /**< Buffer with data to transmit. */ |
64 uint8_t *tx_buffer; /**< Buffer with data to transmit. */ |
64 uint32_t tx_buffer_size; /**< Size of data to transmit. */ |
65 uint32_t tx_buffer_size; /**< Size of data to transmit. */ |
65 uint32_t tx_buffer_offset; /**< Offset of data to tranmit next. */ |
66 uint32_t tx_buffer_offset; /**< Offset of data to tranmit next. */ |
66 uint32_t tx_last_packet; /**< Current packet is last one to send. */ |
67 uint32_t tx_last_packet; /**< Current packet is last one to send. */ |
78 uint32_t rx_filename_len; /**< Length of the receive file name. */ |
79 uint32_t rx_filename_len; /**< Length of the receive file name. */ |
79 }; |
80 }; |
80 |
81 |
81 /*****************************************************************************/ |
82 /*****************************************************************************/ |
82 |
83 |
83 void ec_fsm_foe_init(ec_fsm_foe_t *, ec_datagram_t *); |
84 void ec_fsm_foe_init(ec_fsm_foe_t *); |
84 void ec_fsm_foe_clear(ec_fsm_foe_t *); |
85 void ec_fsm_foe_clear(ec_fsm_foe_t *); |
85 |
86 |
86 int ec_fsm_foe_exec(ec_fsm_foe_t *); |
87 int ec_fsm_foe_exec(ec_fsm_foe_t *, ec_datagram_t *); |
87 int ec_fsm_foe_success(ec_fsm_foe_t *); |
88 int ec_fsm_foe_success(const ec_fsm_foe_t *); |
88 |
89 |
89 void ec_fsm_foe_transfer(ec_fsm_foe_t *, ec_slave_t *, ec_foe_request_t *); |
90 void ec_fsm_foe_transfer(ec_fsm_foe_t *, ec_slave_t *, ec_foe_request_t *); |
90 |
91 |
91 /*****************************************************************************/ |
92 /*****************************************************************************/ |
92 |
93 |