搜索
bottom↓
回复: 8

【征文活动】Working GPIO input interrupt demo for FRDM-K22F with Keniti...

[复制链接]

出0入0汤圆

发表于 2015-3-17 05:37:49 | 显示全部楼层 |阅读模式
本帖最后由 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 pressed  or 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 work  until the configuation in project options->C/C++->Include path,Linker->Scatter File, Linker->Misc controls is correct.


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

出0入0汤圆

发表于 2015-3-17 08:51:42 | 显示全部楼层
兄弟够狠,这是英语作文么?

出0入0汤圆

 楼主| 发表于 2015-3-17 09:15:23 | 显示全部楼层
ccrt 发表于 2015-3-17 08:51
兄弟够狠,这是英语作文么?

玩玩而已。Kenitis很难玩,芯片功能强大而复杂,驱动程序五花八门,连个FRDM的开关输入中断例程都没有。昨晚照着QSP Demo折腾了两小时都没搞定。后来灵机一动,参照LedPin的方式,总算弄出来了。今天早上睡不着,就照社区的例子做了一个demo。英文丢了多年,看起来惨不忍睹,惭愧惭愧!

出0入0汤圆

发表于 2015-3-17 09:45:14 | 显示全部楼层
英文征文大赛

出0入0汤圆

发表于 2015-3-17 12:54:48 | 显示全部楼层
这也可以的啊!?

出0入0汤圆

发表于 2015-3-17 14:51:40 | 显示全部楼层
bailao99 发表于 2015-3-17 09:15
玩玩而已。Kenitis很难玩,芯片功能强大而复杂,驱动程序五花八门,连个FRDM的开关输入中断例程都没有。 ...

有戏,有戏!!!

出0入0汤圆

发表于 2015-3-17 15:47:52 | 显示全部楼层
看到这些我是没发混了,猴不住了!一直都还没上手这个32位机!看来还得拼拼命才行!

出0入0汤圆

发表于 2015-3-22 09:45:39 | 显示全部楼层
bailao99 发表于 2015-3-17 09:15
玩玩而已。Kenitis很难玩,芯片功能强大而复杂,驱动程序五花八门,连个FRDM的开关输入中断例程都没有。 ...

同感,KDS难玩,Kenitis还不错

出0入0汤圆

发表于 2015-4-8 14:13:47 | 显示全部楼层
非常感谢你关于Kinetis的经验分享 !
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-5-3 04:32

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表