Go to the documentation of this file.
40 #ifndef __AFE_CONFIG_H__
41 #define __AFE_CONFIG_H__
48 #include "adi_pqlib.h"
60 #define BITM_WFB_CFG_BURST_ALL_CHAN 0x00000000
62 #define BITM_WFB_CFG_WF_CAP_RESAMPLED_SEL 0x00000000
64 #define REG_WAVEFORM_FIRST_HALF_ADDRESS 0x801
66 #define REG_WAVEFORM_SECOND_HALF_ADDRESS 0xC01
68 #define BITM_ACCMODE_SELFREQ_50HZ 0x0
70 #define BITM_ACCMODE_SELFREQ_60HZ 0x0100
72 #define BITM_FREQ_VCONSEL_ICONSEL 0xFE0F
74 #define BITM_CONFIG0_PERIOD_AVG_CFG_AV8 0x00010000
76 #define BITM_CONFIG0_PERIOD_AVG_CFG_AV16 0x00020000
78 #define LP_SEL_APERIOD 0x0000
80 #define LP_SEL_BPERIOD 0x0008
82 #define LP_SEL_CPERIOD 0x0010
84 #define ZX_SEL_ZXVA 0x0000
86 #define ZX_SEL_ZXVB 0x0002
88 #define ZX_SEL_ZXVC 0x0004
90 #define SPI_TIMEOUT 100
94 #define SPI_HEADER_SIZE 2
96 #define MAX_SPI_DATA_SIZE 4
98 #define SPI_16BIT_DATA_SIZE 2
100 #define SPI_32BIT_DATA_SIZE 4
102 #define MAX_SPI_BUFFER_SIZE SPI_HEADER_SIZE + MAX_SPI_DATA_SIZE
197 uint16_t angleVolCur);
void no_os_memswap64(void *buf, uint32_t bytes, uint32_t step)
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:85
#define SYS_STATUS_AFE_READWAVEFORM_FAILED
Definition: status.h:60
int afe_read_angle(uint16_t *pAngle, uint16_t numAngles, uint16_t angleVolCur)
reads angle registers.
Definition: afe_config.c:270
#define LP_SEL_APERIOD
Definition: afe_config.h:78
Header file of ADE9430 Driver.
int afe_read_status_1(uint32_t *pSTATUS1)
Read STATUS1 register.
Definition: afe_config.c:289
#define SYS_STATUS_AFE_READRMSONE_FAILED
Definition: status.h:62
#define BITM_FREQ_VCONSEL_ICONSEL
Definition: afe_config.h:72
int32_t no_os_spi_write_and_read(struct no_os_spi_desc *desc, uint8_t *data, uint16_t bytes_number)
Write and read data to/from SPI.
Definition: no_os_spi.c:165
int afe_read_status_1(uint32_t *pSTATUS1)
Read STATUS1 register.
Definition: afe_config.c:289
int afe_write_16bit_reg(uint16_t addr, uint16_t *pData)
write the 16bit value to the register
Definition: afe_config.c:333
int afe_set_ref_channel(uint16_t refChannel)
sets refChannel.
Definition: afe_config.c:495
int afe_read_rms_1012(uint32_t *pRMS, uint16_t numRMS)
reads rms1012value registers.
Definition: afe_config.c:260
#define SYS_STATUS_AFE_READVERSION_FAILED
Definition: status.h:65
#define SYS_STATUS_AFE_MASK0_FAILED
Definition: status.h:57
int afe_write_16bit_reg(uint16_t addr, uint16_t *pData)
write the 16bit value to the register
Definition: afe_config.c:333
@ AFE_SPI_STATUS_DMA_COMPLETED
Definition: afe_config.h:111
Definition: no_os_spi.h:91
#define BITM_ACCMODE_SELFREQ_50HZ
Definition: afe_config.h:68
uint32_t AFE_OUTPUT_STATUS
Definition: afe_config.h:92
int config_afe_irq(void)
Configures IRQ flags.
Definition: afe_config.c:165
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.
Definition: afe_config.c:371
int afe_read_version(uint32_t *pVersion)
reads AFE version.
Definition: afe_config.c:305
int afe_read_waveform(uint16_t *pData, uint16_t numSamples)
reads waveform buffer.
Definition: afe_config.c:213
#define SYS_STATUS_AFE_CONFIG2_FAILED
Definition: status.h:54
#define SPI_16BIT_DATA_SIZE
Definition: afe_config.h:98
#define SYS_STATUS_AFE_READANGLE_FAILED
Definition: status.h:64
int reset_afe(void)
resets the AFE
Definition: afe_config.c:391
int config_wfb(void)
configure WFB_CFB register, initialized with start filling
Definition: afe_config.c:180
@ AFE_SPI_STATUS_DMA_RUNNING
Definition: afe_config.h:110
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:132
#define SYS_STATUS_SUCCESS
Definition: status.h:47
#define BITM_ACCMODE_SELFREQ_60HZ
Definition: afe_config.h:70
int afe_start(void)
Starts the AFE.
Definition: afe_config.c:137
#define SYS_STATUS_AFE_RUN_FAILED
Definition: status.h:58
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.
Definition: afe_config.c:371
int afe_read_rms_one(uint32_t *pRMS, uint16_t numRMS)
reads rmsonevalue registers.
Definition: afe_config.c:250
struct no_os_spi_desc * hSPI
Definition: afe_config.c:51
#define SYS_STATUS_AFE_WFB_CFG_FAILED
Definition: status.h:59
#define SYS_STATUS_AFE_STATUS0_FAILED
Definition: status.h:67
#define SYS_STATUS_AFE_READRMS1012_FAILED
Definition: status.h:61
AFE_SPI_STATUS
Definition: afe_config.h:108
#define REG_WAVEFORM_SECOND_HALF_ADDRESS
Definition: afe_config.h:66
int afe_init(void)
Initializes SPI handler, AFE register values.
Definition: afe_config.c:59
int afe_read_period(uint32_t *pPeriod, uint16_t numPeriods)
reads period registers.
Definition: afe_config.c:237
int afe_start(void)
Starts the AFE.
Definition: afe_config.c:137
int32_t no_os_gpio_remove(struct no_os_gpio_desc *desc)
Free the resources allocated by no_os_gpio_get().
Definition: no_os_gpio.c:110
int config_wfb(void)
configure WFB_CFB register, initialized with start filling
Definition: afe_config.c:180
Structure holding SPI descriptor.
Definition: no_os_spi.h:177
#define ZX_SEL_ZXVA
Definition: afe_config.h:84
struct no_os_spi_msg spiMsg
Definition: afe_config.c:52
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:102
#define SYS_STATUS_PQLIB_CONFIG_ERROR
Definition: status.h:51
#define REG_CONFIG0
Definition: ad9361.h:213
#define SPI_32BIT_DATA_SIZE
Definition: afe_config.h:100
#define SYS_STATUS_AFE_ZX_LP_SEL_FAILED
Definition: status.h:56
#define BITM_WFB_CFG_BURST_ALL_CHAN
Definition: afe_config.h:60
int32_t no_os_gpio_get(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Obtain the GPIO decriptor.
Definition: no_os_gpio.c:55
#define SYS_STATUS_AFE_READPERIOD_FAILED
Definition: status.h:63
int afe_init(void)
Initializes SPI handler, AFE register values.
Definition: afe_config.c:59
int afe_read_period(uint32_t *pPeriod, uint16_t numPeriods)
reads period registers.
Definition: afe_config.c:237
#define LP_SEL_BPERIOD
Definition: afe_config.h:80
#define BITM_CONFIG0_PERIOD_AVG_CFG_AV16
Definition: afe_config.h:76
#define SYS_STATUS_AFE_STATUS1_FAILED
Definition: status.h:66
int afe_set_ref_channel(uint16_t refChannel)
sets refChannel.
Definition: afe_config.c:495
#define REG_WAVEFORM_FIRST_HALF_ADDRESS
Definition: afe_config.h:64
#define SYS_STATUS_AFE_ACCMODE_FAILED
Definition: status.h:55
void afe_wait_settling(uint32_t cycles)
Waits for passed number of cycles.
Definition: afe_config.c:448
int32_t no_os_gpio_set_value(struct no_os_gpio_desc *desc, uint8_t value)
Set the value of the specified GPIO.
Definition: no_os_gpio.c:203
struct no_os_gpio_init_param reset_gpio_ip
Definition: common_data.c:140
void afe_wait_settling(uint32_t cycles)
Waits for passed number of cycles.
Definition: afe_config.c:448
int config_afe_irq(void)
Configures IRQ flags.
Definition: afe_config.c:165
int afe_read_version(uint32_t *pVersion)
reads AFE version.
Definition: afe_config.c:305
int afe_set_acc_mode(uint16_t frequency, uint16_t vconsel, uint16_t iconsel)
sets ACCMODE register for nominal frequency, ICONSEL, VCONSEL.
Definition: afe_config.c:464
int afe_read_waveform(uint16_t *pData, uint16_t numSamples)
reads waveform buffer.
Definition: afe_config.c:213
int afe_read_angle(uint16_t *pAngle, uint16_t numAngles, uint16_t angleVolCur)
reads angle registers.
Definition: afe_config.c:270
#define BITM_WFB_CFG_WF_CAP_RESAMPLED_SEL
Definition: afe_config.h:62
int afe_write_32bit_reg(uint16_t addr, uint32_t *pData)
write the 32bit value to the register
Definition: afe_config.c:315
@ AFE_SPI_STATUS_DMA_IDLE
Definition: afe_config.h:109
struct no_os_spi_init_param spi_egy_ip
Definition: common_data.c:130
int afe_set_acc_mode(uint16_t frequency, uint16_t vconsel, uint16_t iconsel)
sets ACCMODE register for nominal frequency, ICONSEL, VCONSEL.
Definition: afe_config.c:464
#define ZX_SEL_ZXVC
Definition: afe_config.h:88
int32_t no_os_spi_init(struct no_os_spi_desc **desc, const struct no_os_spi_init_param *param)
Initialize the SPI communication peripheral.
Definition: no_os_spi.c:58
int afe_read_rms_one(uint32_t *pRMS, uint16_t numRMS)
reads rmsonevalue registers.
Definition: afe_config.c:250
int reset_afe(void)
resets the AFE
Definition: afe_config.c:391
Header file of utility functions.
int afe_read_rms_1012(uint32_t *pRMS, uint16_t numRMS)
reads rms1012value registers.
Definition: afe_config.c:260
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.
Definition: afe_config.c:351
int32_t no_os_gpio_direction_output(struct no_os_gpio_desc *desc, uint8_t value)
Enable the output direction of the specified GPIO.
Definition: no_os_gpio.c:153
int afe_read_status0(uint32_t *pSTATUS0)
Read STATUS0 register.
Definition: afe_config.c:422
int spi_device_init(void)
SPI Initialization Function.
Definition: afe_config.c:417
#define LP_SEL_CPERIOD
Definition: afe_config.h:82
#define SYS_STATUS_AFE_CONFIG1_FAILED
Definition: status.h:53
#define SYS_STATUS_AFE_CONFIG0_FAILED
Definition: status.h:52
int afe_write_32bit_reg(uint16_t addr, uint32_t *pData)
write the 32bit value to the register
Definition: afe_config.c:315
int init_interrupt(void)
Initialize interrupt from ade9430 for STATUS polling.
Definition: intrpt_handler.c:64
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.
Definition: afe_config.c:351
#define ZX_SEL_ZXVB
Definition: afe_config.h:86
volatile uint8_t rmsOneReady
Definition: afe_config.c:50
int afe_read_status0(uint32_t *pSTATUS0)
Read STATUS0 register.
Definition: afe_config.c:422
int spi_device_init(void)
SPI Initialization Function.
Definition: afe_config.c:417