James Reynolds / AD594x Driver
Embed: (wiki syntax)

« Back to documentation index

ad5940.c File Reference

ad5940.c File Reference

AD5940 library. More...

Go to the source code of this file.

Functions

static uint32_t AD5940_SPIReadReg (uint16_t RegAddr)
 Read register through SPI.
static void AD5940_SPIWriteReg (uint16_t RegAddr, uint32_t RegData)
 Write register through SPI.
static void AD5940_D2DWriteReg (uint16_t RegAddr, uint32_t RegData)
 Function_Helpers.
void AD5940_SEQGenInsert (uint32_t CmdWord)
 Manually input a command to sequencer generator.
static AD5940Err AD5940_SEQGenSearchReg (uint32_t RegAddr, uint32_t *pIndex)
 Search data-base to get current register value.
static AD5940Err AD5940_SEQGenGetRegDefault (uint32_t RegAddr, uint32_t *pRegData)
 Get the register default value by SPI read.
static void AD5940_SEQRegInfoInsert (uint16_t RegAddr, uint32_t RegData)
 Record the current register info to data-base.
static uint32_t AD5940_SEQReadReg (uint16_t RegAddr)
 Get current register value.
static void AD5940_SEQWriteReg (uint16_t RegAddr, uint32_t RegData)
 Generate a sequencer command to write register.
void AD5940_SEQGenInit (uint32_t *pBuffer, uint32_t BufferSize)
 Initialize sequencer generator with specified buffer.
AD5940Err AD5940_SEQGenFetchSeq (const uint32_t **ppSeqCmd, uint32_t *pSeqLen)
 Get sequencer command generated.
void AD5940_SEQGenCtrl (BoolFlag bFlag)
 Start or stop the sequencer generator.
uint32_t AD5940_SEQCycleTime (void)
 Calculate the number of cycles in the sequence.
static int32_t _is_value_in_table (uint8_t value, const uint8_t *table, uint8_t len, uint8_t *index)
 Sequencer_Generator_Functions.
BoolFlag AD5940_Notch50HzAvailable (ADCFilterCfg_Type *pFilterInfo, uint8_t *dl)
 return if the SINC3/SINC2 combination is available for notch 50Hz filter.
BoolFlag AD5940_Notch60HzAvailable (ADCFilterCfg_Type *pFilterInfo, uint8_t *dl)
 return if the SINC3/SINC2 combination is available for notch 60Hz filter.
void AD5940_ClksCalculate (ClksCalInfo_Type *pFilterInfo, uint32_t *pClocks)
 Calculate how many clocks are needed in sequencer wait command to generate required number of data from filter output.
void AD5940_SweepNext (SoftSweepCfg_Type *pSweepCfg, float *pNextFreq)
 void AD5940_SweepNext(SoftSweepCfg_Type *pSweepCfg, float *pNextFreq) For sweep function, calculate next frequency point according to pSweepCfg info.
void AD5940_StructInit (void *pStruct, uint32_t StructSize)
 Initialize Structure members to zero.
float AD5940_ADCCode2Volt (uint32_t code, uint32_t ADCPga, float VRef1p82)
 Convert ADC Code to voltage.
fImpCar_Type AD5940_ComplexDivFloat (fImpCar_Type *a, fImpCar_Type *b)
 Do complex number division.
fImpCar_Type AD5940_ComplexMulFloat (fImpCar_Type *a, fImpCar_Type *b)
 Do complex number multiplication.
fImpCar_Type AD5940_ComplexAddFloat (fImpCar_Type *a, fImpCar_Type *b)
 Do complex number addition.
fImpCar_Type AD5940_ComplexSubFloat (fImpCar_Type *a, fImpCar_Type *b)
 Do complex number subtraction.
fImpCar_Type AD5940_ComplexDivInt (iImpCar_Type *a, iImpCar_Type *b)
 Do complex number division.
fImpCar_Type AD5940_ComplexMulInt (iImpCar_Type *a, iImpCar_Type *b)
 Do complex number multiplication.
float AD5940_ComplexMag (fImpCar_Type *a)
 Calculate the complex number magnitude.
float AD5940_ComplexPhase (fImpCar_Type *a)
 Calculate the complex number phase.
FreqParams_Type AD5940_GetFreqParameters (float freq)
 Calculate the optimum filter settings based on signal frequency.
void AD5940_FIFORd (uint32_t *pBuffer, uint32_t uiReadCount)
 Read specific number of data from FIFO with optimized SPI access.
