Glomation
 
Advanced Search
Welcome, Guest. Please login or register.

Login with username, password and session length
May 20, 2012, 02:29:45 AM
News: Glomation introduced new wireless ready low cost GESBC-9260S
Pages: [1]
Topic Tools  
Read July 28, 2011, 10:31:44 AM #0
AwareWolf

Basics for accessing peripherals from code

I need help with the very basics of using this Glomation board. I am fairly new to developing apps that run in the context of Linux on an "embedded" controller, so I'm not sure if I'm even asking the right questions, but:

To access (read/write) the GPIO pins, e.g. to toggle an LED, would I be writing to a device driver, or accessing the processor registers directly, as if there were no OS?

Is there sample code somewhere to give me a clue how to do this? I know on the Glomation support site there are code samples, but they are for a different board/processor. For what it's worth, those examples seem to be hitting the processor registers directly, or am I mistaken about that?
 
Read July 28, 2011, 05:34:31 PM #1
admin

Re: Basics for accessing peripherals from code

The Linux kernel 2.6.30 and up includes GPIO drivers.  Writing hardware registers from user space application is not safe.  Please upgrade to newer kernel and use the GPIO driver as shown here, https://www.ridgerun.com/developer/wiki/index.php/How_to_use_GPIO_signals

The GPIO lines may require allocation in the board init code as following to ensure proper operation,

   at91_set_GPIO_periph(AT91_PIN_PB0, 1);
   at91_set_GPIO_periph(AT91_PIN_PB1, 1);
   at91_set_GPIO_periph(AT91_PIN_PB2, 1);
   at91_set_GPIO_periph(AT91_PIN_PB3, 1);
   at91_set_GPIO_periph(AT91_PIN_PB8, 1);
   at91_set_GPIO_periph(AT91_PIN_PB9, 1);
   at91_set_GPIO_periph(AT91_PIN_PC4, 1);
   at91_set_GPIO_periph(AT91_PIN_PC5, 1);
   at91_set_GPIO_periph(AT91_PIN_PC6, 1);
   at91_set_GPIO_periph(AT91_PIN_PC7, 1);

in file arch/arm/mach-at91/board-sam9260ek.c
 
Read August 01, 2011, 07:10:19 AM #2
AwareWolf

Re: Basics for accessing peripherals from code

OK, thanks.

How do I access the GPIO pins if I don't upgrade to 2.6.30? The board came with 2.6.27.4. Does this version not have GPIO drivers?
 
Read August 01, 2011, 08:28:45 AM #3
admin

Re: Basics for accessing peripherals from code

Direct GPIO control register manipulation can be used to control the GPIO from user space if GPIO driver is not available.  But it is not recommended.

It's better to upgrade the kerenl to 2.6.30 and higher with built-in GPIO support.
 
Pages: [1]
Jump to:  

Theme Update by Runic Warrior Originally created by m3talc0re