22366 views|0 replies

139

Posts

0

Resources
The OP
 

Sinlinx A33 Development Board Linux Interrupt Programming 1--- Principle Description [Copy link]

The experimental goal of this section is to achieve the key trigger interrupt terminal display key release or press Experimental platform Sinlinx A33 development board [attach]401140 [/attach] step1 Look at the schematic diagram, the three buttons are connected to the LRADC0 pin, and the voltage is determined by which key is pressed. step2 The kernel about the CPU interrupt number The irq interrupt number in the linux interrupt registration function is not the physical number of the chip, but is defined by the chip manufacturer in the architecture-related header file when porting the Linux system. In the kernel source code, the name is generally irqs.h. Open vim /root/work/sinlinx/a33/lichee/linux-3.4/arch/arm/mach-sunxi/include/mach/irqs.h Here is Allwinner A33#include "sun8i/irqs-sun8iw5p1.h" Open vim /root/work/sinlinx/a33/lichee/linux-3.4/arch/arm/mach-sunxi/include/mach/sun8i/irqs-sun8iw5p1.h If you don’t know which platform the development board uses, just look for it in .config From this, find the interrupt number of the chip in the kernel step 3 Briefly introduce the functions used by the interrupt driver View irq.h , Helvetica, sans-serif] * 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 [ color=#323232] * * The fields here need to overlay the ones in irq_desc until we * cleaned up the direct references and switched everything over to [ font=Arial, Helvetica, sans-serif] * irq_data. */ struct irq_data { [color =#323232] unsigned int irq; [ size=13px] unsigned long hwirq; [ i] unsigned int node; unsigned int state_use_accessors; [ color=#323232] struct irq_chip *chip; [color=#323232 ] struct irq_domain *domain; [size= 13px] void *handler_data; void *chip_data; [ color=#323232] struct msi_desc *msi_desc; [color=#323232 ]#ifdef CONFIG_SMP cpumask_var_t affinity; #endif [color= #323232]}; struct irqaction The structure is in /root/work/sinlinx/a33/lichee/linux-3.4/[ color=#323232]include/linux/interrupt.h /** [color =#323232] * 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 */ [color= #323232]struct irqaction { irq_handler_t handler; Interrupt service function 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; [ color=#323232] unsigned long thread_mask; const char *name;[/ i] struct proc_dir_entry *dir; } ____cacheline_internodealigned_in_smp; There are many in interrupt.h Functions related to interrupts example: request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char *name, void *dev) FunctionRegister an interrupt service function with the kernel. When an interrupt with interrupt number irq occurs When the handler pointer function is executed. void free_irq(unsigned int irq, void *dev_id) FunctionDelete an interrupt structure from the kernel interrupt list void disable_irq(unsigned int irq) [ size=5]FunctionDisables the specified interrupt and waits for the interrupt service function to finish running before returning. Called outside the interrupt function,[/ color] Cannot be called in an interrupt service routine. void disable_irq_nosync(unsigned int irq) Function[color=# ff0000] Disable the specified interrupt, do not wait for the interrupt service function to end, and return immediately after calling this function. Interrupt service function can be [color=#ff0000 ]. void enable_irq(unsigned int irq) Function Enable the specified interrupt Macro local_save_flags(flags)[/b FunctionDisable all interrupts of this CPU and save CPU status information. Macro local_irq_disable() Function [color =#ff0000]Disable all interrupts of this CPU Linux kernel and GPIO port related kernel API example: static inline int gpio_get_value(unsigned int gpio) FunctionGet the level status of the specified IO port[ /color] Return IO level status, non-0: high level, 0: low level static inline void gpio_set_value(unsigned int gpio,int value) FunctionSet the level state of the gpio port to value Return the IO level state, non-0: represents high level, 0 represents low level static inline int gpio_to_irq(unsigned int gpio) FunctionGet the external interrupt number that appears on this IO through the gpio port number Return the corresponding external interrupt number on this IO step 4About Linux interrupt sharing Shared interrupt refers to the situation where multiple devices share an interrupt line. When an interrupt arrives, all interrupt handlers that share this interrupt will be traversed until Returns IRQ_HANDLED when an interrupt service function is called.

1.PNG (45.42 KB, downloads: 0)

1.PNG
This post is from Embedded System

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list