This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: 回复:[ECOS] Re: How to use TWR-K60N512's GPIO in user app


On 20.05.2013 13:48, xfce@sina.com wrote:
> Dear ilijak,
>
>     For the TWR-K60N512 target,If I want to set a GPIO for input, and how to set the input as pull up or pull down? Thanks 

As it suits you. If you have a button, normally it should be tied to the
opposite rail then the button. Then you don't need external resistor. If
you have external resistor than you need no pull.

HTH

Ilija


>
> ----- 原始邮件 -----
> 发件人:Ilija Kocho <ilijak@siva.com.mk>
> 收件人:xfce@sina.com
> 抄送人:ecos-discuss <ecos-discuss@sourceware.org>
> 主题:[ECOS] Re: How to use TWR-K60N512's GPIO in user app
> 日期:2013年05月17日 21点13分
> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]