static unsigned char AD5940_ReadWrite8B (unsigned char data)
 Using SPI to transmit one byte and return the received byte.
static uint16_t AD5940_ReadWrite16B (uint16_t data)
 Using SPI to transmit two bytes and return the received bytes.
static uint32_t AD5940_ReadWrite32B (uint32_t data)
 Using SPI to transmit four bytes and return the received bytes.
void AD5940_WriteReg (uint16_t RegAddr, uint32_t RegData)
 SPI_Block.
uint32_t AD5940_ReadReg (uint16_t RegAddr)
 Read register.
void AD5940_Initialize (void)
 Initialize AD5940.
void AD5940_AFECtrlS (uint32_t AfeCtrlSet, BoolFlag State)
 Control most AFE digital and analog block within one register access.
AD5940Err AD5940_LPModeCtrlS (uint32_t EnSet)
 When LP mode is enabled, some functions are under control of LPMODECON, rather than original registers.
void AD5940_AFEPwrBW (uint32_t AfePwr, uint32_t AfeBw)
 Set AFE power mode and system bandwidth include HSDAC, Excitation-buffer, HSTIA and ADC etc.
void AD5940_REFCfgS (AFERefCfg_Type *pBufCfg)
 Configure reference buffer include 1.8V/1.1V high/low power buffers.
void AD5940_HSLoopCfgS (HSLoopCfg_Type *pHsLoopCfg)
 Configure High speed loop(high bandwidth loop or called excitation loop).
void AD5940_SWMatrixCfgS (SWMatrixCfg_Type *pSwMatrix)
 Initialize switch matrix.
void AD5940_HSDacCfgS (HSDACCfg_Type *pHsDacCfg)
 Initialize HSDAC.
AD5940Err AD5940_HSTIACfgS (HSTIACfg_Type *pHsTiaCfg)
 Initialize High speed TIA amplifier.
void AD5940_HSRTIACfgS (uint32_t HSTIARtia)
 Configure HSTIA RTIA resistor and keep other parameters unchanged.
void AD5940_WGCfgS (WGCfg_Type *pWGInit)
 Initialize waveform generator.
AD5940Err AD5940_WGDACCodeS (uint32_t code)
 Write HSDAC code directly when WG configured to MMR type.
void AD5940_WGFreqCtrlS (float SinFreqHz, float WGClock)
 Update WG SIN wave frequency in Hz.
uint32_t AD5940_WGFreqWordCal (float SinFreqHz, float WGClock)
 Calculate sine wave generator frequency word.
void AD5940_LPLoopCfgS (LPLoopCfg_Type *pLpLoopCfg)
 Configure low power loop include LPDAC LPAmp(PA and TIA)
void AD5940_LPDACCfgS (LPDACCfg_Type *pLpDacCfg)
 Initialize LPDAC.
void AD5940_LPDACWriteS (uint16_t Data12Bit, uint8_t Data6Bit)
 Write LPDAC data.
void AD5940_LPDAC0WriteS (uint16_t Data12Bit, uint8_t Data6Bit)
 Write LPDAC0 data.
void AD5940_LPDAC1WriteS (uint16_t Data12Bit, uint8_t Data6Bit)
 Write LPDAC1 data.
void AD5940_LPAMPCfgS (LPAmpCfg_Type *pLpAmpCfg)
 Initialize LP TIA and PA.
void AD5940_DSPCfgS (DSPCfg_Type *pDSPCfg)
 Configure low power loop include LPDAC LPAmp(PA and TIA)
uint32_t AD5940_ReadAfeResult (uint32_t AfeResultSel)
 Read AD5940 generated data like ADC and DFT etc.
void AD5940_ADCBaseCfgS (ADCBaseCfg_Type *pADCInit)
 Initializes ADC peripheral according to the specified parameters in the pADCInit.
void AD5940_ADCFilterCfgS (ADCFilterCfg_Type *pFiltCfg)
 Initializes ADC filter according to the specified parameters in the pFiltCfg.
void AD5940_ADCPowerCtrlS (BoolFlag State)
 Power up or power down ADC block(including ADC PGA and FRONTBUF).
void AD5940_ADCConvtCtrlS (BoolFlag State)
 Start or stop ADC convert.
void AD5940_ADCMuxCfgS (uint32_t ADCMuxP, uint32_t ADCMuxN)
 Configure ADC input MUX.
