STM32L031 HAL库读写内部EEprom

//字节写
void FLASHEx_EEPROM_WRITE(uint16_t Address, uint8_t *Data, uint8_t len)
{
	uint8_t i;

	HAL_FLASHEx_DATAEEPROM_Unlock();
	for(i=0;i<len;i++)
	{
		status=HAL_FLASHEx_DATAEEPROM_Program(FLASH_TYPEPROGRAMDATA_BYTE,DATA_EEPROM_ADDR+Address+i,*Data);
		Data++;
	}
	HAL_FLASHEx_DATAEEPROM_Lock();
}
//字节读
void FLASHEx_EEPROM_READ(uint16_t Addr,uint8_t *Buffer,uint16_t Length)
{
	uint8_t *wAddr;
	wAddr=(uint8_t *)(DATA_EEPROM_ADDR+Addr);
	while(Length--)
	{
		*Buffer++=*wAddr++;
	}	
}

你可能感兴趣的:(嵌入式)