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()
{
}
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?
<<code>>
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()
{
}
<</code>>
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
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.
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?
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.
<<code>>
InterruptIn buttonInterrupts[1] = { buttonPins[1] }; // Manually create object array.
<</code>>
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?
Important Information for this Arm website
This site uses cookies to store information on your computer.
By continuing to use our site, you consent to our cookies.
If you are not happy with the use of these cookies, please review our
Cookie Policy
to learn how they can be disabled.
By disabling cookies, some features of the site will not work.
Access Warning
You do not have the correct permissions to perform this operation.
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?