lundi 30 mai 2016

C++ import external variable into private class variable

I'm trying to get a variable declared in the main into the private variables of my class without passing it as an argument for the constructor. I need to link the interrupt controller to multiple hardware interrupts without re initializing the interrupt instance and thus overwriting it.

XScuGic InterruptInstance 

int main(){
    // Initialize interrupt by looking up config and initializing with that config
    ConfigPtr = XScuGic_LookupConfig(INTERRUPT_DEVICE_ID);
    XScuGic_CfgInitialize(&InterruptInstance, ConfigPtr, ConfigPtr->BaseAddr);

    Foo foo;
    foo.initializeSpi(deviceID,slaveMask);

    return 0;
    }

And the implementation of the class Foo:

class Foo{
private:
   XScuGic InterruptInstance // This should be linked to the one in the main
public:
   void initializeSpi(uint16_t deviceID, uint32_t slaveMask); // In here, the interrupt is linked to the SPI device
};

The deviceID and slaveMask are defined in a header which is included.

Is there some way to achieve this?

Aucun commentaire:

Enregistrer un commentaire