James Reynolds / AD594x Driver
Embed: (wiki syntax)

« Back to documentation index

Exported_Functions

Exported_Functions
[AD5940_Library]

TypeDefinitions. More...

Functions

void AD5940_WriteReg (uint16_t RegAddr, uint32_t RegData)
 SPI_Block.
uint32_t AD5940_ReadReg (uint16_t RegAddr)
 Read register.
void AD5940_FIFORd (uint32_t *pBuffer, uint32_t uiReadCount)
 Read specific number of data from FIFO with optimized SPI access.
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_LPLoopCfgS (LPLoopCfg_Type *pLpLoopCfg)
 Configure low power loop include LPDAC LPAmp(PA and TIA)
void AD5940_LPDACCfgS (LPDACCfg_Type *pLpDacCfg)
 Initialize LPDAC.
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_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_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 GpioSet)
 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.
AD5940Err AD5940_ADCPGACal (ADCPGACal_Type *ADCPGACal)
 Calibrate ADC PGA.
AD5940Err AD5940_LPDACCal (LPDACCal_Type *pCalCfg, LPDACPara_Type *pResult)
 Use ADC to measure LPDAC offset and gain factor.
AD5940Err AD5940_LPTIAOffsetCal (LPTIAOffsetCal_Type *pLPTIAOffsetCal)
 Calibrate LPTIA offset.
AD5940Err AD5940_HSRtiaCal (HSRTIACal_Type *pCalCfg, void *pResult)
 Measure HSTIA internal RTIA impedance.
AD5940Err AD5940_HSDACCal (HSDACCal_Type *pCalCfg)
 calibrate HSDAC output voltage using ADC.
AD5940Err AD5940_LPRtiaCal (LPRTIACal_Type *pCalCfg, void *pResult)
 Measure LPTIA internal RTIA impedance with HSTIA.
AD5940Err AD5940_LFOSCMeasure (LFOSCMeasure_Type *pCfg, float *pFreq)
 Use system clock to measure LFOSC frequency.
void AD5940_SEQGenInit (uint32_t *pBuffer, uint32_t BufferSize)
 Initialize sequencer generator with specified buffer.
void AD5940_SEQGenCtrl (BoolFlag bFlag)
 Start or stop the sequencer generator.
void AD5940_SEQGenInsert (uint32_t CmdWord)
 Manually input a command to sequencer generator.
AD5940Err AD5940_SEQGenFetchSeq (const uint32_t **ppSeqCmd, uint32_t *pSeqCount)
 Get sequencer command generated.
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.
uint32_t AD5940_SEQCycleTime (void)
 Calculate the number of cycles in the sequence.
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.
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.
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.

Detailed Description

TypeDefinitions.


Function Documentation

void AD5940_ADCBaseCfgS ( ADCBaseCfg_Type pADCInit )

Initializes ADC peripheral according to the specified parameters in the pADCInit.

Parameters:
pADCInit,:Pointer to ADC initialize structure.
Returns:
return none.

Definition at line 1781 of file ad5940.c.

float AD5940_ADCCode2Volt ( uint32_t  code,
uint32_t  ADCPga,
float  VRef1p82 
)

Convert ADC Code to voltage.

Parameters:
ADCPga,:The ADC PGA used for this result.
code,:ADC code.
VRef1p82,:the actual 1.82V reference voltage.
Returns:
Voltage in volt.

Definition at line 628 of file ad5940.c.

void AD5940_ADCConvtCtrlS ( BoolFlag  State )

Start or stop ADC convert.

Parameters:
State: {bTRUE, bFALSE}

  • bTRUE: Start ADC convert
  • bFALSE: Stop ADC convert
Returns:
return none.

Definition at line 1867 of file ad5940.c.

void AD5940_ADCDigCompCfgS ( ADCDigComp_Type pCompCfg )

Set ADC digital comparator function.

Parameters:
pCompCfg,:Pointer to configuration structure
Returns:
return none.

Definition at line 1913 of file ad5940.c.

void AD5940_ADCFilterCfgS ( ADCFilterCfg_Type pFiltCfg )

Initializes ADC filter according to the specified parameters in the pFiltCfg.

Parameters:
pFiltCfg,:Pointer to filter initialize structure.
Returns:
return none.

Average filter is enabled when DFT source is DFTSRC_AVG in function AD5940_DFTCfgS. Once average function is enabled, it's automatically set as DFT source, register DFTCON.DFTINSEL is ignored.

Definition at line 1803 of file ad5940.c.

void AD5940_ADCMuxCfgS ( uint32_t  ADCMuxP,
uint32_t  ADCMuxN 
)

Configure ADC input MUX.

Parameters:
ADCMuxP: {ADCMUXP_FLOAT, ADCMUXP_HSTIA_P, ,,, ,ADCMUXP_P_NODE}

  • ADCMUXP_FLOAT: float ADC MUX positive input
  • ADCMUXP_HSTIA_P: High speed TIA output sense terminal
  • ADCMUXP_P_NODE: Excitation loop P node
ADCMuxN: {ADCMUXP_FLOAT, ADCMUXP_HSTIA_P, ,,, ,ADCMUXP_P_NODE}

  • ADCMUXP_FLOAT: float ADC MUX positive input
  • ADCMUXP_HSTIA_P: High speed TIA output sense terminal
  • ADCMUXP_P_NODE: Excitation loop P node
Returns:
return none.

Definition at line 1895 of file ad5940.c.

AD5940Err AD5940_ADCPGACal ( ADCPGACal_Type pADCPGACal )

Calibrate ADC PGA.

Parameters:
pADCPGACal,:PGA calibration parameters include filter setup and PGA gain.
Returns:
AD5940ERR_OK.

Determine Gain calibration method according to different gain value... and calibration register

AD5940 use formular Output = gain*(input + offset) for calibration. So, the measured results should be divided by gain to get value for offset register.

Definition at line 3087 of file ad5940.c.

void AD5940_ADCPowerCtrlS ( BoolFlag  State )