void AD5940_ADCDigCompCfgS (ADCDigComp_Type *pCompCfg)
 Set ADC digital comparator function.
void AD5940_StatisticCfgS (StatCfg_Type *pStatCfg)
 Configure statistic functions.
void AD5940_ADCRepeatCfgS (uint32_t Number)
 Set ADC Repeat convert function number.
void AD5940_DFTCfgS (DFTCfg_Type *pDftCfg)
 Configure DFT number and source and hanning window.
void AD5940_FIFOCfg (FIFOCfg_Type *pFifoCfg)
 Configure AD5940 FIFO.
AD5940Err AD5940_FIFOGetCfg (FIFOCfg_Type *pFifoCfg)
 Read current FIFO configuration.
void AD5940_FIFOCtrlS (uint32_t FifoSrc, BoolFlag FifoEn)
 Configure AD5940 FIFO Source and enable or disable FIFO.
void AD5940_FIFOThrshSet (uint32_t FIFOThresh)
 Configure AD5940 Data FIFO threshold value.
uint32_t AD5940_FIFOGetCnt (void)
 Get Data count in FIFO.
void AD5940_SEQCfg (SEQCfg_Type *pSeqCfg)
 Initialize Sequencer.
AD5940Err AD5940_SEQGetCfg (SEQCfg_Type *pSeqCfg)
 Read back current sequencer configuration and store it to pSeqCfg.
void AD5940_SEQCtrlS (BoolFlag SeqEn)
 Enable or Disable sequencer.
void AD5940_SEQHaltS (void)
 Halt sequencer immediately.
void AD5940_SEQMmrTrig (uint32_t SeqId)
 Trigger sequencer by register write.
void AD5940_SEQCmdWrite (uint32_t StartAddr, const uint32_t *pCommand, uint32_t CmdCnt)
 Write sequencer commands to AD5940 SRAM.
void AD5940_SEQInfoCfg (SEQInfo_Type *pSeq)
 Initialize Sequence INFO.
AD5940Err AD5940_SEQInfoGet (uint32_t SeqId, SEQInfo_Type *pSeqInfo)
 Get sequence info: start address and sequence length.
void AD5940_SEQGpioCtrlS (uint32_t Gpio)
 Control GPIO with register SYNCEXTDEVICE.
uint32_t AD5940_SEQTimeOutRd (void)
 Read back current count down timer value for Sequencer Timer Out command.
AD5940Err AD5940_SEQGpioTrigCfg (SeqGpioTrig_Cfg *pSeqGpioTrigCfg)
 Configure GPIO to allow it to trigger corresponding sequence(SEQ0/1/2/3).
void AD5940_WUPTCfg (WUPTCfg_Type *pWuptCfg)
 Configure Wakeup Timer.
void AD5940_WUPTCtrl (BoolFlag Enable)
 Enable or disable wakeup timer.
AD5940Err AD5940_WUPTTime (uint32_t SeqId, uint32_t SleepTime, uint32_t WakeupTime)
 Configure WakeupTimer.
void AD5940_CLKCfg (CLKCfg_Type *pClkCfg)
 Configure AD5940 clock.
void AD5940_HFOSC32MHzCtrl (BoolFlag Mode32MHz)
 Configure Internal HFOSC to output 32MHz or 16MHz.
void AD5940_HPModeEn (BoolFlag Enable)
 Enable high power mode for high frequency EIS.
void AD5940_INTCCfg (uint32_t AfeIntcSel, uint32_t AFEIntSrc, BoolFlag State)
 Enable or Disable selected interrupt source(s)
uint32_t AD5940_INTCGetCfg (uint32_t AfeIntcSel)
 Check if current interrupt configuration.
void AD5940_INTCClrFlag (uint32_t AfeIntSrcSel)
 Clear selected interrupt(s) flag(INTC0Flag and INTC1Flag are both cleared).
BoolFlag AD5940_INTCTestFlag (uint32_t AfeIntcSel, uint32_t AfeIntSrcSel)
 Test if selected interrupt source(s) is(are) bTRUE.
uint32_t AD5940_INTCGetFlag (uint32_t AfeIntcSel)
 return register value of REG_INTC_INTCFLAGx
void AD5940_AGPIOCfg (AGPIOCfg_Type *pAgpioCfg)
 Initialize AFE GPIO.
void AD5940_AGPIOFuncCfg (uint32_t uiCfgSet)
 Configure the function of GP0 to GP7.
