📄 abu_init.c
字号:
/****************************************************************************
**
** File Name
** ---------
**
** ABU_INIT.C
**
*****************************************************************************
*****************************************************************************
**
** Description
** -----------
**
** User provided initialization and exit cleanup routines..
**
*****************************************************************************
*****************************************************************************
**
** Source Change Indices
** ---------------------
**
** Porting: <none>----4<major> Customization: <none>----4<major>
**
** * Application developers may to add initialization steps to this
** module that setup application specific objects.
**
*****************************************************************************
*****************************************************************************
** **
** ETHERNET/IP EXAMPLE CODE **
** COPYRIGHT (c) 2000-2005 ODVA (Open DeviceNet Vendor Association) **
** & ControlNet International Ltd. **
** **
** All rights reserved, except as specifically licensed in writing. **
** Use of the Ethernet/IP Example Protocol Software is subject to **
** ODVA's and ControlNet International's Terms of Use Agreement. **
** The following work constitutes example program code and is intended **
** merely to illustrate useful programming techniques. The user is **
** responsible for applying the code correctly. The code is provided **
** AS IS without warranty and is in no way guaranteed to be error-free. **
** **
*****************************************************************************
*****************************************************************************
*/
#include "cd.h"
#include "id.h" /* Identity Object public interfaces */
#include "ns.h" /* NV storage utility public interfaces */
#include "abu_init.h" /* interface for host specific hardware */
#include "ns_util.h"
#include "nsu_util.h"
#ifdef WIN32
#include <malloc.h>
#endif
/****************************************************************************
**
** Public Data
**
*****************************************************************************
*/
/*---------------------------------------------------------------------------
**
** Connection good/bad status and run/idle bit array.
**
**---------------------------------------------------------------------------
*/
UINT8 AB_abConnectionStatus[ AB_NUM_CONN_STATUS_BITS / 8 ];
/*
** Global configuration data.
*/
ABU_DataType ABU_s;
/****************************************************************************
**
** Private Services
**
*****************************************************************************
*/
/*---------------------------------------------------------------------------
** abu_AcquireInterrupts()
**---------------------------------------------------------------------------
*/
void abu_AcquireInterrupts( void )
{
/*
** Platform dependant set up for the example code. Hook all interrupt
** vectors used by the example code stack here. Save any vectors that
** need to be restored later, if expecting to exit from the example
** code stack.
*/
/*********************************************************/
/*** PORTING ALERT! ***/
/*** ADD APPLICATION SPECIFIC INITIALIZATION CODE HERE ***/
/*********************************************************/
} /* end of abu_AcquireInterrupts */
/*---------------------------------------------------------------------------
** abu_Exit()
**---------------------------------------------------------------------------
*/
void abu_Exit( void )
{
/*
** Cleanup in preparation for shutting down the code.
*/
/***************************************************/
/*** PORTING ALERT! ***/
/*** ADD APPLICATION SPECIFIC SHUTDOWN CODE HERE ***/
/***************************************************/
#ifdef WIN32
free( (void *) FD_IntelSegment( AB_s.pHeapBase ) );
#endif
} /* end of abu_Exit() */
/*---------------------------------------------------------------------------
** abu_Init()
**---------------------------------------------------------------------------
*/
StatusType abu_Init( UINT16 iOptions )
{
/*
** Initialization of user portion of the application.
** Initialization consists of several discrete parts.
** See ab.h for a definition of the initialization option bits.
*/
/*********************************************************/
/*** PORTING ALERT! ***/
/*** ADD APPLICATION SPECIFIC INITIALIZATION CODE HERE ***/
/*********************************************************/
if( iOptions & AB_CREATE_RESOURCE )
{
}
if( iOptions & AB_INIT_RESOURCE )
{
/*
** Fill in the ABU_s struct so the NSU_Init() function
** can properly fetch the NV segments
*/
ABU_s.sSegConfig[ 0 ].sSegmentAttributes.lSegSize = 8 * 1024;
#ifdef NV_STORAGE_UTIL
NSU_Init();
#endif
}
if( iOptions & AB_CREATE_TASK )
{
}
if( iOptions & AB_INIT_TASK )
{
}
if( iOptions & AB_PREPARE_FOR_RESTART )
{
}
return( SUCCESS );
} /* end of abu_Init() */
/*---------------------------------------------------------------------------
** abu_PreInit()
**---------------------------------------------------------------------------
*/
StatusType abu_PreInit( void )
{
UINT16 i;
/*
** User initialization that must be performed prior to the
** initialization of the individual objects.
** This consists mostly of loading useful values into the global
** information structure used to initialize various other components.
*/
/*********************************************************/
/*** PORTING ALERT! ***/
/*** ADD APPLICATION SPECIFIC INITIALIZATION CODE HERE ***/
/*********************************************************/
#ifdef WIN32
AB_s.pHeapBase = malloc( ( GS_TOTAL_HEAP_SIZE ) + 16L );
if( AB_s.pHeapBase == NULL )
{
return( GS_SYS_MEMORY_UNAVAIL );
}
#endif
/* initialize device specific non-volatile segment parameters */
for ( i = 0; i < ABU_NUM_OF_SEGMENTS; i++ )
{
ABU_s.sSegConfig[i].iSegmentNumber = 0;
ABU_s.sSegConfig[i].bSectorStart = 0;
ABU_s.sSegConfig[i].bSectorEnd = 0;
ABU_s.sSegConfig[i].fStackedSegment = FALSE;
ABU_s.sSegConfig[i].sSegmentAttributes.bMajRev = 0;
ABU_s.sSegConfig[i].sSegmentAttributes.bMinRev = 0;
}
/*
** define the main segment parameters
*/
#ifdef NV_STORAGE_UTIL
ABU_s.sSegConfig[0].iSegmentNumber = NS_CC_SEGMENT;
#else
ABU_s.sSegConfig[0].iSegmentNumber = 0; /* ??? ??? ??? */
#endif
ABU_s.sSegConfig[0].bSectorStart = 0;
ABU_s.sSegConfig[0].bSectorEnd = 0;
ABU_s.sSegConfig[0].fStackedSegment = TRUE;
ABU_s.sSegConfig[0].sSegmentAttributes.bMajRev = 0;
ABU_s.sSegConfig[0].sSegmentAttributes.bMinRev = 0;
ABU_s.sSegConfig[0].sSegmentAttributes.iBootFlag = 0;
ABU_s.sSegConfig[0].sSegmentAttributes.iBurnIncrement = 1;
ABU_s.sSegConfig[0].sSegmentAttributes.iTransferSize = 128;
ABU_s.sSegConfig[0].sSegmentAttributes.iUploadSize = 0;
ABU_s.sSegConfig[0].sSegmentAttributes.fResetForNvUpdate = TRUE;
/*
** Size and address of this segment get filled in during
** abu_Init( )
*/
/*
** Publish the location of the connection status bit array.
*/
AB_s.pabConnectionStatus = &AB_abConnectionStatus[ 0 ];
/*
** All pre-initialization went well. We may continue.
*/
return( SUCCESS );
} /* end of abu_PreInit() */
/*---------------------------------------------------------------------------
** abu_RelinquishInterrupts()
**---------------------------------------------------------------------------
*/
void abu_RelinquishInterrupts( void )
{
/*
** Restore previously acquired interrupt vectors used by the example code
** if expecting to cleanly exit from the example code stack.
** If no clean exit is required, nothing needs to be done here
*/
/*********************************************************/
/*** PORTING ALERT! ***/
/*** ADD APPLICATION SPECIFIC INITIALIZATION CODE HERE ***/
/*********************************************************/
} /* end of abu_RelinquishInterrupts */
/****************************************************************************
**
** End of ABU_INIT.C
**
*****************************************************************************
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -