Hi Sorry for the later reply as i was not on duty due to sickness.
Have tried providing the requested details
Function 1 and 2 are used for initializing IAP.
Function 3 is used for writing into flash bank B
Function 4 is used for reading flash
I hope I have provided all the details, if not, please do ask specfically.
thanks and regards,
Jagdish
/ Function - 1 ***************************************************************/
* Function : Init_Iap()
* Purpose : IAP initialization
short Init_Iap(void)
{
short return_status = ERROR;
paramin[0] = IAP_INIT;
iap_entry(paramin, paramout);
return_status = paramout[0];
return( return_status );
}
/ Function - 2 ***************************************************************/
#define IAP_ENTRY_LOCATION (*((uint32_t *) 0x10400100))
/* IAP_ENTRY API function type */
typedef void (*IAP_ENTRY_T)(unsigned long[5], unsigned long[4]);
static INLINE void iap_entry(unsigned long cmd_param[], unsigned long status_result[])
{
((IAP_ENTRY_T) IAP_ENTRY_LOCATION)(cmd_param, status_result);
}
/ Function - 3 ***************************************************************/
/*--------------------------------------------------------------------------------
* Function : RamTo_Flash()
* Purpose : IAP operation copy data from RAM to flash ,command code 51
* Inputs : dest addr(flash)
* src addr(RAM)
* Number of Bytes
* Outputs :
* Returns : Return configuration status
*-------------------------------------------------------------------------------*/
short RamTo_Flash(unsigned long dst, unsigned long src, unsigned long byteswrt)
{
short return_status = VAL_ZERO;
paramin[0] = IAP_RAMTOFLASH;
paramin[1] = dst;
paramin[2] = src;
paramin[3] = byteswrt;
paramin[4] = SystemCoreClock / 1000;
paramin[5] = IAP_FLASH_BANK_B;
iap_entry(paramin, paramout);
return_status = paramout[0];
return(return_status);
}
/ Function - 4 ***************************************************************/
/*--------------------------------------------------------------------------------
* Function : Read_From_Flash (unsigned long int Flash_u16ByteAddress, unsigned long int Sector_Start_Add,
* unsigned char *Flash_arri8ReadBytes, unsigned long int Offset_Address, unsigned int Flash_i16NumberOfBytes)
* Purpose : Reads multiple Data bytes from the Flash
* Accepts : Flash_u16ByteAddress - Starting Read Address from where the data is to be read
Sector_Start_Add - Starting Address of the secor form where the data is to be Read
Flash_arri8ReadBytes - Pointer to the Array where data is to be copied
Offset_Address - Offest address of the data
Flash_i16NumberOfBytes - No of bytes to be Read
* Returns : None
*-------------------------------------------------------------------------------*/
void Read_From_Flash (unsigned long int Flash_u16ByteAddress, unsigned long int Sector_Start_Add,
unsigned char *Flash_arri8ReadBytes, unsigned long int Offset_Address, unsigned int Flash_i16NumberOfBytes)
{
unsigned char *destination;
unsigned int Temp_Byte_Count = 0;
unsigned int Byte_count = 0;
unsigned int Max_Byte_Count = 0;
#if DISABLE_INTERRUPT_DURING_IAP
__disable_irq();
#endif
Temp_Byte_Count = Flash_i16NumberOfBytes;
while (Temp_Byte_Count != 0)
{
destination = &Temp_Data[0];
memcpy((void *)destination, ((const void *)(Sector_Start_Add + Flash_u16ByteAddress - Offset_Address)), BYTES_512);
if (Temp_Byte_Count >= BYTES_512)
{
Max_Byte_Count = BYTES_512;
Temp_Byte_Count = Temp_Byte_Count - BYTES_512;
}
else
{
Max_Byte_Count = Temp_Byte_Count;
Temp_Byte_Count = Temp_Byte_Count - Temp_Byte_Count;
}
for (Byte_count = 0; Byte_count < Max_Byte_Count; Byte_count++)
{
*Flash_arri8ReadBytes = Temp_Data[Byte_count];
Flash_arri8ReadBytes++;
}
}
#if DISABLE_INTERRUPT_DURING_IAP
__enable_irq();
#endif
}