//
// SCI_GetPacket - This routine receives the packet, returns the
//                 command and puts the data length in Uin16* length
//                 and data in Uint16* data
//
Uint16 SCI_GetPacket(Uint16* length, Uint16* data)
{
    if(SCIA_GetOnlyWordData() != 0x1BE4)
    {
        SendNAK();
        return(100); //start packet error
    }

    *length = SCIA_GetOnlyWordData();

    checksum = 0; //checksum of command and data
    Uint16 command = SCIA_GetOnlyWordData();

    int i = 0;
    for(i = 0; i < (*length)/2; i++)
    {
        *(data+i) = SCIA_GetOnlyWordData();
    }

    Uint16 dataChecksum = checksum;
    if(dataChecksum != SCIA_GetOnlyWordData())
    {
        SendNAK();
        return(101); //checksum error
    }
    if(SCIA_GetOnlyWordData() != 0xE41B)
    {
        SendNAK();
        return(102); //end packet error
    }

    SendACK();
    return(command);
}
Uint32 SCI_Boot()
{
   Uint32 EntryAddr;

   // Asign GetWordData to the SCI-A version of the
   // function.  GetOnlyWordData is a pointer to a function.
   // This version doesn't send echo back each character.
   GetOnlyWordData = SCIA_GetOnlyWordData;

   SCIA_Init();
   SCIA_AutobaudLock();
   checksum = 0;

   // If the KeyValue was invalid, abort the load
   // and return the flash entry point. 
   if (SCIA_GetOnlyWordData() != 0x08AA) return FLASH_ENTRY_POINT;

   ReadReservedFn();

   EntryAddr = GetLongData();   
   CopyData();

   return EntryAddr;
}