FSDev_NOR_BSP_WaitWhileBusy()

CPU_BOOLEAN  
FSDev_NOR_BSP_WaitWhileBusy 
       (FS_QTY                 unit_nbr,
        FS_DEV_NOR_PHY_DATA   *p_phy_data,
        CPU_BOOLEAN          (*poll_fnct)(FS_DEV_NOR_PHY_DATA  *),
        CPU_INT32U             to_us);

File

Called from

Code enabled by

fs_dev_nor_bsp.c

NOR physical-layer driver

N/A

Wait while NAND is busy.

Arguments

unit_nbr

Unit number of NOR.

p_phy_data

Pointer to NOR phy data.

poll_fnct

Pointer to function to poll, if there is no hardware ready/busy signal.

to_us

Timeout, in microseconds.

Returned Value

DEF_OK, if NAND became ready.

DEF_FAIL, otherwise.

Notes/Warnings

None.

FSDev_NOR_BSP_WaitWhileBusy( ) (without hardware read/busy signal)
CPU_BOOLEAN  FSDev_NOR_BSP_WaitWhileBusy  (FS_QTY                 unit_nbr,
                                           FS_DEV_NOR_PHY_DATA   *p_phy_data,
                                           CPU_BOOLEAN          (*poll_fnct)(FS_DEV_NOR_PHY_DATA  *),
                                           CPU_INT32U             to_us)
{
    CPU_INT32U   time_cur_us;
    CPU_INT32U   time_start_us;
    CPU_BOOLEAN  rdy;
    time_cur_us   = /* $$$$ GET CURRENT TIME, IN MICROSECONDS. */;
    time_start_us = time_cur_us;
    while (time_cur_us - time_start_us < to_us) {                                      (1)
        rdy = poll_fnct(p_phy_data);                                                   (2)
        if (rdy == DEF_OK) {
            return (DEF_OK);
        }
        time_cur_us = /* $$$$ GET CURRENT TIME, IN MICROSECONDS. */;
    }
    return (DEF_FAIL);                                                                 (3)
}


(1) At least to_us microseconds should elapse before the function gives up and returns. Returning early can cause disruptive timeout errors within the physical-layer driver.

(2)  poll_fnct should be called with p_phy_data as its sole argument. If it returns DEF_OK, then the device is ready and the function should return DEF_OK.

(3) If to_us microseconds elapse without the poll function or hardware ready/busy signaling indicating success, the function should return DEF_FAIL.