Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 8 months ago.
BootLoader_K64F as a Class?
What would be the advantage of using these functions in a class, for example?
__attribute__((section(".ARM.__at_0x10000" ))) class bootLoaderClass { //Program Sector Location private: void write(char *value) { int i = 0; //Loop through string and send everything while(*(value+i) != '\0') { while(!(UART0->S1 & UART_S1_TDRE_MASK)); UART0->D = *(value+i); i++; } } };
.
One advantage I can think of is that there is only one Flash memory location to reference in terms of sector location ".ARM.at_0x10000"?
Another advantage might be that the bootloader class could extend the FreeScaleIAP if this was a class?
I would like to understand when to take advantage of classes and when to avoid classes.
Question relating to:
1 Answer
9 years, 8 months ago.
It would then need to be a completely static class, since a regular one with constructor makes little sense in this case. I did consider it, however since I didn't see the advantage of doing that here I just sticked to C functions.
You are correct it might make it easier to put the whole thing in a different memory location, so it is an idea to change it to a static class. Although I am not 100% sure that that would actually work. For example the functions are in flash, but private variables would be in RAM (not that it has any, but in general).