7 Generated APIs

The generated library offers a list of user-friendly APIs that abstract and simplify the low-level configuration.

The APIs from the Motor Control Stack found in motor_control.h are the following:

  • MC_Initialize - The initialization function must be called before any other function
  • MC_StartStop - Starts or stops the motor depending on which state it is found in when the start-stop event is received
  • MC_DelayMs - Performs a delay using a timer in the background, without interrupts
  • MC_ReferenceSet - Sets the reference point for speed in closed loop or the amplitude level in open loop synchronization
  • MC_PotentiometerRead - Returns potentiometer value, expressed in percentage
  • MC_FastPotentiometerRead - Returns potentiometer value, expressed in raw Analog-to-Digital (A/D) format
  • MC_VoltageBusRead - Returns voltage bus value expressed in volts
  • MC_TemperatureRead - Returns MOSFET transistors temperature, expressed in degrees Celsius
  • MC_CurrentRead - Returns mean application current consumption, expressed in milliamperes
  • MC_Speed_Get - Returns the rotational speed expressed in mc_speed_t
  • MC_PeriodicHandlerRegister - Registers a custom software callback for the main application. This function must be called from the main and not the interrupt context.
  • MC_StatusGet - Returns the state of the motor (MOTOR_IDLE, MOTOR_RUNNING or MOTOR_FAULT), direction of the motor (MC_DIR_CW or MC_DIR_CCW), and the fault status (FAULT_UNDERVOLTAGE, FAULT_OVERVOLTAGE, FAULT_STALL, FAULT_OVERTEMPERATURE or FAULT_OVERCURRENT)

Users must only use the public APIs from the motor_control.h file so as not to alter the library’s functionality.