a33 linux 硬解码_全志A33 lichee 开发板 Linux中断编程原理说明
开发平台
* 芯灵思SinlinxA33开发板
嵌入式linux 开发板交流 641395230
本节实验目标实现按键触发中断终端显示按键松开或按下 实验平台 芯灵思Sinlinx A33 开发板
step1 查看原理图,三个按键都连接到LRADC0引脚,通过判断电压大小来确定是按的哪个键。 step2 内核关于 CPU 的中断号linux 中断注册函数中的 irq 中断号并不是芯片物理上的编号,而是由芯片商在移植 Linux 系统时定在构架相 关的头文件中定义好的, 在内核源码中,名字一般是 irqs.h。 打开vim /root/work/sinlinx/a33/lichee/linux-3.4/arch/ARM/mach-sunxi/include/mach/irqs.h
这里全志A33 是#include "sun8i/irqs-sun8iw5p1.h" 打开vim /root/work/sinlinx/a33/lichee/linux-3.4/arch/arm/mach-sunxi/include/mach/sun8i/irqs-sun8iw5p1.h
不知道开发板用的哪个平台,直接在.config中找
由此找到芯片在内核中的中断号 step 3 简要介绍中断驱动要用到的函数 查看 irq.h 文件 里面有关于中断的函数结构体声明 /root/work/sinlinx/a33/lichee/linux-3.4/include/linux/irq.h
* struct irq_data - per irq and irq chip data passed down to chip functions
* @irq: interrupt number
* @hwirq: hardware interrupt number, local to the interrupt domain
* @node: node index useful for balancing
* @state_use_accessors: status information for irq chip functions.
* Use accessor functions to deal with it
* @chip: low level interrupt hardware access
* @domain: Interrupt translation domain; responsible for mapping
* between hwirq number and linux irq number.
* @handler_data: per-IRQ data for the irq_chip methods
* @chip_data: platform-specific per-chip private data for the chip
* methods, to allow shared chip implementations
* @msi_desc: MSI descriptor
* @affinity: IRQ affinity on SMP
*
* The fields here need to overlay the ones in irq_desc until we
* cleaned up the direct references and switched everything over to
* irq_data.
*/
struct irq_data {
unsigned int irq;
unsigned long hwirq;
unsigned int node;
unsigned int state_use_accessors;
struct irq_chip *chip;
struct irq_domain *domain;
void *handler_data;
void *chip_data;
struct msi_desc *msi_desc;
#ifdef CONFIG_SMP
cpumask_var_t affinity;
#endif
};
struct irqaction 结构体在 /root/work/sinlinx/a33/lichee/linux-3.4/include/linux/interrupt.h
/**
* struct irqaction - per interrupt action descriptor
* @handler: interrupt handler function
* @flags: flags (see IRQF_* above)
* @name: name of the device
* @dev_id: cookie to identify the device
* @percpu_dev_id: cookie to identify the device
* @next: pointer to the next irqaction for shared interrupts
* @irq: interrupt number
* @dir: pointer to the proc/irq/NN/name entry
* @thread_fn: interrupt handler function for threaded interrupts
* @thread: thread pointer for threaded interrupts
* @thread_flags: flags related to @thread
* @thread_mask: bitmask for keeping track of @thread activity
*/
struct irqaction {
irq_handler_t handler; 中断服务函数 handler
unsigned long flags;
void *dev_id;
void __percpu *percpu_dev_id;
struct irqaction *next;
int irq;
irq_handler_t thread_fn;
struct task_struct *thread;
unsigned long thread_flags;
unsigned long thread_mask;
const char *name;
struct proc_dir_entry *dir;
} ____cacheline_internodealigned_in_smp;
在 interrupt.h 中有许多和中断相干的函数 exmple:
request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char *name, void *dev) 功能 向内核注册一个中断服务函数,当发生中断号为 irq 的中断时候,会执行 handler 指针函数。
void free_irq(unsigned int irq, void *dev_id)
功能 从内核中断链表上删除一个中断结构 void disable_irq(unsigned int irq)
功能 关闭指定的中断,并等待中断服务函数运行结束后才会返回, 在中断函数外调用, 不能在中断服务程序中调用。 void disable_irq_nosync(unsigned int irq)
功能 关闭指定的中断,不等待中断服务函数结束,调用完这个函数立即返回。 可以中断服务函数 中调用。 void enable_irq(unsigned int irq)
功能 使能指定的中断 宏 local_save_flags(flags)
功能 禁止本 CPU 全部中断,并保存 CPU 状态信息。 宏local_irq_disable()
功能 禁止本 CPU 全部中断
Linux 内核和 GPIO 口相关的内核 API exmple:
static inline int gpio_get_value(unsigned int gpio)
功能 获取指定 IO 口的电平状态 返回 IO 电平状态,非 0:表示高电平 , 0 表示低电平
static inline void gpio_set_value(unsigned int gpio, int value)
功能 设置 gpio 口的电平状态为 value 返回 IO 电平状态,非 0:表示高电平 , 0 表示低电平
static inline int gpio_to_irq(unsigned int gpio)
功能 通过 gpio 口编号获得出现这个 IO 上的外部中断编号 返回 这个 IO 上对应的外部中断编号
step 4关于 Linux 中断共享 共享中断是指多个设备共享一根中断线的情况, 在中断到来时,会遍历共享此中断的所有中断处理程序, 直
到某一个中断服务函数时返回 IRQ_HANDLED
a33 linux 硬解码_全志A33 lichee 开发板 Linux中断编程原理说明相关推荐
- a33 linux 硬解码_全志A33 linux led驱动编程(附实测参考代码)
开发平台 开发平台 * 芯灵思SinlinxA33开发板 嵌入式linux 开发板交流 QQ:641395230 #实验原理 在芯灵思开发板上,没有led灯模块,只能通过引脚电平观察: 这里我选择LS ...
- a33 linux 硬解码_全志A33-修改linux kernel启动参数
开发板:A33,运行linux-3.4.39 主机:Ubuntu 14.04 ---------------------------------------------- 1. 修改kernel启动参 ...
- Linux移植:正点原子阿尔法IMX6ULL开发板Linux内核源码移植详细步骤(4.1.15版本内核)
Linux移植:正点原子阿尔法IMX6ULL开发板Linux内核源码移植详细步骤(4.1.15版本内核) 文章目录 Linux移植:正点原子阿尔法IMX6ULL开发板Linux内核源码移植详细步骤(4 ...
- linux 串口 loopback,友善NanoPC T2 4418开发板Linux下串口回环测试 -申嵌
注意事项:friendlycore系统下 UART3 对应的设备文件名是 /dev/ttyAMA3 实验目的:实现串口回环测试,即:自己给自己发数据,然后自己接收到自己发送的内容. 实验内容: 1. ...
- 基于全志A33开发板linux系统移植学习记录(Boot0)
基于全志A33开发板linux系统移植学习记录 第一章 Boot0基于ARMGCC的编译与修改 文章目录 基于全志A33开发板linux系统移植学习记录 前言 一.全志A33简介以及上电引导流程 二. ...
- 第一视角体验搭载全志T507-H的开发板MYD-YT507H开发板
如今车规级芯片市场潜力巨大,需求旺盛,芯片都在逐渐走向国产化.本文要介绍的主角是MYD-YT507H开发板,该开发板是米尔科技结合全志国产工业级平台CPU--全志T507-H芯片研制的CPU模组,全志 ...
- 全志r11_全志R328 Demo开发板;全志R333开发板/核心板;全志R11开发板/核心板;全志R16开发板/方案设计...
1.全志R328 Demo开发板 参数: 扫码可见详情信息: 2.全志R333开发板/核心板 硬件特征: 扫码可见详情信息: 3.全志R11开发板/核心板 硬件特征: 具体详情扫码可见: 4.全志R1 ...
- NUC980开发板Linux系统EC20模块 移植 串口 PPP拨号
NUC980开发板Linux系统EC20模块 移植 串口 PPP拨号 1. EC20模块连接 2. Linux内核配置 3. 交叉编译PPP 4. 拨号脚本 5. 进行拨号 1. EC20模块连接 在 ...
- firefly-rk3288j开发板--linux I2C实验之eeprom驱动
firefly-rk3288j开发板–linux I2C实验之eeprom驱动 1 准备工作 开发板:aio-rk3288j SDK版本:rk3288_linux_release_20210304 下 ...
最新文章
- ICML 2021刚刚做出了一个「艰难的决定」:将论文接收率直接砍掉10%
- Eclipse导入servlet项目报错
- 怎么用python制作简单的程序-神级程序员教你如何用python制作一个牛逼的外挂!...
- Fiddler抓包使用教程-基本功能介绍
- 【渝粤教育】国家开放大学2018年秋季 0692-22T化工设备机械基础 参考试题
- OpenJDK9 Hotspot :Zero 解释器 - BytecodeInterpreter
- bootstrap的表单验证 vue_分享几个基于Vue的UI库和开源项目
- ios调用系统的短信和发送邮件功能,实现短信分享邮件分享
- java基础-对象-练习集锦
- 2021-08-03 DISTINCT去重复操作
- Vulnerability Scanning Tools
- COSMOS认证咨询,Cosmo-天然产品标准以及Cosmo有机产品标准分为哪几大类
- 迷宫(深度优先搜索)
- 在阿里外包是一种什么样的体验?
- 软件测试(白盒测试与黑盒测试)
- 成功解决socket.timeout: The read operation timed out问题
- 使用UTF8编码将Excel转换为CSV
- Word文件解除限制编辑
- kafka-go源码解析一(Dialer)
- mapreduce 中文版 中文翻译