##// END OF EJS Templates
Added ui file for APB_UART_PLUGIN.
jeandet -
r26:5e1f92d2bac2 default
parent child
Show More
@@ -0,0 +1,44
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
22 #include "apbuart_plugin_ui.h"
23 #include "ui_apbuart_plugin_ui.h"
24
25 APBUART_Plugin_ui::APBUART_Plugin_ui(QWidget *parent) :
26 QWidget(parent),
27 ui(new Ui::APBUART_Plugin_ui)
28 {
29 ui->setupUi(this);
30 connect(this->ui->FIFODebugChkBx,SIGNAL(stateChanged(int)),this,SIGNAL(loopbackChkBxStateChanged(int)));
31 connect(this,SIGNAL(apbUartTextReceived(QString)),this->ui->UART_TERM,SLOT(append(QString)));
32 }
33
34 APBUART_Plugin_ui::~APBUART_Plugin_ui()
35 {
36 delete ui;
37 }
38
39 void APBUART_Plugin_ui::setEnableForLoopBack(bool enable)
40 {
41 this->ui->PortNameLineEdit->setEnabled(enable);
42 this->ui->ConnectQpb->setEnabled(enable);
43 this->ui->UartSpeedLineEdit->setEnabled(enable);
44 }
@@ -0,0 +1,49
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
22 #ifndef APBUART_PLUGIN_UI_H
23 #define APBUART_PLUGIN_UI_H
24
25 #include <QWidget>
26
27 namespace Ui {
28 class APBUART_Plugin_ui;
29 }
30
31 class APBUART_Plugin_ui : public QWidget
32 {
33 Q_OBJECT
34
35 public:
36 explicit APBUART_Plugin_ui(QWidget *parent = 0);
37 ~APBUART_Plugin_ui();
38
39 public slots:
40 void setEnableForLoopBack(bool enable);
41 signals:
42 void loopbackChkBxStateChanged( int state );
43 void apbUartTextReceived(QString text);
44
45 private:
46 Ui::APBUART_Plugin_ui *ui;
47 };
48
49 #endif // APBUART_PLUGIN_UI_H
@@ -0,0 +1,82
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
3 <class>APBUART_Plugin_ui</class>
4 <widget class="QWidget" name="APBUART_Plugin_ui">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>400</width>
10 <height>300</height>
11 </rect>
12 </property>
13 <property name="windowTitle">
14 <string>Form</string>
15 </property>
16 <layout class="QVBoxLayout" name="verticalLayout">
17 <item>
18 <widget class="QTabWidget" name="TabWidget">
19 <property name="currentIndex">
20 <number>0</number>
21 </property>
22 <widget class="QWidget" name="Config">
23 <attribute name="title">
24 <string>Configuration</string>
25 </attribute>
26 <layout class="QGridLayout" name="gridLayout">
27 <item row="1" column="1">
28 <widget class="QLineEdit" name="PortNameLineEdit"/>
29 </item>
30 <item row="0" column="0" colspan="2">
31 <widget class="QCheckBox" name="FIFODebugChkBx">
32 <property name="text">
33 <string>Enable FIFO debug mode</string>
34 </property>
35 <property name="checked">
36 <bool>true</bool>
37 </property>
38 </widget>
39 </item>
40 <item row="1" column="0">
41 <widget class="QLabel" name="PortNameLbl">
42 <property name="text">
43 <string>Port Name</string>
44 </property>
45 </widget>
46 </item>
47 <item row="3" column="0">
48 <widget class="QLabel" name="UartSpeedLbl">
49 <property name="text">
50 <string>Uart Speed</string>
51 </property>
52 </widget>
53 </item>
54 <item row="4" column="1">
55 <widget class="QPushButton" name="ConnectQpb">
56 <property name="text">
57 <string>Open Port</string>
58 </property>
59 </widget>
60 </item>
61 <item row="3" column="1">
62 <widget class="QLineEdit" name="UartSpeedLineEdit"/>
63 </item>
64 </layout>
65 </widget>
66 <widget class="QWidget" name="Terminal">
67 <attribute name="title">
68 <string>Terminal</string>
69 </attribute>
70 <layout class="QVBoxLayout" name="verticalLayout_2">
71 <item>
72 <widget class="QTextEdit" name="UART_TERM"/>
73 </item>
74 </layout>
75 </widget>
76 </widget>
77 </item>
78 </layout>
79 </widget>
80 <resources/>
81 <connections/>
82 </ui>
@@ -1,198 +1,199
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 3 -- Copyright (C) 2013, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 2 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@member.fsf.org
21 21 ----------------------------------------------------------------------------*/
22 22 #include "APBUARTPLUGIN.h"
23 23 #include <socexplorerengine.h>
24 24
25
26 25 ApbUartPlugin::ApbUartPlugin(QWidget *parent):socexplorerplugin(parent)
27 26 {
28 this->UI = new ApbUartPluginUi();
27 this->UI = new APBUART_Plugin_ui();
29 28 this->setWidget((QWidget*)this->UI);
30 29 this->useLoopBack = false;
31 30 connect(this->UI,SIGNAL(loopbackChkBxStateChanged(int)),this,SLOT(loopbackChangeState(int)));
32 31 connect(this,SIGNAL(apbUartTextReceived(QString)),this->UI,SIGNAL(apbUartTextReceived(QString)));
33 32 connect(&this->loopBackTimer,SIGNAL(timeout()),this,SLOT(uartReadout()));
34 33 }
35 34
36 35
37 36 ApbUartPlugin::~ApbUartPlugin()
38 37 {
39 38
40 39 }
41 40
42 41 void ApbUartPlugin::closeMe()
43 42 {
44 43 emit this->closePlugin(this);
45 44 }
46 45
47 46 void ApbUartPlugin::postInstantiationTrigger()
48 47 {
49 48 if(this->isEnabled())
50 49 {
51 50 this->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),0));
52 51 loopbackChangeState(Qt::Checked);
53 52 }
54 53 }
55 54
56 55 void ApbUartPlugin::loopbackChangeState(int state)
57 56 {
58 57 if(state==Qt::Checked)
59 58 {
60 59 enableLoopback();
61 60 }
62 61 else
63 62 {
64 63 disableLoopback();
65 64 }
66 65 }
67 66
68 67 void ApbUartPlugin::uartReadout()
69 68 {
70 69 #ifdef WIN32
71 70 int readcnt=0;
72 71 #endif
73 72 if(this->isEnabled() && parent!=NULL)
74 73 {
75 74 if(this->useLoopBack)
76 75 {
77 76 if(this->baseAddress()!=-1)
78 77 {
79 78 this->loopBackTimer.stop();
80 79 unsigned int status_reg,data;
81 80 char ch;
82 81 QString printdata="";
83 82 parent->Read(&status_reg,1,this->baseAddress()+APB_UART_STATUS_REG);
84 83 while ((status_reg&4)==0) {
85 84 parent->Read(&data,1,this->baseAddress()+APB_UART_FIFO_DEBUG_REG);
86 85 ch = (char)(0xff & data);
87 86 printdata+=ch;
88 87 #ifdef WIN32
89 88 readcnt++;
90 89 if(readcnt>=32)
91 90 {
92 91 qApp->processEvents();
93 92 break;
94 93 }
95 94 #endif
96 95 parent->Read(&status_reg,1,this->baseAddress()+APB_UART_STATUS_REG);
97 96 }
98 97 if(printdata!="")
99 98 emit apbUartTextReceived(printdata);
100 99 this->loopBackTimer.start(200);
101 100 }
102 101 else
103 102 {
104 103 this->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),0));
105 104 this->enableLoopback();
106 105 }
107 106 }
108 107 }
109 108 }
110 109
111 110 void ApbUartPlugin::activate(bool flag)
112 111 {
113 112 this->setEnabled(flag);
114 113 emit this->activateSig(flag);
115 114 if(this->isEnabled())
116 115 {this->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),0));
117 116
118 117 loopbackChangeState(Qt::Checked);
119 118 }
120 119 }
121 120
122 121 void ApbUartPlugin::activateScan(bool flag)
123 122 {
124 123 if(flag)
125 124 this->loopBackTimer.start(200);
126 125 else
127 126 this->loopBackTimer.stop();
128 127 }
129 128
130 129 int ApbUartPlugin::enableLoopback()
131 130 {
132 131
133 132 this->useLoopBack = true;
134 133 this->loopBackTimer.start(200);
135 134 SocExplorerEngine::message(this,"Set FiFo debug mode mode");
136 135 if(parent==NULL)
137 136 {
138 137 SocExplorerEngine::message(this,"Can't set FiFo debug mode no parent driver accessible");
139 138 return -1;
140 139 }
141 140 if(this->baseAddress()==-1)
142 141 {
143 142 this->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),0));
144 143 if(this->baseAddress()==-1)
145 144 return -1;
146 145 }
147 146 unsigned int ctrl_reg= 0x843;
148 147 parent->Write(&ctrl_reg,1,this->baseAddress()+APB_UART_CONTROL_REG);
148 this->UI->setEnableForLoopBack(false);
149 149 return 0;
150 150 }
151 151
152 152 int ApbUartPlugin::disableLoopback()
153 153 {
154 154 SocExplorerEngine::message(this,"Disable FiFo debug mode mode");
155 155 if(parent==NULL)
156 156 {
157 157 SocExplorerEngine::message(this,"Can't disable FiFo debug mode no parent driver accessible");
158 158 return -1;
159 159 }
160 160 if(this->baseAddress()==-1)
161 161 {
162 162 this->setBaseAddress(SocExplorerEngine::self()->getEnumDeviceBaseAddress(this,this->VID(),this->PID(),0));
163 163 if(this->baseAddress()==-1)
164 164 return -1;
165 165 }
166 166 unsigned int ctrl_reg;
167 167 this->loopBackTimer.stop();
168 168 /* Firts get Control reg value*/
169 169 parent->Read(&ctrl_reg,1,this->baseAddress()+APB_UART_CONTROL_REG);
170 170 ctrl_reg = ctrl_reg & (~(1<<11));
171 171 parent->Write(&ctrl_reg,1,this->baseAddress()+APB_UART_CONTROL_REG);
172 172 this->useLoopBack = false;
173 this->UI->setEnableForLoopBack(true);
173 174 return 0;
174 175 }
175 176
176 177
177 178 unsigned int ApbUartPlugin::Read(unsigned int *Value,unsigned int count,unsigned int address)
178 179 {
179 180 if(parent!=NULL)
180 181 return parent->Read(Value,count,address);
181 182 return 0;
182 183 }
183 184
184 185
185 186 unsigned int ApbUartPlugin::Write(unsigned int *Value,unsigned int count, unsigned int address)
186 187 {
187 188 if(parent!=NULL)
188 189 return parent->Write(Value,count,address);
189 190 return 0;
190 191 }
191 192
192 193
193 194
194 195
195 196
196 197
197 198
198 199
@@ -1,69 +1,70
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 3 -- Copyright (C) 2013, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 3 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@member.fsf.org
21 21 ----------------------------------------------------------------------------*/
22 22 #ifndef APBUARTPLUGIN_H
23 23 #define APBUARTPLUGIN_H
24 24 #include <QMenuBar>
25 25 #include <QMenu>
26 26 #include <QAction>
27 27 #include <QLayout>
28 28
29 29 #include <socexplorerplugin.h>
30 30 #include <apbuartpluginui.h>
31 31 #include <QTimer>
32 #include "apbuart_plugin_ui.h"
32 33
33 34 #define APB_UART_DATA_REG 0x0
34 35 #define APB_UART_STATUS_REG 0x4
35 36 #define APB_UART_CONTROL_REG 0x8
36 37 #define APB_UART_SCALE_REG 0xC
37 38 #define APB_UART_FIFO_DEBUG_REG 0x10
38 39
39 40
40 41 class ApbUartPlugin : public socexplorerplugin
41 42 {
42 43 Q_OBJECT
43 44 public:
44 45 explicit ApbUartPlugin(QWidget *parent = 0);
45 46 ~ApbUartPlugin();
46 47 int VID(){return driver_VID;}
47 48 int PID(){return driver_PID;}
48 49
49 50 public slots:
50 51 unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
51 52 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
52 53 void closeMe();
53 54 void postInstantiationTrigger();
54 55 void loopbackChangeState( int state );
55 56 void uartReadout();
56 57 void activateScan(bool flag);
57 58 void activate(bool flag);
58 59 signals:
59 60 void apbUartTextReceived(QString text);
60 61 private:
61 ApbUartPluginUi* UI;
62 APBUART_Plugin_ui* UI;
62 63 bool useLoopBack;
63 64 QTimer loopBackTimer;
64 65 int enableLoopback();
65 66 int disableLoopback();
66 67 };
67 68
68 69 #endif // APBUARTPLUGIN_H
69 70
@@ -1,69 +1,74
1 1 #
2 2 # Project created by QtCreator 2011-09-20T08:15:30
3 3 #
4 4 #-------------------------------------------------
5 5
6 6 CONFIG += socexplorerplugin
7 7 win32:CONFIG += dll
8 8 win32:CONFIG -= static
9 9
10 10 CONFIG(debug, debug|release) {
11 11 DEBUG_EXT = _d
12 12 } else {
13 13 DEBUG_EXT =
14 14 }
15 15
16 16 TARGET = ApbUartPlugin$${DEBUG_EXT}
17 17
18 18 DEFINES += PLUGIN=ApbUartPlugin
19 19 DEFINES += PLUGINHEADER="\"\\\"APBUARTPLUGIN.h"\\\"\"
20 20 DEFINES += driver_Name="\"\\\"APB_UART_PLUGIN"\\\"\"
21 21 DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org"\\\"\"
22 22 DEFINES += driver_Version="\"\\\"0.0.1"\\\"\"
23 23 DEFINES += driver_Description="\"\\\"This plugin provides a terminal widget connected to Gaisler\'s APBUART with or without loop-back mode."\\\"\"
24 24 DEFINES += driver_can_be_root=0
25 25 DEFINES += driver_can_be_child=1
26 26 DEFINES += driver_VID=1
27 27 DEFINES += driver_PID=0x0c
28 28
29 29
30 30
31 31 INCLUDEPATH += \
32 32 $${PWD}
33 33
34 34 HEADERS += \
35 35 APBUARTPLUGIN.h \
36 36 apbuartpluginui.h \
37 37 apbuartcfg.h \
38 apbuartterminal.h
38 apbuartterminal.h \
39 apbuart_plugin_ui.h
39 40
40 41
41 42 SOURCES += \
42 43 APBUARTPLUGIN.cpp \
43 44 apbuartpluginui.cpp \
44 45 apbuartcfg.cpp \
45 apbuartterminal.cpp
46 apbuartterminal.cpp \
47 apbuart_plugin_ui.cpp
48
49 FORMS += \
50 apbuart_plugin_ui.ui
46 51
47 52
48 53
49 54
50 55
51 56
52 57
53 58
54 59
55 60
56 61
57 62
58 63
59 64
60 65
61 66
62 67
63 68
64 69
65 70
66 71
67 72
68 73
69 74
General Comments 0
You need to be logged in to leave comments. Login now