Files
CX9261API-C/cx9261adriver_c.h
T
Gatsby 2fc5941f0f refactor: use standard integer types; remove <algorithm> dependency
- Replaced unsigned char,  int and long long with uint8_t int32_t and int64_t for platform independence
- Removed <algorithm> dependency, implemented custom alternatives
2024-11-07 14:13:37 +08:00

986 lines
28 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifndef __CX9261ADRIVER_C_H
#define __CX9261ADRIVER_C_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __cplusplus
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#endif
#define MAX_NUM_FIR 64
#define MAX_MULTI_POINTS 64
extern uint32_t CX9261A_RiscvBinLen;
extern uint8_t *CX9261A_RiscvBin;
typedef enum {
CX9261A_WKM_Rx,
CX9261A_WKM_Tx,
CX9261A_WKM_FDD
} CX9261A_WorkMode;
/**
* @brief 收发数据通道数量
* @note 此模式并不代表使用几个通道进行收发
*/
typedef enum {
CX9261A_TRM_R1T1,
CX9261A_TRM_R2T2
} CX9261A_TrMode;
/**
* @brief 收发接口通道数量
*/
typedef enum {
CX9261A_PORTM_Single,
CX9261A_PORTM_Dual
} CX9261A_PortMode;
/**
* @brief 接口模式:
* CMOS CMOS接口模式,
* LVDS_S LVDS顺序模式,
* LVDS_E LVDS奇偶模式
*/
typedef enum {
CX9261A_IOM_CMOS,
CX9261A_IOM_LVDS_S,
CX9261A_IOM_LVDS_E
} CX9261A_IOMode;
/**
* @brief 本振来源
*/
typedef enum {
CX9261A_LOSRC_Pll1 = 0b00001,
CX9261A_LOSRC_Pll2 = 0b00010,
CX9261A_LOSRC_Pll3 = 0b00100,
CX9261A_LOSRC_Pll4 = 0b01000,
CX9261A_LOSRC_Pll5 = 0b10000,
CX9261A_LOSRC_Off = 0
} CX9261A_LoSource;
/**
* @brief 接收通道
*/
typedef enum {
CX9261A_RXCH_Rx1 = 1,
CX9261A_RXCH_Rx2,
CX9261A_RXCH_Rx3
} CX9261A_RxChannel;
/**
* @brief 发射通道
*/
typedef enum {
CX9261A_TXCH_Tx1 = 1,
CX9261A_TXCH_Tx2
} CX9261A_TxChannel;
/**
* @brief 电源模式
*/
typedef enum {
CX9261A_PWM_Shutdown = 0,
CX9261A_PWM_Sleep,
CX9261A_PWM_Alert,
CX9261A_PWM_Calib,
CX9261A_PWM_Receive,
CX9261A_PWM_Transmit,
CX9261A_PWM_Duplex,
CX9261A_PWM_Obs
} CX9261A_PowerMode;
/**
* @brief NCO模式
*/
typedef enum {
CX9261A_NCOM_Bypass = 0,
CX9261A_NCOM_Up,
CX9261A_NCOM_Down,
CX9261A_NCOM_BIST,
CX9261A_NCOM_Master,
CX9261A_NCOM_Slaver
} CX9261A_NCOMode;
/**
* @brief 温补模式 DAC: DAC模式 Band: 跳子带模式
*/
typedef enum {
CX9261A_TEMPCP_DAC = 0,
CX9261A_TEMPCP_Band
} CX9261A_TemperatureComp;
/**
* @brief 校准方法 TST: 时域统计 Rx通道使用, Bisec: 二分法 Tx通道使用, MultiPoints: 多点校准
*/
typedef enum {
CX9261A_CALM_TST = 0,
CX9261A_CALM_Bisec,
CX9261A_CALM_MultiPoints,
CX9261A_CALM_Tracking
} CX9261A_CalibMethod;
/**
* @brief DC校准方法 Tracking: 跟踪校准 HighPass: 高通滤波器滤掉直流
*/
typedef enum {
CX9261A_DCCALM_Tracking=0,
CX9261A_DCCALM_HighPass
} CX9261A_DCCalibMethod;
typedef struct {
CX9261A_LoSource first;
CX9261A_LoSource second;
} CX9261A_LoSourcePair;
typedef struct {
CX9261A_LoSourcePair key;
uint16_t value;
} CX9261A_SrcMapEntry;
/**
* @brief 接收通道本振来源映射表
*/
static const CX9261A_SrcMapEntry CX9261A_rxSrcMap[] = {
{ { CX9261A_LOSRC_Pll2, CX9261A_LOSRC_Pll2 }, 0b0010000 },
{ { CX9261A_LOSRC_Pll1, CX9261A_LOSRC_Pll1 }, 0b1101000 },
{ { CX9261A_LOSRC_Pll2, CX9261A_LOSRC_Pll1 }, 0b0100000 },
{ { CX9261A_LOSRC_Pll1, CX9261A_LOSRC_Pll2 }, 0b1000000 },
{ { CX9261A_LOSRC_Off, CX9261A_LOSRC_Pll1 }, 0b0101010 },
{ { CX9261A_LOSRC_Off, CX9261A_LOSRC_Pll2 }, 0b1010010 },
{ { CX9261A_LOSRC_Pll1, CX9261A_LOSRC_Off }, 0b1001001 },
{ { CX9261A_LOSRC_Pll2, CX9261A_LOSRC_Off }, 0b0110001 },
{ { CX9261A_LOSRC_Off, CX9261A_LOSRC_Off }, 0b0011011 }
};
/**
* @brief 发射通道本振来源映射表
*/
static const CX9261A_SrcMapEntry CX9261A_txSrcMap[] = {
{ { CX9261A_LOSRC_Pll4, CX9261A_LOSRC_Pll4 }, 16 }, { { CX9261A_LOSRC_Pll3, CX9261A_LOSRC_Pll3 }, 104 },
{ { CX9261A_LOSRC_Pll4, CX9261A_LOSRC_Pll3 }, 32 }, { { CX9261A_LOSRC_Pll3, CX9261A_LOSRC_Pll4 }, 64 },
{ { CX9261A_LOSRC_Pll2, CX9261A_LOSRC_Pll2 }, 1560 }, { { CX9261A_LOSRC_Pll1, CX9261A_LOSRC_Pll1 }, 1944 },
{ { CX9261A_LOSRC_Pll2, CX9261A_LOSRC_Pll1 }, 1688 }, { { CX9261A_LOSRC_Pll1, CX9261A_LOSRC_Pll2 }, 1816 },
{ { CX9261A_LOSRC_Off, CX9261A_LOSRC_Pll3 }, 42 }, { { CX9261A_LOSRC_Off, CX9261A_LOSRC_Pll4 }, 82 },
{ { CX9261A_LOSRC_Off, CX9261A_LOSRC_Pll2 }, 794 }, { { CX9261A_LOSRC_Off, CX9261A_LOSRC_Pll1 }, 666 },
{ { CX9261A_LOSRC_Pll3, CX9261A_LOSRC_Off }, 73 }, { { CX9261A_LOSRC_Pll4, CX9261A_LOSRC_Off }, 49 },
{ { CX9261A_LOSRC_Pll2, CX9261A_LOSRC_Off }, 1177 }, { { CX9261A_LOSRC_Pll1, CX9261A_LOSRC_Off }, 1305 },
{ { CX9261A_LOSRC_Off, CX9261A_LOSRC_Off }, 27 }, { { CX9261A_LOSRC_Pll1, CX9261A_LOSRC_Pll3 }, 1320 },
{ { CX9261A_LOSRC_Pll1, CX9261A_LOSRC_Pll4 }, 1360 }, { { CX9261A_LOSRC_Pll2, CX9261A_LOSRC_Pll3 }, 1064 },
{ { CX9261A_LOSRC_Pll2, CX9261A_LOSRC_Pll4 }, 1104 }, { { CX9261A_LOSRC_Pll3, CX9261A_LOSRC_Pll1 }, 712 },
{ { CX9261A_LOSRC_Pll4, CX9261A_LOSRC_Pll1 }, 688 }, { { CX9261A_LOSRC_Pll3, CX9261A_LOSRC_Pll2 }, 584 },
{ { CX9261A_LOSRC_Pll4, CX9261A_LOSRC_Pll2 }, 560 }
};
/**
* @brief 环路参数选择表
*/
static const uint8_t CX9261A_coreTable[7][4][3] = {
{ { 0x0C, 0x30, 0x08 }, { 0x0B, 0x30, 0x09 }, { 0x0C, 0x30, 0x05 }, { 0x0D, 0x30, 0x08 } },
{ { 0x0C, 0x30, 0x0C }, { 0x0B, 0x30, 0x0E }, { 0x0C, 0x30, 0x08 }, { 0x0D, 0x30, 0x0B } },
{ { 0x0C, 0x20, 0x10 }, { 0x0B, 0x20, 0x10 }, { 0x0C, 0x20, 0x0A }, { 0x0D, 0x20, 0x0D } },
{ { 0x0C, 0x20, 0x11 }, { 0x0B, 0x20, 0x13 }, { 0x0C, 0x20, 0x0C }, { 0x0D, 0x20, 0x0F } },
{ { 0x0D, 0x30, 0x14 }, { 0x0D, 0x22, 0x14 }, { 0x0D, 0x20, 0x0D }, { 0x0D, 0x15, 0x0C } },
{ { 0x0E, 0x30, 0x18 }, { 0x0E, 0x25, 0x16 }, { 0x0E, 0x25, 0x0F }, { 0x0E, 0x18, 0x0F } },
{ { 0x0F, 0x38, 0x1A }, { 0x0F, 0x32, 0x1C }, { 0x0F, 0x18, 0x12 }, { 0x0F, 0x18, 0x12 } }
};
/**
* @brief AGC PDT模式的结构体
*/
typedef struct
{
int pdtN;
int pdtM;
} CX9261A_AGCPDT;
/**
* @brief AGC LMT模式的结构体
*/
typedef struct
{
int count; /**< LMT统计次数阈值*/
int threshold1; /**< LMT阈值第一档*/
int threshold2; /**< LMT阈值第二档*/
int threshold3; /**< LMT阈值第三档*/
int threshold4; /**< LMT阈值第四档*/
} CX9261A_AGCLMT;
/**
* @brief AGC DIG模式的结构体
*/
typedef struct
{
int count; /**< DIG统计次数阈值*/
int threshold1; /**< DIG阈值第一档*/
int threshold2; /**< DIG阈值第二档*/
int threshold3; /**< DIG阈值第三档*/
int threshold4; /**< DIG阈值第四档*/
} CX9261A_AGCDIG;
/**
* @brief AGC模式的结构体
*/
typedef struct
{
int mode; /**< AGC模式选择*/
CX9261A_AGCPDT pdt; /**< AGC PDT模式的结构体*/
CX9261A_AGCLMT lmt; /**< AGC LMT模式的结构体*/
CX9261A_AGCDIG dig; /**< AGC DIG模式的结构体*/
} CX9261A_AGC;
/**
* @brief 时钟相关参数结构体
*/
typedef struct
{
double ref; /**< 参考时钟频率,单位MHz*/
double adc; /**< ADC频率,单位MHz*/
int refDiv; /**< 参考时钟分频比*/
bool bbUseIntDiv; /**< 是否使用整数分频模式*/
bool refDoubler; /**< 是否使用参考时钟倍频器*/
} CX9261A_Clock;
/**
* @brief 校准相关参数结构体
*/
typedef struct
{
bool calibDC; /**< 是否开启DC Tracking*/
CX9261A_DCCalibMethod dcCalibMethod;
int dcTrackingLength; /**< DC Tracking长度*/
int dcHighPassFactor; /**< DC高通滤波系数,越大代表滤波器阶数越高,滤波范围越窄*/
uint8_t rx1CalibPll; /**< rx1校准的pll选择,Pll1 | Pll2*/
uint8_t rx2CalibPll; /**< rx2校准的pll选择,Pll1 | Pll2*/
uint8_t rx3CalibPll; /**< rx3校准的pll选择,Pll5*/
uint8_t tx1CalibPll; /**< tx1校准的pll选择,Pll1 | Pll2 | Pll3 | Pll4*/
uint8_t tx2CalibPll; /**< tx2校准的pll选择,Pll1 | Pll2 | Pll3 | Pll4*/
CX9261A_CalibMethod rxMethod;
CX9261A_CalibMethod txMethod;
double f0; /**< 校准音频率*/
uint32_t numRxPoint; /**< Rx多点校准的频率个数*/
uint32_t numTxPoint; /**< Tx多点校准的频率个数*/
double rxMultiPoints[MAX_MULTI_POINTS]; /**< Rx多点校准的频率*/
double txMultiPoints[MAX_MULTI_POINTS]; /**< Tx多点校准的频率*/
} CX9261A_Calib;
/**
* @brief 配置PLL来源相关参数结构体
*/
typedef struct
{
bool rxUseExt; /**< 接收通道是否使用外本振*/
bool txUseExt; /**< 发射通道是否使用外本振*/
CX9261A_LoSource rx1Source; /**< Rx1通道本振来源*/
CX9261A_LoSource rx2Source; /**< Rx2通道本振来源*/
CX9261A_LoSource rx3Source; /**< Rx3通道本振来源*/
CX9261A_LoSource tx1Source; /**< Tx1通道本振来源*/
CX9261A_LoSource tx2Source; /**< Tx2通道本振来源*/
} CX9261A_PllSource;
/**
* @brief 配置PLL频率相关参数结构体
*/
typedef struct
{
double pll1Freq; /**< PLL1本振时钟,单位MHz*/
double pll2Freq; /**< PLL2本振时钟,单位MHz*/
double pll3Freq; /**< PLL3本振时钟,单位MHz*/
double pll4Freq; /**< PLL4本振时钟,单位MHz*/
double pll5Freq; /**< PLL5本振时钟,单位MHz*/
double rxExtFreq; /**< 接收通道使用外本振时,外本振频率,单位MHz*/
double txExtFreq; /**< 发射通道使用外本振时,外本振频率,单位MHz*/
} CX9261A_PllFreq;
/**
* @brief 配置接口相关参数结构体
*/
typedef struct
{
CX9261A_WorkMode workMode; /**< 芯片工作模式*/
CX9261A_TrMode trMode; /**< 收发数据通道模式*/
CX9261A_PortMode portMode; /**< 收发接口通道模式*/
CX9261A_IOMode ioMode; /**< 接口电平模式*/
} CX9261A_Interface;
/**
* @brief 配置TX NCO相关参数结构体
*/
typedef struct
{
bool txUseBist; /**< 是否开启BIST模式*/
double txNCOFreq; /**< NCO频率*/
} CX9261A_TxNCO;
/**
* @brief 配置RX NCO相关参数结构体
*/
typedef struct
{
bool rxUseBist; /**< 是否开启BIST模式*/
bool rxNCOBypass; /**< 是否Bypass NCO*/
bool rxNCOUpward; /**< 开启上/下混频模式*/
bool rxNCOMaster; /**< 使用Master/Slaver模式*/
double rxNCOFreq; /**< NCO频率*/
} CX9261A_RxNCO;
/**
* @brief 配置接收通道相关参数结构体
*/
typedef struct {
double bandwidth; /**< 接收通道1dB带宽,单位MHz*/
int tia; /**< 接收通道TIA增益配置,推荐配置6*/
int mixer; /**< 接收通道Mixer增益配置*/
} CX9261A_RxConfig;
/**
* @brief 配置发射通道相关参数结构体
*/
typedef struct {
double bandwidth; /**< 发射通道1dB带宽,单位MHz*/
int mixer; /**< 发射通道Mixer增益配置*/
} CX9261A_TxConfig;
/**
* @brief 配置滤波器相关参数结构体,0代表bypass
*/
typedef struct {
int fir; /**< FIR滤波器抽取/插值倍数*/
int hbf1; /**< HBF1滤波器抽取/插值倍数*/
int hbf2; /**< HBF2滤波器抽取/插值倍数*/
int hbf3; /**< HBF3滤波器抽取/插值倍数*/
int cic; /**< CIC滤波器抽取/插值倍数*/
} CX9261A_Filters;
/**
* @brief 配置电源模式结构体,1代表该模块上电
*/
typedef struct {
bool dig_tx2;
bool dig_tx1;
bool dig_rx3;
bool dig_rx2;
bool dig_rx1;
bool fref1_rx;
bool auxadc2;
bool auxadc1;
bool auxdac;
bool temp_sensor;
bool bgr;
bool exlo;
bool tx2;
bool tx1;
bool rx3;
bool rx2;
bool rx1;
bool pll5_ldo;
bool pll5;
bool pll4_ldo;
bool pll4;
bool pll3_ldo;
bool pll3;
bool pll2_ldo;
bool pll2;
bool pll1_ldo;
bool pll1;
bool bbpll;
} CX9261A_Power;
/**
* @brief 配置电源模式管理,包含模式选择,接收模式,发射模式,FDD模式
*/
typedef struct {
CX9261A_PowerMode powerMode;
CX9261A_Power rxPower;
CX9261A_Power txPower;
CX9261A_Power fddPower;
} CX9261A_PowerManagement;
/**
* @brief 储存窄带校准结果的结构体
*/
typedef struct {
int bHigh;
int bLow;
int cHigh;
int cLow;
int dciHigh;
int dciLow;
int dcqHigh;
int dcqLow;
} CX9261A_CalibPredis;
/**
* @brief CX9261A结构体
*/
typedef struct {
CX9261A_TemperatureComp tempComp; /**< 温度补偿*/
CX9261A_AGC agc; /**< AGC结构体*/
CX9261A_Interface interface; /**< Interface结构体*/
CX9261A_Clock clock; /**< Clock结构体*/
CX9261A_PllSource pllSource; /**< PllSource结构体*/
CX9261A_Calib calib; /**< Calib结构体*/
CX9261A_PllFreq pllFreq; /**< PllFreq结构体*/
CX9261A_TxNCO txNco; /**< TxNCO结构体*/
CX9261A_RxNCO rxNco; /**< RxNCO结构体*/
CX9261A_RxConfig rx1Config; /**< RxConfig结构体*/
CX9261A_RxConfig rx2Config; /**< RxConfig结构体*/
CX9261A_RxConfig rx3Config; /**< RxConfig结构体*/
CX9261A_TxConfig tx1Config; /**< TxConfig结构体*/
CX9261A_TxConfig tx2Config; /**< TxConfig结构体*/
CX9261A_Filters rxFilters; /**< Filters结构体*/
CX9261A_Filters txFilters; /**< Filters结构体*/
CX9261A_PowerManagement powerManagement; /**< PowerManagement结构体*/
uint32_t numRxFIR;
uint32_t numTxFIR;
double rxFIRCoe[MAX_NUM_FIR]; /**< Rx FIR滤波器系数*/
double txFIRCoe[MAX_NUM_FIR]; /**< Tx FIR滤波器系数*/
} CX9261A_CX9261AConfiguration;
typedef struct {
int first;
int second;
}QecStatePair;
// 定义函数指针类型
typedef void (*CX9261A_LoggingFunc)(const char* msg);
typedef void (*CX9261A_WriteSpiFunc)(uint16_t address, uint8_t value);
typedef int (*CX9261A_ReadSpiFunc)(uint16_t address);
typedef void (*CX9261A_SetPinFunc)(uint32_t pin, bool value);
typedef void (*CX9261A_PauseFunc)(double ms);
/**
* @brief 绑定日志函数
* @param msg 要输出的内容
*/
void CX9261A_setLoggingFunc(CX9261A_LoggingFunc func);
/**
* @brief 绑定SPI写入寄存器函数
* @param address 要写入的寄存器地址
* @param value 要写入的寄存器值
*/
void CX9261A_setWriteSpiFunc(CX9261A_WriteSpiFunc func);
/**
* @brief 绑定等待函数
* @param ms 等待时间,单位毫秒
*/
void CX9261A_setReadSpiFunc(CX9261A_ReadSpiFunc func);
/**
* @brief 绑定SPI读取寄存器函数
* @param address 要读取的寄存器地址
* @return 返回的寄存器值
*/
void CX9261A_setPauseFunc(CX9261A_PauseFunc func);
/**
* @brief 绑定配置FPGA对应寄存器函数
* @param pin 寄存器地址
* @param value 寄存器值
*/
void CX9261A_setSetPinFunc(CX9261A_SetPinFunc func);
/**
* @brief 初始化芯片状态,写入与具体配置无关的寄存器值
*/
void CX9261A_initialChip();
/**
* @brief 初始化电源配置,如果只自定义配置部分模式下的电源管理,在自定义配置之前需要先调用此函数
*/
void CX9261A_initialPowerConfig(const CX9261A_CX9261AConfiguration *config);
/**
* @brief 初始化BBPLL相关寄存器,如果调用了initialChip,则无需单独调用此函数
*/
void CX9261A_initialBBPLL();
/**
* @brief 初始化PLL1相关寄存器,如果调用了initialChip,则无需单独调用此函数
*/
void CX9261A_initialPLL1();
/**
* @brief 初始化PLL2相关寄存器,如果调用了initialChip,则无需单独调用此函数
*/
void CX9261A_initialPLL2();
/**
* @brief 初始化PLL3相关寄存器,如果调用了initialChip,则无需单独调用此函数
*/
void CX9261A_initialPLL3();
/**
* @brief 初始化PLL4相关寄存器,如果调用了initialChip,则无需单独调用此函数
*/
void CX9261A_initialPLL4();
/**
* @brief 初始化PLL5相关寄存器,如果调用了initialChip,则无需单独调用此函数
*/
void CX9261A_initialPLL5();
/**
* @brief 配置受参考时钟频率影响的寄存器
* @param ref 参考时钟频率,单位MHz
*/
void CX9261A_configRef(double ref);
/**
* @brief 配置时钟相关寄存器,包括ADC和BBPLL
* @param config CX9261A参数结构体
*/
void CX9261A_configBBPLL(const CX9261A_CX9261AConfiguration *config);
/**
* @brief BBPLL AFC
* @return 是否锁定
*/
bool CX9261A_afcBBPll();
/**
* @brief 配置PLL1频率
* @param lo 目标频率
* @param clock 时钟结构体,使用其中的ref和refDoubler属性
*/
void CX9261A_configPll1(double lo, const CX9261A_Clock *clock);
/**
* @brief Pll1 AFC
* @return 是否锁定
*/
bool CX9261A_afcPll1();
/**
* @brief 配置PLL2频率
* @param lo 目标频率
* @param clock 时钟结构体,使用其中的ref和refDoubler属性
*/
void CX9261A_configPll2(double lo, const CX9261A_Clock *clock);
/**
* @brief Pll2 AFC
* @return 是否锁定
*/
bool CX9261A_afcPll2();
/**
* @brief 配置PLL3频率
* @param lo 目标频率
* @param clock 时钟结构体,使用其中的ref和refDoubler属性
*/
void CX9261A_configPll3(double lo, const CX9261A_Clock *clock);
/**
* @brief Pll3 AFC
* @return 是否锁定
*/
bool CX9261A_afcPll3();
/**
* @brief 配置PLL4频率
* @param lo 目标频率
* @param clock 时钟结构体,使用其中的ref和refDoubler属性
*/
void CX9261A_configPll4(double lo, const CX9261A_Clock *clock);
/**
* @brief Pll4 AFC
* @return 是否锁定
*/
bool CX9261A_afcPll4();
/**
* @brief 配置PLL5频率
* @param lo 目标频率
* @param clock 时钟结构体,使用其中的ref和refDoubler属性
*/
void CX9261A_configPll5(double lo, const CX9261A_Clock *clock);
/**
* @brief Pll5 AFC
* @return 是否锁定
*/
bool CX9261A_afcPll5();
/**
* @brief 配置AGC模式
* @param mode 模式0~13
*/
void CX9261A_configAGCMode(int mode);
/**
* @brief 配置AGC PDT
* @param pdt AGCPDT结构体
*/
void CX9261A_configAGCPDT(const CX9261A_AGCPDT *pdt);
/**
* @brief 配置AGC LMT
* @param lmt AGCLMT结构体
*/
void CX9261A_configAGCLMT(const CX9261A_AGCLMT *lmt);
/**
* @brief 配置AGC DIG
* @param dig AGCDIG结构体
*/
void CX9261A_configAGCDIG(const CX9261A_AGCDIG *dig);
/**
* @brief 配置AGC
* @param agc AGC结构体
*/
void CX9261A_configAGC(const CX9261A_AGC *agc);
/**
* @brief 配置片内处理器,仅在使用需要处理器辅助的校准方法时需要开启处理器
* @param on 开启/关闭
*/
void CX9261A_configRISCV(bool on);
/**
* @brief 配置温补
* @param mode 温补模式 DAC/Band
*/
void CX9261A_configTemperatureCompensation(CX9261A_TemperatureComp mode);
/**
* @brief ADC校准
* @param adc ADC速率
*/
void CX9261A_configADCCalib(double adc);
/**
* @brief Flash校准
*/
void CX9261A_configFlashCalib();
/**
* @brief QEC校准会改变部分寄存器配置,在进行校准之前需要保存这部分寄存器,校准后恢复
* @return 包含寄存器地址和值的map
*/
void CX9261A_beforeQecState(QecStatePair* buff, size_t *len);
/**
* @brief 恢复QEC校准过程中改变的寄存器
* @param state beforeQecState函数返回的map
*/
void CX9261A_restoreQecState(QecStatePair* buff, size_t len);
/**
* @brief 根据pll来源配置校准模式下的电源管理
* @param pllSource PllSource结构体
*/
void CX9261A_preparePowerForRxCalib(const CX9261A_PllSource *pllSource);
/**
* @brief 调整校准时Pll的配置
* @param config CX9261A配置结构体
* @param chan 要进行校准的通道
*/
void CX9261A_preparePllForRxCalib(const CX9261A_CX9261AConfiguration *config, CX9261A_RxChannel chan);
/**
* @brief 等待RxTST窄带校准结束,可重写
* @return 校准是否结束
*/
bool CX9261A_waitRxTSTFinished();
/**
* @brief RX时域统计校准
* @param chan 校准的RX通道
*/
void CX9261A_rxTSTCalib(CX9261A_RxChannel chan);
/**
* @brief RX延时线校准
* @param fs ADC采样率
* @param chan 校准的RX通道
*/
void CX9261A_rxDelayCalib(double fs, CX9261A_RxChannel chan);
/**
* @brief DC Tracking
* @param config CX9261A配置结构体
*/
void CX9261A_configDcCalib(const CX9261A_Calib *config);
void CX9261A_configDcCalibMethod(CX9261A_DCCalibMethod method);
void CX9261A_configDcTrackingLength(int length);
void CX9261A_configDcHighPassFactor(int factor);
/**
* @brief Rx校准
* @param config CX9261A配置结构体
* @param chan 要进行校准的通道
*/
void CX9261A_rxCalib(const CX9261A_CX9261AConfiguration *config, CX9261A_RxChannel chan);
/**
* @brief 选择校准方法
* @param calib 校准结构体
*/
void CX9261A_configCalibMethod(const CX9261A_Calib *calib);
/**
* @brief 读取当前Rx chan通道的校准值
* @param chan Rx通道
* @return 校准值结构体
*/
CX9261A_CalibPredis CX9261A_readRxCalibPredis(CX9261A_RxChannel chan);
/**
* @brief 储存校准值
* @param index 第index组校准值
* @param chan 接收通道
* @param pll 使用的PLL
*/
void CX9261A_saveRxCalibPredis(uint8_t index, CX9261A_RxChannel chan, CX9261A_LoSource pll);
/**
* @brief 加载保存的校准值
* @param index 第index组校准值
* @param chan 指定加载校准值的通道
* @param pll 使用的PLL
*/
void CX9261A_loadRxCalibPredis(uint8_t index, CX9261A_RxChannel chan, CX9261A_LoSource pll);
/**
* @brief Rx窄带多点校准
* @param config CX9261A配置结构体
* @param points 校准点
* @param chan 接收通道
*/
void CX9261A_configRxMultiPointsQec(const CX9261A_CX9261AConfiguration *config, CX9261A_RxChannel chan, const double *points, size_t len);
/**
* @brief 根据pll来源配置校准模式下的电源管理
* @param pllSource PllSource结构体
*/
void CX9261A_preparePowerForTxCalib(const CX9261A_PllSource *pllSource);
/**
* @brief 调整校准时Pll的配置
* @param config CX9261A配置结构体
*/
void CX9261A_preparePllForTxCalib(const CX9261A_CX9261AConfiguration *config);
/**
* @brief TX二分法QEC校准
* @param f0 校准音频率
* @param fs adc频率
*/
void CX9261A_txBisectionQecCalib(double f0, double fs);
/**
* @brief TX时域统计法校准
* @param config CX9261A配置结构体
* @param chan 要校准的通道
*/
void CX9261A_txTSTCalib(const CX9261A_CX9261AConfiguration *config, CX9261A_TxChannel chan);
/**
* @brief TX二分法DC校准
* @param f0 校准音频率
* @param fs adc频率
*/
void CX9261A_txBisectionDcCalib(double f0, double fs);
/**
* @brief Tx多点校准
* @param config CX9261A配置结构体
* @param points 校准点
*/
void CX9261A_configTxMultiPointsQec(const CX9261A_CX9261AConfiguration *config, const double *points, size_t len);
/**
* @brief Tx通道校准
* @param config CX9261A配置结构体
*/
void CX9261A_txCalib(const CX9261A_CX9261AConfiguration *config);
/**
* @brief 储存校准值
* @param index 第index组校准值
* @param chan 发射通道
* @param pll pll
*/
void CX9261A_saveTxCalibPredis(uint8_t index, CX9261A_TxChannel chan, CX9261A_LoSource pll);
/**
* @brief 加载保存的校准值
* @param index 第index组校准值
* @param chan 指定加载校准值的通道
* @param pll 指定加载校准值对应的PLL
*/
void CX9261A_loadTxCalibPredis(uint8_t index, CX9261A_TxChannel chan, CX9261A_LoSource pll);
/**
* @brief Qec校准顶层函数,内部根据配置选择使用对应方法进行校准
* @param config CX9261A配置结构体
*/
void CX9261A_configQecCalib(const CX9261A_CX9261AConfiguration *config);
/**
* @brief 配置TX NCO相关寄存器
* @param nco TX NCO配置结构体
* @param fs adc速率
*/
void CX9261A_configTxNco(const CX9261A_TxNCO *nco, double fs);
/**
* @brief 配置TX NCO BIST模式
* @param bist 开启/关闭BIST
*/
void CX9261A_configTxBIST(bool bist);
/**
* @brief 配置TX NCO频率
* @param freq 混频频率
* @param fs adc抽取后速率
*/
void CX9261A_configTxNcoFreq(double freq, double fs);
/**
* @brief 配置RX NCO相关寄存器
* @param nco RX NCO配置结构体
* @param fs adc速率
*/
void CX9261A_configRxNco(const CX9261A_RxNCO *nco, double fs);
/**
* @brief 配置Rx NCO模式
* @param mode NCO模式:Bypass/BIST/Up/Down
*/
void CX9261A_configRxNcoMode(CX9261A_NCOMode mode);
/**
* @brief 配置Rx NCO模式
* @param mode NCO模式:Master/Slaver
*/
void CX9261A_configRxNcoMS(CX9261A_NCOMode mode);
/**
* @brief 配置Rx NCO频率
* @param freq 混频频率
* @param fs adc速率
*/
void CX9261A_configRxNcoFreq(double freq, double fs);
/**
* @brief 配置接口相关寄存器
* @param interface Interface配置结构体
*/
void CX9261A_configInterface(const CX9261A_Interface *interface);
/**
* @brief 配置PLL来源
* @param pllSource PLlSource结构体
*/
void CX9261A_configPllSource(const CX9261A_PllSource *pllSource);
/**
* @brief 切换电源模式
* @param pm 电源模式
*/
void CX9261A_configPowerMode(CX9261A_PowerMode pm);
/**
* @brief 配置电源管理
* @param power 电源配置结构体
* @param pm 电源模式
*/
void CX9261A_configPowerPins(const CX9261A_Power *power, CX9261A_PowerMode pm);
/**
* @brief 配置参考倍频器
* @param doubler 倍频器开关
* @param ref 参考时钟频率,单位MHz
*/
void CX9261A_configRefDoubler(bool doubler, double ref);
/**
* @brief 初始化通道,调用initialChip函数会初始化RX1,RX2,RX3三个通道
* @param chan 通道 RX1/RX2/RX3
*/
void CX9261A_initialRxChannel(CX9261A_RxChannel chan);
/**
* @brief 配置Rx带宽
* @note 只改变Rx带宽会导致通道增益改变,建议使用configRxChannel函数进行带宽调整
* @param bandwidth 带宽,单位(MHz)
* @param chan 通道 Rx1/Rx2/Rx3
*/
void CX9261A_configRxBandwidth(double bandwidth, CX9261A_RxChannel chan);
/**
* @brief 配置Rx TIA
* @note 只改变TIA会导致通道带宽改变,建议使用configRxChannel函数进行TIA调整
* @param tia tia档位
* @param chan 通道 Rx1/Rx2/Rx3
*/
void CX9261A_configRxTIA(int tia, CX9261A_RxChannel chan);
/**
* @brief 配置Rx Mixer
* @param mixer mixer档位
*/
void CX9261A_configRxMixer(int mixer);
/**
* @brief 配置Rx通道,包含TIA,Mixer以及Bandwidth
* @param config RxConfig结构体
* @param chan Rx1/Rx2/Rx3
*/
void CX9261A_configRxChannel(const CX9261A_RxConfig *config, CX9261A_RxChannel chan);
/**
* @brief 配置Rx FIR滤波器抽取倍数
* @param fir 抽取倍数 0(Bypass)/1/2/3/4/8
*/
void CX9261A_configRxFIR(int fir);
/**
* @brief 配置Rx HBF1滤波器抽取倍数
* @param hbf 抽取倍数 0(Bypass)/2
*/
void CX9261A_configRxHBF1(int hbf);
/**
* @brief 配置Rx HBF2滤波器抽取倍数
* @param hbf 抽取倍数 0(Bypass)/2
*/
void CX9261A_configRxHBF2(int hbf);
/**
* @brief 配置Rx HBF3滤波器抽取倍数
* @param hbf 抽取倍数 0(Bypass)/2/3
*/
void CX9261A_configRxHBF3(int hbf);
/**
* @brief 配置Rx CIC滤波器
* @param cic 抽取倍数 0(Bypass)/20
*/
void CX9261A_configRxCIC(int cic);
/**
* @brief 配置Rx滤波器
* @param filters Filters结构体
*/
void CX9261A_configRxFilters(const CX9261A_Filters *filters);
/**
* @brief 配置Rx FIR滤波器系数
* @param coe 滤波器系数,长度为16的整倍数,最大128
*/
void CX9261A_configRxFIRCoe(const double *coe, size_t len);
/**
* @brief 配置Tx带宽
* @param bandwidth 带宽,单位(MHz)
* @param chan 通道 TX1/TX2
*/
void CX9261A_configTxBandwidth(double bandwidth, CX9261A_TxChannel chan);
/**
* @brief 配置Tx Mixer
* @param mixer 混频器值
* @param chan TX1/TX2
*/
void CX9261A_configTxMixer(int mixer, CX9261A_TxChannel chan);
/**
* @brief 初始化Tx通道
* @param chan 通道 TX1/TX2
*/
void CX9261A_initialTxChannel(CX9261A_TxChannel chan);
/**
* @brief 根据Tx通道的本振频率,配置对应的参数
* @param lo 本振频率,单位(MHz)
* @param chan 通道(Tx1/Tx2)
*/
void CX9261A_configTxChannelFrequency(double lo, CX9261A_TxChannel chan);
/**
* @brief 配置Tx通道,Mixer以及Bandwidth
* @param config TxConfig结构体
* @param chan Tx1/Tx2
*/
void CX9261A_configTxChannel(const CX9261A_TxConfig *config, CX9261A_TxChannel chan);
/**
* @brief 配置Tx FIR滤波器插值倍数
* @param fir 插值倍数 0(Bypass)/1/2/3/4/8
*/
void CX9261A_configTxFIR(int fir);
/**
* @brief 配置Tx HBF1滤波器插值倍数
* @param hbf 插值倍数 0(Bypass)/2
*/
void CX9261A_configTxHBF1(int hbf);
/**
* @brief 配置Tx HBF2滤波器插值倍数
* @param hbf 插值倍数 0(Bypass)/2
*/
void CX9261A_configTxHBF2(int hbf);
/**
* @brief 配置Tx HBF3滤波器插值倍数
* @param hbf 插值倍数 0(Bypass)/2/3
*/
void CX9261A_configTxHBF3(int hbf);
/**
* @brief 配置Tx CIC滤波器
* @param cic 插值倍数 0(Bypass)/8/20/32/80
*/
void CX9261A_configTxCIC(int cic);
/**
* @brief 配置Tx滤波器
* @param filters Filters结构体
*/
void CX9261A_configTxFilters(const CX9261A_Filters *filters);
/**
* @brief 配置Tx FIR滤波器系数
* @param coe 滤波器系数,长度为16的整倍数,最大128
*/
void CX9261A_configTxFIRCoe(const double *coe, size_t len);
/**
* @brief 读取当前Tx chan通道的校准值
* @param chan Tx通道
* @return 校准值结构体
*/
CX9261A_CalibPredis CX9261A_readTxCalibPredis(CX9261A_TxChannel chan);
/**
* @brief 此函数为Demo板配套配置函数,用于配置FPGA接口,用户开发自己的程序时应重写对应功能
* @param interface Interface结构体
*/
void CX9261A_configFPGA(const CX9261A_Interface *interface);
#ifdef __cplusplus
}
#endif
#endif // __CX9261ADRIVER_C_H