Power up or power down ADC block(including ADC PGA and FRONTBUF).

Parameters:
State: {bTRUE, bFALSE}

  • bTRUE: Power up ADC
  • bFALSE: Power down ADC
Returns:
return none.

Definition at line 1845 of file ad5940.c.

void AD5940_ADCRepeatCfgS ( uint32_t  Number )

Set ADC Repeat convert function number.

Turn off ADC automatically after Number samples of ADC raw data are ready

Parameters:
Number,:Specify after how much ADC raw data need to sample before shutdown ADC
Returns:
return none.

Definition at line 1945 of file ad5940.c.

void AD5940_AFECtrlS ( uint32_t  AfeCtrlSet,
BoolFlag  State 
)

Control most AFE digital and analog block within one register access.

Parameters:
AfeCtrlSet,:A set of blocks that will be controlled select it from AFECTRL_Const Below is two examples to use it.

  • AFECTRL_HPREFPWR: Control high power reference(bandgap).
  • AFECTRL_WG|AFECTRL_ADCPWR: The OR'ed control set. Control Waveform generator and ADC power.
State,:Enable or disable selected control set signal. Select from

  • bFALSE: Disable or power down selected block(s).
  • bTRUE: Enable all selected block(s).
Returns:
return none.

Definition at line 1170 of file ad5940.c.

void AD5940_AFEPwrBW ( uint32_t  AfePwr,
uint32_t  AfeBw 
)

Set AFE power mode and system bandwidth include HSDAC, Excitation-buffer, HSTIA and ADC etc.

Parameters:
AfePwr: {AFEPWR_LP, AFEPWR_HP} Select parameters from AFEPWR_Const

  • AFEPWR_LP: Set AFE to low power mode
  • AFEPWR_HP: Set AFE to High speed mode to support 200kHz.
AfeBw: {AFEBW_AUTOSET, AFEBW_50KHZ, AFEBW_100KHZ, AFEBW_250KHZ}

  • AFEBW_AUTOSET: Set the bandwidth automatically based on WGFCW frequency word.
  • AFEBW_50KHZ: Set system bandwidth to 50kHz.
  • AFEBW_100KHZ: Set system bandwidth to 100kHz.
  • AFEBW_250KHZ: Set system bandwidth to 250kHz.
Returns:
return none.

Definition at line 1279 of file ad5940.c.

void AD5940_AGPIOCfg ( AGPIOCfg_Type pAgpioCfg )

Initialize AFE GPIO.

Parameters:
pAgpioCfg,:Pointer to configuration structure
Returns:
return none.

Definition at line 2768 of file ad5940.c.

void AD5940_AGPIOClr ( uint32_t  uiPinSet )

Put selected GPIOs to low level.

Parameters:
uiPinSet,:Select from: {AGPIO_Pin0|AGPIO_Pin1|AGPIO_Pin2|AGPIO_Pin3|AGPIO_Pin4|AGPIO_Pin5|AGPIO_Pin6|AGPIO_Pin7}
Returns:
return none

Definition at line 2848 of file ad5940.c.

void AD5940_AGPIOFuncCfg ( uint32_t  uiCfgSet )

Configure the function of GP0 to GP7.

Parameters:
uiCfgSet:{GP0_INT,GP0_TRIG,GP0_SYNC,GP0_GPIO| GP1_GPIO,GP1_TRIG,GP1_SYNC,GP1_SLEEP| GP2_PORB,GP2_TRIG,GP2_SYNC,GP2_EXTCLK| GP3_GPIO,GP3_TRIG,GP3_SYNC,GP3_INT0|\ GP4_GPIO,GP4_TRIG,GP4_SYNC,GP4_INT1| GP5_GPIO,GP5_TRIG,GP5_SYNC,GP5_EXTCLK| GP6_GPIO,GP6_TRIG,GP6_SYNC,GP6_INT0| GP7_GPIO,GP7_TRIG,GP7_SYNC,GP7_INT}
Returns:
return none.

Definition at line 2789 of file ad5940.c.

void AD5940_AGPIOIen ( uint32_t  uiPinSet )

Enable input on selected pins while disable others.

Parameters:
uiPinSet,:Select from {AGPIO_Pin0|AGPIO_Pin1|AGPIO_Pin2|AGPIO_Pin3|AGPIO_Pin4|AGPIO_Pin5|AGPIO_Pin6|AGPIO_Pin7}
Returns:
return none

Definition at line 2809 of file ad5940.c.

uint32_t AD5940_AGPIOIn ( void   )

Read the GPIO status.

Returns:
return GP0IN register which is the GPIO status.

Definition at line 2818 of file ad5940.c.

void AD5940_AGPIOOen ( uint32_t  uiPinSet )

Enable GPIO output mode on selected pins.

Disable output on non-selected pins.

Parameters:
uiPinSet:Select from {AGPIO_Pin0|AGPIO_Pin1|AGPIO_Pin2|AGPIO_Pin3|AGPIO_Pin4|AGPIO_Pin5|AGPIO_Pin6|AGPIO_Pin7}
Returns:
return none

Definition at line 2799 of file ad5940.c.

void AD5940_AGPIOPen ( uint32_t  uiPinSet )

Enable pull-up or down on selected pins while disable other pins.

Parameters:
uiPinSet,:Select from: {AGPIO_Pin0|AGPIO_Pin1|AGPIO_Pin2|AGPIO_Pin3|AGPIO_Pin4|AGPIO_Pin5|AGPIO_Pin6|AGPIO_Pin7}
Returns:
return none

Definition at line 2828 of file ad5940.c.

void AD5940_AGPIOSet ( uint32_t  uiPinSet )

Put selected GPIOs to high level.

Parameters:
uiPinSet,:Select from: {AGPIO_Pin0|AGPIO_Pin1|AGPIO_Pin2|AGPIO_Pin3|AGPIO_Pin4|AGPIO_Pin5|AGPIO_Pin6|AGPIO_Pin7}
Returns:
return none

