42 #include "master/ioctl.h" |
42 #include "master/ioctl.h" |
43 |
43 |
44 /*****************************************************************************/ |
44 /*****************************************************************************/ |
45 |
45 |
46 int ecrt_slave_config_sync_manager(ec_slave_config_t *sc, uint8_t sync_index, |
46 int ecrt_slave_config_sync_manager(ec_slave_config_t *sc, uint8_t sync_index, |
47 ec_direction_t dir) |
47 ec_direction_t dir, ec_watchdog_mode_t watchdog_mode) |
48 { |
48 { |
49 ec_ioctl_config_t data; |
49 ec_ioctl_config_t data; |
50 unsigned int i; |
50 unsigned int i; |
51 |
51 |
52 if (sync_index >= EC_MAX_SYNC_MANAGERS) |
52 if (sync_index >= EC_MAX_SYNC_MANAGERS) |
53 return -ENOENT; |
53 return -ENOENT; |
54 |
54 |
55 memset(&data, 0x00, sizeof(ec_ioctl_config_t)); |
55 memset(&data, 0x00, sizeof(ec_ioctl_config_t)); |
56 data.config_index = sc->index; |
56 data.config_index = sc->index; |
57 data.syncs[sync_index].dir = dir; |
57 data.syncs[sync_index].dir = dir; |
|
58 data.syncs[sync_index].watchdog_mode = watchdog_mode; |
|
59 data.syncs[sync_index].config_this = 1; |
58 |
60 |
59 if (ioctl(sc->master->fd, EC_IOCTL_SC_SYNC, &data) == -1) { |
61 if (ioctl(sc->master->fd, EC_IOCTL_SC_SYNC, &data) == -1) { |
60 fprintf(stderr, "Failed to config sync manager: %s\n", |
62 fprintf(stderr, "Failed to config sync manager: %s\n", |
61 strerror(errno)); |
63 strerror(errno)); |
62 return -1; // FIXME |
64 return -1; // FIXME |
63 } |
65 } |
64 |
66 |
65 return 0; |
67 return 0; |
|
68 } |
|
69 |
|
70 /*****************************************************************************/ |
|
71 |
|
72 void ecrt_slave_config_watchdog(ec_slave_config_t *sc, |
|
73 uint16_t divider, uint16_t intervals) |
|
74 { |
|
75 ec_ioctl_config_t data; |
|
76 |
|
77 memset(&data, 0x00, sizeof(ec_ioctl_config_t)); |
|
78 data.config_index = sc->index; |
|
79 data.watchdog_divider = divider; |
|
80 data.watchdog_intervals = intervals; |
|
81 |
|
82 if (ioctl(sc->master->fd, EC_IOCTL_SC_WATCHDOG, &data) == -1) { |
|
83 fprintf(stderr, "Failed to config watchdog: %s\n", |
|
84 strerror(errno)); |
|
85 } |
66 } |
86 } |
67 |
87 |
68 /*****************************************************************************/ |
88 /*****************************************************************************/ |
69 |
89 |
70 int ecrt_slave_config_pdo_assign_add(ec_slave_config_t *sc, |
90 int ecrt_slave_config_pdo_assign_add(ec_slave_config_t *sc, |
164 fprintf(stderr, "Invalid sync manager index %u!\n", |
184 fprintf(stderr, "Invalid sync manager index %u!\n", |
165 sync_info->index); |
185 sync_info->index); |
166 return -ENOENT; |
186 return -ENOENT; |
167 } |
187 } |
168 |
188 |
169 ret = ecrt_slave_config_sync_manager( |
189 ret = ecrt_slave_config_sync_manager(sc, sync_info->index, |
170 sc, sync_info->index, sync_info->dir); |
190 sync_info->dir, sync_info->watchdog_mode); |
171 if (ret) |
191 if (ret) |
172 return ret; |
192 return ret; |
173 |
193 |
174 if (sync_info->n_pdos && sync_info->pdos) { |
194 if (sync_info->n_pdos && sync_info->pdos) { |
175 ecrt_slave_config_pdo_assign_clear(sc, sync_info->index); |
195 ecrt_slave_config_pdo_assign_clear(sc, sync_info->index); |