/* Programs n half-word at a specified start address.  */
void FLASH_ProgramHWord(uint32_t Addr, uint16_t *HWordBuffer, uint32_t Length)
/* Programs n half-word at a specified start address.  */
void FLASH_ProgramHWord(uint32_t Addr, uint16_t *HWordBuffer, uint32_t Length)
{
  uint32_t i;
  assert_parameters(IS_FLASH_ADRRHW(Addr));
  FLASH->PGADDR = Addr;
  FLASH->PASS = FLASH_PASS_KEY;
  for (i=0; i<Length; i++)
  {
    if (((Addr + 2*i)&0x3) == 0)
      *((__IO uint16_t*)(&FLASH->PGDATA)) = *(HWordBuffer++);
    else
      *((__IO uint16_t*)(&FLASH->PGDATA ) + 1) = *(HWordBuffer++);
    while (FLASH->STS != 1);
  }
  FLASH->PASS = 0;
}