hi guys, can u explain step by step how to make a program using QT to control LED, buttons, and GPIO in mini2440? i really need your advice. thanks
controll led, button, GPIO with QT
thanks electutorial for your reply. i have tried your tutorial in youtube and it's very help me.thanks a lot! now i'm trying to make a program to control another peripherals on mini2440 with QT. i searched in google and it's so hard to find. do you have another example?
may be your video wasn't popular, but it helped me and the others i think.:) oh ya, can i request a video how to controll led with button in board? or may be how to control the con pin in mini 2440?
@shaco, have you gone through all the material available on andahammer.com site for the mini2440 ? also many people have had success translating few chapters of the Chinese user manual (using google's free online translation service). It's a shame, FriendlyARM doesn't translate the doc properly. Google auto-translator is not bad, but some human touch, by someone who knows Chinese and English well enough, would give it the golden touch. @electutorial, nice video tute. look forward to more.
@electutorial, ok, tell me when you video finished. @Icarus, thanks for your reply. i have gone there, and i don't find tutorial to develop mini2440 with QT in linux. i'm new in embedded system, especially using mini2440. so i need many references that can help me. Icarus, what tool si you use to develop mini2440?
@shaco: Hope this link can help you: http://ultimatewebfree.kinssha.org/index.php/tutorielmini2440 (it uses French? @electutorial: thanks for you videos. its really helpful for beginner like me!. waiting next video. best regards.
Hi all, This is my GPIO class I've written in my captions project last year, you can use it to control whatever GPIO pins you want: file gpio.h /**************************************************************************** ** ** Copyright (C) 2010 FPT University FUEMES group. ** All rights reserved. ** Contact: FPT University http://www.fpt.edu.vn ** ** This file is part of the demonstration applications of the FUEMES mini2440 client ** ** $FUEMES_BEGIN_LICENSE:LGPL$ ** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Commercial License Agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you have questions regarding the use of this file, please contact ** FUEMES group at fuemes@gmail.com. ** $FUEMES_END_LICENSE$ ** ****************************************************************************/ #ifndef GPIO_H #define GPIO_H #include <qstring.h> #include <qobject.h> #include <string.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> //Header pin number definitions #define PIN9 160 #define PIN10 161 #define PIN11 162 #define PIN12 163 #define PIN13 164 #define PIN14 165 #define PIN15 166 #define PIN16 192 #define PIN17 193 #define PIN18 195 #define PIN19 197 #define PIN20 198 #define PIN21 199 #define PIN22 201 #define PIN23 202 #define PIN24 203 #define PIN25 139 #define PIN26 140 #define PIN27 141 #define PIN28 194 #define PIN29 142 #define PIN30 143 #define PIN31 32 #define PIN32 33 #define PIN33 233 #define PIN34 234 class GPIO : public QObject { Q_OBJECT public: GPIO(int pin); //pin is the pin nuber on con4 of the FriendlyARM board ~GPIO(); enum Direction {In,Out,Err}; int openPin(); int closePin(); int setDirection(Direction direction); //set direction in/out. returns 0 if ok and -1 on error int getDirection(); //returns direction int setState(bool state); void setValue(bool value); bool getState(); public: private: Direction _direction; int _state; int _pinNumber; QString _directionString; QString _valueString; QString _strPin; }; #endif // GPIO_H file gpio.c #include "mini2440Gpio.h" //------------------------------------------------------------------------------ -------------------------- GPIO::GPIO(int pin) { _pinNumber = pin; _valueString = QString("/sys/class/gpio/gpio%1/value").arg(pin); _directionString = QString("/sys/class/gpio/gpio%1/direction").arg(pin); _strPin = QString("%1").arg(pin); } //------------------------------------------------------------------------------ -------------------------- GPIO::~GPIO() { FILE * fp; //This will create the folder /sys/class/gpio/gpio37 if ((fp = fopen("/sys/class/gpio/unexport", "ab")) == NULL) return; rewind(fp); //Set pointer to begining of the file fwrite(_strPin.toLatin1(), sizeof(char),_strPin.length() , fp); fclose(fp); } //------------------------------------------------------------------------------ -------------------------- int GPIO::openPin() { FILE * fp; //This will create the folder /sys/class/gpio/gpio37 if ((fp = fopen("/sys/class/gpio/export", "ab")) == NULL) return -1; rewind(fp);//Set pointer to begining of the file fwrite(_strPin.toLatin1(), sizeof(char),_strPin.length() , fp); fclose(fp); return 0; } //------------------------------------------------------------------------------ -------------------------- int GPIO::closePin() { FILE * fp; //This will create the folder /sys/class/gpio/gpio37 if ((fp = fopen("/sys/class/gpio/unexport", "ab")) == NULL) return -1; rewind(fp);//Set pointer to begining of the file fwrite(_strPin.toLatin1(), sizeof(char),_strPin.length() , fp); fclose(fp); return 0; } //------------------------------------------------------------------------------ -------------------------- int GPIO::setDirection(Direction direction) { //set direction in/out. returns 0 if ok and -1 on error FILE * fp; if ((fp = fopen(_directionString.toLatin1(), "rb+")) == NULL) return -1; rewind(fp);//Set pointer to begining of the file if(direction == In) fwrite("in", sizeof(char),2, fp); if(direction == Out) fwrite("out", sizeof(char),3, fp); fclose(fp); return 0; } //------------------------------------------------------------------------------ -------------------------- /* int GPIO::getDirection() {//returns direction }*/ //------------------------------------------------------------------------------ -------------------------- int GPIO::setState(bool state) {//state is 0 or 1. No effect if other value. returns the new state or -1 on error FILE * fp; if ((fp = fopen(_valueString .toLatin1(), "rb+")) == NULL) return -1; rewind(fp);//Set pointer to begining of the file if(state) fwrite("high", sizeof(char),4, fp); else fwrite("low", sizeof(char),3, fp); fclose(fp); return 0; } //------------------------------------------------------------------------------ -------------------------- bool GPIO::getState() { //returns 1 or 0 - the pin state. Returns -1 on error FILE * fp; char value; if ((fp = fopen(_valueString.toLatin1(), "rb+")) == NULL) return false; rewind(fp);//Set pointer to begining of the file fread(&value, sizeof(char),1, fp); fclose(fp); if(value=='1') return true; if(value=='0') return false; return false; } //------------------------------------------------------------------------------ -------------------------- to use gpio class you just declare like this: GPIO test = new GPIO(PIN32); test->openPin(); // open pin test->setDirection(GPIO::Out); // set direction to output test->setState(false); // set value to low. test->closePin();//close pin delete test; // delete pointer to avoid leak memory. Have funs!
@Coungle, thanks for your reply, ya its in frances. now i'am trying to develop an application with qt for mini2440. i need some resources how to develop it. do u have any information? @TungPham,thanks for your reply, it will help everyone here. where can i found information about the function of the pin (Header pin number definitions)?
Hi, there are some links I think that can help you: http://www.youtube.com/watch?v=VmXN6JNndms http://www.youtube.com/watch?v=ghzRuwEAWdo Good luck.
@shaco: the GPIO informations you can see there: http://www.avrfreaks.net/wiki/index.php/Documentation:Linux/GPIO
@TungPham, thanks for your reply. i have read it, but i still don't understand what is the function of every pin that you wrote in the program? if i want to use another pin, shoul i change the gpio.h?
//Header pin number definitions #define PIN9 160 #define PIN10 161 Are codes for Mini6410-pins the same? Where can I find it?
hi i have problem on my mini2440 board there is no gpio directory i.e. /sys/class thats it so how i can put gpio directory on board
can you please tell me on which pin led are connected in mini2440|s3c2440 ARM9(friendly arm). and kindly tell me which pins are free here which can be further connected to a relay.???
thank you I was searching for this I already managed to use gpio's from linux command console. But did not have any qt sources. I will try the code