void AD5940_AGPIOOen (uint32_t uiPinSet)
 Enable GPIO output mode on selected pins.
void AD5940_AGPIOIen (uint32_t uiPinSet)
 Enable input on selected pins while disable others.
uint32_t AD5940_AGPIOIn (void)
 Read the GPIO status.
void AD5940_AGPIOPen (uint32_t uiPinSet)
 Enable pull-up or down on selected pins while disable other pins.
void AD5940_AGPIOSet (uint32_t uiPinSet)
 Put selected GPIOs to high level.
void AD5940_AGPIOClr (uint32_t uiPinSet)
 Put selected GPIOs to low level.
void AD5940_AGPIOToggle (uint32_t uiPinSet)
 Toggle selected GPIOs.
AD5940Err AD5940_LPModeEnS (BoolFlag LPModeEn)
 Enter or leave LPMODE.
void AD5940_LPModeClkS (uint32_t LPModeClk)
 Select system clock source for LPMODE.
void AD5940_SleepKeyCtrlS (uint32_t SlpKey)
 LPMode_Block_Functions.
void AD5940_EnterSleepS (void)
 Put AFE to hibernate.
void AD5940_ShutDownS (void)
 Turn off LP-Loop and put AFE to hibernate mode;.
uint32_t AD5940_WakeUp (int32_t TryCount)
 Try to wakeup AD5940 by read register.
uint32_t AD5940_GetADIID (void)
 Read ADIID register, the value for current version is AD5940_ADIID.
uint32_t AD5940_GetChipID (void)
 Read CHIPID register, the value for current version is 0x5501.
AD5940Err AD5940_SoftRst (void)
 Reset AD5940 by register.
void AD5940_HWReset (void)
 Reset AD5940 with RESET pin.
static void __AD5940_ReferenceON (void)
 Turn on High power 1.8V/1.1V reference and 2.5V LP reference.
static uint32_t __AD5940_TakeMeasurement (int32_t *time_out)
 Turn on ADC to sample one SINC2 data.
AD5940Err AD5940_ADCPGACal (ADCPGACal_Type *pADCPGACal)
 Calibrate ADC PGA.
AD5940Err AD5940_LPTIAOffsetCal (LPTIAOffsetCal_Type *pLPTIAOffsetCal)
 Calibrate LPTIA offset.
AD5940Err AD5940_HSTIAOffsetCal (LPTIAOffsetCal_Type *pHSTIAOffsetCal)
 Calibrate HSTIA offset-ongoing.
AD5940Err AD5940_HSRtiaCal (HSRTIACal_Type *pCalCfg, void *pResult)
 Measure HSTIA internal RTIA impedance.
AD5940Err AD5940_LPRtiaCal (LPRTIACal_Type *pCalCfg, void *pResult)
 Measure LPTIA internal RTIA impedance with HSTIA.
AD5940Err AD5940_HSDACCal (HSDACCal_Type *pCalCfg)
 calibrate HSDAC output voltage using ADC.
AD5940Err AD5940_LPDACCal (LPDACCal_Type *pCalCfg, LPDACPara_Type *pResult)
 Use ADC to measure LPDAC offset and gain factor.
AD5940Err AD5940_LFOSCMeasure (LFOSCMeasure_Type *pCfg, float *pFreq)
 Use system clock to measure LFOSC frequency.

Detailed Description

AD5940 library.

This file contains all AD5940 library functions.

Author:
ADI
Date:
March 2019
Revision History:

Copyright (c) 2017-2019 Analog Devices, Inc. All Rights Reserved.

This software is proprietary to Analog Devices, Inc. and its licensors. By using this software you agree to the terms of the associated Analog Devices Software License Agreement.

Definition in file ad5940.c.


Variable Documentation

uint32_t BufferSize

Total buffer size.

Definition at line 98 of file ad5940.c.

Flag to mark start of the generator.

Definition at line 97 of file ad5940.c.

The last error message.

Definition at line 104 of file ad5940.c.

SEQGenRegInfo_Type* pRegInfo

Pointer to buffer where stores register info.

Definition at line 102 of file ad5940.c.

uint32_t* pSeqBuff

The buffer for sequence generator(both sequences and RegInfo)

Definition at line 100 of file ad5940.c.

uint32_t RegCount

The count of register info available in buffer *pRegInfo.

Definition at line 103 of file ad5940.c.

uint32_t SeqLen

Generated sequence length till now.

Definition at line 101 of file ad5940.c.