Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
nimish
PostPosted: Oct 11, 2008 - 07:16 AM
Newbie


Joined: Jun 10, 2007
Posts: 16


Is there sombody know how I can use yellow leds on STK1000 and switchs on STK1000, useing C/C++. I am useing linux kernal.

cd /config/gpio
mkdir leds
cd leds
echo 1 > gpio_id
echo 0xff > pin_mask
echo 0xff > oe_mask
echo 1 > enabled
cat /dev/urandom > /dev/gpio0

this is working fine no problems

but when I am useing

unsigned long pin_state = 0;
int fd;

fd = open("/dev/gpio0", O_WRONLY);
while (1) {
pin_state = pin_state ^ 1;
write(fd, &pin_state, sizeof(pin_state));
sleep(1);
}

this is not working

Can some body help me I think there is very simple mistake I am doing.

If any one can help me for accessing keys in C/C++ that will be very helpfull for me. I want to use this keys in qtopia

Best regards
 
 View user's profile Send private message  
Reply with quote Back to top
squidgit
PostPosted: Oct 11, 2008 - 07:36 AM
Raving lunatic


Joined: Sep 14, 2003
Posts: 4228
Location: Queanbeyan, Australia

Do access the keys in Qtopia you'll have to have them appear as a keyboard. This can be done with the gpio-keys driver, search around the forum for that.

Regarding the above code, what failed? Can you confirm that /dev/gpio0 exists before you run the program?

-S.

_________________
Blag: http://www.niasdigital.com/blag
 
 View user's profile Send private message  
Reply with quote Back to top
nimish
PostPosted: Oct 11, 2008 - 10:33 AM
Newbie


Joined: Jun 10, 2007
Posts: 16


Thnaks for replay.

But this directory is not exist

What should I have to do in this case

regards

Nimish
 
 View user's profile Send private message  
Reply with quote Back to top
nimish
PostPosted: Oct 11, 2008 - 10:45 AM
Newbie


Joined: Jun 10, 2007
Posts: 16


I seen that after excuting
cd /config/gpio
mkdir leds
cd leds
echo 1 > gpio_id
echo 0xff > pin_mask
echo 0xff > oe_mask
echo 1 > enabled
cat /dev/urandom > /dev/gpio0


this I am able to creat /dev/gpio0 and then C program is running.

can you tell me how I can run all together from C

best regards

Nimish
 
 View user's profile Send private message  
Reply with quote Back to top
squidgit
PostPosted: Oct 12, 2008 - 07:29 AM
Raving lunatic


Joined: Sep 14, 2003
Posts: 4228
Location: Queanbeyan, Australia

You must execute all those above shell commands from C. The /dev/gpio0 file will not exist until the "echo 1 > enabled" bit.

You can either call "echo" from within C using the execute() function or use open/write/close.

-S.

_________________
Blag: http://www.niasdigital.com/blag
 
 View user's profile Send private message  
Reply with quote Back to top
nimish
PostPosted: Oct 13, 2008 - 07:59 AM
Newbie


Joined: Jun 10, 2007
Posts: 16


Dear squidgit

Can you tell me how I can use PINGO game on stk1000

For Linux system I am using buildroot 2.2.0.

I think to detech GPIOs in BSP 2.0 atmel patched kernal. so that from start there is /dev/gpio0 is exist.

Can you tell me how I can do this?

One more thing As I see I have 4 GPIO connectors J1 , J2 , J3 , J6 the /dev/gpio0 is on J1 I connected LED connector to J3 and trying same thing to blink LED with

cd /config/gpio
mkdir leds
cd leds
echo 2 > gpio_id
echo 0xff > pin_mask
echo 0xff > oe_mask
echo 2 > enabled
cat /dev/urandom > /dev/gpio1

But this is not working can you guide me what is wrong in this


Best regards

Nimish
 
 View user's profile Send private message  
Reply with quote Back to top
squidgit
PostPosted: Oct 14, 2008 - 08:17 AM
Raving lunatic


Joined: Sep 14, 2003
Posts: 4228
Location: Queanbeyan, Australia

nimish wrote:
Dear squidgit

Can you tell me how I can use PINGO game on stk1000

For Linux system I am using buildroot 2.2.0.
You mean Pong? Have you seen http://www.avrfreaks.net/wiki/index.php ... pment/Pong ?
Quote:
I think to detech GPIOs in BSP 2.0 atmel patched kernal. so that from start there is /dev/gpio0 is exist.
Um, I think Pong takes care of all this. Do _not_ set up any /dev/gpio0 file or anything. If you do it'll conflict with what Pong tries to do.

Just make sure that the 10 way cable is correctly connected.
Quote:
One more thing As I see I have 4 GPIO connectors J1 , J2 , J3 , J6 the /dev/gpio0 is on J1 I connected LED connector to J3 and trying same thing to blink LED with

cd /config/gpio
mkdir leds
cd leds
echo 2 > gpio_id
echo 0xff > pin_mask
echo 0xff > oe_mask
echo 2 > enabled
cat /dev/urandom > /dev/gpio1
Seems fine (though generally you write '1' to enabled, though any non-zero number works). Donno sry.

-S.

_________________
Blag: http://www.niasdigital.com/blag
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits