Remove duplicated code

I want to know if I can somehow rewrite the following code to remove the duplicated code. As you can see below the two cases have almost identical code.

#include <AutoDriver.h>

AutoDriver board_a(10, 6);
AutoDriver board_b(9, 6);
...
...
void loop() {
 
  long board_status = 0;
  
  if (stringComplete) {
    
    if (command == "C") {
      switch(motorCmd) {
        case 0:
          board_status = board_a.getStatus();
          if ((bitRead(board_status, 3) == 0)){
            board_a.goUntil(RESET_ABSPOS, dirCmd, stepsCmd);
            while(board_a.busyCheck());
          }
          else {
            Serial.println(board_a.getPos());
          }
          Serial.print("Completed calibration, current pos: ");
          Serial.println(board_a.getPos());
          LEDS_COLOR[motorCmd] = COLOR_CALIBRATED;
          break;
        case 1:
          board_status = board_b.getStatus();
          if ((bitRead(board_status, 3) == 0)){
            board_b.goUntil(RESET_ABSPOS, dirCmd, stepsCmd);
            while(board_b.busyCheck());
          }
          else {
            Serial.println(board_b.getPos());
          }
          Serial.print("Completed calibration, current pos: ");
          Serial.println(board_b.getPos());
          LEDS_COLOR[motorCmd] = COLOR_CALIBRATED;
          break;
      }
    }
...

Create an array of AutoDriver objects.

Put your case: code into a function, (all except the break;) Call the function in each of your cases with an input to tell the function whether it's operating on board a or board b.