#include "stdio.h"
#include "NuMicro.h"
#define PLL_CLOCK 192000000
//#define POSITION6_EN PF9 //仓位电机EN
#define POSITION6_EN PE2 //用LED引脚
#define POSITION6_DIR PF10 //方向
#define POSITION6_INIT PB7 //仓位电机初始位
#define POSITION6_RLIM PF4 //仓位电机右检管
#define POSITION6_LLIM PF5 //仓位电机左检管
#define POSITION7_EN PH6 //仓位电机EN
#define POSITION7_DIR PH7 //方向
#define POSITION7_INIT PB14 //仓位电机初始位
#define POSITION7_RLIM PH5 //仓位电机右检管
#define POSITION7_LLIM PH4 //仓位电机左检管
void SYS_Init(void)
{
/* Set core clock as PLL_CLOCK from PLL */
CLK_SetCoreClock(PLL_CLOCK);
/* Set PCLK0/PCLK1 to HCLK/2 */
CLK->PCLKDIV = (CLK_PCLKDIV_APB0DIV_DIV2 | CLK_PCLKDIV_APB1DIV_DIV2);
}
int32_t main(void)
{
/* Unlock protected registers */
SYS_UnlockReg();
/* Init System, peripheral clock and multi-function I/O */
SYS_Init();
/* Lock protected registers */
SYS_LockReg();
GPIO_SetMode(PE, BIT2, GPIO_MODE_OUTPUT);
GPIO_SetMode(PF, BIT4, GPIO_MODE_INPUT);
GPIO_SetMode(PF, BIT5, GPIO_MODE_INPUT);
GPIO_SetMode(PH, BIT4, GPIO_MODE_INPUT);
GPIO_SetMode(PH, BIT5, GPIO_MODE_INPUT);
while(1)
{
if(POSITION6_RLIM)
POSITION6_EN = 1;
else
POSITION6_EN = 0;
}
}
|