DS160PR810 HAL Based Library 1.0.0
This library is a software library that works with the DS160PR810 PCIe 4.0 16-Gbps 8-channel linear redriver. This library provides a convenient and efficient way to access the I2C interfaces of the chip, allowing developers to easily integrate this redriver into their systems.
Loading...
Searching...
No Matches
ds160pr810.h File Reference
#include "main.h"
#include "i2c.h"

Go to the source code of this file.

Data Structures

struct  ds160pr810
 Class (struct) that stores variables for interacting with DS160PR180. More...
 
union  ds160pr810::_reg
 
struct  ds160pr810::_reg::_general_control_register
 
struct  ds160pr810::_reg::_eeprom_status_register
 
struct  ds160pr810::_reg::_device_id0_register
 
struct  ds160pr810::_reg::_device_id1_register
 
struct  ds160pr810::_reg::_rx_det_sts
 
struct  ds160pr810::_reg::_eq_ctrl
 
struct  ds160pr810::_reg::_gain_ctrl
 
struct  ds160pr810::_reg::_rx_det_ctrl1
 
struct  ds160pr810::_reg::_rx_det_ctrl2
 

Macros

#define OFFSET_CHANNEL_0   0x00
 
#define OFFSET_CHANNEL_1   0x20
 
#define OFFSET_CHANNEL_2   0x40
 
#define OFFSET_CHANNEL_3   0x60
 
#define RX_DET_STS   0x00
 
#define EQ_CTRL   0x01
 
#define GAIN_CTRL   0x02
 
#define RX_DET_CTRL1   0x03
 
#define RX_DET_CTRL2   0x09
 
#define BROADCAST_WRITE_ALL   0x80
 
#define BROADCAST_WRITE_0_1   0xA0
 
#define BROADCAST_WRITE_2_3   0xC0
 
#define GENERAL_CONTROL_REGISTER   0xE2
 
#define EEPROM_STATUS_REGISTER   0xE3
 
#define DEVICE_ID0_REGISTER   0xF0
 
#define DEVICE_ID1_REGISTER   0xF1
 

Typedefs

typedef enum Status Status
 Status enum.
 
typedef enum BankNumber BankNumber
 Bank indexes.
 
typedef enum RxDetectStatus RxDetectStatus
 Rx Detect Status.
 
typedef enum EQStage1Bypass EQStage1Bypass
 Bypass state of CTLE first stage.
 
typedef enum EQDCGain EQDCGain
 DC gain.
 
typedef enum TxVOD TxVOD
 TX VOD.
 
typedef enum ApplyTo ApplyTo
 
typedef struct ds160pr810 DS160PR810
 Class (struct) that stores variables for interacting with DS160PR180.
 

Enumerations

enum  Status { STATUS_OK , STATUS_TimeOut , STATUS_ArgumentError }
 Status enum. More...
 
enum  BankNumber { BANK0 , BANK1 }
 Bank indexes. More...
 
enum  RxDetectStatus { RX_DET_NONE , RX_DET_N , RX_DET_P , RX_DET_BOTH }
 Rx Detect Status. More...
 
enum  EQStage1Bypass { EQ_STAGE1_BYPASS_DISABLE , EQ_STAGE1_BYPASS_ENABLE }
 Bypass state of CTLE first stage. More...
 
enum  EQDCGain { EQ_DC_GAIN_0db , EQ_DC_GAIN_3db5 }
 DC gain. More...
 
enum  TxVOD { TX_VOD_m6db , TX_VOD_m3db5 , TX_VOD_m1db6 , TX_VOD_0db }
 TX VOD. More...
 
