A method of writing different interrupt service functions based on different class registration

Source: Internet
Author: User

One, the registration of a hardware interrupt service function Irq_handler, as a result of a hardware interrupt, the actual interruption of the service function of the total entrance.

void Intc_setup_irq (vector, priority, Irq_handler)

Second, interrupt service function Irq_handler entry, call different branches according to different conditions

void Irq_handler (void) {         get  ISR val         Switch(val)         {                   case  condition_1:                            call_service (condition_1)                   case condition_2:                            call_service (condition_2) ...                   ...         }}

Third, define a global function pointer, as "Interrupt Virtual service Routine", through the registration function, at different stages, register to perform different service functions.

void (*GLOBAL_VSR) (int condition);

Four, define the interrupt virtual service registration function Irq_register_service, change the actual point of GLOBAL_VSR, used to point to the current interrupt service function.

void irq_register_service (void (*CUR_VSR) (int)) {         = cur_vsr;}

V. Call_service function, Call_service actually invokes the current interrupt service function through GLOBAL_VSR.

void Call_service (condition) {         GLOBAL_VSR (condition);}

Key points of Use:

1, pay attention to Irq_register_service registration Interrupt virtual service function time!!

2, interrupt the virtual service function consistency??

A method of writing different interrupt service functions based on different class registration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.