no-OS
Macros | Typedefs | Enumerations | Functions
afe_config.h File Reference
#include "ade9430.h"
#include "adi_pqlib.h"
#include "common_data.h"
#include "no_os_util.h"
#include "status.h"
#include <stdint.h>
#include <string.h>
Include dependency graph for afe_config.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BITM_WFB_CFG_BURST_ALL_CHAN   0x00000000
 
#define BITM_WFB_CFG_WF_CAP_RESAMPLED_SEL   0x00000000
 
#define REG_WAVEFORM_FIRST_HALF_ADDRESS   0x801
 
#define REG_WAVEFORM_SECOND_HALF_ADDRESS   0xC01
 
#define BITM_ACCMODE_SELFREQ_50HZ   0x0
 
#define BITM_ACCMODE_SELFREQ_60HZ   0x0100
 
#define BITM_FREQ_VCONSEL_ICONSEL   0xFE0F
 
#define BITM_CONFIG0_PERIOD_AVG_CFG_AV8   0x00010000
 
#define BITM_CONFIG0_PERIOD_AVG_CFG_AV16   0x00020000
 
#define LP_SEL_APERIOD   0x0000
 
#define LP_SEL_BPERIOD   0x0008
 
#define LP_SEL_CPERIOD   0x0010
 
#define ZX_SEL_ZXVA   0x0000
 
#define ZX_SEL_ZXVB   0x0002
 
#define ZX_SEL_ZXVC   0x0004
 
#define SPI_TIMEOUT   100
 
#define SPI_HEADER_SIZE   2
 
#define MAX_SPI_DATA_SIZE   4
 
#define SPI_16BIT_DATA_SIZE   2
 
#define SPI_32BIT_DATA_SIZE   4
 
#define MAX_SPI_BUFFER_SIZE   SPI_HEADER_SIZE + MAX_SPI_DATA_SIZE
 

Typedefs

typedef uint32_t AFE_OUTPUT_STATUS
 

Enumerations

enum  AFE_SPI_STATUS {
  AFE_SPI_STATUS_DMA_IDLE,
  AFE_SPI_STATUS_DMA_RUNNING,
  AFE_SPI_STATUS_DMA_COMPLETED
}
 

Functions

int spi_device_init (void)
 SPI Initialization Function. More...
 
int config_wfb (void)
 configure WFB_CFB register, initialized with start filling More...
 
int reset_afe (void)
 resets the AFE More...
 
int afe_start (void)
 Starts the AFE. More...
 
int afe_init (void)
 Initializes SPI handler, AFE register values. More...
 
int afe_read_waveform (uint16_t *pData, uint16_t numSamples)
 reads waveform buffer. More...
 
int afe_read_period (uint32_t *pPeriod, uint16_t numPeriods)
 reads period registers. More...
 
int afe_read_rms_one (uint32_t *pRMS, uint16_t numRMS)
 reads rmsonevalue registers. More...
 
int afe_read_rms_1012 (uint32_t *pRMS, uint16_t numRMS)
 reads rms1012value registers. More...
 
int afe_read_angle (uint16_t *pAngle, uint16_t numAngles, uint16_t angleVolCur)
 reads angle registers. More...
 
int afe_read_status_1 (uint32_t *pSTATUS1)
 Read STATUS1 register. More...
 
int afe_read_status0 (uint32_t *pSTATUS0)
 Read STATUS0 register. More...
 
void afe_wait_settling (uint32_t cycles)
 Waits for passed number of cycles. More...
 
int afe_read_version (uint32_t *pVersion)
 reads AFE version. More...
 
int config_afe_irq (void)
 Configures IRQ flags. More...
 
int afe_set_acc_mode (uint16_t frequency, uint16_t vconsel, uint16_t iconsel)
 sets ACCMODE register for nominal frequency, ICONSEL, VCONSEL. More...
 
int afe_set_ref_channel (uint16_t refChannel)
 sets refChannel. More...
 
int afe_read_32bit_buff (uint16_t addr, uint16_t numSamples, uint32_t *pData)
 reads the 32bit value from the register and saves to a 32bit buffer. More...
 
int afe_read_16bit_buff (uint16_t addr, uint16_t numSamples, uint16_t *pData)
 reads the 16bit value from the register and saves to a 16bitbuffer. More...
 
int afe_write_32bit_reg (uint16_t addr, uint32_t *pData)
 write the 32bit value to the register More...
 
int afe_write_16bit_reg (uint16_t addr, uint16_t *pData)
 write the 16bit value to the register More...
 

Macro Definition Documentation

◆ BITM_ACCMODE_SELFREQ_50HZ

#define BITM_ACCMODE_SELFREQ_50HZ   0x0

50Hz System nominal frequency

◆ BITM_ACCMODE_SELFREQ_60HZ

#define BITM_ACCMODE_SELFREQ_60HZ   0x0100

60Hz System nominal frequency

◆ BITM_CONFIG0_PERIOD_AVG_CFG_AV16

#define BITM_CONFIG0_PERIOD_AVG_CFG_AV16   0x00020000

Average by 16 to reduce jitter

◆ BITM_CONFIG0_PERIOD_AVG_CFG_AV8