Definition at line 2838 of file ad5940.c.

void AD5940_AGPIOToggle ( uint32_t  uiPinSet )

Toggle selected GPIOs.

Parameters:
uiPinSet,:Select from: {AGPIO_Pin0|AGPIO_Pin1|AGPIO_Pin2|AGPIO_Pin3|AGPIO_Pin4|AGPIO_Pin5|AGPIO_Pin6|AGPIO_Pin7}
Returns:
return none

Definition at line 2858 of file ad5940.c.

void AD5940_CLKCfg ( CLKCfg_Type pClkCfg )

Configure AD5940 clock.

Parameters:
pClkCfg,:Pointer to configuration structure.
Returns:
return none.

Definition at line 2499 of file ad5940.c.

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.

Note:
When measurement is done, it's recommend to disable blocks like ADCPWR, ADCCNV, SINC2, DFT etc. If blocks remain powered up, they may need less clocks to generate required number of output. Use function AD5940_AFECtrlS to control these blocks.
Parameters:
pFilterInfo,:Pointer to configuration structure.
pClocks,:pointer used to store results.
Returns:
return none.

Definition at line 480 of file ad5940.c.

fImpCar_Type AD5940_ComplexAddFloat ( fImpCar_Type a,
fImpCar_Type b 
)

Do complex number addition.

Parameters:
a,:The addend.
b,:The addend .
Returns:
Return result.

Definition at line 695 of file ad5940.c.

fImpCar_Type AD5940_ComplexDivFloat ( fImpCar_Type a,
fImpCar_Type b 
)

Do complex number division.

Parameters:
a,:The dividend.
b,:The divisor.
Returns:
Return result.

Definition at line 662 of file ad5940.c.

fImpCar_Type AD5940_ComplexDivInt ( iImpCar_Type a,
iImpCar_Type b 
)

Do complex number division.

Parameters:
a,:The dividend.
b,:The divisor.
Returns:
Return result.

Definition at line 727 of file ad5940.c.

float AD5940_ComplexMag ( fImpCar_Type a )

Calculate the complex number magnitude.

Parameters:
a,:The complex number.
Returns:
Return magnitude.

Definition at line 760 of file ad5940.c.

fImpCar_Type AD5940_ComplexMulFloat ( fImpCar_Type a,
fImpCar_Type b 
)

Do complex number multiplication.

Parameters:
a,:The multiplicand.
b,:The multiplier .
Returns:
Return result.

Definition at line 680 of file ad5940.c.

fImpCar_Type AD5940_ComplexMulInt ( iImpCar_Type a,
iImpCar_Type b 
)

Do complex number multiplication.

Parameters:
a,:The multiplicand.
b,:The multiplier .
Returns:
Return result.

Definition at line 745 of file ad5940.c.

float AD5940_ComplexPhase ( fImpCar_Type a )

Calculate the complex number phase.

Parameters:
a,:The complex number.
Returns:
Return phase.

Definition at line 770 of file ad5940.c.

fImpCar_Type AD5940_ComplexSubFloat ( fImpCar_Type a,
fImpCar_Type b 
)

Do complex number subtraction.

Parameters:
a,:The minuend.
b,:The subtrahend .
Returns:
Return result.

Definition at line 711 of file ad5940.c.

void AD5940_DFTCfgS ( DFTCfg_Type pDftCfg )

Configure DFT number and source and hanning window.

Parameters:
pDftCfg,:Pointer to configuration structure
Returns:
return none.

Definition at line 1956 of file ad5940.c.

void AD5940_DSPCfgS ( DSPCfg_Type pDSPCfg )

Configure low power loop include LPDAC LPAmp(PA and TIA)

Parameters:
pDSPCfg,:Pointer to configure structure;
Returns:
return none.

Definition at line 1722 of file ad5940.c.

void AD5940_EnterSleepS ( void   )

Put AFE to hibernate.

This will only take effect when SLP_KEY has been unlocked. Use function AD5940_SleepKeyCtrlS to enter correct key.

Returns:
return none.

Definition at line 2921 of file ad5940.c.

void AD5940_FIFOCfg ( FIFOCfg_Type pFifoCfg )

Configure AD5940 FIFO.

Parameters:
pFifoCfg,:Pointer to configuration structure.
Returns:
return none.

Definition at line 2003 of file ad5940.c.

void AD5940_FIFOCtrlS ( uint32_t  FifoSrc,
BoolFlag  FifoEn 
)

Configure AD5940 FIFO Source and enable or disable FIFO.

Parameters:
FifoSrc: available choices are FIFOSRC_Const

  • FIFOSRC_SINC3 SINC3 data
  • FIFOSRC_DFT DFT real and imaginary part
  • FIFOSRC_SINC2NOTCH SINC2+NOTCH block. Notch can be bypassed, so SINC2 data can be feed to FIFO
  • FIFOSRC_VAR Statistic variance output
  • FIFOSRC_MEAN Statistic mean output
FifoEn,:enable or disable the FIFO.
Returns:
return none.

Definition at line 2063 of file ad5940.c.

AD5940Err AD5940_FIFOGetCfg ( FIFOCfg_Type pFifoCfg )

Read current FIFO configuration.

Parameters:
pFifoCfg,:Pointer to a buffer that used to store FIFO configuration.
Returns:
return AD5940ERR_OK if succeed.

Definition at line 2031 of file ad5940.c.

uint32_t AD5940_FIFOGetCnt ( void   )

Get Data count in FIFO.

Returns:
return none.

Definition at line 2089 of file ad5940.c.

void AD5940_FIFORd ( uint32_t *  pBuffer,
uint32_t  uiReadCount 
)

Read specific number of data from FIFO with optimized SPI access.

Parameters:
pBuffer,:Pointer to a buffer that used to store data read back.
uiReadCount,:How much data to be read.
Returns:
none.

Definition at line 866 of file ad5940.c.

void AD5940_FIFOThrshSet ( uint32_t  FIFOThresh )

Configure AD5940 Data FIFO threshold value.

