Skip to content

Commit

Permalink
Got compilation to work on a Mac using a cross-compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
lehoff committed May 13, 2013
1 parent 4eb6392 commit 730ca1d
Show file tree
Hide file tree
Showing 12 changed files with 126 additions and 639 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ $(PIHWMLIB):
$(CC) $(CFLAGS) -c -lpthread -lerl_interface -lei lib/$@.c


build:
build: rebar_plugin
rebar compile

rebar_plugin: plugins/compile-deps/src/rebar_compiledeps_plugin.beam plugins/compile-deps/src/rebar_compiledeps_plugin.beam
erlc plugins/compile-deps/src/rebar_compiledeps_plugin.erl -o plugins/compile-deps/src/rebar_compiledeps_plugin.beam

build_sim:
rebar -D simulation_mode compile

Expand Down
6 changes: 3 additions & 3 deletions c_src/gpio_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include <string.h>
#include <ei.h>

#include "lib/port_comms.h"
#include "lib/pihwm.h"
#include "lib/pi_gpio.h"
#include <port_comms.h>
#include <pihwm.h>
#include <pi_gpio.h>

#define BUF_SIZE 128

Expand Down
71 changes: 71 additions & 0 deletions c_src/gpio_test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* gpio_test.c -- Test of GPIO output.
Copyright (C) 2012 Omer Kilic
Copyright (C) 2012 Embecosm Limited
Contributor Omer Kilic <omerkilic@gmail.com>
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
This file is part of pihwm.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>. */

#include <stdio.h>

#include <pihwm.h>
#include <pi_gpio.h>

#define BTN0 17
#define BTN1 22
#define LED0 23
#define LED1 24

int
main (void)
{
unsigned int val, i;

printf("main() start\n");

gpio_init(LED0, OUTPUT);
gpio_init(LED1, OUTPUT);
gpio_init(BTN0, INPUT);
gpio_init(BTN1, INPUT);

printf("Pushbuttons:\n");
for (i = 0; i < 10; i++)
{
val = gpio_read(BTN0);
printf(" GPIO%d: %d ", BTN0, val);
val = gpio_read(BTN1);
printf("GPIO%d: %d\n", BTN1, val);

gpio_write(LED0, HIGH);
gpio_write(LED1, HIGH);
sleep(1);
gpio_write(LED0, LOW);
gpio_write(LED1, LOW);
sleep(1);
}

gpio_release(LED0);
gpio_release(LED1);
gpio_release(BTN0);
gpio_release(BTN1);

printf("main() end\n");

return 0;
}

Loading

0 comments on commit 730ca1d

Please sign in to comment.