diff --git a/Examples/ADC/QT_src/ADC b/Examples/ADC/QT_src/ADC deleted file mode 100755 index 40ef590..0000000 Binary files a/Examples/ADC/QT_src/ADC and /dev/null differ diff --git a/Examples/ADC/QT_src/ADCw.cpp b/Examples/ADC/QT_src/ADCw.cpp deleted file mode 100644 index 07015b5..0000000 --- a/Examples/ADC/QT_src/ADCw.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include "ADCw.h" - -ADCw::ADCw() -{ - ADCBuffer = jz_adc_init(); - /*************************Clean FPGA RAM memory****************************/ - for (int i = 0; i < 512; i++) //RAMB16_s9_s9 has 2048 bytes 8-bit - { - ADCBuffer[i] = 0x00000000; //Clean 4 register by cicle - } -} - -void ADCw::testADC() -{ - /****************Configure ADC register on FPGA RAM memory*****************/ - jz_adc_config(ADCBuffer, 0x00, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_SPI_CLKDIV); - usleep (1000); - jz_adc_config(ADCBuffer, 0x00, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_FAST_CONV); - usleep (1000); - printf("\nADC in Fast Convertion Mode (10us) and Fs=9.8KHz (Min)\n"); - - int LENB = 0xFE; // 254 read/cmd - - /******************************* TEST 1 ***********************************/ - printf("\nINIT TEST1: Autoselft {(Vref+) - (Vref-)}/2 -> Return 0x0200 \n"); - jz_adc_config(ADCBuffer, 0x00, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_AUTOSELFT_1); - printf("[%08X]", ADCBuffer[0]);fflush (stdout); - usleep (1000); - jz_adc_config(ADCBuffer, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_READ_AUTOSELFT_1); - printf("[%08X]", ADCBuffer[0]);fflush (stdout); - while(jz_adc_check_buffer(ADCBuffer)){usleep (10);} - for(int i=1; i< 512; i++) - printf("[%08X]", ADCBuffer[i]); - fflush (stdout); - - /******************************* TEST 2 ***********************************/ - printf("\n\nINIT TEST2: Autoselft (Vref-) -> Return 0x0000 \n"); - jz_adc_config(ADCBuffer, 0x00, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_AUTOSELFT_2); - printf("[%08X]", ADCBuffer[0]);fflush (stdout); - usleep (1000); - jz_adc_config(ADCBuffer, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_READ_AUTOSELFT_2); - printf("[%08X]", ADCBuffer[0]);fflush (stdout); - while(jz_adc_check_buffer(ADCBuffer)){usleep (10);} - for(int i=1; i< 512; i++) - printf("[%08X]", ADCBuffer[i]); - fflush (stdout); - - /******************************* TEST 3 ***********************************/ - printf("\n\nINIT TEST3: Autoselft (Vref+) -> Return 0x03FF \n"); - jz_adc_config(ADCBuffer, 0x00, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_AUTOSELFT_3); - printf("[%08X]", ADCBuffer[0]);fflush (stdout); - usleep (1000); - jz_adc_config(ADCBuffer, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_READ_AUTOSELFT_3); - printf("[%08X]", ADCBuffer[0]);fflush (stdout); - while(jz_adc_check_buffer(ADCBuffer)){usleep (10);} - for(int i=1; i< 512; i++) - printf("[%08X]", ADCBuffer[i]); - fflush (stdout); - - printf("\n\nTESTS complete\n"); -} - -void ADCw::powerDownADC() -{ - jz_adc_config(ADCBuffer, 0x00, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_POWER_DOWN); - printf("\nADC in Power Down Mode \n"); -} - -JZ_REG* ADCw::takeSamplesADC(int LENB, uchar CLKDIV, int CHANNEL) -{ - jz_adc_config(ADCBuffer, 0x00, CLKDIV, ADC_CMD_SET_CHANNEL0+CHANNEL); - usleep (1000); - jz_adc_config(ADCBuffer, LENB, CLKDIV, ADC_CMD_READ_CHANNEL0+CHANNEL); - //while(jz_adc_check_buffer(ADCBuffer)){usleep (400000);printf("[%08X]", ADCBuffer[0]);fflush (stdout);} - while(jz_adc_check_buffer(ADCBuffer)){usleep (10);} - return ADCBuffer; -} diff --git a/Examples/ADC/QT_src/ADCw.h b/Examples/ADC/QT_src/ADCw.h deleted file mode 100644 index 845e45e..0000000 --- a/Examples/ADC/QT_src/ADCw.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef ADCW_H -#define ADCW_H - -#include "jz_adc_peripheral.h" -#include -#include - -class ADCw -{ -public: - ADCw(); - ~ADCw(){}; - - void testADC(); - void powerDownADC(); - JZ_REG * takeSamplesADC(int LENB, uchar CLKDIV, int CHANNEL); -private: - JZ_REG * ADCBuffer; -}; - -#endif // ADCW_H diff --git a/Examples/ADC/QT_src/mainwindow.cpp b/Examples/ADC/QT_src/mainwindow.cpp deleted file mode 100755 index 5afe798..0000000 --- a/Examples/ADC/QT_src/mainwindow.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" -#include - -#include -#include - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent), ui(new Ui::MainWindow) -{ - ui->setupUi(this); - connect(this,SIGNAL(refresh()),ui->Graph, SLOT(repaint())); - ui->Graph->setPointsPerPlot(300); - ui->Graph->setVoltsPerDiv(102); - - timer1 = new QTimer(this); - timer1->start(50); - connect(timer1, SIGNAL(timeout()), this, SLOT(updateGraph())); - - ADC1 = new ADCw; - ADC1->testADC(); - printf("\nTaking 250 samples each 50ms from Channel 0 at Fs=9.8KHz \n"); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - -void MainWindow::updateGraph() -{ - JZ_REG * dataADC =ADC1->takeSamplesADC(300, 0x08, 1); - int tempD; - - for(int i=1; i< 300/2+1; i++) - { - //printf("[%08X]",dataADC[i]); - tempD = dataADC[i]&0xFFFF; - ui->Graph->addPoint(tempD); - tempD = dataADC[i]>>16; - ui->Graph->addPoint(tempD); - } - //printf("\n \n *************************************************************** \n\n"); - //fflush (stdout); - /*for(int i = 0; i<100;i++) - ui->Graph->addPoint(20*sin(6.2832*i/100)+20);*/ - - emit refresh(); -} diff --git a/Examples/ADC/Scope-QT-src/ADC b/Examples/ADC/Scope-QT-src/ADC new file mode 100755 index 0000000..96016a3 Binary files /dev/null and b/Examples/ADC/Scope-QT-src/ADC differ diff --git a/Examples/ADC/QT_src/ADC1.pro b/Examples/ADC/Scope-QT-src/ADC1.pro similarity index 100% rename from Examples/ADC/QT_src/ADC1.pro rename to Examples/ADC/Scope-QT-src/ADC1.pro diff --git a/Examples/ADC/QT_src/ADC1.pro.user b/Examples/ADC/Scope-QT-src/ADC1.pro.user similarity index 100% rename from Examples/ADC/QT_src/ADC1.pro.user rename to Examples/ADC/Scope-QT-src/ADC1.pro.user diff --git a/Examples/ADC/Scope-QT-src/ADCw.cpp b/Examples/ADC/Scope-QT-src/ADCw.cpp new file mode 100644 index 0000000..a295184 --- /dev/null +++ b/Examples/ADC/Scope-QT-src/ADCw.cpp @@ -0,0 +1,76 @@ +#include "ADCw.h" + +ADCw::ADCw() +{ + BUFFER_OFFSET = 8; + ADC_SPI_CLKDIV=ADC_SPI_CLKDIV_MAX; //Set clock to minimum speed + BUFFER_LEN=10; + + ADCBuffer = jz_adc_init(); + + //Clean FPGA RAM memory + for (int i = 0; i < 512; i++) //RAMB16_s9_s9 has 2048 bytes 8-bit + { + ADCBuffer[i] = 0x00000000; //Clean 4 register by cicle + } + + adcConfig(ADC_CMD_SET_SPI_CLKDIV); + adcConfig(ADC_CMD_SET_FAST_CONV); + printf("\nADC in Fast Convertion Mode (10us) and Fs=9.8KHz (Min)\n"); +} + +void ADCw::testADC() +{ + /******************************* TEST 1 ***********************************/ + printf("\nINIT TEST1: Autoselft {(Vref+) - (Vref-)}/2 -> Return 0x0200 \n"); + adcConfig(ADC_CMD_SET_AUTOSELFT_1); + adcConfig(ADC_CMD_READ_AUTOSELFT_1); + while(adcCheckBufferFull())usleep (10); + for(int i=BUFFER_OFFSET; i< BUFFER_LEN/2+BUFFER_OFFSET; i++) + printf("[%08X]", ADCBuffer[i]); + fflush (stdout); + + /******************************* TEST 2 ***********************************/ + printf("\n\nINIT TEST2: Autoselft (Vref-) -> Return 0x0000 \n"); + adcConfig(ADC_CMD_SET_AUTOSELFT_2); + adcConfig(ADC_CMD_READ_AUTOSELFT_2); + while(adcCheckBufferFull())usleep (10); + for(int i=BUFFER_OFFSET; i< BUFFER_LEN/2+BUFFER_OFFSET; i++) + printf("[%08X]", ADCBuffer[i]); + fflush (stdout); + + /******************************* TEST 3 ***********************************/ + printf("\n\nINIT TEST3: Autoselft (Vref+) -> Return 0x03FF \n"); + adcConfig(ADC_CMD_SET_AUTOSELFT_3); + adcConfig(ADC_CMD_READ_AUTOSELFT_3); + for(int i=BUFFER_OFFSET; i< BUFFER_LEN/2+BUFFER_OFFSET; i++) + printf("[%08X]", ADCBuffer[i]); + fflush (stdout); + + printf("\n\nTESTS complete\n"); +} + +void ADCw::powerDownADC() +{ + adcConfig(ADC_CMD_SET_POWER_DOWN); + printf("\nADC in Power Down Mode \n"); +} + +JZ_REG* ADCw::takeSamplesADC(int CHANNEL) +{ + adcConfig(ADC_CMD_SET_CHANNEL0+CHANNEL); + adcConfig(ADC_CMD_READ_CHANNEL0+CHANNEL); + while(adcCheckBufferFull())usleep (10); + return (JZ_REG*)(ADCBuffer+BUFFER_OFFSET); +} + +void ADCw::adcConfig(uchar CMD) +{ + ADCBuffer[0] = ((BUFFER_LEN+(BUFFER_OFFSET-1)*2) << 16) + (ADC_SPI_CLKDIV<<8) + CMD; + usleep (100); +} + +int ADCw::adcCheckBufferFull() +{ + return ADCBuffer[0]&0x20; +} diff --git a/Examples/ADC/Scope-QT-src/ADCw.h b/Examples/ADC/Scope-QT-src/ADCw.h new file mode 100644 index 0000000..83eedb7 --- /dev/null +++ b/Examples/ADC/Scope-QT-src/ADCw.h @@ -0,0 +1,30 @@ +#ifndef ADCW_H +#define ADCW_H + +#include "jz_adc_peripheral.h" +#include +#include + +class ADCw +{ +public: + ADCw(); + ~ADCw(){} + + void testADC(); + void powerDownADC(); + JZ_REG * takeSamplesADC(int CHANNEL); + void setClockDiv(uchar value){ ADC_SPI_CLKDIV = value;} + void setBufferLen(int value){ BUFFER_LEN = value;} + +private: + void adcConfig(uchar CMD); + int adcCheckBufferFull(); + + JZ_REG * ADCBuffer; + uchar ADC_SPI_CLKDIV; + int BUFFER_LEN; + int BUFFER_OFFSET; +}; + +#endif // ADCW_H diff --git a/Examples/ADC/QT_src/Makefile b/Examples/ADC/Scope-QT-src/Makefile similarity index 99% rename from Examples/ADC/QT_src/Makefile rename to Examples/ADC/Scope-QT-src/Makefile index dd3827f..b624c46 100644 --- a/Examples/ADC/QT_src/Makefile +++ b/Examples/ADC/Scope-QT-src/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: ADC -# Generated by qmake (2.01a) (Qt 4.6.2) on: Wed Apr 7 21:11:41 2010 +# Generated by qmake (2.01a) (Qt 4.6.2) on: Fri Apr 9 10:33:37 2010 # Project: ADC1.pro # Template: app # Command: /home/juan64bits/ebd/ECB/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/bin/qmake -spec ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/qws/linux-openwrt-g++ -unix -o Makefile ADC1.pro diff --git a/Examples/ADC/QT_src/jz47xx_gpio.cpp b/Examples/ADC/Scope-QT-src/jz47xx_gpio.cpp similarity index 100% rename from Examples/ADC/QT_src/jz47xx_gpio.cpp rename to Examples/ADC/Scope-QT-src/jz47xx_gpio.cpp diff --git a/Examples/ADC/QT_src/jz47xx_gpio.h b/Examples/ADC/Scope-QT-src/jz47xx_gpio.h similarity index 100% rename from Examples/ADC/QT_src/jz47xx_gpio.h rename to Examples/ADC/Scope-QT-src/jz47xx_gpio.h diff --git a/Examples/ADC/QT_src/jz47xx_mmap.cpp b/Examples/ADC/Scope-QT-src/jz47xx_mmap.cpp similarity index 100% rename from Examples/ADC/QT_src/jz47xx_mmap.cpp rename to Examples/ADC/Scope-QT-src/jz47xx_mmap.cpp diff --git a/Examples/ADC/QT_src/jz47xx_mmap.h b/Examples/ADC/Scope-QT-src/jz47xx_mmap.h similarity index 100% rename from Examples/ADC/QT_src/jz47xx_mmap.h rename to Examples/ADC/Scope-QT-src/jz47xx_mmap.h diff --git a/Examples/ADC/QT_src/jz_adc_peripheral.cpp b/Examples/ADC/Scope-QT-src/jz_adc_peripheral.cpp similarity index 87% rename from Examples/ADC/QT_src/jz_adc_peripheral.cpp rename to Examples/ADC/Scope-QT-src/jz_adc_peripheral.cpp index 9390a3a..091f350 100644 --- a/Examples/ADC/QT_src/jz_adc_peripheral.cpp +++ b/Examples/ADC/Scope-QT-src/jz_adc_peripheral.cpp @@ -45,15 +45,3 @@ jz_adc_init() return virt_addr; } - -void -jz_adc_config(JZ_REG * addr, int BUFFER, uchar CLK_DIV, uchar CMD) -{ - addr[0] = (BUFFER << 16) + (CLK_DIV<<8) + CMD; -} - -int -jz_adc_check_buffer(JZ_REG * addr) -{ - return addr[0]&0x00000010; -} diff --git a/Examples/ADC/QT_src/jz_adc_peripheral.h b/Examples/ADC/Scope-QT-src/jz_adc_peripheral.h similarity index 91% rename from Examples/ADC/QT_src/jz_adc_peripheral.h rename to Examples/ADC/Scope-QT-src/jz_adc_peripheral.h index d92bff4..9617df2 100644 --- a/Examples/ADC/QT_src/jz_adc_peripheral.h +++ b/Examples/ADC/Scope-QT-src/jz_adc_peripheral.h @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "jz47xx_gpio.h" #define ADC_CMD_NONE 0x00 /* Nothing to do */ -#define ADC_CMD_SET_SPI_CLKDIV 0x90 /* Set clock divider for ADC sclk */ +#define ADC_CMD_SET_SPI_CLKDIV 0x00 /* Set clock divider for ADC sclk */ #define ADC_CMD_SET_CHANNEL0 0x30 /* Set channel 0 */ #define ADC_CMD_READ_CHANNEL0 0x20 /* Read channel 0 */ @@ -54,7 +54,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #define ADC_CMD_SET_FAST_CONV 0X39 /* Initialize ADC Fast Convertion(<10us)*/ -#define ADC_CMD_SET_LOW_CONV 0X3A /* Initialize ADC Fast Convertion(<40us)*/ +#define ADC_CMD_SET_LOW_CONV 0X3A /* Initialize ADC Slow Convertion(<40us)*/ #define ADC_CMD_SET_AUTOSELFT_1 0x3B /* Set Autoselft ADC {(Vref+)-(Vref-)}/2*/ #define ADC_CMD_READ_AUTOSELFT_1 0x2B /* Read Autoselft ADC 1 (0x0200) */ @@ -68,7 +68,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #define ADC_SPI_CLKDIV_MIN 0x08 /* 50/(2*9) -> 2.78MHz (MAX=2.8MHz) */ #define ADC_SPI_CLKDIV_MAX 0xFF /* 50/(2*256) -> 97.65KHz */ -#define ADC_MAX_BUFFER 0x3FE/* 1022 reads/commands */ +#define ADC_MAX_BUFFER 0x3F0/* 1008 reads/commands */ #define CS2_PORT JZ_GPIO_PORT_B #define CS2_PIN 26 @@ -77,8 +77,4 @@ typedef unsigned char uchar; JZ_REG *jz_adc_init(); -void jz_adc_config(JZ_REG * addr, int BUFFER, uchar CLK_DIV, uchar CMD); - -int jz_adc_check_buffer(JZ_REG * addr); - #endif diff --git a/Examples/ADC/QT_src/main.cpp b/Examples/ADC/Scope-QT-src/main.cpp similarity index 100% rename from Examples/ADC/QT_src/main.cpp rename to Examples/ADC/Scope-QT-src/main.cpp diff --git a/Examples/ADC/Scope-QT-src/mainwindow.cpp b/Examples/ADC/Scope-QT-src/mainwindow.cpp new file mode 100755 index 0000000..0c6da83 --- /dev/null +++ b/Examples/ADC/Scope-QT-src/mainwindow.cpp @@ -0,0 +1,63 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" +#include + +#include +#include + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent), ui(new Ui::MainWindow) +{ + ui->setupUi(this); + connect(this,SIGNAL(refresh()),ui->Graph, SLOT(repaint())); + ui->Graph->setPointsPerPlot(120); + ui->Graph->setVoltsPerDiv(205); + + timer1 = new QTimer(this); + timer1->start(50); + connect(timer1, SIGNAL(timeout()), this, SLOT(updateGraph())); + + CHANNEL = 1; + ADC1 = new ADCw; + ADC1->testADC(); + ADC1->setBufferLen(120); + ADC1->setClockDiv(ADC_SPI_CLKDIV_MAX); //Maximun speed + printf("\nTaking 300 samples each 50ms from Channel 0,1 at Fs=99KHz \n"); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::updateGraph() +{ + JZ_REG * dataADC; + + int tempD; + + //CHANNEL 0 + dataADC=ADC1->takeSamplesADC(0); + for(int i=0; i< 120/2; i++) + { + //printf("[%08X]",dataADC[i]); + tempD = dataADC[i]&0xFFFF; + ui->Graph->addPoint1(tempD+0x3ff); + tempD = dataADC[i]>>16; + ui->Graph->addPoint1(tempD+0x3ff); + } + CHANNEL = 1; + + //CHANNEL 1 + dataADC=ADC1->takeSamplesADC(1); + for(int i=0; i< 120/2; i++) + { + //printf("[%08X]",dataADC[i]); + tempD = dataADC[i]&0xFFFF; + ui->Graph->addPoint2(tempD); + tempD = dataADC[i]>>16; + ui->Graph->addPoint2(tempD); + } + + emit refresh(); +} diff --git a/Examples/ADC/QT_src/mainwindow.h b/Examples/ADC/Scope-QT-src/mainwindow.h similarity index 96% rename from Examples/ADC/QT_src/mainwindow.h rename to Examples/ADC/Scope-QT-src/mainwindow.h index f87f85c..f06f4ba 100755 --- a/Examples/ADC/QT_src/mainwindow.h +++ b/Examples/ADC/Scope-QT-src/mainwindow.h @@ -27,6 +27,7 @@ private: Ui::MainWindow *ui; QTimer *timer1; ADCw *ADC1; + bool CHANNEL; }; #endif // MAINWINDOW_H diff --git a/Examples/ADC/QT_src/mainwindow.ui b/Examples/ADC/Scope-QT-src/mainwindow.ui similarity index 100% rename from Examples/ADC/QT_src/mainwindow.ui rename to Examples/ADC/Scope-QT-src/mainwindow.ui diff --git a/Examples/ADC/QT_src/signaldisplay.cpp b/Examples/ADC/Scope-QT-src/signaldisplay.cpp similarity index 51% rename from Examples/ADC/QT_src/signaldisplay.cpp rename to Examples/ADC/Scope-QT-src/signaldisplay.cpp index d50868f..8bcd53f 100755 --- a/Examples/ADC/QT_src/signaldisplay.cpp +++ b/Examples/ADC/Scope-QT-src/signaldisplay.cpp @@ -4,7 +4,8 @@ SignalDisplay::SignalDisplay(QWidget *&parent):QWidget(parent) { - colorTrace = Qt::black; + colorTrace1 = Qt::blue; + colorTrace2 = Qt::red; secsPerDiv = 1.0/600.0; voltsPerDiv = 20; setPointsPerPlot(10); @@ -13,8 +14,9 @@ SignalDisplay::SignalDisplay(QWidget *&parent):QWidget(parent) void SignalDisplay::setPointsPerPlot(int value) { pointsPerPlot = value; - waves = new QPoint[pointsPerPlot]; - secsIdx = 0; + wave1 = new QPoint[pointsPerPlot]; + wave2 = new QPoint[pointsPerPlot]; + secsIdx1 = 0; secsIdx2 = 0; } void SignalDisplay::drawGrid(QPainter &p, QColor colorGrid, int x, int y, int w, int h, int nx, int ny){ @@ -35,26 +37,25 @@ void SignalDisplay::paintEvent(QPaintEvent *event){ ox = w; oy = h; painter.fillRect(0,0,w,h,Qt::white); - //painter.setPen(Qt::white); - //painter.drawLine(secsIdx*w/10/60.0/pointsPerPlot/secsPerDiv,0, \ - // secsIdx*w/10/60.0/pointsPerPlot/secsPerDiv,h); drawGrid(painter, Qt::lightGray,0,0,w,h,5, 10); - - /*for(int i = 0; i < pointsPerPlot; i++) - { - painter.fillRect(waves[i].x()-w/pointsPerPlot/2,waves[i].y(), \ - w/pointsPerPlot,h-waves[i].y(), Qt::blue); - }*/ - painter.setPen(colorTrace); - painter.drawPolyline(waves,pointsPerPlot); - + painter.setPen(colorTrace1); + painter.drawPolyline(wave1,pointsPerPlot); + painter.setPen(colorTrace2); + painter.drawPolyline(wave2,pointsPerPlot); } -void SignalDisplay::addPoint( int value1) +void SignalDisplay::addPoint1( int value) { - waves[secsIdx] = QPoint(secsIdx*w/10/60.0/pointsPerPlot/secsPerDiv+w/(2*pointsPerPlot), \ - oy-value1*h/voltsPerDiv/10); - secsIdx = (secsIdx+1) % pointsPerPlot; + wave1[secsIdx1] = QPoint(secsIdx1*w/10/60.0/pointsPerPlot/secsPerDiv+w/(2*pointsPerPlot), \ + oy-value*h/voltsPerDiv/10); + secsIdx1 = (secsIdx1+1) % pointsPerPlot; +} + +void SignalDisplay::addPoint2( int value) +{ + wave2[secsIdx2] = QPoint(secsIdx2*w/10/60.0/pointsPerPlot/secsPerDiv+w/(2*pointsPerPlot), \ + oy-value*h/voltsPerDiv/10); + secsIdx2 = (secsIdx2+1) % pointsPerPlot; } //EOF diff --git a/Examples/ADC/QT_src/signaldisplay.h b/Examples/ADC/Scope-QT-src/signaldisplay.h similarity index 71% rename from Examples/ADC/QT_src/signaldisplay.h rename to Examples/ADC/Scope-QT-src/signaldisplay.h index 8229c1c..4b87a86 100755 --- a/Examples/ADC/QT_src/signaldisplay.h +++ b/Examples/ADC/Scope-QT-src/signaldisplay.h @@ -9,21 +9,23 @@ class SignalDisplay : public QWidget { public: SignalDisplay(QWidget *&parent); - void addPoint( int value1); + void addPoint1( int value); + void addPoint2( int value); void setSecsPerDiv( float value ){ secsPerDiv = fabs(value);} void setVoltsPerDiv( float value ){ voltsPerDiv = fabs(value);} float getSecsPerDiv(){ return secsPerDiv; } void setPointsPerPlot(int value); - void setColorTrace(QColor color){colorTrace=color;}; + void setColorTrace1(QColor color){colorTrace1=color;} + void setColorTrace2(QColor color){colorTrace2=color;} private: void paintEvent(QPaintEvent *event); void drawGrid(QPainter &p, QColor colorGrid, int x, int y, int w, int h, int nx, int ny); - QPoint *waves; + QPoint *wave1, *wave2; float voltsPerDiv; float secsPerDiv; - QColor colorTrace; - int secsIdx; + QColor colorTrace1,colorTrace2; + int secsIdx1, secsIdx2; int w, h, ox, oy; int pointsPerPlot; }; diff --git a/Examples/ADC/logic/ADC.bit b/Examples/ADC/logic/ADC.bit new file mode 100644 index 0000000..b984bf9 Binary files /dev/null and b/Examples/ADC/logic/ADC.bit differ diff --git a/Examples/ADC/logic/ADC.v b/Examples/ADC/logic/ADC.v index 2956edb..0871f7f 100644 --- a/Examples/ADC/logic/ADC.v +++ b/Examples/ADC/logic/ADC.v @@ -77,14 +77,14 @@ module ADC(clk, sram_data, addr, nwe, ncs, noe, reset, led, ADC_EOC, wire [7:0] rdBus0, rdBus1, rdBus2, rdBus3; assign csN = buffer_addr[12]? (buffer_addr[11]? 4'b1000: - 4'b0100) + 4'b0100) : (buffer_addr[11]? 4'b0010: - 4'b0001); + 4'b0001); assign rdBus = buffer_addr[12]? (buffer_addr[11]? rdBus3: - rdBus2) + rdBus2) : (buffer_addr[11]? rdBus1: - rdBus0); + rdBus0); // Peripheral instantiation ADC_peripheral P1( diff --git a/Examples/ADC/logic/ADC_peripheral.v b/Examples/ADC/logic/ADC_peripheral.v index b28dd13..185ae3a 100644 --- a/Examples/ADC/logic/ADC_peripheral.v +++ b/Examples/ADC/logic/ADC_peripheral.v @@ -47,12 +47,12 @@ module ADC_peripheral( clk, reset, cs, ADC_EOC, ADC_CS, ADC_CSTART, .DOB(), // Port B 8-bit Data Output .DOPA(), // Port A 1-bit Parity Output .DOPB(), // Port B 1-bit Parity Output - .ADDRA(addr), // Port A 11-bit Address Input - .ADDRB(addr2), // Port B 11-bit Address Input + .ADDRA(addr[10:0]), // Port A 11-bit Address Input + .ADDRB(addr2[10:0]), // Port B 11-bit Address Input .CLKA(~clk), // Port A Clock .CLKB(~clk), // Port B Clock - .DIA(wrBus), // Port A 8-bit Data Input - .DIB(wrBus2), // Port B 8-bit Data Input + .DIA(wrBus[7:0]), // Port A 8-bit Data Input + .DIB(wrBus2[7:0]), // Port B 8-bit Data Input .DIPA(1'b0), // Port A 1-bit parity Input .DIPB(1'b0), // Port-B 1-bit parity Input .ENA(1'b1), // Port A RAM Enable Input @@ -141,7 +141,7 @@ module ADC_peripheral( clk, reset, cs, ADC_EOC, ADC_CS, ADC_CSTART, /**************************************************************************/ // REGISTER BANK: Write control - always @(posedge clk) + always @(negedge clk) if(reset) {CMD_START, CMD_TYP,CMD_ADC,SIZEB,we1} <= 0; else if(we & cs) begin @@ -175,21 +175,21 @@ module ADC_peripheral( clk, reset, cs, ADC_EOC, ADC_CS, ADC_CSTART, // CONTROL always @(posedge clk) - if(reset) + if(reset) begin {w_st0, SPI_wr} <= 0; + ADC_CS <=1; + end else begin case (w_st0) 0: begin - rstStart <= 0; loadB <= 0; ADC_CS <=0; initB<=0; + rstStart <= 0; loadB <= 0; initB<=0; if(CMD_START) begin - initB<=1; + ADC_CS <=0; + SPI_wr <= 1; w_st0 <=1; end - end + end 1: begin - SPI_wr <= 1; w_st0 <=2; - end - 2: begin SPI_wr <= 0; if(!busy && ADC_EOC) begin ADC_CS <=1; @@ -198,12 +198,12 @@ module ADC_peripheral( clk, reset, cs, ADC_EOC, ADC_CS, ADC_CSTART, w_st0<= 0; end else begin - loadB <= 1; - w_st0<= 0; + initB<=1; + w_st0<= 2; end end end - + 2: begin loadB <= 1; w_st0<= 0; end endcase end diff --git a/Examples/ADC/logic/Makefile b/Examples/ADC/logic/Makefile index af4144b..6c1d966 100644 --- a/Examples/ADC/logic/Makefile +++ b/Examples/ADC/logic/Makefile @@ -18,7 +18,6 @@ remake: clean-build all clean: rm -f *~ */*~ a.out *.log *.key *.edf *.ps trace.dat - rm *.bit clean-build: clean rm -rf build diff --git a/Examples/ADC/src/Makefile b/Examples/ADC/src/Makefile deleted file mode 100644 index a4ad1eb..0000000 --- a/Examples/ADC/src/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -CC = mipsel-openwrt-linux-gcc - -all: upload - -DEBUG = -O3 -g0 - -COMMON_SOURCES = jz47xx_gpio.c jz47xx_mmap.c jz_adc_peripheral.c - -H_SOURCES = jz47xx_gpio.h jz47xx_mmap.h jz_adc_peripheral.h - -INCLUDE = -I. - -WARNINGS= -Wcast-align -Wpacked -Wpadded -Wall - -CCFLAGS = ${INCLUDE} ${DEBUG} ${WARNINGS} - -LDFLAGS = - -COMMON_OBJECTS = $(COMMON_SOURCES:.c=.o) - -NANO_IP = 192.168.254.101 - -jz_test_adc: $(COMMON_OBJECTS) - $(CC) $(LDFLAGS) $(COMMON_OBJECTS) jz_test_adc.c -o jz_test_adc - -.c.o: - $(CC) -c $(CCFLAGS) $< -o $@ - -upload: jz_test_adc - scp jz_test_adc root@$(NANO_IP):/root/ - -clean: - rm -f *.o jz_test_adc ${EXEC} *~ - -indent: - indent -bad -bap -nbc -bl -nce -i2 --no-tabs --line-length120 $(COMMON_SOURCES) $(H_SOURCES) diff --git a/Examples/ADC/src/jz47xx_gpio.c b/Examples/ADC/src/jz47xx_gpio.c deleted file mode 100644 index affa85e..0000000 --- a/Examples/ADC/src/jz47xx_gpio.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - JZ47xx GPIO at userspace - - Copyright (C) 2010 Andres Calderon andres.calderon@emqbit.com - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#include -#include -#include - -#include -#include - - -#define JZ_GPIO_BASE 0x10010000 - -void -jz_gpio_as_output (JZ_PIO * pio, unsigned int o) -{ - pio->PXFUNC = (1 << (o)); - pio->PXSELC = (1 << (o)); - pio->PXDIRS = (1 << (o)); -} - -void -jz_gpio_as_input (JZ_PIO * pio, unsigned int o) -{ - pio->PXFUNC = (1 << (o)); - pio->PXSELC = (1 << (o)); - pio->PXDIRC = (1 << (o)); -} - -void -jz_gpio_set_pin (JZ_PIO * pio, unsigned int o) -{ - pio->PXDATS = (1 << (o)); -} - -void -jz_gpio_clear_pin (JZ_PIO * pio, unsigned int o) -{ - pio->PXDATC = (1 << (o)); -} - -void -jz_gpio_out (JZ_PIO * pio, unsigned int o, unsigned int val) -{ - if (val == 0) - pio->PXDATC = (1 << (o)); - else - pio->PXDATS = (1 << (o)); -} - -unsigned int -jz_gpio_get_pin (JZ_PIO * pio, unsigned int o) -{ - return (pio->PXPIN & (1 << o)) ? 1 : 0; -} - -int -jz_gpio_as_func (JZ_PIO * pio, unsigned int o, int func) -{ - switch (func) - { - case 0: - pio->PXFUNS = (1 << o); - pio->PXTRGC = (1 << o); - pio->PXSELC = (1 << o); - return 1; - - case 1: - pio->PXFUNS = (1 << o); - pio->PXTRGC = (1 << o); - pio->PXSELS = (1 << o); - return 1; - - case 2: - pio->PXFUNS = (1 << o); - pio->PXTRGS = (1 << o); - pio->PXSELC = (1 << o); - return 1; - } - return 0; -} - -JZ_PIO * -jz_gpio_map (int port) -{ - JZ_PIO *pio; - - pio = (JZ_PIO *) jz_mmap (JZ_GPIO_BASE); - pio = (JZ_PIO *) ((unsigned int) pio + port * 0x100); - - return pio; -} diff --git a/Examples/ADC/src/jz47xx_gpio.h b/Examples/ADC/src/jz47xx_gpio.h deleted file mode 100644 index d8b0113..0000000 --- a/Examples/ADC/src/jz47xx_gpio.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - JZ47xx GPIO at userspace - - Copyright (C) 2010 Andres Calderon andres.calderon@emqbit.com - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#ifndef __jz47xx_gpio_h__ -#define __jz47xx_gpio_h__ - -#define JZ_GPIO_PORT_A 0 -#define JZ_GPIO_PORT_B 1 -#define JZ_GPIO_PORT_C 2 -#define JZ_GPIO_PORT_D 3 - -typedef volatile unsigned int JZ_REG; /* Hardware register definition */ - -typedef struct _JZ_PIO -{ - JZ_REG PXPIN; /* PIN Level Register */ - JZ_REG Reserved0; - JZ_REG Reserved1; - JZ_REG Reserved2; - JZ_REG PXDAT; /* Port Data Register */ - JZ_REG PXDATS; /* Port Data Set Register */ - JZ_REG PXDATC; /* Port Data Clear Register */ - JZ_REG Reserved3; - JZ_REG PXIM; /* Interrupt Mask Register */ - JZ_REG PXIMS; /* Interrupt Mask Set Reg */ - JZ_REG PXIMC; /* Interrupt Mask Clear Reg */ - JZ_REG Reserved4; - JZ_REG PXPE; /* Pull Enable Register */ - JZ_REG PXPES; /* Pull Enable Set Reg. */ - JZ_REG PXPEC; /* Pull Enable Clear Reg. */ - JZ_REG Reserved5; - JZ_REG PXFUN; /* Function Register */ - JZ_REG PXFUNS; /* Function Set Register */ - JZ_REG PXFUNC; /* Function Clear Register */ - JZ_REG Reserved6; - JZ_REG PXSEL; /* Select Register */ - JZ_REG PXSELS; /* Select Set Register */ - JZ_REG PXSELC; /* Select Clear Register */ - JZ_REG Reserved7; - JZ_REG PXDIR; /* Direction Register */ - JZ_REG PXDIRS; /* Direction Set Register */ - JZ_REG PXDIRC; /* Direction Clear Register */ - JZ_REG Reserved8; - JZ_REG PXTRG; /* Trigger Register */ - JZ_REG PXTRGS; /* Trigger Set Register */ - JZ_REG PXTRGC; /* Trigger Set Register */ - JZ_REG Reserved9; - JZ_REG PXFLG; /* Port Flag Register */ - JZ_REG PXFLGC; /* Port Flag clear Register */ -} JZ_PIO, *PJZ_PIO; - -void jz_gpio_as_output (JZ_PIO * pio, unsigned int o); - -void jz_gpio_as_input (JZ_PIO * pio, unsigned int o); - -void jz_gpio_set_pin (JZ_PIO * pio, unsigned int o); - -void jz_gpio_clear_pin (JZ_PIO * pio, unsigned int o); - -void jz_gpio_out (JZ_PIO * pio, unsigned int o, unsigned int val); - -unsigned int jz_gpio_get_pin (JZ_PIO * pio, unsigned int o); - -int jz_gpio_as_func (JZ_PIO * pio, unsigned int o, int func); - -JZ_PIO *jz_gpio_map (int port); - -#endif diff --git a/Examples/ADC/src/jz47xx_mmap.c b/Examples/ADC/src/jz47xx_mmap.c deleted file mode 100644 index e8cf317..0000000 --- a/Examples/ADC/src/jz47xx_mmap.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * JZ47xx GPIO lines - * - * Written 2010 by Andres Calderon andres.calderon@emqbit.com - */ - -#include -#include -#include -#include -#include -#include - -#include - - -void * -jz_mmap (off_t address) -{ - int fd; - - void *pio; - - if ((fd = open ("/dev/mem", O_RDWR | O_SYNC)) == -1) - { - fprintf (stderr, "Cannot open /dev/mem.\n"); - return 0; - } - - pio = (void *) mmap (0, getpagesize (), PROT_READ | PROT_WRITE, MAP_SHARED, fd, address); - - if (pio == (void *) -1) - { - fprintf (stderr, "Cannot mmap.\n"); - return 0; - } - - return pio; -} diff --git a/Examples/ADC/src/jz47xx_mmap.h b/Examples/ADC/src/jz47xx_mmap.h deleted file mode 100644 index 492825b..0000000 --- a/Examples/ADC/src/jz47xx_mmap.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * JZ47xx GPIO lines - * - * Written 2010 by Andres Calderon andres.calderon@emqbit.com - */ - -#ifndef __jz47xx_mmap_h__ -#define __jz47xx_mmap_h__ - -#include - -void *jz_mmap (off_t address); - -#endif diff --git a/Examples/ADC/src/jz_adc_peripheral.c b/Examples/ADC/src/jz_adc_peripheral.c deleted file mode 100644 index e5f9cd1..0000000 --- a/Examples/ADC/src/jz_adc_peripheral.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ADC Peripheral.c - -Copyright (C) 2010 Carlos Camargo cicamargoba@unal.edu.co - Andres Calderon andres.calderon@emqbit.com - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#include -#include - -#include "jz_adc_peripheral.h" - -void -jz_adc_config(JZ_REG * addr, uchar BUFFER, uchar CLK_DIV, uchar CMD) -{ - addr[0] = (BUFFER << 16) + (CLK_DIV<<8) + CMD; -} - -int -jz_adc_check_buffer(JZ_REG * addr) -{ - return addr[0]&0x00FF0000; -} - diff --git a/Examples/ADC/src/jz_adc_peripheral.h b/Examples/ADC/src/jz_adc_peripheral.h deleted file mode 100644 index de55827..0000000 --- a/Examples/ADC/src/jz_adc_peripheral.h +++ /dev/null @@ -1,78 +0,0 @@ -/* ADC Peripheral.h - -Copyright (C) 2010 Carlos Camargo cicamargoba@unal.edu.co - Andres Calderon andres.calderon@emqbit.com - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#ifndef __adc_peropheral_h__ -#define __adc_peropheral_h__ - -#include "jz47xx_gpio.h" - -#define ADC_CMD_NONE 0x00 /* Nothing to do */ -#define ADC_CMD_SET_SPI_CLKDIV 0x90 /* Set clock divider for ADC sclk */ - -#define ADC_CMD_SET_CHANNEL0 0x50 /* Set channel 0 */ -#define ADC_CMD_READ_CHANNEL0 0x60 /* Read channel 0 */ - -#define ADC_CMD_SET_CHANNEL1 0x51 /* Set channel 1 */ -#define ADC_CMD_READ_CHANNEL1 0x61 /* Read channel 1 */ - -#define ADC_CMD_SET_CHANNEL2 0x52 /* Set channel 2 */ -#define ADC_CMD_READ_CHANNEL2 0x62 /* Read channel 2 */ - -#define ADC_CMD_SET_CHANNEL3 0x53 /* Set channel 3 */ -#define ADC_CMD_READ_CHANNEL3 0x63 /* Read channel 3 */ - -#define ADC_CMD_SET_CHANNEL4 0x54 /* Set channel 4 */ -#define ADC_CMD_READ_CHANNEL4 0x64 /* Read channel 4 */ - -#define ADC_CMD_SET_CHANNEL5 0x55 /* Set channel 5 */ -#define ADC_CMD_READ_CHANNEL5 0x65 /* Read channel 5 */ - -#define ADC_CMD_SET_CHANNEL6 0x56 /* Set channel 6 */ -#define ADC_CMD_READ_CHANNEL6 0x66 /* Read channel 6 */ - -#define ADC_CMD_SET_CHANNEL7 0x57 /* Set channel 7 */ -#define ADC_CMD_READ_CHANNEL7 0x67 /* Read channel 8 */ - -#define ADC_CMD_SET_POWER_DOWN 0X58 /* Set ADC power down mode (1uA) */ - -#define ADC_CMD_SET_FAST_CONV 0X59 /* Initialize ADC Fast Convertion(<10us)*/ - -#define ADC_CMD_SET_LOW_CONV 0X5A /* Initialize ADC Fast Convertion(<40us)*/ - -#define ADC_CMD_SET_AUTOSELFT_1 0x5B /* Set Autoselft ADC {(Vref+)-(Vref-)}/2*/ -#define ADC_CMD_READ_AUTOSELFT_1 0x6B /* Read Autoselft ADC 1 (0x0200) */ - -#define ADC_CMD_SET_AUTOSELFT_2 0x5C /* Set Autoselft ADC (Vref-) */ -#define ADC_CMD_READ_AUTOSELFT_2 0x6C /* Read Autoselft ADC 2 (0x0000) */ - -#define ADC_CMD_SET_AUTOSELFT_3 0x5D /* Set Autoselft ADC (Vref+) */ -#define ADC_CMD_READ_AUTOSELFT_3 0x6D /* Read Autoselft ADC 3 (0x03FF) */ - -#define ADC_SPI_CLKDIV_MIN 0x09 /* 50/(2*9) -> 2.7MHz (MAX=2.8MHz) */ -#define ADC_SPI_CLKDIV_MAX 0xFF /* 50/(2*255) -> 98.04KHz */ - -#define ADC_MAX_BUFFER 0xFE /* 254 reads/commands */ - -typedef unsigned char uchar; - -void jz_adc_config(JZ_REG * addr, uchar BUFFER, uchar CLK_DIV, uchar CMD); - -int jz_adc_check_buffer(JZ_REG * addr); - -#endif diff --git a/Examples/ADC/src/jz_test_adc.c b/Examples/ADC/src/jz_test_adc.c deleted file mode 100644 index eda939c..0000000 --- a/Examples/ADC/src/jz_test_adc.c +++ /dev/null @@ -1,110 +0,0 @@ -/* ADC TEST - -Copyright (C) 2010 Carlos Camargo cicamargoba@unal.edu.co - Andres Calderon andres.calderon@emqbit.com - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#include -#include - -#include "jz47xx_gpio.h" -#include "jz47xx_mmap.h" -#include "jz_adc_peripheral.h" - -#define TEST_PORT JZ_GPIO_PORT_B -#define TEST_PIN 26 - -int -main () -{ - int i,j; - JZ_PIO *pio; - JZ_REG *virt_addr; - - pio = jz_gpio_map (TEST_PORT); - jz_gpio_as_func (pio, TEST_PIN, 0); - - virt_addr = (JZ_REG *) (jz_mmap (0x13010000) + 0x18); - - if (*virt_addr != 0x0FFF7700) - { - *virt_addr = 0x0FFF7700; - printf ("Configuring CS2 32 bits and 0 WS: %08X\n", *virt_addr); - } - else - printf ("CS2, already configured: %08X\n", *virt_addr); - - virt_addr = (JZ_REG *) jz_mmap (0x14000000); - - /*************************Clean FPGA RAM memory****************************/ - for (i = 0; i < 512; i++) //RAMB16_s9_s9 has 2048 bytes 8-bit - { - virt_addr[i] = 0x00000000; //Clean 4 register by cicle - } - - /****************Configure ADC register on FPGA RAM memory*****************/ - uchar LENB = 0x01; // 1 read/cmd - jz_adc_config(virt_addr, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_SPI_CLKDIV); - usleep (100); - jz_adc_config(virt_addr, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_FAST_CONV); - usleep (100); - printf("\nADC in Fast Convertion Mode (10us) and Fs=9.8KHz (Min)\n"); - - LENB = ADC_MAX_BUFFER; // 254 read/cmd - - /******************************* TEST 1 ***********************************/ - printf("\nINIT TEST1: Autoselft {(Vref+) - (Vref-)}/2 -> Return 0x0200 \n"); - jz_adc_config(virt_addr, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_AUTOSELFT_1); - usleep (100); - jz_adc_config(virt_addr, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_READ_AUTOSELFT_1); - printf("[%08X]", virt_addr[0]); - while(jz_adc_check_buffer(virt_addr)) - { - printf("[%08X]-", virt_addr[0]); - fflush (stdout); - usleep (10000); - } - for(i=1; i< LENB/2+1; i++) - printf("[%08X]", virt_addr[i]); - - /******************************* TEST 2 ***********************************/ - printf("\n\nINIT TEST2: Autoselft (Vref-) -> Return 0x0000 \n"); - jz_adc_config(virt_addr, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_AUTOSELFT_2); - usleep (100); - jz_adc_config(virt_addr, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_READ_AUTOSELFT_2); - while(jz_adc_check_buffer(virt_addr)){usleep (100);} - for(i=1; i< LENB/2+1; i++) - printf("[%08X]", virt_addr[i]); - - /******************************* TEST 3 ***********************************/ - printf("\n\nINIT TEST3: Autoselft (Vref+) -> Return 0x03FF \n"); - jz_adc_config(virt_addr, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_AUTOSELFT_3); - usleep (100); - jz_adc_config(virt_addr, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_READ_AUTOSELFT_3); - while(jz_adc_check_buffer(virt_addr)){usleep (100);} - for(i=1; i< LENB/2+1; i++) - printf("[%08X]", virt_addr[i]); - - printf("\n\nTESTS complete\n"); - - LENB = 0x01; // 1 read/cmd - jz_adc_config(virt_addr, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_POWER_DOWN); - printf("\nADC in Power Down Mode \n"); - - return 0; -} - - diff --git a/docs/wiki/.~lock.ADC.odg# b/docs/wiki/.~lock.ADC.odg# deleted file mode 100644 index 66c0037..0000000 --- a/docs/wiki/.~lock.ADC.odg# +++ /dev/null @@ -1 +0,0 @@ -Juan64Bits ,juan64bits,Maximus,07.04.2010 18:22,file:///home/juan64bits/.openoffice.org/3; \ No newline at end of file diff --git a/docs/wiki/ADC.odg b/docs/wiki/ADC.odg index a0afee9..43f4f28 100644 Binary files a/docs/wiki/ADC.odg and b/docs/wiki/ADC.odg differ