📄 motors.h
字号:
/**
* \addtogroup Motors
* @{
*/
/*****************************************************************************/
/**
* \file Motors.h
* DC electric motor control code for the T89C51AC2 and Keil C51.
* \author Copyright (c) 2005, Murray R. Van Luyn. <vanluynm@iinet.net.au>
* \version 0.0
* \date 10-10-05
*/
/*****************************************************************************/
/*****************************************************************************
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
#ifndef MOTORS_H
#define MOTORS_H
#include "t89c51ac2.h"
#include "Pwm.h"
#include <math.h> // cabs()
/*****************************************************************************
*
* Macros
*
*****************************************************************************/
/*****************************************************************************
*
* Defined Constants
*
*****************************************************************************/
/*
* Motor control port bit defines.
*/
#define MOTORS_IN1 P1_0 // A channel direction control
#define MOTORS_IN2 P1_1 // A channel direction control
#define MOTORS_IN3 P1_2 // B channel direction control
#define MOTORS_IN4 P1_3 // B channel direction control
#define MOTORS_ENA PWM_CHANNEL_1 // A channel enable
#define MOTORS_ENB PWM_CHANNEL_2 // B channel enable
/*
* Motor channel defines.
*/
#define MOTORS_CHANNEL_A 0u
#define MOTORS_CHANNEL_B 1u
/*****************************************************************************
*
* Public Function Prototypes
*
*****************************************************************************/
/**
* DC motor control hardware initialisation function.
* Initialises the 8052 PCA and output ports for PWM motor control.
* Must be called once to set-up hardware during program initialisation.
* \param -
* \return -
*/
void motors_init(void);
/**
* DC motor control speed adjustment function.
* \param channel An \b unsigned \b char representing the channel to set.
* \param speed A \b signed \b char representation of the
* required speed.
* \return -
*/
void motors_set_speed(unsigned char channel, char speed);
/**
* DC motor control set brake function.
* \param channel An \b unsigned \b char representing the channel to set.
* \return -
*/
void motors_set_brake(unsigned char channel);
#endif
/** @} */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -