William Kane / Generic

Dependents:   LaserioLib

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers abcc.h Source File

abcc.h

00001 /*******************************************************************************
00002 ********************************************************************************
00003 **                                                                            **
00004 ** ABCC Driver version 4.01.01 (2015-12-14)                                   **
00005 **                                                                            **
00006 ** Delivered with:                                                            **
00007 **    ABP         7.16.01 (2015-10-14)                                        **
00008 **                                                                            */
00009 /*******************************************************************************
00010 ********************************************************************************
00011 ** COPYRIGHT NOTIFICATION (c) 2013 HMS Industrial Networks AB                 **
00012 **                                                                            **
00013 ** This code is the property of HMS Industrial Networks AB.                   **
00014 ** The source code may not be reproduced, distributed, or used without        **
00015 ** permission. When used together with a product from HMS, permission is      **
00016 ** granted to modify, reproduce and distribute the code in binary form        **
00017 ** without any restrictions.                                                  **
00018 **                                                                            **
00019 ** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT    **
00020 ** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR     **
00021 ** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR     **
00022 ** THAT DEFECTS IN IT CAN BE CORRECTED.                                       **
00023 ********************************************************************************
00024 ********************************************************************************
00025 ** File Description:
00026 ** ABCC driver API used by the the application.
00027 ********************************************************************************
00028 ********************************************************************************
00029 ** Services provided by ABCC driver:
00030 **    ABCC_StartDriver()                  - Make the driver ready for use.
00031 **    ABCC_isReadyForCommunication()      - Check if the driver is ready to
00032 **                                          communicate.
00033 **    ABCC_ShutdownDriver()               - Close the driver.
00034 **    ABCC_HWReset                        - Reset ABCC.
00035 **    ABCC_HWReleaseReset                 - Release the reset on ABCC.
00036 **    ABCC_RunTimerSystem()               - Timer information to ABCC.
00037 **    ABCC_RunDriver()                    - Main routine to be called cyclically
00038 **                                          during polling.
00039 **    ABCC_UserInitComplete()             - End of user specific setup sequence.
00040 **    ABCC_SendCmdMsg()                   - Sends a message command to ABCC.
00041 **    ABCC_SendRespMsg()                  - Sends a message response to ABCC.
00042 **    ABCC_SendRemapRespMsg()             - Send remap response message
00043 **    ABCC_SetAppStatus()                 - Sets the application status.
00044 **    ABCC_GetCmdMsgBuffer()              - Allocates the command message buffer.
00045 **    ABCC_ReturnMsgBuffer()              - Frees the message buffer.
00046 **    ABCC_TakeMsgBufferOwnership()       - Takes the ownership of the message buffer.
00047 **    ABCC_ISR()                          - ABCC interrupt service routine.
00048 **    ABCC_TriggerRdPdUpdate()            - Triggers the RdPd read.
00049 **    ABCC_TriggerReceiveMessage()        - Triggers the message read.
00050 **    ABCC_TriggerWrPdUpdate()            - Triggers the WrPd update.
00051 **    ABCC_TriggerAnbStatusUpdate()       - Check for Anybus status change
00052 **    ABCC_TriggerTransmitMessage()       - Check sending queue
00053 **    ABCC_ModCap()                       - Reads the module capability.
00054 **    ABCC_LedStatus()                    - Reads the led status.
00055 **    ABCC_AnbState()                     - Reads the Anybus state.
00056 **    ABCC_NetworkType()                  - Get network type.
00057 **    ABCC_ModuleType()                   - Get module type.
00058 **    ABCC_DataFormatType()               - Get network endian.
00059 **    ABCC_ParameterSupport()             - Get parameter support.
00060 **    ABCC_GetOpmode()                    - Get operating mode.
00061 **    ABCC_GetAttribute()                 - Fills "Get Attribute" message
00062 **    ABCC_SetByteAttribute()             - Fills "Set Attribute" message
00063 **    ABCC_VerifyMessage()                - Checks if E-bit is set
00064 **    ABCC_GetDataTypeSize()              - Returns size of ABCC data type
00065 **
00066 ** Services to be implemented by user:
00067 ** ABCC_CbfReceiveMsg()                - Delivery of the received message.
00068 ** ABCC_CbfAdiMappingReq()             - Request of the ADI mapping information.
00069 ** ABCC_CbfUserInitReq()               - User specific setup made by the application.
00070 ** ABCC_CbfUpdateWriteProcessData()    - Request of the latest write process data.
00071 ** ABCC_CbfNewReadPd()                 - Delivery of the latest read process data.
00072 ** ABCC_CbfWdTimeout()                 - Communication lost.
00073 ** ABCC_CbfWdTimeoutRecovered()        - Communication restored.
00074 ** ABCC_CbfEvent()                     - Events received. Called from ISR.
00075 ** ABCC_CbfRemapDone()                 - Acknowledge of remap has been sent.
00076 ** ABCC_CbfAnbStateChanged()           - The anybus state has changed.
00077 ** ABCC_CbfSyncIsr()                   - Callback for sync event.
00078 ********************************************************************************
00079 ********************************************************************************
00080 */
00081 #ifndef ABCC_H_
00082 #define ABCC_H_
00083 
00084 #include "abcc_drv_cfg.h"
00085 #include "abcc_port.h"
00086 #include "abcc_td.h"
00087 #include "abp.h"
00088 #include "abcc_ad_if.h"
00089 
00090 /*******************************************************************************
00091 ** Constants
00092 ********************************************************************************
00093 */
00094 
00095 /*------------------------------------------------------------------------------
00096 ** Bit definitions of ABCC events.
00097 ** These bit definitions are used in the bit mask forwarded to the
00098 ** ABCC_CbfEvent() callback.
00099 **------------------------------------------------------------------------------
00100 */
00101 #define ABCC_ISR_EVENT_RDPD       0x01
00102 #define ABCC_ISR_EVENT_RDMSG      0x02
00103 #define ABCC_ISR_EVENT_WRMSG      0x04
00104 #define ABCC_ISR_EVENT_STATUS     0x08
00105 
00106 /*******************************************************************************
00107 ** Typedefs
00108 ********************************************************************************
00109 */
00110 
00111 /*------------------------------------------------------------------------------
00112 ** Function types used by user to deliver messages to the application.
00113 **------------------------------------------------------------------------------
00114 */
00115 typedef void (*ABCC_MsgHandlerFuncType)( ABP_MsgType* psMsg );
00116 
00117 /*------------------------------------------------------------------------------
00118 ** Data format type.
00119 **------------------------------------------------------------------------------
00120 */
00121 typedef enum ABCC_DataFormatType
00122 {
00123    ABCC_DF_LSB_FIRST = 0,
00124    ABCC_DF_MSB_FIRST = 1
00125 }
00126 ABCC_DataFormatType;
00127 
00128 /*------------------------------------------------------------------------------
00129 ** Driver severity codes indicated by ABCC_CbfDriverError.
00130 **------------------------------------------------------------------------------
00131 */
00132 typedef enum ABCC_SeverityType
00133 {
00134    /*
00135    ** Information about an event that has occurred (e.g., serial message lost).
00136    */
00137    ABCC_SEV_INFORMATION = 0,
00138 
00139    /*
00140    ** An error of minor importance has occurred. The system can recover from
00141    ** this error.
00142    */
00143    ABCC_SEV_WARNING,
00144 
00145    /*
00146    ** A fatal event has occurred, the system cannot recover (e.g., driver is
00147    ** out of timers).
00148    */
00149    ABCC_SEV_FATAL,
00150 
00151    /*
00152    ** Force the compiler to use a 16-bit variable as enumeration.
00153    */
00154    ABCC_SEV_SET_ENUM_ANSI_SIZE = 0x7FFF
00155 
00156 }
00157 ABCC_SeverityType;
00158 
00159 /*------------------------------------------------------------------------------
00160 **  Driver error codes indicated by ABCC_CbfDriverError.
00161 **------------------------------------------------------------------------------
00162 */
00163 typedef enum ABCC_ErrorCodeType
00164 {
00165    ABCC_EC_NO_ERROR,
00166    ABCC_EC_INTERNAL_ERROR,
00167    ABCC_EC_LINK_CMD_QUEUE_FULL,
00168    ABCC_EC_LINK_RESP_QUEUE_FULL,
00169    ABCC_EC_OUT_OF_MSG_BUFFERS,
00170    ABCC_EC_TRYING_TO_FREE_NULL_POINTER,
00171    ABCC_EC_INCORRECT_OPERATING_MODE,
00172    ABCC_EC_INCORRECT_STATE,
00173    ABCC_EC_RESP_MSG_E_BIT_SET,
00174    ABCC_EC_WRPD_SIZE_ERR,
00175    ABCC_EC_RDPD_SIZE_ERR,
00176    ABCC_EC_RDMSG_SIZE_ERR,
00177    ABCC_EC_INVALID_RESP_SOURCE_ID,
00178    ABCC_EC_MODULE_NOT_DECTECTED,
00179    ABCC_EC_PARAMETER_NOT_VALID,
00180    ABCC_EC_MODULE_ID_NOT_SUPPORTED,
00181    ABCC_EC_DEFAULT_MAP_ERR,
00182    ABCC_EC_ERROR_IN_READ_MAP_CONFIG,
00183    ABCC_EC_ERROR_IN_WRITE_MAP_CONFIG,
00184    ABCC_EC_INTSTATUS_NOT_SUPPORTED_BY_DRV_IMPL,
00185    ABCC_EC_MODCAP_NOT_SUPPORTED_BY_DRV_IMPL,
00186    ABCC_EC_SPI_OP_NOT_ALLOWED_DURING_SPI_TRANSACTION,
00187    ABCC_EC_WRMSG_SIZE_ERR,
00188    ABCC_EC_MSG_BUFFER_CORRUPTED,
00189    ABCC_EC_MSG_BUFFER_ALREADY_FREED,
00190    ABCC_EC_NO_RESOURCES,
00191    ABCC_EC_HW_INIT_FAILED,
00192    ABCC_EC_SET_ENUM_ANSI_SIZE       = 0x7FFF
00193 }
00194 ABCC_ErrorCodeType;
00195 
00196 /*------------------------------------------------------------------------------
00197 ** ABCC_CommunicationStateType:
00198 **
00199 ** ABCC_NOT_READY_FOR_COMMUNICATION: Nothing is wrong but it
00200 **                                   is not yet possible to
00201 **                                   communicate with the ABCC.
00202 ** ABCC_READY_FOR_COMMUNICATION:     Possible to communicate with ABCC
00203 ** ABCC_COMMUNICATION_ERROR:         ABCC module is not responding
00204 **
00205 **------------------------------------------------------------------------------
00206 */
00207 typedef enum ABCC_CommunicationState
00208 {
00209    ABCC_NOT_READY_FOR_COMMUNICATION = 0,
00210    ABCC_READY_FOR_COMMUNICATION = 1,
00211    ABCC_COMMUNICATION_ERROR = 2
00212 }
00213 ABCC_CommunicationStateType;
00214 
00215 
00216 /*------------------------------------------------------------------------------
00217 ** Used for storing the data format of the field bus.
00218 ** NET_UNKNOWN means that the Anybus-CC has not yet responded to our command to
00219 ** read the fieldbus data format.
00220 **------------------------------------------------------------------------------
00221 */
00222 typedef enum NetFormatType
00223 {
00224    NET_LITTLEENDIAN,
00225    NET_BIGENDIAN,
00226    NET_UNKNOWN
00227 }
00228 NetFormatType;
00229 
00230 /*------------------------------------------------------------------------------
00231 ** Type for indicate if parameter support is available or not.
00232 **------------------------------------------------------------------------------
00233 */
00234 typedef enum ParameterSupportType
00235 {
00236    NOT_PARAMETER_SUPPORT,
00237    PARAMETER_SUPPORT,
00238    PARAMETER_UNKNOWN
00239 }
00240 ParameterSupportType;
00241 
00242 /*******************************************************************************
00243 ** Public Globals
00244 ********************************************************************************
00245 */
00246 
00247 /*------------------------------------------------------------------------------
00248 ** Macros for basic endian swap. Used by conversion macros below.
00249 **------------------------------------------------------------------------------
00250 */
00251 #ifndef ABCC_iEndianSwap
00252 #define ABCC_iEndianSwap( iFoo )    (UINT16)( ( (UINT16)(iFoo) >> 8 ) | ( (UINT16)(iFoo) << 8 ) )
00253 #endif
00254 
00255 #ifndef ABCC_lEndianSwap
00256 #define ABCC_lEndianSwap( lFoo )      (UINT32)( ( (UINT32)ABCC_iEndianSwap( (UINT16)( (UINT32)(lFoo) ) ) << 16 ) | (UINT32)ABCC_iEndianSwap( (UINT32)(lFoo) >> 16 ) )
00257 #endif
00258 
00259 #if( ABCC_CFG_64BIT_ADI_SUPPORT )
00260 #ifndef ABCC_l64EndianSwap
00261 #define ABCC_l64EndianSwap( lFoo )  (UINT64)( ( (UINT64)ABCC_lEndianSwap( (UINT32)( (UINT64)(lFoo) ) ) << 32 ) | (UINT64)ABCC_lEndianSwap( (UINT64)(lFoo) >> 32 ) )
00262 #endif
00263 #endif
00264 
00265 /*------------------------------------------------------------------------------
00266 ** Macros for reading/writing byte to/from a 16 bit word.
00267 **------------------------------------------------------------------------------
00268 */
00269 #ifndef ABCC_iSetLSB
00270 #define ABCC_iSetLSB( iDest, iSrc )                               \
00271 do                                                                \
00272 {                                                                 \
00273    (iDest) &= (UINT16)0xFF00;                                     \
00274    (iDest) |= (UINT16)( iSrc ) & (UINT16)0x00FF;                  \
00275 }                                                                 \
00276 while( 0 )
00277 #endif
00278 
00279 #ifndef ABCC_iSetMSB
00280 #define ABCC_iSetMSB( iDest, iSrc )                               \
00281 do                                                                \
00282 {                                                                 \
00283    (iDest) &=  (UINT16)0x00FF;                                    \
00284    (iDest) |=  (UINT16)(iSrc) << 8;                               \
00285 }                                                                 \
00286 while( 0 )
00287 #endif
00288 
00289 #ifndef ABCC_iLSB
00290 #define ABCC_iLSB( iFoo )           (UINT16)( (iFoo) & 0x00FF)
00291 #endif
00292 
00293 #ifndef ABCC_iMSB
00294 #define ABCC_iMSB( iFoo )           (UINT16)( (UINT16)(iFoo) >> 8 )
00295 #endif
00296 
00297 /*------------------------------------------------------------------------------
00298 ** Endian dependent macros:
00299 **------------------------------------------------------------------------------
00300 ** Macros to convert to/from native endian to/from specified endian:
00301 **
00302 ** iBeTOi( iBeFoo )   - 16 bit big endian    -> native endian
00303 ** iTOiBe( iFoo )     - 16 bit native endian -> big endian
00304 ** iLeTOi( iLeFoo )   - 16 bit little endian -> native endian
00305 ** iTOiLe( iFoo )     - 16 bit native endian -> little endian
00306 **                    -
00307 ** lBeTOl( lBeFoo )   - 32 bit big endian    -> native endian
00308 ** lTOlBe( lFoo )     - 32 bit native endian -> big endian
00309 ** lLeTOl( lLeFoo )   - 32 bit little endian -> native endian
00310 ** lTOlLe( lFoo )     - 32 bit native endian -> little endian
00311 **                    -
00312 ** lBeTOl64( lBeFoo ) - 64 bit big endian    -> native endian
00313 ** lTOlBe64( lFoo )   - 64 bit native endian -> big endian
00314 ** lLeTOl64( lLeFoo ) - 64 bit little endian -> native endian
00315 ** lTOlLe64( lFoo )   - 64 bit native endian -> little endian
00316 **------------------------------------------------------------------------------
00317 ** Macros to set/get low/high address octet from a word:
00318 **
00319 ** ABCC_GetLowAddrOct( iFoo )
00320 ** ABCC_GetHighAddrOct( iFoo )
00321 ** ABCC_SetLowAddrOct( iDest, iSrc )
00322 ** ABCC_SetHighAddrOct( iDest, iSrc )
00323 **------------------------------------------------------------------------------
00324 */
00325 #ifdef ABCC_SYS_BIG_ENDIAN
00326 
00327    #define iBeTOi( iBeFoo )                     (UINT16)(iBeFoo)
00328    #define iTOiBe( iFoo )                       (UINT16)(iFoo)
00329    #define iLeTOi( iLeFoo )                     ABCC_iEndianSwap( iLeFoo )
00330    #define iTOiLe( iFoo )                       ABCC_iEndianSwap( iFoo )
00331 
00332    #define lBeTOl( lBeFoo )                     (UINT32)( lBeFoo )
00333    #define lTOlBe( lFoo )                       (UINT32)( lFoo )
00334    #define lLeTOl( lLeFoo )                     ABCC_lEndianSwap( lLeFoo )
00335    #define lTOlLe( lFoo )                       ABCC_lEndianSwap( lFoo )
00336 
00337 
00338    #define ABCC_GetLowAddrOct( iFoo )           ABCC_iMSB( iFoo )
00339    #define ABCC_GetHighAddrOct( iFoo )          ABCC_iLSB( iFoo )
00340 
00341    #define ABCC_SetLowAddrOct( iDest, iSrc )    ABCC_iSetMSB( iDest, iSrc )
00342    #define ABCC_SetHighAddrOct( iDest, iSrc )   ABCC_iSetLSB( iDest, iSrc )
00343 
00344 #else
00345    #define iBeTOi( iBeFoo )                     ABCC_iEndianSwap( iBeFoo )
00346    #define iTOiBe( iFoo )                       ABCC_iEndianSwap( iFoo )
00347    #define iLeTOi( iLeFoo )                     (UINT16)(iLeFoo)
00348    #define iTOiLe( iFoo )                       (UINT16)(iFoo)
00349    #define lBeTOl( lBeFoo )                     ABCC_lEndianSwap( lBeFoo )
00350    #define lTOlBe( lFoo )                       ABCC_lEndianSwap( lFoo )
00351    #define lLeTOl( lLeFoo )                     (UINT32)( lLeFoo )
00352    #define lTOlLe( lFoo )                       (UINT32)( lFoo )
00353 
00354    #define ABCC_GetLowAddrOct( iFoo )           ABCC_iLSB( iFoo )
00355    #define ABCC_GetHighAddrOct( iFoo )          ABCC_iMSB( iFoo )
00356 
00357    #define ABCC_SetLowAddrOct( iDest, iSrc )    ABCC_iSetLSB( iDest, iSrc )
00358    #define ABCC_SetHighAddrOct( iDest, iSrc )   ABCC_iSetMSB( iDest, iSrc )
00359 #endif
00360 
00361 #if( ABCC_CFG_64BIT_ADI_SUPPORT )
00362 #ifdef ABCC_SYS_BIG_ENDIAN
00363 #define lBeTOl64( lBeFoo )  (UINT64)( lBeFoo )
00364 #define lTOlBe64( lFoo )    (UINT64)( lFoo )
00365 #define lLeTOl64( lLeFoo )  ABCC_l64EndianSwap( lLeFoo )
00366 #define lTOlLe64( lFoo )    ABCC_l64EndianSwap( lFoo )
00367 #else
00368 #define lBeTOl64( lBeFoo )  ABCC_l64EndianSwap( lBeFoo )
00369 #define lTOlBe64( lFoo )    ABCC_l64EndianSwap( lFoo )
00370 #define lLeTOl64( lLeFoo )  (UINT64)( lLeFoo )
00371 #define lTOlLe64( lFoo )    (UINT64)( lFoo )
00372 #endif
00373 #endif
00374 
00375 /*------------------------------------------------------------------------------
00376 ** 8/16 bit char platform dependent macros for reading ABP message type members
00377 **------------------------------------------------------------------------------
00378 ** ABCC_GetMsgDataSize( psMsg ) - Message data size (in octets)
00379 ** ABCC_GetMsgInstance( psMsg ) - Message instance
00380 ** ABCC_GetMsgSourceId( psMsg ) - Message source id
00381 ** ABCC_GetMsgDestObj( psMsg )  - Destination object
00382 ** ABCC_IsCmdMsg( psMsg )       - Message command bit
00383 ** ABCC_GetMsgCmdBits( psMsg )  - Message command
00384 ** ABCC_GetMsgCmdExt0( psMsg )  - Command extension 0
00385 ** ABCC_GetMsgCmdExt1( psMsg )  - Command extension 1
00386 ** ABCC_GetMsgCmdExt( psMsg )   - Get extension 0 and 1 16 bit type
00387 ** ABCC_SetMsgCmdExt( psMsg )   - Set extension 0 and 1 16 bit type
00388 **------------------------------------------------------------------------------
00389 */
00390 
00391 #define ABCC_GetMsgDataSize( psMsg )   ( iLeTOi( (psMsg)->sHeader.iDataSize ) )
00392 #define ABCC_GetMsgInstance( psMsg )   ( iLeTOi( (psMsg)->sHeader.iInstance ) )
00393 
00394 #ifdef ABCC_SYS_16_BIT_CHAR
00395 #define ABCC_GetMsgSourceId( psMsg )   ( ABCC_GetLowAddrOct( (psMsg)->sHeader.iSourceIdDestObj ) )
00396 #define ABCC_GetMsgDestObj( psMsg )    ( ABCC_GetHighAddrOct( (psMsg)->sHeader.iSourceIdDestObj ) )
00397 #define ABCC_IsCmdMsg( psMsg )         ( ABCC_GetLowAddrOct( (psMsg)->sHeader.iCmdReserved ) & ABP_MSG_HEADER_C_BIT )
00398 #define ABCC_GetMsgCmdBits( psMsg )    ( ABCC_GetLowAddrOct( (psMsg)->sHeader.iCmdReserved ) & ABP_MSG_HEADER_CMD_BITS )
00399 #define ABCC_GetMsgCmdExt0( psMsg )    ( ABCC_GetLowAddrOct( (psMsg)->sHeader.iCmdExt0CmdExt1)  )
00400 #define ABCC_GetMsgCmdExt1( psMsg )    ( ABCC_GetHighAddrOct( (psMsg)->sHeader.iCmdExt0CmdExt1)  )
00401 #define ABCC_GetMsgCmdExt( psMsg )     ( iLeTOi( (psMsg)->sHeader.iCmdExt0CmdExt1 ) )
00402 #define ABCC_SetMsgCmdExt( psMsg, iExt ) ( (psMsg)->sHeader.iCmdExt0CmdExt1 = iTOiLe( iExt ) )
00403 #define ABCC_GetMsgDataPtr( psMsg )    ( (psMsg)->aiData )
00404 #else
00405 #define ABCC_GetMsgSourceId( psMsg )    ( (psMsg)->sHeader.bSourceId )
00406 #define ABCC_GetMsgDestObj( psMsg )    (psMsg)->sHeader.bDestObj
00407 #define ABCC_IsCmdMsg( psMsg )         ( (psMsg)->sHeader.bCmd & ABP_MSG_HEADER_C_BIT )
00408 #define ABCC_GetMsgCmdBits( psMsg )    ( (psMsg)->sHeader.bCmd & ABP_MSG_HEADER_CMD_BITS )
00409 #define ABCC_GetMsgCmdExt0( psMsg )    ( (psMsg)->sHeader.bCmdExt0 )
00410 #define ABCC_GetMsgCmdExt1( psMsg )    ( (psMsg)->sHeader.bCmdExt1 )
00411 #define ABCC_GetMsgCmdExt( psMsg )     ( iLeTOi( *(UINT16*)&(psMsg)->sHeader.bCmdExt0 ) )
00412 #define ABCC_SetMsgCmdExt( psMsg, iExt )  ( *(UINT16*)&(psMsg)->sHeader.bCmdExt0 = iTOiLe( iExt ) )
00413 #define ABCC_GetMsgDataPtr( psMsg )    ( (psMsg)->abData )
00414 #endif
00415 
00416 /*------------------------------------------------------------------------------
00417 ** 8/16 bit char platform dependent macros to read and write message data
00418 **------------------------------------------------------------------------------
00419 ** ABCC_SetMsgString()  - Copy native string to ABCC message
00420 ** ABCC_GetMsgString()  - Copy ABCC message string to native string
00421 ** ABCC_SetMsgData8()   - Write 8 bit data to ABCC message
00422 ** ABCC_SetMsgData16()  - Write 16 bit data to ABCC message
00423 ** ABCC_SetMsgData32()  - Write 32 bit data to ABCC message
00424 ** ABCC_GetMsgData8()   - Read 8 bit data from an ABCC message
00425 ** ABCC_GetMsgData16()  - Read 16 bit data from an ABCC message
00426 ** ABCC_GetMsgData32()  - Read 32 bit data from an ABCC message
00427 **------------------------------------------------------------------------------
00428 ** ABCC_SetMsgString( psMsg, pcString, iNumChar, iOctetOffset )
00429 **    psMsg - Pointer to message
00430 **    pcString - String to be written
00431 **    iNumChar - Number of chars in the string
00432 **    iOctetOffset - Offset to where the string shall be written.
00433 **
00434 ** ABCC_GetMsgString( psMsg, pcString, iNumChar, iOctetOffset )
00435 **    psMsg - Pointer to message
00436 **    pcString - String to be written
00437 **    iNumChar - Number of chars in the string
00438 **    iOctetOffset - Offset to where the string shall be read.
00439 **
00440 ** ABCC_SetMsgDataX( psMsg, Data, iOctetOffset )
00441 **    psMsg - Pointer to message
00442 **    Data  - Data to be set
00443 **    iOctetOffset - Offset to where data shall be written.
00444 **
00445 ** ABCC_GetMsgDataX( psMsg, Data, iOctetOffset )
00446 **    psMsg - Pointer to message
00447 **    Data  - Read data variable
00448 **    iOctetOffset - Offset to where data shall be read.
00449 **------------------------------------------------------------------------------
00450 */
00451 void ABCC_SetMsgString( ABP_MsgType* psMsg, const char* pcString, UINT16 iNumChar, UINT16 iOctetOffset );
00452 void ABCC_GetMsgString( ABP_MsgType* psMsg, char* pcString, UINT16 iNumChar, UINT16 iOctetOffset );
00453 
00454 void ABCC_GetMsgData8( ABP_MsgType* psMsg, UINT8* pbData, UINT16 iOctetOffset );
00455 void ABCC_SetMsgData8( ABP_MsgType* psMsg, UINT8 bData, UINT16 iOctetOffset );
00456 
00457 void ABCC_GetMsgData16( ABP_MsgType* psMsg, UINT16* piData, UINT16 iOctetOffset );
00458 void ABCC_SetMsgData16( ABP_MsgType* psMsg, UINT16 iData, UINT16 iOctetOffset );
00459 
00460 void ABCC_GetMsgData32( ABP_MsgType* psMsg, UINT32* plData, UINT16 iOctetOffset );
00461 void ABCC_SetMsgData32( ABP_MsgType* psMsg, UINT32 lData, UINT16 iOctetOffset );
00462 
00463 #if( ABCC_CFG_64BIT_ADI_SUPPORT )
00464 UINT64 ABCC_GetMsgData64( ABP_MsgType* psMsg, UINT16 iOctetOffset );
00465 void ABCC_SetMsgData64( ABP_MsgType* psMsg, UINT64 lData, UINT16 iOctetOffset );
00466 #endif
00467 
00468 /*------------------------------------------------------------------------------
00469 ** Copy a number of bytes, from the source pointer to the destination pointer.
00470 ** This function can be modified to use performance enhancing platform specific
00471 ** instructions. The default implementation is memcpy().
00472 **------------------------------------------------------------------------------
00473 ** Arguments:
00474 **    pbDestinationPtr - Pointer to the destination.
00475 **    pbSourcePtr      - Pointer to source data.
00476 **    iNbrOfBytes      - The number of bytes that shall be copied.
00477 **
00478 ** Returns:
00479 **    None
00480 **------------------------------------------------------------------------------
00481 */
00482 #define ABCC_MemCpy( pbDestinationPtr, pbSourcePtr, iNbrOfBytes )             \
00483         ABCC_PORT_MemCpy( pbDestinationPtr, pbSourcePtr, iNbrOfBytes )
00484 
00485 /*******************************************************************************
00486 ** Public Services
00487 ********************************************************************************
00488 */
00489 
00490 /*------------------------------------------------------------------------------
00491 ** This function is used to measure sync timings. ABCC_CFG_SYNC_MEASUREMENT_OP
00492 ** is used when measuring the output processing time and
00493 ** ABCC_CFG_SYNC_MEASUREMENT_IP is used to measure the input processing time.
00494 **------------------------------------------------------------------------------
00495 ** Arguments:
00496 **    None
00497 ** Returns:
00498 **    None
00499 **------------------------------------------------------------------------------
00500 */
00501 #if( ABCC_CFG_SYNC_MEASUREMENT_OP || ABCC_CFG_SYNC_MEASUREMENT_IP )
00502 EXTFUNC void ABCC_GpioReset( void );
00503 #endif
00504 
00505 /*------------------------------------------------------------------------------
00506 ** This function is used to measure sync timings. ABCC_CFG_SYNC_MEASUREMENT_OP
00507 ** is used when measuring the output processing time and
00508 ** ABCC_CFG_SYNC_MEASUREMENT_IP is used to measure the input processing time.
00509 **------------------------------------------------------------------------------
00510 ** Arguments:
00511 **    None
00512 ** Returns:
00513 **    None
00514 **------------------------------------------------------------------------------
00515 */
00516 #if( ABCC_CFG_SYNC_MEASUREMENT_OP || ABCC_CFG_SYNC_MEASUREMENT_IP )
00517 EXTFUNC void ABCC_GpioSet( void );
00518 #endif
00519 
00520 /*------------------------------------------------------------------------------
00521 ** This function will initiate the hardware required to communicate with the
00522 ** ABCC. This interface shall be called once during the power up initialization.
00523 ** The driver can be restarted without calling this interface again.
00524 **------------------------------------------------------------------------------
00525 ** Arguments:
00526 **    None
00527 ** Returns:
00528 **    ABCC_ErrorCodeType
00529 **------------------------------------------------------------------------------
00530 */
00531 EXTFUNC ABCC_ErrorCodeType ABCC_HwInit( void );
00532 
00533 /*------------------------------------------------------------------------------
00534 ** This function will initiate the driver, enable interrupt, and set the
00535 ** operation mode. If a firmware update is pending a delay, iMaxStartupTime, can
00536 ** be defined describing how long the driver is to wait for the startup
00537 ** interrupt. iMaxStartupTime set to Zero (0) makes the driver use the
00538 ** ABCC_CFG_STARTUP_TIME_MS time.
00539 ** When this function has been called the timer system could be started,
00540 ** see ABCC_RunTimerSystem().
00541 ** Note! This function will NOT release the reset of the ABCC.
00542 ** To release reset, ABCC_HwReleaseReset() has to be called by the application.
00543 **------------------------------------------------------------------------------
00544 ** Arguments:
00545 **    lMaxStartupTimeMs -    Max startup time for ABCC
00546 **
00547 ** Returns:
00548 **    ABCC_ErrorCodeType
00549 **------------------------------------------------------------------------------
00550 */
00551 EXTFUNC ABCC_ErrorCodeType ABCC_StartDriver( UINT32 lMaxStartupTimeMs );
00552 
00553 /*------------------------------------------------------------------------------
00554 ** Stops the driver and puts it into SHUTDOWN state. The ABCC will be reset.
00555 **------------------------------------------------------------------------------
00556 ** Arguments:
00557 **    None
00558 **
00559 ** Returns:
00560 **    None
00561 **------------------------------------------------------------------------------
00562 */
00563 EXTFUNC void ABCC_ShutdownDriver( void );
00564 
00565 /*------------------------------------------------------------------------------
00566 ** This function shall be polled after ABCC_StartDriver() has been executed
00567 ** until ABCC_READY_FOR_COMMUNICATION is returned. This indicates that the ABCC
00568 ** is ready for communication and the ABCC setup sequence is started.
00569 **------------------------------------------------------------------------------
00570 ** Arguments:
00571 **    None
00572 **
00573 ** Returns:
00574 **    ABCC_CommunicationStateType:
00575 **    ( see description of ABCC_CommunicationStateType )
00576 **
00577 **------------------------------------------------------------------------------
00578 */
00579 EXTFUNC ABCC_CommunicationStateType ABCC_isReadyForCommunication( void );
00580 
00581 /*------------------------------------------------------------------------------
00582 ** This function should be called from inside the ABCC interrupt routine to
00583 ** acknowledge and handle received ABCC events (Triggered by IRQ_n on the
00584 ** abcc application interface).
00585 ** The user configuration defines, ABCC_CFG_INT_ENABLE_MASK and
00586 ** ABCC_CFG_HANDLE_IN_ABCC_ISR_MASK, allows configuration of which events to
00587 ** handle by the ISR and which events to pass on to the application
00588 ** (ABCC_CbfEvent()).
00589 **------------------------------------------------------------------------------
00590 ** Arguments:
00591 **    None
00592 **
00593 ** Returns:
00594 **    None
00595 **------------------------------------------------------------------------------
00596 */
00597 EXTFUNC void ( *ABCC_ISR )( void );
00598 
00599 /*------------------------------------------------------------------------------
00600 ** This function is responsible for handling all timers for the ABCC-driver. It
00601 ** is recommended to call this function on a regular basis from a timer
00602 ** interrupt. Without this function no timeout and watchdog functionality will
00603 ** work. This function can be called after ABCC_StartDriver() has been called.
00604 **------------------------------------------------------------------------------
00605 ** Arguments:
00606 **    iDeltaTimeMs - Milliseconds since last call.
00607 **
00608 ** Returns:
00609 **    None
00610 **------------------------------------------------------------------------------
00611 */
00612 EXTFUNC void ABCC_RunTimerSystem( const INT16 iDeltaTimeMs );
00613 
00614 /*------------------------------------------------------------------------------
00615 ** ABCC hardware reset.
00616 ** Note! This function will only set reset pin to low. It the responsibility of
00617 ** the caller to make sure that the reset time is long enough.
00618 **------------------------------------------------------------------------------
00619 ** Arguments:
00620 **    None
00621 **
00622 ** Returns:
00623 **    None
00624 **------------------------------------------------------------------------------
00625 */
00626 EXTFUNC void ABCC_HWReset( void );
00627 
00628 /*------------------------------------------------------------------------------
00629 ** Releases the ABCC reset.
00630 **------------------------------------------------------------------------------
00631 ** Arguments:
00632 **    None
00633 **
00634 ** Returns:
00635 **    None
00636 **------------------------------------------------------------------------------
00637 */
00638 EXTFUNC void ABCC_HWReleaseReset( void );
00639 
00640 /*------------------------------------------------------------------------------
00641 ** This function drives the ABCC driver sending and receiving mechanism.
00642 ** The driver must be ready for communication before this function is called
00643 ** (ABCC_isReadyForCommunication() must be TRUE). This function could be called
00644 ** cyclically or be based on events from the ABCC. If all events are handled in
00645 ** the interrupt context then there is no need to call this function.
00646 **------------------------------------------------------------------------------
00647 ** Arguments:
00648 **    None
00649 **
00650 ** Returns:
00651 **    ABCC_ErrorCodeType
00652 **------------------------------------------------------------------------------
00653 */
00654 EXTFUNC ABCC_ErrorCodeType (*ABCC_RunDriver)( void );
00655 
00656 /*------------------------------------------------------------------------------
00657 ** This function should be called by the application when the last response from
00658 ** the user specific setup has been received. This will end the ABCC setup
00659 ** sequence and ABCC_SETUP_COMPLETE will be sent. The user specific setup is a
00660 ** part of the ABCC setup sequence and it is initiated by the driver by calling
00661 ** the ABCC_CbfUserInitReq() function.
00662 **------------------------------------------------------------------------------
00663 ** Arguments:
00664 **    None
00665 **
00666 ** Returns:
00667 **    None
00668 **------------------------------------------------------------------------------
00669 */
00670 EXTFUNC void ABCC_UserInitComplete( void );
00671 
00672 /*------------------------------------------------------------------------------
00673 ** Sends a command message to the ABCC.
00674 ** The function ABCC_GetCmdMsgBuffer() must be used to allocate the message
00675 ** buffer. It is OK to re-use a previously received response buffer
00676 ** The driver will use the sourceId to map the response to the correct response
00677 ** handler. ABCC_GetNewSourceId() could be used to provide an new source id.
00678 ** Example where ABCC_CbfMessageReceived() function is used as response handler:
00679 **
00680 ** eResp = ABCC_SendCmdMsg( psMsg, ABCC_CbfMessageReceived );
00681 **------------------------------------------------------------------------------
00682 ** Arguments:
00683 **    psCmdMsg     - Pointer to the command message.
00684 **    pnMsgHandler - Pointer to the function to handle the response
00685 **                   message.
00686 **
00687 ** Returns:
00688 **    ABCC_ErrorCodeType
00689 **------------------------------------------------------------------------------
00690 */
00691 EXTFUNC ABCC_ErrorCodeType ABCC_SendCmdMsg( ABP_MsgType* psCmdMsg,
00692                                             ABCC_MsgHandlerFuncType pnMsgHandler );
00693 
00694 /*------------------------------------------------------------------------------
00695 ** Retrieves the number of entries left in the command queue.
00696 ** Note! When sending a message the returned status must always be checked to
00697 ** verify that the message has in fact been sent.
00698 **------------------------------------------------------------------------------
00699 ** Arguments:
00700 **    None
00701 **
00702 ** Returns:
00703 **    Number of queue entries left in the command queue
00704 **------------------------------------------------------------------------------
00705 */
00706 EXTFUNC UINT16 ABCC_GetCmdQueueSize( void );
00707 
00708 /*------------------------------------------------------------------------------
00709 ** Sends a response message to the ABCC.
00710 ** Note! The received command buffer can be reused as a response buffer. If a
00711 ** new buffer is used then the function ABCC_GetCmdMsgBuffer() must be used to
00712 ** allocate the buffer.
00713 **------------------------------------------------------------------------------
00714 ** Arguments:
00715 **    psMsgResp - Pointer to the message.
00716 **
00717 ** Returns:
00718 **    ABCC_ErrorCodeType
00719 **------------------------------------------------------------------------------
00720 */
00721 EXTFUNC ABCC_ErrorCodeType ABCC_SendRespMsg( ABP_MsgType* psMsgResp );
00722 
00723 /*------------------------------------------------------------------------------
00724 ** Sends a remap response to the ABCC. When the response is sent the new process
00725 ** data sizes will be set and the function ABCC_CbfRemapDone() will be called to
00726 ** indicate the change.
00727 **------------------------------------------------------------------------------
00728 ** Arguments:
00729 **    psMsgResp       - Pointer to the response message.
00730 **    iNewReadPdSize  - RdPd size when the remap is done.
00731 **    iNewWritePdSize - WrPd size when the remap is done.
00732 **
00733 ** Returns:
00734 **    ABCC_ErrorCodeType
00735 **------------------------------------------------------------------------------
00736 */
00737 #if( ABCC_CFG_REMAP_SUPPORT_ENABLED )
00738 EXTFUNC ABCC_ErrorCodeType ABCC_SendRemapRespMsg( ABP_MsgType* psMsgResp,
00739                                                   UINT16 iNewReadPdSize,
00740                                                   const UINT16 iNewWritePdSize );
00741 #endif
00742 
00743 /*------------------------------------------------------------------------------
00744 ** Get the current application status.
00745 ** Note! This information is only supported in SPI and parallel operating mode.
00746 **------------------------------------------------------------------------------
00747 ** Arguments:
00748 **    None
00749 **
00750 ** Returns:
00751 **    The application status of the ABCC
00752 **------------------------------------------------------------------------------
00753 */
00754 EXTFUNC ABP_AppStatusType ABCC_GetAppStatus( void );
00755 
00756 /*------------------------------------------------------------------------------
00757 ** Sets the current application status.
00758 ** Note! This information is only supported in SPI and parallel operating mode.
00759 ** When used for other operating modes the call has no effect.
00760 **------------------------------------------------------------------------------
00761 ** Arguments:
00762 **    eAppStatus        - Current application status
00763 **
00764 ** Returns:
00765 **    None
00766 **------------------------------------------------------------------------------
00767 */
00768 EXTFUNC void ABCC_SetAppStatus( ABP_AppStatusType eAppStatus  );
00769 
00770 /*------------------------------------------------------------------------------
00771 ** Retrieves a message buffer. This function MUST be used when allocating
00772 ** message buffers. The size of the buffer is controlled by
00773 ** ABCC_CFG_MAX_MSG_SIZE.
00774 **------------------------------------------------------------------------------
00775 ** Arguments:
00776 **    None
00777 **
00778 ** Returns:
00779 **    ABP_MsgType* - Pointer to the message buffer.
00780 **                   NULL is returned if no resource is available.
00781 **------------------------------------------------------------------------------
00782 */
00783 EXTFUNC ABP_MsgType* ABCC_GetCmdMsgBuffer( void );
00784 
00785 /*------------------------------------------------------------------------------
00786 ** Returns the message buffer to the driver's message pool.
00787 ** Note! This function may only be used in combination with
00788 ** ABCC_TakeMsgBufferOwnership().
00789 **------------------------------------------------------------------------------
00790 ** Arguments:
00791 **    ppsBuffer - Pointer to the message buffer that was freed.
00792 **                The buffer pointer will be set to NULL.
00793 **
00794 ** Returns:
00795 **    ABCC_ErrorCodeType
00796 **------------------------------------------------------------------------------
00797 */
00798 EXTFUNC ABCC_ErrorCodeType ABCC_ReturnMsgBuffer( ABP_MsgType** ppsBuffer );
00799 
00800 /*------------------------------------------------------------------------------
00801 ** Takes the ownership of the message buffer. The driver will not free this
00802 ** buffer when returning from e.g. a response callback. It is the user's
00803 ** responsibility to free this buffer when it is not needed anymore by using
00804 ** ABCC_ReturnMsgBuffer().
00805 **------------------------------------------------------------------------------
00806 ** Arguments:
00807 **   psMsg - Pointer to the message buffer to take ownership of
00808 **
00809 ** Returns:
00810 **    ABCC_StatusType
00811 **------------------------------------------------------------------------------
00812 */
00813 EXTFUNC void ABCC_TakeMsgBufferOwnership( ABP_MsgType* psMsg );
00814 
00815 /*------------------------------------------------------------------------------
00816 ** Reads the module ID.
00817 **------------------------------------------------------------------------------
00818 ** Arguments:
00819 **    None
00820 **
00821 ** Returns:
00822 **    ModuleId
00823 **------------------------------------------------------------------------------
00824 */
00825 EXTFUNC UINT8 ABCC_ReadModuleId( void );
00826 
00827 /*------------------------------------------------------------------------------
00828 ** Detects if a module is present. If the ABCC Module detect pins on the host
00829 ** connector is not connected (ABCC_CFG_MOD_DETECT_PINS_CONN shall be defined)
00830 ** this interface will always return TRUE.
00831 **------------------------------------------------------------------------------
00832 ** Arguments:
00833 **    None
00834 **
00835 ** Returns:
00836 **    TRUE  - Module detected.
00837 **    FALSE - No module detected
00838 **------------------------------------------------------------------------------
00839 */
00840 EXTFUNC BOOL ABCC_ModuleDetect( void );
00841 
00842 /*------------------------------------------------------------------------------
00843 ** Reads the module capability. This function is only supported by the ABCC40
00844 ** parallel operating mode.
00845 **------------------------------------------------------------------------------
00846 ** Arguments:
00847 **    None
00848 **
00849 ** Returns:
00850 **    Module capability
00851 **------------------------------------------------------------------------------
00852 */
00853 #if( ABCC_CFG_DRV_PARALLEL )
00854 EXTFUNC UINT16 ABCC_ModCap( void );
00855 #endif
00856 
00857 /*------------------------------------------------------------------------------
00858 ** Reads the LED status. Only supported in SPI and parallel operating mode.
00859 **------------------------------------------------------------------------------
00860 ** Arguments:
00861 **    None
00862 **
00863 ** Returns:
00864 **    LED status according to the software design guide.
00865 **------------------------------------------------------------------------------
00866 */
00867 #if( ABCC_CFG_DRV_PARALLEL || ABCC_CFG_DRV_SPI )
00868 EXTFUNC UINT16 ABCC_LedStatus( void );
00869 #endif
00870 
00871 /*------------------------------------------------------------------------------
00872 ** Reads the current Anybus state.
00873 **------------------------------------------------------------------------------
00874 ** Arguments:
00875 **    None
00876 **
00877 ** Returns:
00878 **    Anybus state
00879 **------------------------------------------------------------------------------
00880 */
00881 EXTFUNC UINT8 ABCC_AnbState( void);
00882 
00883 /*------------------------------------------------------------------------------
00884 ** Returns the current status of the supervision bit.
00885 **------------------------------------------------------------------------------
00886 ** Arguments:
00887 **    None
00888 **
00889 ** Returns:
00890 **    TRUE  - Is supervised by another network device.
00891 **    FALSE - Not supervised.
00892 **------------------------------------------------------------------------------
00893 */
00894 EXTFUNC BOOL ABCC_IsSupervised( void );
00895 
00896 /*------------------------------------------------------------------------------
00897 ** Retrieves the network type.
00898 ** This function will return a valid value after ABCC_CbfAdiMappingReq has been
00899 ** called by the driver. If called earlier the function will return 0xFFFF which
00900 ** indicates that the network is unknown. The different newtwork types could
00901 ** be found in abp.h.
00902 **------------------------------------------------------------------------------
00903 ** Arguments:
00904 **    None
00905 **
00906 ** Returns:
00907 **    Network type (0xFFFF if the network is unknown)
00908 **------------------------------------------------------------------------------
00909 */
00910 EXTFUNC UINT16 ABCC_NetworkType( void );
00911 
00912 /*------------------------------------------------------------------------------
00913 ** Retrieves the module type.
00914 ** This function will return a valid value after ABCC_CbfAdiMappingReq has been
00915 ** called by the driver. If called earlier the function will return 0xFFFF which
00916 ** indicates that the moduleType is unknown. The different module types types
00917 ** could be found in abp.h.
00918 **------------------------------------------------------------------------------
00919 ** Arguments:
00920 **    None
00921 **
00922 ** Returns:
00923 **    Module type (0x04XX for Anybus-CC modules).
00924 **------------------------------------------------------------------------------
00925 */
00926 EXTFUNC UINT16 ABCC_ModuleType( void );
00927 
00928 /*------------------------------------------------------------------------------
00929 ** Retrieves the network format.
00930 ** This function will return a valid value after ABCC_CbfAdiMappingReq has been
00931 ** called by the driver. If called earlier the function will return NET_UNKNOWN.
00932 **------------------------------------------------------------------------------
00933 ** Arguments:
00934 **    None
00935 **
00936 ** Returns:
00937 **    Network format type (NET_LITTLEENDIAN, NET_BIGENDIAN).
00938 **------------------------------------------------------------------------------
00939 */
00940 EXTFUNC NetFormatType ABCC_NetFormatType( void );
00941 
00942 /*------------------------------------------------------------------------------
00943 ** Retrieves the parameter support.
00944 ** This function will return a valid value after ABCC_CbfAdiMappingReq has been
00945 ** called by the driver. If called earlier PARAMETR_UNKNOWN will be returned.
00946 **------------------------------------------------------------------------------
00947 ** Arguments:
00948 **    None
00949 **
00950 ** Returns:
00951 **    ParamemterSupportType
00952 **------------------------------------------------------------------------------
00953 */
00954 EXTFUNC ParameterSupportType ABCC_ParameterSupport( void );
00955 
00956 /*------------------------------------------------------------------------------
00957 ** This function will call ABCC_SYS_GetOpmode() to read the operating mode from
00958 ** HW. If the operation is known and fixed or in any other way decided by the
00959 ** application this function could be ignored.
00960 **------------------------------------------------------------------------------
00961 ** Arguments:
00962 **    None
00963 **
00964 ** Returns:
00965 **    The ABCC40 4 bit operating mode according to abp.h
00966 **------------------------------------------------------------------------------
00967 */
00968 EXTFUNC UINT8 ABCC_GetOpmode( void );
00969 
00970 /*******************************************************************************
00971 ** Callback Functions.
00972 ** These function must be implemented by the application. The context of the
00973 ** callback will differ depending on implementation.
00974 ** If, for example, the read process data is chosen to be interrupt driven and
00975 ** the message handling chosen to be polled ( see ABCC_CFG_INT_ENABLE_MASK and
00976 ** HANDLE_ABCC_CFG_IN_ABCC_ISR in ABCC_CFG_def.h ), the  ABCC_CbfNewReadPd()
00977 ** will be called from interrupt context and ABCC_CbfReceiveMsg() will be called
00978 ** from the same context as ABCC_RunDriver().
00979 ********************************************************************************
00980 */
00981 
00982 /*------------------------------------------------------------------------------
00983 ** This function is called from ABCC_ISR() when events specified in
00984 ** ABCC_CFG_INT_ENABLE_MASK_X have occurred. The function returns a mask of
00985 ** ABCC_ISR_EVENT_X bits with the currently active events that has not already
00986 ** been handled by the ISR itself. What interrupt to be handled by the ISR is
00987 ** defined in the ABCC_CFG_HANDLE_INT_IN_ISR_MASK.
00988 ** This function is always called from interrupt context.
00989 **------------------------------------------------------------------------------
00990 ** Arguments:
00991 **    iEvents - Mask according to the ISR event bits ABCC_ISR_EVENT_X
00992 **
00993 ** Returns:
00994 **    None
00995 **------------------------------------------------------------------------------
00996 */
00997 EXTFUNC void ABCC_CbfEvent( UINT16 iEvents);
00998 
00999 /*------------------------------------------------------------------------------
01000 ** If sync is supported this function will be invoked at the sync event.
01001 ** The function is executed in interrupt context. If the separate sync pin in
01002 ** the ABCC interface is used this function shall be called from the interrupt
01003 ** handler. If the ABCC interrupt is used the driver will call this function.
01004 **------------------------------------------------------------------------------
01005 ** Arguments:
01006 **    None
01007 **
01008 ** Returns:
01009 **    None
01010 **------------------------------------------------------------------------------
01011 */
01012 #if ABCC_CFG_SYNC_ENABLE
01013 EXTFUNC void ABCC_CbfSyncIsr( void );
01014 #endif
01015 
01016 
01017 /*------------------------------------------------------------------------------
01018 ** This function needs to be implemented by the application. The function is
01019 ** called to trigger a user specific setup during the ABCC setup state. The ABCC
01020 ** driver will remain in ABCC_CFG_INIT state until ABCC_UserInitComplete() is called
01021 ** by the application.  If no user specific setup is required,
01022 ** ABCC_UserInitComplete() must be called inside this function otherwise setup
01023 ** complete will never be sent.
01024 **
01025 ** This function call will be invoked in same context as the read message handling.
01026 ** (See comment for callback section above)
01027 **------------------------------------------------------------------------------
01028 ** Arguments:
01029 **    None
01030 **
01031 ** Returns:
01032 **    None
01033 **------------------------------------------------------------------------------
01034 */
01035 EXTFUNC void ABCC_CbfUserInitReq( void );
01036 
01037 /*------------------------------------------------------------------------------
01038 ** A message has been received from the ABCC. This is the receive function for
01039 ** all received commands from the ABCC. It could also be used as a response
01040 ** handler if passed on as an argument to the ABCC_SendCmdMsg() function.
01041 ** Regarding callback context, see comment for callback section above.
01042 **------------------------------------------------------------------------------
01043 ** Arguments:
01044 **    psReceivedMsg       - Pointer to received message.
01045 **
01046 ** Returns:
01047 **    None
01048 **------------------------------------------------------------------------------
01049 */
01050 EXTFUNC void ABCC_CbfReceiveMsg( ABP_MsgType* psReceivedMsg );
01051 
01052 /*------------------------------------------------------------------------------
01053 ** This function needs to be implemented by the application. The function
01054 ** updates the current write process data. The data must be copied into the
01055 ** buffer before returning from the function.
01056 ** The data will only be sent to the ABCC if the return value is TRUE.
01057 ** Regarding callback context, see comment for callback section above.
01058 **------------------------------------------------------------------------------
01059 ** Arguments:
01060 **    pxWritePd - Pointer to the process data to be sent.
01061 **
01062 ** Returns:
01063 **    TRUE  - If the process data has been changed since last call.
01064 **    FALSE - Process data not changed.
01065 **------------------------------------------------------------------------------
01066 */
01067 EXTFUNC BOOL ABCC_CbfUpdateWriteProcessData( void* pxWritePd );
01068 
01069 /*------------------------------------------------------------------------------
01070 ** This function needs to be implemented by the application. The function is
01071 ** called when new process data has been received. The process data needs to
01072 ** be copied to the application ADI:s before returning from the function. Note
01073 ** that the data may not be changed since last time.
01074 ** Regarding callback context, see comment for callback section above.
01075 **------------------------------------------------------------------------------
01076 ** Arguments:
01077 **    pxReadPd - Pointer to the received process data.
01078 **
01079 ** Returns:
01080 **    None
01081 **------------------------------------------------------------------------------
01082 */
01083 EXTFUNC void ABCC_CbfNewReadPd( void* pxReadPd );
01084 
01085 /*------------------------------------------------------------------------------
01086 ** This function needs to be implemented by the application. The function is
01087 ** called when communication with the ABCC module has been lost. The watchdog
01088 ** timeout is defined by ABCC_CFG_WD_TIMEOUT_MS.
01089 ** Note! No watch functionality is provided for parallel 8/16 bit operation
01090 ** mode.
01091 ** This function is invoked in the same context as ABCC_RunTimerSystem().
01092 **------------------------------------------------------------------------------
01093 ** Arguments:
01094 **    None
01095 **
01096 ** Returns:
01097 **    None
01098 **------------------------------------------------------------------------------
01099 */
01100 #if( ABCC_CFG_DRV_SPI || ABCC_CFG_DRV_SERIAL ||           \
01101      ABCC_CFG_DRV_PARALLEL_30 )
01102 EXTFUNC void ABCC_CbfWdTimeout( void );
01103 #endif
01104 
01105 /*------------------------------------------------------------------------------
01106 ** This function needs to be implemented by the application. The function
01107 ** indicates that we recently had an ABCC watchdog timeout but now the
01108 ** communication is working again.
01109 ** This function will be invoked from same context as the receive handling.
01110 ** (see comment for callback section above).
01111 **------------------------------------------------------------------------------
01112 ** Arguments:
01113 **    None
01114 **
01115 ** Returns:
01116 **    None
01117 **------------------------------------------------------------------------------
01118 */
01119 #if(  ABCC_CFG_DRV_SPI || ABCC_CFG_DRV_SERIAL ||           \
01120       ABCC_CFG_DRV_PARALLEL_30 )
01121 EXTFUNC void ABCC_CbfWdTimeoutRecovered( void );
01122 #endif
01123 
01124 /*------------------------------------------------------------------------------
01125 ** This function need to be implemented by the application. The function is
01126 ** called when the driver is about to start the automatic process data mapping.
01127 ** If no automatic configuration is desired then the pointers are set to NULL.
01128 ** Otherwise the pointers are set to point at the structures containing mapping
01129 ** information. The mapping structures are defined in abcc_ad_if.h.
01130 ** This function will be invoked in same context as the read message handling.
01131 ** (See comment for callback section above)
01132 **------------------------------------------------------------------------------
01133 ** Arguments:
01134 **    ppsAdiEntry   - Pointer to the requested configuration structure pointer.
01135 **    ppsDefaultMap - Pointer to default mapping table.
01136 **
01137 ** Returns:
01138 **    Number of Adi:s in the psAdiEntry table.
01139 **------------------------------------------------------------------------------
01140 */
01141 EXTFUNC UINT16 ABCC_CbfAdiMappingReq( const AD_AdiEntryType** const ppsAdiEntry,
01142                                       const AD_DefaultMapType**  const ppsDefaultMap );
01143 
01144 /*------------------------------------------------------------------------------
01145 ** This function needs to be implemented by the application.
01146 ** The context of the call is depending on where the error has occured.
01147 **------------------------------------------------------------------------------
01148 ** Arguments:
01149 **    eSeverity  - Severity of the event (see ABCC_SeverityType).
01150 **    iErrorCode - Error code.
01151 **    lAddInfo   - Depending on error different additional information can be
01152 **                 added.
01153 **
01154 ** Returns:
01155 **    None
01156 **------------------------------------------------------------------------------
01157 */
01158 EXTFUNC void ABCC_CbfDriverError(  ABCC_SeverityType eSeverity,
01159                                    ABCC_ErrorCodeType  iErrorCode,
01160                                    UINT32  lAddInfo );
01161 
01162 /*------------------------------------------------------------------------------
01163 ** This callback is invoked if the anybus changes state
01164 ** See ABP_AnbStateType in abp.h for more information.
01165 **
01166 ** Regarding callback context, see comment for callback section above.
01167 **------------------------------------------------------------------------------
01168 ** Arguments:
01169 **    bNewAnbState   - New anybus state
01170 **
01171 ** Returns:
01172 **    None
01173 **------------------------------------------------------------------------------
01174 */
01175 EXTFUNC void ABCC_CbfAnbStateChanged( ABP_AnbStateType bNewAnbState );
01176 
01177 /*******************************************************************************
01178 ** REMAP Related functions
01179 ********************************************************************************
01180 */
01181 
01182 /*------------------------------------------------------------------------------
01183 ** This callback is invoked when REMAP response is successfully sent to the
01184 ** ABCC.
01185 **------------------------------------------------------------------------------
01186 ** Arguments:
01187 **    None
01188 **
01189 ** Returns:
01190 **    None
01191 **------------------------------------------------------------------------------
01192 */
01193 #if( ABCC_CFG_REMAP_SUPPORT_ENABLED )
01194 EXTFUNC void ABCC_CbfRemapDone( void );
01195 #endif
01196 
01197 /*******************************************************************************
01198 ** Event related functions
01199 ********************************************************************************
01200 */
01201 
01202 /*------------------------------------------------------------------------------
01203 ** This function is called to trigger a RdPd read. If the read process data is
01204 ** available then a call to the function ABCC_CbfNewReadPd() will be triggered.
01205 **------------------------------------------------------------------------------
01206 ** Arguments:
01207 **    None
01208 **
01209 ** Returns:
01210 **    None
01211 **------------------------------------------------------------------------------
01212 */
01213 EXTFUNC void ABCC_TriggerRdPdUpdate( void );
01214 
01215 /*------------------------------------------------------------------------------
01216 ** This function is called to trigger a message receive read. If a read message
01217 ** is available then the corresponding message handler will be called.
01218 **------------------------------------------------------------------------------
01219 ** Arguments:
01220 **    None
01221 **
01222 ** Returns:
01223 **    None
01224 **------------------------------------------------------------------------------
01225 */
01226 EXTFUNC void ABCC_TriggerReceiveMessage( void );
01227 
01228 /*------------------------------------------------------------------------------
01229 ** This function indicates that new process data from the application is
01230 ** available and will be sent to the ABCC.
01231 **------------------------------------------------------------------------------
01232 ** Arguments:
01233 **    None
01234 **
01235 ** Returns:
01236 **    None
01237 **------------------------------------------------------------------------------
01238 */
01239 EXTFUNC void (*ABCC_TriggerWrPdUpdate)( void );
01240 
01241 /*------------------------------------------------------------------------------
01242 ** Check if current anybus status has changed.
01243 ** If the status  is changed  ABCC_CbfAnbStatusChanged() will be invoked.
01244 **------------------------------------------------------------------------------
01245 ** Arguments:
01246 **    None
01247 **
01248 ** Returns:
01249 **    None
01250 **------------------------------------------------------------------------------
01251 */
01252 EXTFUNC void ABCC_TriggerAnbStatusUpdate( void );
01253 
01254 /*------------------------------------------------------------------------------
01255 ** Checks if there are any messages to send.
01256 **------------------------------------------------------------------------------
01257 ** Arguments:
01258 **    None
01259 **
01260 ** Returns:
01261 **    None
01262 **------------------------------------------------------------------------------
01263 */
01264 EXTFUNC void ABCC_TriggerTransmitMessage( void );
01265 
01266 /*******************************************************************************
01267 ** Message support functions
01268 ********************************************************************************
01269 */
01270 
01271 /*------------------------------------------------------------------------------
01272 ** This function fills an ABCC message with parameters to get an attribute.
01273 **------------------------------------------------------------------------------
01274 ** Arguments:
01275 **    psMsg      - Pointer to message buffer.
01276 **    bObject    - Object number.
01277 **    iInstance  - Instance number.
01278 **    bAttribute - Attribute number.
01279 **    bSourceId  - Source identifier
01280 **
01281 ** Returns:
01282 **    None
01283 **------------------------------------------------------------------------------
01284 */
01285 EXTFUNC void ABCC_GetAttribute( ABP_MsgType* psMsg,
01286                                 UINT8 bObject,
01287                                 UINT16 iInstance,
01288                                 UINT8 bAttribute,
01289                                 UINT8 bSourceId );
01290 
01291 /*------------------------------------------------------------------------------
01292 ** This function fills an ABCC message with parameters in order to set an
01293 ** attribute.
01294 **------------------------------------------------------------------------------
01295 ** Arguments:
01296 **    psMsg      - Pointer to message buffer.
01297 **    bObject    - Object number.
01298 **    iInstance  - Instance number.
01299 **    bAttribute - Attribute number.
01300 **    bVal       - Value to set.
01301 **    bSourceId  - Source identifier.
01302 **
01303 ** Returns:
01304 **    None
01305 **------------------------------------------------------------------------------
01306 */
01307 EXTFUNC void ABCC_SetByteAttribute( ABP_MsgType* psMsg,
01308                                     UINT8 bObject,
01309                                     UINT16 iInstance,
01310                                     UINT8 bAttribute,
01311                                     UINT8 bVal,
01312                                     UINT8 bSourceId );
01313 
01314 /*------------------------------------------------------------------------------
01315 ** This function sets the input arguments to the ABCC message header correctly.
01316 ** The data must be copied to message data buffer separately.
01317 **------------------------------------------------------------------------------
01318 ** Arguments:
01319 **    psMsg      - Pointer to message buffer.
01320 **    bObject    - Object number.
01321 **    iInstance  - Instance number.
01322 **    bAttribute - Attribute number.
01323 **    eService   - Message command
01324 **    iDataSize  - Size of the message data in bytes
01325 **    bSourceId  - Source identifier.
01326 **
01327 ** Returns:
01328 **    None
01329 **------------------------------------------------------------------------------
01330 */
01331 EXTFUNC void ABCC_SetMsgHeader( ABP_MsgType* psMsg,
01332                                 UINT8 bObject,
01333                                 UINT16 iInstance,
01334                                 UINT8 bAttribute,
01335                                 ABP_MsgCmdType eService,
01336                                 UINT16 iDataSize,
01337                                 UINT8 bSourceId );
01338 
01339 /*------------------------------------------------------------------------------
01340 ** This function verifies an ABCC response message.
01341 **------------------------------------------------------------------------------
01342 ** Arguments:
01343 **    psMsg - Pointer to message buffer.
01344 **
01345 ** Returns:
01346 **    ABCC_ErrorCodeType.
01347 **------------------------------------------------------------------------------
01348 */
01349 EXTFUNC ABCC_ErrorCodeType ABCC_VerifyMessage( const ABP_MsgType* psMsg );
01350 
01351 /*------------------------------------------------------------------------------
01352 ** This function returns a new source id that could used when sending a command
01353 ** message. It is guaranteed be unique if this function is used every time a new
01354 ** command is sent. The alternative would be that the user uses fixed source
01355 ** id:s.
01356 **------------------------------------------------------------------------------
01357 ** Arguments:
01358 **    None
01359 **
01360 ** Returns:
01361 **    New SourceId
01362 **------------------------------------------------------------------------------
01363 */
01364 EXTFUNC UINT8 ABCC_GetNewSourceId( void );
01365 
01366 /*------------------------------------------------------------------------------
01367 ** This function returns the size of an ABP data type.
01368 **------------------------------------------------------------------------------
01369 ** Arguments:
01370 **    bDataType - Data type number.
01371 **
01372 ** Returns:
01373 **    Data type size in bytes.
01374 **------------------------------------------------------------------------------
01375 */
01376 EXTFUNC UINT8 ABCC_GetDataTypeSize( UINT8 bDataType );
01377 
01378 /*------------------------------------------------------------------------------
01379 ** This function returns the size of an ABP data type in bits.
01380 **------------------------------------------------------------------------------
01381 ** Arguments:
01382 **    bDataType - Data type number.
01383 **
01384 ** Returns:
01385 **    Data type size in bits.
01386 **------------------------------------------------------------------------------
01387 */
01388 EXTFUNC UINT16 ABCC_GetDataTypeSizeInBits( UINT8 bDataType );
01389 
01390 #endif  /* inclusion lock */