enum  ApplyTo {
  BANK0_CHANNEL0 = OFFSET_CHANNEL_0 , BANK0_CHANNEL1 = OFFSET_CHANNEL_1 , BANK0_CHANNEL2 = OFFSET_CHANNEL_2 , BANK0_CHANNEL3 = OFFSET_CHANNEL_3 ,
  BANK0_CHANNEL0_1 = BROADCAST_WRITE_0_1 , BANK0_CHANNEL2_3 = BROADCAST_WRITE_2_3 , BANK1_CHANNEL0 = OFFSET_CHANNEL_0 | 0x01 , BANK1_CHANNEL1 = OFFSET_CHANNEL_1 | 0x01 ,
  BANK1_CHANNEL2 = OFFSET_CHANNEL_2 | 0x01 , BANK1_CHANNEL3 = OFFSET_CHANNEL_3 | 0x01 , BANK1_CHANNEL0_1 = BROADCAST_WRITE_0_1 | 0x01 , BANK1_CHANNEL2_3 = BROADCAST_WRITE_2_3 | 0x01 ,
  CHANNEL0 = OFFSET_CHANNEL_0 , CHANNEL1 = OFFSET_CHANNEL_1 , CHANNEL2 = OFFSET_CHANNEL_2 , CHANNEL3 = OFFSET_CHANNEL_3 ,
  CHANNEL4 = OFFSET_CHANNEL_0 | 0x01 , CHANNEL5 = OFFSET_CHANNEL_1 | 0x01 , CHANNEL6 = OFFSET_CHANNEL_2 | 0x01 , CHANNEL7 = OFFSET_CHANNEL_3 | 0x01 ,
  CHANNEL0_1 = BROADCAST_WRITE_0_1 , CHANNEL2_3 = BROADCAST_WRITE_2_3 , CHANNEL4_5 = BROADCAST_WRITE_0_1 | 0x01 , CHANNEL6_7 = BROADCAST_WRITE_2_3 | 0x01 ,
  BANK0_ALL_CHANNELS = BROADCAST_WRITE_ALL , BANK1_ALL_CHANNELS = BROADCAST_WRITE_ALL | 0x01 , ALL_BANKS = 0xFF
}
 

Functions

Status DS160PR810_init (DS160PR810 *self, I2C_HandleTypeDef *hi2c, uint8_t BANK0_I2C_ADDR)
 Initialize the DS160PR810 with the given config.
 
Status DS160PR810_resetRegisters (DS160PR810 *self)
 Resets the DS160PR810 registers.
 
Status __DS160PR810_writeByte (DS160PR810 *self, BankNumber bank_number, uint8_t MemAddress)
 Write a byte of data to DS160PR810 from the ds160pr810::_reg::raw_data.
 
Status __DS160PR810_readByte (DS160PR810 *self, BankNumber bank_number, uint8_t MemAddress)
 Read a byte of data from DS160PR810 and stores in the ds160pr810::_reg::raw_data.
 
Status __DS160PR810_setChannelConfig (DS160PR810 *self, ApplyTo target, uint8_t ChannelRegister)
 Configures the channel registers for the DS160PR810 This function writes configuration values to a specific channel register or broadcasts the configuration to all channels depending on the target parameter.
 
Status __DS160PR810_getChannelConfig (DS160PR810 *self, ApplyTo target, uint8_t ChannelRegister)
 Reads the configuration of a channel register of the DS160PR810 This function reads configuration values of a specific channel register.
 
Status DS160PR810_setCTLE (DS160PR810 *self, ApplyTo target, EQStage1Bypass isByPassed, uint8_t Stage1, uint8_t Stage2)
 Set the CTLE setting of the DS160PR810.
 
Status DS160PR810_setResetRxDetectStateMachine (DS160PR810 *self, ApplyTo target)
 Resets the RX detect state machine.
 
Status DS160PR810_setClearRxDetectStateMachine (DS160PR810 *self, ApplyTo target)
 Clear the reset flag of the RX detect state machine.
 
Status DS160PR810_setDCGain (DS160PR810 *self, ApplyTo target, TxVOD tx_vod, EQDCGain dc_gain)
 Set the DC gain settings of the DS160PR810.
 
EQStage1Bypass DS160PR810_getCTLE_EQStage1Bypass (DS160PR810 *self, ApplyTo target)
 Reads the DS160PR810 CTLE first stage status. This function reads status of the first stage of CTLE.
 
uint8_t DS160PR810_getCTLE_Stage1 (DS160PR810 *self, ApplyTo target)
 Reads the DS160PR810 CTLE first stage gain index. This function reads gain index of the first stage of CTLE.
 
