📄 stepper.c
字号:
/*------------------------------------------------------------------*-
Stepper.C (v1.00)
------------------------------------------------------------------
Simple stepper control functions for robot.
COPYRIGHT
---------
This code is associated with the book:
EMBEDDED C by Michael J. Pont
[Pearson Education, 2002: ISBN: 0-201-79523-X].
This code is copyright (c) 2001 by Michael J. Pont.
See book for copyright details and other information.
-*------------------------------------------------------------------*/
#include "Main.h"
#include "Port.h"
#include "Stepper.h"
// ------ Public variable definitions ------------------------------
bit Motor_L;
bit Motor_R;
// ------ Private variable definitions -----------------------------
static bit Stepper_state_G;
/*------------------------------------------------------------------*-
STEPPER_Init()
-*------------------------------------------------------------------*/
void STEPPER_Init(void)
{
Stepper_state_G = 0;
Motor_L = 0;
Motor_R = 0;
}
/*------------------------------------------------------------------*-
STEPPER_Update()
Controls two stepper motors.
-*------------------------------------------------------------------*/
void STEPPER_Update(void)
{
// Step the motors, as required
if (Stepper_state_G == 1)
{
Stepper_state_G = 0;
if (Motor_L == 1)
{
Motor_L_pin = 1;
}
if (Motor_R == 1)
{
Motor_R_pin = 1;
}
}
else
{
Stepper_state_G = 1;
Motor_L_pin = 0;
Motor_R_pin = 0;
}
}
/*------------------------------------------------------------------*-
---- END OF FILE -------------------------------------------------
-*------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -