public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Ilija Kocho <ilijak@siva.com.mk>
To: xfce@sina.com
Cc: ecos-discuss <ecos-discuss@sourceware.org>
Subject: [ECOS] Re: How to use TWR-K60N512's GPIO in user app
Date: Fri, 17 May 2013 13:13:00 -0000	[thread overview]
Message-ID: <51962CF9.3050607@siva.com.mk> (raw)
In-Reply-To: <20130517003836.11ECF560589@webmail.sinamail.sina.com.cn>

On 17.05.2013 02:38, xfce@sina.com wrote:
> Dear ilijak
> I want to use the TWR-K60N512's GPIO in my app.c
>
> below is some of my codes, and it can't work correctly,could you
> please tell me where is the bug,thanks.
>
> #include <cyg/hal/var_io.h> //gpio function header file
>
> //set the PORTA bit_19 and bit_11 as GPIO function
> #define KEY1_GPIO_ENABLE CYGHWR_HAL_KINETIS_PIN(A, 19,
> CYGHWR_HAL_KINETIS_PORT_PCR_MUX_GPIO,
> CYGHWR_HAL_KINETIS_PORT_PCR_PE_M) //KEY1
> #define LED1_GPIO_ENABLE CYGHWR_HAL_KINETIS_PIN(A, 11,
> CYGHWR_HAL_KINETIS_PORT_PCR_MUX_GPIO,
> CYGHWR_HAL_KINETIS_PORT_PCR_PE_M) //LED1
>
> //set the GPIO as INPUT and OUTPUT
> #define KEY1_INPUT_ENABLE CYGHWR_HAL_KINETIS_GPIO_PIN_DDR_IN(A, 19)
> #define LED1_OUTPUT_ENABLE CYGHWR_HAL_KINETIS_GPIO_PIN_DDR_OUT(A, 11)
>
> //get the input value
> #define GET_KEY1_VALUE CYGHWR_HAL_KINETIS_GPIO_GET_PIN(A, 19)
>
> //set the output high or low
> #define LED1_OUTPUT_H CYGHWR_HAL_KINETIS_GPIO_SET_PIN(A, 11)
> #define LED1_OUTPUT_L CYGHWR_HAL_KINETIS_GPIO_CLEAR_PIN(A, 11)
>
> //gpio test function
> void cyg_user_start(void)
> {
> // KEY1_GPIO_ENABLE;
> // LED1_GPIO_ENABLE;
> // KEY1_INPUT_ENABLE;
> // LED1_OUTPUT_ENABLE;
>
// CYGHWR_HAL_KINETIS_PIN() computes pin setting, but does not set a
PORT register.
// You need to call hal_set_pin_function();

// Example:

hal_set_pin_function(KEY1_GPIO_ENABLE);
// etc...

// HTH
// Ilija
> for(;;)
> {
> if(1==GET_KEY1_VALUE)
> {
> LED1_OUTPUT_H;
> }
> else
> {
> LED1_OUTPU_L;
> }
> }
> }
>

Note: When you post to eCos mailing lists use only plain text. HTML will
be rejected.

I hope this helps
Ilija

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

           reply	other threads:[~2013-05-17 13:13 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <20130517003836.11ECF560589@webmail.sinamail.sina.com.cn>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51962CF9.3050607@siva.com.mk \
    --to=ilijak@siva.com.mk \
    --cc=ecos-discuss@sourceware.org \
    --cc=xfce@sina.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).