uint8_t DS160PR810_getCTLE_Stage2 (DS160PR810 *self, ApplyTo target)
 Reads the DS160PR810 CTLE second stage gain index. This function reads gain index of the second stage of CTLE.
 
TxVOD DS160PR810_getDCGain_TxVOD (DS160PR810 *self, ApplyTo target)
 Reads the TX VOD of the DS160PR810.
 
EQDCGain DS160PR810_getDCGain_EQDCGain (DS160PR810 *self, ApplyTo target)
 Reads the DC gain of the DS160PR810.
 
RxDetectStatus DS160PR810_getRxDetectStatus (DS160PR810 *self, ApplyTo target)
 Reads the RX detect status of the DS160PR810.
 
uint8_t DS160PR810_getDevID0 (DS160PR810 *self, BankNumber bank_number)
 Reads device ID0 of the specific bank of th DS160PR810.
 
uint8_t DS160PR810_getDevID1 (DS160PR810 *self, BankNumber bank_number)
 Reads device ID1 of the specific bank of th DS160PR810.
 
uint8_t DS160PR810_getEELoadComplete (DS160PR810 *self, BankNumber bank_number)
 
uint8_t DS160PR810_getEELoadFail (DS160PR810 *self, BankNumber bank_number)
 
uint8_t DS160PR810_getEEAtemptCount (DS160PR810 *self, BankNumber bank_number)
 

Macro Definition Documentation

◆ BROADCAST_WRITE_0_1

#define BROADCAST_WRITE_0_1   0xA0

◆ BROADCAST_WRITE_2_3

#define BROADCAST_WRITE_2_3   0xC0

◆ BROADCAST_WRITE_ALL

#define BROADCAST_WRITE_ALL   0x80

◆ DEVICE_ID0_REGISTER

#define DEVICE_ID0_REGISTER   0xF0

◆ DEVICE_ID1_REGISTER

#define DEVICE_ID1_REGISTER   0xF1

◆ EEPROM_STATUS_REGISTER

#define EEPROM_STATUS_REGISTER   0xE3

◆ EQ_CTRL

#define EQ_CTRL   0x01

◆ GAIN_CTRL

#define GAIN_CTRL   0x02

◆ GENERAL_CONTROL_REGISTER

#define GENERAL_CONTROL_REGISTER   0xE2

◆ OFFSET_CHANNEL_0

#define OFFSET_CHANNEL_0   0x00

◆ OFFSET_CHANNEL_1

#define OFFSET_CHANNEL_1   0x20

◆ OFFSET_CHANNEL_2

#define OFFSET_CHANNEL_2   0x40

◆ OFFSET_CHANNEL_3

#define OFFSET_CHANNEL_3   0x60

◆ RX_DET_CTRL1

#define RX_DET_CTRL1   0x03

◆ RX_DET_CTRL2

#define RX_DET_CTRL2   0x09

◆ RX_DET_STS

#define RX_DET_STS   0x00

Typedef Documentation

◆ ApplyTo

typedef enum ApplyTo ApplyTo

◆ BankNumber

typedef enum BankNumber BankNumber

Bank indexes.

◆ DS160PR810

typedef struct ds160pr810 DS160PR810

Class (struct) that stores variables for interacting with DS160PR180.

◆ EQDCGain

typedef enum EQDCGain EQDCGain

DC gain.

◆ EQStage1Bypass

Bypass state of CTLE first stage.

◆ RxDetectStatus

Rx Detect Status.

◆ Status

typedef enum Status Status

Status enum.

◆ TxVOD

typedef enum TxVOD TxVOD

TX VOD.

Enumeration Type Documentation

◆ ApplyTo

enum ApplyTo
Enumerator
BANK0_CHANNEL0 

Channel 0 of Bank 0 (Channel 0)

BANK0_CHANNEL1 

Channel 1 of Bank 0 (Channel 1)

BANK0_CHANNEL2 

Channel 2 of Bank 0 (Channel 2)

BANK0_CHANNEL3 

Channel 3 of Bank 0 (Channel 3)

BANK0_CHANNEL0_1 

Channel 0 and 1 of Bank 0 (Channel 0 and 1)

BANK0_CHANNEL2_3 

