18 #define pPORTFIO_SET ((vuint16_t *)PORTFIO_SET) 19 #define pPORTFIO_CLEAR ((vuint16_t *)PORTFIO_CLEAR) 20 #define pPORTFIO_DIR ((vuint16_t *)PORTFIO_DIR) 31 #define NUMBER_OF_SLAVES 9 106 data_ptr += module_index * 4;
110 return_value = *data_ptr++;
111 return_value += (*data_ptr++ << 8);
112 return_value += (*data_ptr++ << 16);
113 return_value += (*data_ptr++ << 24);
124 data_ptr += module_index * 4;
128 *data_ptr++ = (value >> 0) & 0xFF;
129 *data_ptr++ = (value >> 8) & 0xFF;
130 *data_ptr++ = (value >> 16) & 0xFF;
131 *data_ptr++ = (value >> 24) & 0xFF;
139 if (*
ec_slave[slave_no].inputs & BIT (module_index - 1 + startbit))
153 data_ptr += module_index * 2;
157 return_value = *data_ptr++;
158 return_value += (*data_ptr++ << 8);
169 data_ptr += module_index * 2;
173 *data_ptr++ = (value >> 0) & 0xFF;
174 *data_ptr++ = (value >> 8) & 0xFF;
182 if (*
ec_slave[slave_no].outputs & BIT (module_index - 1 + startbit))
219 rprintp (
"Processor load was %d:%d:%d (1s:5s:10s) with TT errors: %d\n",
251 rprintp(
"Starting simple test\n");
256 rprintp(
"ec_init succeeded.\n");
269 rprintp(
"Slaves mapped, state to SAFE_OP.\n");
276 rprintp(
"\nSlave:%d\n Name:%s\n Output size: %dbits\n Input size: %dbits\n State: %d\n Delay: %d[ns]\n Has DC: %d\n",
279 rprintp(
" Configured address: %x\n",
ec_slave[cnt].configadr);
280 rprintp(
" Outputs address: %x\n",
ec_slave[cnt].outputs);
281 rprintp(
" Inputs address: %x\n",
ec_slave[cnt].inputs);
285 rprintp(
" FMMU%1d Ls:%x Ll:%4d Lsb:%d Leb:%d Ps:%x Psb:%d Ty:%x Act:%x\n", j,
290 rprintp(
" FMMUfunc 0:%d 1:%d 2:%d 3:%d\n",
295 rprintp(
"Request operational state for all slaves\n");
306 rprintp(
"Operational state reached for all slaves.\n");
310 rprintp(
"Not all slaves reached operational state.\n");
316 rprintp(
"Slave %d State=0x%04x StatusCode=0x%04x\n",
344 if (slave_EL1008_1.
in1 || slave_EL1008_1.
in2 || slave_EL1008_1.
in3)
360 if (slave_EL1008_1.
in3)
361 task_delay(tick_from_ms(20));
363 task_delay(tick_from_ms(5));
365 digout = (
uint8) (digout | BIT((
dorun / 16) & 0xFF));
379 task_delay(tick_from_ms(2));
385 rprintp(
"Mismatch of network units!\n");
390 rprintp(
"No slaves found!\n");
392 rprintp(
"End simple test, close socket\n");
398 rprintp(
"ec_init failed");
400 rprintp(
"End program\n");
407 ASSERT (timeout_us > 4000);
425 #define USECS_PER_SEC 1000000 426 #define USECS_PER_TICK (USECS_PER_SEC / CFG_TICKS_PER_SECOND) 428 #define ABS(x) ((x) < 0 ? -(x) : (x)) 435 ASSERT (stop.
sec >= start.
sec);
436 if (stop.
sec == start.
sec)
444 ASSERT (difference_us >= 0);
445 return difference_us;
456 int32 measurement_us;
459 boolean is_deviation_within_tolerance;
466 deviation_us =
ABS (measurement_us - sleep_time_us);
467 is_deviation_within_tolerance = deviation_us <= usleep_accuracy_us;
468 ASSERT (is_deviation_within_tolerance);
483 #include <lwip/inet.h> 492 ASSERT (network == htons (host));
502 ASSERT (host == ntohs (network));
512 rprintp(
"SOEM (Simple Open EtherCAT Master)\nSimple test\n");
514 task_spawn (
"simpletest",
simpletest, 9, 8192, NULL);
static void test_osal_timer_timeout_us(const uint32 timeout_us)
static void test_osal_timer(void)
static void test_osal_current_time_for_delay_us(const int32 sleep_time_us)
boolean osal_timer_is_expired(osal_timert *self)
int ec_send_processdata(void)
static void test_oshw_htons(void)
Headerfile for all ethercat headers.
int32 get_input_int32(uint16 slave_no, uint8 module_index)
static int32 time_difference_us(const ec_timet stop, const ec_timet start)
int ec_receive_processdata(int timeout)
uint8 get_output_bit(uint16 slave_no, uint8 module_index)
void set_output_bit(uint16 slave_no, uint8 module_index, uint8 value)
int ec_init(const char *ifname)
uint16 oshw_ntohs(uint16 network)
static void test_oshw_ntohs(void)
void tt_error(uint32_t task_ix)
uint16 oshw_htons(uint16 host)
int ec_config_map(void *pIOmap)
out_EL2622_t slave_EL2622_1
ec_timet osal_current_time(void)
in_EL3061_t slave_EL3061_1
in_EL1008_t slave_EL1008_2
int osal_usleep(uint32 usec)
uint32 network_configuration(void)
in_EL1008_t slave_EL1008_1
static void my_cyclic_callback(void *arg)
out_EL4001_t slave_EL4001_1
int ec_writestate(uint16 slave)
void set_input_int32(uint16 slave_no, uint8 module_index, int32 value)
int16 get_output_int16(uint16 slave_no, uint8 module_index)
out_EL2622_t slave_EL2622_3
static void test_osal_current_time(void)
void simpletest(void *arg)
void osal_timer_start(osal_timert *self, uint32 timeout_usec)
void set_output_int16(uint16 slave_no, uint8 module_index, int16 value)
uint16 ec_statecheck(uint16 slave, uint16 reqstate, int timeout)
out_EL2622_t slave_EL2622_2
uint8 get_input_bit(uint16 slave_no, uint8 module_index)
int ec_config_init(uint8 usetable)