Using same MCU for Odrive and App - How to Communicate?

Hi!

I’m developed a PCB that integrates the Odrive environment and my custom application (USB Game Controller HID+VCP) on the same MCU (STM32F405).

Right now, I could join them and the code is compiling fine, but I’m struggling on how to properly set parameters without getting a Hardfault when setting some of them.

As I’m using the same MCU, I do not use the default communication interface, so what I’ve tried until now:

Seems to set right values:

Axis* axis = axes[0];
axis->encoder_.config_.cpr = 4096;
axis->encoder_.config_.mode = Encoder::MODE_INCREMENTAL;

Even not getting error on setting the values, on debugger appears other completely different:

axis->motor_.config_.pole_pairs = 5;
axis->motor_.config_.motor_type = Motor::MOTOR_TYPE_HIGH_CURRENT;
axis->motor_.config_.resistance_calib_max_voltage = 3.0;
axis->motor_.config_.phase_inductance = 0.0023965;
axis->motor_.config_.phase_resistance = 1.01844;

Generates HardFault when setting values:
axis->controller_.config_.vel_limit = 5;

Also here:

Controller *cont = ODriveIntf::AxisIntf::get_controller(ODriveIntf::get_axis0(&odrv));
cont->config_.vel_limit = 5;

Any clue on how to set the parameters and run methods?

Thanks!