Errors

08 Sep 2011

I am trying to create an array of interrupts based upon the number of pin names stored in an array passed to the I2CButtonStateTransmitter object. What is the proper means and syntax for I am trying to do?

I2CButtonStateTransmitter::I2CButtonStateTransmitter(PinName buttonPins[], 
                                                     PinName scl, PinName sda)
{
    const int numOfButtons = sizeof buttonPins / sizeof buttonPins[0];
    InterruptIn buttonInterrupts[numOfButtons]; // The compiler wants the constructor called here.
    // Generate interrupts for each button.
    for (int i = 0; i < numOfButtons; i++) // I want to call it in the loop to create the interrupts.
    {
        InterruptIn buttonInterrupts = new InterruptIn(numOfButtons[i])[i];
        buttonInterrupts[i].rise(&transmit);
    }
}

void I2CButtonStateTransmitter::transmit()
{
    
}

07 Sep 2011

If you do not understand what I am trying to do based upon my description, just ask me to clarify.

08 Sep 2011

Anyone?

08 Sep 2011

Ben,

There are many errors in your code, but the most salient answer to your question is that you are using the wrong form of rise.

The form you are using is not meant for member functions except static member functions.

Use the second form, which is meant for member functions. From the handbook (the template):

http://mbed.org/projects/libraries/api/mbed/trunk/InterruptIn#InterruptIn.rise

Harry

08 Sep 2011

I want to initialize an x number of interrupts. The code below allows for the manual selection of the number of interrupts, however it will not work because it has to happen to an x number.

InterruptIn buttonInterrupts[1] = { buttonPins[1] }; // Manually create object array.

My application calls for code to accept a parameter and set up the number of interrupts based upon the size of the buttonPins array. How is this done?