示例#1
0
void read_protect(void)
{
	if(FLASH_GetReadOutProtectionStatus() != SET)
	{
	       FLASH_Unlock();//不解锁FALSH可能会导致无法正常设置读保护
	       FLASH_ReadOutProtection(ENABLE);
	}
}
示例#2
0
void FLASH_ReadOutProtection_Enable(void)
// If FLASH readout protection not already set, enable protection and reset device
// NOTES: The user area of the Flash memory can be protected against read by untrusted code.
//Protection is enabled only for firmware compiled with flag RELEASE_PUBLIC set (see makefile).
//When readout protection is set debugging via JTAG is not possible any more.
//If the read protection is set while the debugger is still connected through JTAG/SWD, apply a
//POR (power-on reset) instead of a system reset (without debugger connection).
{
	if (FLASH_GetReadOutProtectionStatus() != SET)
	{
#ifdef RELEASE_PUBLIC // HINT: define is done via makefile
	FLASH_Unlock();
	if (FLASH_ReadOutProtection(ENABLE) != FLASH_COMPLETE) // set readout protection
	{
	// ERROR: could not program read protection
	}
	else
	NVIC_SystemReset(); // protection set --> reset device to enable protection
#else
	// output warning message
#endif
	}
}