void Write_Memory_Command(void)
{
uint16_t WriteCounter= 0;
uint16_t Number_Bytes_Transferred = 0;
uint32_t Add_Flash,DATA_SIZE_IN_PAGE = 0;
uint16_t Idx = 0;
/* Wait until receiving Flash address to write into + number of data to be written
+ the data to be written */
while (Rx_Idx!= 0);
/* Read the address */
Add_Flash = Read_Add();
/* Read the number of bytes to be written */
Number_Bytes_Transferred = Read_Byte_Page_Number();
if (Number_Bytes_Transferred <= PAGE_SIZE)
{
DATA_SIZE_IN_PAGE = 1;
}
else
{
if ((Number_Bytes_Transferred%PAGE_SIZE)==0)
{
DATA_SIZE_IN_PAGE= Number_Bytes_Transferred/PAGE_SIZE;
}
else
{
DATA_SIZE_IN_PAGE=(uint32_t) (Number_Bytes_Transferred/PAGE_SIZE)+1;
}
}
for (Idx=4; Idx<(Number_Bytes_Transferred+8)/2; Idx++)
{
I2C1_Buffer_Rx[2*Idx+1]=I2C1_Buffer_Rx[2*Idx+1]<<8;
I2C1_Buffer_Rx[2*Idx]=I2C1_Buffer_Rx[2*Idx]|I2C1_Buffer_Rx[2*Idx+1];
}
#if defined USE_STM3210B_EVAL || USE_STM32100B_EVAL
Erase_Page(Add_Flash,DATA_SIZE_IN_PAGE);
#elif defined USE_STM3210E_EVAL || USE_STM3210C_EVAL
if (((Add_Flash/(PAGE_SIZE/(PAGE_SIZE/Number_Bytes_Transferred)))&1)==0)
{
Erase_Page(Add_Flash,DATA_SIZE_IN_PAGE);
}
#endif
for (WriteCounter = 0; (WriteCounter < (Number_Bytes_Transferred)/2 ); WriteCounter++)
{
FLASH_ProgramHalfWord((Add_Flash+2*WriteCounter), I2C1_Buffer_Rx[2*(WriteCounter+4)]);
}
opcode=0;
}
请问其中下面这句为什么Number_Bytes_Transferred要+8呢
for (Idx=4; Idx<(Number_Bytes_Transferred+8)/2; Idx++) |