Channel 2 and 3 of Bank 0 (Channel 2 and 3)

BANK1_CHANNEL0 

Channel 0 of Bank 1 (Channel 4)

BANK1_CHANNEL1 

Channel 1 of Bank 1 (Channel 5)

BANK1_CHANNEL2 

Channel 2 of Bank 1 (Channel 6)

BANK1_CHANNEL3 

Channel 3 of Bank 1 (Channel 7)

BANK1_CHANNEL0_1 

Channel 0 and 1 of Bank 1 (Channel 4 and 5)

BANK1_CHANNEL2_3 

Channel 2 and 3 of Bank 1 (Channel 6 and 7)

CHANNEL0 

Channel 0 of Bank 0 (Channel 0)

CHANNEL1 

Channel 1 of Bank 0 (Channel 1)

CHANNEL2 

Channel 2 of Bank 0 (Channel 2)

CHANNEL3 

Channel 3 of Bank 0 (Channel 3)

CHANNEL4 

Channel 0 of Bank 1 (Channel 4)

CHANNEL5 

Channel 1 of Bank 1 (Channel 5)

CHANNEL6 

Channel 2 of Bank 1 (Channel 6)

CHANNEL7 

Channel 3 of Bank 1 (Channel 7)

CHANNEL0_1 

Channel 0 and 1 of Bank 0 (Channel 0 and 1)

CHANNEL2_3 

Channel 2 and 3 of Bank 0 (Channel 2 and 3)

CHANNEL4_5 

Channel 0 and 1 of Bank 1 (Channel 4 and 5)

CHANNEL6_7 

Channel 2 and 3 of Bank 1 (Channel 6 and 7)

BANK0_ALL_CHANNELS 

Channel 0 to 3 of Bank 1 (Channel 0 to 3)

BANK1_ALL_CHANNELS 

Channel 0 to 3 of Bank 1 (Channel 4 to 7)

ALL_BANKS 

Channel 0 to 3 of all banks (Channel 0 to 7)

◆ BankNumber

enum BankNumber

Bank indexes.

Enumerator
BANK0 

Bank 0.

BANK1 

Bank 1.

◆ EQDCGain

enum EQDCGain

DC gain.

Enumerator
EQ_DC_GAIN_0db 

0 db

EQ_DC_GAIN_3db5 

3.5 db

◆ EQStage1Bypass

Bypass state of CTLE first stage.

Enumerator
EQ_STAGE1_BYPASS_DISABLE 

Bypass is disable (Stage 1 is active)

EQ_STAGE1_BYPASS_ENABLE 

Bypass is enale (Stage 1 is bypassed)

◆ RxDetectStatus

Rx Detect Status.

Enumerator
RX_DET_NONE 

Nothing detected.

RX_DET_N 

Detected on N.

RX_DET_P 

Detected on P.

RX_DET_BOTH 

Detected on both.

◆ Status

enum Status

Status enum.

Enumerator
STATUS_OK 

Means everything is OK.

STATUS_TimeOut 

The commiunication timed out.

STATUS_ArgumentError 

Arguments are wrong.

◆ TxVOD

enum TxVOD

TX VOD.

Enumerator
TX_VOD_m6db 

-6 db

TX_VOD_m3db5 

-3.5 db

TX_VOD_m1db6 

-1.6 db

TX_VOD_0db 

0 db

Function Documentation

◆ __DS160PR810_getChannelConfig()

Status __DS160PR810_getChannelConfig ( DS160PR810 * self,
ApplyTo target,
uint8_t ChannelRegister )

Reads the configuration of a channel register of the DS160PR810 This function reads configuration values of a specific channel register.

Parameters
selfA pointer to the ds160pr810 object (struct)
targetSpecifies the target.
ChannelRegisterThe base address of the channel register to read.
Returns
The status of initialization
Return values
STATUS_OKin case of success
STATUS_TimeOutin case of failure

◆ __DS160PR810_readByte()

Status __DS160PR810_readByte ( DS160PR810 * self,
BankNumber bank_number,
uint8_t MemAddress )

Read a byte of data from DS160PR810 and stores in the ds160pr810::_reg::raw_data.

Parameters
selfA pointer to the ds160pr810 object (struct)
bank_numberIndex of the bank you want to read the data
MemAddressAddress of the target register
Returns
The status of initialization
Return values
STATUS_OKin case of success
STATUS_TimeOutin case of failure

◆ __DS160PR810_setChannelConfig()

Status __DS160PR810_setChannelConfig ( DS160PR810 * self,
ApplyTo target,
uint8_t ChannelRegister )

Configures the channel registers for the DS160PR810 This function writes configuration values to a specific channel register or broadcasts the configuration to all channels depending on the target parameter.

Parameters
selfA pointer to the ds160pr810 object (struct)
targetSpecifies the target.
ChannelRegisterThe base address of the channel register to configure.
Returns
The status of initialization
Return values
STATUS_OKin case of success
STATUS_TimeOutin case of failure

◆ __DS160PR810_writeByte()

Status __DS160PR810_writeByte ( DS160PR810 * self,
BankNumber bank_number,
uint8_t MemAddress )

Write a byte of data to DS160PR810 from the ds160pr810::_reg::raw_data.

Parameters
selfA pointer to the ds160pr810 object (struct)
bank_numberIndex of the bank you want to write the data
MemAddressAddress of the target register
Returns
The status of initialization
Return values
STATUS_OKin case of success
STATUS_TimeOutin case of failure

◆ DS160PR810_getCTLE_EQStage1Bypass()

EQStage1Bypass DS160PR810_getCTLE_EQStage1Bypass ( DS160PR810 * self,
ApplyTo target )

Reads the DS160PR810 CTLE first stage status. This function reads status of the first stage of CTLE.

Parameters
selfA pointer to the ds160pr810 object (struct)
targetSpecifies the target.
Returns
The status of first stage
Return values
EQ_STAGE1_BYPASS_DISABLEStage1 is active
EQ_STAGE1_BYPASS_ENABLEStage1 is bypassed

◆ DS160PR810_getCTLE_Stage1()

uint8_t DS160PR810_getCTLE_Stage1 ( DS160PR810 * self,
ApplyTo target )

Reads the DS160PR810 CTLE first stage gain index. This function reads gain index of the first stage of CTLE.

Parameters
selfA pointer to the ds160pr810 object (struct)
targetSpecifies the target.
Returns
The gain index of first stage
Return values
From0 to 7

◆ DS160PR810_getCTLE_Stage2()

uint8_t DS160PR810_getCTLE_Stage2 ( DS160PR810 * self,
ApplyTo target )

Reads the DS160PR810 CTLE second stage gain index. This function reads gain index of the second stage of CTLE.

Parameters
selfA pointer to the ds160pr810 object (struct)
targetSpecifies the target.
Returns
The gain index of second stage
Return values
From0 to 7

◆ DS160PR810_getDCGain_EQDCGain()

EQDCGain DS160PR810_getDCGain_EQDCGain ( DS160PR810 * self,
ApplyTo target )

Reads the DC gain of the DS160PR810.

Parameters
selfA pointer to the ds160pr810 object (struct)
targetSpecifies the target.
Returns
The DC gain
Return values
EQ_DC_GAIN_0db0.0db
EQ_DC_GAIN_3db53.5db

◆ DS160PR810_getDCGain_TxVOD()

TxVOD DS160PR810_getDCGain_TxVOD ( DS160PR810 * self,
ApplyTo target )

Reads the TX VOD of the DS160PR810.

Parameters
selfA pointer to the ds160pr810 object (struct)
targetSpecifies the target.
Returns
The TX VOD
Return values
TX_VOD_0db0.0db
TX_VOD_m1db6-1.6db
TX_VOD_m3db5-3.5db
TX_VOD_m6db-6.0db

◆ DS160PR810_getDevID0()

uint8_t DS160PR810_getDevID0 ( DS160PR810 * self,
BankNumber bank_number )

Reads device ID0 of the specific bank of th DS160PR810.

Parameters
selfA pointer to the ds160pr810 object (struct)
bank_numberThe bank index
Returns
The device ID0

◆ DS160PR810_getDevID1()

uint8_t DS160PR810_getDevID1 ( DS160PR810 * self,
BankNumber bank_number )

