5

When using Ada interrupt handlers, I have so far isolated some specific things that need to be in the code for them to work.

Using Ada.Interrupts:

protected Int_Handler is --a protected object to handle interrupts
    procedure Handler_1; --A procedure which handles interrupts from your first device (with a body, of course)
    pragma Interrupt_Handler (Handler_1); --To tell the compiler this is an interrupt handler
    --Later in the program:
begin
    Attach_Handler (Int_Handler.Handler_1'access, Serial_1);

Assuming this is all correct and I've enabled interrupts in the registers, is there any other interrupt-related code I would need to add to this? Particularly, would I need to interact with the registers directly to in some way 'link up' my handler code, or can I just set up a record representation of the registers, output to them directly the necessary settings, and let rip?

Thanks!

Simon Wright
  • 25,108
  • 2
  • 35
  • 62
Leon
  • 51
  • 2
  • Anything with "pragma" is by definition implementation dependent; "tick-address" (and, for that matter, registers and hardware interrupts) are entirely platform dependent. IMHO... – paulsm4 May 17 '12 at 17:02
  • @paulsm4: By definition: "There are language-defined pragmas that give instructions for optimization, listing control, etc. An implementation may support additional (implementation-defined) pragmas." [Ada LRM 2.8](http://www.adaic.org/resources/add_content/standards/05rm/html/RM-2-8.html) – Marc C May 17 '12 at 20:05

1 Answers1

6

I think you're on the right track, but if you haven't done this before, I would, if I were you, review some of the articles that have been published on interrupt handling with Ada. E.g.:

Marc C
  • 8,664
  • 1
  • 24
  • 29