EtherCAT slave that reads 3 Xsens IMU's connected to a Xbus Master
Dependencies: MODSERIAL mbed KL25Z_ClockControl
Fork of EtherCAT by
Diff: soes.cpp
- Revision:
- 27:93c0e4ae943e
- Parent:
- 26:c7959f1fd09a
- Child:
- 28:8505285f65ed
--- a/soes.cpp Sun Mar 08 21:53:00 2015 +0000 +++ b/soes.cpp Mon Mar 09 15:58:00 2015 +0000 @@ -67,7 +67,7 @@ SPI et1100_spi(ET1100_MOSI,ET1100_MISO,ET1100_SCK); MODSERIAL xbus_serial(PTC4,PTC3); xbus_t xbus_master; -MODSERIAL pc(USBTX,USBRX); +MODSERIAL pc(USBTX,USBRX,512); DigitalOut ploep(PTA13); #define PLOEP do{ploep = !(ploep);}while(0); @@ -99,9 +99,11 @@ { uint32_t rates[] = {460800,230400,115200,76800,57600,38400,28800,19200,14400,9600}; if(Eb.setting8 < (sizeof(rates)/sizeof(uint32_t)) ) - { + { + XbusGoToConfig(); XbusSetBaudRate(Eb.setting8); XbusReset(); + wait(2); xbus_serial.baud(rates[Eb.setting8]); XbusInitializeXbusMaster(); @@ -224,7 +226,6 @@ { while(xbus_serial.readable()) { - PLOEP; XbusReceiveState(&xbus_master, xbus_serial.getc()); if(xbus_master.rx.checksum_ok) { @@ -233,6 +234,7 @@ memcpy_byteswap((uint8_t *)&local_Rb.timestamp ,&xbus_master.rx.buffer[4], 2); memcpy_byteswap((uint8_t *)&local_Rb.first.acc[0],&xbus_master.rx.buffer[6],60); //pc.printf("%x %x\n",Rb.timestamp, *((uint16_t *)(&xbus_master.rx.buffer[4]))); + PLOEP; } xbus_master.rx.checksum_ok = 0; }