Anybus AB6381 User guide

Type
User guide
Anybus® CompactCom 40
HOST APPLICATION IMPLEMENTATION GUIDE
HMSI-27-334
Version 1.8
Publicaon date 2023-05-05
ENGLISH
Important User Informaon
Disclaimer
The informaon in this document is for informaonal purposes only. Please inform HMS Networks of any
inaccuracies or omissions found in this document. HMS Networks disclaims any responsibility or liability for
any errors that may appear in this document.
HMS Networks reserves the right to modify its products in line with its policy of connuous product
development. The informaon in this document shall therefore not be construed as a commitment on the
part of HMS Networks and is subject to change without noce. HMS Networks makes no commitment to
update or keep current the informaon in this document.
The data, examples and illustraons found in this document are included for illustrave purposes and
are only intended to help improve understanding of the funconality and handling of the product. In
view of the wide range of possible applicaons of the product, and because of the many variables and
requirements associated with any parcular implementaon, HMS Networks cannot assume responsibility
or liability for actual use based on the data, examples or illustraons included in this document nor for
any damages incurred during installaon of the product. Those responsible for the use of the product
must acquire sucient knowledge in order to ensure that the product is used correctly in their specic
applicaon and that the applicaon meets all performance and safety requirements including any applicable
laws, regulaons, codes and standards. Further, HMS Networks will under no circumstances assume liability
or responsibility for any problems that may arise as a result from the use of undocumented features or
funconal side eects found outside the documented scope of the product. The eects caused by any direct
or indirect use of such aspects of the product are undened and may include e.g. compability issues and
stability issues.
Copyright © 2023 HMS Networks
Contact Informaon
Postal address:
Box 4126
300 04 Halmstad, Sweden
Table of Contents
1. Preface .................................................................................................................................. 1
1.1. About this Document ........................................................................................................ 1
1.2. Related Documents ........................................................................................................... 1
1.3. Document History ............................................................................................................ 1
1.4. Document Convenons ..................................................................................................... 2
2. Introducon ........................................................................................................................... 4
2.1. Overview ........................................................................................................................ 5
2.2. Preparaons .................................................................................................................... 6
3. Step One ................................................................................................................................ 7
3.1. System Adaptaon and Applicaon Development ................................................................... 7
3.2. System Set-up .................................................................................................................. 7
3.2.1. Big- or Lile Endian ................................................................................................... 7
3.2.2. 16-bit Char System .................................................................................................... 7
3.2.3. Extended Bus Endian Dierence .................................................................................. 7
3.2.4. Data Types ............................................................................................................... 8
3.3. Anybus CompactCom Set-up ............................................................................................... 8
3.3.1. Communicaon Interfaces and Operang Modes ............................................................ 8
3.3.2. Parallel Operang Mode Specics ................................................................................ 9
3.3.3. SPI Operang Mode Specics ..................................................................................... 10
3.3.4. Module ID and Module Detect Sengs ........................................................................ 10
3.3.5. Message and Process Data Sengs ............................................................................. 11
3.3.6. Interrupt Handling ................................................................................................... 11
3.3.7. Communicaon Watchdog Sengs ............................................................................. 11
3.3.8. ADI Sengs ............................................................................................................ 11
3.3.9. Debug Event Print Sengs ......................................................................................... 12
3.3.10. Startup Time ......................................................................................................... 12
3.3.11. Sync Sengs ......................................................................................................... 13
3.4. System Adaptaon Funcons ............................................................................................. 14
3.4.1. General Funcons .................................................................................................... 14
3.4.2. SPI Operang Mode ................................................................................................. 15
3.4.3. Parallel Operang Mode ........................................................................................... 16
3.4.4. Serial Operang Mode .............................................................................................. 17
3.5. Object Conguraon ........................................................................................................ 17
3.6. Example Applicaon ........................................................................................................ 18
3.6.1. ADI and Process Data Mapping ................................................................................... 18
3.6.2. Main Loop .............................................................................................................. 18
3.6.3. Compile and Run ..................................................................................................... 20
4. Step Two ............................................................................................................................... 21
4.1. Adaptaons and Customizaons ........................................................................................ 21
4.1.1. Anybus CompactCom Setup ....................................................................................... 21
4.1.2. System Adaptaon Funcons ..................................................................................... 24
4.1.3. Network Idencaon .............................................................................................. 25
4.1.4. Soware Plaorm Porng ......................................................................................... 27
4.1.5. Example Applicaon ................................................................................................. 30
Appendix A. Soware Overview ................................................................................................... 42
1. Folders ............................................................................................................................. 42
2. Root Files ......................................................................................................................... 42
3. CompactCom Driver Interface (Read Only) .............................................................................. 42
Anybus® CompactCom 40
HMSI-27-334 Version 1.8
4. Internal Driver Files (Read Only) ............................................................................................ 43
4.1. 8/16 Bit Parallel Event Specic Files ............................................................................... 43
4.2. SPI Specic Files ......................................................................................................... 43
4.3. 8 Bit Parallel Half Duplex Specic Files ............................................................................ 43
4.4. Serial Specic Files ...................................................................................................... 44
5. System Adaptaon Files ...................................................................................................... 44
Appendix B. API ......................................................................................................................... 45
1. API Documentaon ............................................................................................................ 45
Appendix C. Host Applicaon State Machine .................................................................................. 48
Appendix D. 30- and 40-series Modules in the Same Applicaon ....................................................... 51
1. Hardware Design Consideraons .......................................................................................... 51
2. Module Idencaon ......................................................................................................... 52
3. Enable Supported Communicaon Interfaces .......................................................................... 52
4. Select Operang Mode ....................................................................................................... 53
5. Message Data Size .............................................................................................................. 54
6. Process Data Size ............................................................................................................... 54
7. Supported Data Types ......................................................................................................... 54
Anybus® CompactCom 40
HMSI-27-334 Version 1.8
1. Preface
1.1. About this Document
This document describes the host applicaon example code. It provides a guide for making a simple
implementaon and ps for further development.
For addional related documentaon and le downloads, please visit www.anybus.com/support.
1.2. Related Documents
Document Author Document ID
Anybus CompactCom 40 Soware Design Guide HMS HMSI-216-125
1.3. Document History
Version Date Descripon
1.00 2015-11-20 New document
1.10 2016-02-05 Fully revised revision
1.2 2017-01-10 Converted to DOX Major updates
1.3 2018-01-23 Added disclaimer Changed document type
1.4 2018-05-31 Updated API descripon
Added appendix on 30- and 40-series modules in the same applicaon Minor updates
1.5 2018-10-16 Minor updates to t latest soware release
1.6 2019-02-25 Rebranding
1.7 2020-03-09 Minor updates
1.8 2023-05-05 Document migrated to Paligo
Minor updates
Preface Anybus® CompactCom 40
HMSI-27-334 Version 1.8 Page 1 of 54
1.4. Document Convenons
Lists
Numbered lists indicate tasks that should be carried out in sequence:
1. First do this
2. Then do this
Bulleted lists are used for:
Tasks that can be carried out in any order
Itemized informaon
User Interacon Elements
User interacon elements (buons etc.) are indicated with bold text.
Program Code and Scripts
Program code and script examples
Cross-References and Links
Cross-reference within this document: Document Convenons (page 2)
External link (URL): www.anybus.com
Safety Symbols
DANGER
Instrucons that must be followed to avoid an imminently hazardous situaon which, if not avoided,
will result in death or serious injury.
WARNING
Instrucons that must be followed to avoid a potenal hazardous situaon that, if not avoided, could
result in death or serious injury.
CAUTION
Instrucon that must be followed to avoid a potenal hazardous situaon that, if not avoided, could
result in minor or moderate injury.
IMPORTANT
Instrucon that must be followed to avoid a risk of reduced funconality and/or damage to the
equipment, or to avoid a network security risk.
Anybus® CompactCom 40 Document Convenons
Page 2 of 54 HMSI-27-334 Version 1.8
Informaon Symbols
NOTE
Addional informaon which may facilitate installaon and/or operaon.
TIP
Helpful advice and suggesons.
Document Convenons Anybus® CompactCom 40
HMSI-27-334 Version 1.8 Page 3 of 54
2. Introducon
When starng an implementaon of the Anybus CompactCom 30 or the Anybus CompactCom 40, host
applicaon example code is available to speed up the development process. The host applicaon example
code includes a driver, which acts as glue between the Anybus CompactCom module and the host applicaon.
The driver has an API (Applicaon Programming Interface), which denes a common interface to the driver. Also
included in the example code is an example applicaon which makes use of the API to form an applicaon that
can be used as a base for the nal product.
NOTE
This guide is developed to describe a step-by-step implementaon of the Anybus CompactCom
driver and example applicaon. The programmer is requested to have basic knowledge in
the Anybus CompactCom object model and the communicaon protocol before starng the
implementaon.
This document is based on the contents of version 3.08 of the host applicaon example code.
The guide is divided into two steps:
1. The adaptaons needed for the target hardware are done here and a simple applicaon is
developed. The goal with this step is to make sure that the hardware specic code is working
and that it is possible to connect to the network and exchange a limited amount of data.
2. The code is adapted to the target product. The goal with this step is to customize the code and
add to it, to congure the data that will be sent on the network. Aer this, the applicaon can
be further extended and improved.
The driver is fully OS independent and it can even be used without an operang system, if required.
Furthermore, it can be used for Anybus CompactCom 30 modules as well as Anybus CompactCom 40 modules.
The driver supports mulple operang modes, where selecon of one of the implemented modes can be made
at runme.
It is possible to use modules from the 30- and the 40-series in the same applicaon, see
30- and 40-series Modules in the Same Applicaon, p. 51 (page 51).
The host applicaon example code is available in dierent versions for dierent plaorms. At this me, the
plaorms depicted below are available.
Each folder contains all les for a specic plaorm/development environment.
Plaorm Reference Project/Tool Chain Descripon
Generic - Can be ported to any plaorm
Xilinx, MicroZed GNU Used for the Microzed evaluaon plaorm with Anybus IP
ST, STM3240-EVAL Keil µVision Used for the STM3240-EVAL evaluaon plaorm
IAR Embedded Workbench Used for the STM3240-EVAL evaluaon plaorm
NXP, TWRP1025 Code Warrior Used for the NXP TWRP1025 evaluaon plaorm
HMS, USB II Board Visual Studio Used for the HMS Starter Kit hardware (USB board)
NUCLEO H743ZI2 ST CubeIDE Used for the NUCLEO H743ZI2 evaluaon plaorm
IAR Embedded Workbench Used for the NUCLEO H743ZI2 evaluaon plaorm
Anybus® CompactCom 40 Introducon
Page 4 of 54 HMSI-27-334 Version 1.8
2.1. Overview
Parts of the driver code need to be adapted to the host applicaon plaorm. This generally includes funcons
which access the Anybus host interface, or funcons which need to be adapted to integrate the driver into the
host system. The gure below shows the dierent parts of the host applicaon example code.
Host Applicaon Objects ADI/Process Data
CompactCom Applicaon Handler Main Loop
Example Applicaon
API
CompactCom Driver
System Adaptaon Layer
Anybus Physical Interface
Figure 1. Soware Overview
The host applicaon example code is divided into ve dierent folders depending on the funconality and
whether or not the les need to be adapted by the user.
Table 1. Folder Structure
/abcc_abp (part of the driver - read only) Contains all Anybus object and communicaon protocol denions.
Files may be updated when new Anybus CompactCom releases are
available.
These les are read only and must not be changed in any way by the
user.
/abcc_drv (part of the driver - read only) Contains source and header les for the driver. Files may be updated
when new Anybus CompactCom releases are available.
These les are read only and must not be changed in any way by the
user.
/abcc_adapt Contains conguraon les. These les must be modied by the user to
adapt the driver and the example code to the system environment.
NOTE
If using example code adjusted to a specic plaorm,
most of the adaptaons needed in this folder are
already completed.
/abcc_obj Includes all Anybus host applicaon object implementaons. These les
can be modied if needed, for opmizaon and/or addional features.
/example_app Example applicaon including:
Main state machine to handle inializaon, restart, normal and error
states.
State machine paerns to show how to send Anybus CompactCom
messages.
Implementaon of callbacks required by the driver.
Denion of ADIs, Applicaon Data Instances, and default process
data mapping setup.
These les have to be adapted to the applicaon by the programmer.
Addionally they may be modied for opmizaon and/or addional
features.
Overview Anybus® CompactCom 40
HMSI-27-334 Version 1.8 Page 5 of 54
2.2. Preparaons
Before connuing, try to answer as many of the quesons below as possible. This will make decisions during
implementaon easier. It is also good to have access to the hardware schemacs of the target hardware during
the implementaon.
Step One
Consider the following quesons:
What operang mode, or modes, shall be used in the design?
What communicaon interfaces shall be used to communicate with the CompactCom in the design?
Which networks shall be used in the design?
Are the networks available in the CompactCom 40 series or is there also a need to use CompactCom 30 series
modules?
Are the Module Idencaon pins connected to the host processor?
Are the Module Detecon pins connected to the host processor?
Step Two
Consider the following quesons:
Is the interrupt signal implemented in the hardware?
Which parameters/data shall be communicated on the network in the nal product?
– Name
Data type
Number of elements
Read/Write access
Acyclic access, Cyclic access
Max/Min/Default values
Which events (diagnoscs) shall be reported on the network?
What network idencaon parameters are available? E.g. Vendor ID, Product Code, ID number etc.
Anybus® CompactCom 40 Preparaons
Page 6 of 54 HMSI-27-334 Version 1.8
3. Step One
3.1. System Adaptaon and Applicaon Development
When this step is completed you will have...
...implemented the system specic funcons needed to communicate with the Anybus CompactCom.
...compiled the host applicaon example code with default sengs.
...exchanged data between the host applicaon and the network master/scanner.
3.2. System Set-up
These denes can be found in abcc_adapt/abcc_td.h.
General sengs for the system environment, to be used in the driver, are congured here.
3.2.1. Big- or Lile Endian
Congure if the host applicaon is a big endian system or a lile endian system. Dene
ABCC_SYS_BIG_ENDIAN if it is a big endian system. Do not dene (leave as default) if the host applicaon is a
lile endian system.
#define ABCC_SYS_BIG_ENDIAN /* Big endian host application */
/* #define ABCC_SYS_BIG_ENDIAN */ /* Little endian host application */
3.2.2. 16-bit Char System
Congure if the host applicaon is a 16-bit char system or an 8-bit char system (i.e. if the smallest addressable
type is 8-bit or 16-bit). Dene ABCC_SYS_16BIT_CHAR if it is a 16-bit char system. Do not dene (leave as
default) if it is an 8-bit char system. Conguring 16-bit char on an 8-bit char system is not recommended.
#define ABCC_SYS_16_BIT_CHAR /* 16 bit char system */
/* #define ABCC_SYS_16_BIT_CHAR */ /* 8 bit char system */
3.2.3. Extended Bus Endian Dierence
If the endianness for the external parallel data bus diers from the internal data bus endianness, enable this
dene. If parallel 16-bit operang mode is not used, this dene is ignored.
#define ABCC_CFG_PAR_EXT_BUS_ENDIAN_DIFF (FALSE)
Step One Anybus® CompactCom 40
HMSI-27-334 Version 1.8 Page 7 of 54
3.2.4. Data Types
Dene the Data Types for the current system. For 16-bit char systems, all 8-bit types shall be typed to 16-bit
types. The following data types must be dened:
BOOL Standard boolean data type.
BOOL8 Standard boolean data type, 8-bit.
INT8 Standard signed 8-bit data type.
INT16 Standard singed 16-bit data type.
INT32 Standard signed 32-bit data type.
UINT8 Standard unsigned 8-bit data type.
UINT16 Standard unsigned 16-bit data type.
UINT32 Standard unsigned 32-bit data type.
FLOAT32 Float (according to IEC 60559).
3.3. Anybus CompactCom Set-up
These denes and funcons are found in abcc_adapt/abcc_drv_cfg.h. Detailed descripons are
available in abcc_drv/inc/abcc_cfg.h.
Sengs for how to use and communicate with the Anybus CompactCom. For example, Operang mode,
interrupt handling, and memory handling, are congured here.
3.3.1. Communicaon Interfaces and Operang Modes
Dene the communicaon interfaces and the operang mode between the host applicaon and the
CompactCom (Parallel, SPI, Serial), that will be used in the implementaon. There are several possibilies to
set the operang mode depending on how the host applicaon is intended to communicate with the Anybus and
also depending on how the operang mode is selected by the user.
First, dene all communicaon interfaces that will be supported by the implementaon. All interfaces that will
be used must be dened here, otherwise an error will be reported later on. Only dene the interfaces that will
really be used, since every enabled interface will increase the compiled code size.
Only for 40-series.
#define ABCC_CFG_DRV_PARALLEL ( TRUE ) /* Parallel, 8/16-bit, event
mode */
#define ABCC_CFG_DRV_SPI ( FALSE ) /* SPI */
For both 30-series and 40-series.
#define ABCC_CFG_DRV_SERIAL ( FALSE ) /* Serial */
#define ABCC_CFG_DRV_PARALLEL_30 ( TRUE ) /* Parallel, 8-bit, half
duplex */
NOTE
ABCC_CFG_DRV_SERIAL and ABCC_CFG_DRV_PARALLEL_30 use the CompactCom half
duplex communicaon protocol, with limited data sizes for process data and message data.
Anybus® CompactCom 40 Anybus CompactCom Set-up
Page 8 of 54 HMSI-27-334 Version 1.8
Get the operang mode from external hardware - If the operang mode is set e.g. via a dipswitch connected
to the host applicaon processor or via an HMI controller, dene the ABCC_CFG_OP_MODE_GETTABLE and
implement the funcon ABCC_SYS_GetOpmode() in abcc_adapt/abcc_sys_adapt.c.
#define ABCC_CFG_OP_MODE_GETTABLE ( TRUE )
If not dened, the operang mode denes must be explicitly dened for the specic module type. (See
ABCC_CFG_ABCC_OP_MODE_30 and ABCC_CFG_ABCC_OP_MODE_40 below (page 9)).
If the operang mode pins on the CompactCom host connector can be controlled by the host processor,
dene ABCC_CFG_OP_MODE_SETTABLE and implement the funcon ABCC_SYS_SetOpmode() in
abcc_adapt/abcc_sys_adapt.c.
#define ABCC_CFG_OP_MODE_SETTABLE ( TRUE )
If not dened, it is assumed that the operang mode signals of the CompactCom host connector are xed or
controlled by external hardware, e.g. a dip-switch.
If only one operang mode per module type (CompactCom 30 and CompactCom 40) is used, dene
the operang mode with ABCC_CFG_ABCC_OP_MODE_30 and ABCC_CFG_ABCC_OP_MODE_40. The
available operang modes (ABP_OP_MODE_X) can be found in abcc_abp/abp.h.
#define ABCC_CFG_ABCC_OP_MODE_30 ABP_OP_MODE_8_BIT_PARALLEL
#define ABCC_CFG_ABCC_OP_MODE_40 ABP_OP_MODE_16_BIT_PARALLEL
If none of these denes are set, ABCC_SYS_GetOpmode() must be implemented to retrieve the operang
mode from external hardware. See ABCC_CFG_OP_MODE_GETTABLE (page 9) above.
3.3.2. Parallel Operang Mode Specics
NOTE
If parallel operang mode (8-bit or 16-bit) is not used, this secon can be ignored.
If direct access to the CompactCom memory is available (the host controller provides dedicated signals to access
external SRAM), dene ABCC_CFG_MEMORY_MAPPED_ACCESS to TRUE and dene the base address with
ABCC_CFG_PARALLEL_BASE_ADR (this address must be dened to suit the host plaorm).
#define ABCC_CFG_MEMORY_MAPPED_ACCESS ( TRUE )
#define ABCC_CFG_PARALLEL_BASE_ADR ( 0x00000000 )
If direct access to the CompactCom memory is not available, several funcons to read and write
data must be implemented in abcc_adapt/abcc_sys_adapt.c (described in abcc_drv/inc/
abcc_sys_adapt_par.h).
NOTE
The recommendaon is to have direct access to the CompactCom memory if possible for a simpler
and most oen faster implementaon.
Anybus CompactCom Set-up Anybus® CompactCom 40
HMSI-27-334 Version 1.8 Page 9 of 54
3.3.3. SPI Operang Mode Specics
NOTE
Only for 40-series. If SPI operang mode is not used, this secon can be ignored.
The length of an SPI message fragment in bytes per SPI transacon is dened with
ABCC_CFG_SPI_MSG_FRAG_LEN.
If the ABCC_CFG_SPI_MSG_FRAG_LEN value is less than the largest message to be transmied, the sending
or receiving of a message may be fragmented and take several SPI transacons to be completed. Each SPI
transacon will have a message eld of this length regardless if a message is present or not. If messages are
important the fragment length should be set to the largest message to avoid fragmentaon. If IO data are
important the message fragment length should be set to a smaller value to speed up the SPI transacon.
For high message performance a fragment length up to 1524 octets is supported. The message header is 12
octets, so 16 or 32 octets will be enough to support small messages without fragmentaon.
#define ABCC_CFG_SPI_MSG_FRAG_LEN ( 16 )
3.3.4. Module ID and Module Detect Sengs
If the Module Idencaon pins (MI) on the CompactCom host connector are not connected
to the host processor, ABCC_CFG_MODULE_ID_PINS_CONN must be dened as FALSE, and
ABCC_CFG_ABCC_MODULE_ID must be dened to the correct CompactCom module ID that corresponds to
the module ID of the used device. If dened, it shall be set to the correct ABP_MODULE_ID_X denion from
abcc_abp/abp.h.
If ABCC_CFG_MODULE_ID_PINS_CONN is dened as TRUE, the funcon
ABCC_SYS_ReadModuleId() in abcc_adapt/abcc_sys_adapt.c must be implemented.
NOTE
The recommendaon is to connect the Module ID pins on the applicaon connector directly to
GPIO-pins on the host processor and implement the ABCC_SYS_ReadModuleId() funcon.
#define ABCC_CFG_ABCC_MODULE_ID ABP_MODULE_ID_ACTIVE_ABCC40
#define ABCC_CFG_MODULE_ID_PINS_CONN ( TRUE )
If the Module Detect pins (MD) in the host applicaon connector are connected to the host processor, the
ABCC_CFG_MOD_DETECT_PINS_CONN shall be set to TRUE and the ABCC_SYS_ModuleDetect()
funcon in abcc_adapt/abcc_sys_adapt.c must be implemented.
#define ABCC_CFG_MOD_DETECT_PINS_CONN ( TRUE )
Anybus® CompactCom 40 Anybus CompactCom Set-up
Page 10 of 54 HMSI-27-334 Version 1.8
3.3.5. Message and Process Data Sengs
Leave the following denes with the default values for now.
#define ABCC_CFG_MAX_NUM_APPL_CMDS ( 2 )
#define ABCC_CFG_MAX_NUM_ABCC_CMDS ( 2 )
#define ABCC_CFG_MAX_MSG_SIZE ( 255 )
#define ABCC_CFG_MAX_PROCESS_DATA_SIZE ( 512 )
#define ABCC_CFG_REMAP_SUPPORT_ENABLED ( FALSE )
#define ABCC_CFG_CMD_SEQ_MAX_NUM_RETRIES ( 0 )
#define ABCC_CFG_MAX_NUM_CMD_SEQ ( 2 )
NOTE
The dierent plaorms can have dierent default values depending on the available resources.
3.3.6. Interrupt Handling
If the IRQ pin is connected the driver can be congured to check if an event has occurred
even if the interrupt is disabled. It can be used e.g. to detect the CompactCom power up event.
Dene ABCC_CFG_POLL_ABCC_IRQ_PIN to enable this funconality, and implement the funcon
ABCC_SYS_IsAbccInterruptActive() in abcc_adapt/abcc_sys_adapt.c.
#define ABCC_CFG_POLL_ABCC_IRQ_PIN ( TRUE )
In this step, we will not use the interrupt funconality, which means that we will dene
ABCC_CFG_INT_ENABLED as FALSE.
If the IRQ pin is not connected, this dene must be set to false.
#define ABCC_CFG_INT_ENABLED ( FALSE )
3.3.7. Communicaon Watchdog Sengs
The meout for the CompactCom communicaon watchdog is congured with ABCC_CFG_WD_TIMEOUT_MS.
If a meout occurs, the callback funcon ABCC_CbfWdTimeout() is called.
NOTE
The watchdog funconality is only supported by the SPI-, serial- and parallel30 (half duplex)
operang modes.
#define ABCC_CFG_WD_TIMEOUT_MS ( 1000 )
3.3.8. ADI Sengs
Leave the following denes with the default values for now.
#define ABCC_CFG_STRUCT_DATA_TYPE ( FALSE )
#define ABCC_CFG_ADI_GET_SET_CALLBACK ( FALSE )
#define ABCC_CFG_64BIT_ADI_SUPPORT ( FALSE )
Anybus CompactCom Set-up Anybus® CompactCom 40
HMSI-27-334 Version 1.8 Page 11 of 54
3.3.9. Debug Event Print Sengs
For development purposes, a number of debug funcons are available for the developer. The following denes
aects debug printouts from the driver. If addional printouts are needed from the applicaon code, use the
ported funcon ABCC_PORT_DebugPrint() in abcc_adapt/abcc_sw_port.h.
Enable or disable the error reporng callback funcon ABCC_CbfDriverError() with
ABCC_CFG_ERR_REPORTING_ENABLED. The funcon is described in abcc_drv/inc/abcc.h.
#define ABCC_CFG_ERR_REPORTING_ENABLED ( TRUE )
Enable or disable driver support for print out of debug events within the driver
with ABCC_CFG_DEBUG_EVENT_ENABLED. ABCC_PORT_DebugPrint() in abcc_adapt/
abcc_sw_port.h will be used to print debug informaon.
#define ABCC_CFG_DEBUG_EVENT_ENABLED ( TRUE )
Enable or disable printout of debug informaon, such as le name and line number, when
ABCC_CbfDriverError() is called with ABCC_CFG_DEBUG_ERR_ENABLED.
#define ABCC_CFG_DEBUG_ERR_ENABLED ( FALSE )
Enable or disable printout of received and sent messages with ABCC_CFG_DEBUG_MESSAGING. Related
events such as buer allocaon and queuing informaon is also printed.
#define ABCC_CFG_DEBUG_MESSAGING ( FALSE )
Enable or disable printout of command sequencer acons with ABCC_CFG_DEBUG_CMD_SEQ_ENABLED.
#define ABCC_CFG_DEBUG_CMD_SEQ_ENABLED ( FALSE )
3.3.10. Startup Time
If the CompactCom IRQ pin is connected, ABCC_CFG_STARTUP_TIME_MS will be used as
a meout while waing for the CompactCom to become ready for communicaon. An error
(APPL_MODULE_NOT_ANSWERING) will be reported if the start-up interrupt is not received within this me. If
the interrupt pin is not available ABCC_CFG_STARTUP_TIME_MS will serve as me to wait before starng to
communicate with the CompactCom. If not dened, the default value is 1500 ms.
#define ABCC_CFG_STARTUP_TIME_MS ( 1500 )
NOTE
If possible, the recommendaon is to use the startup interrupt (opon available for the SPI and
parallel communicaon interfaces).
Anybus® CompactCom 40 Anybus CompactCom Set-up
Page 12 of 54 HMSI-27-334 Version 1.8
3.3.11. Sync Sengs
NOTE
Only for 40-series.
Leave the following denes with the default values for now.
#define ABCC_CFG_SYNC_ENABLE ( FALSE )
#define ABCC_CFG_SYNC_MEASUREMENT_IP ( FALSE )
#define ABCC_CFG_SYNC_MEASUREMENT_OP ( FALSE )
Anybus CompactCom Set-up Anybus® CompactCom 40
HMSI-27-334 Version 1.8 Page 13 of 54
3.4. System Adaptaon Funcons
A number of funcons must be implemented for the driver to be able to access the Anybus CompactCom.
The funcons shall be implemented in abcc_adapt/abcc_sys_adapt.c. The funcons are described per
operang mode in the les specied below.
General funcons: abcc_drv/inc/abcc_sys_adapt.h
SPI operang mode: abcc_drv/inc/abcc_sys_adapt_spi.h
Parallel operang mode: abcc_drv/inc/abcc_sys_adapt_par.h
Serial operang mode: abcc_drv/inc/abcc_sys_adapt_ser.h
3.4.1. General Funcons
These funcons can be found in abcc_drv/inc/abcc_sys_adapt.h.
ABCC_SYS_HwInit()
This funcon can be used to iniate the hardware required to communicate with the CompactCom device (e.g.
conguring the direcon and inial values of used host processor port pins). This funcon shall be called once
during the power up inializaon.
NOTE
Make sure that the CompactCom is kept in reset state when returning from this funcon.
ABCC_SYS_Init()
This funcon is called by the driver at start-up and restart of the driver. If needed, any hardware or system
dependent inializaon shall be done here. If not used, leave the funcon empty.
ABCC_SYS_Close()
Called from the driver if the driver is terminated. If resources were allocated in ABCC_SYS_Init() it is
recommended to close or free them in this funcon. If not used, leave the funcon empty.
ABCC_SYS_HWReset()
This funcon must be implemented to pull the reset pin on the Anybus CompactCom interface to low.
ABCC_SYS_HWReleaseReset()
This funcon must be implemented to set the reset pin on the Anybus CompactCom interface to high.
ABCC_SYS_AbccInterruptEnable()
For now, interrupt will be disabled. Leave this funcon empty.
ABCC_SYS_AbccInterruptDisable()
For now, interrupt will be disabled. Leave this funcon empty.
ABCC_SYS_IsAbccInterruptActive()
If the interrupt pin (IRQ) is connected to the host processor, this funcon shall read the interrupt signal from
the CompactCom and return TRUE if the interrupt pin is low (i.e. interrupt is acve) and return FALSE if
the interrupt pin is high (i.e. the interrupt is inacve). It is used to enable polling of the interrupt pin of the
CompactCom interface if interrupts are not enabled.
ABCC_SYS_SyncInterruptEnable()
For now, synchronizaon will be disabled. Leave this funcon empty.
ABCC_SYS_SyncInterruptDisable()
For now, synchronizaon will be disabled. Leave this funcon empty.
Anybus® CompactCom 40 System Adaptaon Funcons
Page 14 of 54 HMSI-27-334 Version 1.8
3.4.2. SPI Operang Mode
NOTE
Only for 40-series. If SPI operang mode is not used, the funcons below are never called, and this
secon can be ignored.
These funcons can be found in abcc_drv/inc/abcc_sys_adapt_spi.h.
ABCC_SYS_SpiRegDataReceived(ABCC_SYS_SpiDataReceivedCbfType pnDataReceived)
Registers the callback funcon that shall be called when new data is received (MISO frame received).
Example 1.
static ABCC_SYS_SpiDataReceivedCbfType pnDataReadyCbf;
void ABCC_SYS_SpiRegDataReceived(
ABCC_SYS_SpiDataReceivedCbfType pnDataReceived
)
{
pnDataReadyCbf = pnDataReceived;
}
ABCC_SYS_SpiSendReceive(void* pxSendDataBuffer, void* pxReceiveDataBuffer,
UINT16 iLength)
Handles sending and receiving of data in SPI mode.
Two buers are provided, one with a MOSI data frame to be sent and one buer to store the received MISO
frame.
System Adaptaon Funcons Anybus® CompactCom 40
HMSI-27-334 Version 1.8 Page 15 of 54
3.4.3. Parallel Operang Mode
These funcons can be found in abcc_drv/inc/abcc_sys_adapt_par.h.
NOTE
If parallel operang mode is not used, the funcons below are never called, and this secon can be
ignored.
NOTE
If parallel operang mode is used and ABCC_CFG_MEMORY_MAPPED_ACCESS is dened, this
secon can be ignored. See Parallel Operang Mode Specics (page 9) for more informaon about
ABCC_CFG_MEMORY_MAPPED_ACCESS.
ABCC_SYS_ParallelRead()
Reads an amount of octets from the CompactCom memory.
ABCC_SYS_ParallelRead8()
Only used for half duplex parallel operang mode.
Reads an octet from the CompactCom memory.
ABCC_SYS_ParallelRead16()
Reads a word from the CompactCom memory.
ABCC_SYS_ParallelWrite()
Writes an amount of octets to the CompactCom memory.
ABCC_SYS_ParallelWrite8()
Only used for half duplex parallel operang mode.
Writes an octet to the CompactCom memory.
ABCC_SYS_ParallelWrite16()
Writes a word to the CompactCom memory.
ABCC_SYS_ParallelGetRdPdBuffer()
Get the address to the received read process data.
ABCC_SYS_ParallelGetWrPdBuffer()
Get the address to store the write process data.
Anybus® CompactCom 40 System Adaptaon Funcons
Page 16 of 54 HMSI-27-334 Version 1.8
  • Page 1 1
  • Page 2 2
  • Page 3 3
  • Page 4 4
  • Page 5 5
  • Page 6 6
  • Page 7 7
  • Page 8 8
  • Page 9 9
  • Page 10 10
  • Page 11 11
  • Page 12 12
  • Page 13 13
  • Page 14 14
  • Page 15 15
  • Page 16 16
  • Page 17 17
  • Page 18 18
  • Page 19 19
  • Page 20 20
  • Page 21 21
  • Page 22 22
  • Page 23 23
  • Page 24 24
  • Page 25 25
  • Page 26 26
  • Page 27 27
  • Page 28 28
  • Page 29 29
  • Page 30 30
  • Page 31 31
  • Page 32 32
  • Page 33 33
  • Page 34 34
  • Page 35 35
  • Page 36 36
  • Page 37 37
  • Page 38 38
  • Page 39 39
  • Page 40 40
  • Page 41 41
  • Page 42 42
  • Page 43 43
  • Page 44 44
  • Page 45 45
  • Page 46 46
  • Page 47 47
  • Page 48 48
  • Page 49 49
  • Page 50 50
  • Page 51 51
  • Page 52 52
  • Page 53 53
  • Page 54 54
  • Page 55 55
  • Page 56 56
  • Page 57 57
  • Page 58 58

Anybus AB6381 User guide

Type
User guide

Ask a question and I''ll find the answer in the document

Finding information in a document is now easier with AI