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