本文整理汇总了C++中HAL_FLASH_Program函数的典型用法代码示例。如果您正苦于以下问题:C++ HAL_FLASH_Program函数的具体用法?C++ HAL_FLASH_Program怎么用?C++ HAL_FLASH_Program使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HAL_FLASH_Program函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: flash_write
void flash_write(const uint32_t *src, uint32_t dst, uint32_t size)
{
// Unlock flash
HAL_FLASH_Unlock();
#if defined(MCU_SERIES_H7)
// Program the flash 32 bytes at a time.
for (int i=0; i<size/32; i++) {
if (HAL_FLASH_Program(TYPEPROGRAM_WORD, dst, (uint64_t)(uint32_t) src) != HAL_OK) {
// error occurred during flash write
HAL_FLASH_Lock(); // lock the flash
__fatal_error();
}
src += 8;
dst += 32;
}
#else
// Program the flash 4 bytes at a time.
for (int i=0; i<size/4; i++) {
if (HAL_FLASH_Program(TYPEPROGRAM_WORD, dst, *src) != HAL_OK) {
// error occurred during flash write
HAL_FLASH_Lock(); // lock the flash
__fatal_error();
}
src += 1;
dst += 4;
}
#endif
// lock the flash
HAL_FLASH_Lock();
}
开发者ID:openmv,项目名称:openmv,代码行数:32,代码来源:flash.c
示例2: flash_program_page
/** Program one page starting at defined address
*
* The page should be at page boundary, should not cross multiple sectors.
* This function does not do any check for address alignments or if size
* is aligned to a page size.
* @param obj The flash object
* @param address The sector starting address
* @param data The data buffer to be programmed
* @param size The number of bytes to program
* @return 0 for success, -1 for error
*/
int32_t flash_program_page(flash_t *obj, uint32_t address,
const uint8_t *data, uint32_t size)
{
uint32_t StartAddress = 0;
int32_t status = 0;
if ((address >= (FLASH_BASE + FLASH_SIZE)) || (address < FLASH_BASE)) {
return -1;
}
if ((size % 8) != 0) {
/* L4 flash devices can only be programmed 64bits/8 bytes at a time */
return -1;
}
if (flash_unlock() != HAL_OK) {
return -1;
}
/* Program the user Flash area word by word */
StartAddress = address;
/* HW needs an aligned address to program flash, which data
* parameters doesn't ensure */
if ((uint32_t) data % 4 != 0) {
volatile uint64_t data64;
while ((address < (StartAddress + size)) && (status == 0)) {
for (uint8_t i =0; i < 8; i++) {
*(((uint8_t *) &data64) + i) = *(data + i);
}
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, address, data64)
== HAL_OK) {
address = address + 8;
data = data + 8;
} else {
status = -1;
}
}
} else { /* case where data is aligned, so let's avoid any copy */
while ((address < (StartAddress + size)) && (status == 0)) {
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, address,
*((uint64_t*) data))
== HAL_OK) {
address = address + 8;
data = data + 8;
} else {
status = -1;
}
}
}
flash_lock();
return status;
}
开发者ID:Archcady,项目名称:mbed-os,代码行数:67,代码来源:flash_api.c
示例3: flash_program_page
int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data, uint32_t size)
{
uint32_t StartAddress = 0;
int32_t status = 0;
if (!(IS_FLASH_PROGRAM_ADDRESS(address))) {
return -1;
}
if ((size % MIN_PROG_SIZE) != 0) {
return -1;
}
if (flash_unlock() != HAL_OK) {
return -1;
}
/* Program the user Flash area word by word */
StartAddress = address;
/* HW needs an aligned address to program flash, which data parameter doesn't ensure */
if ((uint32_t) data % 4 != 0) {
volatile uint32_t data32;
while (address < (StartAddress + size) && (status == 0)) {
for (uint8_t i = 0; i < MIN_PROG_SIZE; i++) {
*(((uint8_t *) &data32) + i) = *(data + i);
}
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, address, data32) == HAL_OK) {
address = address + MIN_PROG_SIZE;
data = data + MIN_PROG_SIZE;
} else {
status = -1;
}
}
} else { /* case where data is aligned, so let's avoid any copy */
while ((address < (StartAddress + size)) && (status == 0)) {
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, address, *((uint32_t*) data)) == HAL_OK) {
address = address + MIN_PROG_SIZE;
data = data + MIN_PROG_SIZE;
} else {
status = -1;
}
}
}
flash_lock();
return status;
}
开发者ID:mbedNoobNinja,项目名称:mbed,代码行数:51,代码来源:flash_api.c
示例4: EE_VerifyPageFullWriteVariable
/**
* @brief Verify if active page is full and Writes variable in EEPROM.
* @param VirtAddress: 16 bit virtual address of the variable
* @param Data: 16 bit data to be written as variable value
* @retval Success or error status:
* - FLASH_COMPLETE: on success
* - PAGE_FULL: if valid page is full
* - NO_VALID_PAGE: if no valid page was found
* - Flash error code: on write Flash error
*/
static uint16_t EE_VerifyPageFullWriteVariable(uint16_t VirtAddress, uint16_t Data)
{
HAL_StatusTypeDef FlashStatus = HAL_OK;
uint16_t ValidPage = PAGE0;
uint32_t Address = EEPROM_START_ADDRESS, PageEndAddress = EEPROM_START_ADDRESS+PAGE_SIZE;
/* Get valid Page for write operation */
ValidPage = EE_FindValidPage(WRITE_IN_VALID_PAGE);
/* Check if there is no valid page */
if (ValidPage == NO_VALID_PAGE)
{
return NO_VALID_PAGE;
}
/* Get the valid Page start Address */
Address = (uint32_t)(EEPROM_START_ADDRESS + (uint32_t)(ValidPage * PAGE_SIZE));
/* Get the valid Page end Address */
PageEndAddress = (uint32_t)((EEPROM_START_ADDRESS - 1) + (uint32_t)((ValidPage + 1) * PAGE_SIZE));
/* Check each active page address starting from begining */
while (Address < PageEndAddress)
{
/* Verify if Address and Address+2 contents are 0xFFFFFFFF */
if ((*(__IO uint32_t*)Address) == 0xFFFFFFFF)
{
/* Set variable data */
FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, Address, Data);
/* If program operation was failed, a Flash error code is returned */
if (FlashStatus != HAL_OK)
{
return FlashStatus;
}
/* Set variable virtual address */
FlashStatus = HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, Address + 2, VirtAddress);
/* Return program operation status */
return FlashStatus;
}
else
{
/* Next address location */
Address = Address + 4;
}
}
/* Return PAGE_FULL in case the valid page is full */
return PAGE_FULL;
}
开发者ID:z80,项目名称:stm32f429,代码行数:59,代码来源:eeprom.c
示例5: FLASH_If_Write
/**
* @brief This function writes a data buffer in flash (data are 32-bit aligned).
* @note After writing data buffer, the flash content is checked.
* @param destination: start address for target location
* @param p_source: pointer on buffer with data to write
* @param length: length of data buffer (unit is 32-bit word)
* @retval uint32_t 0: Data successfully written to Flash memory
* 1: Error occurred while writing data in Flash memory
* 2: Written Data in flash memory is different from expected one
*/
uint32_t FLASH_If_Write(uint32_t destination, uint32_t *p_source, uint32_t length)
{
uint32_t i = 0;
/* Unlock the Flash to enable the flash control register access *************/
HAL_FLASH_Unlock();
for (i = 0; (i < length) && (destination <= (USER_FLASH_END_ADDRESS-4)); i++)
{
/* Device voltage range supposed to be [2.7V to 3.6V], the operation will
be done by word */
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, destination, *(uint32_t*)(p_source+i)) == HAL_OK)
{
/* Check the written value */
if (*(uint32_t*)destination != *(uint32_t*)(p_source+i))
{
/* Flash content doesn't match SRAM content */
return(FLASHIF_WRITINGCTRL_ERROR);
}
/* Increment FLASH destination address */
destination += 4;
}
else
{
/* Error occurred while writing data in Flash memory */
return (FLASHIF_WRITING_ERROR);
}
}
/* Lock the Flash to disable the flash control register access (recommended
to protect the FLASH memory against possible unwanted operation) *********/
HAL_FLASH_Lock();
return (FLASHIF_OK);
}
开发者ID:NjordCZ,项目名称:stm32cubef0,代码行数:45,代码来源:flash_if.c
示例6: writeEEPROM
// FIXME: HAL for now this will only work for F4/F7 as flash layout is different
void writeEEPROM(void)
{
// Generate compile time error if the config does not fit in the reserved area of flash.
BUILD_BUG_ON(sizeof(master_t) > FLASH_TO_RESERVE_FOR_CONFIG);
HAL_StatusTypeDef status;
uint32_t wordOffset;
int8_t attemptsRemaining = 3;
suspendRxSignal();
// prepare checksum/version constants
masterConfig.version = EEPROM_CONF_VERSION;
masterConfig.size = sizeof(master_t);
masterConfig.magic_be = 0xBE;
masterConfig.magic_ef = 0xEF;
masterConfig.chk = 0; // erase checksum before recalculating
masterConfig.chk = calculateChecksum((const uint8_t *) &masterConfig, sizeof(master_t));
// write it
/* Unlock the Flash to enable the flash control register access *************/
HAL_FLASH_Unlock();
while (attemptsRemaining--)
{
/* Fill EraseInit structure*/
FLASH_EraseInitTypeDef EraseInitStruct = {0};
EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;
EraseInitStruct.VoltageRange = FLASH_VOLTAGE_RANGE_3; // 2.7-3.6V
EraseInitStruct.Sector = (FLASH_SECTOR_TOTAL-1);
EraseInitStruct.NbSectors = 1;
uint32_t SECTORError;
status = HAL_FLASHEx_Erase(&EraseInitStruct, &SECTORError);
if (status != HAL_OK)
{
continue;
}
else
{
for (wordOffset = 0; wordOffset < sizeof(master_t); wordOffset += 4)
{
status = HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, CONFIG_START_FLASH_ADDRESS + wordOffset, *(uint32_t *) ((char *) &masterConfig + wordOffset));
if(status != HAL_OK)
{
break;
}
}
}
if (status == HAL_OK) {
break;
}
}
HAL_FLASH_Lock();
// Flash write failed - just die now
if (status != HAL_OK || !isEEPROMContentValid()) {
failureMode(FAILURE_FLASH_WRITE_FAILED);
}
resumeRxSignal();
}
开发者ID:tianbin4279,项目名称:betaflight,代码行数:61,代码来源:config_eeprom.c
示例7: WriteFlash
HAL_StatusTypeDef WriteFlash(int32_t* table, uint32_t Address, uint32_t lenth)
{
HAL_StatusTypeDef res;
HAL_FLASH_Unlock();
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |
FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR);
/* Erase the user Flash area
(area defined by FLASH_USER_START_ADDR and FLASH_USER_END_ADDR) ***********/
EraseFlash(Address);
for(int i=0;i<lenth;i++)
HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD,Address+4*i,*(table+i));
res = HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD,Address+4*lenth-4,table[lenth-1]);
HAL_FLASH_Lock();
return res;
}
开发者ID:StefanJia,项目名称:test2,代码行数:16,代码来源:flash.c
示例8: EE_Format
/**
* @brief Erases PAGE and PAGE1 and writes VALID_PAGE header to PAGE
* @param None
* @retval Status of the last operation (Flash write or erase) done during
* EEPROM formating
*/
static HAL_StatusTypeDef EE_Format(void)
{
HAL_StatusTypeDef OperationStatus = HAL_OK;
/* Erase Page0 */
FLASH_Erase_Sector(PAGE0_ID, VOLTAGE_RANGE);
/* If erase operation was failed, a Flash error code is returned */
OperationStatus = FLASH_WaitForLastOperation(1000);
if(OperationStatus != HAL_OK)
{
return OperationStatus;
}
/* Set Page0 as valid page: Write VALID_PAGE at Page0 base address */
OperationStatus = HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, PAGE0_BASE_ADDRESS, VALID_PAGE);
/* If program operation was failed, a Flash error code is returned */
if (OperationStatus != HAL_OK)
{
return OperationStatus;
}
/* Erase Page1 */
FLASH_Erase_Sector(PAGE1_ID, VOLTAGE_RANGE);
OperationStatus = FLASH_WaitForLastOperation(1000);
if(OperationStatus != HAL_OK)
{
return OperationStatus;
}
/* Return Page1 erase operation status */
return OperationStatus;
}
开发者ID:javifercep,项目名称:MuBABoot,代码行数:38,代码来源:eeprom.c
示例9: Flash_If_Write
/**
* @brief Writes Data into Memory.
* @param src: Pointer to the source buffer. Address to be written to.
* @param dest: Pointer to the destination buffer.
* @param Len: Number of data to be written (in bytes).
* @retval 0 if operation is successeful, MAL_FAIL else.
*/
uint16_t Flash_If_Write(uint8_t *src, uint8_t *dest, uint32_t Len)
{
uint32_t i = 0;
for(i = 0; i < Len; i+=4)
{
/* Device voltage range supposed to be [2.7V to 3.6V], the operation will
be done by byte */
if(HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, (uint32_t)(dest+i), *(uint32_t*)(src+i)) == HAL_OK)
{
/* Check the written value */
if(*(uint32_t *)(src + i) != *(uint32_t*)(dest+i))
{
/* Flash content doesn't match SRAM content */
return 2;
}
}
else
{
/* Error occurred while writing data in Flash memory */
return 1;
}
}
return 0;
}
开发者ID:z80,项目名称:stm32f429,代码行数:32,代码来源:usbd_dfu_flash.c
示例10: stm32f3_flash_program
/**
* @brief Write data to flash memory
*
* @param dev
* @param base
* @param data
* @param len
*
* @return Negative error code
*/
static int stm32f3_flash_program(struct flash_dev *dev, uint32_t base, const void* data, size_t len) {
int err = 0;
int offset;
if (!stm32f3_flash_check_align(base, len)
|| ((uintptr_t) data & 0x1) != 0) {
return -EINVAL;
}
if (!stm32f3_flash_check_range(dev, base, len)) {
return -EFBIG;
}
HAL_FLASH_Unlock();
/* Write data halfword by halfword */
for (offset = 0; offset < len; offset += 2) {
if (HAL_OK != HAL_FLASH_Program(TYPEPROGRAM_HALFWORD,
dev->start + base + offset,
*((uint32_t*) data + offset)))
return -1; /* TODO: set appropriate code */
}
/* Lock to prevent unwanted operations with flash memory */
HAL_FLASH_Lock();
return err;
}
开发者ID:AleksandraButrova,项目名称:embox,代码行数:38,代码来源:stm32f3_flash.c
示例11: program_flash_data
int program_flash_data(uint32_t start, uint32_t size, uint8_t *data)
{
uint64_t data64;
uint32_t offset = 0;
while (offset < size) {
data64 = 0xFFFFFFFFFFFFFFFF;
if((size - offset) < 8) {
memcpy((uint8_t *)&data64, (uint8_t *)&data[offset], (size - offset));
} else {
memcpy((uint8_t *)&data64, (uint8_t *)&data[offset], 8);
}
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, start, data64) == HAL_OK) {
start += 8;
offset += 8;
} else {
/* Error occurred while writing data in Flash memory.
User can add here some code to deal with this error */
while (1) {
}
}
}
return 0;
}
开发者ID:meisteg,项目名称:muc-loader,代码行数:25,代码来源:stm32l4xx_flash.c
示例12: stm32f4_flash_write
static int
stm32f4_flash_write(const struct hal_flash *dev, uint32_t address,
const void *src, uint32_t num_bytes)
{
const uint8_t *sptr;
uint32_t i;
int rc;
sptr = src;
/*
* Clear status of previous operation.
*/
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | \
FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR| FLASH_FLAG_PGSERR);
for (i = 0; i < num_bytes; i++) {
rc = HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, address, sptr[i]);
if (rc != 0) {
return rc;
}
address++;
}
return 0;
}
开发者ID:ccollins476ad,项目名称:incubator-mynewt-core,代码行数:25,代码来源:hal_flash.c
示例13: FLASH_If_Write
/**
* @brief This function writes a data buffer in flash (data are 32-bit aligned).
* @note After writing data buffer, the flash content is checked.
* @param FlashAddress: start address for writing data buffer
* @param Data: pointer on data buffer
* @param DataLength: length of data buffer (unit is 32-bit word)
* @retval 0: Data successfully written to Flash memory
* 1: Error occurred while writing data in Flash memory
* 2: Written Data in flash memory is different from expected one
*/
uint32_t FLASH_If_Write(__IO uint32_t* FlashAddress, uint32_t* Data ,uint16_t DataLength)
{
uint32_t i = 0;
for (i = 0; (i < DataLength) && (*FlashAddress <= (USER_FLASH_END_ADDRESS-4)); i++)
{
/* Device voltage range supposed to be [2.7V to 3.6V], the operation will
be done by word */
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, *FlashAddress, *(uint32_t*)(Data+i)) == HAL_OK)
{
/* Check the written value */
if (*(uint32_t*)*FlashAddress != *(uint32_t*)(Data+i))
{
/* Flash content doesn't match SRAM content */
return(2);
}
/* Increment FLASH destination address */
*FlashAddress += 4;
}
else
{
/* Error occurred while writing data in Flash memory */
return (1);
}
}
return (0);
}
开发者ID:451506709,项目名称:automated_machine,代码行数:38,代码来源:flash_if.c
示例14: SaveSSIDPasswordToMemory
/**
* @brief Save Access Point parameters to FLASH
* @param None
* @retval System_Status_t (MODULE_SUCCESS/MODULE_ERROR)
*/
System_Status_t SaveSSIDPasswordToMemory(void)
{
System_Status_t status = MODULE_ERROR;
/* Reset Before The data in Memory */
status = ResetSSIDPasswordInMemory();
if (status) {
/* Store in Flash Memory */
uint32_t Address = BLUEMSYS_FLASH_ADD;
int32_t WriteIndex;
/* Unlock the Flash to enable the flash control register access *************/
HAL_FLASH_Unlock();
/* Write the Magic Number */
{
uint32_t MagicNumber = WIFI_CHECK_SSID_KEY;
if (HAL_FLASH_Program(TYPEPROGRAM_WORD, Address,MagicNumber) == HAL_OK) {
Address = Address + 4;
} else {
printf("\r\nError while writing in FLASH");
status = MODULE_ERROR;
}
}
/* Write the Wifi */
for (WriteIndex=0;WriteIndex<UNION_DATA_SIZE;WriteIndex++) {
if (HAL_FLASH_Program(TYPEPROGRAM_WORD, Address,UnionWifiToken.Data[WriteIndex]) == HAL_OK){
Address = Address + 4;
} else {
printf("\r\nError while writing in FLASH");
status = MODULE_ERROR;
}
}
/* Lock the Flash to disable the flash control register access (recommended
to protect the FLASH memory against possible unwanted operation) *********/
HAL_FLASH_Lock();
printf("\n\rSaveSSIDPasswordToMemory OK");
} else {
printf("\n\rError while resetting FLASH memory");
}
return status;
}
开发者ID:nguyendinhthi,项目名称:nguyendinh,代码行数:52,代码来源:wifi_support.c
示例15: program_flash_dword
int program_flash_dword(const uint64_t *dword)
{
int rv;
dbgprintx32("program_flash_dword ", PARTITION_FLASHMODE_START, "\r\n");
rv = HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, PARTITION_FLASHMODE_START, *dword);
return rv;
}
开发者ID:meisteg,项目名称:muc-loader,代码行数:8,代码来源:stm32l4xx_flash.c
示例16: hacs_pstore_set
int hacs_pstore_set(hacs_pstore_type_t ent, uint8_t *wbuf, uint32_t byte_len)
{
uint32_t ent_addr = hacs_pstore_ent_rel_addr[ent];
hacs_pstore_entry_t *ent_header;
hacs_pstore_header_t *bank_header;
uint8_t *buf_ptr;
uint32_t counter;
uint32_t temp;
uint32_t sector;
int retval;
// Read in the entire current bank
memcpy(ram_buf, (uint8_t*)current_bank_addr, HACS_PSTORE_BANK_SIZE);
// Check entry size. Make sure we are not writing something too big.
retval = -HACS_INVALID_ARGS;
HACS_REQUIRES(byte_len <= hacs_pstore_ent_size[ent], done);
// Update entry content
buf_ptr = (uint8_t*)(ram_buf + ent_addr + sizeof(hacs_pstore_entry_t));
memcpy(buf_ptr, wbuf, byte_len);
// Update entry header
ent_header = (hacs_pstore_entry_t*)(ram_buf + ent_addr);
ent_header->byte_len = byte_len;
ent_header->crc = hacs_crc32_calc(wbuf, byte_len); // each entry has its own CRC
// Update bank header
bank_header = (hacs_pstore_header_t *)ram_buf;
bank_header->bank_version++;
bank_header->layout_version = HACS_PSTORE_LAYOUT_VERSION;
// Write the ram buffer to the alternate bank
HAL_FLASH_Unlock();
sector = (alternate_bank_addr == HACS_PSTORE_0_ADDR) ? HACS_PSTORE_0_SECTOR : HACS_PSTORE_1_SECTOR;
FLASH_Erase_Sector(sector, VOLTAGE_RANGE_3);
// Write the ram buffer word by word.
counter = 0;
while(counter < sizeof(ram_buf)) {
HAL_FLASH_Program(TYPEPROGRAM_WORD, alternate_bank_addr+counter,
*(uint32_t*)(ram_buf+counter)); // unaligned access supported
counter += 4;
}
// Note that I exploit the fact that the ram buffer is word-aligned
// (its length is multiple of 4).
assert(counter == sizeof(ram_buf));
HAL_FLASH_Lock();
// Switch current bank and alternate bank
temp = alternate_bank_addr;
alternate_bank_addr = current_bank_addr;
current_bank_addr = temp;
retval = HACS_NO_ERROR;
done:
return retval;
}
开发者ID:gzwsc2007,项目名称:Hobby_Airplane_Control_System,代码行数:57,代码来源:hacs_pstore.c
示例17: main
int main(void)
{
HAL_StatusTypeDef status;
FLASH_EraseInitTypeDef eraseInit;
uint32_t sectorError;
uint32_t *ptr=ADDRESS_SECTOR_18;
uint32_t checkCR;
int guard=0;
while(1){
status=HAL_FLASH_Unlock();
//this guard function is to program the Flash
if(guard){
while(status==HAL_BUSY);
status=HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, ADDRESS_SECTOR_18, DATA_PROGRAM);
while(status==HAL_BUSY);
guard=0;
}
//this guard function is to sector erase the Flash
if(guard){
flashEraseInit(&eraseInit,
FLASH_TYPEERASE_SECTORS,
0,
FLASH_SECTOR_18,
1,
FLASH_VOLTAGE_RANGE_3);
while(status==HAL_BUSY);
HAL_FLASHEx_Erase(&eraseInit,§orError);
while(status==HAL_BUSY);
guard=0;
}
//this guard function is to Mass erase the Flash
if(guard){
flashEraseInit(&eraseInit,
FLASH_TYPEERASE_MASSERASE,
0,
0,
1,
FLASH_VOLTAGE_RANGE_3);
while(status==HAL_BUSY);
HAL_FLASHEx_Erase(&eraseInit,§orError);
while(status==HAL_BUSY);
guard=0;
}
status=HAL_FLASH_Lock();
}
}
开发者ID:JangSing,项目名称:stm32f429_Flash_Hal,代码行数:56,代码来源:main.c
示例18: flash_write
void flash_write(uint32_t flash_dest, const uint32_t *src, uint32_t num_word32) {
#if defined(MCU_SERIES_L4)
// program the flash uint64 by uint64
for (int i = 0; i < num_word32 / 2; i++) {
uint64_t val = *(uint64_t*)src;
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, flash_dest, val) != HAL_OK) {
// error occurred during flash write
HAL_FLASH_Lock(); // lock the flash
return;
}
flash_dest += 8;
src += 2;
}
if ((num_word32 & 0x01) == 1) {
uint64_t val = *(uint64_t*)flash_dest;
val = (val & 0xffffffff00000000uL) | (*src);
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, flash_dest, val) != HAL_OK) {
// error occurred during flash write
HAL_FLASH_Lock(); // lock the flash
return;
}
}
#else
// program the flash word by word
for (int i = 0; i < num_word32; i++) {
if (HAL_FLASH_Program(TYPEPROGRAM_WORD, flash_dest, *src) != HAL_OK) {
// error occurred during flash write
HAL_FLASH_Lock(); // lock the flash
return;
}
flash_dest += 4;
src += 1;
}
#endif
// lock the flash
HAL_FLASH_Lock();
}
开发者ID:19emtuck,项目名称:micropython,代码行数:42,代码来源:flash.c
示例19: EPS_set_memory_word
//set word from a specific memory address: remote debug session.
void EPS_set_memory_word(uint32_t memory_address, uint32_t *memory_data){
uint32_t flash_write_value = *memory_data;
/* write to memory the proper status true value */
HAL_FLASH_Unlock();
HAL_FLASH_Program(TYPEPROGRAM_WORD, memory_address, flash_write_value);
HAL_FLASH_Lock();
}
开发者ID:nchronas,项目名称:upsat-eps-software,代码行数:12,代码来源:eps_non_volatile_mem_handling.c
示例20: flash_write
void flash_write(uint32_t flash_dest, const uint32_t *src, uint32_t num_word32) {
// program the flash word by word
for (int i = 0; i < num_word32; i++) {
if (HAL_FLASH_Program(TYPEPROGRAM_WORD, flash_dest, *src) != HAL_OK) {
// error occurred during flash write
HAL_FLASH_Lock(); // lock the flash
return;
}
flash_dest += 4;
src += 1;
}
// lock the flash
HAL_FLASH_Lock();
}
开发者ID:ashtons,项目名称:micropython,代码行数:15,代码来源:flash.c
注:本文中的HAL_FLASH_Program函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论