Source_File
Dependencies: mbed X_NUCLEO_IHM02A1
Diff: main.cpp
- Revision:
- 24:d1f487cb02ba
- Parent:
- 23:073b26366d03
- Child:
- 26:caec5f51abe8
--- a/main.cpp Thu Mar 09 15:35:35 2017 +0000 +++ b/main.cpp Fri Mar 10 11:20:58 2017 +0100 @@ -46,7 +46,7 @@ #include "DevSPI.h" /* Expansion Board specific header files. */ -#include "x_nucleo_ihm02a1_class.h" +#include "XNucleoIhm02a1.h" /* Definitions ---------------------------------------------------------------*/ @@ -67,10 +67,10 @@ /* Variables -----------------------------------------------------------------*/ /* Motor Control Expansion Board. */ -X_NUCLEO_IHM02A1 *x_nucleo_ihm02a1; +XNucleoIhm02a1 *x_nucleo_ihm02a1; /* Initialization parameters of the motors connected to the expansion board. */ -L6470_Init_t init[L6470DAISYCHAINSIZE] = { +L6470_init_t init[L6470DAISYCHAINSIZE] = { /* First Motor. */ { 9.0, /* Motor supply voltage in V. */ @@ -143,10 +143,10 @@ #endif /* Initializing Motor Control Expansion Board. */ - x_nucleo_ihm02a1 = new X_NUCLEO_IHM02A1(&init[0], &init[1], A4, A5, D4, A2, &dev_spi); + x_nucleo_ihm02a1 = new XNucleoIhm02a1(&init[0], &init[1], A4, A5, D4, A2, &dev_spi); /* Building a list of motor control components. */ - L6470 **motors = x_nucleo_ihm02a1->GetComponents(); + L6470 **motors = x_nucleo_ihm02a1->get_components(); /* Printing to the console. */ printf("Motor Control Application Example for 2 Motors\r\n\n"); @@ -158,13 +158,13 @@ printf("--> Setting home position.\r\n"); /* Setting the home position. */ - motors[0]->SetHome(); + motors[0]->set_home(); /* Waiting. */ wait_ms(DELAY_1); /* Getting the current position. */ - int position = motors[0]->GetPosition(); + int position = motors[0]->get_position(); /* Printing to the console. */ printf("--> Getting the current position: %d\r\n", position); @@ -176,13 +176,13 @@ printf("--> Moving forward %d steps.\r\n", STEPS_1); /* Moving. */ - motors[0]->Move(StepperMotor::FWD, STEPS_1); + motors[0]->move(StepperMotor::FWD, STEPS_1); /* Waiting while active. */ - motors[0]->WaitWhileActive(); + motors[0]->wait_while_active(); /* Getting the current position. */ - position = motors[0]->GetPosition(); + position = motors[0]->get_position(); /* Printing to the console. */ printf("--> Getting the current position: %d\r\n", position); @@ -191,7 +191,7 @@ printf("--> Marking the current position.\r\n"); /* Marking the current position. */ - motors[0]->SetMark(); + motors[0]->set_mark(); /* Waiting. */ wait_ms(DELAY_1); @@ -200,16 +200,16 @@ printf("--> Moving backward %d steps.\r\n", STEPS_2); /* Moving. */ - motors[0]->Move(StepperMotor::BWD, STEPS_2); + motors[0]->move(StepperMotor::BWD, STEPS_2); /* Waiting while active. */ - motors[0]->WaitWhileActive(); + motors[0]->wait_while_active(); /* Waiting. */ wait_ms(DELAY_1); /* Getting the current position. */ - position = motors[0]->GetPosition(); + position = motors[0]->get_position(); /* Printing to the console. */ printf("--> Getting the current position: %d\r\n", position); @@ -221,16 +221,16 @@ printf("--> Going to marked position.\r\n"); /* Going to marked position. */ - motors[0]->GoMark(); + motors[0]->go_mark(); /* Waiting while active. */ - motors[0]->WaitWhileActive(); + motors[0]->wait_while_active(); /* Waiting. */ wait_ms(DELAY_1); /* Getting the current position. */ - position = motors[0]->GetPosition(); + position = motors[0]->get_position(); /* Printing to the console. */ printf("--> Getting the current position: %d\r\n", position); @@ -242,16 +242,16 @@ printf("--> Going to home position.\r\n"); /* Going to home position. */ - motors[0]->GoHome(); + motors[0]->go_home(); /* Waiting while active. */ - motors[0]->WaitWhileActive(); + motors[0]->wait_while_active(); /* Waiting. */ wait_ms(DELAY_1); /* Getting the current position. */ - position = motors[0]->GetPosition(); + position = motors[0]->get_position(); /* Printing to the console. */ printf("--> Getting the current position: %d\r\n", position); @@ -264,7 +264,7 @@ /* Halving the microsteps. */ init[0].step_sel = (init[0].step_sel > 0 ? init[0].step_sel - 1 : init[0].step_sel); - if (!motors[0]->SetStepMode((StepperMotor::step_mode_t) init[0].step_sel)) { + if (!motors[0]->set_step_mode((StepperMotor::step_mode_t) init[0].step_sel)) { printf(" Step Mode not allowed.\r\n"); } @@ -275,13 +275,13 @@ printf("--> Setting home position.\r\n"); /* Setting the home position. */ - motors[0]->SetHome(); + motors[0]->set_home(); /* Waiting. */ wait_ms(DELAY_1); /* Getting the current position. */ - position = motors[0]->GetPosition(); + position = motors[0]->get_position(); /* Printing to the console. */ printf("--> Getting the current position: %d\r\n", position); @@ -293,13 +293,13 @@ printf("--> Moving forward %d steps.\r\n", STEPS_1); /* Moving. */ - motors[0]->Move(StepperMotor::FWD, STEPS_1); + motors[0]->move(StepperMotor::FWD, STEPS_1); /* Waiting while active. */ - motors[0]->WaitWhileActive(); + motors[0]->wait_while_active(); /* Getting the current position. */ - position = motors[0]->GetPosition(); + position = motors[0]->get_position(); /* Printing to the console. */ printf("--> Getting the current position: %d\r\n", position); @@ -308,7 +308,7 @@ printf("--> Marking the current position.\r\n"); /* Marking the current position. */ - motors[0]->SetMark(); + motors[0]->set_mark(); /* Waiting. */ wait_ms(DELAY_2); @@ -321,11 +321,11 @@ /* Preparing each motor to perform a run at a specified speed. */ for (int m = 0; m < L6470DAISYCHAINSIZE; m++) { - motors[m]->PrepareRun(StepperMotor::BWD, 400); + motors[m]->prepare_run(StepperMotor::BWD, 400); } /* Performing the action on each motor at the same time. */ - x_nucleo_ihm02a1->PerformPreparedActions(); + x_nucleo_ihm02a1->perform_prepared_actions(); /* Waiting. */ wait_ms(DELAY_3); @@ -335,11 +335,11 @@ /* Preparing each motor to perform a run at a specified speed. */ for (int m = 0; m < L6470DAISYCHAINSIZE; m++) { - motors[m]->PrepareGetSpeed(); + motors[m]->prepare_get_speed(); } /* Performing the action on each motor at the same time. */ - uint32_t* results = x_nucleo_ihm02a1->PerformPreparedActions(); + uint32_t* results = x_nucleo_ihm02a1->perform_prepared_actions(); /* Printing to the console. */ printf(" Speed: M1 %d, M2 %d.\r\n", results[0], results[1]); @@ -349,22 +349,22 @@ /* Preparing each motor to perform a run at a specified speed. */ for (int m = 0; m < L6470DAISYCHAINSIZE; m++) { - motors[m]->PrepareRun(StepperMotor::BWD, results[m] << 1); + motors[m]->prepare_run(StepperMotor::BWD, results[m] << 1); } /* Performing the action on each motor at the same time. */ - results = x_nucleo_ihm02a1->PerformPreparedActions(); + results = x_nucleo_ihm02a1->perform_prepared_actions(); /* Waiting. */ wait_ms(DELAY_3); /* Preparing each motor to perform a run at a specified speed. */ for (int m = 0; m < L6470DAISYCHAINSIZE; m++) { - motors[m]->PrepareGetSpeed(); + motors[m]->prepare_get_speed(); } /* Performing the action on each motor at the same time. */ - results = x_nucleo_ihm02a1->PerformPreparedActions(); + results = x_nucleo_ihm02a1->perform_prepared_actions(); /* Printing to the console. */ printf(" Speed: M1 %d, M2 %d.\r\n", results[0], results[1]); @@ -380,11 +380,11 @@ /* Preparing each motor to perform a hard stop. */ for (int m = 0; m < L6470DAISYCHAINSIZE; m++) { - motors[m]->PrepareHardStop(); + motors[m]->prepare_hard_stop(); } /* Performing the action on each motor at the same time. */ - x_nucleo_ihm02a1->PerformPreparedActions(); + x_nucleo_ihm02a1->perform_prepared_actions(); /* Waiting. */ wait_ms(DELAY_2); @@ -402,10 +402,10 @@ int steps = (int) (((int) init[m].fullstepsperrevolution * pow(2.0f, init[m].step_sel)) / MPR_1); /* Moving. */ - motors[m]->Move(StepperMotor::FWD, steps); + motors[m]->move(StepperMotor::FWD, steps); /* Waiting while active. */ - motors[m]->WaitWhileActive(); + motors[m]->wait_while_active(); /* Waiting. */ wait_ms(DELAY_1); @@ -423,11 +423,11 @@ /* Preparing each motor to set High Impedance State. */ for (int m = 0; m < L6470DAISYCHAINSIZE; m++) { - motors[m]->PrepareHardHiZ(); + motors[m]->prepare_hard_hiz(); } /* Performing the action on each motor at the same time. */ - x_nucleo_ihm02a1->PerformPreparedActions(); + x_nucleo_ihm02a1->perform_prepared_actions(); /* Waiting. */ wait_ms(DELAY_2);