新版本中断API函数

本文档提供了一个C语言示例,展示如何处理来自4位PIO外设按钮硬件中断的服务中断例程(ISR)。当按钮被按下时,ISR读取PIO的边沿捕获寄存器并将值存储到全局变量中。中断注册API函数的参数包括中断控制器ID、设备的硬件中断号、指向设备驱动实例的数据结构以及响应IRQ的ISR函数指针。
摘要由CSDN通过智能技术生成

C Example

Example 8–1 illustrates an ISR that services a hardware interrupt from a button
parallel I/O (PIO) component. This example is based on a Nios II system with a 4-bit PIO peripheral connected to push buttons. An IRQ is generated any time a button is pushed. The ISR code reads the PIO peripheral’s edge capture register and stores the value to a global variable. The address of the global variable is passed to the ISR in the context pointer.

ALT_ENHANCED_INTERRUPT_API_PRESENT被定义时,启用此版本的中断注册API函数

// Example 8–1. An ISR to Service a Button PIO Interrupt
#include "system.h"
#include "altera_avalon_pio_regs.h"
#include "alt_types.h"
#ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT
static void handle_button_interrupts(void* context)
#else
static void handle_button_interrupts(void* context, alt_u32 id)
#endif
{
/* Cast context to edge_capture's type.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值