Parameters:
FIFOThresh,:FIFO threshold value
Returns:
return none.

Definition at line 2079 of file ad5940.c.

uint32_t AD5940_GetADIID ( void   )

Read ADIID register, the value for current version is AD5940_ADIID.

Returns:
return none.

Definition at line 2974 of file ad5940.c.

uint32_t AD5940_GetChipID ( void   )

Read CHIPID register, the value for current version is 0x5501.

Returns:
return none.

Definition at line 2983 of file ad5940.c.

FreqParams_Type AD5940_GetFreqParameters ( float  freq )

Calculate the optimum filter settings based on signal frequency.

Parameters:
freq,:Frequency of signalr.
Returns:
Return FreqParams.

Definition at line 780 of file ad5940.c.

void AD5940_HFOSC32MHzCtrl ( BoolFlag  Mode32MHz )

Configure Internal HFOSC to output 32MHz or 16MHz.

Parameters:
Mode32MHz: {bTRUE, bFALSE}

  • bTRUE: HFOSC 32MHz mode.
  • bFALSE: HFOSC 16MHz mode.
Returns:
return none.

Definition at line 2564 of file ad5940.c.

void AD5940_HPModeEn ( BoolFlag  Enable )

Enable high power mode for high frequency EIS.

Parameters:
Mode32MHz: {bTRUE, bFALSE}

  • bTRUE: HFOSC 32MHz mode.
  • bFALSE: HFOSC 16MHz mode.
Returns:
return none.

Definition at line 2599 of file ad5940.c.

AD5940Err AD5940_HSDACCal ( HSDACCal_Type pCalCfg )

calibrate HSDAC output voltage using ADC.

Note:
It acutally calibrates voltage output of excitation buffer.
Parameters:
pCalCfg,:pointer to configuration structure
Returns:
return AD5940ERR_OK if succeeded.

Definition at line 3938 of file ad5940.c.

void AD5940_HSDacCfgS ( HSDACCfg_Type pHsDacCfg )

Initialize HSDAC.

Parameters:
pHsDacCfg,:Pointer to configuration structure
Returns:
return none.

Definition at line 1379 of file ad5940.c.

void AD5940_HSLoopCfgS ( HSLoopCfg_Type pHsLoopCfg )

Configure High speed loop(high bandwidth loop or called excitation loop).

This configuration includes HSDAC, HSTIA and Switch matrix.

Parameters:
pHsLoopCfg: Pointer to configure structure;
Returns:
return none.

Definition at line 1352 of file ad5940.c.

AD5940Err AD5940_HSRtiaCal ( HSRTIACal_Type pCalCfg,
void *  pResult 
)

Measure HSTIA internal RTIA impedance.

Parameters:
pCalCfg,:pointer to calibration structure.
pResult,:Pointer to a variable that used to store result. If bPolarResult in structure is set, then use type fImpPol_Type otherwise use fImpCar_Type.
Returns:
AD5940ERR_OK if succeed.

Definition at line 3394 of file ad5940.c.

void AD5940_HSRTIACfgS ( uint32_t  HSTIARtia )

Configure HSTIA RTIA resistor and keep other parameters unchanged.

Parameters:
HSTIARtia,:The RTIA setting, select it from HSTIARTIA_Const
Returns:
return none.

Definition at line 1468 of file ad5940.c.

AD5940Err AD5940_HSTIACfgS ( HSTIACfg_Type pHsTiaCfg )

Initialize High speed TIA amplifier.

Parameters:
pHsTiaCfg,:Pointer to configuration structure
Returns:
return none.

Definition at line 1430 of file ad5940.c.

void AD5940_HWReset ( void   )

Reset AD5940 with RESET pin.

Note:
This will call function AD5940_RstClr which locates in file XXXPort.C
Returns:
return none.

Definition at line 3007 of file ad5940.c.

void AD5940_Initialize ( void   )

Initialize AD5940.

This function must be called whenever there is reset(Software Reset or Hardware reset or Power up) happened. This function is used to put AD5940 to correct state.

Returns:
return None

Definition at line 1094 of file ad5940.c.

void AD5940_INTCCfg ( uint32_t  AfeIntcSel,
uint32_t  AFEIntSrc,
BoolFlag  State 
)

Enable or Disable selected interrupt source(s)

Parameters:
AfeIntcSel: {AFEINTC_0, AFEINTC_1}

  • AFEINTC_0: Configure Interrupt Controller 0
  • AFEINTC_1: Configure Interrupt Controller 1
