View Single Post
Old 18 January 2016, 13:17   #1
NetBSD developer
Join Date: May 2012
Location: Warsaw, Poland
Posts: 411
How to pass data to interrupt handler with VBCC?


I'm writing a simple program that will be used to the hardware I am developing (I2C controller). I generally got it working, but didn't like the fact that I was using way too many globals. So I decided to replace globals with... God struct/object. Anyway, I have trouble passing data to interrupt handler.

I know there's some magic with __amigainterrupt required, but I couldn't find any examples.

I have my God object/struct:
typedef struct { 
} pca9564_state_t;
It is instantiated in the main function, where interrupt is also defined:
int main(void) 
        pca9564_state_t sc;
        struct Interrupt *int6;

        if (int6 = AllocMem(sizeof(struct Interrupt), MEMF_PUBLIC|MEMF_CLEAR)) {
                int6->is_Node.ln_Type = NT_INTERRUPT;
                int6->is_Node.ln_Pri = -60;
                int6->is_Node.ln_Name = "PCA9564";
                int6->is_Data = (APTR)≻
                int6->is_Code = pca9564_isr;

                AddIntServer(INTB_EXTER, int6);
        } else {
Now, the question is, how do I access the struct inside of interrupt server? I have my server defined like this:

__amigainterrupt void
pca9564_isr(pca9564_state_t *sp)
But sp seems to contain garbage, or at least not what I expect.

Whole code of my program is here:

Previous version, which worked correctly but used globals is here:

Last edited by strim; 18 January 2016 at 13:30.
strim is offline  
Page generated in 0.04196 seconds with 11 queries