| v_hdmirxss Vitis Drivers API Documentation

- Overview
- Data Structures
- APIs
- File List
- Examples

Functions | Variables
si5324drv.c File Reference

## Overview

This file contains low-level driver functions for controlling the SiliconLabs Si5324 clock generator as mounted on the KC705 demo board.

The user should refer to the hardware device specification for more details of the device operation.

    MODIFICATION HISTORY:

    Ver   Who Date         Changes

    1.00  hf  2014/10/10   First release
    1.10  MG  2016/07/05   Updated LOCKT register
    1.11  YH  2016/09/14   Add option to enable fast switching
    1.12  YH  2017/07/19   Added SI5324 control using PS IIC
    1.13  GM  2017/11/15   Issued powerdown on CLKIN1 & CLKIN2 depending on
                              Free Run Mode to force correct clock selection

## Functions
int | Si5324_DoSettings (u32 IICBaseAddress, u8 IICAddress, u8 *BufPtr, int NumRegs)
| Send a list of register settings to the Si5324 clock generator. More...
int | Si5324_Reset (u32 IICBaseAddress, u8 IICAddress)
| Reset the SiliconLabs Si5324 clock generator. More...
int | Si5324_Init (u32 IICBaseAddress, u8 IICAddress)
| Initialize the SiliconLabs Si5324 clock generator. More...
void | Si5324_RatApprox (u64 f, u64 md, u32 *num, u32 *denom)
| Find the closest rational approximation for the N2_LS/N3 fraction. More...
int | Si5324_FindN2ls (si5324_settings_t *settings)
| Search through the possible settings for the N2_LS parameter. More...
int | Si5324_FindN2 (si5324_settings_t *settings)
| Find a valid setting for N2_HS and N2_LS. More...
int | Si5324_CalcNclsLimits (si5324_settings_t *settings)
| Calculates the valid range for NCn_LS with the value for the output frequency and N1_HS already set in settings. More...
int | Si5324_FindNcls (si5324_settings_t *settings)
| Find a valid setting for NCn_LS that can deliver the correct output frequency. More...
int | Si5324_CalcFreqSettings (u32 ClkInFreq, u32 ClkOutFreq, u8 *N1_hs, u32 *NCn_ls, u8 *N2_hs, u32 *N2_ls, u32 *N3n, u8 *BwSel)
| Calculate the frequency settings for the desired output frequency. More...
int | Si5324_SetClock (u32 IICBaseAddress, u8 IICAddress, u8 ClkSrc, u32 ClkInFreq, u32 ClkOutFreq)
| Set the output frequency of the Si5324 clock generator. More...

## Variables
u8 | SI5324_DEFAULTS []
| Default register settings that differ from the (power-on-)reset values. More...

## Function Documentation

int Si5324_CalcFreqSettings | ( | u32 | ClkInFreq,
|  | u32 | ClkOutFreq,
|  | u8 * | N1_hs,
|  | u32 * | NCn_ls,
|  | u8 * | N2_hs,
|  | u32 * | N2_ls,
|  | u32 * | N3n,
|  | u8 * | BwSel
| ) |  |

Calculate the frequency settings for the desired output frequency.

Parameters

  ClkInFreq | contains the frequency of the input clock.
  ClkOutFreq | contains the desired output clock frequency.
  N1_hs | will be set to the value for the N1_HS register.
  NCn_ls | will be set to the value for the NCn_LS register.
  N2_hs | will be set to the value for the N2_HS register.
  N2_ls | will be set to the value for the N2_LS register.
  N3n | will be set to the value for the N3n register.
  BwSel | will be set to the value for the BW_SEL register.

Returns
  SI5324_SUCCESS for success, SI5324_ERR_FREQ when the requested frequency cannot be generated.

Note
  Private function.

References Si5324_CalcNclsLimits(), SI5324_DEBUG, SI5324_ERR_FREQ, SI5324_F3_MAX, Si5324_FindNcls(), SI5324_FOSC_MAX, SI5324_FOSC_MIN, SI5324_N1_HS_MAX, SI5324_N1_HS_MIN, SI5324_N3_MAX, SI5324_N3_MIN, SI5324_NC_LS_MAX, SI5324_NC_LS_MIN, and SI5324_SUCCESS.

Referenced by Si5324_SetClock().

int Si5324_CalcNclsLimits | ( | si5324_settings_t * | settings | ) |

Calculates the valid range for NCn_LS with the value for the output frequency and N1_HS already set in settings.

Parameters

  settings | Holds the input and output frequencies and the setting for N1_HS.

Returns
  -1 when there are no valid settings for NCn_LS, 0 otherwise.

Note
  Private function.

References SI5324_NC_LS_MAX, and SI5324_NC_LS_MIN.

Referenced by Si5324_CalcFreqSettings().

int Si5324_DoSettings | ( | u32 | IICBaseAddress,
|  | u8 | IICAddress,
|  | u8 * | BufPtr,
|  | int | NumRegs
| ) |  |

Send a list of register settings to the Si5324 clock generator.

Parameters

  IICBaseAddress | contains the base address of the IIC master device.
  IICAddress | contains the 7 bit IIC address of the Si5324 device.
  BufPtr | is a pointer to an array with alternating register addresses and register values to program into the Si5324. The array length must be at least 2*NumRegs.
  NumRegs | contains the number of registers to write.

