350 lines
14 KiB
C
350 lines
14 KiB
C
/*
|
|
* headless.h
|
|
*
|
|
* Created on: 2021��6��8��
|
|
* Author: Josh
|
|
*/
|
|
|
|
#ifndef SRC_HEADLESS_H_
|
|
#define SRC_HEADLESS_H_
|
|
|
|
/***************************** Include Files ********************************/
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include "xil_cache.h"
|
|
#include "xscugic.h"
|
|
//#include "xgpio.h"
|
|
|
|
#include "common.h"
|
|
#include "./mykonos/ad9528.h"
|
|
#include "./mykonos/mykonos.h"
|
|
#include "./mykonos/Mykonos_M3.h"
|
|
#include "./mykonos/mykonos_gpio.h"
|
|
#include "myk_ad9528init.h"
|
|
#include "myk_init.h"
|
|
|
|
#include "parameters.h"
|
|
|
|
/************************** Constant Definitions *****************************/
|
|
|
|
/**************************** Type Definitions *******************************/
|
|
|
|
/***************** Macros (Inline Functions) Definitions *********************/
|
|
#define HW_PRINT(...) __asm__("nop")
|
|
// #define HW_PRINT(...) printf(__VA_ARGS__)
|
|
/************************** Variable Definitions *****************************/
|
|
|
|
/************************** Function Prototypes ******************************/
|
|
|
|
/*****************************************************************************/
|
|
/*
|
|
*
|
|
* This function setups ad9528 and ad9371 via spi.
|
|
*
|
|
* @param None.
|
|
*
|
|
* @return
|
|
* - ADIERR_FAILED if successful,
|
|
* - ADIERR_OK if not succesful
|
|
*
|
|
* @note None.
|
|
*
|
|
******************************************************************************/
|
|
int HARDWARE_initialize();
|
|
|
|
int HARDWARE_ad9371Config(void);
|
|
|
|
/*****************************************************************************/
|
|
/*
|
|
*
|
|
* Setup up Axi Gpio, through which ad9371 can be reconfigured. Axi Gpio
|
|
* instance and interrupt system initialization are included.
|
|
*
|
|
* @param None.
|
|
*
|
|
* @return
|
|
* - ADIERR_FAILED if successful,
|
|
* - ADIERR_OK if not succesful
|
|
*
|
|
* @note None.
|
|
*
|
|
******************************************************************************/
|
|
int HW_ad9371DynamicCfgInit(void);
|
|
|
|
/*****************************************************************************/
|
|
/*
|
|
*
|
|
* Setup up interrupt system, initialize exception handlers.
|
|
*
|
|
* @param DeviceId is the unique identifier for a device.
|
|
* @param GicPtr is a pointer to the XScuGic instance.
|
|
*
|
|
* @return
|
|
* - XST_SUCCESS if successful,
|
|
* - XST_FAILURE if not succesful
|
|
*
|
|
* @note None.
|
|
*
|
|
******************************************************************************/
|
|
int HW_setupIntrSystem(u16 DeviceId, XScuGic * GicPtr);
|
|
|
|
/*****************************************************************************/
|
|
/*
|
|
*
|
|
* Make the connection between the Int_Id of the interrupt source and the
|
|
* associated handler. Set the interrupt priority and trigger type for the
|
|
* specified IRQ source..
|
|
*
|
|
* @param GicPtr is a pointer to the XScuGic instance.
|
|
* @param Int_Id contains the ID of the interrupt source and should be
|
|
* in the range of 0 to XSCUGIC_MAX_NUM_INTR_INPUTS - 1
|
|
* @param Handler to the handler for that interrupt.
|
|
* @param CallBackRef is the callback reference, usually the instance
|
|
* pointer of the connecting driver.
|
|
* @param Priority is the new priority for the IRQ source. 0 is highest
|
|
* priority, 0xF8(248) is lowest. There are 32 priority levels
|
|
* supported with a step of 8. Hence the supported priorities are
|
|
* 0, 8, 16, 32, 40 ..., 248.
|
|
* @param Trigger is the new trigger type for the IRQ source.
|
|
* Each bit pair describes the configuration for an INT_ID.
|
|
* SFI Read Only b10 always
|
|
* PPI Read Only depending on how the PPIs are configured.
|
|
* b01 Active HIGH level sensitive
|
|
* b11 Rising edge sensitive
|
|
* SPI LSB is read only.
|
|
* b01 Active HIGH level sensitive
|
|
* b11 Rising edge sensitive/
|
|
*
|
|
* @return
|
|
* - XST_SUCCESS if successful,
|
|
* - XST_FAILURE if not succesful
|
|
*
|
|
* @note None.
|
|
*
|
|
******************************************************************************/
|
|
int HW_connectIntr(XScuGic *GicPtr,u32 IntrId,Xil_InterruptHandler Handler,
|
|
void *CallBackRef, u8 Priority, u8 Trigger);
|
|
|
|
/*****************************************************************************/
|
|
/*
|
|
*
|
|
* Initialize Analog Device related configuration profile. This is a HARDWARE-
|
|
* ASSOTIATED function, which may differ between different board.
|
|
*
|
|
* @param None.
|
|
*
|
|
* @return
|
|
* - ADIERR_OK if configuration profile exists,
|
|
* - ADIERR_FAILED if onfiguration profile does not exist
|
|
*
|
|
* @note None.
|
|
*
|
|
******************************************************************************/
|
|
int HW_adiCfgProfileInit(void);
|
|
|
|
/******************************************************************************/
|
|
/**
|
|
*
|
|
* This function conducts AD9528 device configuration initializing procedure.
|
|
*
|
|
* @param clockAD9528_device is a pointer to the data structure holding
|
|
* AD9528 settings, which contains basic AD9528 settings such as
|
|
* spi and gpio.
|
|
*
|
|
* @return
|
|
* - ADIERR_OK if successful.
|
|
* - ADIERR_FAILED if not successful.
|
|
*
|
|
* @note None.
|
|
*
|
|
*******************************************************************************/
|
|
int HW_9528Config(ad9528Device_t *clockAD9528_device);
|
|
|
|
/******************************************************************************/
|
|
/**
|
|
*
|
|
* This function read AD9528 reg508 status, to check whether ad9528 is locked or
|
|
* not.
|
|
*
|
|
* @param clockAD9528_device is a pointer to the data structure holding
|
|
* AD9528 settings, which contains basic AD9528 settings.
|
|
*
|
|
* @return
|
|
* - ADIERR_OK if successful.
|
|
* - ADIERR_FAILED if not successful.
|
|
*
|
|
* @note None.
|
|
*
|
|
*******************************************************************************/
|
|
int HW_9528GetLockStatus(ad9528Device_t *device, uint8_t *reg508);
|
|
|
|
/******************************************************************************/
|
|
/**
|
|
*
|
|
* Conduct AD9371 device configuration initializing procedure.
|
|
*
|
|
* @param clockAD9528_device is a pointer to the data structure holding
|
|
* AD9528 settings, which contains basic AD9528 settings.
|
|
* @param mykDevice is ADI hardware layer settings pointer specific to
|
|
* a Mykonos instance which contains basic settings such as spi,
|
|
* gpio, tx/rx and jesd configurations.
|
|
*
|
|
* @return
|
|
* - ADIERR_OK if successful.
|
|
* - ADIERR_FAILED if not successful.
|
|
*
|
|
* @note None.
|
|
*
|
|
*******************************************************************************/
|
|
int HW_9371Config(ad9528Device_t *clockAD9528_device, mykonosDevice_t *mykDevice);
|
|
|
|
/******************************************************************************/
|
|
/**
|
|
*
|
|
* Read AD9371's RX framer, ORX framer and TX deframer status, to check jesd204b
|
|
* sync status.
|
|
*
|
|
* @param mykDevice is ADI hardware layer settings pointer specific to
|
|
* a Mykonos instance which contains basic settings such as spi,
|
|
* gpio, tx/rx and jesd configurations.
|
|
* @param framerStatus is the RX framer status byte read
|
|
* framerStatus | Description
|
|
* -------------|-----------------------------------------------------------------------------
|
|
* [7] | SYSREF phase error ? a new SYSREF had different timing than the first that set the LMFC timing.
|
|
* [6] | Framer lane FIFO read/write pointer delta has changed. Can help debug issues with deterministic latency.
|
|
* [5] | Framer has received the SYSREF and has retimed its LMFC
|
|
* [4:2] | Framer ILAS state: 0=CGS, 1= 1st Multframe, 2= 2nd Multiframe, 3= 3rd Multiframe, 4= 4th multiframe, 5= Last multiframe, 6=invalid, 7= ILAS complete
|
|
* [1:0] | Framer Tx state: 0=CGS, 1= ILAS, 2 = ADC Data
|
|
* @param obsFramerStatus is the ORX framer status byte read
|
|
* obsFramerStatus | Description
|
|
* ----------------|-----------------------------------------------------------------------------
|
|
* [7] | SYSREF phase error ? a new SYSREF had different timing than the first that set the LMFC timing.
|
|
* [6] | Framer lane FIFO read/write pointer delta has changed. Can help debug issues with deterministic latency.
|
|
* [5] | Framer has received the SYSREF and has retimed its LMFC
|
|
* [4:2] | Framer ILAS state: 0=CGS, 1= 1st Multframe, 2= 2nd Multiframe, 3= 3rd Multiframe, 4= 4th multiframe, 5= Last multiframe, 6=invalid, 7= ILAS complete
|
|
* [1:0] | Framer Tx state: 0=CGS, 1= ILAS, 2 = ADC Data
|
|
* @param deframerStatus is the TX deframer status byte read
|
|
* deframerStatus | Bit Name | Description
|
|
* ----------------|--------------------------|---------------------------------------------
|
|
* [7] | Unused | Unused
|
|
* [6] | Deframer IRQ | This bit indicates that the IRQ interrupt was asserted.
|
|
* [5] | Deframer SYSREF Received | When this bit is set, it indicates that the SYSREF pulse was received by the deframer IP
|
|
* [4] | Deframer Receiver Error | This bit is set when PRBS has received an error.
|
|
* [3] | Valid Checksum | This bit is set when the received ILAS checksum is valid.
|
|
* [2] | EOF Event | This bit captures the internal status of the framer End of Frame event. Value =1 if framing error during ILAS
|
|
* [1] | EOMF Event | This bit captures the internal status of the framer End of Multi-Frame event. Value =1 if framing error during ILAS
|
|
* [0] | FS Lost | This bit captures the internal status of the framer Frame Symbol event. Value =1 if framing error during ILAS or user data (invalid replacement characters)
|
|
*
|
|
* @return
|
|
* - ADIERR_OK if successful.
|
|
* - ADIERR_FAILED if not successful.
|
|
*
|
|
* @note None.
|
|
*
|
|
*******************************************************************************/
|
|
int HW_9371CheckJesdStatus(mykonosDevice_t *mykDevice, uint8_t *framerStatus,
|
|
uint8_t *obsFramerStatus, uint8_t *deframerStatus);
|
|
|
|
/******************************************************************************/
|
|
/**
|
|
*
|
|
* This function conducts AD9371/9375 samll RF PLL frequcny change procedure. The
|
|
* procedure is performed as follows:
|
|
* 1. Move the device into the radio off state.
|
|
* 2. Program the new local oscillator (LO) frequency.
|
|
* 3. Reset the external channel.(ignored)
|
|
* 4. Move the device back into the radio on state.
|
|
* 5. Reenable tracking calibrations.(ignored)
|
|
*
|
|
* @param mykDevice is ADI hardware layer settings pointer specific to
|
|
* a Mykonos instance which contains basic settings such as spi,
|
|
* gpio, tx/rx and jesd configurations.
|
|
* @param freq_Hz is the target frequancy in Hz.
|
|
*
|
|
* @return None.
|
|
*
|
|
* @note The procedure is used when a radio frequency (RF) phased-lock loop
|
|
* (PLL) change is required with the following conditions:
|
|
* - A desire to change the Rx, Tx, and ORx frequencies.
|
|
* - The frequency step change is less than 100 MHz.
|
|
* - The frequency step does not cross the divide by 2 boundaries outlined
|
|
* in AD9371/9375-UG-992-Rev.B-Table 96.
|
|
*
|
|
*******************************************************************************/
|
|
int HW_9371SmallFrequencyChange(mykonosDevice_t *mykDevice, uint64_t freq_Hz);
|
|
|
|
/******************************************************************************/
|
|
/**
|
|
*
|
|
* This function conducts AD9371/9375 large RF PLL frequcny change procedure. The
|
|
* procedure is performed as follows:
|
|
* 1. Move the device into the radio off state.
|
|
* 2. Program the new local oscillator (LO) frequency.
|
|
* 3. Rerun the initialization calibrations.
|
|
* 4. Move the device back into the radio on state.
|
|
* 5. Reenable tracking calibrations.(ignored)
|
|
*
|
|
* @param mykDevice is ADI hardware layer settings pointer specific to
|
|
* a Mykonos instance which contains basic settings such as spi,
|
|
* gpio, tx/rx and jesd configurations.
|
|
* @param freq_Hz is the target frequancy in Hz.
|
|
*
|
|
* @return None.
|
|
*
|
|
* @note The procedure is used when a radio frequency (RF) phased-lock loop
|
|
* (PLL) change is required with the following conditions:
|
|
* - A desire to change the Rx, Tx, and ORx frequencies.
|
|
* - The frequency step change is more than 100 MHz.
|
|
* - The frequency step does cross the divide by 2 boundaries outlined
|
|
* in AD9371/9375-UG-992-Rev.B-Table 96.
|
|
*
|
|
*******************************************************************************/
|
|
int HW_9371LargeFrequencyChange(mykonosDevice_t *mykDevice, uint64_t freq_Hz);
|
|
|
|
/******************************************************************************/
|
|
/**
|
|
*
|
|
* Handles AD9371 TX & RX frequency change axi gpio interruput.
|
|
*
|
|
* @param CallBackRef is the callback reference, usually the instance
|
|
* pointer of the connecting driver.
|
|
*
|
|
* @return None.
|
|
*
|
|
* @note None.
|
|
*
|
|
*******************************************************************************/
|
|
void FreqIntrHandler(void *CallbackRef);
|
|
|
|
/******************************************************************************/
|
|
/**
|
|
*
|
|
* Handles AD9371 Rx gain index change axi gpio interruput.
|
|
*
|
|
* @param CallBackRef is the callback reference, usually the instance
|
|
* pointer of the connecting driver.
|
|
*
|
|
* @return None.
|
|
*
|
|
* @note None.
|
|
*
|
|
*******************************************************************************/
|
|
void GainIntrHandler(void *CallbackRef);
|
|
|
|
/******************************************************************************/
|
|
/**
|
|
*
|
|
* Handles AD9371 Tx attenuation change axi gpio interruput.
|
|
*
|
|
* @param CallBackRef is the callback reference, usually the instance
|
|
* pointer of the connecting driver.
|
|
*
|
|
* @return None.
|
|
*
|
|
* @note None.
|
|
*
|
|
*******************************************************************************/
|
|
void AttnIntrHandler(void *CallbackRef);
|
|
|
|
#endif /* SRC_HEADLESS_H_ */
|