/* Programs n byte at a specified start address.  */
void FLASH_ProgramByte(uint32_t Addr, uint8_t *ByteBuffer, uint32_t Length)
/* Programs n byte at a specified start address.  */
void FLASH_ProgramByte(uint32_t Addr, uint8_t *ByteBuffer, uint32_t Length)
{
  uint32_t i;
  assert_parameters(IS_FLASH_ADDRESS(Addr));
  FLASH->PGADDR = Addr;
  FLASH->PASS = FLASH_PASS_KEY;
  for (i=0; i<Length; i++)
  {
    if (((Addr + i)&0x3) == 0)
      *((__IO uint8_t*)(&FLASH->PGDATA)) = *(ByteBuffer++);
    else if (((Addr + i)&0x3) == 1)
      *((__IO uint8_t*)(&FLASH->PGDATA) + 1) = *(ByteBuffer++);
    else if (((Addr + i)&0x3) == 2)
      *((__IO uint8_t*)(&FLASH->PGDATA) + 2) = *(ByteBuffer++);
    else
      *((__IO uint8_t*)(&FLASH->PGDATA) + 3) = *(ByteBuffer++);
    while (FLASH->STS != 1); 
  }
  FLASH->PASS = 0;
}