2023-07-21 10:04:33 +08:00
//******************** (C) COPYRIGHT 2022 SmartLogic*******************************
// FileName : ucp_api_jesd.h
2023-09-22 12:14:28 +08:00
// Author : Boheng Lin bhlin919@126.com
2023-07-21 10:04:33 +08:00
// Date First Issued : 2023-03-04 14:37:50 PM
// Last Modified :
// Description :
// ------------------------------------------------------------
// Modification History:
// Version Date Author Modification Description
//
//**********************************************************************************
# ifndef UCP_API_JESD_H_
# define UCP_API_JESD_H_
# include <stdio.h>
2023-09-22 12:14:28 +08:00
# include <stdint.h>
2023-07-21 10:04:33 +08:00
# include <stdlib.h>
# ifdef __cplusplus
extern " C " {
# endif
2023-09-22 12:14:28 +08:00
/**
* \ brief the max channels of trx
*/
# define MAX_UCP_JESD_TRX_CH (4)
2023-07-21 10:04:33 +08:00
/**
* \ brief Data structure to hold UCP API State
*/
typedef enum ucp_jesd_States
{
UCP_JESD_STATE_POWERONRESET = 0x00 ,
UCP_JESD_STATE_JSCTRLOK = 0x01 ,
UCP_JESD_STATE_CRGOK = 0x02 ,
UCP_JESD_STATE_SUBCTRLOK = 0x04 ,
UCP_JESD_STATE_204COREOK = 0x08 ,
UCP_JESD_STATE_PMAOK = 0x10 ,
UCP_JESD_STATE_TIMEROK = 0x20 ,
UCP_JESD_STATE_RUN = 0x40
} ucp_jesd_States_e ;
2023-07-24 19:59:22 +08:00
/**
* \ brief Data structure to ape working step
*/
typedef enum ucp_jesd_ApeWorkStep
{
UCP_JESD_APE_POWERONRESET = 0x00 ,
UCP_JESD_APE_CLOCKGENRUN = 0x01 ,
UCP_JESD_APE_CELLRUN = 0x02 ,
} ucp_jesd_ApeWorkStep_e ;
2023-09-22 12:14:28 +08:00
/**
* \ brief Data structure to the level status of trx ' s control pins .
*/
typedef enum ucp_jesd_gpioEnableLevel
{
UCP_JESD_TRX_GPIO_DISABLE = 0x00 ,
UCP_JESD_TRX_GPIO_VALID_HIGH = 0x01 ,
UCP_JESD_TRX_GPIO_VALID_LOW = 0x02 ,
} ucp_jesd_gpioEnableLevel_e ;
2025-05-20 01:51:25 +08:00
/**
* \ brief Index of trx ' s control pins .
*/
enum {
GPIO_TRX_TX1 = 0 ,
GPIO_TRX_TX2 ,
GPIO_TRX_TX3 ,
GPIO_TRX_TX4 ,
GPIO_RF_TX1 ,
GPIO_RF_TX2 ,
GPIO_RF_TX3 ,
GPIO_RF_TX4 ,
GPIO_SW_TX1 ,
GPIO_SW_TX2 ,
GPIO_SW_TX3 ,
GPIO_SW_TX4 ,
GPIO_TRX_RX1 ,
GPIO_TRX_RX2 ,
GPIO_TRX_RX3 ,
GPIO_TRX_RX4 ,
GPIO_RF_RX1 ,
GPIO_RF_RX2 ,
GPIO_RF_RX3 ,
GPIO_RF_RX4 ,
GPIO_SW_RX1 ,
GPIO_SW_RX2 ,
GPIO_SW_RX3 ,
GPIO_SW_RX4 ,
GPIO_TRX_ORX1 ,
GPIO_TRX_ORX2 ,
GPIO_TRX_ORX3 ,
GPIO_TRX_ORX4 ,
GPIO_RF_ORX1 ,
GPIO_RF_ORX2 ,
GPIO_RF_ORX3 ,
GPIO_RF_ORX4 ,
GPIO_SW_ORX1 ,
GPIO_SW_ORX2 ,
GPIO_SW_ORX3 ,
GPIO_SW_ORX4 ,
GPIO_TRIGER ,
GPIO_TR_MAX = 40
} ;
2023-07-24 19:59:22 +08:00
/**
* \ brief Data structure to contrl pins of rf ' s trx
*/
2023-09-22 12:14:28 +08:00
typedef struct ucp_jesd_gpio {
uint8_t port ;
uint8_t pin ;
uint8_t enableLevel ;
} ucp_jesd_gpio_t ;
2023-12-29 16:48:28 +08:00
typedef struct ucp_jesd_tr_gpio {
ucp_jesd_gpio_t trx ;
ucp_jesd_gpio_t rf ;
ucp_jesd_gpio_t sw ;
} ucp_jesd_tr_gpio_t ;
2023-07-24 19:59:22 +08:00
typedef struct ucp_jesd_TrxGpio {
2023-12-29 16:48:28 +08:00
ucp_jesd_tr_gpio_t tx ;
ucp_jesd_tr_gpio_t rx ;
ucp_jesd_tr_gpio_t orx ;
2023-07-24 19:59:22 +08:00
} ucp_jesd_TrxGpio_t ;
2023-09-22 12:14:28 +08:00
/**
* \ brief Data structure to configure of trx ' s contrl pins
*/
typedef struct ucp_jesd_TrxGpioCfg {
2023-12-29 16:48:28 +08:00
char board [ 16 ] ;
uint32_t version ;
2023-09-22 12:14:28 +08:00
uint8_t maxCh ;
2023-10-26 09:01:30 +08:00
uint8_t devClkSrc ;
2023-09-22 12:14:28 +08:00
int32_t uldelay ;
int32_t dldelay ;
2025-05-20 01:51:25 +08:00
char lvdsCoupling [ 16 ] ;
2023-09-22 12:14:28 +08:00
ucp_jesd_gpio_t triger ;
ucp_jesd_TrxGpio_t ch [ MAX_UCP_JESD_TRX_CH ] ;
} ucp_jesd_TrxGpioCfg_t ;
2023-07-21 10:04:33 +08:00
/**
* \ brief Data structure to hold digital clock settings
*/
typedef struct ucp_jesd_CommonSettings
{
2023-12-29 16:48:28 +08:00
uint32_t devClock_kHz ; /*!< Device clock frequency in kHz */
2023-07-21 10:04:33 +08:00
uint8_t enableJesd204C ; /*!< 1= Enable JESD204C framer, 0 = use JESD204B framer */
uint8_t jesdSubClass ;
} ucp_jesd_CommonSettings_t ;
/**
* \ brief Data structure to hold UCP JESD204b Framer configuration settings
*/
typedef struct ucp_jesd_FrmCfg
{
uint8_t enable ;
2023-12-29 16:48:28 +08:00
uint32_t sampleClock_kHz ; /*!< Sample clock frequency in kHz */
2023-07-21 10:04:33 +08:00
uint8_t jesd204M ; /*!< Number of ADCs (0, 2, or 4) where 2 ADCs are required per receive chain (I and Q). */
uint16_t jesd204K ; /*!< Number of frames in a multiframe. Default = 32, F*K must be modulo 4. Where, F=2*M/numberOfLanes (Max 32 for JESD204B, Max 256 for JESD204C). */
uint8_t jesd204F ; /*!< Number of bytes(octets) per frame (Valid 1, 2, 4, 8). */
uint8_t jesd204Np ; /*!< converter sample resolution (12, 16, 24). */
uint8_t jesd204E ; /*!< JESD204C E parameter */
uint8_t scramble ; /*!< Scrambling off if framerScramble = 0, if framerScramble > 0 scrambling is enabled */
uint8_t serializerLanesEnabled ; /*!< Serializer lane select bit field. Where, [0] = Lane0 enabled, [1] = Lane1 enabled, etc */
uint8_t syncbInSelect ; /*!< Selects SYNCb input source. Where, 0 = use SYNCBIN0 for this framer, 1 = use SYNCBIN1 for this framer, 2 = use SYNCBIN2 */
} ucp_jesd_FrmCfg_t ;
/**
* \ brief Data structure to hold the settings for the deframer configuration
*/
typedef struct ucp_jesd_DfrmCfg
{
uint8_t enable ;
2023-12-29 16:48:28 +08:00
uint32_t sampleClock_kHz ; /*!< Sample clock frequency in kHz */
2023-07-21 10:04:33 +08:00
uint8_t jesd204M ; /*!< Number of DACs (0, 2, or 4) - 2 DACs per transmit chain (I and Q) */
uint16_t jesd204K ; /*!< Number of frames in a multiframe. Default = 32, F*K = modulo 4. Where, F=2*M/numberOfLanes (Max 32 for JESD204B, Max 256 for JESD204C) */
uint8_t jesd204F ; /*!< Number of bytes(octets) per frame . */
uint8_t jesd204Np ; /*!< converter sample resolution (12, 16) */
uint8_t jesd204E ; /*!< JESD204C E parameter */
uint8_t scramble ; /*!< Scrambling off if scramble = 0, if framerScramble > 0 scrambling is enabled */
uint8_t deserializerLanesEnabled ; /*!< Deserializer lane select bit field. Where, [0] = Lane0 enabled, [1] = Lane1 enabled, etc */
uint8_t syncbOutSelect ; /*!< Selects deframer SYNCBOUT pin (0 = SYNCBOUT0, 1 = SYNCBOUT1, 2 = output SYNCB to SYNCBOUT0 and SYNCBOUT1) */
} ucp_jesd_DfrmCfg_t ;
/**
* \ brief Data structure to hold ucp JESD Framer and Deframer configuration information
*/
typedef struct ucp_jesd_Init
{
ucp_jesd_CommonSettings_t common ; /*!< Holds settings for CLKPLL and reference clock */
ucp_jesd_FrmCfg_t framer ; /*!< Framer 0 configuration data structures */
ucp_jesd_DfrmCfg_t deframer [ 2 ] ; /*!< Deframer 0/1 configuration data structures */
} ucp_jesd_Init_t ;
/**
* \ brief get jesd module ' s version
*
* \ param void
*
* \ retval version .
*/
extern uint32_t UCP_API_JESD_Version ( void ) ;
/**
2023-07-24 19:59:22 +08:00
* \ brief Sets up the ape work step
2023-07-21 10:04:33 +08:00
*
2023-07-24 19:59:22 +08:00
* \ param step
* UCP_JESD_APE_POWERONRESET : when jesd reset or power up , set this value
* UCP_JESD_APE_CLOCKGENRUN : when clock gen chip sets up , set this value
* UCP_JESD_APE_CELLRUN : when cell and trx set up , set this value
2023-07-21 10:04:33 +08:00
*
* \ retval none .
*/
2023-07-24 19:59:22 +08:00
extern void UCP_API_JESD_ApeWorkStep ( ucp_jesd_ApeWorkStep_e step ) ;
/**
* \ brief Sets up the gpios of tx and rx
*
* \ param setting
*
* \ retval none .
*/
2025-05-20 01:51:25 +08:00
extern void UCP_API_JESD_TrxGpioSetup ( const char * trxGpioConfigFile , uint16_t enLog ) ;
2023-07-21 10:04:33 +08:00
2023-12-29 16:48:28 +08:00
/**
* \ brief Gets the gpio ' s inf of tx and rx
*
* \ param void
*
* \ retval TrxGpioCfg point .
*/
extern ucp_jesd_TrxGpioCfg_t * UCP_API_JESD_TrxGpioGet ( void ) ;
2023-07-21 10:04:33 +08:00
/**
* \ brief Sets up the ucp4008 jesd ' s para setting
*
* \ param setting
*
* \ retval none .
*/
extern ucp_jesd_States_e UCP_API_JESD_Init ( ucp_jesd_Init_t * setting ) ;
/**
* \ brief Sets up the ucp4008 jesd ' s para setting
*
* \ param setting
*
* \ retval none .
*/
extern ucp_jesd_States_e UCP_API_JESD_CellSetup ( ucp_jesd_Init_t * setting ) ;
/**
* \ brief Sets up the ucp4008 jesd ' s para setting
*
* \ param setting
*
* \ retval none .
*/
extern void UCP_API_JESD_CellDelete ( void ) ;
2023-12-29 16:48:28 +08:00
/**
* \ brief gpio of rf controlling
*
* \ param setting
*
* \ retval none .
*/
2025-05-20 01:51:25 +08:00
extern int ucp_jesd_gpioSet ( const int pinIdex , int value ) ;
extern int ucp_jesd_gpioGet ( const int pinIdex ) ;
2023-12-29 16:48:28 +08:00
extern void UCP_API_GPIO_Tx ( void ) ;
extern void UCP_API_GPIO_Rx ( void ) ;
extern void UCP_API_GPIO_On ( void ) ;
extern void UCP_API_GPIO_Off ( void ) ;
extern void UCP_API_GPIO_OrxOn ( void ) ;
extern void UCP_API_GPIO_OrxOff ( void ) ;
extern void UCP_API_GPIO_TrigOn ( void ) ;
extern void UCP_API_GPIO_TrigOff ( void ) ;
2023-07-21 10:04:33 +08:00
# ifdef __cplusplus
}
# endif
# endif /* #ifndef UCP_API_JESD_H_ */
2023-07-24 19:59:22 +08:00