AFEIntSrc,:select from AFEINTC_SRC_Const

  • AFEINTSRC_ADCRDY : Bit0 ADC Result Ready Status
  • AFEINTSRC_DFTRDY : Bit1 DFT Result Ready Status
  • AFEINTSRC_SUPPLYFILTRDY : Bit2 Low Pass Filter Result Status
  • AFEINTSRC_TEMPRDY : Bit3, Temp Sensor Result Ready
  • AFEINTSRC_ADCMINERR : Bit4, ADC Minimum Value
  • AFEINTSRC_ADCMAXERR : Bit5, ADC Maximum Value
  • AFEINTSRC_ADCDIFFERR : Bit6, ADC Delta Ready
  • AFEINTSRC_MEANRDY : Bit7, Mean Result Ready
  • AFEINTSRC_VARRDY : Bit8, Variance Result Ready
  • AFEINTSRC_DLYCMDDONE : Bit9, User controlled interrupt by writing AFEGENINTSTA. Provides an Early Indication for the End of the Test _Block.
  • AFEINTSRC_HWSETUPDONE : Bit10, User controlled interrupt by writing AFEGENINTSTA. Indicates the MMR Setup for the Measurement Step Finished
  • AFEINTSRC_BRKSEQ : Bit11, User controlled interrupt by writing AFEGENINTSTA.
  • AFEINTSRC_CUSTOMINS : Bit12, User controlled interrupt by writing AFEGENINTSTA. General Purpose Custom Interrupt.
  • AFEINTSRC_BOOTLDDONE : Bit13, OTP Boot Loading Done
  • AFEINTSRC_WAKEUP : Bit14, AFE Woken up
  • AFEINTSRC_ENDSEQ : Bit15, End of Sequence Interrupt.
  • AFEINTSRC_SEQTIMEOUT : Bit16, Sequencer Timeout Command Finished.
  • AFEINTSRC_SEQTIMEOUTERR : Bit17, Sequencer Timeout Command Error.
  • AFEINTSRC_CMDFIFOFULL : Bit18, Command FIFO Full Interrupt.
  • AFEINTSRC_CMDFIFOEMPTY : Bit19, Command FIFO Empty
  • AFEINTSRC_CMDFIFOTHRESH: Bit20, Command FIFO Threshold Interrupt.
  • AFEINTSRC_CMDFIFOOF : Bit21, Command FIFO Overflow Interrupt.
  • AFEINTSRC_CMDFIFOUF : Bit22, Command FIFO Underflow Interrupt.
  • AFEINTSRC_DATAFIFOFULL : Bit23, Data FIFO Full Interrupt.
  • AFEINTSRC_DATAFIFOEMPTY: Bit24, Data FIFO Empty
  • AFEINTSRC_DATAFIFOTHRESH: Bit25, Data FIFO Threshold Interrupt.
  • AFEINTSRC_DATAFIFOOF : Bit26, Data FIFO Overflow Interrupt.
  • AFEINTSRC_DATAFIFOUF : Bit27, Data FIFO Underflow Interrupt.
  • AFEINTSRC_WDTIRQ : Bit28, WDT Timeout Interrupt.
  • AFEINTSRC_CRC_OUTLIER : Bit29, CRC interrupt for M355, Outliers Int for AD5940
  • AFEINTSRC_GPT0INT_SLPWUT: Bit30, General Purpose Timer0 IRQ for M355. Sleep or Wakeup Timer timeout for AD5940
  • AFEINTSRC_GPT1INT_TRYBRK: Bit31, General Purpose Timer1 IRQ for M355. Tried to Break IRQ for AD5940
  • AFE_INTC_ALLINT : All interrupts
State: {bTRUE, bFALSE}

  • bTRUE: Enable these interrupt source(s)
  • bFALSE: Disable interrupt source(s)
Returns:
return none.

Definition at line 2676 of file ad5940.c.

void AD5940_INTCClrFlag ( uint32_t  AfeIntSrcSel )

Clear selected interrupt(s) flag(INTC0Flag and INTC1Flag are both cleared).

Parameters:
AfeIntSrcSel,:Select from AFEINTC_SRC_Const
Returns:
return none.

Definition at line 2713 of file ad5940.c.

uint32_t AD5940_INTCGetCfg ( uint32_t  AfeIntcSel )

Check if current interrupt configuration.

Parameters:
AfeIntcSel: {AFEINTC_0, AFEINTC_1}

  • AFEINTC_0: Configure Interrupt Controller 0
  • AFEINTC_1: Configure Interrupt Controller 1

Definition at line 2698 of file ad5940.c.

uint32_t AD5940_INTCGetFlag ( uint32_t  AfeIntcSel )

return register value of REG_INTC_INTCFLAGx

Parameters:
AfeIntcSel: {AFEINTC_0, AFEINTC_1}

  • AFEINTC_0: Read Interrupt Controller 0 flag
  • AFEINTC_1: Read Interrupt Controller 1 flag
Returns:
register value of REG_INTC_INTCFLAGx.

Definition at line 2745 of file ad5940.c.

BoolFlag AD5940_INTCTestFlag ( uint32_t  AfeIntcSel,
uint32_t  AfeIntSrcSel 
)

Test if selected interrupt source(s) is(are) bTRUE.

Parameters:
AfeIntcSel: {AFEINTC_0, AFEINTC_1}

  • AFEINTC_0: Read Interrupt Controller 0 flag
  • AFEINTC_1: Read Interrupt Controller 1 flag
AfeIntSrcSel,:Select from AFEINTC_SRC_Const
Returns:
If selected interrupt source(s) are all cleared, return bFALSE. Otherwise return bTRUE.

Definition at line 2726 of file ad5940.c.

AD5940Err AD5940_LFOSCMeasure ( LFOSCMeasure_Type pCfg,
float *  pFreq 
)

Use system clock to measure LFOSC frequency.

Note:
Set system clock to external crystal to get a better measurement accuracy. This function use 3 sequences and the start address is specified by parameter.
Parameters:
pCfg,:pointer to structure.
pFreq,:Pointer to a variable that used to store frequency in Hz.
Returns:
AD5940ERR_OK if succeed.

  Sleep wakeup timer running...
  -SLP----WKP----SLP----WKP----SLP----WKP
  --|-----|-------------|-------------|------------Trigger sequencer when Wakeup Timer over.
  --------|SEQA---------|SEQB----------------------Execute SeqA then SeqB
  ---------|InitT--------|StopT--------------------SeqA start timer and SeqB trigger interrupt so MCU read back current count
  ------------------------|INT---------------------
  -----------------------------------------|Read---We read SEQTIMEOUT register here
  ---------|-----TimerCount----------------|-------
  ---------|--------------|---TimerCount2--|-------We change SeqB to reset timer so we measure how much time needed for MCU to read back SEQTIMEOUT register(TimerCount2)

Interrupt flag AFEINTSRC_ENDSEQ will be set after this command. So We can inform MCU to read back current timer value. MCU will need some additional time to read back time count. So we use SeqB to measure how much time needed for MCU to read back

Definition at line 4272 of file ad5940.c.

void AD5940_LPAMPCfgS ( LPAmpCfg_Type pLpAmpCfg )

Initialize LP TIA and PA.

Parameters:
pLpAmpCfg,:Pointer to configuration structure
Returns:
return none.

Definition at line 1673 of file ad5940.c.

void AD5940_LPDAC0WriteS ( uint16_t  Data12Bit,
uint8_t  Data6Bit 
)

Write LPDAC0 data.

Parameters:
Data12Bit,:12Bit DAC data
Data6Bit,:6Bit DAC data
Returns:
return none.

Definition at line 1646 of file ad5940.c.

void AD5940_LPDAC1WriteS ( uint16_t  Data12Bit,
uint8_t  Data6Bit 
)

Write LPDAC1 data.

Parameters:
Data12Bit,:12Bit DAC data
Data6Bit,:6Bit DAC data
Returns:
return none.

Definition at line 1660 of file ad5940.c.

AD5940Err AD5940_LPDACCal ( LPDACCal_Type pCalCfg,
LPDACPara_Type pResult 
)

Use ADC to measure LPDAC offset and gain factor.

Note:
Assume ADC is accurate enough or accurate than LPDAC at least.
Parameters:
pCalCfg,:pointer to structure.
pResult,:the pointer to save calibration result.
Returns:
AD5940ERR_OK if succeed.

Definition at line 4105 of file ad5940.c.

void AD5940_LPDACCfgS ( LPDACCfg_Type pLpDacCfg )

Initialize LPDAC.

Parameters:
pLpDacCfg,:Pointer to configuration structure
Returns:
return none.

Definition at line 1600 of file ad5940.c.

void AD5940_LPLoopCfgS ( LPLoopCfg_Type pLpLoopCfg )

Configure low power loop include LPDAC LPAmp(PA and TIA)

Parameters:
pLpLoopCfg,:Pointer to configure structure;
Returns:
return none.

Definition at line 1589 of file ad5940.c.

void AD5940_LPModeClkS ( uint32_t  LPModeClk )

Select system clock source for LPMODE.

Note:
Only in LP Mode, this operation takes effect. Enter LPMODE by function AD5940_LPModeEnS.
Parameters:
LPModeClk,:Select from LPMODECLK_Const

  • LPMODECLK_LFOSC: Select LFOSC 32kHz for system clock
  • LPMODECLK_HFOSC: Select HFOSC 16MHz/32MHz for system clock
Returns:
none.

Definition at line 2894 of file ad5940.c.

AD5940Err AD5940_LPModeCtrlS ( uint32_t  EnSet )

When LP mode is enabled, some functions are under control of LPMODECON, rather than original registers.

Warning:
LPMODE is key protected, this function only takes effect after AD5940_LPModeEnS(bTRUE) For LP mode, use one register to control most AFE digital and analog block.

The parameter means the blocks. The selected block will be enabled. All others will be disabled. The method to enable/disable blocks are defined by register LPMODECON, either by clearing or setting bits.

Parameters:
EnSet,:A set of blocks that will be enabled. Select it from LPMODECTRL_Const. All others not selected in EnSet will be disabled.

  • LPMODECTRL_ALDOPWR|LPMODECTRL_HFOSCEN: Turn on ALDO and HFOSC, disable all others.
  • LPMODECTRL_ALL: Enable all blocks.
Returns:
return none.

Definition at line 1216 of file ad5940.c.

AD5940Err AD5940_LPModeEnS ( BoolFlag  LPModeEn )

Enter or leave LPMODE.

Once enter this mode, some registers are collected together to a new register so we can Control most blocks with in one register. The so called LPMODE has nothing to do with AD5940 power.

Returns:
return AD5940ERR_OK

Definition at line 2877 of file ad5940.c.

AD5940Err AD5940_LPRtiaCal ( LPRTIACal_Type pCalCfg,
void *  pResult 
)

Measure LPTIA internal RTIA impedance with HSTIA.

This is the recommended method for LPTIA RTIA calibration.

Parameters:
pCalCfg,:pointer to calibration structure.
pResult,:Pointer to a variable that used to store result. If bPolarResult in structure is set, then use type fImpPol_Type otherwise use fImpCar_Type.
Returns:
AD5940ERR_OK if succeed.

Determine the best ADC PGA gain for both RCAL and RTIA voltage measurement.

Definition at line 3605 of file ad5940.c.

AD5940Err AD5940_LPTIAOffsetCal ( LPTIAOffsetCal_Type pLPTIAOffsetCal )

Calibrate LPTIA offset.

Parameters:
pLPTIAOffsetCalPointer to LPTIA offset calibration settings.
Returns:
AD5940ERR_OK.

Definition at line 3263 of file ad5940.c.

BoolFlag AD5940_Notch50HzAvailable ( ADCFilterCfg_Type pFilterInfo,
uint8_t *  dl 
)

return if the SINC3/SINC2 combination is available for notch 50Hz filter.

If it's not availabe, hardware automatically bypass Notch even if it's enabled.

Parameters:
pFilterInfothe filter configuration, only need sinc2/sinc3 osr and adc data rate information.
Returns:
return bTRUE if notch 50Hz filter is available.

Definition at line 370 of file ad5940.c.

BoolFlag AD5940_Notch60HzAvailable ( ADCFilterCfg_Type pFilterInfo,
uint8_t *  dl 
)

return if the SINC3/SINC2 combination is available for notch 60Hz filter.

If it's not availabe, hardware automatically bypass Notch even if it's enabled.

Parameters:
pFilterInfothe filter configuration, need sinc2/sinc3 osr and adc data rate information.
Returns:
return bTRUE if notch 60Hz filter is available.

Definition at line 424 of file ad5940.c.

uint32_t AD5940_ReadAfeResult ( uint32_t  AfeResultSel )

Read AD5940 generated data like ADC and DFT etc.

Parameters:
AfeResultSel,:available parameters are AFERESULT_Const

  • AFERESULT_SINC3: Read SINC3 filter data result
  • AFERESULT_SINC2: Read SINC2+NOTCH filter result, when Notch filter is bypassed, the result is SINC2
  • AFERESULT_STATSVAR: Statistic variance result
Returns:
return data read back.

Definition at line 1739 of file ad5940.c.

uint32_t AD5940_ReadReg ( uint16_t  RegAddr )

Read register.

