Rearrange init some to fix a crash, details:

mr was not being intialized before it was being used by the stepper intialization.

Also added a check to prevent it from happening from other places.
This commit is contained in:
Rob Giseburt
2020-01-22 15:40:08 -06:00
parent 8c7c085ed1
commit f2fa2da3a5
2 changed files with 7 additions and 1 deletions

View File

@@ -100,11 +100,11 @@ void application_init_machine(void)
{
cm = &cm1; // set global canonical machine pointer to primary machine
cm->machine_state = MACHINE_INITIALIZING;
canonical_machine_inits(); // combined inits for CMs and planner - do before anything might use cm or mr!
stepper_init(); // stepper subsystem
encoder_init(); // virtual encoders
gpio_init(); // inputs and outputs
canonical_machine_inits(); // combined inits for CMs and planner
}
void application_init_startup(void)

View File

@@ -264,6 +264,12 @@ void mp_set_runtime_position(uint8_t axis, const float position) { mr->position[
void mp_set_steps_to_runtime_position()
{
if (mr == nullptr) {
#if IN_DEBUGGER
__asm__ volatile("BKPT 1"); // mp_set_steps_to_runtime_position called with null mr!
#endif
return;
}
float step_position[MOTORS];
// There use to be a call to kn_inverse_kinematics here, but we don't do that now, instead we call kn->sync_encoders()
// after handling the steps, allowing the kinematics to intelligently handle the offset of step and position.