/* ** =================================================================== ** Method : IFsh1_LaunchCmdAndTestError (component IntFLASH) ** ** Description : ** This method executes flash command and tests result of the ** operation. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ static byte IFsh1_LaunchCmdAndTestError(byte Command_, IFsh1_TAddress Addr_, byte Value_) { /*lint -save -e740 -e931 -e926 -e927 -e928 -e929 Disable MISRA rule (1.2,11.4) checking. */ TFnCmdInRamStruct FnCmdInRam = *(TFnCmdInRamStruct *)(FnCmdInRam_); /*lint -restore Enable MISRA rule (1.2,11.4) checking. */ SaveStatusReg(); /* Save the PS register */ FSTAT = 0x00U; /* Init. flash engine */ if ((FSTAT & BM_FLASH_ERR_MASK) != 0U) { /* Protection violation or access error? */ FSTAT = BM_FLASH_ERR_MASK; /* Clear FPVIOL & FACERR flag */ } *(volatile byte *) (Addr_) = Value_; /* Write data to the flash memory */ /*lint -save -e740 -e931 -e926 -e927 -e928 -e929 Disable MISRA rule (1.2,11.4) checking. */ ((PFnCmdInRam)&FnCmdInRam)(Command_); /* Call code in RAM */ /*lint -restore Enable MISRA rule (1.2,11.4) checking. */ RestoreStatusReg(); /* Restore the PS register */ if ((FSTAT & BM_FLASH_ERR_MASK) != 0U) { /* Error detected? */ if ((FSTAT_FPVIOL) != 0U) { /* Protect violation? */ return ERR_PROTECT; /* Return error code ERR_PROTECT */ } else { return ERR_NOTAVAIL; /* Return error code ERR_NOTAVAIL */ } } return ERR_OK; }
/* Set the output compare register value and enable timer interrupt */ INLINE void vMBPortTimersEnable( ) { /* Enable the timer with the timeout passed to xMBPortTimersInit( ) */ SaveStatusReg( ); TPM1C0V = TPM1CNT + usDelta; RestoreStatusReg( ); if( TPM1C0SC_CH0F ) TPM1C0SC_CH0F = FALSE; TPM1C0SC_CH0IE = TRUE; }
/* ** =================================================================== ** Method : IFsh1_NonDestructiveUnsecureWrite (component IntFLASH) ** ** Description : ** This method performs Non-destructive unsecure write. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ byte IFsh1_NonDestructiveUnsecureWrite(IFsh1_TAddress src, IFsh1_TAddress dst, word size) { byte tmp; /* Temporary read current destination value */ /*lint -save -e740 -e931 -e926 -e927 -e928 -e929 Disable MISRA rule (1.2,11.4) checking. */ TFnCmdInRamStruct FnCmdInRam = *(TFnCmdInRamStruct *)(FnCmdInRam_); /*lint -restore Enable MISRA rule (1.2,11.4) checking. */ if ((FSTAT_FCCF) == 0U) { /* Is previous command completed ? */ return ERR_BUSY; /* If no then error */ } SaveStatusReg(); /* Save status information and disable interrupts(if enabled) */ FSTAT = 0x00U; /* Init. flash engine */ if ((FSTAT & BM_FLASH_ERR_MASK) != 0U) { /* Protection violation or access error? */ FSTAT = BM_FLASH_ERR_MASK; /* Clear FPVIOL & FACERR flag */ } /* Burn data into FLASH */ while (size--) { /* For all written bytes do: */ tmp = *(byte *)dst; /* Read current byte value from FLASH */ if (*(byte *)src != tmp) { /* Is the src. byte equal to the dest. byte? */ *(byte *)dst = *(byte *)src | (byte)~(byte)tmp; /* Write byte to the flash memory, do not modify zero bits */ /*lint -save -e740 -e931 -e926 -e927 -e928 -e929 Disable MISRA rule (1.2,11.4) checking. */ ((PFnCmdInRam)&FnCmdInRam)(FCMD_BURST_PROGRAM); /* Call code in ram */ /*lint -restore Enable MISRA rule (1.2,11.4) checking. */ } ++dst; /* Increment destination pointer */ ++src; /* Increment source pointer */ } /* while size */ RestoreStatusReg(); /* Restore status information and interrupt state */ if ((FSTAT & BM_FLASH_ERR_MASK) != 0U) { /* Error detected? */ if ((FSTAT_FPVIOL) != 0U) { /* Protect violation? */ return ERR_PROTECT; /* Return error code ERR_PROTECT */ } else { return ERR_NOTAVAIL; /* Return error code ERR_NOTAVAIL */ } } return ERR_OK; }