Skip to content

Commit

Permalink
examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyrog committed Jun 10, 2013
1 parent 611d1fb commit 8647048
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,38 @@ The interface has the following functions for accessing several pins using a mas
<li>clr_mask</li>
</ul>

### Example

An example on how to setup a gpio interrupt.

gpio:set_interrupt(25, falling),
receive
{gpio_interrupt, 0, 25, Value} ->
io:format("pin 25, high to low\n")
end.

Given that the gpio application is started with the following config
in environment (raspberry pi mode):

{gpio, [{options, [{chipset,bcm2835}]}]}

Then we can do some fast gpio access

gpio:init_direct(24),
gpio:set_direction(24, low),
gpio:set(24),
timer:sleep(1010),
gpio:clr(24),
timer:sleep(2210),
ok.

This code will init pin 24 in direct access mode, using io registers
instead of the normal linux /sys/class/gpio file interface. Then
set pin 24 in output mode that default to a low output value. After that
the pin is set to high for 1010 ms and then set to low again.
(This is the power-on sequence for a SIM900 GPRS module).


For details see the generated documentation.

### Documentation
Expand Down

0 comments on commit 8647048

Please sign in to comment.