SOES implementation i.c.w. ET1100 (Beckhoff ASIC)
Dependencies: KL25Z_ClockControl MODSERIAL mbed
Fork of EtherCAT-XbusMaster by
soes.cpp@37:d00717883d98, 2015-09-11 (annotated)
- Committer:
- vsluiter
- Date:
- Fri Sep 11 11:55:46 2015 +0000
- Revision:
- 37:d00717883d98
- Parent:
- 33:b4844666684f
- Child:
- 39:8c5329c37de1
Changed memcopy for right naming, changed PDO names in objectlist
Who changed what in which revision?
User | Revision | Line number | New 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 : soes.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 | |
vsluiter | 1:5e22bf1a3817 | 32 | /**************************************************** |
vsluiter | 1:5e22bf1a3817 | 33 | Chip type : STM32F051R8 |
vsluiter | 1:5e22bf1a3817 | 34 | Clock frequency : 48 MHz |
vsluiter | 1:5e22bf1a3817 | 35 | *****************************************************/ |
vsluiter | 1:5e22bf1a3817 | 36 | |
vsluiter | 1:5e22bf1a3817 | 37 | /* Includes ------------------------------------------------------------------*/ |
vsluiter | 1:5e22bf1a3817 | 38 | #include "mbed.h" |
vsluiter | 1:5e22bf1a3817 | 39 | #include "cpuinit.h" |
vsluiter | 1:5e22bf1a3817 | 40 | #include "utypes.h" |
vsluiter | 1:5e22bf1a3817 | 41 | #include "esc.h" |
vsluiter | 12:cac4e7c2bd0f | 42 | #include "MODSERIAL.h" |
vsluiter | 17:c5946a0fde83 | 43 | #include "xbus.h" |
vsluiter | 1:5e22bf1a3817 | 44 | |
vsluiter | 1:5e22bf1a3817 | 45 | /* Private typedef -----------------------------------------------------------*/ |
vsluiter | 1:5e22bf1a3817 | 46 | /* Private define ------------------------------------------------------------*/ |
vsluiter | 1:5e22bf1a3817 | 47 | #define wd_reset 1000 |
vsluiter | 1:5e22bf1a3817 | 48 | |
vsluiter | 1:5e22bf1a3817 | 49 | /* Private macro -------------------------------------------------------------*/ |
vsluiter | 1:5e22bf1a3817 | 50 | /* Private variables ---------------------------------------------------------*/ |
vsluiter | 1:5e22bf1a3817 | 51 | _ESCvar ESCvar; |
vsluiter | 1:5e22bf1a3817 | 52 | uint8 APPstate; |
vsluiter | 1:5e22bf1a3817 | 53 | _MBX MBX[MBXBUFFERS]; |
vsluiter | 1:5e22bf1a3817 | 54 | _MBXcontrol MBXcontrol[MBXBUFFERS]; |
vsluiter | 1:5e22bf1a3817 | 55 | uint8 MBXrun=0; |
vsluiter | 1:5e22bf1a3817 | 56 | uint16 SM2_sml,SM3_sml; |
vsluiter | 1:5e22bf1a3817 | 57 | _Rbuffer Rb; |
vsluiter | 1:5e22bf1a3817 | 58 | _Wbuffer Wb; |
vsluiter | 11:166353137b95 | 59 | _Ebuffer Eb; //EEprom |
vsluiter | 1:5e22bf1a3817 | 60 | uint8 TXPDOsize,RXPDOsize; |
vsluiter | 1:5e22bf1a3817 | 61 | uint16 wd_ok = 1, wd_cnt = wd_reset; |
vsluiter | 1:5e22bf1a3817 | 62 | |
vsluiter | 25:829af6f3429f | 63 | _Rbuffer local_Rb; //to prevent issues when updating |
vsluiter | 1:5e22bf1a3817 | 64 | DigitalOut led(LED_PIN); |
vsluiter | 1:5e22bf1a3817 | 65 | DigitalOut et1100_ss(ET1100_SS); |
vsluiter | 1:5e22bf1a3817 | 66 | DigitalIn et1100_miso(ET1100_MISO); |
vsluiter | 1:5e22bf1a3817 | 67 | SPI et1100_spi(ET1100_MOSI,ET1100_MISO,ET1100_SCK); |
vsluiter | 28:8505285f65ed | 68 | MODSERIAL xbus_serial(PTA2,PTA1, 512); |
vsluiter | 18:6629e8c5d59e | 69 | xbus_t xbus_master; |
vsluiter | 28:8505285f65ed | 70 | //MODSERIAL pc(USBTX,USBRX,512); |
vsluiter | 16:bfc7ea6bd1af | 71 | |
vsluiter | 22:3f3a9f55054c | 72 | DigitalOut ploep(PTA13); |
vsluiter | 22:3f3a9f55054c | 73 | #define PLOEP do{ploep = !(ploep);}while(0); |
vsluiter | 19:8ead12aec8d5 | 74 | |
vsluiter | 1:5e22bf1a3817 | 75 | /* Private function prototypes -----------------------------------------------*/ |
vsluiter | 1:5e22bf1a3817 | 76 | /* Private functions ---------------------------------------------------------*/ |
vsluiter | 1:5e22bf1a3817 | 77 | |
vsluiter | 1:5e22bf1a3817 | 78 | /** void ESC_objecthandler(uint16 index, uint8 subindex) |
vsluiter | 1:5e22bf1a3817 | 79 | \brief Object handler, declared from esc.h, as extern function |
vsluiter | 1:5e22bf1a3817 | 80 | \param index |
vsluiter | 1:5e22bf1a3817 | 81 | \param subindex |
vsluiter | 1:5e22bf1a3817 | 82 | */ |
vsluiter | 1:5e22bf1a3817 | 83 | void ESC_objecthandler(uint16 index, uint8 subindex); |
vsluiter | 1:5e22bf1a3817 | 84 | void TXPDO_update(void); |
vsluiter | 1:5e22bf1a3817 | 85 | void RXPDO_update(void); |
vsluiter | 1:5e22bf1a3817 | 86 | void DIG_process(void); |
vsluiter | 5:6d75f432a41f | 87 | void sample(void); |
vsluiter | 1:5e22bf1a3817 | 88 | |
vsluiter | 1:5e22bf1a3817 | 89 | void ESC_objecthandler(uint16 index, uint8 subindex) |
vsluiter | 1:5e22bf1a3817 | 90 | { |
vsluiter | 1:5e22bf1a3817 | 91 | uint8 dummy8; |
vsluiter | 1:5e22bf1a3817 | 92 | uint16 dummy16; |
vsluiter | 1:5e22bf1a3817 | 93 | switch (index) |
vsluiter | 1:5e22bf1a3817 | 94 | { |
vsluiter | 1:5e22bf1a3817 | 95 | case 0x8000: |
vsluiter | 1:5e22bf1a3817 | 96 | switch (subindex) |
vsluiter | 1:5e22bf1a3817 | 97 | { |
vsluiter | 1:5e22bf1a3817 | 98 | case 0x01: |
vsluiter | 26:c7959f1fd09a | 99 | { |
vsluiter | 26:c7959f1fd09a | 100 | uint32_t rates[] = {460800,230400,115200,76800,57600,38400,28800,19200,14400,9600}; |
vsluiter | 28:8505285f65ed | 101 | if(Eb.setting8 < (sizeof(rates)/sizeof(uint32_t)) ) |
vsluiter | 27:93c0e4ae943e | 102 | { |
vsluiter | 27:93c0e4ae943e | 103 | XbusGoToConfig(); |
vsluiter | 26:c7959f1fd09a | 104 | XbusSetBaudRate(Eb.setting8); |
vsluiter | 26:c7959f1fd09a | 105 | XbusReset(); |
vsluiter | 27:93c0e4ae943e | 106 | wait(2); |
vsluiter | 26:c7959f1fd09a | 107 | xbus_serial.baud(rates[Eb.setting8]); |
vsluiter | 26:c7959f1fd09a | 108 | XbusInitializeXbusMaster(); |
vsluiter | 26:c7959f1fd09a | 109 | |
vsluiter | 26:c7959f1fd09a | 110 | } |
vsluiter | 28:8505285f65ed | 111 | else if(Eb.setting8 == 0x80) |
vsluiter | 28:8505285f65ed | 112 | { |
vsluiter | 28:8505285f65ed | 113 | XbusGoToConfig(); |
vsluiter | 28:8505285f65ed | 114 | XbusSetBaudRate(0x80); |
vsluiter | 28:8505285f65ed | 115 | XbusReset(); |
vsluiter | 28:8505285f65ed | 116 | wait(2); |
vsluiter | 28:8505285f65ed | 117 | xbus_serial.baud(960800); |
vsluiter | 28:8505285f65ed | 118 | XbusInitializeXbusMaster(); |
vsluiter | 28:8505285f65ed | 119 | |
vsluiter | 28:8505285f65ed | 120 | } |
vsluiter | 1:5e22bf1a3817 | 121 | break; |
vsluiter | 26:c7959f1fd09a | 122 | } |
vsluiter | 1:5e22bf1a3817 | 123 | case 0x02: |
vsluiter | 5:6d75f432a41f | 124 | dummy16 = 0;//Eb.setting16;//Write value to EEPROM; eeprom_write_word(&eedat.setting16, Wb.setting16); |
vsluiter | 1:5e22bf1a3817 | 125 | break; |
vsluiter | 1:5e22bf1a3817 | 126 | } |
vsluiter | 1:5e22bf1a3817 | 127 | break; |
vsluiter | 1:5e22bf1a3817 | 128 | } |
vsluiter | 1:5e22bf1a3817 | 129 | } |
vsluiter | 1:5e22bf1a3817 | 130 | |
vsluiter | 1:5e22bf1a3817 | 131 | void TXPDO_update(void) |
vsluiter | 1:5e22bf1a3817 | 132 | { |
vsluiter | 1:5e22bf1a3817 | 133 | ESC_write(SM3_sma, &Rb, TXPDOsize, &ESCvar.ALevent); |
vsluiter | 1:5e22bf1a3817 | 134 | } |
vsluiter | 1:5e22bf1a3817 | 135 | |
vsluiter | 1:5e22bf1a3817 | 136 | void RXPDO_update(void) |
vsluiter | 1:5e22bf1a3817 | 137 | { |
vsluiter | 1:5e22bf1a3817 | 138 | ESC_read(SM2_sma, &Wb, RXPDOsize, &ESCvar.ALevent); |
vsluiter | 1:5e22bf1a3817 | 139 | } |
vsluiter | 1:5e22bf1a3817 | 140 | |
vsluiter | 1:5e22bf1a3817 | 141 | void APP_safeoutput(void) |
vsluiter | 1:5e22bf1a3817 | 142 | { |
vsluiter | 1:5e22bf1a3817 | 143 | asm("nop"); |
vsluiter | 1:5e22bf1a3817 | 144 | //Wb.dout = 0; |
vsluiter | 1:5e22bf1a3817 | 145 | //DOUTPORT = (Wb.dout >> 4) & 0xf0; |
vsluiter | 1:5e22bf1a3817 | 146 | } |
vsluiter | 1:5e22bf1a3817 | 147 | |
vsluiter | 1:5e22bf1a3817 | 148 | void DIG_process(void) |
vsluiter | 1:5e22bf1a3817 | 149 | { |
vsluiter | 16:bfc7ea6bd1af | 150 | uint8_t correct_offset; |
vsluiter | 1:5e22bf1a3817 | 151 | if (APPstate & APPSTATE_OUTPUT) //output enabled |
vsluiter | 1:5e22bf1a3817 | 152 | { |
vsluiter | 1:5e22bf1a3817 | 153 | if (ESCvar.ALevent & ESCREG_ALEVENT_SM2) // SM2 trigger ? |
vsluiter | 1:5e22bf1a3817 | 154 | { |
vsluiter | 1:5e22bf1a3817 | 155 | ESCvar.ALevent &= ~ESCREG_ALEVENT_SM2; |
vsluiter | 8:09dcef3ed467 | 156 | RXPDO_update(); |
vsluiter | 1:5e22bf1a3817 | 157 | // dummy output point |
vsluiter | 5:6d75f432a41f | 158 | correct_offset = Wb.correct_offset; |
vsluiter | 5:6d75f432a41f | 159 | if(correct_offset & 0x01) { |
vsluiter | 8:09dcef3ed467 | 160 | // led.write(1); |
vsluiter | 14:e3c49b75fee9 | 161 | asm("nop"); |
vsluiter | 8:09dcef3ed467 | 162 | } |
vsluiter | 8:09dcef3ed467 | 163 | // else |
vsluiter | 8:09dcef3ed467 | 164 | // led.write(0); |
vsluiter | 1:5e22bf1a3817 | 165 | wd_cnt = wd_reset; |
vsluiter | 1:5e22bf1a3817 | 166 | } |
vsluiter | 1:5e22bf1a3817 | 167 | |
vsluiter | 5:6d75f432a41f | 168 | if (!wd_cnt) { |
vsluiter | 1:5e22bf1a3817 | 169 | ESC_stopoutput(); |
vsluiter | 1:5e22bf1a3817 | 170 | // watchdog, invalid outputs |
vsluiter | 1:5e22bf1a3817 | 171 | ESC_ALerror(ALERR_WATCHDOG); |
vsluiter | 1:5e22bf1a3817 | 172 | // goto safe-op with error bit set |
vsluiter | 1:5e22bf1a3817 | 173 | ESC_ALstatus(ESCsafeop | ESCerror); |
vsluiter | 1:5e22bf1a3817 | 174 | } |
vsluiter | 1:5e22bf1a3817 | 175 | } |
vsluiter | 1:5e22bf1a3817 | 176 | else |
vsluiter | 1:5e22bf1a3817 | 177 | { |
vsluiter | 1:5e22bf1a3817 | 178 | //wd_ok = 1; |
vsluiter | 1:5e22bf1a3817 | 179 | wd_cnt = wd_reset; |
vsluiter | 1:5e22bf1a3817 | 180 | } |
vsluiter | 1:5e22bf1a3817 | 181 | if (APPstate) //input or output enabled |
vsluiter | 5:6d75f432a41f | 182 | { |
vsluiter | 25:829af6f3429f | 183 | //Rb.timestamp = ESCvar.Time; |
vsluiter | 1:5e22bf1a3817 | 184 | //just some dummy data to test |
vsluiter | 4:bb72df6dce33 | 185 | //Rb.counter++; |
vsluiter | 4:bb72df6dce33 | 186 | //Rb.diginput = diginput; |
vsluiter | 4:bb72df6dce33 | 187 | //Rb.analog[0] = 1; |
vsluiter | 4:bb72df6dce33 | 188 | //Rb.analog[1] = 2; |
vsluiter | 14:e3c49b75fee9 | 189 | |
vsluiter | 25:829af6f3429f | 190 | memcpy(&Rb, &local_Rb, sizeof(Rb)); |
vsluiter | 1:5e22bf1a3817 | 191 | TXPDO_update(); |
vsluiter | 5:6d75f432a41f | 192 | } |
vsluiter | 1:5e22bf1a3817 | 193 | } |
vsluiter | 1:5e22bf1a3817 | 194 | |
vsluiter | 33:b4844666684f | 195 | float ReverseFloat( const float inFloat ) |
vsluiter | 33:b4844666684f | 196 | { |
vsluiter | 33:b4844666684f | 197 | float retVal; |
vsluiter | 33:b4844666684f | 198 | char *floatToConvert = ( char* ) & inFloat; |
vsluiter | 33:b4844666684f | 199 | char *returnFloat = ( char* ) & retVal; |
vsluiter | 33:b4844666684f | 200 | |
vsluiter | 33:b4844666684f | 201 | // swap the bytes into a temporary buffer |
vsluiter | 33:b4844666684f | 202 | returnFloat[0] = floatToConvert[3]; |
vsluiter | 33:b4844666684f | 203 | returnFloat[1] = floatToConvert[2]; |
vsluiter | 33:b4844666684f | 204 | returnFloat[2] = floatToConvert[1]; |
vsluiter | 33:b4844666684f | 205 | returnFloat[3] = floatToConvert[0]; |
vsluiter | 33:b4844666684f | 206 | |
vsluiter | 33:b4844666684f | 207 | return retVal; |
vsluiter | 33:b4844666684f | 208 | } |
vsluiter | 33:b4844666684f | 209 | |
vsluiter | 21:6150ca891301 | 210 | //Watch out, this is an uggly fix; for odd numbers of num_bytes, still the trailing byte will be used too. |
vsluiter | 21:6150ca891301 | 211 | //No memory protection what so ever. |
vsluiter | 21:6150ca891301 | 212 | void memcpy_byteswap(uint8_t * dest, uint8_t * source, uint16_t num_bytes) |
vsluiter | 21:6150ca891301 | 213 | { |
vsluiter | 21:6150ca891301 | 214 | for( int i = 0 ; i < num_bytes ; i+=2 ) |
vsluiter | 21:6150ca891301 | 215 | { |
vsluiter | 21:6150ca891301 | 216 | dest[i] = source[i+1]; |
vsluiter | 21:6150ca891301 | 217 | dest[i+1] = source[i]; |
vsluiter | 21:6150ca891301 | 218 | } |
vsluiter | 21:6150ca891301 | 219 | } |
vsluiter | 17:c5946a0fde83 | 220 | |
vsluiter | 33:b4844666684f | 221 | //Watch out, this is an uggly fix; for odd numbers of num_bytes, still the trailing byte will be used too. |
vsluiter | 33:b4844666684f | 222 | //No memory protection what so ever. |
vsluiter | 33:b4844666684f | 223 | void memcpy_floatswap(uint8_t * dest, uint8_t * source, uint16_t num_bytes) |
vsluiter | 33:b4844666684f | 224 | { |
vsluiter | 33:b4844666684f | 225 | for( int i = 0 ; i < num_bytes ; i+=4 ) |
vsluiter | 33:b4844666684f | 226 | { |
vsluiter | 33:b4844666684f | 227 | dest[i] = source[i+3]; |
vsluiter | 33:b4844666684f | 228 | dest[i+1] = source[i+2]; |
vsluiter | 33:b4844666684f | 229 | dest[i+2] = source[i+1]; |
vsluiter | 33:b4844666684f | 230 | dest[i+3] = source[i]; |
vsluiter | 33:b4844666684f | 231 | } |
vsluiter | 33:b4844666684f | 232 | } |
vsluiter | 33:b4844666684f | 233 | |
vsluiter | 33:b4844666684f | 234 | |
vsluiter | 1:5e22bf1a3817 | 235 | int main(void) |
vsluiter | 1:5e22bf1a3817 | 236 | { |
vsluiter | 25:829af6f3429f | 237 | |
vsluiter | 1:5e22bf1a3817 | 238 | /*!< At this stage the microcontroller clock setting is already configured, |
vsluiter | 1:5e22bf1a3817 | 239 | this is done through SystemInit() function which is called from startup |
vsluiter | 1:5e22bf1a3817 | 240 | file (startup_stm32f0xx.s) before to branch to application main. |
vsluiter | 1:5e22bf1a3817 | 241 | To reconfigure the default setting of SystemInit() function, refer to |
vsluiter | 1:5e22bf1a3817 | 242 | system_stm32f0xx.c file |
vsluiter | 1:5e22bf1a3817 | 243 | */ |
vsluiter | 1:5e22bf1a3817 | 244 | cpuinit(); |
vsluiter | 1:5e22bf1a3817 | 245 | TXPDOsize = sizeTXPDO(); |
vsluiter | 1:5e22bf1a3817 | 246 | RXPDOsize = sizeRXPDO(); |
vsluiter | 1:5e22bf1a3817 | 247 | wait_ms(200); |
vsluiter | 1:5e22bf1a3817 | 248 | /*initialize configuration*/ |
vsluiter | 5:6d75f432a41f | 249 | //Eb.setting16 = 0xABCD; |
vsluiter | 28:8505285f65ed | 250 | Eb.setting8 = 1; |
vsluiter | 1:5e22bf1a3817 | 251 | // wait until ESC is started up |
vsluiter | 1:5e22bf1a3817 | 252 | while ((ESCvar.DLstatus & 0x0001) == 0) |
vsluiter | 1:5e22bf1a3817 | 253 | ESC_read(ESCREG_DLSTATUS, &ESCvar.DLstatus, sizeof(ESCvar.DLstatus), &ESCvar.ALevent); |
vsluiter | 1:5e22bf1a3817 | 254 | |
vsluiter | 1:5e22bf1a3817 | 255 | // reset ESC to init state |
vsluiter | 1:5e22bf1a3817 | 256 | ESC_ALstatus(ESCinit); |
vsluiter | 1:5e22bf1a3817 | 257 | ESC_ALerror(ALERR_NONE); |
vsluiter | 1:5e22bf1a3817 | 258 | ESC_stopmbx(); |
vsluiter | 1:5e22bf1a3817 | 259 | ESC_stopinput(); |
vsluiter | 1:5e22bf1a3817 | 260 | ESC_stopoutput(); |
vsluiter | 25:829af6f3429f | 261 | |
vsluiter | 25:829af6f3429f | 262 | // pc.baud(115200); |
vsluiter | 1:5e22bf1a3817 | 263 | // application run loop |
vsluiter | 1:5e22bf1a3817 | 264 | while (1) |
vsluiter | 1:5e22bf1a3817 | 265 | { |
vsluiter | 20:ad13d4f5fd98 | 266 | while(xbus_serial.readable()) |
vsluiter | 20:ad13d4f5fd98 | 267 | { |
vsluiter | 20:ad13d4f5fd98 | 268 | XbusReceiveState(&xbus_master, xbus_serial.getc()); |
vsluiter | 20:ad13d4f5fd98 | 269 | if(xbus_master.rx.checksum_ok) |
vsluiter | 20:ad13d4f5fd98 | 270 | { |
vsluiter | 20:ad13d4f5fd98 | 271 | if(xbus_master.rx.buffer[2] == 0x32) |
vsluiter | 20:ad13d4f5fd98 | 272 | { |
vsluiter | 25:829af6f3429f | 273 | memcpy_byteswap((uint8_t *)&local_Rb.timestamp ,&xbus_master.rx.buffer[4], 2); |
vsluiter | 37:d00717883d98 | 274 | memcpy_floatswap((uint8_t *)&local_Rb.first.q0,&xbus_master.rx.buffer[6],xbus_master.rx.buffer[3] - 2); |
vsluiter | 33:b4844666684f | 275 | //memcpy_byteswap((uint8_t *)&local_Rb.first.acc[0],&xbus_master.rx.buffer[6],xbus_master.rx.buffer[3] - 2); |
vsluiter | 25:829af6f3429f | 276 | //pc.printf("%x %x\n",Rb.timestamp, *((uint16_t *)(&xbus_master.rx.buffer[4]))); |
vsluiter | 27:93c0e4ae943e | 277 | PLOEP; |
vsluiter | 20:ad13d4f5fd98 | 278 | } |
vsluiter | 20:ad13d4f5fd98 | 279 | xbus_master.rx.checksum_ok = 0; |
vsluiter | 20:ad13d4f5fd98 | 280 | } |
vsluiter | 18:6629e8c5d59e | 281 | } |
vsluiter | 1:5e22bf1a3817 | 282 | ESC_read(ESCREG_LOCALTIME, &ESCvar.Time, sizeof(ESCvar.Time), &ESCvar.ALevent); |
vsluiter | 1:5e22bf1a3817 | 283 | ESC_ALevent(); |
vsluiter | 1:5e22bf1a3817 | 284 | ESC_state(); |
vsluiter | 1:5e22bf1a3817 | 285 | if (ESC_mbxprocess()) |
vsluiter | 1:5e22bf1a3817 | 286 | { |
vsluiter | 1:5e22bf1a3817 | 287 | ESC_coeprocess(); |
vsluiter | 1:5e22bf1a3817 | 288 | ESC_xoeprocess(); |
vsluiter | 1:5e22bf1a3817 | 289 | } |
vsluiter | 1:5e22bf1a3817 | 290 | DIG_process(); |
vsluiter | 1:5e22bf1a3817 | 291 | } |
vsluiter | 1:5e22bf1a3817 | 292 | } |
vsluiter | 1:5e22bf1a3817 | 293 | |
vsluiter | 1:5e22bf1a3817 | 294 | /** void ESC_objecthandler(uint16 index, uint8 subindex) |
vsluiter | 1:5e22bf1a3817 | 295 | \brief Object handler, declared from esc.h, as extern function |
vsluiter | 1:5e22bf1a3817 | 296 | \param index |
vsluiter | 1:5e22bf1a3817 | 297 | \param subindex |
vsluiter | 1:5e22bf1a3817 | 298 | */ |
vsluiter | 1:5e22bf1a3817 | 299 | |
vsluiter | 1:5e22bf1a3817 | 300 | |
vsluiter | 1:5e22bf1a3817 | 301 | #ifdef USE_FULL_ASSERT |
vsluiter | 1:5e22bf1a3817 | 302 | |
vsluiter | 1:5e22bf1a3817 | 303 | /** |
vsluiter | 1:5e22bf1a3817 | 304 | * @brief Reports the name of the source file and the source line number |
vsluiter | 1:5e22bf1a3817 | 305 | * where the assert_param error has occurred. |
vsluiter | 1:5e22bf1a3817 | 306 | * @param file: pointer to the source file name |
vsluiter | 1:5e22bf1a3817 | 307 | * @param line: assert_param error line source number |
vsluiter | 1:5e22bf1a3817 | 308 | * @retval None |
vsluiter | 1:5e22bf1a3817 | 309 | */ |
vsluiter | 1:5e22bf1a3817 | 310 | void assert_failed(uint8_t* file, uint32_t line) |
vsluiter | 1:5e22bf1a3817 | 311 | { |
vsluiter | 1:5e22bf1a3817 | 312 | /* User can add his own implementation to report the file name and line number, |
vsluiter | 1:5e22bf1a3817 | 313 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |
vsluiter | 1:5e22bf1a3817 | 314 | |
vsluiter | 1:5e22bf1a3817 | 315 | /* Infinite loop */ |
vsluiter | 1:5e22bf1a3817 | 316 | while (1) |
vsluiter | 1:5e22bf1a3817 | 317 | { |
vsluiter | 1:5e22bf1a3817 | 318 | } |
vsluiter | 1:5e22bf1a3817 | 319 | } |
vsluiter | 1:5e22bf1a3817 | 320 | #endif |
vsluiter | 1:5e22bf1a3817 | 321 | |
vsluiter | 1:5e22bf1a3817 | 322 | /** |
vsluiter | 1:5e22bf1a3817 | 323 | * @} |
vsluiter | 1:5e22bf1a3817 | 324 | */ |
vsluiter | 1:5e22bf1a3817 | 325 | |
vsluiter | 1:5e22bf1a3817 | 326 | /** |
vsluiter | 1:5e22bf1a3817 | 327 | * @} |
vsluiter | 1:5e22bf1a3817 | 328 | */ |
vsluiter | 1:5e22bf1a3817 | 329 | |
vsluiter | 1:5e22bf1a3817 | 330 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
vsluiter | 1:5e22bf1a3817 | 331 |