/* param base LCDIF v2 peripheral base address. param layerIndex Which layer to set. param lutData The LUT data to load. param count Count of lutData. retval kStatus_Success Set success. retval kStatus_Fail Previous LUT data is not loaded to hardware yet.  */
status_t LCDIFV2_SetLut(LCDIFV2_Type *base, uint8_t layerIndex, const uint32_t *lutData, uint16_t count, bool useShadowLoad)
/* param base LCDIF v2 peripheral base address. param layerIndex Which layer to set. param lutData The LUT data to load. param count Count of lutData. retval kStatus_Success Set success. retval kStatus_Fail Previous LUT data is not loaded to hardware yet.  */
status_t LCDIFV2_SetLut(LCDIFV2_Type *base, uint8_t layerIndex, const uint32_t *lutData, uint16_t count, bool useShadowLoad)
{
    assert(count <= LCDIFV2_LUT_ENTRY_NUM);
    uint16_t i;
    status_t status;
    if ((base->CLUT_LOAD & LCDIFV2_CLUT_LOAD_CLUT_UPDATE_EN_MASK) != 0U)
    {
        status = kStatus_Fail;
    }
    else
    {
        if (useShadowLoad)
        {
            base->CLUT_LOAD = LCDIFV2_CLUT_LOAD_SEL_CLUT_NUM(layerIndex) | LCDIFV2_CLUT_LOAD_CLUT_UPDATE_EN_MASK;
        }
        else
        {
            base->CLUT_LOAD = LCDIFV2_CLUT_LOAD_SEL_CLUT_NUM(layerIndex);
        }
        for (i = 0; i < count; i++)
        {
            (LCDIFV2_LUT_MEM(base))[i + LCDIFV2_LUT_ENTRY_NUM * layerIndex] = lutData[i];
        }
        status = kStatus_Success;
    }
    return status;
}