Reads device ID1 of the specific bank of th DS160PR810.

Parameters
selfA pointer to the ds160pr810 object (struct)
bank_numberThe bank index
Returns
The device ID1

◆ DS160PR810_getEEAtemptCount()

uint8_t DS160PR810_getEEAtemptCount ( DS160PR810 * self,
BankNumber bank_number )

◆ DS160PR810_getEELoadComplete()

uint8_t DS160PR810_getEELoadComplete ( DS160PR810 * self,
BankNumber bank_number )

◆ DS160PR810_getEELoadFail()

uint8_t DS160PR810_getEELoadFail ( DS160PR810 * self,
BankNumber bank_number )

◆ DS160PR810_getRxDetectStatus()

RxDetectStatus DS160PR810_getRxDetectStatus ( DS160PR810 * self,
ApplyTo target )

Reads the RX detect status of the DS160PR810.

Parameters
selfA pointer to the ds160pr810 object (struct)
targetSpecifies the target.
Returns
The RX detect status
Return values
RX_DET_NONE
RX_DET_N
RX_DET_P
RX_DET_BOTH

◆ DS160PR810_init()

Status DS160PR810_init ( DS160PR810 * self,
I2C_HandleTypeDef * hi2c,
uint8_t BANK0_I2C_ADDR )

Initialize the DS160PR810 with the given config.

Parameters
selfA pointer to the ds160pr810 object (struct)
hi2cA pointer to the I2C handler that is connected to DS160PR810
BANK0_I2C_ADDRThe I2C address of the bank0 of the DS160PR810. It depends on the state of ADDR0 and ADDR1 pins of the chip.
Returns
The status of initialization
Return values
STATUS_OKin case of success
STATUS_TimeOutin case of failure

◆ DS160PR810_resetRegisters()

Status DS160PR810_resetRegisters ( DS160PR810 * self)

Resets the DS160PR810 registers.

Parameters
selfA pointer to the ds160pr810 object (struct)
Returns
The status of initialization
Return values
STATUS_OKin case of success
STATUS_TimeOutin case of failure

◆ DS160PR810_setClearRxDetectStateMachine()

Status DS160PR810_setClearRxDetectStateMachine ( DS160PR810 * self,
ApplyTo target )

Clear the reset flag of the RX detect state machine.

Parameters
selfA pointer to the ds160pr810 object (struct)
targetSpecifies the target.
Returns
The status of config
Return values
STATUS_OKin case of success
STATUS_TimeOutin case of failure

◆ DS160PR810_setCTLE()

Status DS160PR810_setCTLE ( DS160PR810 * self,
ApplyTo target,
EQStage1Bypass isByPassed,
uint8_t Stage1,
uint8_t Stage2 )

Set the CTLE setting of the DS160PR810.

Parameters
selfA pointer to the ds160pr810 object (struct)
targetSpecifies the target.
isByPassedDetermines the status of first stage of CTLE
Stage1Determines the gain index of first stage of CTLE. This s value between 0 to 7.
Stage2Determines the gain index of second stage of CTLE. This s value between 0 to 7.
Returns
The status of config
Return values
STATUS_OKin case of success
STATUS_TimeOutin case of failure

◆ DS160PR810_setDCGain()

Status DS160PR810_setDCGain ( DS160PR810 * self,
ApplyTo target,
TxVOD tx_vod,
EQDCGain dc_gain )

Set the DC gain settings of the DS160PR810.

Parameters
selfA pointer to the ds160pr810 object (struct)
targetSpecifies the target.
tx_vodSpecifies the VOD
dc_gainSpecifies the DC gain
Returns
The status of config
Return values
STATUS_OKin case of success
STATUS_TimeOutin case of failure

◆ DS160PR810_setResetRxDetectStateMachine()

Status DS160PR810_setResetRxDetectStateMachine ( DS160PR810 * self,
ApplyTo target )

Resets the RX detect state machine.

Parameters
selfA pointer to the ds160pr810 object (struct)
targetSpecifies the target.
Returns
The status of config
Return values
STATUS_OKin case of success
STATUS_TimeOutin case of failure