/* GPMI Set And Start Data Sample Delay. 
This function sets the NAND Timing register which controls the delay in the data read sampling. It then set the delay hardware to be active (if needed by hardware) */
void gpmi_set_and_enable_data_sample_delay(uint32_t u32DelayCycles, uint32_t u32GpmiPeriod_ns)
/* GPMI Set And Start Data Sample Delay. 
This function sets the NAND Timing register which controls the delay in the data read sampling. It then set the delay hardware to be active (if needed by hardware) */
void gpmi_set_and_enable_data_sample_delay(uint32_t u32DelayCycles, uint32_t u32GpmiPeriod_ns)
{
    BW_GPMI_CTRL1_DLL_ENABLE(0);
    if ((u32DelayCycles == 0) || (u32GpmiPeriod_ns > GPMI_MAX_DLL_PERIOD_NS) )
    {
        BW_GPMI_CTRL1_RDN_DELAY(0);
        BW_GPMI_CTRL1_HALF_PERIOD(0);
    }
    else
    {
        uint32_t waitTimeNeeded;
        BW_GPMI_CTRL1_RDN_DELAY(u32DelayCycles);
        BW_GPMI_CTRL1_DLL_ENABLE(1);
        waitTimeNeeded = (u32GpmiPeriod_ns * GPMI_WAIT_CYCLES_AFTER_DLL_ENABLE) / 1000;
        hal_delay_us(waitTimeNeeded);
    }
}