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:
- 25:829af6f3429f
- Parent:
- 24:fa1c5af49650
- Child:
- 26:c7959f1fd09a
--- a/soes.cpp Fri Mar 06 11:17:33 2015 +0000 +++ b/soes.cpp Sun Mar 08 21:15:47 2015 +0000 @@ -60,16 +60,14 @@ uint8 TXPDOsize,RXPDOsize; uint16 wd_ok = 1, wd_cnt = wd_reset; -uint8_t copy_new_data = 0; -uint8_t copydata; - +_Rbuffer local_Rb; //to prevent issues when updating DigitalOut led(LED_PIN); DigitalOut et1100_ss(ET1100_SS); DigitalIn et1100_miso(ET1100_MISO); 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); DigitalOut ploep(PTA13); #define PLOEP do{ploep = !(ploep);}while(0); @@ -160,14 +158,14 @@ } if (APPstate) //input or output enabled { - Rb.timestamp = ESCvar.Time; + //Rb.timestamp = ESCvar.Time; //just some dummy data to test //Rb.counter++; //Rb.diginput = diginput; //Rb.analog[0] = 1; //Rb.analog[1] = 2; - + memcpy(&Rb, &local_Rb, sizeof(Rb)); TXPDO_update(); } } @@ -185,6 +183,7 @@ int main(void) { + /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup file (startup_stm32f0xx.s) before to branch to application main. @@ -208,7 +207,8 @@ ESC_stopmbx(); ESC_stopinput(); ESC_stopoutput(); - + +// pc.baud(115200); // application run loop while (1) { @@ -220,9 +220,9 @@ { if(xbus_master.rx.buffer[2] == 0x32) { - memcpy_byteswap((uint8_t *)&Rb.first.acc[0],&xbus_master.rx.buffer[6],60); - memcpy_byteswap((uint8_t *)&Rb.timestamp, &xbus_master.rx.buffer[4],2); - //pc.printf("%u , %u\n", Rb.first.acc[0] , *((uint16_t *)(&xbus_master.rx.buffer[6])) ); + 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]))); } xbus_master.rx.checksum_ok = 0; }