#define BITM_CONFIG0_PERIOD_AVG_CFG_AV8   0x00010000

Average by 8 to reduce jitter

◆ BITM_FREQ_VCONSEL_ICONSEL

#define BITM_FREQ_VCONSEL_ICONSEL   0xFE0F

frequency, VCON and ICON selection

◆ BITM_WFB_CFG_BURST_ALL_CHAN

#define BITM_WFB_CFG_BURST_ALL_CHAN   0x00000000

WFB_CFG burst all channels

◆ BITM_WFB_CFG_WF_CAP_RESAMPLED_SEL

#define BITM_WFB_CFG_WF_CAP_RESAMPLED_SEL   0x00000000

WFB_CFG resampled data for waveform

◆ LP_SEL_APERIOD

#define LP_SEL_APERIOD   0x0000

Line period measurement on APERIOD

◆ LP_SEL_BPERIOD

#define LP_SEL_BPERIOD   0x0008

Line period measurement on BPERIOD

◆ LP_SEL_CPERIOD

#define LP_SEL_CPERIOD   0x0010

Line period measurement on CPERIOD

◆ MAX_SPI_BUFFER_SIZE

#define MAX_SPI_BUFFER_SIZE   SPI_HEADER_SIZE + MAX_SPI_DATA_SIZE

maximum size of SPI buffer

◆ MAX_SPI_DATA_SIZE

#define MAX_SPI_DATA_SIZE   4

SPI max data size in bytes

◆ REG_WAVEFORM_FIRST_HALF_ADDRESS

#define REG_WAVEFORM_FIRST_HALF_ADDRESS   0x801

Waveform buffer first half address

◆ REG_WAVEFORM_SECOND_HALF_ADDRESS

#define REG_WAVEFORM_SECOND_HALF_ADDRESS   0xC01

Waveform buffer second half address

◆ SPI_16BIT_DATA_SIZE

#define SPI_16BIT_DATA_SIZE   2

SPI 16bit data size in bytes

◆ SPI_32BIT_DATA_SIZE

#define SPI_32BIT_DATA_SIZE   4

SPI 32bit data size in bytes

◆ SPI_HEADER_SIZE

#define SPI_HEADER_SIZE   2

SPI header size in bytes

◆ SPI_TIMEOUT

#define SPI_TIMEOUT   100

Spi timeout

◆ ZX_SEL_ZXVA

#define ZX_SEL_ZXVA   0x0000

zero-crossing signal routed to the CF3/ZX on ZXVA

◆ ZX_SEL_ZXVB

#define ZX_SEL_ZXVB   0x0002

zero-crossing signal routed to the CF3/ZX on ZXVB

◆ ZX_SEL_ZXVC

#define ZX_SEL_ZXVC   0x0004

zero-crossing signal routed to the CF3/ZX on ZXVC

Typedef Documentation

◆ AFE_OUTPUT_STATUS

typedef uint32_t AFE_OUTPUT_STATUS

status of afe functions

Enumeration Type Documentation

◆ AFE_SPI_STATUS

Enumeration to capture status of SPI

Enumerator
AFE_SPI_STATUS_DMA_IDLE 
AFE_SPI_STATUS_DMA_RUNNING 
AFE_SPI_STATUS_DMA_COMPLETED 

Function Documentation

◆ afe_init()

int afe_init ( void  )

Initializes SPI handler, AFE register values.

Returns
status - SYS_STATUS_SUCCESS on Success.
  • AFE macro failure on Failure.
Here is the caller graph for this function:

◆ afe_read_16bit_buff()

int afe_read_16bit_buff ( uint16_t  addr,
uint16_t  numSamples,
uint16_t *  pData 
)

reads the 16bit value from the register and saves to a 16bitbuffer.

Parameters
[in]addr- register address
[in]numSamples- number of samples to be read
[in]pData- pointer to read pData
Returns
status 0 for success.
Here is the caller graph for this function:

◆ afe_read_32bit_buff()

int afe_read_32bit_buff ( uint16_t  addr,
uint16_t  numSamples,
uint32_t *  pData 
)

reads the 32bit value from the register and saves to a 32bit buffer.

Parameters
[in]addr- register address
[in]numSamples- number of samples to be write
[out]pData- pointer to write pData
Returns
status 0 for success.
Here is the caller graph for this function:

◆ afe_read_angle()

int afe_read_angle ( uint16_t *  pAngle,
uint16_t  numAngles,
uint16_t  angleVolCur 
)

reads angle registers.

Parameters
[out]pAngle- pointer to read angle values.
[in]numAngles- number of angle values to be read.
[in]angleVolCur- address of current or voltage angle
Returns
status - SYS_STATUS_SUCCESS on success,
  • SYS_STATUS_AFE_READANGLE_FAILED on failure.
Here is the caller graph for this function:

◆ afe_read_period()

int afe_read_period ( uint32_t *  pPeriod,
uint16_t  numPeriods 
)

reads period registers.

Parameters
[out]pPeriod- pointer to read period.
[in]numPeriods- number of periods to be read.
Returns
status - SYS_STATUS_SUCCESS on success,
  • SYS_STATUS_AFE_READPERIOD_FAILED on failure.
