wg_util.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2008, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the Willow Garage nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 #pragma once
36 
37 #include <stdint.h>
40 
41 namespace ethercat_hardware
42 {
43 
44 // Syncmanger control register 0x804+N*8
46  union {
47  uint8_t raw;
48  struct {
49  uint8_t mode : 2;
50  uint8_t direction : 2;
51  uint8_t ecat_irq_enable : 1;
52  uint8_t pdi_irq_enable : 1;
53  uint8_t watchdog_enable : 1;
54  uint8_t res1 : 1;
55  } __attribute__ ((__packed__));
56  } __attribute__ ((__packed__));
57  //static const unsigned BASE_ADDR=0x804;
58  //static unsigned base_addr(unsigned num);
59  //void print(std::ostream &os=std::cout) const;
60 } __attribute__ ((__packed__));
61 
62 // Syncmanger status register 0x805+N*8
63 struct SyncManStatus {
64  union {
65  uint8_t raw;
66  struct {
67  uint8_t interrupt_write : 1;
68  uint8_t interrupt_read : 1;
69  uint8_t res1 : 1;
70  uint8_t mailbox_status : 1;
71  uint8_t buffer_status : 2;
72  uint8_t res2 : 2;
73  } __attribute__ ((__packed__));
74  } __attribute__ ((__packed__));
75  //static const unsigned BASE_ADDR=0x805;
76  //static unsigned base_addr(unsigned num);
77  //void print(std::ostream &os=std::cout) const;
78 } __attribute__ ((__packed__));
79 
80 // Syncmanger activation register 0x806+N*8
82  union {
83  uint8_t raw;
84  struct {
85  uint8_t enable : 1;
86  uint8_t repeat_request : 1;
87  uint8_t res4 : 4;
88  uint8_t ecat_latch_event : 1;
89  uint8_t pdi_latch_event : 1;
90  } __attribute__ ((__packed__));
91  } __attribute__ ((__packed__));
92  static const unsigned BASE_ADDR=0x806;
93  static unsigned baseAddress(unsigned num);
94  //void print(std::ostream &os=std::cout) const;
95  bool writeData(EthercatCom *com, EtherCAT_SlaveHandler *sh, EthercatDevice::AddrMode addrMode, unsigned num) const;
96 } __attribute__ ((__packed__));
97 
98 // Syncmanger PDI control register 0x807+N*8
100  union {
101  uint8_t raw;
102  struct {
103  uint8_t deactivate : 1;
104  uint8_t repeat_ack : 1;
105  uint8_t res6 : 6;
106  } __attribute__ ((__packed__));
107  } __attribute__ ((__packed__));
108  //static const unsigned BASE_ADDR=0x807;
109  //static unsigned base_addr(unsigned num);
110  //void print(std::ostream &os=std::cout) const;
111 } __attribute__ ((__packed__));
112 
113 
114 // For SyncManager settings REG 0x800+8*N
115 struct SyncMan {
116  union {
117  uint8_t raw[8];
118  struct {
119  uint16_t start_addr;
120  uint16_t length;
121  SyncManControl control;
122  SyncManStatus status;
123  SyncManActivate activate;
125  } __attribute__ ((__packed__));
126  } __attribute__ ((__packed__));
127 
128  // Base address for first syncmanager
129  static const unsigned BASE_ADDR=0x800;
130  // Base address of Nth syncmanager for N=0-7
131  static unsigned baseAddress(unsigned num);
132 
133  bool readData(EthercatCom *com, EtherCAT_SlaveHandler *sh, EthercatDevice::AddrMode addrMode, unsigned num);
134  //void print(unsigned num, std::ostream &os=std::cout) const;
135 } __attribute__ ((__packed__));
136 
137 namespace wg_util
138 {
139 unsigned computeChecksum(void const *data, unsigned length);
140 unsigned int rotateRight8(unsigned in);
141 };
142 
143 }; // end namespace ethercat_hardware
SyncManStatus status
Definition: wg_util.h:121
static unsigned baseAddress(unsigned num)
uint8_t ecat_latch_event
Definition: wg_util.h:87
uint16_t length
Definition: wg_util.h:119
SyncManActivate activate
Definition: wg_util.h:122
SyncManControl control
Definition: wg_util.h:120
unsigned computeChecksum(void const *data, unsigned length)
Definition: wg_util.cpp:49
uint8_t mailbox_status
Definition: wg_util.h:69
uint8_t buffer_status
Definition: wg_util.h:70
data
uint8_t enable
Definition: wg_util.h:84
uint8_t pdi_latch_event
Definition: wg_util.h:88
uint8_t res6
Definition: wg_util.h:104
uint8_t repeat_ack
Definition: wg_util.h:103
static const unsigned BASE_ADDR
Definition: wg_util.h:87
SyncManPDIControl pdi_control
Definition: wg_util.h:124
unsigned int rotateRight8(unsigned in)
Definition: wg_util.cpp:41
uint8_t interrupt_write
Definition: wg_util.h:66
uint8_t res4
Definition: wg_util.h:86
uint16_t start_addr
Definition: wg_util.h:118
uint8_t res2
Definition: wg_util.h:71
uint8_t interrupt_read
Definition: wg_util.h:67
bool writeData(EthercatCom *com, EtherCAT_SlaveHandler *sh, EthercatDevice::AddrMode addrMode, unsigned num) const
uint8_t repeat_request
Definition: wg_util.h:85
bool readData(EthercatCom *com, EtherCAT_SlaveHandler *sh, EthercatDevice::AddrMode addrMode, unsigned num)
uint8_t deactivate
Definition: wg_util.h:102
union ethercat_hardware::SyncManControl::@22 __attribute__((__packed__))


ethercat_hardware
Author(s): Rob Wheeler , Derek King
autogenerated on Thu Mar 4 2021 03:10:21