Returns
  SI5324_SUCCESS for success, SI5324_ERR_IIC for IIC access failure, SI5324_ERR_PARM when the number of registers to write is less than one.

Note
  Private function. Does not modify the contents of the buffer pointed to by BufPtr.

References SI5324_DEBUG, SI5324_ERR_IIC, SI5324_ERR_PARM, and SI5324_SUCCESS.

Referenced by Si5324_Init(), Si5324_Reset(), and Si5324_SetClock().

int Si5324_FindN2 | ( | si5324_settings_t * | settings | ) |

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.

Parameters

  settings | Holds the settings up till now.

Returns
  1 when the best possible result has been found.

Note
  Private function.

References SI5324_DEBUG, SI5324_F3_MAX, Si5324_FindN2ls(), SI5324_N2_HS_MAX, SI5324_N2_HS_MIN, SI5324_N2_LS_MAX, and SI5324_N2_LS_MIN.

Referenced by Si5324_FindNcls().

int Si5324_FindN2ls | ( | si5324_settings_t * | settings | ) |

Search through the possible settings for the N2_LS parameter.

Finds the best setting for N2_LS and N3n with the values for N1_HS, NCn_LS, and N2_HS already set in settings.

Parameters

  settings | Holds the settings up till now.

Returns
  1 when the best possible result has been found.

Note
  Private function.

References SI5324_DEBUG, SI5324_F3_MAX, SI5324_FOSC_MAX, SI5324_FOSC_MIN, SI5324_FOUT_MAX, SI5324_FOUT_MIN, and Si5324_RatApprox().

Referenced by Si5324_FindN2().

int Si5324_FindNcls | ( | si5324_settings_t * | settings | ) |

Find a valid setting for NCn_LS that can deliver the correct output frequency.

Assumes that the valid range is relatively small so a full search can be done (should be true for video clock frequencies).

Parameters

  settings | Holds the input and output frequencies, the setting for N1_HS, and the limits for NCn_LS.

Returns
  1 when the best possible result has been found.

Note
  Private function.

References SI5324_DEBUG, and Si5324_FindN2().

Referenced by Si5324_CalcFreqSettings().

int Si5324_Init | ( | u32 | IICBaseAddress,
|  | u8 | IICAddress
| ) |  |

Initialize the SiliconLabs Si5324 clock generator.

After initialization, the clock generator is not generating a clock yet. Call si5324_set_clock to start the clock generator.

Parameters

  IICBaseAddress | contains the base address of the IIC master device.
  IICAddress | contains the 7 bit IIC address of the Si5324 device.

Returns
  SI5324_SUCCESS for success, SI5324_ERR_IIC for IIC access failure.

References SI5324_DEBUG, SI5324_DEFAULTS, and Si5324_DoSettings().

void Si5324_RatApprox | ( | u64 | f,
|  | u64 | md,
|  | u32 * | num,
|  | u32 * | denom
| ) |  |

Find the closest rational approximation for the N2_LS/N3 fraction.

Parameters

  f | Holds the N2_LS/N3 fraction in 36.28 fixed point notation.
  md | Holds the maximum denominator (N3) value allowed.
  num | Will store the numinator (N2_LS) found.
  denom | Will store the denominator (N3) found.

Referenced by Si5324_FindN2ls().

int Si5324_Reset | ( | u32 | IICBaseAddress,
|  | u8 | IICAddress
| ) |  |

Reset the SiliconLabs Si5324 clock generator.

Parameters

  IICBaseAddress | contains the base address of the IIC master device.
  IICAddress | contains the 7 bit IIC address of the Si5324 device.

Returns
  SI5324_SUCCESS for success, SI5324_ERR_IIC for IIC access failure.

Note
  Private function.

References SI5324_DEBUG, Si5324_DoSettings(), SI5324_ERR_IIC, and SI5324_SUCCESS.

int Si5324_SetClock | ( | u32 | IICBaseAddress,
|  | u8 | IICAddress,
|  | u8 | ClkSrc,
|  | u32 | ClkInFreq,
|  | u32 | ClkOutFreq
| ) |  |

Set the output frequency of the Si5324 clock generator.

Set the output frequency.

Parameters

  IICBaseAddress | contains the base address of the IIC master device.
  IICAddress | contains the 7 bit IIC address of the Si5324 device.
  ClkSrc | selects the clock input to use.
  ClkInFreq | contains the frequency of the input clock (2kHz-710MHz).
  ClkOutFreq | contains the desired output clock frequency (2kHz-945MHz).

Returns
  SI5324_SUCCESS for success, SI5324_ERR_IIC for IIC access failure, SI5324_ERR_FREQ when the requested frequency cannot be generated, SI5324_ERR_PARM when the ClkSrc or ClkDest parameters are invalid or the ClkInFreq or ClkOutFreq are out of range.

References Si5324_CalcFreqSettings(), SI5324_CLKSRC_CLK1, SI5324_CLKSRC_CLK2, SI5324_CLKSRC_XTAL, SI5324_DEBUG, Si5324_DoSettings(), SI5324_ERR_PARM, SI5324_FIN_MAX, SI5324_FIN_MIN, SI5324_FOUT_MAX, SI5324_FOUT_MIN, and SI5324_SUCCESS.

## Variable Documentation

u8 SI5324_DEFAULTS[]

Default register settings that differ from the (power-on-)reset values.

This array consists of pairs with the first value the register number and the second number the register value.

Referenced by Si5324_Init().