XilinxProcessorIPLib/drivers/v_hdmitxss1/examples/xhdmi_example/si5324drv.c
int Si5324_FindN2(si5324_settings_t *settings) {
    u32 result;

    for (settings->n2_hs = SI5324_N2_HS_MAX; settings->n2_hs >= SI5324_N2_HS_MIN; settings->n2_hs--) {
        if (SI5324_DEBUG) {
            xil_printf("\t\tTrying N2_HS = %d.\r\n", settings->n2_hs);
        }
        settings->n2_ls_min = (u32)(settings->fosc / ((u64)(SI5324_F3_MAX * settings->n2_hs) << 28));
        if (settings->n2_ls_min < SI5324_N2_LS_MIN) {
            settings->n2_ls_min = SI5324_N2_LS_MIN;
        }
        settings->n2_ls_max = (u32)(settings->fosc / ((u64)(SI5324_F3_MIN * settings->n2_hs) << 28));
        if (settings->n2_ls_max > SI5324_N2_LS_MAX) {
            settings->n2_ls_max = SI5324_N2_LS_MAX;
        }
        result = Si5324_FindN2ls(settings);
        if (result) {
            // Best possible result found. Skip the rest of the possibilities.
            break;
        }
    }
    return result;
}
/*****************************************************************************/
/**
 * Find a valid setting for N2_HS and N2_LS. Finds the best
 * setting for N2_HS, N2_LS, and N3n with the values for N1_HS, and NCn_LS
 * already set in settings. Iterates over all possibilities
 * of N2_HS and then performs a binary search over the N2_LS values.
 *
 * @param settings Holds the settings up till now.
 * @return 1 when the best possible result has been found.
 * @note     Private function.
 */
Find a valid setting for N2_HS and N2_LS. Finds the best
setting for N2_HS, N2_LS, and N3n with the values for N1_HS, and NCn_LS
already set in settings. Iterates over all possibilities
of N2_HS and then performs a binary search over the N2_LS values.

@param settings Holds the settings up till now.
@return 1 when the best possible result has been found.
@note     Private function.
Find a valid setting for N2_HS and N2_LS . Finds the best setting for N2_HS N2_LS and N3n with the values for N1_HS and NCn_LS already set in settings . Iterates over all possibilities of N2_HS and then performs a binary search over the N2_LS values . @param settings Holds the settings up till now . @return 1 when the best possible result has been found . @note Private function .
int Si5324_FindN2(si5324_settings_t *settings) {
    u32 result;
    for (settings->n2_hs = SI5324_N2_HS_MAX; settings->n2_hs >= SI5324_N2_HS_MIN; settings->n2_hs--) {
        if (SI5324_DEBUG) {
            xil_printf("\t\tTrying N2_HS = %d.\r\n", settings->n2_hs);
        }
        settings->n2_ls_min = (u32)(settings->fosc / ((u64)(SI5324_F3_MAX * settings->n2_hs) << 28));
        if (settings->n2_ls_min < SI5324_N2_LS_MIN) {
            settings->n2_ls_min = SI5324_N2_LS_MIN;
        }
        settings->n2_ls_max = (u32)(settings->fosc / ((u64)(SI5324_F3_MIN * settings->n2_hs) << 28));
        if (settings->n2_ls_max > SI5324_N2_LS_MAX) {
            settings->n2_ls_max = SI5324_N2_LS_MAX;
        }
        result = Si5324_FindN2ls(settings);
        if (result) {
            break;
        }
    }
    return result;
}
int Si5324_FindN2 ( si5324_settings_t * settings ) { u32 result ; for ( settings -> n2_hs = SI5324_N2_HS_MAX ; settings -> n2_hs >= SI5324_N2_HS_MIN ; settings -> n2_hs -- ) { if ( SI5324_DEBUG ) { xil_printf ( " \t \t \r \n " , settings -> n2_hs ) ; } settings -> n2_ls_min = ( u32 ) ( settings -> fosc / ( ( u64 ) ( SI5324_F3_MAX * settings -> n2_hs ) << 28 ) ) ; if ( settings -> n2_ls_min < SI5324_N2_LS_MIN ) { settings -> n2_ls_min = SI5324_N2_LS_MIN ; } settings -> n2_ls_max = ( u32 ) ( settings -> fosc / ( ( u64 ) ( SI5324_F3_MIN * settings -> n2_hs ) << 28 ) ) ; if ( settings -> n2_ls_max > SI5324_N2_LS_MAX ) { settings -> n2_ls_max = SI5324_N2_LS_MAX ; } result = Si5324_FindN2ls ( settings ) ; if ( result ) { break ; } } return result ; }
Find a valid setting for N2_HS and N2_LS.
Find a valid setting for N2_HS and N2_LS .
// Best possible result found. Skip the rest of the possibilities.