public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Re: How to use TWR-K60N512's GPIO in user app
       [not found] <20130517003836.11ECF560589@webmail.sinamail.sina.com.cn>
@ 2013-05-17 13:13 ` Ilija Kocho
  0 siblings, 0 replies; only message in thread
From: Ilija Kocho @ 2013-05-17 13:13 UTC (permalink / raw)
  To: xfce; +Cc: ecos-discuss

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-05-17 13:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20130517003836.11ECF560589@webmail.sinamail.sina.com.cn>
2013-05-17 13:13 ` [ECOS] Re: How to use TWR-K60N512's GPIO in user app Ilija Kocho

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).