Hello, I've tried to write a simple program on c++ for the lpc1768 and I have a problem when i try to construct an object:
//led.h #include <LPC17xx.H> enum state_t{ ON, OFF, }; class led{ private: state_t state; public: led(); void conmutar(void); }; // led.cpp #include <LPC17xx.H> #include "led.h" led::led() { LPC_GPIO1->FIODIR |= (1<<29); } void led::conmutar(void) { LPC_GPIO1->FIOPIN ^= (1<<29); } //main.cpp #include <LPC17xx.H> #include "led.h" led* led_29 = new led(); /*if I remove " = new led()" the program runs in the board but then there is no constructor*/ extern "C" void EINT3_IRQHandler(void) { LPC_SC->EXTINT = 1 << 3; //Limpiar el flag de la EINT2. led_29->conmutar(); //LPC_GPIO1->FIOPIN ^= (1<<29); } int main(){ irq_config(); while(1); }
I've looked for some information about this and I found that some modifications on the startup_LPC17xx.s code are needed to run c++ code successfully.
Thanks.