Go to the documentation of this file.
34 #ifndef __AFE_CONFIG_H__
35 #define __AFE_CONFIG_H__
42 #include "adi_pqlib.h"
55 #define BITM_WFB_CFG_BURST_ALL_CHAN 0x00000000
57 #define BITM_WFB_CFG_WF_CAP_RESAMPLED_SEL 0x00000000
59 #define REG_WAVEFORM_FIRST_HALF_ADDRESS 0x801
61 #define REG_WAVEFORM_SECOND_HALF_ADDRESS 0xC01
63 #define BITM_ACCMODE_SELFREQ_50HZ 0x0
65 #define BITM_ACCMODE_SELFREQ_60HZ 0x0100
67 #define BITM_FREQ_VCONSEL_ICONSEL 0xFE0F
69 #define BITM_CONFIG0_PERIOD_AVG_CFG_AV8 0x00010000
71 #define BITM_CONFIG0_PERIOD_AVG_CFG_AV16 0x00020000
73 #define LP_SEL_APERIOD 0x0000
75 #define LP_SEL_BPERIOD 0x0008
77 #define LP_SEL_CPERIOD 0x0010
79 #define ZX_SEL_ZXVA 0x0000
81 #define ZX_SEL_ZXVB 0x0002
83 #define ZX_SEL_ZXVC 0x0004
85 #define SPI_TIMEOUT 100
89 #define SPI_HEADER_SIZE 2
91 #define MAX_SPI_DATA_SIZE 4
93 #define SPI_16BIT_DATA_SIZE 2
95 #define SPI_32BIT_DATA_SIZE 4
97 #define MAX_SPI_BUFFER_SIZE SPI_HEADER_SIZE + MAX_SPI_DATA_SIZE
199 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:79
#define SYS_STATUS_AFE_READWAVEFORM_FAILED
Definition: status.h:54
int afe_read_angle(uint16_t *pAngle, uint16_t numAngles, uint16_t angleVolCur)
reads angle registers.
Definition: afe_config.c:343
#define LP_SEL_APERIOD
Definition: afe_config.h:73
Header file of ADE9430 Driver.
int afe_read_status_1(uint32_t *pSTATUS1)
Read STATUS1 register.
Definition: afe_config.c:362
#define SYS_STATUS_AFE_READRMSONE_FAILED
Definition: status.h:56
#define BITM_FREQ_VCONSEL_ICONSEL
Definition: afe_config.h:67
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:159
int afe_read_status_1(uint32_t *pSTATUS1)
Read STATUS1 register.
Definition: afe_config.c:362
nhd_c12832a1z Initialization parameters.
Definition: nhd_c12832a1z.h:99
int afe_write_16bit_reg(uint16_t addr, uint16_t *pData)
write the 16bit value to the register
Definition: afe_config.c:406
Header file of nhd_c12832a1z.
int afe_set_ref_channel(uint16_t refChannel)
sets refChannel.
Definition: afe_config.c:564
int afe_read_rms_1012(uint32_t *pRMS, uint16_t numRMS)
reads rms1012value registers.
Definition: afe_config.c:333
#define SYS_STATUS_AFE_READVERSION_FAILED
Definition: status.h:59
#define SYS_STATUS_AFE_MASK0_FAILED
Definition: status.h:51
int afe_write_16bit_reg(uint16_t addr, uint16_t *pData)
write the 16bit value to the register
Definition: afe_config.c:406
@ AFE_SPI_STATUS_DMA_COMPLETED
Definition: afe_config.h:106
Definition: no_os_spi.h:100
@ SPI_SS_POL_LOW
Definition: maxim_spi.h:49
#define BITM_ACCMODE_SELFREQ_50HZ
Definition: afe_config.h:63
uint32_t AFE_OUTPUT_STATUS
Definition: afe_config.h:87
int config_afe_irq(void)
Configures IRQ flags.
Definition: afe_config.c:238
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:444
int32_t port
Definition: no_os_gpio.h:81
int afe_read_version(uint32_t *pVersion)
reads AFE version.
Definition: afe_config.c:378
int afe_read_waveform(uint16_t *pData, uint16_t numSamples)
reads waveform buffer.
Definition: afe_config.c:286
#define SYS_STATUS_AFE_CONFIG2_FAILED
Definition: status.h:48
#define SPI_16BIT_DATA_SIZE
Definition: afe_config.h:93
#define SYS_STATUS_AFE_READANGLE_FAILED
Definition: status.h:58
int reset_afe(void)
resets the AFE
Definition: afe_config.c:464
@ NO_OS_PULL_NONE
Definition: no_os_gpio.h:66
@ NO_OS_SPI_MODE_3
Definition: no_os_spi.h:67
int config_wfb(void)
configure WFB_CFB register, initialized with start filling
Definition: afe_config.c:253
uint32_t device_id
Definition: no_os_spi.h:142
@ AFE_SPI_STATUS_DMA_RUNNING
Definition: afe_config.h:105
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:126
#define SYS_STATUS_SUCCESS
Definition: status.h:41
#define BITM_ACCMODE_SELFREQ_60HZ
Definition: afe_config.h:65
int afe_start(void)
Starts the AFE.
Definition: afe_config.c:210
Maxim specific SPI initialization parameters.
Definition: maxim_spi.h:53
#define SYS_STATUS_AFE_RUN_FAILED
Definition: status.h:52
struct no_os_spi_init_param * spi_ip
Definition: nhd_c12832a1z.h:105
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:444
int afe_read_rms_one(uint32_t *pRMS, uint16_t numRMS)
reads rmsonevalue registers.
Definition: afe_config.c:323
struct no_os_spi_desc * hSPI
Definition: afe_config.c:44
#define SYS_STATUS_AFE_WFB_CFG_FAILED
Definition: status.h:53
#define SYS_STATUS_AFE_STATUS0_FAILED
Definition: status.h:61
#define SYS_STATUS_AFE_READRMS1012_FAILED
Definition: status.h:55
AFE_SPI_STATUS
Definition: afe_config.h:103
#define REG_WAVEFORM_SECOND_HALF_ADDRESS
Definition: afe_config.h:61
int afe_init(void)
Initializes SPI handler, AFE register values.
Definition: afe_config.c:133
int afe_read_period(uint32_t *pPeriod, uint16_t numPeriods)
reads period registers.
Definition: afe_config.c:310
int afe_start(void)
Starts the AFE.
Definition: afe_config.c:210
const struct no_os_spi_platform_ops max_spi_ops
maxim platform specific SPI platform ops structure
Definition: maxim_spi.c:795
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:104
int config_wfb(void)
configure WFB_CFB register, initialized with start filling
Definition: afe_config.c:253
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
#define ZX_SEL_ZXVA
Definition: afe_config.h:79
struct no_os_spi_msg spiMsg
Definition: afe_config.c:45
const struct no_os_gpio_platform_ops max_gpio_ops
maxim platform specific GPIO platform ops structure
Definition: maxim_gpio.c:320
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
#define SYS_STATUS_PQLIB_CONFIG_ERROR
Definition: status.h:45
#define REG_CONFIG0
Definition: ad9361.h:207
#define SPI_32BIT_DATA_SIZE
Definition: afe_config.h:95
nhd_c12832a1z device structure.
Definition: nhd_c12832a1z.h:86
mxc_gpio_vssel_t vssel
Definition: maxim_gpio.h:57
#define SYS_STATUS_AFE_ZX_LP_SEL_FAILED
Definition: status.h:50
#define BITM_WFB_CFG_BURST_ALL_CHAN
Definition: afe_config.h:55
GPIO platform specific init parameters.
Definition: maxim_gpio.h:55
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:49
int nhd_c12832a1z_init(struct nhd_c12832a1z_dev **device, struct nhd_c12832a1z_init_param init_param)
Initializes nhd_c12832a1z for display screening.
Definition: nhd_c12832a1z.c:467
#define SYS_STATUS_AFE_READPERIOD_FAILED
Definition: status.h:57
int afe_init(void)
Initializes SPI handler, AFE register values.
Definition: afe_config.c:133
int afe_read_period(uint32_t *pPeriod, uint16_t numPeriods)
reads period registers.
Definition: afe_config.c:310
#define LP_SEL_BPERIOD
Definition: afe_config.h:75
#define BITM_CONFIG0_PERIOD_AVG_CFG_AV16
Definition: afe_config.h:71
@ NO_OS_SPI_BIT_ORDER_MSB_FIRST
Definition: no_os_spi.h:76
#define SYS_STATUS_AFE_STATUS1_FAILED
Definition: status.h:60
int nhd_c12832a1z_print_string(struct nhd_c12832a1z_dev *dev, char *msg)
nhd_c12832a1z print string on LCD.
Definition: nhd_c12832a1z.c:358
int afe_set_ref_channel(uint16_t refChannel)
sets refChannel.
Definition: afe_config.c:564
int init_lcd(void)
Initialize LCD screen and text.
Definition: afe_config.c:52
#define REG_WAVEFORM_FIRST_HALF_ADDRESS
Definition: afe_config.h:59
#define SYS_STATUS_AFE_ACCMODE_FAILED
Definition: status.h:49
void afe_wait_settling(uint32_t cycles)
Waits for passed number of cycles.
Definition: afe_config.c:519
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:197
int init_lcd(void)
Initialize LCD screen and text.
Definition: afe_config.c:52
struct no_os_gpio_init_param reset_gpio_ip
Definition: common_data.c:226
void afe_wait_settling(uint32_t cycles)
Waits for passed number of cycles.
Definition: afe_config.c:519
int config_afe_irq(void)
Configures IRQ flags.
Definition: afe_config.c:238
int afe_read_version(uint32_t *pVersion)
reads AFE version.
Definition: afe_config.c:378
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:533
int afe_read_waveform(uint16_t *pData, uint16_t numSamples)
reads waveform buffer.
Definition: afe_config.c:286
int afe_read_angle(uint16_t *pAngle, uint16_t numAngles, uint16_t angleVolCur)
reads angle registers.
Definition: afe_config.c:343
#define BITM_WFB_CFG_WF_CAP_RESAMPLED_SEL
Definition: afe_config.h:57
int afe_write_32bit_reg(uint16_t addr, uint32_t *pData)
write the 32bit value to the register
Definition: afe_config.c:388
@ AFE_SPI_STATUS_DMA_IDLE
Definition: afe_config.h:104
struct no_os_spi_init_param spi_egy_ip
Definition: common_data.c:216
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:533
#define ZX_SEL_ZXVC
Definition: afe_config.h:83
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:52
int afe_read_rms_one(uint32_t *pRMS, uint16_t numRMS)
reads rmsonevalue registers.
Definition: afe_config.c:323
int reset_afe(void)
resets the AFE
Definition: afe_config.c:464
Header file of utility functions.
int afe_read_rms_1012(uint32_t *pRMS, uint16_t numRMS)
reads rms1012value registers.
Definition: afe_config.c:333
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:424
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:147
int afe_read_status0(uint32_t *pSTATUS0)
Read STATUS0 register.
Definition: afe_config.c:495
int spi_device_init(void)
SPI Initialization Function.
Definition: afe_config.c:490
#define LP_SEL_CPERIOD
Definition: afe_config.h:77
#define SYS_STATUS_AFE_CONFIG1_FAILED
Definition: status.h:47
#define SYS_STATUS_AFE_CONFIG0_FAILED
Definition: status.h:46
int afe_write_32bit_reg(uint16_t addr, uint32_t *pData)
write the 32bit value to the register
Definition: afe_config.c:388
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:424
#define ZX_SEL_ZXVB
Definition: afe_config.h:81
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140
int afe_read_status0(uint32_t *pSTATUS0)
Read STATUS0 register.
Definition: afe_config.c:495
int spi_device_init(void)
SPI Initialization Function.
Definition: afe_config.c:490