Commit 6fca5770 authored by Joshua Supra's avatar Joshua Supra
Browse files

doc improvements

parent c544fbb2
......@@ -67,8 +67,7 @@ void initpilc2(IOCardStruct *IOCard){
/**
*
* Deinitialisation function for the PiLC 2. Calling the function will
* deinitialize the connectionto the FPGA Register space.
* checked.
* deinitialize the connection to the FPGA Register space.
*
* @return None
*
......@@ -79,7 +78,6 @@ void deinitpilc2(void){
status = DeinitFPGA();
if (status < 0){
perror("Error init spi");
exit(1);
}
}
......
......@@ -48,7 +48,6 @@
#define IO_CH_14 0x4000
#define IO_CH_15 0x8000
//#define PILC_IODDR_CFG_REG 0xB
#define PILC_IODDR_CFG_REG 0x1
#define PILC_IO_INPUT 0x0
......
/******************************************************************************/
/**
*
* @file pilc2_adc.c
*
* This file contains the implementation of the driver functions for the PiLC2
* ADC IP.
*
*******************************************************************************/
/***************************** Include Files **********************************/
#include "pilc2_adc.h"
#include "pilc2_register_func.h"
/******************************************************************************/
/**
*
* Reads a 32-Bit value containing the current ADC value of the selected channel.
*
*
* @param ADCchannel - Selected ADC channel
*
* @return The current ADC value.
*
* @note None.
*
*******************************************************************************/
int getADCvalue(char ADCchannel) {
int adc_value = ReadFPGA(PILC_ADC_OFFSET+ADC_DATA_REG_OFFSET+ADCchannel);
......@@ -10,6 +33,19 @@ int getADCvalue(char ADCchannel) {
}
/******************************************************************************/
/**
*
* Reads a 32-Bit value containing the current ADC filter value of the selected
* channel.
*
* @param ADCchannel - Selected ADC channel
*
* @return The current ADC filter value.
*
* @note None.
*
*******************************************************************************/
int getADCFiltervalue(char ADCchannel) {
int adc_filter_value = ReadFPGA(PILC_ADC_OFFSET+ADC_FILTER_REG_OFFSET+
ADCchannel);
......@@ -18,6 +54,19 @@ int getADCFiltervalue(char ADCchannel) {
}
/******************************************************************************/
/**
*
* Sets the ADC filter value for the selected channel.
*
* @param ADCchannel - Selected ADC channel
* @param filterValue - Filter value for selected ADC channel
*
* @return None.
*
* @note None.
*
*******************************************************************************/
void setADCFiltervalue(char ADCchannel, int filterValue) {
WriteFPGA(PILC_ADC_OFFSET+ADC_FILTER_REG_OFFSET+ADCchannel, filterValue);
......
/******************************************************************************/
/**
*
* @file pilc_IO_GPIO.h
*
* This file contains the functions declariation for the PiLC ADC IP.
*
*******************************************************************************/
/*************************** Constant Definitions *****************************/
#define PILC_ADC_OFFSET (0x3000>>2)
#define ADC_FILTER_REG_OFFSET (0x0>>2)
#define ADC_DATA_REG_OFFSET (0x40>>2)
......@@ -34,6 +41,8 @@
#define PILC_ADC_FILTER_512 0xA
#define PILC_ADC_FILTER_1014 0xB
/*************************** Function Prototypes ******************************/
int getADCvalue(char ADCchannel);
int getADCFiltervalue(char ADCchannel);
void setADCFiltervalue(char ADCchannel, int filterValue);
/*****************************************************************************/
/******************************************************************************/
/**
*
* @file pilc2_axi_gpio.c
*
* This file contains the implementation of the driver functions for the PiLC2
* axi gpio. This device is used to trigger interrupts depending on the amount
* adc IP. This device is used to trigger interrupts depending on the amount
* of words written into the BRAM.
*
* This driver is written to be used with UIO.
*
******************************************************************************/
*******************************************************************************/
/***************************** Include Files *********************************/
/***************************** Include Files **********************************/
#include "pilc2_axi_gpio.h"
#include "pilc2_bram_controller.h"
......@@ -21,25 +21,22 @@
#include <sys/mman.h>
#include <sys/select.h>
#include <sys/time.h>
/************************** Function Definitions *****************************/
/************************** Function Definitions ******************************/
/*****************************************************************************/
/**
*
* Function to write a 32 bit value into the specified register of the axi
* GPIO.
*
*
* @param axi_gpio_base is the base address of the axi gpio.
*
* offset is the register offset where value will be written.
*
* value the 32 bit value to be written at specified address.
* @param offset is the register offset where value will be written.
* @param value the 32 bit value to be written at specified address.
*
* @return None.
*
* @note None.
*
******************************************************************************/
*******************************************************************************/
void PiLC2AxiGPIOWrite(void *axi_gpio_base, unsigned int offset,
unsigned int value)
{
......@@ -47,44 +44,40 @@ void PiLC2AxiGPIOWrite(void *axi_gpio_base, unsigned int offset,
}
/*****************************************************************************/
/******************************************************************************/
/**
*
* FThis function reads a 32 bit value from a specified register of the axi
* gpio.
*
*
* @param axi_gpio_base is the base address of the axi gpio.
*
* offset is the register offset where value will be read.
* @param offset is the register offset where value will be read.
*
* @return The value of the specified register.
*
* @note None.
*
******************************************************************************/
*******************************************************************************/
unsigned int PiLC2AxiGPIORead(void *axi_gpio_base, unsigned int offset)
{
return *((volatile unsigned *)(axi_gpio_base + offset));
}
/*****************************************************************************/
/******************************************************************************/
/**
*
* Initialisatoin function for the axi gpio. The gpio will be granted access
* in the user and the device will be memory mapped to user space.
*
* Initialisatoin function for the axi gpio. The gpio will be granted access in
* the user and the device will be memory mapped to user space.
*
* @param uiod pointer to the UIO device file
*
* gpio_ptr pointer to mmap device in user space
* @param gpio_ptr pointer to mmap device in user space
*
* @return None.
*
* @note None.
*
******************************************************************************/
*******************************************************************************/
int PiLC2AxiGpioInit(char *uiod, void **axigpio_ptr){
unsigned int fd;
......@@ -108,20 +101,19 @@ int PiLC2AxiGpioInit(char *uiod, void **axigpio_ptr){
}
/*****************************************************************************/
/******************************************************************************/
/**
*
* Interrupt enable function for the axi gpio which is triggered by the BRAM
* data count.
*
*
* @param axi_gpio_base is the base address of the axi gpio.
*
* @return None.
*
* @note None.
*
******************************************************************************/
*******************************************************************************/
void PiLC2AxiGpioIntEn(void *axi_gpio_base){
unsigned int global_int_en_mask = 0x80000000;
unsigned int int_en_mask = 0x1;
......@@ -132,7 +124,7 @@ void PiLC2AxiGpioIntEn(void *axi_gpio_base){
}
/*****************************************************************************/
/******************************************************************************/
/**
*
* Interrupt disable function for the axi gpio which is triggered by the BRAM
......@@ -145,7 +137,7 @@ void PiLC2AxiGpioIntEn(void *axi_gpio_base){
*
* @note None.
*
******************************************************************************/
*******************************************************************************/
void PiLC2AxiGpioIntDis(void *axi_gpio_base){
PiLC2AxiGPIOWrite(axi_gpio_base, AXI_GPIO_IER_OFFSET, 0x0);
......@@ -154,7 +146,7 @@ void PiLC2AxiGpioIntDis(void *axi_gpio_base){
}
/*****************************************************************************/
/******************************************************************************/
/**
*
* This function clears the pending interrupt bit in the device.
......@@ -166,135 +158,9 @@ void PiLC2AxiGpioIntDis(void *axi_gpio_base){
*
* @note None.
*
******************************************************************************/
*******************************************************************************/
void PiLC2AxiGpioClearInterrupt(void *axi_gpio_base){
int interrupt_mask = 0x01;
PiLC2AxiGPIOWrite(axi_gpio_base, AXI_GPIO_ISR_OFFSET, interrupt_mask);
}
/*****************************************************************************/
/**
*
* Test function for the axi timer interrupt.
*
*
* @param fd the file discriptor to axi timer UIO device.
*
* timer_ptr pointer to axi timer base address.
*
* @return None.
*
* @note None.
*
******************************************************************************/
/*void PiLC2AxiGpioWaitInterrupt(int fd, void *axi_gpio_ptr)
{
int pending = 0;
int reenable = 1;
static int sum = 0;
int axi_gpio_interrupt;
// block on the file waiting for an interrupt
read(fd, (void *)&pending, sizeof(int));
//printf("writefds: %d\n", sfds.fd_array);
//printf("exceptfds: %d\n", fd);
axi_gpio_interrupt = PiLC2AxiGPIORead(axi_gpio_ptr,
AXI_GPIO_GPIO1_DATA_OFFSET);
if (axi_gpio_interrupt != 0x0){
if(axi_gpio_interrupt == 0x3){
printf("BRAM overflow: %d \n", sum++);
printf("BRAM data count: %d\n", PiLC2BRAMControllerRBRAMCount());
}
PiLC2BRAMControllerDisWBRAM();
PiLC2BRAMControllerResetBRAMcount();
PiLC2BRAMControllerEnWBRAM();
}
// Clear the pending interrupt of the devie
PiLC2AxiGpioClearInterrupt(axi_gpio_ptr);
// re-enable the interrupt in the interrupt controller thru the
// the UIO subsystem
write(fd, (void *)&reenable, sizeof(int));
}*/
/*****************************************************************************/
/**
*
* Test function for the axi timer interrupt.
*
*
* @param fd the file discriptor to axi timer UIO device.
*
* timer_ptr pointer to axi timer base address.
*
* @return None.
*
* @note None.
*
******************************************************************************/
/*
void PiLC2AxiGpioWaitInterrupt(int fd, void *axi_gpio_ptr, void *cdma_ptr)
{
int pending = 0;
int reenable = 1;
int axi_gpio_interrupt;
int bram_data_count;
// block on the file waiting for an interrupt
read(fd, (void *)&pending, sizeof(int));
axi_gpio_interrupt = PiLC2AxiGPIORead(axi_gpio_ptr,
AXI_GPIO_GPIO1_DATA_OFFSET);
PiLC2BRAMControllerDisWBRAM();
if (axi_gpio_interrupt != 0x0){
if(axi_gpio_interrupt == 0x1){
//printf("BRAM half full: %d \n", sum++);
bram_data_count = PiLC2BRAMControllerRBRAMCount();
}
if(axi_gpio_interrupt == 0x3){
printf("BRAM data count: %d\n", PiLC2BRAMControllerRBRAMCount());
}
while(PiLC2BRAMControllerGetStatus()!= 0x2);
PiLC2CDMAWrite(cdma_ptr, CDMA_DESTINATION_ADDRESS_OFFSET,
PS_RAM_DESTIONATION_ADDRESS+sum_data_sets*4);
PiLC2CDMAWrite(cdma_ptr, CDMA_BYTE_TO_TRANSFER_OFFSET,
bram_data_count*4);
dma_sync(cdma_ptr);
memdump_sorted_error(ps_mem_dest_base_addr+sum_data_sets, bram_data_count);
sum_data_sets = sum_data_sets + bram_data_count;
PiLC2BRAMControllerResetBRAMcount();
PiLC2BRAMControllerEnWBRAM();
}
// Clear the pending interrupt of the devie
PiLC2AxiGpioClearInterrupt(axi_gpio_ptr);
// re-enable the interrupt in the interrupt controller thru the
// the UIO subsystem
write(fd, (void *)&reenable, sizeof(int));
}*/
......@@ -11,8 +11,6 @@
/***************************** Include Files *********************************/
#include "pilc2_axi_timer.h"
//#include "pilc2_register_func.h"
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
......@@ -27,10 +25,8 @@
*
*
* @param timer_base is the base address of the axi timer.
*
* offset is the register offset where value will be written.
*
* value the 32 bit value to be written at specified address.
* @param offset is the register offset where value will be written.
* @param value the 32 bit value to be written at specified address.
*
* @return None.
*
......@@ -51,8 +47,7 @@ void PiLC2TimerWrite(void *timer_base, unsigned int offset, unsigned int value)
*
*
* @param timer_base is the base address of the axi timer.
*
* offset is the register offset where value will be read.
* @param offset is the register offset where value will be read.
*
* @return The value of the specified register.
*
......@@ -72,8 +67,7 @@ unsigned int PiLC2TimerRead(void *timer_base, unsigned int offset)
*
*
* @param fd the file discriptor to axi timer UIO device.
*
* timer_ptr pointer to axi timer base address.
* @param timer_ptr pointer to axi timer base address.
*
* @return None.
*
......@@ -113,8 +107,7 @@ void PiLC2TimerWaitInterruptTest(int fd, void *timer_ptr)
*
*
* @param uiod pointer to the UIO device file
*
* timer_ptr pointer to mmap device in user space
* @param timer_ptr pointer to mmap device in user space
*
* @return None.
*
......@@ -174,8 +167,7 @@ void PiLC2TimerClearInterrupt(void *timer_base){
*
*
* @param timer_base is the base address of the axi timer.
*
* value auto relaod value for the timer
* @param value auto relaod value for the timer
*
* @return None.
*
......@@ -196,8 +188,7 @@ void PiLC2TimerSetReloadValue(void *timer_base, unsigned int value){
*
*
* @param timer_base is the base address of the axi timer.
*
* config value to be written in the config register
* @param config value to be written in the config register
*
* @return None.
*
......
/******************************************************************************/
/**
*
* @file pilc_IO_GPIO.h
*
* This file contains the functions declariation for the PiLC axi timer.
*
*******************************************************************************/
#ifndef PILC2_AXI_TIMER_H
#define PILC2_AXI_TIMER_H
/*************************** Constant Definitions *****************************/
#define TMR_MAP_SIZE 0x1000
#define TMR_TCSRO_OFFSET 0x0
#define TMR_TLR0_OFFSET 0x4
#define TMR_TCR_OFFSET 0x8
/*TIMING_INTERVAL = (TLRx + 2) * AXI_CLOCK_PERIOD*/
//#define TMR_L_VALUE 0x0BEBC1FE //1 s
#define TMR_L_VALUE 0x30D3E //1 ms
#define PILC2_TMR_INT_EN 0x40
......@@ -17,6 +23,8 @@
char *uiod_axitimer;
/*************************** Function Prototypes ******************************/
int PiLC2TimerInit(char *uiod, void **timer_ptr);
unsigned int PiLC2TimerRead(void *timer_base, unsigned int offset);
void PiLC2TimerWrite(void *timer_base, unsigned int offset,
......@@ -30,77 +38,4 @@ void PiLC2TimerClearInterrupt(void *timer_base);
#endif
/* Initalize the timer and get the file discriptor*/
//timer_fd = PiLC2TimerInit(uiod,&timer_ptr);
/* clear pending interrupts in case of unexpected programm termination*/
//write(timer_fd, (void *)&reenable, sizeof(int));
/* set timer reload value */
//PiLC2TimerSetReloadValue(timer_ptr, TMR_L_VALUE);
/* config timer with interrupt enabled */
//PiLC2TimerConfig(timer_ptr, PILC2_TMR_INT_EN|PILC2_TMR_AUTO_RELOAD);
/* enable timer */
//PiLC2TimerEnable(timer_ptr);
//void PiLC2TimerWaitInterrupt(int fd, void *timer_ptr, void *cdma_ptr)
//{
// int pending = 0;
// int reenable = 1;
// static int current_ram_address = 0;
// int bram_data_count;
//
// /* block on the file waiting for an interrupt */
// read(fd, (void *)&pending, sizeof(int));
//
// /* disable the BRAM and store incoming data into the FIFO*/
// PiLC2BRAMControllerDisWBRAM();
//
// /* wait until current records has been written into BRAM */
// while(PiLC2BRAMControllerGetStatus()!= 0x2);
//
// /**/
// bram_data_count = PiLC2BRAMControllerRBRAMCount();
//
// if(bram_data_count > 0){
// if((current_ram_address*4 + bram_data_count*4 ) > MAX_MEMORY){
//
// current_ram_address = 0;
// }
//
// PiLC2CDMAWrite(cdma_ptr, CDMA_DESTINATION_ADDRESS_OFFSET,
// PS_RAM_DESTIONATION_ADDRESS+current_ram_address*4);
//
// PiLC2CDMAWrite(cdma_ptr, CDMA_BYTE_TO_TRANSFER_OFFSET,
// bram_data_count*4);
//
// dma_sync(cdma_ptr);
//
// memdump_sorted_error(ps_mem_dest_base_addr+current_ram_address,
// bram_data_count);
//
// current_ram_address = current_ram_address + bram_data_count;
// sum_data_sets = sum_data_sets + bram_data_count;
//
// PiLC2BRAMControllerResetBRAMcount();
//
//
// }
//
// PiLC2BRAMControllerEnWBRAM();
//
// if (!STOP){
//
// /* Clear the pending interrupt of the devie */
// PiLC2TimerClearInterrupt(timer_ptr);
//
// /* re-enable the interrupt in the interrupt controller thru the
// the UIO subsystem */
// write(fd, (void *)&reenable, sizeof(int));
// }
//}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment