Date:2010-04-05 21:06:50 (13 years 11 months ago)
Author:Juan64Bits
Commit:bebee7c64403bf604c6995f06f091eab7e186df6
Message:Fixing LOGIC and QT_src files.

Files: Examples/ADC/QT_src/ADC (0 diffs)
Examples/ADC/QT_src/ADC1.pro (1 diff)
Examples/ADC/QT_src/ADC1.pro.user (1 diff)
Examples/ADC/QT_src/ADCw.cpp (1 diff)
Examples/ADC/QT_src/ADCw.h (1 diff)
Examples/ADC/QT_src/Makefile (1 diff)
Examples/ADC/QT_src/jz47xx_gpio.c (1 diff)
Examples/ADC/QT_src/jz47xx_gpio.cpp (1 diff)
Examples/ADC/QT_src/jz47xx_gpio.h (1 diff)
Examples/ADC/QT_src/jz47xx_mmap.c (1 diff)
Examples/ADC/QT_src/jz47xx_mmap.cpp (1 diff)
Examples/ADC/QT_src/jz47xx_mmap.h (1 diff)
Examples/ADC/QT_src/jz_adc_peripheral.c (1 diff)
Examples/ADC/QT_src/jz_adc_peripheral.cpp (1 diff)
Examples/ADC/QT_src/jz_adc_peripheral.h (1 diff)
Examples/ADC/QT_src/jz_test_adc.c (1 diff)
Examples/ADC/QT_src/main.cpp (1 diff)
Examples/ADC/QT_src/mainwindow.cpp (1 diff)
Examples/ADC/QT_src/mainwindow.h (1 diff)
Examples/ADC/QT_src/mainwindow.ui (1 diff)
Examples/ADC/QT_src/signaldisplay.cpp (1 diff)
Examples/ADC/QT_src/signaldisplay.h (1 diff)
Examples/ADC/logic/ADC_peripheral.v (10 diffs)

Change Details

Examples/ADC/QT_src/ADC
Examples/ADC/QT_src/ADC1.pro
1# #####################################################################
2# Automatically generated by qmake (2.01a) Sat Apr 3 14:28:42 2010
3# #####################################################################
4TEMPLATE = app
5TARGET = ADC
6DEPENDPATH += .
7INCLUDEPATH += .
8
9# Input
10HEADERS += mainwindow.h \
11    jz47xx_mmap.h \
12    signaldisplay.h \
13    ADCw.h \
14    jz_adc_peripheral.h \
15    jz47xx_gpio.h
16FORMS += mainwindow.ui
17SOURCES += main.cpp \
18    mainwindow.cpp \
19    signaldisplay.cpp \
20    ADCw.cpp \
21    jz_adc_peripheral.cpp \
22    jz47xx_gpio.cpp \
23    jz47xx_mmap.cpp
Examples/ADC/QT_src/ADC1.pro.user
1<!DOCTYPE QtCreatorProject>
2<qtcreator>
3 <data>
4  <variable>RunConfiguration0-Arguments</variable>
5  <valuelist type="QVariantList" />
6 </data>
7 <data>
8  <variable>RunConfiguration0-Executable</variable>
9  <value type="QString" ></value>
10 </data>
11 <data>
12  <variable>RunConfiguration0-RunConfiguration.name</variable>
13  <value type="QString" >Custom Executable</value>
14 </data>
15 <data>
16  <variable>RunConfiguration0-UseTerminal</variable>
17  <value type="bool" >false</value>
18 </data>
19 <data>
20  <variable>RunConfiguration0-UserEnvironmentChanges</variable>
21  <valuelist type="QVariantList" />
22 </data>
23 <data>
24  <variable>RunConfiguration0-UserName</variable>
25  <value type="QString" ></value>
26 </data>
27 <data>
28  <variable>RunConfiguration0-UserSetName</variable>
29  <value type="bool" >false</value>
30 </data>
31 <data>
32  <variable>RunConfiguration0-WorkingDirectory</variable>
33  <value type="QString" >$BUILDDIR</value>
34 </data>
35 <data>
36  <variable>RunConfiguration0-type</variable>
37  <value type="QString" >ProjectExplorer.CustomExecutableRunConfiguration</value>
38 </data>
39 <data>
40  <variable>activeRunConfiguration</variable>
41  <value type="int" >0</value>
42 </data>
43 <data>
44  <variable>activebuildconfiguration</variable>
45  <value type="QString" >Debug</value>
46 </data>
47 <data>
48  <variable>buildConfiguration-Debug</variable>
49  <valuemap type="QVariantMap" >
50   <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString" >Debug</value>
51   <value key="QtVersionId" type="int" >2</value>
52   <value key="addQDumper" type="" ></value>
53  </valuemap>
54 </data>
55 <data>
56  <variable>buildconfiguration-Debug-buildstep0</variable>
57  <valuemap type="QVariantMap" >
58   <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString" >Debug</value>
59   <valuelist key="abstractProcess.Environment" type="QVariantList" >
60    <value type="QString" >DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-cTqMrTHqN2,guid=cb05698ea245dbdf49f1995a4bb51c63</value>
61    <value type="QString" >DESKTOP_SESSION=gnome</value>
62    <value type="QString" >DESKTOP_STARTUP_ID=</value>
63    <value type="QString" >DISPLAY=:0.0</value>
64    <value type="QString" >GDMSESSION=gnome</value>
65    <value type="QString" >GDM_KEYBOARD_LAYOUT=es</value>
66    <value type="QString" >GDM_LANG=en_US.UTF-8</value>
67    <value type="QString" >GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
68    <value type="QString" >GNOME_KEYRING_PID=2296</value>
69    <value type="QString" >GNOME_KEYRING_SOCKET=/tmp/keyring-Z9jTYs/socket</value>
70    <value type="QString" >GTK_MODULES=canberra-gtk-module</value>
71    <value type="QString" >GTK_RC_FILES=/etc/gtk/gtkrc:/home/juan64bits/.gtkrc-1.2-gnome2</value>
72    <value type="QString" >HOME=/home/juan64bits</value>
73    <value type="QString" >LANG=en_US.UTF-8</value>
74    <value type="QString" >LANGUAGE=</value>
75    <value type="QString" >LD_LIBRARY_PATH=/usr/lib/qtcreator:</value>
76    <value type="QString" >LOGNAME=juan64bits</value>
77    <value type="QString" >ORBIT_SOCKETDIR=/tmp/orbit-juan64bits</value>
78    <value type="QString" >PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
79    <value type="QString" >PWD=/home/juan64bits</value>
80    <value type="QString" >QTDIR=/usr</value>
81    <value type="QString" >SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/2311,unix/Maximus:/tmp/.ICE-unix/2311</value>
82    <value type="QString" >SHELL=/bin/bash</value>
83    <value type="QString" >SHLVL=0</value>
84    <value type="QString" >SPEECHD_PORT=7560</value>
85    <value type="QString" >SSH_AGENT_PID=2357</value>
86    <value type="QString" >SSH_AUTH_SOCK=/tmp/keyring-Z9jTYs/socket.ssh</value>
87    <value type="QString" >USER=juan64bits</value>
88    <value type="QString" >USERNAME=juan64bits</value>
89    <value type="QString" >XAUTHORITY=/var/run/gdm/auth-for-juan64bits-TMPZko/database</value>
90    <value type="QString" >XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
91    <value type="QString" >XDG_SESSION_COOKIE=195688a1fd83f711af67c5214b6a489d-1270160483.283912-172210674</value>
92   </valuelist>
93   <valuelist key="abstractProcess.arguments" type="QVariantList" >
94    <value type="QString" >/home/juan64bits/QT/ADC1/ADC1.pro</value>
95    <value type="QString" >-spec</value>
96    <value type="QString" >/usr/share/qt4/mkspecs/linux-g++</value>
97    <value type="QString" >-r</value>
98    <value type="QString" >CONFIG+=debug</value>
99   </valuelist>
100   <value key="abstractProcess.command" type="QString" >/usr/bin/qmake-qt4</value>
101   <value key="abstractProcess.enabled" type="bool" >false</value>
102   <value key="abstractProcess.workingDirectory" type="QString" >/home/juan64bits/QT/ADC1</value>
103   <value key="buildConfiguration" type="int" >2</value>
104  </valuemap>
105 </data>
106 <data>
107  <variable>buildconfiguration-Debug-buildstep1</variable>
108  <valuemap type="QVariantMap" >
109   <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString" >Debug</value>
110   <valuelist key="abstractProcess.Environment" type="QVariantList" >
111    <value type="QString" >DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-cTqMrTHqN2,guid=cb05698ea245dbdf49f1995a4bb51c63</value>
112    <value type="QString" >DESKTOP_SESSION=gnome</value>
113    <value type="QString" >DESKTOP_STARTUP_ID=</value>
114    <value type="QString" >DISPLAY=:0.0</value>
115    <value type="QString" >GDMSESSION=gnome</value>
116    <value type="QString" >GDM_KEYBOARD_LAYOUT=es</value>
117    <value type="QString" >GDM_LANG=en_US.UTF-8</value>
118    <value type="QString" >GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
119    <value type="QString" >GNOME_KEYRING_PID=2296</value>
120    <value type="QString" >GNOME_KEYRING_SOCKET=/tmp/keyring-Z9jTYs/socket</value>
121    <value type="QString" >GTK_MODULES=canberra-gtk-module</value>
122    <value type="QString" >GTK_RC_FILES=/etc/gtk/gtkrc:/home/juan64bits/.gtkrc-1.2-gnome2</value>
123    <value type="QString" >HOME=/home/juan64bits</value>
124    <value type="QString" >LANG=en_US.UTF-8</value>
125    <value type="QString" >LANGUAGE=</value>
126    <value type="QString" >LD_LIBRARY_PATH=/usr/lib/qtcreator:</value>
127    <value type="QString" >LOGNAME=juan64bits</value>
128    <value type="QString" >ORBIT_SOCKETDIR=/tmp/orbit-juan64bits</value>
129    <value type="QString" >PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
130    <value type="QString" >PWD=/home/juan64bits</value>
131    <value type="QString" >QTDIR=/usr</value>
132    <value type="QString" >SESSION_MANAGER=local/Maximus:@/tmp/.ICE-unix/2311,unix/Maximus:/tmp/.ICE-unix/2311</value>
133    <value type="QString" >SHELL=/bin/bash</value>
134    <value type="QString" >SHLVL=0</value>
135    <value type="QString" >SPEECHD_PORT=7560</value>
136    <value type="QString" >SSH_AGENT_PID=2357</value>
137    <value type="QString" >SSH_AUTH_SOCK=/tmp/keyring-Z9jTYs/socket.ssh</value>
138    <value type="QString" >USER=juan64bits</value>
139    <value type="QString" >USERNAME=juan64bits</value>
140    <value type="QString" >XAUTHORITY=/var/run/gdm/auth-for-juan64bits-TMPZko/database</value>
141    <value type="QString" >XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
142    <value type="QString" >XDG_SESSION_COOKIE=195688a1fd83f711af67c5214b6a489d-1270160483.283912-172210674</value>
143   </valuelist>
144   <valuelist key="abstractProcess.arguments" type="QVariantList" >
145    <value type="QString" >-w</value>
146   </valuelist>
147   <value key="abstractProcess.command" type="QString" >/usr/bin/make</value>
148   <value key="abstractProcess.enabled" type="bool" >true</value>
149   <value key="abstractProcess.workingDirectory" type="QString" >/home/juan64bits/QT/ADC1</value>
150  </valuemap>
151 </data>
152 <data>
153  <variable>buildconfiguration-Debug-cleanstep0</variable>
154  <valuemap type="QVariantMap" >
155   <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString" >Debug</value>
156  </valuemap>
157 </data>
158 <data>
159  <variable>buildconfigurations</variable>
160  <valuelist type="QVariantList" >
161   <value type="QString" >Debug</value>
162  </valuelist>
163 </data>
164 <data>
165  <variable>buildstep0</variable>
166  <valuemap type="QVariantMap" >
167   <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString" ></value>
168   <value key="mkspec" type="QString" ></value>
169  </valuemap>
170 </data>
171 <data>
172  <variable>buildstep1</variable>
173  <valuemap type="QVariantMap" >
174   <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString" ></value>
175  </valuemap>
176 </data>
177 <data>
178  <variable>buildsteps</variable>
179  <valuelist type="QVariantList" >
180   <value type="QString" >trolltech.qt4projectmanager.qmake</value>
181   <value type="QString" >trolltech.qt4projectmanager.make</value>
182  </valuelist>
183 </data>
184 <data>
185  <variable>cleanstep0</variable>
186  <valuemap type="QVariantMap" >
187   <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString" ></value>
188   <value key="clean" type="bool" >true</value>
189  </valuemap>
190 </data>
191 <data>
192  <variable>cleansteps</variable>
193  <valuelist type="QVariantList" >
194   <value type="QString" >trolltech.qt4projectmanager.make</value>
195  </valuelist>
196 </data>
197 <data>
198  <variable>defaultFileEncoding</variable>
199  <value type="QByteArray" >System</value>
200 </data>
201 <data>
202  <variable>project</variable>
203  <valuemap type="QVariantMap" />
204 </data>
205</qtcreator>
Examples/ADC/QT_src/ADCw.cpp
1#include "ADCw.h"
2
3ADCw::ADCw()
4{
5    ADCBuffer = jz_adc_init();
6    /*************************Clean FPGA RAM memory****************************/
7    for (int i = 0; i < 512; i++) //RAMB16_s9_s9 has 2048 bytes 8-bit
8    {
9        ADCBuffer[i] = 0x00000000; //Clean 4 register by cicle
10    }
11}
12
13void ADCw::testADC()
14{
15    /****************Configure ADC register on FPGA RAM memory*****************/
16    jz_adc_config(ADCBuffer, 0x01, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_SPI_CLKDIV);
17    usleep (1000);
18    jz_adc_config(ADCBuffer, 0x01, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_FAST_CONV);
19    usleep (1000);
20    printf("\nADC in Fast Convertion Mode (10us) and Fs=9.8KHz (Min)\n");
21
22    int LENB = 0xFE; // 254 read/cmd
23
24    /******************************* TEST 1 ***********************************/
25    printf("\nINIT TEST1: Autoselft {(Vref+) - (Vref-)}/2 -> Return 0x0200 \n");
26    jz_adc_config(ADCBuffer, 0x01, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_AUTOSELFT_1);
27    usleep (1000);
28    jz_adc_config(ADCBuffer, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_READ_AUTOSELFT_1);
29    printf("[%08X]", ADCBuffer[0]);fflush (stdout);
30    while(jz_adc_check_buffer(ADCBuffer)){usleep (10);}
31    for(int i=1; i< LENB/2+1; i++)
32        printf("[%08X]", ADCBuffer[i]);
33    fflush (stdout);
34
35    /******************************* TEST 2 ***********************************/
36    printf("\n\nINIT TEST2: Autoselft (Vref-) -> Return 0x0000 \n");
37    jz_adc_config(ADCBuffer, 0x01, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_AUTOSELFT_2);
38    usleep (1000);
39    jz_adc_config(ADCBuffer, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_READ_AUTOSELFT_2);
40    printf("[%08X]", ADCBuffer[0]);fflush (stdout);
41    while(jz_adc_check_buffer(ADCBuffer)){usleep (10);}
42    for(int i=1; i< LENB/2+1; i++)
43        printf("[%08X]", ADCBuffer[i]);
44    fflush (stdout);
45
46    /******************************* TEST 3 ***********************************/
47    printf("\n\nINIT TEST3: Autoselft (Vref+) -> Return 0x03FF \n");
48    jz_adc_config(ADCBuffer, 0x01, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_AUTOSELFT_3);
49    usleep (1000);
50    jz_adc_config(ADCBuffer, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_READ_AUTOSELFT_3);
51    printf("[%08X]", ADCBuffer[0]);fflush (stdout);
52    while(jz_adc_check_buffer(ADCBuffer)){usleep (10);}
53    for(int i=1; i< LENB/2+1; i++)
54        printf("[%08X]", ADCBuffer[i]);
55    fflush (stdout);
56
57    printf("\n\nTESTS complete\n");
58}
59
60void ADCw::powerDownADC()
61{
62    jz_adc_config(ADCBuffer, 0x01, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_POWER_DOWN);
63    printf("\nADC in Power Down Mode \n");
64}
65
66JZ_REG* ADCw::takeSamplesADC(int LENB, uchar CLKDIV, int CHANNEL)
67{
68    jz_adc_config(ADCBuffer, 0x01, CLKDIV, ADC_CMD_SET_CHANNEL0+CHANNEL);
69    usleep (1000);
70    jz_adc_config(ADCBuffer, LENB, CLKDIV, ADC_CMD_READ_CHANNEL0+CHANNEL);
71    //while(jz_adc_check_buffer(ADCBuffer)){usleep (400000);printf("[%08X]", ADCBuffer[0]);fflush (stdout);}
72    while(jz_adc_check_buffer(ADCBuffer)){usleep (10);}
73    return ADCBuffer;
74}
Examples/ADC/QT_src/ADCw.h
1#ifndef ADCW_H
2#define ADCW_H
3
4#include "jz_adc_peripheral.h"
5#include <stdio.h>
6#include <unistd.h>
7
8class ADCw
9{
10public:
11    ADCw();
12    ~ADCw(){};
13
14    void testADC();
15    void powerDownADC();
16    JZ_REG * takeSamplesADC(int LENB, uchar CLKDIV, int CHANNEL);
17private:
18    JZ_REG * ADCBuffer;
19};
20
21#endif // ADCW_H
Examples/ADC/QT_src/Makefile
1#############################################################################
2# Makefile for building: ADC
3# Generated by qmake (2.01a) (Qt 4.6.2) on: Mon Apr 5 13:58:40 2010
4# Project: ADC1.pro
5# Template: app
6# 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
7#############################################################################
8
9####### Compiler, tools and options
10
11CC = mipsel-openwrt-linux-uclibc-gcc
12CXX = mipsel-openwrt-linux-uclibc-g++
13DEFINES = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED
14CFLAGS = -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -fhonour-copts -msoft-float -I/home/juan64bits/ebd/ECB/openwrt-xburst/staging_dir/target-mipsel_uClibc-0.9.30.1/usr/include/freetype2 -I/home/juan64bits/ebd/ECB/openwrt-xburst/staging_dir/target-mipsel_uClibc-0.9.30.1/usr/include -I/home/juan64bits/ebd/ECB/openwrt-xburst/staging_dir/target-mipsel_uClibc-0.9.30.1/include -I/home/juan64bits/ebd/ECB/openwrt-xburst/staging_dir/toolchain-mipsel_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/include -I/home/juan64bits/ebd/ECB/openwrt-xburst/staging_dir/toolchain-mipsel_gcc-4.3.3+cs_uClibc-0.9.30.1/include -O2 -Wall -W -D_REENTRANT $(DEFINES)
15CXXFLAGS = -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -fhonour-copts -msoft-float -I/home/juan64bits/ebd/ECB/openwrt-xburst/staging_dir/target-mipsel_uClibc-0.9.30.1/usr/include/freetype2 -I/home/juan64bits/ebd/ECB/openwrt-xburst/staging_dir/target-mipsel_uClibc-0.9.30.1/usr/include -I/home/juan64bits/ebd/ECB/openwrt-xburst/staging_dir/target-mipsel_uClibc-0.9.30.1/include -I/home/juan64bits/ebd/ECB/openwrt-xburst/staging_dir/toolchain-mipsel_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/include -I/home/juan64bits/ebd/ECB/openwrt-xburst/staging_dir/toolchain-mipsel_gcc-4.3.3+cs_uClibc-0.9.30.1/include -O2 -Wall -W -D_REENTRANT $(DEFINES)
16INCPATH = -I../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/qws/linux-openwrt-g++ -I. -I../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/include/QtCore -I../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/include/QtNetwork -I../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/include/QtGui -I../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/include -I. -I. -I.
17LINK = mipsel-openwrt-linux-uclibc-g++
18LFLAGS = -L/home/juan64bits/ebd/ECB/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/lib -L/home/juan64bits/ebd/ECB/openwrt-xburst/staging_dir/target-mipsel_uClibc-0.9.30.1/usr/lib -L/home/juan64bits/ebd/ECB/openwrt-xburst/staging_dir/target-mipsel_uClibc-0.9.30.1/lib -L/home/juan64bits/ebd/ECB/openwrt-xburst/staging_dir/toolchain-mipsel_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/lib -L/home/juan64bits/ebd/ECB/openwrt-xburst/staging_dir/toolchain-mipsel_gcc-4.3.3+cs_uClibc-0.9.30.1/lib -Wl,-rpath-link=/home/juan64bits/ebd/ECB/openwrt-xburst/staging_dir/target-mipsel_uClibc-0.9.30.1/usr/lib -Wl,-O1
19LIBS = $(SUBLIBS) -L/home/juan64bits/ebd/ECB/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/lib -lQtGui -L/home/juan64bits/ebd/ECB/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/lib -L/home/juan64bits/ebd/ECB/openwrt-xburst/staging_dir/target-mipsel_uClibc-0.9.30.1/usr//lib -ldirectfb -lfusion -ldirect -lQtNetwork -lQtCore -lpthread
20AR = mipsel-openwrt-linux-uclibc-ar cqs
21RANLIB = mipsel-openwrt-linux-uclibc-ranlib
22QMAKE = /home/juan64bits/ebd/ECB/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/bin/qmake
23TAR = tar -cf
24COMPRESS = gzip -9f
25COPY = cp -f
26SED = sed
27COPY_FILE = $(COPY)
28COPY_DIR = $(COPY) -r
29STRIP = :
30INSTALL_FILE = install -m 644 -p
31INSTALL_DIR = $(COPY_DIR)
32INSTALL_PROGRAM = install -m 755 -p
33DEL_FILE = rm -f
34SYMLINK = ln -f -s
35DEL_DIR = rmdir
36MOVE = mv -f
37CHK_DIR_EXISTS= test -d
38MKDIR = mkdir -p
39
40####### Output directory
41
42OBJECTS_DIR = ./
43
44####### Files
45
46SOURCES = main.cpp \
47        mainwindow.cpp \
48        signaldisplay.cpp \
49        ADCw.cpp \
50        jz_adc_peripheral.cpp \
51        jz47xx_gpio.cpp \
52        jz47xx_mmap.cpp moc_mainwindow.cpp
53OBJECTS = main.o \
54        mainwindow.o \
55        signaldisplay.o \
56        ADCw.o \
57        jz_adc_peripheral.o \
58        jz47xx_gpio.o \
59        jz47xx_mmap.o \
60        moc_mainwindow.o
61DIST = ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/common/g++.conf \
62        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/common/unix.conf \
63        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/common/linux.conf \
64        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/common/qws.conf \
65        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/qt_functions.prf \
66        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/qt_config.prf \
67        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/exclusive_builds.prf \
68        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/default_pre.prf \
69        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/release.prf \
70        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/default_post.prf \
71        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/warn_on.prf \
72        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/qt.prf \
73        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/unix/thread.prf \
74        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/moc.prf \
75        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/resources.prf \
76        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/uic.prf \
77        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/yacc.prf \
78        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/lex.prf \
79        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/include_source_dir.prf \
80        ADC1.pro
81QMAKE_TARGET = ADC
82DESTDIR =
83TARGET = ADC
84
85first: all
86####### Implicit rules
87
88.SUFFIXES: .o .c .cpp .cc .cxx .C
89
90.cpp.o:
91    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
92
93.cc.o:
94    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
95
96.cxx.o:
97    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
98
99.C.o:
100    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
101
102.c.o:
103    $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
104
105####### Build rules
106
107all: Makefile $(TARGET)
108
109$(TARGET): ui_mainwindow.h $(OBJECTS)
110    $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
111
112Makefile: ADC1.pro ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/qws/linux-openwrt-g++/qmake.conf ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/common/g++.conf \
113        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/common/unix.conf \
114        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/common/linux.conf \
115        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/common/qws.conf \
116        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/qt_functions.prf \
117        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/qt_config.prf \
118        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/exclusive_builds.prf \
119        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/default_pre.prf \
120        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/release.prf \
121        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/default_post.prf \
122        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/warn_on.prf \
123        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/qt.prf \
124        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/unix/thread.prf \
125        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/moc.prf \
126        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/resources.prf \
127        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/uic.prf \
128        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/yacc.prf \
129        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/lex.prf \
130        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/include_source_dir.prf \
131        /home/juan64bits/ebd/ECB/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/lib/libQtGui.prl \
132        /home/juan64bits/ebd/ECB/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/lib/libQtNetwork.prl \
133        /home/juan64bits/ebd/ECB/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/lib/libQtCore.prl
134    $(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
135../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/common/g++.conf:
136../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/common/unix.conf:
137../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/common/linux.conf:
138../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/common/qws.conf:
139../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/qt_functions.prf:
140../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/qt_config.prf:
141../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/exclusive_builds.prf:
142../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/default_pre.prf:
143../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/release.prf:
144../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/default_post.prf:
145../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/warn_on.prf:
146../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/qt.prf:
147../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/unix/thread.prf:
148../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/moc.prf:
149../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/resources.prf:
150../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/uic.prf:
151../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/yacc.prf:
152../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/lex.prf:
153../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/mkspecs/features/include_source_dir.prf:
154/home/juan64bits/ebd/ECB/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/lib/libQtGui.prl:
155/home/juan64bits/ebd/ECB/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/lib/libQtNetwork.prl:
156/home/juan64bits/ebd/ECB/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/lib/libQtCore.prl:
157qmake: FORCE
158    @$(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
159
160dist:
161    @$(CHK_DIR_EXISTS) .tmp/ADC1.0.0 || $(MKDIR) .tmp/ADC1.0.0
162    $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/ADC1.0.0/ && $(COPY_FILE) --parents mainwindow.h jz47xx_mmap.h signaldisplay.h ADCw.h jz_adc_peripheral.h jz47xx_gpio.h .tmp/ADC1.0.0/ && $(COPY_FILE) --parents main.cpp mainwindow.cpp signaldisplay.cpp ADCw.cpp jz_adc_peripheral.cpp jz47xx_gpio.cpp jz47xx_mmap.cpp .tmp/ADC1.0.0/ && $(COPY_FILE) --parents mainwindow.ui .tmp/ADC1.0.0/ && (cd `dirname .tmp/ADC1.0.0` && $(TAR) ADC1.0.0.tar ADC1.0.0 && $(COMPRESS) ADC1.0.0.tar) && $(MOVE) `dirname .tmp/ADC1.0.0`/ADC1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/ADC1.0.0
163
164
165clean:compiler_clean
166    -$(DEL_FILE) $(OBJECTS)
167    -$(DEL_FILE) *~ core *.core
168
169
170####### Sub-libraries
171
172distclean: clean
173    -$(DEL_FILE) $(TARGET)
174    -$(DEL_FILE) Makefile
175
176
177/home/juan64bits/ebd/ECB/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/bin/moc:
178    (cd $(QTDIR)/src/tools/moc && $(MAKE))
179
180mocclean: compiler_moc_header_clean compiler_moc_source_clean
181
182mocables: compiler_moc_header_make_all compiler_moc_source_make_all
183
184compiler_moc_header_make_all: moc_mainwindow.cpp
185compiler_moc_header_clean:
186    -$(DEL_FILE) moc_mainwindow.cpp
187moc_mainwindow.cpp: ADCw.h \
188        jz_adc_peripheral.h \
189        jz47xx_mmap.h \
190        jz47xx_gpio.h \
191        mainwindow.h \
192        ../../../../openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/bin/moc
193    /home/juan64bits/ebd/ECB/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/bin/moc $(DEFINES) $(INCPATH) mainwindow.h -o moc_mainwindow.cpp
194
195compiler_rcc_make_all:
196compiler_rcc_clean:
197compiler_image_collection_make_all: qmake_image_collection.cpp
198compiler_image_collection_clean:
199    -$(DEL_FILE) qmake_image_collection.cpp
200compiler_moc_source_make_all:
201compiler_moc_source_clean:
202compiler_uic_make_all: ui_mainwindow.h
203compiler_uic_clean:
204    -$(DEL_FILE) ui_mainwindow.h
205ui_mainwindow.h: mainwindow.ui \
206        signaldisplay.h
207    /home/juan64bits/ebd/ECB/openwrt-xburst/build_dir/target-mipsel_uClibc-0.9.30.1/qt-everywhere-opensource-src-4.6.2/bin/uic mainwindow.ui -o ui_mainwindow.h
208
209compiler_yacc_decl_make_all:
210compiler_yacc_decl_clean:
211compiler_yacc_impl_make_all:
212compiler_yacc_impl_clean:
213compiler_lex_make_all:
214compiler_lex_clean:
215compiler_clean: compiler_moc_header_clean compiler_uic_clean
216
217####### Compile
218
219main.o: main.cpp mainwindow.h \
220        ADCw.h \
221        jz_adc_peripheral.h \
222        jz47xx_mmap.h \
223        jz47xx_gpio.h
224    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
225
226mainwindow.o: mainwindow.cpp mainwindow.h \
227        ADCw.h \
228        jz_adc_peripheral.h \
229        jz47xx_mmap.h \
230        jz47xx_gpio.h \
231        ui_mainwindow.h
232    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o mainwindow.o mainwindow.cpp
233
234signaldisplay.o: signaldisplay.cpp signaldisplay.h
235    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o signaldisplay.o signaldisplay.cpp
236
237ADCw.o: ADCw.cpp ADCw.h \
238        jz_adc_peripheral.h \
239        jz47xx_mmap.h \
240        jz47xx_gpio.h
241    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o ADCw.o ADCw.cpp
242
243jz_adc_peripheral.o: jz_adc_peripheral.cpp jz_adc_peripheral.h \
244        jz47xx_mmap.h \
245        jz47xx_gpio.h
246    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o jz_adc_peripheral.o jz_adc_peripheral.cpp
247
248jz47xx_gpio.o: jz47xx_gpio.cpp jz47xx_gpio.h \
249        jz47xx_mmap.h
250    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o jz47xx_gpio.o jz47xx_gpio.cpp
251
252jz47xx_mmap.o: jz47xx_mmap.cpp jz47xx_mmap.h
253    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o jz47xx_mmap.o jz47xx_mmap.cpp
254
255moc_mainwindow.o: moc_mainwindow.cpp
256    $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_mainwindow.o moc_mainwindow.cpp
257
258####### Install
259
260install: FORCE
261
262uninstall: FORCE
263
264FORCE:
265
Examples/ADC/QT_src/jz47xx_gpio.c
1/*
2  JZ47xx GPIO at userspace
3
4  Copyright (C) 2010 Andres Calderon andres.calderon@emqbit.com
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
19
20#include <stdio.h>
21#include <stdlib.h>
22#include <unistd.h>
23
24#include <jz47xx_gpio.h>
25#include <jz47xx_mmap.h>
26
27
28#define JZ_GPIO_BASE 0x10010000
29
30void
31jz_gpio_as_output (JZ_PIO * pio, unsigned int o)
32{
33  pio->PXFUNC = (1 << (o));
34  pio->PXSELC = (1 << (o));
35  pio->PXDIRS = (1 << (o));
36}
37
38void
39jz_gpio_as_input (JZ_PIO * pio, unsigned int o)
40{
41  pio->PXFUNC = (1 << (o));
42  pio->PXSELC = (1 << (o));
43  pio->PXDIRC = (1 << (o));
44}
45
46void
47jz_gpio_set_pin (JZ_PIO * pio, unsigned int o)
48{
49  pio->PXDATS = (1 << (o));
50}
51
52void
53jz_gpio_clear_pin (JZ_PIO * pio, unsigned int o)
54{
55  pio->PXDATC = (1 << (o));
56}
57
58void
59jz_gpio_out (JZ_PIO * pio, unsigned int o, unsigned int val)
60{
61  if (val == 0)
62    pio->PXDATC = (1 << (o));
63  else
64    pio->PXDATS = (1 << (o));
65}
66
67unsigned int
68jz_gpio_get_pin (JZ_PIO * pio, unsigned int o)
69{
70  return (pio->PXPIN & (1 << o)) ? 1 : 0;
71}
72
73int
74jz_gpio_as_func (JZ_PIO * pio, unsigned int o, int func)
75{
76  switch (func)
77    {
78    case 0:
79      pio->PXFUNS = (1 << o);
80      pio->PXTRGC = (1 << o);
81      pio->PXSELC = (1 << o);
82      return 1;
83
84    case 1:
85      pio->PXFUNS = (1 << o);
86      pio->PXTRGC = (1 << o);
87      pio->PXSELS = (1 << o);
88      return 1;
89
90    case 2:
91      pio->PXFUNS = (1 << o);
92      pio->PXTRGS = (1 << o);
93      pio->PXSELC = (1 << o);
94      return 1;
95    }
96  return 0;
97}
98
99JZ_PIO *
100jz_gpio_map (int port)
101{
102  JZ_PIO *pio;
103
104  pio = (JZ_PIO *) jz_mmap (JZ_GPIO_BASE);
105  pio = (JZ_PIO *) ((unsigned int) pio + port * 0x100);
106
107  return pio;
108}
Examples/ADC/QT_src/jz47xx_gpio.cpp
1/*
2  JZ47xx GPIO at userspace
3
4  Copyright (C) 2010 Andres Calderon andres.calderon@emqbit.com
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
19
20#include <stdio.h>
21#include <stdlib.h>
22#include <unistd.h>
23
24#include <jz47xx_gpio.h>
25#include <jz47xx_mmap.h>
26
27
28#define JZ_GPIO_BASE 0x10010000
29
30void
31jz_gpio_as_output (JZ_PIO * pio, unsigned int o)
32{
33  pio->PXFUNC = (1 << (o));
34  pio->PXSELC = (1 << (o));
35  pio->PXDIRS = (1 << (o));
36}
37
38void
39jz_gpio_as_input (JZ_PIO * pio, unsigned int o)
40{
41  pio->PXFUNC = (1 << (o));
42  pio->PXSELC = (1 << (o));
43  pio->PXDIRC = (1 << (o));
44}
45
46void
47jz_gpio_set_pin (JZ_PIO * pio, unsigned int o)
48{
49  pio->PXDATS = (1 << (o));
50}
51
52void
53jz_gpio_clear_pin (JZ_PIO * pio, unsigned int o)
54{
55  pio->PXDATC = (1 << (o));
56}
57
58void
59jz_gpio_out (JZ_PIO * pio, unsigned int o, unsigned int val)
60{
61  if (val == 0)
62    pio->PXDATC = (1 << (o));
63  else
64    pio->PXDATS = (1 << (o));
65}
66
67unsigned int
68jz_gpio_get_pin (JZ_PIO * pio, unsigned int o)
69{
70  return (pio->PXPIN & (1 << o)) ? 1 : 0;
71}
72
73int
74jz_gpio_as_func (JZ_PIO * pio, unsigned int o, int func)
75{
76  switch (func)
77    {
78    case 0:
79      pio->PXFUNS = (1 << o);
80      pio->PXTRGC = (1 << o);
81      pio->PXSELC = (1 << o);
82      return 1;
83
84    case 1:
85      pio->PXFUNS = (1 << o);
86      pio->PXTRGC = (1 << o);
87      pio->PXSELS = (1 << o);
88      return 1;
89
90    case 2:
91      pio->PXFUNS = (1 << o);
92      pio->PXTRGS = (1 << o);
93      pio->PXSELC = (1 << o);
94      return 1;
95    }
96  return 0;
97}
98
99JZ_PIO *
100jz_gpio_map (int port)
101{
102  JZ_PIO *pio;
103
104  pio = (JZ_PIO *) jz_mmap (JZ_GPIO_BASE);
105  pio = (JZ_PIO *) ((unsigned int) pio + port * 0x100);
106
107  return pio;
108}
Examples/ADC/QT_src/jz47xx_gpio.h
1/*
2  JZ47xx GPIO at userspace
3
4  Copyright (C) 2010 Andres Calderon andres.calderon@emqbit.com
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
19
20#ifndef __jz47xx_gpio_h__
21#define __jz47xx_gpio_h__
22
23#define JZ_GPIO_PORT_A 0
24#define JZ_GPIO_PORT_B 1
25#define JZ_GPIO_PORT_C 2
26#define JZ_GPIO_PORT_D 3
27
28typedef volatile unsigned int JZ_REG; /* Hardware register definition */
29
30typedef struct _JZ_PIO
31{
32  JZ_REG PXPIN; /* PIN Level Register */
33  JZ_REG Reserved0;
34  JZ_REG Reserved1;
35  JZ_REG Reserved2;
36  JZ_REG PXDAT; /* Port Data Register */
37  JZ_REG PXDATS; /* Port Data Set Register */
38  JZ_REG PXDATC; /* Port Data Clear Register */
39  JZ_REG Reserved3;
40  JZ_REG PXIM; /* Interrupt Mask Register */
41  JZ_REG PXIMS; /* Interrupt Mask Set Reg */
42  JZ_REG PXIMC; /* Interrupt Mask Clear Reg */
43  JZ_REG Reserved4;
44  JZ_REG PXPE; /* Pull Enable Register */
45  JZ_REG PXPES; /* Pull Enable Set Reg. */
46  JZ_REG PXPEC; /* Pull Enable Clear Reg. */
47  JZ_REG Reserved5;
48  JZ_REG PXFUN; /* Function Register */
49  JZ_REG PXFUNS; /* Function Set Register */
50  JZ_REG PXFUNC; /* Function Clear Register */
51  JZ_REG Reserved6;
52  JZ_REG PXSEL; /* Select Register */
53  JZ_REG PXSELS; /* Select Set Register */
54  JZ_REG PXSELC; /* Select Clear Register */
55  JZ_REG Reserved7;
56  JZ_REG PXDIR; /* Direction Register */
57  JZ_REG PXDIRS; /* Direction Set Register */
58  JZ_REG PXDIRC; /* Direction Clear Register */
59  JZ_REG Reserved8;
60  JZ_REG PXTRG; /* Trigger Register */
61  JZ_REG PXTRGS; /* Trigger Set Register */
62  JZ_REG PXTRGC; /* Trigger Set Register */
63  JZ_REG Reserved9;
64  JZ_REG PXFLG; /* Port Flag Register */
65  JZ_REG PXFLGC; /* Port Flag clear Register */
66} JZ_PIO, *PJZ_PIO;
67
68void jz_gpio_as_output (JZ_PIO * pio, unsigned int o);
69
70void jz_gpio_as_input (JZ_PIO * pio, unsigned int o);
71
72void jz_gpio_set_pin (JZ_PIO * pio, unsigned int o);
73
74void jz_gpio_clear_pin (JZ_PIO * pio, unsigned int o);
75
76void jz_gpio_out (JZ_PIO * pio, unsigned int o, unsigned int val);
77
78unsigned int jz_gpio_get_pin (JZ_PIO * pio, unsigned int o);
79
80int jz_gpio_as_func (JZ_PIO * pio, unsigned int o, int func);
81
82JZ_PIO *jz_gpio_map (int port);
83
84#endif
Examples/ADC/QT_src/jz47xx_mmap.c
1/*
2 * JZ47xx GPIO lines
3 *
4 * Written 2010 by Andres Calderon andres.calderon@emqbit.com
5 */
6
7#include <stdio.h>
8#include <sys/mman.h>
9#include <fcntl.h>
10#include <stdlib.h>
11#include <termios.h>
12#include <unistd.h>
13
14#include <jz47xx_mmap.h>
15
16
17void *
18jz_mmap (off_t address)
19{
20  int fd;
21
22  void *pio;
23
24  if ((fd = open ("/dev/mem", O_RDWR | O_SYNC)) == -1)
25    {
26      fprintf (stderr, "Cannot open /dev/mem.\n");
27      return 0;
28    }
29
30  pio = (void *) mmap (0, getpagesize (), PROT_READ | PROT_WRITE, MAP_SHARED, fd, address);
31
32  if (pio == (void *) -1)
33    {
34      fprintf (stderr, "Cannot mmap.\n");
35      return 0;
36    }
37
38  return pio;
39}
Examples/ADC/QT_src/jz47xx_mmap.cpp
1/*
2 * JZ47xx GPIO lines
3 *
4 * Written 2010 by Andres Calderon andres.calderon@emqbit.com
5 */
6
7#include <stdio.h>
8#include <sys/mman.h>
9#include <fcntl.h>
10#include <stdlib.h>
11#include <termios.h>
12#include <unistd.h>
13
14#include <jz47xx_mmap.h>
15
16
17unsigned int *
18jz_mmap (off_t address)
19{
20  int fd;
21
22  unsigned int *pio;
23
24  if ((fd = open ("/dev/mem", O_RDWR | O_SYNC)) == -1)
25    {
26      fprintf (stderr, "Cannot open /dev/mem.\n");
27      return 0;
28    }
29
30  pio = (unsigned int *) mmap (0, getpagesize (), PROT_READ | PROT_WRITE, MAP_SHARED, fd, address);
31
32  if (pio == (unsigned int *) -1)
33    {
34      fprintf (stderr, "Cannot mmap.\n");
35      return 0;
36    }
37
38  return pio;
39}
Examples/ADC/QT_src/jz47xx_mmap.h
1/*
2 * JZ47xx GPIO lines
3 *
4 * Written 2010 by Andres Calderon andres.calderon@emqbit.com
5 */
6
7#ifndef __jz47xx_mmap_h__
8#define __jz47xx_mmap_h__
9
10#include <sys/mman.h>
11
12unsigned int * jz_mmap (off_t address);
13
14#endif
Examples/ADC/QT_src/jz_adc_peripheral.c
1/* ADC Peripheral.c
2
3Copyright (C) 2010 Carlos Camargo cicamargoba@unal.edu.co
4                               Andres Calderon andres.calderon@emqbit.com
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
19
20#include <stdio.h>
21#include <unistd.h>
22
23#include "jz_adc_peripheral.h"
24
25void
26jz_adc_config(JZ_REG * addr, uchar BUFFER, uchar CLK_DIV, uchar CMD)
27{
28    addr[0] = (BUFFER << 16) + (CLK_DIV<<8) + CMD;
29}
30
31int
32jz_adc_check_buffer(JZ_REG * addr)
33{
34    return addr[0]&0x00FF0000;
35}
36
Examples/ADC/QT_src/jz_adc_peripheral.cpp
1/* ADC Peripheral.c
2
3Copyright (C) 2010 Carlos Camargo cicamargoba@unal.edu.co
4                               Andres Calderon andres.calderon@emqbit.com
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
19
20#include <stdio.h>
21#include <unistd.h>
22
23#include "jz_adc_peripheral.h"
24
25JZ_REG *
26jz_adc_init()
27{
28    JZ_PIO *pio;
29    JZ_REG *virt_addr;
30
31    pio = jz_gpio_map (CS2_PORT);
32    jz_gpio_as_func (pio, CS2_PIN, 0);
33
34    virt_addr = (JZ_REG *) (jz_mmap(0x13010000) + 0x18);
35
36    if (*virt_addr != 0x0FFF7700)
37    {
38        *virt_addr = 0x0FFF7700;
39        printf ("ADC: Configuring CS2 8 bits and 0 WS: %08X\n", *virt_addr);
40    }
41    else
42        printf ("ADC: CS2, already configured: %08X\n", *virt_addr);
43
44    virt_addr = (JZ_REG *) jz_mmap (0x14000000);
45
46    return virt_addr;
47}
48
49void
50jz_adc_config(JZ_REG * addr, int BUFFER, uchar CLK_DIV, uchar CMD)
51{
52    addr[0] = (BUFFER << 16) + (CLK_DIV<<8) + CMD;
53}
54
55int
56jz_adc_check_buffer(JZ_REG * addr)
57{
58    return addr[0]&0x00FF0000;
59}
Examples/ADC/QT_src/jz_adc_peripheral.h
1/* ADC Peripheral.h
2
3Copyright (C) 2010 Carlos Camargo cicamargoba@unal.edu.co
4                               Andres Calderon andres.calderon@emqbit.com
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
19
20#ifndef __adc_peripheral_h__
21#define __adc_peripheral_h__
22
23#include "jz47xx_mmap.h"
24#include "jz47xx_gpio.h"
25
26#define ADC_CMD_NONE 0x00 /* Nothing to do */
27#define ADC_CMD_SET_SPI_CLKDIV 0x90 /* Set clock divider for ADC sclk */
28
29#define ADC_CMD_SET_CHANNEL0 0x50 /* Set channel 0 */
30#define ADC_CMD_READ_CHANNEL0 0x60 /* Read channel 0 */
31
32#define ADC_CMD_SET_CHANNEL1 0x51 /* Set channel 1 */
33#define ADC_CMD_READ_CHANNEL1 0x61 /* Read channel 1 */
34
35#define ADC_CMD_SET_CHANNEL2 0x52 /* Set channel 2 */
36#define ADC_CMD_READ_CHANNEL2 0x62 /* Read channel 2 */
37
38#define ADC_CMD_SET_CHANNEL3 0x53 /* Set channel 3 */
39#define ADC_CMD_READ_CHANNEL3 0x63 /* Read channel 3 */
40
41#define ADC_CMD_SET_CHANNEL4 0x54 /* Set channel 4 */
42#define ADC_CMD_READ_CHANNEL4 0x64 /* Read channel 4 */
43
44#define ADC_CMD_SET_CHANNEL5 0x55 /* Set channel 5 */
45#define ADC_CMD_READ_CHANNEL5 0x65 /* Read channel 5 */
46
47#define ADC_CMD_SET_CHANNEL6 0x56 /* Set channel 6 */
48#define ADC_CMD_READ_CHANNEL6 0x66 /* Read channel 6 */
49
50#define ADC_CMD_SET_CHANNEL7 0x57 /* Set channel 7 */
51#define ADC_CMD_READ_CHANNEL7 0x67 /* Read channel 8 */
52
53#define ADC_CMD_SET_POWER_DOWN 0X58 /* Set ADC power down mode (1uA) */
54
55#define ADC_CMD_SET_FAST_CONV 0X59 /* Initialize ADC Fast Convertion(<10us)*/
56
57#define ADC_CMD_SET_LOW_CONV 0X5A /* Initialize ADC Fast Convertion(<40us)*/
58
59#define ADC_CMD_SET_AUTOSELFT_1 0x5B /* Set Autoselft ADC {(Vref+)-(Vref-)}/2*/
60#define ADC_CMD_READ_AUTOSELFT_1 0x6B /* Read Autoselft ADC 1 (0x0200) */
61
62#define ADC_CMD_SET_AUTOSELFT_2 0x5C /* Set Autoselft ADC (Vref-) */
63#define ADC_CMD_READ_AUTOSELFT_2 0x6C /* Read Autoselft ADC 2 (0x0000) */
64
65#define ADC_CMD_SET_AUTOSELFT_3 0x5D /* Set Autoselft ADC (Vref+) */
66#define ADC_CMD_READ_AUTOSELFT_3 0x6D /* Read Autoselft ADC 3 (0x03FF) */
67
68#define ADC_SPI_CLKDIV_MIN 0x14 /* 50/(2*20) -> 1.25MHz (MAX=2.8MHz) */
69#define ADC_SPI_CLKDIV_MAX 0xFF /* 50/(2*255) -> 98.04KHz */
70
71#define ADC_MAX_BUFFER 0x3FE/* 1022 reads/commands */
72
73#define CS2_PORT JZ_GPIO_PORT_B
74#define CS2_PIN 26
75
76typedef unsigned char uchar;
77
78JZ_REG *jz_adc_init();
79
80void jz_adc_config(JZ_REG * addr, int BUFFER, uchar CLK_DIV, uchar CMD);
81
82int jz_adc_check_buffer(JZ_REG * addr);
83
84#endif
Examples/ADC/QT_src/jz_test_adc.c
1/* ADC TEST
2
3Copyright (C) 2010 Carlos Camargo cicamargoba@unal.edu.co
4                               Andres Calderon andres.calderon@emqbit.com
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
19
20#include <stdio.h>
21#include <unistd.h>
22
23#include "jz47xx_gpio.h"
24#include "jz47xx_mmap.h"
25#include "jz_adc_peripheral.h"
26
27#define TEST_PORT JZ_GPIO_PORT_B
28#define TEST_PIN 26
29
30int
31main ()
32{
33    int i,j;
34    JZ_PIO *pio;
35    JZ_REG *virt_addr;
36
37    pio = jz_gpio_map (TEST_PORT);
38    jz_gpio_as_func (pio, TEST_PIN, 0);
39
40    virt_addr = (JZ_REG *) (jz_mmap (0x13010000) + 0x18);
41
42    if (*virt_addr != 0x0FFF7700)
43    {
44          *virt_addr = 0x0FFF7700;
45          printf ("Configuring CS2 32 bits and 0 WS: %08X\n", *virt_addr);
46    }
47    else
48        printf ("CS2, already configured: %08X\n", *virt_addr);
49
50    virt_addr = (JZ_REG *) jz_mmap (0x14000000);
51
52    /*************************Clean FPGA RAM memory****************************/
53    for (i = 0; i < 512; i++) //RAMB16_s9_s9 has 2048 bytes 8-bit
54    {
55          virt_addr[i] = 0x00000000; //Clean 4 register by cicle
56    }
57
58    /****************Configure ADC register on FPGA RAM memory*****************/
59    uchar LENB = 0x01; // 1 read/cmd
60    jz_adc_config(virt_addr, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_SPI_CLKDIV);
61    usleep (100);
62    jz_adc_config(virt_addr, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_FAST_CONV);
63    usleep (100);
64    printf("\nADC in Fast Convertion Mode (10us) and Fs=9.8KHz (Min)\n");
65
66    LENB = ADC_MAX_BUFFER; // 254 read/cmd
67
68    /******************************* TEST 1 ***********************************/
69    printf("\nINIT TEST1: Autoselft {(Vref+) - (Vref-)}/2 -> Return 0x0200 \n");
70    jz_adc_config(virt_addr, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_AUTOSELFT_1);
71    usleep (100);
72    jz_adc_config(virt_addr, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_READ_AUTOSELFT_1);
73    printf("[%08X]", virt_addr[0]);
74    while(jz_adc_check_buffer(virt_addr))
75    {
76        printf("[%08X]-", virt_addr[0]);
77        fflush (stdout);
78        usleep (10000);
79    }
80    for(i=1; i< LENB/2+1; i++)
81        printf("[%08X]", virt_addr[i]);
82
83    /******************************* TEST 2 ***********************************/
84    printf("\n\nINIT TEST2: Autoselft (Vref-) -> Return 0x0000 \n");
85    jz_adc_config(virt_addr, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_AUTOSELFT_2);
86    usleep (100);
87    jz_adc_config(virt_addr, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_READ_AUTOSELFT_2);
88    while(jz_adc_check_buffer(virt_addr)){usleep (100);}
89    for(i=1; i< LENB/2+1; i++)
90        printf("[%08X]", virt_addr[i]);
91
92    /******************************* TEST 3 ***********************************/
93    printf("\n\nINIT TEST3: Autoselft (Vref+) -> Return 0x03FF \n");
94    jz_adc_config(virt_addr, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_AUTOSELFT_3);
95    usleep (100);
96    jz_adc_config(virt_addr, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_READ_AUTOSELFT_3);
97    while(jz_adc_check_buffer(virt_addr)){usleep (100);}
98    for(i=1; i< LENB/2+1; i++)
99        printf("[%08X]", virt_addr[i]);
100
101    printf("\n\nTESTS complete\n");
102
103    LENB = 0x01; // 1 read/cmd
104    jz_adc_config(virt_addr, LENB, ADC_SPI_CLKDIV_MAX, ADC_CMD_SET_POWER_DOWN);
105    printf("\nADC in Power Down Mode \n");
106
107  return 0;
108}
109
110
Examples/ADC/QT_src/main.cpp
1#include <QtGui/QApplication>
2#include "mainwindow.h"
3
4int main(int argc, char *argv[])
5{
6    QApplication a(argc, argv);
7    MainWindow w;
8    w.show();
9    return a.exec();
10}
Examples/ADC/QT_src/mainwindow.cpp
1#include "mainwindow.h"
2#include "ui_mainwindow.h"
3#include <QDebug>
4
5#include <QTime>
6#include <math.h>
7
8MainWindow::MainWindow(QWidget *parent)
9    : QMainWindow(parent), ui(new Ui::MainWindow)
10{
11    ui->setupUi(this);
12    connect(this,SIGNAL(refresh()),ui->Graph, SLOT(repaint()));
13    ui->Graph->setPointsPerPlot(250);
14    ui->Graph->setVoltsPerDiv(102);
15
16    timer1 = new QTimer(this);
17    timer1->start(50);
18    connect(timer1, SIGNAL(timeout()), this, SLOT(updateGraph()));
19
20    ADC1 = new ADCw;
21    ADC1->testADC();
22    printf("\nTaking 250 samples each 50ms from Channel 0 at Fs=9.8KHz \n");
23}
24
25MainWindow::~MainWindow()
26{
27    delete ui;
28}
29
30void MainWindow::updateGraph()
31{
32    JZ_REG * dataADC =ADC1->takeSamplesADC(250, 0xFF, 1);
33    int tempD;
34
35    for(int i=1; i< 250/2+1; i++)
36    {
37        tempD = dataADC[i]&0xFFFF; //printf("[%08X]",tempD);
38        ui->Graph->addPoint(tempD);
39        tempD = dataADC[i]>>16; //printf("[%08X]",tempD);
40        ui->Graph->addPoint(tempD);
41    }
42    //fflush (stdout);
43    /*for(int i = 0; i<100;i++)
44        ui->Graph->addPoint(20*sin(6.2832*i/100)+20);*/
45
46    emit refresh();
47}
Examples/ADC/QT_src/mainwindow.h
1#ifndef MAINWINDOW_H
2#define MAINWINDOW_H
3
4#include <QtGui/QMainWindow>
5#include "ADCw.h"
6
7namespace Ui
8{
9    class MainWindow;
10}
11
12class MainWindow : public QMainWindow
13{
14    Q_OBJECT
15
16public:
17    MainWindow(QWidget *parent = 0);
18    ~MainWindow();
19
20public slots:
21    void updateGraph();
22
23signals:
24    void refresh();
25
26private:
27    Ui::MainWindow *ui;
28    QTimer *timer1;
29    ADCw *ADC1;
30};
31
32#endif // MAINWINDOW_H
Examples/ADC/QT_src/mainwindow.ui
1<?xml version="1.0" encoding="UTF-8"?>
2<ui version="4.0">
3 <class>MainWindow</class>
4 <widget class="QMainWindow" name="MainWindow">
5  <property name="geometry">
6   <rect>
7    <x>0</x>
8    <y>0</y>
9    <width>320</width>
10    <height>240</height>
11   </rect>
12  </property>
13  <property name="windowTitle">
14   <string>ADC Test</string>
15  </property>
16  <widget class="QWidget" name="centralWidget">
17   <layout class="QGridLayout" name="gridLayout">
18    <item row="0" column="0" colspan="2">
19     <widget class="SignalDisplay" name="Graph" native="true">
20      <property name="minimumSize">
21       <size>
22        <width>100</width>
23        <height>20</height>
24       </size>
25      </property>
26     </widget>
27    </item>
28   </layout>
29  </widget>
30  <action name="action_Salir">
31   <property name="text">
32    <string>&amp;Salir</string>
33   </property>
34  </action>
35  <action name="actionA_cerca_de">
36   <property name="text">
37    <string>A&amp;cerca de...</string>
38   </property>
39  </action>
40  <action name="actionAcerca_de_QT">
41   <property name="text">
42    <string>Acerca de &amp;QT</string>
43   </property>
44  </action>
45  <action name="actionAcerca_de_Qt">
46   <property name="text">
47    <string>Acerca de &amp;Qt...</string>
48   </property>
49  </action>
50 </widget>
51 <layoutdefault spacing="6" margin="11"/>
52 <customwidgets>
53  <customwidget>
54   <class>SignalDisplay</class>
55   <extends>QWidget</extends>
56   <header location="global">signaldisplay.h</header>
57   <container>1</container>
58  </customwidget>
59 </customwidgets>
60 <resources/>
61 <connections/>
62</ui>
Examples/ADC/QT_src/signaldisplay.cpp
1#include "signaldisplay.h"
2#include <QtGui>
3#include <QDebug>
4
5SignalDisplay::SignalDisplay(QWidget *&parent):QWidget(parent)
6{
7    colorTrace = Qt::blue;
8    secsPerDiv = 1.0/600.0;
9    voltsPerDiv = 20;
10    setPointsPerPlot(10);
11}
12
13void SignalDisplay::setPointsPerPlot(int value)
14{
15    pointsPerPlot = value;
16    waves = new QPoint[pointsPerPlot];
17    secsIdx = 0;
18}
19
20void SignalDisplay::drawGrid(QPainter &p, QColor colorGrid, int x, int y, int w, int h, int nx, int ny){
21    p.setPen(colorGrid);
22    for (int ix= 0; ix<nx; ix++){
23        int x = ix*w/nx;
24        p.drawLine(x,0,x,h);
25    }
26    for (int iy = 0; iy < ny; iy++){
27        int y = iy*h/ny;
28        p.drawLine(0,y,w,y);
29    }
30}
31void SignalDisplay::paintEvent(QPaintEvent *event){
32    QPainter painter(this);
33    w = width();
34    h = height();
35    ox = w;
36    oy = h;
37    painter.fillRect(0,0,w,h,Qt::gray);
38    painter.setPen(Qt::white);
39    //painter.drawLine(secsIdx*w/10/60.0/pointsPerPlot/secsPerDiv,0, \
40    // secsIdx*w/10/60.0/pointsPerPlot/secsPerDiv,h);
41    drawGrid(painter, Qt::darkGray,0,0,w,h,4, 10);
42
43    /*for(int i = 0; i < pointsPerPlot; i++)
44    {
45        painter.fillRect(waves[i].x()-w/pointsPerPlot/2,waves[i].y(), \
46                               w/pointsPerPlot,h-waves[i].y(), Qt::blue);
47    }*/
48    painter.setPen(colorTrace);
49    painter.drawPolyline(waves,pointsPerPlot);
50
51}
52
53void SignalDisplay::addPoint( int value1)
54{
55    waves[secsIdx] = QPoint(secsIdx*w/10/60.0/pointsPerPlot/secsPerDiv+w/(2*pointsPerPlot), \
56                        oy-value1*h/voltsPerDiv/10);
57    secsIdx = (secsIdx+1) % pointsPerPlot;
58}
59
60//EOF
Examples/ADC/QT_src/signaldisplay.h
1#ifndef SIGNALDISPLAY_H
2#define SIGNALDISPLAY_H
3
4#include <QWidget>
5#include <cmath>
6#include <QtGui>
7
8class SignalDisplay : public QWidget
9{
10public:
11    SignalDisplay(QWidget *&parent);
12    void addPoint( int value1);
13    void setSecsPerDiv( float value ){ secsPerDiv = fabs(value);}
14    void setVoltsPerDiv( float value ){ voltsPerDiv = fabs(value);}
15    float getSecsPerDiv(){ return secsPerDiv; }
16    void setPointsPerPlot(int value);
17    void setColorTrace(QColor color){colorTrace=color;};
18
19private:
20    void paintEvent(QPaintEvent *event);
21    void drawGrid(QPainter &p, QColor colorGrid, int x, int y, int w, int h, int nx, int ny);
22    QPoint *waves;
23    float voltsPerDiv;
24    float secsPerDiv;
25    QColor colorTrace;
26    int secsIdx;
27    int w, h, ox, oy;
28    int pointsPerPlot;
29};
30
31#endif // SIGNALDISPLAY_H
Examples/ADC/logic/ADC_peripheral.v
22module ADC_peripheral( clk, reset, cs, ADC_EOC, ADC_CS, ADC_CSTART,
33                        ADC_SCLK, ADC_SDIN, ADC_SDOUT,
44                        addr, rdBus, wrBus, we);
5
5
66    input clk, reset, ADC_EOC, cs, we;
77    input [10:0] addr;
88    input [7:0] wrBus;
...... 
1313    //RAMB registers
1414    reg [7:0] rdBus;
1515    wire [7:0] rdBus1;
16    wire [7:0] rdBus2;
1716    reg [7:0] wrBus2;
1817    reg [10:0] addr2;
1918    reg we1=0;
...... 
2423    reg nSample=0;
2524    reg [10:0] auto_count=0;
2625    reg [4:0] w_st2=0;
26
2727
2828    //SPI registers
2929    reg [3:0] SPI_in_data=0;
...... 
3636    reg CMD_TYP;
3737    reg [3:0] CMD_ADC;
3838    reg [7:0] CLKDIV = 0;
39    reg [10:0] SIZEB; //[10:8] -> size_hi | [7:0] -> size_low
39    reg [9:0] SIZEB; //[10:8] -> size_hi | [7:0] -> size_low
4040        //TEMPS
41    reg [10:0] SIZEB2;
42    reg CMD_DONE2;
41    reg [9:0] SIZEB2;
4342
4443    assign ADC_CSTART = 1'b1;
4544
4645    // Dual-port RAM instatiation
4746    RAMB16_S9_S9 ba0(
48            .DOA(rdBus1), // Port A 8-bit Data Output
49            .DOB(rdBus2), // Port B 8-bit Data Output
50            .DOPA(), // Port A 1-bit Parity Output
51            .DOPB(), // Port B 1-bit Parity Output
52            .ADDRA(addr[10:0]), // Port A 11-bit Address Input
53            .ADDRB(addr2[10:0]), // Port B 11-bit Address Input
54            .CLKA(~clk), // Port A Clock
55            .CLKB(~clk), // Port B Clock
56            .DIA(wrBus), // Port A 8-bit Data Input
57            .DIB(wrBus2), // Port B 8-bit Data Input
58            .DIPA(1'b0), // Port A 1-bit parity Input
59            .DIPB(1'b0), // Port-B 1-bit parity Input
60            .ENA(1'b1), // Port A RAM Enable Input
61            .ENB(1'b1), // Port B RAM Enable Input
62            .SSRA(1'b0), // Port A Synchronous Set/Reset Input
63            .SSRB(1'b0), // Port B Synchronous Set/Reset Input
64            .WEA(we1), // Port A Write Enable Input
65            .WEB(we2) ); // Port B Write Enable Input
47            .DOA(rdBus1), // Port A 8-bit Data Output
48            .DOB(), // Port B 8-bit Data Output
49            .DOPA(), // Port A 1-bit Parity Output
50            .DOPB(), // Port B 1-bit Parity Output
51            .ADDRA(addr), // Port A 11-bit Address Input
52            .ADDRB(addr2), // Port B 11-bit Address Input
53            .CLKA(~clk), // Port A Clock
54            .CLKB(~clk), // Port B Clock
55            .DIA(wrBus), // Port A 8-bit Data Input
56            .DIB(wrBus2), // Port B 8-bit Data Input
57            .DIPA(1'b0), // Port A 1-bit parity Input
58            .DIPB(1'b0), // Port-B 1-bit parity Input
59            .ENA(1'b1), // Port A RAM Enable Input
60            .ENB(1'b1), // Port B RAM Enable Input
61            .SSRA(1'b0), // Port A Synchronous Set/Reset Input
62            .SSRB(1'b0), // Port B Synchronous Set/Reset Input
63            .WEA(we1), // Port A Write Enable Input
64            .WEB(we2) ); // Port B Write Enable Input
6665
6766    // SPI comunication module instantiation
6867    reg ADC_SCLK_buffer = 0;
6968    reg ADC_SDIN_buffer = 0;
70    reg busy = 0;
69    reg busy = 0, load_in = 0;
70    reg pulse = 0, clkdiv_en = 0;
7171
7272    reg [3:0] in_buffer=0;
7373    reg [9:0] out_buffer;
7474    reg [7:0] clkcount = 0;
7575    reg [4:0] count = 0;
76    reg [4:0] w_st1=0;
77
78    assign ADC_CS = ~busy;
79
80    // Clock Generator
81    always@(posedge clk)
82        if (clkdiv_en) begin
83           if(clkcount < CLKDIV) begin
84                   clkcount <= clkcount + 1; pulse <=0;
85           end else begin
86                clkcount <= 0; pulse <=1;
87                if((count>0) && (count < 21))
88                    ADC_SCLK_buffer <= ~ADC_SCLK_buffer;
89           end
90        end else begin
91            ADC_SCLK_buffer <= 0; pulse <=0;
92        end
93    // Control
94    always @(posedge clk)
95    if(reset) begin
96        {w_st1, count, clkdiv_en, busy} <= 0;
97    end else begin
98        case (w_st1)
99             0: begin
100                    if(SPI_wr) begin
101                     clkdiv_en <= 1;
102                     load_in <= 1;
103                     w_st1 <= 1; busy <= 1;
104                     end
105                end
106             1: begin
107                     load_in <= 0;
108                     if(pulse)
109                         count <= count + 1;
110                     else if (count > 30) begin
111                          clkdiv_en <= 0; busy <= 0; w_st1 <= 0; count <= 0; end
112                end
113          endcase
114     end
115
116    // Receptor
117    always@(posedge clk)
118    begin
119        if((count[0] & pulse) && (count < 21)) begin
120            out_buffer <= out_buffer << 1;
121            out_buffer[0] <= ADC_SDOUT;
122        end
123    end
76124
125    always@(SPI_rd or out_buffer or busy or CLKDIV)
126    begin
127        SPI_out_data <= 10'bx;
128        if(SPI_rd)
129            begin SPI_out_data <= out_buffer; end
130    end
131
132    // Transmitter
133    always@(posedge clk)
134    begin
135        if(load_in) in_buffer <= SPI_in_data;
136        if(!count[0] & pulse) begin
137            ADC_SDIN_buffer <= in_buffer[3];
138            in_buffer <= in_buffer << 1;
139        end
140    end
141
142    assign ADC_SCLK = ADC_SCLK_buffer;
143    assign ADC_SDIN = ADC_SDIN_buffer;
144
145/*
77146    assign ADC_CS = ~busy;
78147
79148    always@(SPI_rd or out_buffer or busy or CLKDIV)
...... 
90159            if(SPI_wr)
91160                begin in_buffer = SPI_in_data; busy = 1; end
92161        end
93        else
94        begin
162        else
163        begin
95164            clkcount = clkcount + 1;
96165            if(clkcount >= CLKDIV)
97166            begin
...... 
114183                    busy = 0;
115184                end
116185            end
117        end
186        end
118187    end
119188
120189    always@(posedge ADC_SCLK_buffer)
...... 
124193    end
125194
126195    assign ADC_SCLK = ADC_SCLK_buffer;
127    assign ADC_SDIN = ADC_SDIN_buffer;
196    assign ADC_SDIN = ADC_SDIN_buffer;*/
128197
129198    // Write control
130    always @(negedge clk)
199    always @(posedge clk)
131200        if(reset)
132201            {CMD_TYP,CMD_ADC,SIZEB,we1} <= 0;
133202        else if(we & cs) begin
...... 
136205                             CMD_ADC[3:0] <= wrBus[3:0]; end
137206                    1: begin CLKDIV <= wrBus; end
138207                    2: begin SIZEB[7:0] <= wrBus; end
139                    3: begin SIZEB[10:8] <= wrBus[2:0]; end
140              default: begin we1 <= 1; end
208                    3: begin SIZEB[9:8] <= wrBus[2:0]; end
209              default: begin we1 <= 1; end
141210            endcase
142211        end
143212        else if(nSample)
144213            begin SIZEB <= SIZEB - 1; end
145        else
146            begin we1 <= 0; end
214        else
215            begin we1 <= 0; end
216
147217    // Read control
148218    always @(posedge clk)
149219        if(reset)
...... 
153223                  0: begin rdBus <= {CMD_DONE,CMD_TYP,CMD_ADC};end
154224                  1: begin rdBus <= CLKDIV; end
155225                  2: begin rdBus <= SIZEB[7:0]; end
156                  3: begin rdBus <= SIZEB[10:8]; end
226                  3: begin rdBus <= SIZEB[9:8]; end
157227            default: begin rdBus <= rdBus1; end
158228            endcase
159229        end
...... 
165235    else begin
166236        case (w_st2)
167237             0: begin w_st2 <= 2; SIZEB2<=SIZEB; end
168             2: begin
169                    if (SIZEB == 0)
170                        begin w_st2 <= 0; CMD_DONE<= 1; auto_count <= 0; end
171                    else begin
172                        CMD_DONE<= 0;
173                        //Send data to ADC
174                        auto_count <= auto_count+1;
175                        SPI_in_data <= CMD_ADC[3:0];
176                        SPI_wr <= 1; w_st2 <= 3;
177                    end
178                end
179             3: begin
180                    SPI_wr <= 0;
181                    //Wait for complete convertion
182                    if(!ADC_EOC || ADC_CS) begin
183                        SPI_rd <=1;
184                        if(CMD_TYP)
185                            w_st2<= 2;
186                        else
187                            w_st2<= 4;
188                    end
189                end
190             4: begin
191                    //Write data on BRAM (LOW)
192                    wrBus2 <= SPI_out_data[7:0];
193                    addr2 <= 4+2*(SIZEB2-SIZEB);
194                    we2 <= 1; w_st2 <= 5;
195                end
196             5: begin we2 <= 0; w_st2 <= 6; end
197             6: begin
198                    //Write data on BRAM (HI)
199                    wrBus2 <= SPI_out_data[9:8];
200                    addr2 <= 5+2*(SIZEB2-SIZEB);
201                    we2 <= 1; w_st2 <= 7; nSample <= 1;
202                end
203             7: begin nSample <= 0; we2 <= 0; SPI_rd <=0; w_st2 <= 2; end
238             2: begin
239                    if (SIZEB == 0)
240                        begin w_st2 <= 0; CMD_DONE<= 1; auto_count <= 0; end
241                    else begin
242                        CMD_DONE<= 0;
243                        //Send data to ADC
244                        auto_count <= auto_count+1;
245                        SPI_in_data <= CMD_ADC[3:0];
246                        SPI_wr <= 1; w_st2 <= 3;
247                    end
248                end
249             3: begin
250                    SPI_wr <= 0;
251                    //Wait for complete convertion
252                    if(ADC_CS && ADC_EOC) begin
253                        SPI_rd <=1;
254                        if(CMD_TYP)
255                            w_st2<= 2;
256                        else
257                            w_st2<= 4;
258                    end
259                end
260             4: begin
261                    //Write data on BRAM (LOW)
262                    wrBus2 <= SPI_out_data[7:0];
263                    addr2 <= 4+2*(SIZEB-SIZEB2);
264                    we2 <= 1; w_st2 <= 5;
265                end
266             5: begin we2 <= 0; w_st2 <= 6; end
267             6: begin
268                    //Write data on BRAM (HI)
269                    wrBus2 <= SPI_out_data[9:8];
270                    addr2 <= 5+2*(SIZEB-SIZEB2);
271                    we2 <= 1; w_st2 <= 7; nSample <= 1;
272                end
273             7: begin nSample <= 0; we2 <= 0; SPI_rd <=0; w_st2 <= 2; end
204274        endcase
205275      end
206276

Archive Download the corresponding diff file

Branches:
master



interactive