If sequencer generator is enabled, read current register value from data-base. Otherwise, read register value by SPI.

Parameters:
RegAddr,:The register address.
Returns:
Return register value.

Definition at line 1062 of file ad5940.c.

void AD5940_REFCfgS ( AFERefCfg_Type *  pBufCfg )

Configure reference buffer include 1.8V/1.1V high/low power buffers.

Parameters:
pBufCfg:Pointer to buffer configure structure;
Returns:
return none.

Definition at line 1293 of file ad5940.c.

void AD5940_SEQCfg ( SEQCfg_Type pSeqCfg )

Initialize Sequencer.

Parameters:
pSeqCfg,:Pointer to configuration structure
Returns:
return none.

Definition at line 2101 of file ad5940.c.

void AD5940_SEQCmdWrite ( uint32_t  StartAddr,
const uint32_t *  pCommand,
uint32_t  CmdCnt 
)

Write sequencer commands to AD5940 SRAM.

Returns:
return none.

Definition at line 2196 of file ad5940.c.

void AD5940_SEQCtrlS ( BoolFlag  SeqEn )

Enable or Disable sequencer.

Note:
Only after valid trigger signal, sequencer can run.
Returns:
return none.

Definition at line 2161 of file ad5940.c.

uint32_t AD5940_SEQCycleTime ( void   )

Calculate the number of cycles in the sequence.

Returns:
Return Number of ACLK Cycles that a generated sequence will take.

Definition at line 315 of file ad5940.c.

void AD5940_SEQGenCtrl ( BoolFlag  bFlag )

Start or stop the sequencer generator.

Once started, the register write will be recorded to sequencer generator. Once it's disabled, the register write is written to AD5940 directly by SPI bus.

Parameters:
bFlag,:Enable or disable sequencer generator.
Returns:
Return None.

Definition at line 297 of file ad5940.c.

AD5940Err AD5940_SEQGenFetchSeq ( const uint32_t **  ppSeqCmd,
uint32_t *  pSeqLen 
)

Get sequencer command generated.

Parameters:
ppSeqCmd,:Pointer to a variable(pointer) used to store the pointer to generated sequencer command.
pSeqLen,:Pointer to a variable that used to store how many commands available in buffer.
Returns:
Return lasterror.

Definition at line 276 of file ad5940.c.

void AD5940_SEQGenInit ( uint32_t *  pBuffer,
uint32_t  BufferSize 
)

Initialize sequencer generator with specified buffer.

The buffer is used to store sequencer generated and record register value changes. The command is stored from start address of buffer while register value is stored from end of buffer. Buffer[0] : First sequencer command; Buffer[1] : Second Sequencer command; ... Buffer[Last-1]: The second register value record. Buffer[Last]: The first register value record.

Parameters:
pBuffer,:Pointer to the buffer.
BufferSize,:The buffer length.
Returns:
Return None.

Definition at line 257 of file ad5940.c.

void AD5940_SEQGenInsert ( uint32_t  CmdWord )

Manually input a command to sequencer generator.

Parameters:
CmdWord,:The 32-bit width sequencer command word. Sequencer_Helper can be used to generate commands.
Returns:
None;

Definition at line 112 of file ad5940.c.

AD5940Err AD5940_SEQGetCfg ( SEQCfg_Type pSeqCfg )

Read back current sequencer configuration and store it to pSeqCfg.

Parameters:
pSeqCfg,:Pointer to structure
Returns:
return AD5940ERR_OK if succeed.

Definition at line 2139 of file ad5940.c.

void AD5940_SEQGpioCtrlS ( uint32_t  Gpio )

Control GPIO with register SYNCEXTDEVICE.

Because sequencer have no ability to access register GPIOOUT, so we use this register for sequencer.

Parameters:
Gpio: Select from {AGPIO_Pin0|AGPIO_Pin1|AGPIO_Pin2|AGPIO_Pin3|AGPIO_Pin4|AGPIO_Pin5|AGPIO_Pin6|AGPIO_Pin7}

  • The combination of GPIO pins. The selected pins will be set to High. Others will be pulled low.
Returns:
return None.

Definition at line 2287 of file ad5940.c.

AD5940Err AD5940_SEQGpioTrigCfg ( SeqGpioTrig_Cfg *  pSeqGpioTrigCfg )

Configure GPIO to allow it to trigger corresponding sequence(SEQ0/1/2/3).

There are four sequences. We can use GPIO to trigger each sequence. For example, GP0 or GP4 can be used to trigger sequence0 and GP3 or GP7 to trigger sequence3. There are five mode available to detect pin action: Rising edge, falling edge, both rising and falling edge, low level or high level. Be careful to use level detection. The trigger signal is always available if the pin level is matched. Once the sequence is done, it will immediately run again if the pin level is still matched.

Returns:
return AD5940ERR_OK if succeed.

Definition at line 2311 of file ad5940.c.

void AD5940_SEQHaltS ( void   )

Halt sequencer immediately.

Use this to debug. In normal application, there is no situation that can use this function.

Returns:
return none.

Definition at line 2176 of file ad5940.c.

void AD5940_SEQInfoCfg ( SEQInfo_Type pSeq )

Initialize Sequence INFO.

There are four set of registers that record sequence information. The info contains command start address in SRAM and sequence length. Hardware can automatically manage these four sequences. If the application requires more than 4 sequences, user should manually record the sequence Info(address and length) in MCU.

Parameters:
pSeq,:Pointer to configuration structure. Specify sequence start address in SRAM and sequence length.
Returns:
return none.

Definition at line 2215 of file ad5940.c.

AD5940Err AD5940_SEQInfoGet ( uint32_t  SeqId,
SEQInfo_Type pSeqInfo 
)

Get sequence info: start address and sequence length.

Parameters:
SeqId,:Select from {SEQID_0, SEQID_1, SEQID_2, SEQID_3}

  • Select which sequence we want to get the information.
pSeqInfo,:Pointer to sequence info structure.
Returns:
return AD5940ERR_OK when succeed.

