Re: C++ and STM32
Posted: Sun Sep 04, 2011 8:12 pm
Thanks for that pointer Giovanni, increasing the main and process stack sizes has fixed it 
Giovanni wrote:Heh, careful, the main() function stack is the "process stack", the "main stack" is the stack for interrupts. It is a bit of a mess but those are the names ARM gave them.
Xamusk wrote:I, for one, use the C API in my C++ projects. It's just too troublesome to access some functions in the correct scopes. For example, imagine that I create some hardware abstraction class and this class needs the delay functions. From where should I call it? Must I have a pointer to the caller thread object just so I can call the delay function? Should the delay function be a static member? If it is static, why not just call the C API?
Code: Select all
#include "ch.h"
#include "hal.h"
#include "Eigen/Dense"
using namespace Eigen;
static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) {
(void)arg;
chRegSetThreadName("blinker");
int i = 1;
float valor[2];
Matrix<float, 3, 3> A, L;
A = Matrix<float, 3, 3>::Identity(3, 3) +
Matrix<float, 3, 3>::Constant(1);
while (TRUE)
{
i++;
L = A.llt().matrixL();
A(0, 0) += i;
valor[0] = L(0, 0);
valor[1] = L(1, 1);
palSetPad(GPIOD, GPIOD_LED3); /* Orange. */
chThdSleepMilliseconds(500);
palClearPad(GPIOD, GPIOD_LED3); /* Orange. */
chThdSleepMilliseconds(500);
}
}
int main(void) {
halInit();
chSysInit();
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
while (TRUE) {
chThdSleepMilliseconds(500);
}
}
Code: Select all
Linking build/ch.elf
/home/noether/workspace/tool-chains/arm-none-eabi-4.6.2/lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib/thumb/cortex-m4/libc.a(lib_a-abort.o): In function `abort':
/home/noether/workspace/tool-chains/summon-arm-toolchain/build/arm-none-eabi/thumb/cortex-m4/newlib/libc/stdlib/../../../../../../../gcc-4.6.2/newlib/libc/stdlib/abort.c:63: undefined reference to `_exit'
/home/noether/workspace/tool-chains/arm-none-eabi-4.6.2/lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib/thumb/cortex-m4/libc.a(lib_a-signalr.o): In function `_kill_r':
/home/noether/workspace/tool-chains/summon-arm-toolchain/build/arm-none-eabi/thumb/cortex-m4/newlib/libc/reent/../../../../../../../gcc-4.6.2/newlib/libc/reent/signalr.c:61: undefined reference to `_kill'
/home/noether/workspace/tool-chains/arm-none-eabi-4.6.2/lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib/thumb/cortex-m4/libc.a(lib_a-signalr.o): In function `_getpid_r':
/home/noether/workspace/tool-chains/summon-arm-toolchain/build/arm-none-eabi/thumb/cortex-m4/newlib/libc/reent/../../../../../../../gcc-4.6.2/newlib/libc/reent/signalr.c:96: undefined reference to `_getpid'
collect2: ld returned 1 exit status
make: *** [build/ch.elf] Error 1