1.11.1. Sub Functions in main.c Source File
The function prototypes of the sub functions listed in the table below can be found in the functions.h header file located in the software file directory.
Function Prototype | Description |
---|---|
void chomp (char * string) | Chomps trailing '\n' character from string. |
int StringIsNumeric (char * string) | Tests whether string is numeric. Returns 1 if true, 0 if false. |
int StringIsHex (char * string) | Tests whether string is a hexadecimal number. Returns 1 if true, 0 if false. |
void DelayCounter (alt_u32 count) | Delay counter. Counts up to count ticks, each tick is roughly 1 second (not accurate). |
void Get_L_Init (int * L_init) | Read initially configured value of L from each JESD204B IP core CSR in the design and store the value in L_init array. |
void Get_F_Init (int * F_init) | Read initially configured value of F from each JESD204B IP core CSR in the design and store the value in F_init array. |
void Get_FC_Init (int * FC_init , int * DR_init) | Calculate initially configured value of the frame rate by reading the relevant parameters from each JESD204B IP core CSR in the design and the serial data rate values stored in DR_init. Stores calculated value in FC_init array. |
int Initialize (char * options [][], int * held_resets) | Executes initialize command according to options. This function performs the following actions:
|
void Help (void) | Prints menu of available commands. |
int Reset (char * options [][], int * held_resets) | Executes reset command according to options. This function calls two other subfunctions depending on options:
|
int LoadSPI (char * options [][]) | Executes the load SPI command according to options. Returns 0 if success, 1 if fail. |
int GetSPI (char * options [][]) | Executes get SPI command according to options. Returns 0 if success, 1 if fail. |
int ConfigSPI (int * held_resets , int dnr) | Executes the configure SPI command according to options. Returns 0 if success, 1 if fail. |
int Status (char * options [][]) | Executes the report link status command according to options. Returns 0 if success, 1 if fail, 2 if sync errors found, 4 if pattern checker errors found, 6 if both sync errors and pattern checker errors found. |
int Loopback (char * options [][], int * held_resets , int dnr) | Executes the loopback command according to options. Returns 0 if success, 1 if fail. |
int SourceDest (char * options [][], int * held_resets , int dnr) | Executes the source or destination datapath selection command according to options. Returns 0 if success, 1 if fail. |
int Test (char * options [][], int * held_resets) | Executes the test mode command according to options. Test mode:
|
int Reinit (char * options [][], int * held_resets) | Executes the reinit command according to options. This function performs the following actions:
|
void Sysref (void) | Pulse SYSREF signal one time (that is in "one-shot"). |
int Reconfig (char * options [][], int * L_init , int * F_init , int * DR_init , int * FC_init , int * current_dr_div , unsigned int link_clk_pll_ counter_val_init , unsigned int frame_clk_pll_ counter_val_init , unsigned int * xcvr_native_ array_ptr [][], unsigned int * xcvr_pll_ array_ptr [][], int * held_resets) | Executes dynamic reconfiguration command. This function performs three major tasks:
Returns 0 if success, 1 if fail. |
void ResetHard (void) | Triggers full hardware reset sequence via PIO control registers. |
int ResetSeq (int link , int * held) | Performs full hardware reset sequence on the indicated link via software interface . Returns 0 if success, 1 if fail. |
int ResetForce (int link , int reset_val , int hold_release , int * held_resets) | Forces reset assertion or deassertion on submodule resets for the link indicated by reset_val. The function also decides whether to assert and hold (hold_release =2), deassert ( hold_release =1) or pulse ( hold_release =0) indicated resets. The function has mechanisms (using the global held_resets flag) to ensure that held resets that are not the target of the reset force function are not affected by it. Returns 0 if success, 1 if fail. |
int Reset_PLL_Release (int link, int * held_resets) | Deassert the core PLL reset signal. Wait until the core PLL locked signal assert before returning. Returns 0 if success, 1 if fail. |
int Reset_X_L_F_Release (int link, int * held_resets) | Deassert the transceiver, link, and frame resets. This function deasserts the TX transceiver reset first, waits until the TX transceiver ready signal asserts, then deasserts the TX link and TX frame resets. The function then repeats the above actions with the RX data path. Returns 0 if success, 1 if fail. |
void spiWrite (alt_u16 offset, alt_u8 m_data, alt_u8 slave) | Performs SPI write operation of m_data to SPI slave indicated by slave number at address offset offset. The maximum bit width of m_data is 8 bits while the maximum bit width of offset is 16 bits. |
alt_u8 spiRead (alt_u16 offset, alt_u8 slave) | Performs SPI read operation of SPI slave indicated by slave number at address offset offset. Returns 8-bit read value. The maximum bit width of offset is 16 bits. |
void spiVerify (alt_u16 offset , alt_u8 slave, alt_u8 data) | Performs SPI read operation of SPI slave indicated by slave number at address offset offset, compares the read data to data, then reports whether the read data matches the user-given data. The maximum bit width of data is 8 bits while the maximum bit width of offset is 16 bits. |
void Config_AD9680 (alt_u8 slave) | Executes a series of spiWrites to the AD9680 slave to configure it. |
void InitISR (void) | Initialize the interrupt controllers for the following peripherals:
|
static void ISR_JESD_RX (void * context) | The JESD204B IP core RX interrupt service routine (ISR). Upon an interrupt event (IRQ assert), reads the RX JESD204B CSR rx_err0 and rx_err1 registers and reports the error code to screen. After that, ISR clears all the valid and active status bits in the rx_err0 and rx_err1 registers. 1 |
static void ISR_JESD_TX (void * context) | The JESD204B IP core TX ISR. Upon an interrupt event (IRQ assert), read the TX JESD204B CSR tx_err register and reports the error code to the screen. After that, the ISR clears all the valid and active status registers in the tx_err register. 1 |
static void ISR_SPI (void * context) | The SPI master ISR. Upon an interrupt event (IRQ assert), clear the IRQ flag and return. 1 |