update demo application
parent
b133bc7f97
commit
308fedfafc
|
@ -24,6 +24,9 @@ include(${CMAKE_SYSTEM_NAME})
|
|||
|
||||
# Source paths
|
||||
add_subdirectory (soes)
|
||||
add_subdirectory (applications/rtl_slavedemo)
|
||||
|
||||
message (STATUS "Building for ${CMAKE_SYSTEM_NAME}")
|
||||
|
||||
include (InstallRequiredSystemLibraries)
|
||||
set (CPACK_RESOURCE_FILE_LICENSE "${SOES_SOURCE_DIR}/LICENSE")
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
add_executable (rtl_slavedemo
|
||||
soes.c
|
||||
objectlist.c
|
||||
led_handler.c
|
||||
bootstrap.c
|
||||
main.c
|
||||
)
|
||||
target_link_libraries(rtl_slavedemo LINK_PUBLIC soes)
|
|
@ -20,25 +20,16 @@
|
|||
|
||||
#include <kern.h>
|
||||
#include <bsp.h>
|
||||
//#include <twrk60.h>
|
||||
#include <flash_drv.h>
|
||||
|
||||
#include "utypes.h"
|
||||
#include "esc.h"
|
||||
#include "esc_foe.h"
|
||||
#include "osal.h"
|
||||
/* #include "utypes.h" */
|
||||
/* #include "esc.h" */
|
||||
#include <esc_foe.h>
|
||||
/* #include "osal.h" */
|
||||
#include "bootstrap.h"
|
||||
|
||||
#define ESC_DEBUG
|
||||
|
||||
#ifdef ESC_DEBUG
|
||||
#define DPRINT(...) OSAL_PRINT ("bootstrap: "__VA_ARGS__)
|
||||
#define DEBUG_ASSERT(expression) ASSERT(expression)
|
||||
#else
|
||||
#define DPRINT(...)
|
||||
#define DEBUG_ASSERT(expression)
|
||||
#endif /* DEBUG */
|
||||
|
||||
uint32_t local_boot_state = BOOT_IDLE;
|
||||
static uint32_t boot_started = 0;
|
||||
static uint32_t boot_watch_dog = 0;
|
||||
|
@ -206,5 +197,3 @@ void bootstrap_state (void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,192 +25,133 @@
|
|||
* The EtherCAT Technology, the trade name and logo "EtherCAT" are the intellectual
|
||||
* property of, and protected by Beckhoff Automation GmbH.
|
||||
*/
|
||||
|
||||
|
||||
/** \file
|
||||
* \brief
|
||||
* CoE Object Dictionary.
|
||||
* CoE Object Dictionary.
|
||||
*
|
||||
* Part of application, describe the slave and its process data.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __objectlist__
|
||||
#define __objectlist__
|
||||
|
||||
typedef FLASHSTORE struct PACKED
|
||||
{
|
||||
uint16 subindex;
|
||||
uint16 datatype;
|
||||
uint16 bitlength;
|
||||
uint16 access;
|
||||
char FLASHSTORE *name;
|
||||
uint32 value;
|
||||
void *data;
|
||||
} _objd;
|
||||
#include "esc_coe.h"
|
||||
#include "utypes.h"
|
||||
|
||||
typedef FLASHSTORE struct PACKED
|
||||
{
|
||||
uint16 index;
|
||||
uint16 objtype;
|
||||
uint8 maxsub;
|
||||
uint8 pad1;
|
||||
char FLASHSTORE *name;
|
||||
_objd FLASHSTORE *objdesc;
|
||||
} _objectlist;
|
||||
extern _Rbuffer Rb;
|
||||
extern _Wbuffer Wb;
|
||||
extern _Cbuffer Cb;
|
||||
extern uint32 encoder_scale;
|
||||
extern uint32 encoder_scale_mirror;
|
||||
|
||||
#define OBJH_READ 0
|
||||
#define OBJH_WRITE 1
|
||||
static const char acName1000[] = "Device Type";
|
||||
static const char acName1008[] = "Manufacturer Device Name";
|
||||
static const char acName1009[] = "Manufacturer Hardware Version";
|
||||
static const char acName100A[] = "Manufacturer Software Version";
|
||||
static const char acName1018[] = "Identity Object";
|
||||
static const char acName1018_01[] = "Vendor ID";
|
||||
static const char acName1018_02[] = "Product Code";
|
||||
static const char acName1018_03[] = "Revision Number";
|
||||
static const char acName1018_04[] = "Serial Number";
|
||||
static const char acNameMO[] = "Mapped object";
|
||||
static const char acName1600[] = "Receive PDO mapping";
|
||||
static const char acName1A00[] = "Transmit PDO mapping";
|
||||
static const char acName1C00[] = "Sync Manager Communication type";
|
||||
static const char acName1C00_01[] = "Communications type SM0";
|
||||
static const char acName1C00_02[] = "Communications type SM1";
|
||||
static const char acName1C00_03[] = "Communications type SM2";
|
||||
static const char acName1C00_04[] = "Communications type SM3";
|
||||
static const char acName1C10[] = "Sync Manager 0 PDO Assignment";
|
||||
static const char acName1C11[] = "Sync Manager 1 PDO Assignment";
|
||||
static const char acName1C12[] = "Sync Manager 2 PDO Assignment";
|
||||
static const char acName1C13[] = "Sync Manager 3 PDO Assignment";
|
||||
static const char acNameNOE[] = "Number of entries";
|
||||
static const char acName6000[] = "Digital Inputs";
|
||||
static const char acName6000_01[] = "Button";
|
||||
static const char acName6000_02[] = "Encoder";
|
||||
static const char acName7000[] = "Digital outputs";
|
||||
static const char acName7000_01[] = "LED";
|
||||
static const char acName7100[] = "Parameters";
|
||||
static const char acName7100_01[] = "Encoder scale";
|
||||
static const char acName7100_02[] = "Encoder scale mirror";
|
||||
static const char acName8001[] = "Slave commands";
|
||||
static const char acName8001_01[] = "Reset counter";
|
||||
|
||||
#define _ac FLASHSTORE char
|
||||
#define nil 0
|
||||
static char ac1008_00[] = "SOES test application";
|
||||
static char ac1009_00[] = "0.0.2";
|
||||
static char ac100A_00[] = "0.9.3";
|
||||
|
||||
#define OTYPE_DOMAIN 0x0002
|
||||
#define OTYPE_DEFTYPE 0x0005
|
||||
#define OTYPE_DEFSTRUCT 0x0006
|
||||
#define OTYPE_VAR 0x0007
|
||||
#define OTYPE_ARRAY 0x0008
|
||||
#define OTYPE_RECORD 0x0009
|
||||
|
||||
#define DTYPE_BOOLEAN 0x0001
|
||||
#define DTYPE_INTEGER8 0x0002
|
||||
#define DTYPE_INTEGER16 0x0003
|
||||
#define DTYPE_INTEGER32 0x0004
|
||||
#define DTYPE_UNSIGNED8 0x0005
|
||||
#define DTYPE_UNSIGNED16 0x0006
|
||||
#define DTYPE_UNSIGNED32 0x0007
|
||||
#define DTYPE_REAL32 0x0008
|
||||
#define DTYPE_VISIBLE_STRING 0x0009
|
||||
#define DTYPE_OCTET_STRING 0x000A
|
||||
#define DTYPE_UNICODE_STRING 0x000B
|
||||
#define DTYPE_INTEGER24 0x0010
|
||||
#define DTYPE_UNSIGNED24 0x0016
|
||||
#define DTYPE_INTEGER64 0x0015
|
||||
#define DTYPE_UNSIGNED64 0x001B
|
||||
#define DTYPE_REAL64 0x0011
|
||||
#define DTYPE_PDO_MAPPING 0x0021
|
||||
#define DTYPE_IDENTITY 0x0023
|
||||
#define DTYPE_BIT1 0x0030
|
||||
#define DTYPE_BIT2 0x0031
|
||||
#define DTYPE_BIT3 0x0032
|
||||
#define DTYPE_BIT4 0x0033
|
||||
#define DTYPE_BIT5 0x0034
|
||||
#define DTYPE_BIT6 0x0035
|
||||
#define DTYPE_BIT7 0x0036
|
||||
#define DTYPE_BIT8 0x0037
|
||||
|
||||
#define ATYPE_R 0x07
|
||||
#define ATYPE_RW 0x3F
|
||||
#define ATYPE_RWpre 0x0F
|
||||
#define ATYPE_RXPDO 0x40
|
||||
#define ATYPE_TXPDO 0x80
|
||||
|
||||
_ac acName1000[] = "Device Type";
|
||||
_ac acName1008[] = "Manufacturer Device Name";
|
||||
_ac acName1009[] = "Manufacturer Hardware Version";
|
||||
_ac acName100A[] = "Manufacturer Software Version";
|
||||
_ac acName1018[] = "Identity Object";
|
||||
_ac acName1018_01[] = "Vendor ID";
|
||||
_ac acName1018_02[] = "Product Code";
|
||||
_ac acName1018_03[] = "Revision Number";
|
||||
_ac acName1018_04[] = "Serial Number";
|
||||
_ac acNameMO[] = "Mapped object";
|
||||
_ac acName1600[] = "Receive PDO mapping";
|
||||
_ac acName1A00[] = "Transmit PDO mapping";
|
||||
_ac acName1C00[] = "Sync Manager Communication type";
|
||||
_ac acName1C00_01[] = "Communications type SM0";
|
||||
_ac acName1C00_02[] = "Communications type SM1";
|
||||
_ac acName1C00_03[] = "Communications type SM2";
|
||||
_ac acName1C00_04[] = "Communications type SM3";
|
||||
_ac acName1C10[] = "Sync Manager 0 PDO Assignment";
|
||||
_ac acName1C11[] = "Sync Manager 1 PDO Assignment";
|
||||
_ac acName1C12[] = "Sync Manager 2 PDO Assignment";
|
||||
_ac acName1C13[] = "Sync Manager 3 PDO Assignment";
|
||||
_ac acNameNOE[] = "Number of entries";
|
||||
_ac acName6000[] = "Digital Inputs";
|
||||
_ac acName6000_01[] = "Button";
|
||||
_ac acName6000_02[] = "Encoder";
|
||||
_ac acName7000[] = "Digital outputs";
|
||||
_ac acName7000_01[] = "LED";
|
||||
_ac acName7100[] = "Parameters";
|
||||
_ac acName7100_01[] = "Encoder scale";
|
||||
_ac acName7100_02[] = "Encoder scale mirror";
|
||||
_ac acName8001[] = "Slave commands";
|
||||
_ac acName8001_01[] = "Reset counter";
|
||||
//_ac acName[]="";
|
||||
|
||||
char ac1008_00[] = "SOES test application";
|
||||
char ac1009_00[] = "0.0.2";
|
||||
char ac100A_00[] = "0.9.3";
|
||||
|
||||
FLASHSTORE _objd SDO1000[] =
|
||||
const _objd SDO1000[] =
|
||||
{ {0x00, DTYPE_UNSIGNED32, 32, ATYPE_R, &acName1000[0], 0x00000000, nil} };
|
||||
FLASHSTORE _objd SDO1008[] =
|
||||
const _objd SDO1008[] =
|
||||
{ {0x00, DTYPE_VISIBLE_STRING, sizeof (ac1008_00) << 3, ATYPE_R, &acName1008[0], 0, &ac1008_00[0]}
|
||||
};
|
||||
FLASHSTORE _objd SDO1009[] =
|
||||
const _objd SDO1009[] =
|
||||
{ {0x00, DTYPE_VISIBLE_STRING, sizeof (ac1009_00) << 3, ATYPE_R, &acName1009[0], 0, &ac1009_00[0]}
|
||||
};
|
||||
FLASHSTORE _objd SDO100A[] =
|
||||
const _objd SDO100A[] =
|
||||
{ {0x00, DTYPE_VISIBLE_STRING, sizeof (ac100A_00) << 3, ATYPE_R, &acName100A[0], 0, &ac100A_00[0]}
|
||||
};
|
||||
FLASHSTORE _objd SDO1018[] =
|
||||
const _objd SDO1018[] =
|
||||
{ {0x00, DTYPE_UNSIGNED8, 8, ATYPE_R, &acNameNOE[0], 0x04, nil},
|
||||
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_R, &acName1018_01[0], 0x00001337, nil},
|
||||
{0x02, DTYPE_UNSIGNED32, 32, ATYPE_R, &acName1018_02[0], 0x12783456, nil},
|
||||
{0x03, DTYPE_UNSIGNED32, 32, ATYPE_R, &acName1018_03[0], 0x00000001, nil},
|
||||
{0x04, DTYPE_UNSIGNED32, 32, ATYPE_R, &acName1018_04[0], 0x00000000, nil}
|
||||
};
|
||||
FLASHSTORE _objd SDO1600[] =
|
||||
const _objd SDO1600[] =
|
||||
{ {0x00, DTYPE_UNSIGNED8, 8, ATYPE_R, &acNameNOE[0], 0x01, nil},
|
||||
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_R, &acNameMO[0], 0x70000108, nil}
|
||||
};
|
||||
FLASHSTORE _objd SDO1A00[] =
|
||||
const _objd SDO1A00[] =
|
||||
{ {0x00, DTYPE_UNSIGNED8, 8, ATYPE_R, &acNameNOE[0], 0x02, nil},
|
||||
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_R, &acNameMO[0], 0x60000108, nil},
|
||||
{0x02, DTYPE_UNSIGNED32, 32, ATYPE_R, &acNameMO[0], 0x60000220, nil}
|
||||
|
||||
};
|
||||
FLASHSTORE _objd SDO1C00[] =
|
||||
const _objd SDO1C00[] =
|
||||
{ {0x00, DTYPE_UNSIGNED8, 8, ATYPE_R, &acNameNOE[0], 0x04, nil},
|
||||
{0x01, DTYPE_UNSIGNED8, 8, ATYPE_R, &acName1C00_01[0], 0x01, nil},
|
||||
{0x02, DTYPE_UNSIGNED8, 8, ATYPE_R, &acName1C00_02[0], 0x02, nil},
|
||||
{0x03, DTYPE_UNSIGNED8, 8, ATYPE_R, &acName1C00_03[0], 0x03, nil},
|
||||
{0x04, DTYPE_UNSIGNED8, 8, ATYPE_R, &acName1C00_04[0], 0x04, nil}
|
||||
};
|
||||
FLASHSTORE _objd SDO1C10[] =
|
||||
const _objd SDO1C10[] =
|
||||
{ {0x00, DTYPE_UNSIGNED8, 8, ATYPE_R, &acName1C10[0], 0x00, nil}
|
||||
};
|
||||
FLASHSTORE _objd SDO1C11[] =
|
||||
const _objd SDO1C11[] =
|
||||
{ {0x00, DTYPE_UNSIGNED8, 8, ATYPE_R, &acName1C11[0], 0x00, nil}
|
||||
};
|
||||
FLASHSTORE _objd SDO1C12[] =
|
||||
const _objd SDO1C12[] =
|
||||
{ {0x00, DTYPE_UNSIGNED8, 8, ATYPE_R, &acNameNOE[0], 0x01, nil},
|
||||
{0x01, DTYPE_UNSIGNED16, 16, ATYPE_R, &acNameMO[0], 0x1600, nil}
|
||||
};
|
||||
FLASHSTORE _objd SDO1C13[] =
|
||||
const _objd SDO1C13[] =
|
||||
{ {0x00, DTYPE_UNSIGNED8, 8, ATYPE_R, &acNameNOE[0], 0x01, nil},
|
||||
{0x01, DTYPE_UNSIGNED16, 16, ATYPE_R, &acNameMO[0], 0x1A00, nil}
|
||||
};
|
||||
FLASHSTORE _objd SDO6000[] =
|
||||
const _objd SDO6000[] =
|
||||
{ {0x00, DTYPE_UNSIGNED8, 8, ATYPE_R, &acNameNOE[0], 0x02, nil},
|
||||
{0x01, DTYPE_UNSIGNED8, 8, ATYPE_R, &acName6000_01[0], 0, &(Rb.button)},
|
||||
{0x02, DTYPE_UNSIGNED32, 32, ATYPE_R, &acName6000_02[0], 0, &(Rb.encoder)}
|
||||
};
|
||||
FLASHSTORE _objd SDO7000[] =
|
||||
const _objd SDO7000[] =
|
||||
{ {0x00, DTYPE_UNSIGNED8, 8, ATYPE_R, &acNameNOE[0], 0x01, nil},
|
||||
{0x01, DTYPE_UNSIGNED8, 8, ATYPE_RW, &acName7000_01[0], 0, &(Wb.LED)}
|
||||
};
|
||||
FLASHSTORE _objd SDO7100[] =
|
||||
const _objd SDO7100[] =
|
||||
{ {0x00, DTYPE_UNSIGNED8, 8, ATYPE_R, &acNameNOE[0], 0x02, nil},
|
||||
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RW, &acName7100_01[0], 0, &(encoder_scale)},
|
||||
{0x02, DTYPE_UNSIGNED32, 32, ATYPE_R, &acName7100_02[0], 0, &(encoder_scale_mirror)}
|
||||
};
|
||||
|
||||
FLASHSTORE _objd SDO8001[] =
|
||||
const _objd SDO8001[] =
|
||||
{ {0x00, DTYPE_UNSIGNED8, 8, ATYPE_R, &acNameNOE[0], 0x01, nil},
|
||||
{0x01, DTYPE_UNSIGNED32, 32, ATYPE_RW, &acName8001_01[0], 0, &(Cb.reset_counter)},
|
||||
};
|
||||
|
||||
FLASHSTORE _objectlist SDOobjects[] =
|
||||
const _objectlist SDOobjects[] =
|
||||
{ {0x1000, OTYPE_VAR, 0, 0, &acName1000[0], &SDO1000[0]},
|
||||
{0x1008, OTYPE_VAR, 0, 0, &acName1008[0], &SDO1008[0]},
|
||||
{0x1009, OTYPE_VAR, 0, 0, &acName1009[0], &SDO1009[0]},
|
|
@ -1,28 +0,0 @@
|
|||
/******************************************************************************
|
||||
* * *** ***
|
||||
* *** *** ***
|
||||
* *** **** ********** *** ***** *** **** *****
|
||||
* ********* ********** *** ********* ************ *********
|
||||
* **** *** *** *** *** **** ***
|
||||
* *** *** ****** *** *********** *** **** *****
|
||||
* *** *** ****** *** ************* *** **** *****
|
||||
* *** **** **** *** *** *** **** ***
|
||||
* *** ******* ***** ************** ************* *********
|
||||
* *** ***** *** ******* ** ** ****** *****
|
||||
* t h e r e a l t i m e t a r g e t e x p e r t s
|
||||
*
|
||||
* http://www.rt-labs.com
|
||||
* Copyright (C) 2012-2013. rt-labs AB, Sweden. All rights reserved.
|
||||
*------------------------------------------------------------------------------
|
||||
* $Id: osal.h 522 2013-06-20 16:16:45Z rtlaka $
|
||||
*------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _osal_
|
||||
#define _osal_
|
||||
|
||||
#include <kern.h>
|
||||
|
||||
#define OSAL_PRINT rprintp
|
||||
|
||||
#endif
|
|
@ -28,44 +28,28 @@
|
|||
|
||||
/** \file
|
||||
* \brief
|
||||
* The application.
|
||||
* The application.
|
||||
*
|
||||
* The application, the main loop that service EtherCAT.
|
||||
*/
|
||||
|
||||
#include <kern.h>
|
||||
#include <bsp.h>
|
||||
|
||||
#include <kern.h>
|
||||
#include <flash_drv.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <esc.h>
|
||||
#include <esc_coe.h>
|
||||
#include <esc_foe.h>
|
||||
#include "utypes.h"
|
||||
#include "esc.h"
|
||||
#include "esc_coe.h"
|
||||
#include "esc_foe.h"
|
||||
#include "osal.h"
|
||||
#include "bootstrap.h"
|
||||
|
||||
#define ESC_DEBUG
|
||||
|
||||
#ifdef ESC_DEBUG
|
||||
#define DPRINT(...) OSAL_PRINT ("soes: "__VA_ARGS__)
|
||||
#define DEBUG_ASSERT(expression) ASSERT(expression)
|
||||
#else
|
||||
#define DPRINT(...)
|
||||
#define DEBUG_ASSERT(expression)
|
||||
#endif /* DEBUG */
|
||||
|
||||
#define WD_RESET 1000
|
||||
#define DEFAULTTXPDOMAP 0x1a00
|
||||
#define DEFAULTRXPDOMAP 0x1600
|
||||
#define DEFAULTTXPDOITEMS 1
|
||||
#define DEFAULTRXPDOITEMS 1
|
||||
|
||||
#define GPIO_ECAT_RESET 1 /* specific function to hold ESC reset on startup
|
||||
* when emulating EEPROM
|
||||
*/
|
||||
|
||||
uint32 encoder_scale;
|
||||
uint32 encoder_scale_mirror;
|
||||
|
||||
|
@ -224,31 +208,6 @@ void DIG_process (void)
|
|||
}
|
||||
}
|
||||
|
||||
void esc_reset (void)
|
||||
{
|
||||
volatile int timeout;
|
||||
|
||||
DPRINT("esc_reset_started\n");
|
||||
|
||||
gpio_set (GPIO_ECAT_RESET,0); /* pin =0 */
|
||||
gpio_configure_pin (GPIO_ECAT_RESET,MUX_GPIO,IRQC_DISABLED,MODE_OUTPUT);
|
||||
|
||||
task_delay (1000);
|
||||
|
||||
gpio_configure_pin (GPIO_ECAT_RESET,MUX_GPIO,IRQC_DISABLED,MODE_INPUT);
|
||||
while(timeout<10000000)
|
||||
{
|
||||
/* ECAT releases resetpin */
|
||||
if(gpio_get (GPIO_ECAT_RESET)!=0)
|
||||
{
|
||||
break; // OK
|
||||
}
|
||||
timeout++;
|
||||
task_delay (30);
|
||||
}
|
||||
DPRINT("esc_reset_ended\n");
|
||||
}
|
||||
|
||||
/** Optional: Hook called after state change for application specific
|
||||
* actions for specific state changes.
|
||||
*/
|
||||
|
@ -286,8 +245,8 @@ void soes (void *arg)
|
|||
};
|
||||
ESC_config ((esc_cfg_t *)&config);
|
||||
|
||||
esc_reset ();
|
||||
ESC_init ((void *)spi_name);
|
||||
ESC_reset();
|
||||
ESC_init (spi_name);
|
||||
|
||||
task_delay (tick_from_ms (200));
|
||||
|
||||
|
@ -374,4 +333,3 @@ void my_cyclic_callback (void * arg)
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,33 +25,19 @@
|
|||
* The EtherCAT Technology, the trade name and logo "EtherCAT" are the intellectual
|
||||
* property of, and protected by Beckhoff Automation GmbH.
|
||||
*/
|
||||
|
||||
|
||||
/** \file
|
||||
* \brief
|
||||
* Header file for Application types.
|
||||
* Header file for Application types.
|
||||
*
|
||||
* Part of the application, host declarations of application types mapped against
|
||||
* ServiceData Objects and ProcessData Objects .
|
||||
* ServiceData Objects and ProcessData Objects.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define uint8 uint8_t
|
||||
#define int8 int8_t
|
||||
#define uint16 uint16_t
|
||||
#define int16 int16_t
|
||||
#define uint32 uint32_t
|
||||
#define int32 int32_t
|
||||
#ifndef __utypes_h__
|
||||
#define __utypes_h__
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint16 w;
|
||||
uint8 b[2];
|
||||
} uint16union;
|
||||
|
||||
#define APPSTATE_IDLE 0x00
|
||||
#define APPSTATE_INPUT 0x01
|
||||
#define APPSTATE_OUTPUT 0x02
|
||||
#include <cc.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -70,51 +56,4 @@ typedef struct
|
|||
uint32 reset_counter;
|
||||
} _Cbuffer;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8 state; // internal, don't change!!!!
|
||||
} _App;
|
||||
|
||||
extern _Rbuffer Rb;
|
||||
extern _Wbuffer Wb;
|
||||
extern _Cbuffer Cb;
|
||||
extern _App App;
|
||||
extern uint32 encoder_scale;
|
||||
extern uint32 encoder_scale_mirror;
|
||||
#define EC_LITTLE_ENDIAN
|
||||
|
||||
#if !defined(EC_BIG_ENDIAN) && defined(EC_LITTLE_ENDIAN)
|
||||
|
||||
#define htoes(A) (A)
|
||||
#define htoel(A) (A)
|
||||
#define htoell(A) (A)
|
||||
#define etohs(A) (A)
|
||||
#define etohl(A) (A)
|
||||
#define etohll(A) (A)
|
||||
|
||||
#elif !defined(EC_LITTLE_ENDIAN) && defined(EC_BIG_ENDIAN)
|
||||
|
||||
#define htoes(A) ((((uint16)(A) & 0xff00) >> 8) | \
|
||||
(((uint16)(A) & 0x00ff) << 8))
|
||||
#define htoel(A) ((((uint32)(A) & 0xff000000) >> 24) | \
|
||||
(((uint32)(A) & 0x00ff0000) >> 8) | \
|
||||
(((uint32)(A) & 0x0000ff00) << 8) | \
|
||||
(((uint32)(A) & 0x000000ff) << 24))
|
||||
#define htoell(A) ((((uint64)(A) & (uint64)0xff00000000000000ULL) >> 56) | \
|
||||
(((uint64)(A) & (uint64)0x00ff000000000000ULL) >> 40) | \
|
||||
(((uint64)(A) & (uint64)0x0000ff0000000000ULL) >> 24) | \
|
||||
(((uint64)(A) & (uint64)0x000000ff00000000ULL) >> 8) | \
|
||||
(((uint64)(A) & (uint64)0x00000000ff000000ULL) << 8) | \
|
||||
(((uint64)(A) & (uint64)0x0000000000ff0000ULL) << 24) | \
|
||||
(((uint64)(A) & (uint64)0x000000000000ff00ULL) << 40) | \
|
||||
(((uint64)(A) & (uint64)0x00000000000000ffULL) << 56))
|
||||
|
||||
#define etohs htoes
|
||||
#define etohl htoel
|
||||
#define etohll htoell
|
||||
|
||||
#else
|
||||
|
||||
#error "Must define one of EC_BIG_ENDIAN or EC_LITTLE_ENDIAN"
|
||||
|
||||
#endif
|
||||
|
|
|
@ -16,8 +16,11 @@ set(BSP $ENV{BSP} CACHE STRING
|
|||
set(DUMMY ${CMAKE_TOOLCHAIN_FILE})
|
||||
|
||||
include_directories(
|
||||
${RTK}/include/
|
||||
${RTK}/include/arch/${ARCH}
|
||||
${RTK}/include/kern
|
||||
${RTK}/include/drivers
|
||||
${RTK}/bsp/${BSP}/include
|
||||
${SOES_SOURCE_DIR}/include/sys/gcc
|
||||
)
|
||||
link_directories(
|
||||
|
|
|
@ -38,9 +38,10 @@
|
|||
* registers and memory.
|
||||
*/
|
||||
|
||||
#include <cc.h>
|
||||
#include <esc.h>
|
||||
#include <spi/spi.h>
|
||||
#include <string.h>
|
||||
#include <gpio.h>
|
||||
|
||||
#define ESC_CMD_READ 0x02
|
||||
#define ESC_CMD_READWS 0x03
|
||||
|
@ -52,6 +53,10 @@
|
|||
static int et1100 = -1;
|
||||
static uint8 read_termination[128] = { 0 };
|
||||
|
||||
#define GPIO_ECAT_RESET 1 /* specific function to hold ESC reset on startup
|
||||
* when emulating EEPROM
|
||||
*/
|
||||
|
||||
static void esc_address (uint16 address, uint8 command, uint16 * al_event)
|
||||
{
|
||||
/* Device is selected already.
|
||||
|
@ -120,9 +125,34 @@ uint8 ESC_write (uint16 address, void *buf, uint16 len, void *tALevent)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void ESC_init (void * arg)
|
||||
void ESC_reset (void)
|
||||
{
|
||||
char * spi_name = (char *)arg;
|
||||
volatile int timeout;
|
||||
|
||||
DPRINT("esc_reset_started\n");
|
||||
|
||||
gpio_set (GPIO_ECAT_RESET,0); /* pin =0 */
|
||||
gpio_configure_pin (GPIO_ECAT_RESET,MUX_GPIO,IRQC_DISABLED,MODE_OUTPUT);
|
||||
|
||||
task_delay (1000);
|
||||
|
||||
gpio_configure_pin (GPIO_ECAT_RESET,MUX_GPIO,IRQC_DISABLED,MODE_INPUT);
|
||||
while(timeout<10000000)
|
||||
{
|
||||
/* ECAT releases resetpin */
|
||||
if(gpio_get (GPIO_ECAT_RESET)!=0)
|
||||
{
|
||||
break; // OK
|
||||
}
|
||||
timeout++;
|
||||
task_delay (30);
|
||||
}
|
||||
DPRINT("esc_reset_ended\n");
|
||||
}
|
||||
|
||||
void ESC_init (const void * arg)
|
||||
{
|
||||
const char * spi_name = (char *)arg;
|
||||
et1100 = open (spi_name, O_RDWR, 0);
|
||||
read_termination[127] = 0xFF;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
message (STATUS "Building for ${CMAKE_SYSTEM_NAME}")
|
||||
|
||||
# NOTE: add headers to make them show up in an IDE
|
||||
add_library (soes
|
||||
esc.c
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#define __esc__
|
||||
|
||||
#include <cc.h>
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
|
||||
/* storage modifier for data stored in flashmemory */
|
||||
#define FLASHSTORE const
|
||||
|
@ -487,7 +487,9 @@ void ESC_state (void);
|
|||
/* From hardware file */
|
||||
uint8 ESC_read (uint16 address, void *buf, uint16 len, void *tALevent);
|
||||
uint8 ESC_write (uint16 address, void *buf, uint16 len, void *tALevent);
|
||||
void ESC_init (void * arg);
|
||||
void ESC_init (const void * arg);
|
||||
void ESC_reset (void);
|
||||
|
||||
/* From application */
|
||||
extern void APP_safeoutput ();
|
||||
|
||||
|
|
Loading…
Reference in New Issue