<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://elinux.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://elinux.org/index.php?title=Rpi_Datasheet_751_GPIO_Registers&amp;feed=atom&amp;action=history</id>
		<title>Rpi Datasheet 751 GPIO Registers - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://elinux.org/index.php?title=Rpi_Datasheet_751_GPIO_Registers&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://elinux.org/index.php?title=Rpi_Datasheet_751_GPIO_Registers&amp;action=history"/>
		<updated>2013-05-21T18:26:13Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.21alpha</generator>

	<entry>
		<id>http://elinux.org/index.php?title=Rpi_Datasheet_751_GPIO_Registers&amp;diff=138830&amp;oldid=prev</id>
		<title>Phatina at 10:48, 10 June 2012</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/index.php?title=Rpi_Datasheet_751_GPIO_Registers&amp;diff=138830&amp;oldid=prev"/>
				<updated>2012-06-10T10:48:36Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr style='vertical-align: top;'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 10:48, 10 June 2012&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 57:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 57:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160; &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160; &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; * You are about to change the GPIO settings of your computer.&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; *&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;/&lt;/ins&gt;* You are about to change the GPIO settings of your computer.&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; *&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;#160; &lt;/del&gt;* Mess this up and it will stop working!&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;  *&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;#160;  &lt;/ins&gt;* Mess this up and it will stop working!&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;  *&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;#160; &lt;/del&gt;* It might be a good idea to 'sync' before running this program&amp;#160; &amp;#160; &amp;#160; &amp;#160; *&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;#160;  &lt;/ins&gt;* It might be a good idea to 'sync' before running this program&amp;#160; &amp;#160; &amp;#160; &amp;#160; *&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;#160; &lt;/del&gt;* so at least you still have your code changes written to the SD-card! *&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;#160;  &lt;/ins&gt;* so at least you still have your code changes written to the SD-card! *&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;/&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;#160;  &lt;/del&gt;// Set GPIO pins 7-11 to output&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;#160; &lt;/ins&gt;// Set GPIO pins 7-11 to output&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; for (g=7; g&amp;lt;=11; g++)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; for (g=7; g&amp;lt;=11; g++)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; {&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Phatina</name></author>	</entry>

	<entry>
		<id>http://elinux.org/index.php?title=Rpi_Datasheet_751_GPIO_Registers&amp;diff=100010&amp;oldid=prev</id>
		<title>Turbo-Frambozenbier at 18:57, 18 February 2012</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/index.php?title=Rpi_Datasheet_751_GPIO_Registers&amp;diff=100010&amp;oldid=prev"/>
				<updated>2012-02-18T18:57:18Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr style='vertical-align: top;'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 18:57, 18 February 2012&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 132:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 132:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;} // setup_io&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;} // setup_io&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;{{Template:Raspberry Pi}}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key elinux:diff:version:1.11a:oldid:99932:newid:100010 --&gt;
