BRT Community

General Category => Discussion - EVE => Topic started by: T.Pierret on June 05, 2020, 04:41:38 PM

Title: How to inflate large image
Post by: T.Pierret on June 05, 2020, 04:41:38 PM
Hi,

I would like to inflate a compressed image (ARGB1555) larger than the circular buffer. Is there a way to do that ?

Thanks in advance for any support.

Regards.
Thierry Pierret
Title: Re: How to inflate large image
Post by: Rudolph on June 08, 2020, 11:50:38 AM
In short, you feed the data into the FIFO in packets smaller than the FIFO size and execute it by writing REG_CMD_WRITE.
The same applies to CMD_LOADIMAGE.

Check out EVE_cmd_inflate() here:
https://github.com/RudolphRiedel/FT800-FT813

I do have support code for STM32 in place, check EVE_target.h line 593.
I do not have a native example for STM32 though as I am  not using these myself.
Title: Re: How to inflate large image
Post by: BRT Community on June 08, 2020, 02:54:46 PM
Hello,

Yes, Rudolph is correct, you would split the data into chucks smaller than the FIFO size.
Below is our implementation from our BRT_AN_014 (https://brtchip.com/wp-content/uploads/Support/Documentation/Application_Notes/ICs/EVE/BRT_AN_014_FT81X_Simple_PIC_Library_Examples.pdf) for writing data to the FIFO.
Section 7.2 covers using the INFLATE command.

Code: [Select]
void API_LIB_WriteDataToCMD(const uint8_t *ImgData, uint32_t DataSize)
{
    uint32_t CurrentIndex = 0;
    uint32_t ChunkSize = 0;
    const uint32_t MaxChunkSize = 128;
    uint8_t IsLastChunk = 0;
    uint16_t Freespace = 0;

    // This code works by sending the data in a series of one or more bursts.
    // If the data is more than MaxChunkSize bytes, it is sent as a series of
    // one or more bursts and then the remainder. MaxChunkSize is a size which
    // is smaller than the command buffer on the EVE and small enough to gain
    // maximum buffering effect from the MCU SPI hardware.

    // Pad data length to multiple of 4.
    DataSize = (DataSize + 3) & (~3);

    // While not all data is sent
    while (CurrentIndex < DataSize)
    {
        // If more than ChunkSize bytes to send
        if ((DataSize - CurrentIndex) > MaxChunkSize)
        {
            // ... then add ChunkSize to the current target index to make new target
            ChunkSize = MaxChunkSize;
            // ... and this is not the last chunk
            IsLastChunk = 0;
        }
        // or if all remaining bytes can fit in one chunk
        else
        {
            // ... then add the amount of data to the current target
            ChunkSize = DataSize - CurrentIndex;
            // .. and this is the last chunk
            IsLastChunk = 1;
        }

        // Wait until there is space
        Freespace = 0;
        while (Freespace < MaxChunkSize)
        {
            Freespace = HAL_CheckCmdFreeSpace();
        }

        // Begin an SPI burst write
        HAL_ChipSelect(1);

        // to the next location in the FIFO
        HAL_SetWriteAddress(EVE_RAM_CMD + HAL_GetCmdPointer());
       
        HAL_Write(ImgData, ChunkSize);
        ImgData += ChunkSize;
        CurrentIndex += ChunkSize;

        // End the SPI burst
        HAL_ChipSelect(0);

        // Calculate where end of data lies
        HAL_IncCmdPointer(ChunkSize);
        HAL_WriteCmdPointer();

        // If this is the last chunk of the data,
        if (IsLastChunk)
        {
            break;
        }
    }
}

Best Regards,
BRT Community
Title: Re: How to inflate large image
Post by: T.Pierret on June 09, 2020, 07:31:44 AM
Great! I under-estimated the "Inflate" command !
I will code that.

Many thanks for your answers.