From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31229 invoked by alias); 1 Oct 2007 14:28:42 -0000 Received: (qmail 31220 invoked by uid 22791); 1 Oct 2007 14:28:41 -0000 X-Spam-Check-By: sourceware.org Received: from londo.lunn.ch (HELO londo.lunn.ch) (80.238.139.98) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 01 Oct 2007 14:28:39 +0000 Received: from lunn by londo.lunn.ch with local (Exim 3.36 #1 (Debian)) id 1IcMG4-0006B4-00; Mon, 01 Oct 2007 16:28:28 +0200 Date: Mon, 01 Oct 2007 14:28:00 -0000 From: Andrew Lunn To: Rasmus Stougaard Cc: ecos-discuss@ecos.sourceware.org Message-ID: <20071001142828.GA22379@lunn.ch> Mail-Followup-To: Rasmus Stougaard , ecos-discuss@ecos.sourceware.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.16 (2007-06-11) X-IsSubscribed: yes Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Subject: Re: [ECOS] Problem reading buttons on AT91sam7s-ek X-SW-Source: 2007-10/txt/msg00008.txt.bz2 On Mon, Oct 01, 2007 at 02:27:32PM +0200, Rasmus Stougaard wrote: > Hi > > I am trying to read the state of the buttons on a AT91sam7s-ek > evaluation kit from atmel. > > I figure that something like: > > cyg_uint32 value; > HAL_ARM_AT91_GPIO_CFG_DIRECTION(AT91_GPIO_PA20, AT91_PIN_IN); > HAL_ARM_AT91_GPIO_CFG_PULLUP(AT91_GPIO_PA20, AT91_PIN_PULLUP_ENABLE); > HAL_ARM_AT91_GPIO_GET(AT91_GPIO_PA20, value); > trace(" AT91_GPIO_PA20 %d\n", value); > > Should configure the pin for input and print the current state of the > of the pin. In general that looks O.K. Have you tried the other 3 switches? One idea i have. Is the clock to the GPIO device enabled? Check bit AT91_PMC_PCER_PIOA in AT91_PMC_PCER. Without a clock you can do output. But to do input you need the clock enabled. Andrew -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss