Пример #1
0
/**
 * Write the flash memory starting at the desired address for a block of bytes.  NOTE: The length
 * must be 256, 512, 1024, or 4096 bytes.  The data pointer must be on a WORD boundary.
 * 
 * @param destAddress flash memory address
 * @param length number of bytes to write
 * @param data pointer to data block
 * 
 * @return IAP Status code
 */
IAP::StatusCode IAP::Write (uint32_t destAddress, uint32_t length, void *data)
{
    StatusCode statusCode;
    uint32_t irqState, command[5], result[2];
    
    if ((statusCode = PrepareSector(Sector(destAddress), Sector(destAddress + length))) != CmdSuccess)
        return statusCode;
    
    command[0] = 51;
    command[1] = destAddress;
    command[2] = reinterpret_cast <uint32_t> (data);
    command[3] = length;
    command[4] = SystemControl::GetInstance()->GetPClock() / 1000;
    
    // We have to disable interrupts because flash memory will not be available to execute out of.
    irqState = disableIRQ();
    
    iap (command, result);
    
    restoreIRQ (irqState);
    
    return static_cast <StatusCode> (result[0]);
}
Пример #2
0
/**
 * Erase the flash memory starting at the desired address for a block of bytes.  NOTE: The address range is
 * translated to device sector numbers.  Therefore the operational range may be larger than specified.
 * 
 * @param destAddress starting address to erase
 * @param length number of bytes to erase
 * 
 * @return IAP Status code
 */
IAP::StatusCode IAP::Erase (uint32_t destAddress, uint32_t length)
{
    StatusCode statusCode;
    uint32_t irqState, command[5], result[2];
    
    // 
    command[0] = 52;
    command[1] = Sector(destAddress);
    command[2] = Sector(destAddress + length);
    command[3] = SystemControl::GetInstance()->GetPClock() / 1000;
    
    if ((statusCode = PrepareSector(command[1], command[2])) != CmdSuccess)
        return statusCode;    
    
    // We have to disable interrupts because flash memory will not be available to execute out of.
    irqState = disableIRQ();
    
    iap (command, result);
    
    restoreIRQ (irqState);
    
    return static_cast <StatusCode> (result[0]);
}
Пример #3
0
int csMovableSectorList::Add (iSector *obj)
{
  if (!PrepareSector (obj)) return -1;
  return (int)Push (obj);
}