Here is the caller graph for this function:

◆ afe_read_rms_1012()

int afe_read_rms_1012 ( uint32_t *  pRMS,
uint16_t  numRMS 
)

reads rms1012value registers.

Parameters
[out]pRMS- pointer to read RMS1012 values.
[in]numRMS- number of rms values to be read.
Returns
status - SYS_STATUS_SUCCESS on success,
  • SYS_STATUS_AFE_READRMS1012_FAILED on failure.
Here is the caller graph for this function:

◆ afe_read_rms_one()

int afe_read_rms_one ( uint32_t *  pRMS,
uint16_t  numRMS 
)

reads rmsonevalue registers.

Parameters
[out]pRMS- pointer to read RMSOne values.
[in]numRMS- number of rms values to be read.
Returns
status - SYS_STATUS_SUCCESS on success,
  • SYS_STATUS_AFE_READRMSONE_FAILED on failure.
Here is the caller graph for this function:

◆ afe_read_status0()

int afe_read_status0 ( uint32_t *  pSTATUS0)

Read STATUS0 register.

Parameters
[out]pSTATUS0- pointer to read STATUS0.
Returns
status - SYS_STATUS_SUCCESS on Success,
  • SYS_STATUS_AFE_STATUS0_FAILED on Failure.
Here is the caller graph for this function:

◆ afe_read_status_1()

int afe_read_status_1 ( uint32_t *  pSTATUS1)

Read STATUS1 register.

Parameters
[out]pSTATUS1- pointer to read STATUS1.
Returns
status - SYS_STATUS_SUCCESS on Success
  • SYS_STATUS_AFE_STATUS1_FAILED on Failure.
Here is the caller graph for this function:

◆ afe_read_version()

int afe_read_version ( uint32_t *  pVersion)

reads AFE version.

Parameters
[out]pVersion- pointer to read AFE version.
Returns
status - SYS_STATUS_SUCCESS on success,
  • SYS_STATUS_AFE_READVERSION_FAILED on failure.
Here is the caller graph for this function:

◆ afe_read_waveform()

int afe_read_waveform ( uint16_t *  pData,
uint16_t  numSamples 
)

reads waveform buffer.

Parameters
[out]pData- pointer to read waveform buffer data.
[in]numSamples- number of samples to be read.
Returns
status - SYS_STATUS_SUCCESS on Success
  • SYS_STATUS_AFE_WAVEFORM_FAILED on Failure.
Here is the caller graph for this function:

◆ afe_set_acc_mode()

int afe_set_acc_mode ( uint16_t  frequency,
uint16_t  vconsel,
uint16_t  iconsel 
)

sets ACCMODE register for nominal frequency, ICONSEL, VCONSEL.

Parameters
[in]frequency- nomianl frequency
[in]vconsel- vconsel bits
[in]iconsel- iconsel bits
Returns
status - SYS_STATUS_SUCCESS on success.
  • SYS_STATUS_AFE_ACCMODE_FAILED on failure.
Here is the caller graph for this function:

◆ afe_set_ref_channel()

int afe_set_ref_channel ( uint16_t  refChannel)

sets refChannel.

Parameters
[in]refChannel- refChannel
Returns
status - SYS_STATUS_SUCCESS on success,
  • SYS_STATUS_AFE_ZX_LP_SEL_FAILED on failure.
Here is the caller graph for this function:

◆ afe_start()

int afe_start ( void  )

Starts the AFE.

Returns
status - SYS_STATUS_SUCCESS on Success.
  • AFE macro failure on Failure.
Here is the caller graph for this function:

◆ afe_wait_settling()

void afe_wait_settling ( uint32_t  cycles)

Waits for passed number of cycles.

Parameters
[in]cycles- Number of cycles to wait
Here is the caller graph for this function:

◆ afe_write_16bit_reg()

int afe_write_16bit_reg ( uint16_t  addr,
uint16_t *  pData 
)

write the 16bit value to the register

Parameters
[in]addr- register address
[in]pData- pointer to write data
Returns
status 0 for success.
Here is the caller graph for this function:

◆ afe_write_32bit_reg()

int afe_write_32bit_reg ( uint16_t  addr,
uint32_t *  pData 
)

write the 32bit value to the register

Parameters
[in]addr- register address
[in]pData- pointer to write data
Returns
status 0 for success.
Here is the caller graph for this function:

◆ config_afe_irq()

int config_afe_irq ( void  )

Configures IRQ flags.

Returns
status - SYS_STATUS_SUCCESS on Success
  • SYS_STATUS_AFE_MASK0_FAILED on Failure.
Here is the caller graph for this function:

◆ config_wfb()

int config_wfb ( void  )

configure WFB_CFB register, initialized with start filling

Returns
status - SYS_STATUS_SUCCESS for success failure value for failure
Here is the caller graph for this function:

◆ reset_afe()

int reset_afe ( void  )

resets the AFE

Here is the caller graph for this function:

◆ spi_device_init()

int spi_device_init ( void  )

SPI Initialization Function.

Return values
status0 for success
Here is the caller graph for this function: