EtherCAT slave that reads 3 Xsens IMU's connected to a Xbus Master

Dependencies:   MODSERIAL mbed KL25Z_ClockControl

Fork of EtherCAT by First Last

Committer:
vsluiter
Date:
Fri Dec 12 00:31:22 2014 +0000
Revision:
8:09dcef3ed467
Parent:
5:6d75f432a41f
Child:
13:5e4dcbd44786
WORKING!! With correction of offsets.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vsluiter 1:5e22bf1a3817 1 /*
vsluiter 1:5e22bf1a3817 2 * SOES Simple Open EtherCAT Slave
vsluiter 1:5e22bf1a3817 3 *
vsluiter 1:5e22bf1a3817 4 * File : cpuinit.c
vsluiter 1:5e22bf1a3817 5 * Version : 0.9.2
vsluiter 1:5e22bf1a3817 6 * Date : 22-02-2010
vsluiter 1:5e22bf1a3817 7 * Copyright (C) 2007-2010 Arthur Ketels
vsluiter 1:5e22bf1a3817 8 *
vsluiter 1:5e22bf1a3817 9 * SOES is free software; you can redistribute it and/or modify it under
vsluiter 1:5e22bf1a3817 10 * the terms of the GNU General Public License version 2 as published by the Free
vsluiter 1:5e22bf1a3817 11 * Software Foundation.
vsluiter 1:5e22bf1a3817 12 *
vsluiter 1:5e22bf1a3817 13 * SOES is distributed in the hope that it will be useful, but WITHOUT ANY
vsluiter 1:5e22bf1a3817 14 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
vsluiter 1:5e22bf1a3817 15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
vsluiter 1:5e22bf1a3817 16 * for more details.
vsluiter 1:5e22bf1a3817 17 *
vsluiter 1:5e22bf1a3817 18 * As a special exception, if other files instantiate templates or use macros
vsluiter 1:5e22bf1a3817 19 * or inline functions from this file, or you compile this file and link it
vsluiter 1:5e22bf1a3817 20 * with other works to produce a work based on this file, this file does not
vsluiter 1:5e22bf1a3817 21 * by itself cause the resulting work to be covered by the GNU General Public
vsluiter 1:5e22bf1a3817 22 * License. However the source code for this file must still be made available
vsluiter 1:5e22bf1a3817 23 * in accordance with section (3) of the GNU General Public License.
vsluiter 1:5e22bf1a3817 24 *
vsluiter 1:5e22bf1a3817 25 * This exception does not invalidate any other reasons why a work based on
vsluiter 1:5e22bf1a3817 26 * this file might be covered by the GNU General Public License.
vsluiter 1:5e22bf1a3817 27 *
vsluiter 1:5e22bf1a3817 28 * The EtherCAT Technology, the trade name and logo "EtherCAT" are the intellectual
vsluiter 1:5e22bf1a3817 29 * property of, and protected by Beckhoff Automation GmbH.
vsluiter 1:5e22bf1a3817 30 */
vsluiter 1:5e22bf1a3817 31 //#include <avr/io.h>
vsluiter 1:5e22bf1a3817 32 #include "cpuinit.h"
vsluiter 1:5e22bf1a3817 33 #include "mbed.h"
vsluiter 1:5e22bf1a3817 34
vsluiter 5:6d75f432a41f 35 extern float FrontRight_offset;
vsluiter 5:6d75f432a41f 36 extern float FrontLeft_offset;
vsluiter 5:6d75f432a41f 37 extern float BackLeft_offset;
vsluiter 5:6d75f432a41f 38 extern float BackRight_offset;
vsluiter 5:6d75f432a41f 39
vsluiter 1:5e22bf1a3817 40 void cpuinit(void)
vsluiter 1:5e22bf1a3817 41 {
vsluiter 1:5e22bf1a3817 42 //shoe_serial.baud(921600);
vsluiter 1:5e22bf1a3817 43 //et1100_spi.format(8,3);
vsluiter 8:09dcef3ed467 44 et1100_spi.frequency(1000000);
vsluiter 4:bb72df6dce33 45 //inintialize all dummy inputs
vsluiter 4:bb72df6dce33 46 DigitalOut dummy1(PTC2);//do not leave ADC input floating
vsluiter 4:bb72df6dce33 47 DigitalOut dummy2(PTC0);
vsluiter 4:bb72df6dce33 48 DigitalOut dummy3(PTC1);
vsluiter 8:09dcef3ed467 49 //DigitalOut dummy4(PTD1);
vsluiter 4:bb72df6dce33 50 DigitalOut dummy5(PTD5);
vsluiter 4:bb72df6dce33 51 DigitalOut dummy6(PTD6);
vsluiter 4:bb72df6dce33 52 DigitalOut dummy7(PTE20);
vsluiter 4:bb72df6dce33 53 DigitalOut dummy8(PTE21);
vsluiter 4:bb72df6dce33 54 DigitalOut dummy9(PTE22);
vsluiter 4:bb72df6dce33 55 DigitalOut dummy10(PTE23);
vsluiter 4:bb72df6dce33 56 DigitalOut dummy11(PTE29);
vsluiter 4:bb72df6dce33 57 DigitalOut dummy12(PTE30);
vsluiter 8:09dcef3ed467 58 dummy1 = dummy2 = dummy3 = dummy5 = dummy6 = 0;
vsluiter 4:bb72df6dce33 59 dummy7 = dummy8 = dummy9 = dummy10 = dummy11 = dummy12 = 0;
vsluiter 5:6d75f432a41f 60 //offset correction
vsluiter 5:6d75f432a41f 61 wait_ms(20);
vsluiter 5:6d75f432a41f 62 FrontLeft_offset = adcFrontLeft;
vsluiter 5:6d75f432a41f 63 FrontRight_offset = adcFrontRight;
vsluiter 5:6d75f432a41f 64 BackLeft_offset = adcBackLeft;
vsluiter 5:6d75f432a41f 65 BackRight_offset = adcBackRight;
vsluiter 1:5e22bf1a3817 66
vsluiter 1:5e22bf1a3817 67 }
vsluiter 1:5e22bf1a3817 68