return iNumByteToWrite;
}
/**
* @brief Programs a half word at a specified Option Byte Data address.
* @NOTE This function can be used for all STM32F10x devices.
* @param Address: specifies the address to be programmed.
* @param buf: specifies the data to be programmed.
* @param iNbrToWrite: the number to write into flash
* @retval if success return the number to write, -1 if error
*
*/
int Flash_Write(uint32_t iAddress, uint8_t *buf, uint32_t iNbrToWrite) {
/* Unlock the Flash Bank1 Program Erase controller */
uint32_t secpos;
uint32_t iNumByteToWrite = iNbrToWrite;
uint16_t secoff;
uint16_t secremain;
uint16_t i = 0;
uint8_t tmp[FLASH_PAGE_SIZE];
/**
* @brief Programs a half word at a specified Option Byte Data address.
* @note This function can be used for all STM32F10x devices.
* @param Address: specifies the address to be programmed.
* @param buf: specifies the data to be programmed.
* @param iNbrToWrite: the number to read from flash
* @retval if success return the number to write, without error
*
*/
int Flash_Read(uint32_t iAddress, uint8_t *buf, int32_t iNbrToRead) {
int i = 0;
while(i < iNbrToRead ) {
*(buf + i) = *(__IO uint8_t*) iAddress++;
i++;
}
return i;
}