默认的STM32F FOC SDK提供的工程文件下载到STM32以后不会电机不会自动转,想要让电机转,必须通过串口上位机ST Motor Control Workbench这个软件
若想脱离上位机让电机上电自动旋转,需要在main函数里面调用电机启动函数
UI_ExecCmd (oUI, MC_PROTOCOL_CMD_START_MOTOR);
根据UM1052 User manual STM32F PMSM single/dual FOC SDK v4.2手册中描述的可以利用FOC提供的UI函数来屏蔽底层驱动,直接在用户层编写程序
提供的函数定义在 UserInterfaceClass.c 中,其中主要的函数有
/**
* @brief Creates an object of the class UserInterface
* @param pUserInterfaceParams pointer to an UserInterface parameters structure
* @retval CUI new instance of UserInterface object
*/
CUI UI_NewObject(pUserInterfaceParams_t pUserInterfaceParams);
/**
* @brief Initialization of UI object. It perform the link between the UI
* object and the MC interface and MC tuning objects. It must be called
* before the derived class initialization.
* @param this related object of class CUI.
* @param bMCNum Is the total number of MC object presnet in the list.
* @param pMCI is the pointer of the list of MC interface objects to be linked
* with the UI.
* @param pMCT is the pointer of the list of MC tuning objects to be linked
* with the UI.
* @param pUICfg is the pointer of the user interface configuration list. Each
* element of the list must be a bit field containing one (or more) of
* the exported configuration option UI_CFGOPT_xxx (eventually OR-ed).
* @retval none.
*/
void UI_Init(CUI this, uint8_t bMCNum, CMCI* pMCI, CMCT* pMCT, uint32_t* pUICfg);
/**
* @brief It is used to select the MC on which UI operates.
* @param this related object of class CUI.
* @param bSelectMC The new selected MC, zero based, on which UI operates.
* @retval bool It return true if the bSelectMC is valid oterwise return false.
*/
bool UI_SelectMC(CUI this,uint8_t bSelectMC);
/**
* @brief It is used to retrive the MC on which UI currently operates.
* @param this related object of class CUI.
* @retval uint8_t It returns the currently selected MC, zero based, on which
* UI operates.
*/
uint8_t UI_GetSelectedMC(CUI this);
/**
* @brief It is used to retrive the configuration of the MC on which UI
* currently operates.
* @param this related object of class CUI.
* @retval uint32_t It returns the currently configuration of selected MC on
* which UI operates.
* It represents a bit field containing one (or more) of
* the exported configuration option UI_CFGOPT_xxx (eventually OR-ed).
*/
uint32_t UI_GetSelectedMCConfig(CUI this);
/**
* @brief It is used to execute a SetReg command coming from the user.
* @param this related object of class CUI.
* @param bRegID Code of register to be updated. Valid code is one of the
* MC_PROTOCOL_REG_xxx values exported by UserInterfaceClass.
* @param wValue is the new value to be set.
* @retval bool It returns true if the SetReg command has been performed
* succesfully otherwise returns false.
*/
bool UI_SetReg(CUI this, MC_Protocol_REG_t bRegID, int32_t wValue);
/**
* @brief It is used to execute a GetReg command coming from the user.
* @param this related object of class CUI.
* @param bRegID Code of register to be updated. Valid code is one of the
* MC_PROTOCOL_REG_xxx values exported by UserInterfaceClass.
* @retval int32_t is the current value of register bRegID.
*/
int32_t UI_GetReg(CUI this, MC_Protocol_REG_t bRegID);
/**
* @brief It is used to retrieve the current selected MC tuning object.
* @param this related object of class CUI.
* @retval CMCT It returns the currently selected MC tuning obj