Ejemplo n.º 1
0
// See flash.h for documentation of this function.
status_t flash_read_once(flash_driver_t * driver, uint32_t index, uint32_t *dst, uint32_t lengthInBytes)
{
    if (dst == NULL)
    {
        return kStatus_InvalidArgument;
    }

    status_t returnCode = flash_check_access_ifr_range(driver, index, lengthInBytes);
    if (kStatus_Success != returnCode)
    {
        return returnCode;
    }

    // pass paramters to FTFx
    FTFx_WR_FCCOBx(FTFx, 0, FTFx_READ_ONCE);
    FTFx_WR_FCCOBx(FTFx, 1, index);

    // calling flash command sequence function to execute the command
    returnCode = flash_command_sequence();

    if (kStatus_Success == returnCode)
    {
        *dst = kFCCOBx[1];

        if ((index >= FLASH_PROGRAM_ONCE_MIN_ID_8BYTES) &&
                (index <= FLASH_PROGRAM_ONCE_MAX_ID_8BYTES) &&
                (lengthInBytes == 8))
        {
            *(dst + 1) = kFCCOBx[2];
        }
    }

    return returnCode;
}
Ejemplo n.º 2
0
// See flash.h for documentation of this function.
status_t flash_program_once(flash_driver_t * driver, uint32_t index, uint32_t *src, uint32_t lengthInBytes)
{
    if (src == NULL)
    {
        return kStatus_InvalidArgument;
    }

    status_t returnCode = flash_check_access_ifr_range(driver, index, lengthInBytes);
    if (kStatus_Success != returnCode)
    {
        return returnCode;
    }

    // pass paramters to FTFx
    HW_FTFx_FCCOBx_WR(FTFx_BASE, 0, FTFx_PROGRAM_ONCE);
    HW_FTFx_FCCOBx_WR(FTFx_BASE, 1, index);
    kFCCOBx[1] = *src;

    if (index > FLASH_PROGRAM_ONCE_MAX_ID_4BYTES)
    {
        kFCCOBx[2] = *(src + 1);
    }

    // calling flash command sequence function to execute the command
    returnCode = flash_command_sequence();

    return returnCode;
}