/* Switches blocks by programming the current one and initializing the next.  */
static tFlashBlockInfo * FlashSwitchBlock(tFlashBlockInfo *block, blt_addr base_addr)
/* Switches blocks by programming the current one and initializing the next.  */
static tFlashBlockInfo * FlashSwitchBlock(tFlashBlockInfo *block, blt_addr base_addr)
{
  tFlashBlockInfo * result = BLT_NULL;
  if (block == &bootBlockInfo)
  {
    block = &blockInfo;
    result = block;
  }
  else if (base_addr == flashLayout[0].sector_start)
  {
    block = &bootBlockInfo;
    base_addr = flashLayout[0].sector_start;
    result = block;
  }
  else
  {
    result = block;
    if (FlashWriteBlock(block) == BLT_FALSE)
    {
      result = BLT_NULL;
    }
  }
  if (result != BLT_NULL)
  {
    if (FlashInitBlock(block, base_addr) == BLT_FALSE)
    {
      result = BLT_NULL;
    }
  }
  return result;
}