no-OS
Functions | Variables
afe_config.c File Reference
#include "afe_config.h"
Include dependency graph for afe_config.c:

Functions

int afe_init (void)
 Initializes SPI handler, AFE register values. More...
 
int afe_start (void)
 Starts the AFE. More...
 
int config_afe_irq (void)
 Configures IRQ flags. More...
 
int config_wfb (void)
 configure WFB_CFB register, initialized with start filling 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_version (uint32_t *pVersion)
 reads AFE version. 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...
 
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 reset_afe (void)
 resets the AFE More...
 
int spi_device_init (void)
 SPI Initialization Function. 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_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...
 

Variables

volatile uint8_t rmsOneReady = 0
 
struct no_os_spi_deschSPI
 
struct no_os_spi_msg spiMsg
 
struct no_os_gpio_init_param reset_gpio_ip
 

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:

Variable Documentation

◆ hSPI

struct no_os_spi_desc* hSPI

◆ reset_gpio_ip

struct no_os_gpio_init_param reset_gpio_ip

◆ rmsOneReady

volatile uint8_t rmsOneReady = 0

◆ spiMsg

struct no_os_spi_msg spiMsg