zoukankan      html  css  js  c++  java
  • HPS 访问 FPGA 方法之五—— 通过FPGA 中断访问

    在组件的基础属性栏中将 width 设置为 4,确保 Direction

    为 Input。在 Edge capture register 属性栏中,选中 Synchronously capture,
    并将 Edge Type 设置为 FALLING。在 Interrupt 属性栏中,选中 Generate IRQ,
    并将 IRQ Type 设置为 Edge。点击 Finish 完成 Button 组件的配置 

     

     1 #include <linux/kernel.h>
     2 #include <linux/module.h>
     3 #include <linux/init.h>
     4 #include <linux/interrupt.h>
     5 #include <asm/io.h>
     6 #include "../address_map_arm.h"
     7 #include "../interrupt_ID.h"
     8 void * LW_virtual; // Lightweight bridge base address
     9 volatile int *LEDR_ptr, *KEY_ptr; // virtual addresses
    10 
    11 irq_handler_t irq_handler(int irq, void *dev_id, struct pt_regs *regs)
    12 {
    13 *LEDR_ptr = *LEDR_ptr + 1;
    14 // Clear the Edgecapture register (clears current interrupt)
    15 *(KEY_ptr + 3) = 0xF;
    16  return (irq_handler_t) IRQ_HANDLED;
    17 }
    18 static int __init initialize_pushbutton_handler(void)
    19 {
    20 int value;
    21 // generate a virtual address for the FPGA lightweight bridge
    22 LW_virtual = ioremap_nocache (LW_BRIDGE_BASE, LW_BRIDGE_SPAN);
    23 
    24 LEDR_ptr = LW_virtual + LEDR_BASE; // virtual address for LEDR port
    25 *LEDR_ptr = 0x200; // turn on the leftmost light
    26 
    27 KEY_ptr = LW_virtual + KEY_BASE; // virtual address for KEY port
    28 *(KEY_ptr + 3) = 0xF; // Clear the Edgecapture register
    29 *(KEY_ptr + 2) = 0xF; // Enable IRQ generation for the 4 buttons
    30 
    31 // Register the interrupt handler.
    32 value = request_irq (KEYS_IRQ, (irq_handler_t) irq_handler, IRQF_SHARED,
    33 "pushbutton_irq_handler", (void *) (irq_handler));
    34 return value;
    35 }
    36 static void __exit cleanup_pushbutton_handler(void)
    37 {
    38 *LEDR_ptr = 0; // Turn off LEDs and de-register irq handler
    39 iounmap (LW_virtual);
    40 free_irq (KEYS_IRQ, (void*) irq_handler);
    41 }
    42 module_init(initialize_pushbutton_handler);
    43 module_exit(cleanup_pushbutton_handler);

     

     

  • 相关阅读:
    SAP&nbsp;GUI登陆&nbsp;安全性提示&nbsp;&nbsp;出现乱码
    获取sap登陆用户名的中文描述
    jQuery页面替换+php代码实现搜索后分页
    Linux下更新Git
    DirectoryInfo.GetFiles 方法 (String, SearchOption)
    WF中创建持久化服务和跟踪服务数据库
    ConfigurationSection自定义配置的使用
    微软企业库5.0系统(一):使用缓存 Microsoft.Practices.EnterpriseLibrary.Caching(初级篇)
    HttpWebRequest传输Cookie
    jquery优化规则
  • 原文地址:https://www.cnblogs.com/DoreenLiu/p/14109680.html
Copyright © 2011-2022 走看看