Definition at line 2248 of file ad5940.c.

void AD5940_SEQMmrTrig ( uint32_t  SeqId )

Trigger sequencer by register write.

Returns:
return none.

Definition at line 2185 of file ad5940.c.

uint32_t AD5940_SEQTimeOutRd ( void   )

Read back current count down timer value for Sequencer Timer Out command.

Returns:
return register value of Sequencer Timer out value.

Definition at line 2296 of file ad5940.c.

void AD5940_ShutDownS ( void   )

Turn off LP-Loop and put AFE to hibernate mode;.

By function AD5940_EnterSleepS, we can put most blocks to hibernate mode except LP block. This function will shut down LP block and then enter sleep mode.

Returns:
return none.

Definition at line 2933 of file ad5940.c.

void AD5940_SleepKeyCtrlS ( uint32_t  SlpKey )

LPMode_Block_Functions.

Enter sleep mode key to unlock it or enter incorrect key to lock it. \ Once key is unlocked, it will always be effect until manually lock it

Parameters:
SlpKey: {SLPKEY_UNLOCK, SLPKEY_LOCK}

  • SLPKEY_UNLOCK Unlock Key so we can enter sleep(or called hibernate) mode.
  • SLPKEY_LOCK Lock key so AD5940 is prohibited to enter sleep mode.
Returns:
return none.

Definition at line 2911 of file ad5940.c.

AD5940Err AD5940_SoftRst ( void   )

Reset AD5940 by register.

Note:
AD5940 must be in active state so we can access registers. If AD5940 system clock is too low, we consider to use hardware reset, or we need to make sure register write is successfully.
Returns:
return none.

Definition at line 2994 of file ad5940.c.

void AD5940_StatisticCfgS ( StatCfg_Type pStatCfg )

Configure statistic functions.

Parameters:
pStatCfg,:Pointer to configuration structure
Returns:
return none.

Definition at line 1928 of file ad5940.c.

void AD5940_StructInit ( void *  pStruct,
uint32_t  StructSize 
)

Initialize Structure members to zero.

Parameters:
pStruct,:Pointer to the structure.
StructSize,:The structure size in Byte.
Returns:
Return None.

Definition at line 616 of file ad5940.c.

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.

Returns:
Return next frequency point in Hz.

Definition at line 569 of file ad5940.c.

void AD5940_SWMatrixCfgS ( SWMatrixCfg_Type pSwMatrix )

Initialize switch matrix.

Parameters:
pSwMatrix,:Pointer to configuration structure
Returns:
return none.

Definition at line 1365 of file ad5940.c.

uint32_t AD5940_WakeUp ( int32_t  TryCount )

Try to wakeup AD5940 by read register.

Any SPI operation can wakeup AD5940. AD5940_Initialize must be called to enable this function.

Parameters:
TryCountSpecify how many times we will read register. Zero or negative number means always waiting here.
Returns:
How many times register is read. If returned value is bigger than TryCount, it means wakeup failed.

Definition at line 2953 of file ad5940.c.

void AD5940_WGCfgS ( WGCfg_Type pWGInit )

Initialize waveform generator.

Parameters:
pWGInit,:Pointer to configuration structure
Returns:
return none.

Definition at line 1487 of file ad5940.c.

AD5940Err AD5940_WGDACCodeS ( uint32_t  code )

Write HSDAC code directly when WG configured to MMR type.

Parameters:
code,:The 12-bit HSDAC code.
Returns:
return none.

Definition at line 1529 of file ad5940.c.

void AD5940_WGFreqCtrlS ( float  SinFreqHz,
float  WGClock 
)

Update WG SIN wave frequency in Hz.

Parameters:
SinFreqHz,:The desired frequency in Hz.
WGClock,:The clock for WG. It's same as system clock and the default value is internal 16MHz HSOSC.
Returns:
return none.

Definition at line 1542 of file ad5940.c.

uint32_t AD5940_WGFreqWordCal ( float  SinFreqHz,
float  WGClock 
)

Calculate sine wave generator frequency word.

The maxim frequency is 250kHz-1LSB

Parameters:
SinFreqHz: Target frequency in Hz unit.
WGClock,:Waveform generator clock frequency in Hz unit. The clock is sourced from system clock, default value is 16MHz HFOSC.
Returns:
return none.

Definition at line 1555 of file ad5940.c.

void AD5940_WriteReg ( uint16_t  RegAddr,
uint32_t  RegData 
)

SPI_Block.

Write register. If sequencer generator is enabled, the register write is recorded. Otherwise, the data is written to AD5940 by SPI.

Parameters:
RegAddr,:The register address.
RegData,:The register data.
Returns:
Return None.

Definition at line 1042 of file ad5940.c.

void AD5940_WUPTCfg ( WUPTCfg_Type pWuptCfg )

Configure Wakeup Timer.

Parameters:
pWuptCfg,:Pointer to configuration structure.
Returns:
return none.

Definition at line 2362 of file ad5940.c.

void AD5940_WUPTCtrl ( BoolFlag  Enable )

Enable or disable wakeup timer.

Parameters:
Enable: {bTRUE, bFALSE}

  • bTRUE: enable wakeup timer
  • bFALSE: Disable wakeup timer
Returns:
return none.

Definition at line 2419 of file ad5940.c.

AD5940Err AD5940_WUPTTime ( uint32_t  SeqId,
uint32_t  SleepTime,
uint32_t  WakeupTime 
)

Configure WakeupTimer.

Parameters:
SeqId,:Select from SEQID_0/1/2/3. The wakeup timer will load corresponding value from four sets of registers.
SleepTime,:After how much time, AFE will try to enter hibernate. We disabled this feature in AD59840_Initialize. After this timer expired, nothing will happen.
WakeupTime,:After how much time, AFE will wakeup and trigger corresponding sequencer.
Note:
By SleepTime and WakeupTime, the sequencer is triggered periodically and period is (SleepTime+WakeupTime)
Returns:
return none.

Definition at line 2439 of file ad5940.c.