【征文活动】Working GPIO input interrupt demo for FRDM-K22F with Keniti...
本帖最后由 bailao99 于 2015-3-17 13:13 编辑Working GPIO input interrupt demo for FRDM-K22F with Kenitis SDK V1.1.0
The following (after the "- - - - - -") is debugged code for showing SW2, and SW3 pressedor not on the FRDM-K22F module. It is based on Kenitis SDK V1.1.0. It is built with Keil V5.13 and downloaded with JLINK SWD mode.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#include <string.h>
#include <stdio.h>
#include "fsl_uart_hal.h"
#include "gpio_pins.h"
#include "fsl_clock_manager.h"
#include "fsl_port_hal.h"
#include "board.h"
volatile uint8_t switch_2_isr_entered = 0; // Variable to indicate that the SW2
volatile uint8_t switch_3_isr_entered = 0; // Variable to indicate that the SW3
gpio_input_pin_user_config_t Sw2Pins =
{
.pinName = kGpioSW1,
.config.isPullEnable = false,
.config.pullSelect = kPortPullUp,
.config.isPassiveFilterEnabled = false,
.config.interrupt = kPortIntFallingEdge,
};
gpio_input_pin_user_config_t Sw3Pins =
{
.pinName = kGpioSW2,
.config.isPullEnable = false,
.config.pullSelect = kPortPullUp,
.config.isPassiveFilterEnabled = false,
.config.interrupt = kPortIntFallingEdge,
};
int main(void)
{
// init the hardware board
hardware_init();
// init the debug uart
dbg_uart_init();
/* PB17(Sw3Pin),PC1(Sw2Pin) as GPIO */
PORT_HAL_SetMuxMode(PORTB_BASE,17u,kPortMuxAsGpio);
PORT_HAL_SetMuxMode(PORTC_BASE,0u,kPortMuxAsGpio);
// Initialize the GPIO pins
GPIO_DRV_InputPinInit(&Sw2Pins);
GPIO_DRV_InputPinInit(&Sw3Pins);
printf("\nHello World!\n");
for (;;)
{
if(1==switch_2_isr_entered)
{
switch_2_isr_entered = 0;
printf("\nSW2 Pressed!\n");
}
if(1==switch_3_isr_entered)
{
switch_3_isr_entered = 0;
printf("\nSW3 Pressed!\n");
}
}
return 0;
}
Prepare the Demo
1. Connect a USB cable between the PC host and the OpenSDA USB port on FRDM-K22F.
2. Open a serial terminal with these settings:
• 115200 baud rate
• 8 data bits
• No parity
• One stop bit
• No flow control
3. Download the program to FRDM-K22F board.
4. Either press the reset button on FRDM-K22F to begin running the demo.
5. Press SW2 switch or SW3 switch to check the result.
Here is output.
Attention: My KSDK V1.1.0 path is D:\KSDK_1.1.0. If your KSDK V1.1.0 path is not agree with me, the demo will not workuntil the configuation in project options->C/C++->Include path,Linker->Scatter File, Linker->Misc controls is correct.
兄弟够狠,这是英语作文么? ccrt 发表于 2015-3-17 08:51
兄弟够狠,这是英语作文么?
玩玩而已。Kenitis很难玩,芯片功能强大而复杂,驱动程序五花八门,连个FRDM的开关输入中断例程都没有。昨晚照着QSP Demo折腾了两小时都没搞定。后来灵机一动,参照LedPin的方式,总算弄出来了。今天早上睡不着,就照社区的例子做了一个demo。英文丢了多年,看起来惨不忍睹,惭愧惭愧! 英文征文大赛{:titter:} 这也可以的啊!? bailao99 发表于 2015-3-17 09:15
玩玩而已。Kenitis很难玩,芯片功能强大而复杂,驱动程序五花八门,连个FRDM的开关输入中断例程都没有。 ...
有戏,有戏!!! 看到这些我是没发混了,猴不住了!一直都还没上手这个32位机!看来还得拼拼命才行! bailao99 发表于 2015-3-17 09:15
玩玩而已。Kenitis很难玩,芯片功能强大而复杂,驱动程序五花八门,连个FRDM的开关输入中断例程都没有。 ...
同感,KDS难玩,Kenitis还不错 非常感谢你关于Kinetis的经验分享 !
页:
[1]