no-OS
|
#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 "nhd_c12832a1z.h"
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 | init_lcd (void) |
Initialize LCD screen and text. More... | |
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... | |
#define BITM_ACCMODE_SELFREQ_50HZ 0x0 |
50Hz System nominal frequency
#define BITM_ACCMODE_SELFREQ_60HZ 0x0100 |
60Hz System nominal frequency
#define BITM_CONFIG0_PERIOD_AVG_CFG_AV16 0x00020000 |
Average by 16 to reduce jitter
#define BITM_CONFIG0_PERIOD_AVG_CFG_AV8 0x00010000 |
Average by 8 to reduce jitter
#define BITM_FREQ_VCONSEL_ICONSEL 0xFE0F |
frequency, VCON and ICON selection
#define BITM_WFB_CFG_BURST_ALL_CHAN 0x00000000 |
WFB_CFG burst all channels
#define BITM_WFB_CFG_WF_CAP_RESAMPLED_SEL 0x00000000 |
WFB_CFG resampled data for waveform
#define LP_SEL_APERIOD 0x0000 |
Line period measurement on APERIOD
#define LP_SEL_BPERIOD 0x0008 |
Line period measurement on BPERIOD
#define LP_SEL_CPERIOD 0x0010 |
Line period measurement on CPERIOD
#define MAX_SPI_BUFFER_SIZE SPI_HEADER_SIZE + MAX_SPI_DATA_SIZE |
maximum size of SPI buffer
#define MAX_SPI_DATA_SIZE 4 |
SPI max data size in bytes
#define REG_WAVEFORM_FIRST_HALF_ADDRESS 0x801 |
Waveform buffer first half address
#define REG_WAVEFORM_SECOND_HALF_ADDRESS 0xC01 |
Waveform buffer second half address
#define SPI_16BIT_DATA_SIZE 2 |
SPI 16bit data size in bytes
#define SPI_32BIT_DATA_SIZE 4 |
SPI 32bit data size in bytes
#define SPI_HEADER_SIZE 2 |
SPI header size in bytes
#define SPI_TIMEOUT 100 |
Spi timeout
#define ZX_SEL_ZXVA 0x0000 |
zero-crossing signal routed to the CF3/ZX on ZXVA
#define ZX_SEL_ZXVB 0x0002 |
zero-crossing signal routed to the CF3/ZX on ZXVB
#define ZX_SEL_ZXVC 0x0004 |
zero-crossing signal routed to the CF3/ZX on ZXVC
typedef uint32_t AFE_OUTPUT_STATUS |
status of afe functions
enum AFE_SPI_STATUS |
int afe_init | ( | void | ) |
Initializes SPI handler, AFE register values.
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.
[in] | addr | - register address |
[in] | numSamples | - number of samples to be read |
[in] | pData | - pointer to read pData |
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.
[in] | addr | - register address |
[in] | numSamples | - number of samples to be write |
[out] | pData | - pointer to write pData |
int afe_read_angle | ( | uint16_t * | pAngle, |
uint16_t | numAngles, | ||
uint16_t | angleVolCur | ||
) |
reads angle registers.
[out] | pAngle | - pointer to read angle values. |
[in] | numAngles | - number of angle values to be read. |
[in] | angleVolCur | - address of current or voltage angle |
int afe_read_period | ( | uint32_t * | pPeriod, |
uint16_t | numPeriods | ||
) |
reads period registers.
[out] | pPeriod | - pointer to read period. |
[in] | numPeriods | - number of periods to be read. |
int afe_read_rms_1012 | ( | uint32_t * | pRMS, |
uint16_t | numRMS | ||
) |
reads rms1012value registers.
[out] | pRMS | - pointer to read RMS1012 values. |
[in] | numRMS | - number of rms values to be read. |
int afe_read_rms_one | ( | uint32_t * | pRMS, |
uint16_t | numRMS | ||
) |
reads rmsonevalue registers.
[out] | pRMS | - pointer to read RMSOne values. |
[in] | numRMS | - number of rms values to be read. |
int afe_read_status0 | ( | uint32_t * | pSTATUS0 | ) |
Read STATUS0 register.
[out] | pSTATUS0 | - pointer to read STATUS0. |
int afe_read_status_1 | ( | uint32_t * | pSTATUS1 | ) |
Read STATUS1 register.
[out] | pSTATUS1 | - pointer to read STATUS1. |
int afe_read_version | ( | uint32_t * | pVersion | ) |
reads AFE version.
[out] | pVersion | - pointer to read AFE version. |
int afe_read_waveform | ( | uint16_t * | pData, |
uint16_t | numSamples | ||
) |
reads waveform buffer.
[out] | pData | - pointer to read waveform buffer data. |
[in] | numSamples | - number of samples to be read. |
int afe_set_acc_mode | ( | uint16_t | frequency, |
uint16_t | vconsel, | ||
uint16_t | iconsel | ||
) |
sets ACCMODE register for nominal frequency, ICONSEL, VCONSEL.
[in] | frequency | - nomianl frequency |
[in] | vconsel | - vconsel bits |
[in] | iconsel | - iconsel bits |
int afe_set_ref_channel | ( | uint16_t | refChannel | ) |
sets refChannel.
[in] | refChannel | - refChannel |
int afe_start | ( | void | ) |
Starts the AFE.
void afe_wait_settling | ( | uint32_t | cycles | ) |
Waits for passed number of cycles.
[in] | cycles | - Number of cycles to wait |
int afe_write_16bit_reg | ( | uint16_t | addr, |
uint16_t * | pData | ||
) |
write the 16bit value to the register
[in] | addr | - register address |
[in] | pData | - pointer to write data |
int afe_write_32bit_reg | ( | uint16_t | addr, |
uint32_t * | pData | ||
) |
write the 32bit value to the register
[in] | addr | - register address |
[in] | pData | - pointer to write data |
int config_afe_irq | ( | void | ) |
Configures IRQ flags.
int config_wfb | ( | void | ) |
configure WFB_CFB register, initialized with start filling
int init_lcd | ( | void | ) |
Initialize LCD screen and text.
int reset_afe | ( | void | ) |
resets the AFE
int spi_device_init | ( | void | ) |
SPI Initialization Function.
status | 0 for success |