📄 nv_flash.c
字号:
/* At least one error has occured - but continue */
copyStatus = FALSE;
}
}
/* Update pointers */
pNVRAMCopyFrom++;
pNVRAMCopyTo++;
}
if( FlashEraseSector(( uint16_t )gpScratchPadNvram >> HCS08SectorSize_c )
== FALSE ) {
copyStatus = FALSE;
}
IrqControlLib_RestoreIrqStatus( ccr );
return( copyStatus );
}
/*****************************************************************************
* Reads the NVRAM data from the specified Address.
*
* Interface assumptions:
*
* Return value:
* Status
*
* Revison history:
* Unnecessary checkingof NVM range removed to save code space.
* It is anyway memory copy.
*
* date Author Comments
* ------ ------ --------
* 290301 FSL,LS Created
*****************************************************************************/
bool_t NVM_ReadNVRAM (
uint8_t *PDestination, /*IN: destination address (RAM address) to where
data has to be copied */
uint8_t *pNVRAMSource, /* IN:address in NVRAM from where data has to be
copied */
uint16_t cSourceLength /* IN:length of data to be copied from NVRAM */
)
{
if (NVmemcpy( PDestination, pNVRAMSource, cSourceLength)) {
return TRUE;
}
else {
return FALSE;
}
}
/*****************************************************************************
******************************************************************************
* Private functions
******************************************************************************
*****************************************************************************/
/*****************************************************************************
* The data is written to flash on the location specified in the pointer.
*
* Interface assumptions:
* Should be called from Interrupt disabled context.
*
* Return value:
* FlashStatus
*
* Revison history:
*
* date Author Comments
* ------ ------ --------
* 290301 FSL,LS Created
*****************************************************************************/
bool_t FlashProgByte(
uint8_t data, /* IN:data to be written */
uint8_t * pDestination /* IN:Address where data has to be written */
)
{
bool_t FlashStatus;
/* Go to commom critical part of flash execution in RAM */
FlashStatus = pfNVFlashCommomExecuteCMD_t(data, pDestination, \
FlashByteWriteCmd_c);
return(FlashStatus);
}
/*****************************************************************************
* Erases the sector specified as parameter.
*
* Interface assumptions:
* Should be called from Interrupt disabled context.
*
* Return value:
* FlashStatus
*
* Revison history:
*
* date Author Comments
* ------ ------ --------
* 290301 FSL,LS Created
*****************************************************************************/
bool_t FlashEraseSector(
uint8_t sectorNumber /* IN:sector to be erased */
)
{
bool_t FlashStatus;
/*just avoid erasing code space by programs.*/
if (( sectorNumber == NvramScratchpad_c ) ||
( sectorNumber == NvramMac_c )||
( sectorNumber == NvramZS1_c )||
( sectorNumber == NvramZS2_c )) {
/* Go to critical part of flash execution in RAM */
FlashStatus = pfNVFlashCommomExecuteCMD_t( DummyData_c, \
(( uint8_t* )((( sectorNumber + 1 )*FlashSectorSize_c ) - 1 )),
FlashSectorEraseCmd_c );
}
return( FlashStatus );
}
/*****************************************************************************
* Copies data from source to destination
*
* Interface assumptions:
*
* Return value:
* None
*
* Revison history:
*
* date Author Comments
* ------ ------ --------
* 290301 FSL,LS Created
*****************************************************************************/
bool_t NVmemcpy(
uint8_t *pDest, /* IN:destination address (RAM address) */
uint8_t *pSource, /* IN:the source address in NVRAM */
uint16_t cDataLength /* IN:length of data to be copied */
)
{
uint16_t iIndex;
for ( iIndex = 0; iIndex < cDataLength; iIndex++ ) {
*pDest++ = *pSource++;
}
return TRUE;
}
/******************************************************************************
* This function is used to Get the MAC state
*
* Interface assumptions: None
* Return value: None
*
* Effects on Global Data: none
*
* Revison history:
* date Author Comments
* ------ ------ --------
* 200606 mwest2 Created
******************************************************************************/
uint8_t GetMacStateReq(void) {
aspMsg_t aspGetMacState;
aspGetMacStateReq_t *pGetMacStateReq;
pGetMacStateReq = &aspGetMacState.appToAspMsg.msgData.aspGetMacStateReq;
/* Set the type. */
aspGetMacState.msgType = gAppAspGetMacStateReq_c;
/* Values greater than 1 byte must be little endian byte arrays. */
pGetMacStateReq->dummy = 0x00;
(void) MSG_Send(APP_ASP, &aspGetMacState);
return(aspGetMacState.aspToAppMsg.msgData.appGetMacStateCfm.status);
}
/******************************************************************************
* This function is used to turn ON / turn OFF the receiver.
*
* Interface assumptions: None
* Return value: None
*
* Effects on Global Data: MAC PIBN
*
* Revison history:
* date Author Comments
* ------ ------ --------
* 200606 mwest2 Created
******************************************************************************/
void BUtl_ChangeReceiverStatus
(
uint8_t requestedStatus
)
{
uint16_t i = 0; /* Dummy counter TBC*/
if (requestedStatus == FALSE) {
( void )NWK_INFOBASE_SetPIBAttributeValue( gMPibRxOnWhenIdle_c,
&requestedStatus );
while ((GetMacStateReq() != gAspMacStateIdle_c) && (i++ < mNumRetries_c)){
Mlme_Main( gMacEventMemMlmeMsgQueued_c | gMacEventNwkMcpsMsgQueued_c |
gMacEventNwkMlmeMsgQueued_c | gMacEventMemAspMsgQueued_c);
} /*while...*/
} else {
/*requestedStatus == TRUE */
#if ( gRouterCapability_d == 1) || gCoordinatorCapability_d == 1)
( void )NWK_INFOBASE_SetPIBAttributeValue( gMPibRxOnWhenIdle_c,
&requestedStatus );
#endif
#if (gEndDevCapability_d == 1)
if( ( GetZdoNvmPtr->macCapFlags ) & gCapInfoRcvrOnIdle_c ){
( void )NWK_INFOBASE_SetPIBAttributeValue( gMPibRxOnWhenIdle_c,
&requestedStatus );
}
#endif /*EndDevCapability_d == 1*/
} /*else */
}
/*****************************************************************************
******************************************************************************
* Private Debug stuff
******************************************************************************
*****************************************************************************/
/* None */
#endif /*(gNV_FlashIncluded_d)*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -