我试图将在main
我的类的私有变量中声明的变量而不将其作为构造函数的参数传递。我需要将中断控制器链接到多个硬件中断,而无需重新初始化中断实例并因此覆盖它。
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;
}
Foo类的实现:
class Foo
{
// This should be linked to the one in the main
XScuGic InterruptInstance;
public:
// In here, the interrupt is linked to the SPI device
void initializeSpi(uint16_t deviceID, uint32_t slaveMask);
};
deviceID 和 slaveMask 在包含的标头中定义。
有没有办法做到这一点?