From owner-freebsd-ports@FreeBSD.ORG Mon Nov 25 16:00:06 2013 Return-Path: Delivered-To: ports@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A4CB1B7 for ; Mon, 25 Nov 2013 16:00:06 +0000 (UTC) Received: from be-well.ilk.org (be-well.ilk.org [23.30.133.173]) by mx1.freebsd.org (Postfix) with ESMTP id 7EC9C23DB for ; Mon, 25 Nov 2013 16:00:06 +0000 (UTC) Received: from lowell-desk.lan (lowell-desk.lan [172.30.250.41]) by be-well.ilk.org (Postfix) with ESMTP id 2451433C1E; Mon, 25 Nov 2013 10:59:55 -0500 (EST) Received: by lowell-desk.lan (Postfix, from userid 1147) id 91AC039830; Mon, 25 Nov 2013 10:59:53 -0500 (EST) From: Lowell Gilbert To: Alexander Leidinger Subject: Re: Porting a software which uses INP_GPIO? References: <20131121214359.000006f6@unknown> <44bo1d5u3z.fsf@be-well.ilk.org> <20131122225042.00007aad@unknown> Date: Mon, 25 Nov 2013 10:59:53 -0500 In-Reply-To: <20131122225042.00007aad@unknown> (Alexander Leidinger's message of "Fri, 22 Nov 2013 22:50:42 +0100") Message-ID: <44pppo79qe.fsf@lowell-desk.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain Cc: ports@FreeBSD.org X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list Reply-To: ports@FreeBSD.org List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Nov 2013 16:00:06 -0000 Alexander Leidinger writes: > On Thu, 21 Nov 2013 16:21:20 -0500 > Lowell Gilbert wrote: > >> Alexander Leidinger writes: >> >> > I try to compile a software on FreeBSD which wants to use INP_GPIO, >> > OUTP_GPIO and some oder *GPIO* things. >> > >> > A quick googling shows me some raspberry pi sites. Is this something >> > linux-specific (so that I can forget this software on FreeBSD as >> > long as we don't gain something similar)? >> > >> > Searching for gpio in names of ports didn't show a hit and in the >> > basesystem includes I can't find it either. >> >> GPIO is a way to do pin assignments for a chip package at run-time. I >> use it on embedded platforms all the time, but it isn't normally >> available on a PC. There's a gpioctl(1) that should be able to set the >> a pin for input or output, as those flags indicate, or >> programmatically I guess it would be GPIO_PIN_INPUT or >> GPIO_PIN_OUTPUT in /usr/include/sys/gpio.h but again, you need to >> have the hardware for it. > > I have the hardware. Currently it is accessed from an old Laptop with > the Windows-binary of the program. I would like to replace the Laptop > and use a FreeBSD version of the program. > > The code in question is: > ---snip--- > const int banks[4]={18,23,24,25}; > [...] > for(i=0;i<4;i++) > { > INP_GPIO(banks[i]); > OUT_GPIO(banks[i]); > if(i==bank) > { > GPIO_SET = 1 << banks[i]; // enable bank > } > else > { > GPIO_CLR = 1 << banks[i];// disable bank > } > } > ---snip--- > > When looking at sys/gpio.h, I have no idea how I shall translate the > above into something FreeBSD understands. Could you please explain how > the above translates into "FreeBSD-gpio-speak"? Not offhand, no; that would take some work, and would require some knowledge of the hardware devices installed, and preferably their wiring configurations as well. It would be a reasonable guess that INP_GPIO is equivalent to a GPIOSETCONFIG with a state structure that (at least) includes GPIO_PIN_INPUT in its flags. But the code seems to be operating on whole banks at once, no just individual pins.