&lt;/table&gt;</summary>
		<author><name>Turbo-Frambozenbier</name></author>	</entry>

	<entry>
		<id>http://elinux.org/index.php?title=Rpi_Datasheet_751_GPIO_Registers&amp;diff=99932&amp;oldid=prev</id>
		<title>Turbo-Frambozenbier: Rpi Datasheet 751 GPIO Registers</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/index.php?title=Rpi_Datasheet_751_GPIO_Registers&amp;diff=99932&amp;oldid=prev"/>
				<updated>2012-02-18T18:43:25Z</updated>
		
		<summary type="html">&lt;p&gt;Rpi Datasheet 751 GPIO Registers&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr style='vertical-align: top;'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 18:43, 18 February 2012&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Code Example&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;Code Example&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;How to access GPIO registers from C-code on the Raspberry-Pi&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;'''&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;//&amp;#160; How to access GPIO registers from C-code on the Raspberry-Pi&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;//&amp;#160; How to access GPIO registers from C-code on the Raspberry-Pi&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Turbo-Frambozenbier</name></author>	</entry>

	<entry>
		<id>http://elinux.org/index.php?title=Rpi_Datasheet_751_GPIO_Registers&amp;diff=99926&amp;oldid=prev</id>
		<title>Turbo-Frambozenbier: Created page with &quot;Code Example &lt;pre&gt; //  How to access GPIO registers from C-code on the Raspberry-Pi //  Example program //  15-January-2012 //  Dom and Gert  // Access from ARM Running Linux  #d...&quot;</title>
		<link rel="alternate" type="text/html" href="http://elinux.org/index.php?title=Rpi_Datasheet_751_GPIO_Registers&amp;diff=99926&amp;oldid=prev"/>
				<updated>2012-02-18T18:42:34Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;Code Example &amp;lt;pre&amp;gt; //  How to access GPIO registers from C-code on the Raspberry-Pi //  Example program //  15-January-2012 //  Dom and Gert  // Access from ARM Running Linux  #d...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Code Example&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//  How to access GPIO registers from C-code on the Raspberry-Pi&lt;br /&gt;
//  Example program&lt;br /&gt;
//  15-January-2012&lt;br /&gt;
//  Dom and Gert&lt;br /&gt;
&lt;br /&gt;
// Access from ARM Running Linux&lt;br /&gt;
&lt;br /&gt;
#define BCM2708_PERI_BASE        0x20000000&lt;br /&gt;
#define GPIO_BASE                (BCM2708_PERI_BASE + 0x200000) /* GPIO controller */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;dirent.h&amp;gt;&lt;br /&gt;
#include &amp;lt;fcntl.h&amp;gt;&lt;br /&gt;
#include &amp;lt;assert.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/mman.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/types.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/stat.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#define PAGE_SIZE (4*1024)&lt;br /&gt;
#define BLOCK_SIZE (4*1024)&lt;br /&gt;
&lt;br /&gt;
int  mem_fd;&lt;br /&gt;
char *gpio_mem, *gpio_map;&lt;br /&gt;
char *spi0_mem, *spi0_map;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// I/O access&lt;br /&gt;
volatile unsigned *gpio;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// GPIO setup macros. Always use INP_GPIO(x) before using OUT_GPIO(x) or SET_GPIO_ALT(x,y)&lt;br /&gt;
#define INP_GPIO(g) *(gpio+((g)/10)) &amp;amp;= ~(7&amp;lt;&amp;lt;(((g)%10)*3))&lt;br /&gt;
#define OUT_GPIO(g) *(gpio+((g)/10)) |=  (1&amp;lt;&amp;lt;(((g)%10)*3))&lt;br /&gt;
#define SET_GPIO_ALT(g,a) *(gpio+(((g)/10))) |= (((a)&amp;lt;=3?(a)+4:(a)==4?3:2)&amp;lt;&amp;lt;(((g)%10)*3))&lt;br /&gt;
&lt;br /&gt;
#define GPIO_SET *(gpio+7)  // sets   bits which are 1 ignores bits which are 0&lt;br /&gt;
#define GPIO_CLR *(gpio+10) // clears bits which are 1 ignores bits which are 0&lt;br /&gt;
&lt;br /&gt;
void setup_io();&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char **argv)&lt;br /&gt;
{ int g,rep;&lt;br /&gt;
&lt;br /&gt;
  // Set up gpi pointer for direct register access&lt;br /&gt;
  setup_io();&lt;br /&gt;
&lt;br /&gt;
  // Switch GPIO 7..11 to output mode&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
  * You are about to change the GPIO settings of your computer.          *&lt;br /&gt;
  * Mess this up and it will stop working!                               *&lt;br /&gt;
  * It might be a good idea to 'sync' before running this program        *&lt;br /&gt;
  * so at least you still have your code changes written to the SD-card! *&lt;br /&gt;
   // Set GPIO pins 7-11 to output&lt;br /&gt;
  for (g=7; g&amp;lt;=11; g++)&lt;br /&gt;
  {&lt;br /&gt;
    INP_GPIO(g); // must use INP_GPIO before we can use OUT_GPIO&lt;br /&gt;
    OUT_GPIO(g);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  for (rep=0; rep&amp;lt;10; rep++)&lt;br /&gt;
  {&lt;br /&gt;
     for (g=7; g&amp;lt;=11; g++)&lt;br /&gt;
     {&lt;br /&gt;
       GPIO_SET = 1&amp;lt;&amp;lt;g;&lt;br /&gt;
       sleep(1);&lt;br /&gt;
     }&lt;br /&gt;
     for (g=7; g&amp;lt;=11; g++)&lt;br /&gt;
     {&lt;br /&gt;
       GPIO_CLR = 1&amp;lt;&amp;lt;g;&lt;br /&gt;
       sleep(1);&lt;br /&gt;
     }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
&lt;br /&gt;
} // main&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//&lt;br /&gt;
// Set up a memory regions to access GPIO&lt;br /&gt;
//&lt;br /&gt;
void setup_io()&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   /* open /dev/mem */&lt;br /&gt;
   if ((mem_fd = open(&amp;quot;/dev/mem&amp;quot;, O_RDWR|O_SYNC) ) &amp;lt; 0) {&lt;br /&gt;
      printf(&amp;quot;can't open /dev/mem \n&amp;quot;);&lt;br /&gt;
      exit (-1);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   /* mmap GPIO */&lt;br /&gt;
&lt;br /&gt;
   // Allocate MAP block&lt;br /&gt;
   if ((gpio_mem = malloc(BLOCK_SIZE + (PAGE_SIZE-1))) == NULL) {&lt;br /&gt;
      printf(&amp;quot;allocation error \n&amp;quot;);&lt;br /&gt;
      exit (-1);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // Make sure pointer is on 4K boundary&lt;br /&gt;
   if ((unsigned long)gpio_mem % PAGE_SIZE)&lt;br /&gt;
     gpio_mem += PAGE_SIZE - ((unsigned long)gpio_mem % PAGE_SIZE);&lt;br /&gt;
&lt;br /&gt;
   // Now map it&lt;br /&gt;
   gpio_map = (unsigned char *)mmap(&lt;br /&gt;
      (caddr_t)gpio_mem,&lt;br /&gt;
      BLOCK_SIZE,&lt;br /&gt;
      PROT_READ|PROT_WRITE,&lt;br /&gt;
      MAP_SHARED|MAP_FIXED,&lt;br /&gt;
      mem_fd,&lt;br /&gt;
      GPIO_BASE&lt;br /&gt;
   );&lt;br /&gt;
&lt;br /&gt;
   if ((long)gpio_map &amp;lt; 0) {&lt;br /&gt;
      printf(&amp;quot;mmap error %d\n&amp;quot;, (int)gpio_map);&lt;br /&gt;
      exit (-1);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // Always use volatile pointer!&lt;br /&gt;
   gpio = (volatile unsigned *)gpio_map;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
} // setup_io&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Turbo-Frambozenbier</name></author>	</entry>

	</feed>