/*******************************************************************************
********************************************************************************
** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB                 **
**                                                                            **
** This code is the property of HMS Industrial Networks AB.                   **
** The source code may not be reproduced, distributed, or used without        **
** permission. When used together with a product from HMS, permission is      **
** granted to modify, reproduce and distribute the code in binary form        **
** without any restrictions.                                                  **
**                                                                            **
** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT    **
** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR     **
** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR     **
** THAT DEFECTS IN IT CAN BE CORRECTED.                                       **
********************************************************************************
********************************************************************************
** File Description: Configuration parameters for the application driver.
**
********************************************************************************
********************************************************************************
** Services:
********************************************************************************
********************************************************************************
*/
#ifndef ABCC_USER_DEF_H_
#define ABCC_USER_DEF_H_

#include <stdio.h>
#include "abcc_td.h"
#include "abp.h"

/*******************************************************************************
** The following user defines are used to control and configure the driver.
** These defines are to be specified by the user. They are not defined anywhere
** in the driver and must be added globally by the user.
********************************************************************************
** #define ABCC_USER_DRV_SPI
**    Define if SPI driver shall be used
**
** #define ABCC_USER_DRV_PARALLEL:
**    Define if parallel event driver shall be used.
**    Used for both 8 and 16 bit mode.
**
** #define ABCC_USER_DRV_PARALLEL_30:
**    Define if parallel ping-pong shall be used
*
** #define ABCC_USER_DRV_SERIAL
**    Define if serial ping/pong shall be used
**
** #define ABCC_USER_INT_ENABLED
**    Define if ABCC interrupt (IRQ_N pin) shall be used.
**
** #define ABCC_USER_STARTUP_TIME_MS           ( 1500 )
**    Time to wait before starting to communicate with ABCC. Only valid
**    if fast startup is not used.
**    If not defined in abcc_user_def.h default will be 1500 ms
**
** #define ABCC_USER_REMAP_SUPPORT_ENABLED
**    Define if remap command shall be supported. If defined ABCC_CbfRemapDone() need to be
**    implemented by the application.
**
** #define ABCC_USER_MAX_NUM_APPL_CMDS     ( 2 )
**    Number of commands that could be sent without receiving a response.
**
** #define ABCC_USER_MAX_NUM_ABCC_CMDS     ( 2 )
**    Number of commands that could be received without sending a response.
**
** #define ABCC_USER_MAX_NUM_MSG_RESOURCES          ( 5 )
**    Total number of message resources.
**    If not defined in abcc_user_def.h a default value will be used.
**    The default value is ( ABCC_USER_MAX_NUM_APPL_CMDS + ABCC_USER_MAX_NUM_ABCC_CMDS  )
**
** #define ABCC_USER_MAX_MSG_SIZE                       ( 255 )
**   Size of largest message that will be used  ( in bytes )
**   Note! ABCC30 supports 255 byte messages and ABCC40 supports 1524 byte
**   messages. ABCC_USER_MAX_MSG_SIZE should be set to largest size that will be
**   sent or received. If this size is not known it recommended to set the
**   maximum supported size.
**
** #define ABCC_USER_MAX_PROCESS_DATA_SIZE              ( 512 )
**    Size of max process data that will be used in either direction
**    ( in bytes ).
**
** #define ABCC_USER_MEMORY_MAPPED_ACCESS
**    Define if the ABCC interface is memory mapped.
**    This define will enable the direct memory access macros
**    in sys_adapt_par.h
**
** #define ABCC_USER_PARALLEL_BASE_ADR             ( 0x00000000 )
**    Define the base address of the ABCC if a memory mapped interface is used.
**
** #define ABCC_USER_POLL_WRPD
**    If defined, WRPD will be updated ( ABCC_CbfUpdateWriteProcessData() )  each time
**    ABCC_RunDriver() is called. If not defined the function  ABCC_NewWrPdEvent()
**    must be called by the user to trigger a WrPd update.
**
** #define ABCC_USER_INT_ENABLE_MASK                           ( ABP_INTMASK_RDPDIEN )
**    Defines what ABCC interrupts shall be enabled ( See ABP_INTMASK_X in abp.h )
***   If not defined in abcc_user_def.h the default mask is 0.
**
** #define ABCC_USER_HANDLE_IN_ABCC_ISR_MASK              ( ABCC_USER_INT_ENABLE_MASK )
**    Defines what events should be handled in interrupt context. If not handled in interrupt,
**    it must be polled using ABCC_RunDriver().
**    If not defined in abcc_user_def.h the default value will be:
**    Parallel 16/8: ABCC_USER_INT_ENABLE_MASK
**    Other operation modes N/A
**
** #define ABCC_USER_WD_TIMEOUT_MS                      ( 1000 )
**    Timeout for ping/pong watchdog.
**
** #define ABCC_USER_SPI_MSG_FRAG_LEN                   ( 32 )
**    Length of SPI message fragment in each transaction (in bytes)
**    If shorter than the largest message the sending or receiving of a message
**    may take several SPI transactions. Each SPI transaction will have a message
**    field of this length regardless if a message is present or not.
**    If messages are important the the fragment length should be set to the largest
**    message to avoid fragmentation. If IO data are important the message fragment
**    length could be set to a smaller value.
**
** #define ABCC_USER_ERR_REPORTING_ENABLED
**    Enable the error reporting callback function. ( ABCC_CbfDriverError() )
**
** #define ABCC_USER_DEBUG_PRINT(...)
**    Macro is used by driver for debug prints such as events or error debug
**    information. If not defined the driver will be silent.
**    Note! The compiler need to be C99 complient to support VA_ARGS in
**    in macro.
**
** #define ABCC_USER_64BIT_ADI_SUPPORT
**    Define if 64 ADI shall be supported
**
** #define ABCC_USER_DEBUG_EVENT_ENABLED
**    Enable print out of debug events.
**
** #define ABCC_USER_DEBUG_ERR_ENABLED
**    Enable printout of debug information when ABCC_CbfDriverError() is called
**    such is file and line number.
**
** #define ABCC_USER_BIG_ENDIAN
**   Define if big endian host is used. If not defined little endian is assumed.
**------------------------------------------------------------------------------
*/

#define ABCC_USER_DRV_SPI

/*******************************************************************************
** Operation mode independent defines
********************************************************************************
*/

#define ABCC_USER_MAX_NUM_APPL_CMDS     ( 2 )
#define ABCC_USER_MAX_NUM_ABCC_CMDS     ( 2 )
#define ABCC_USER_MAX_MSG_SIZE                       ( 255 )
#define ABCC_USER_MAX_PROCESS_DATA_SIZE              ( 512 )
#define ABCC_USER_REMAP_SUPPORT_ENABLED
#define ABCC_USER_ERR_REPORTING_ENABLED
#define ABCC_USER_DEBUG_EVENT_ENABLED
#define ABCC_USER_DEBUG_ERR_ENABLED
#define ABCC_USER_DEBUG_PRINT( args )                 printf("\n");printf args
#define ABCC_USER_POLL_WRPD

/*******************************************************************************
** Spi specific defines
********************************************************************************
*/
#ifdef ABCC_USER_DRV_SPI

#define ABCC_USER_INT_ENABLED
#define ABCC_USER_INT_ENABLE_MASK                    ( ABP_INTMASK_RDPDIEN | ABP_INTMASK_STATUSIEN | ABP_INTMASK_RDMSGIEN | ABP_INTMASK_WRMSGIEN | ABP_INTMASK_ANBRIEN  )
#define ABCC_USER_SPI_MSG_FRAG_LEN                   ( 32 )
#define ABCC_USER_WD_TIMEOUT_MS                      ( 1000 )
#endif

#endif  /* inclusion lock */

/*******************************************************************************
** End of abcc_user_def.h
********************************************************************************
*/
