You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
173 lines
4.7 KiB
173 lines
4.7 KiB
|
3 weeks ago
|
/******************************************************************************
|
||
|
|
|
||
|
|
版权所有 (C), 2018-2099, Radkil
|
||
|
|
|
||
|
|
******************************************************************************
|
||
|
|
文 件 名 : robot.h
|
||
|
|
版 本 号 : 初稿
|
||
|
|
作 者 : radkil
|
||
|
|
生成日期 : 2026年4月14日
|
||
|
|
最近修改 :
|
||
|
|
功能描述 : robot.c 的头文件
|
||
|
|
|
||
|
|
修改历史 :
|
||
|
|
1.日 期 : 2026年4月14日
|
||
|
|
作 者 : radkil
|
||
|
|
修改内容 : 创建文件
|
||
|
|
|
||
|
|
******************************************************************************/
|
||
|
|
|
||
|
|
/*----------------------------------------------*
|
||
|
|
* 外部变量说明 *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
|
||
|
|
/*----------------------------------------------*
|
||
|
|
* 外部函数原型说明 *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
|
||
|
|
/*----------------------------------------------*
|
||
|
|
* 内部函数原型说明 *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
|
||
|
|
/*----------------------------------------------*
|
||
|
|
* 全局变量 *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
|
||
|
|
/*----------------------------------------------*
|
||
|
|
* 模块级变量 *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
|
||
|
|
/*----------------------------------------------*
|
||
|
|
* 常量定义 *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
|
||
|
|
/*----------------------------------------------*
|
||
|
|
* 宏定义 *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
|
||
|
|
#ifndef __ROBOT_H__
|
||
|
|
#define __ROBOT_H__
|
||
|
|
|
||
|
|
|
||
|
|
#ifdef __cplusplus
|
||
|
|
#if __cplusplus
|
||
|
|
extern "C"{
|
||
|
|
#endif
|
||
|
|
#endif /* __cplusplus */
|
||
|
|
|
||
|
|
|
||
|
|
/*==============================================*
|
||
|
|
* include header files *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
#include <stdio.h>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
/*==============================================*
|
||
|
|
* constants or macros define *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
/* 跨平台弱符号宏定义 */
|
||
|
|
#if defined(__GNUC__) || defined(__clang__) || defined(__SUNPRO_CC) || defined(__SUNPRO_C)
|
||
|
|
/* GCC, Clang, SunPro 系列 */
|
||
|
|
#define WEAK __attribute__((weak))
|
||
|
|
|
||
|
|
#elif defined(__IAR_SYSTEMS_ICC__)
|
||
|
|
/* IAR Embedded Workbench */
|
||
|
|
#define WEAK __weak
|
||
|
|
|
||
|
|
#elif defined(__CC_ARM) || defined(__ARMCC_VERSION)
|
||
|
|
/* Keil MDK / ARM Compiler */
|
||
|
|
#define WEAK __weak
|
||
|
|
|
||
|
|
#elif defined(_MSC_VER)
|
||
|
|
/* Microsoft Visual C++ */
|
||
|
|
/* 或者干脆定义为空,但需要确保不会重复定义 */
|
||
|
|
#define WEAK
|
||
|
|
|
||
|
|
#else
|
||
|
|
/* 其他未知编译器,保守处理 */
|
||
|
|
#error "Weak symbol not supported on this compiler"
|
||
|
|
#define WEAK
|
||
|
|
/* 可以添加警告:#warning "Weak symbol not supported on this compiler" */
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#define RB_SUCCESS 0 //通用成功
|
||
|
|
#define RB_FAILURE -1 //通用失败
|
||
|
|
|
||
|
|
#define RB_NOSWING -22 //不支持摆臂
|
||
|
|
|
||
|
|
typedef enum
|
||
|
|
{
|
||
|
|
RB_STOP = 0,
|
||
|
|
RB_MANUAL_FORWARD,
|
||
|
|
RB_MANUAL_BACKWARD,
|
||
|
|
RB_PAINT
|
||
|
|
}ERobotCmd;
|
||
|
|
/*==============================================*
|
||
|
|
* project-wide global variables *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
/*==============================================*
|
||
|
|
* routines' or functions' implementations *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
int RobotInit(void);
|
||
|
|
void RobotProc(void);
|
||
|
|
|
||
|
|
#if defined(BUILD_SWING)
|
||
|
|
extern void SwingStrong(void);
|
||
|
|
#endif
|
||
|
|
#if defined(BUILD_PAINT) || defined(BUILD_MOTORTT)
|
||
|
|
extern void PaintStrong(void);
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#if defined(BUILD_CONTROLLER) || defined(BUILD_CTRL2)
|
||
|
|
extern void ControllerStrong(void);
|
||
|
|
#endif
|
||
|
|
#if defined(BUILD_MOTOR) || defined(BUILD_MOTORTT)
|
||
|
|
extern void WheelMotorStrong(void);
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#if defined(BUILD_SWING)
|
||
|
|
#define INIT_SWING_PART() do { SwingStrong(); } while(0)
|
||
|
|
#else
|
||
|
|
#define INIT_SWING_PART() do {} while(0)
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#if defined(BUILD_PAINT)
|
||
|
|
#define INIT_PAINT_PART() do { PaintStrong(); } while(0)
|
||
|
|
#else
|
||
|
|
#define INIT_PAINT_PART() do {} while(0)
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#if defined(BUILD_CONTROLLER) || defined(BUILD_CTRL2)
|
||
|
|
#define INIT_CONTROLLER_PART() do { ControllerStrong(); } while(0)
|
||
|
|
#else
|
||
|
|
#define INIT_CONTROLLER_PART() do {} while(0)
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#if defined(BUILD_MOTOR) || defined(BUILD_MOTORTT)
|
||
|
|
#define INIT_MOTOR_PART() do { WheelMotorStrong(); } while(0)
|
||
|
|
#else
|
||
|
|
#define INIT_MOTOR_PART() do {} while(0)
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#define RB_INIT() \
|
||
|
|
do { \
|
||
|
|
INIT_SWING_PART(); \
|
||
|
|
INIT_PAINT_PART(); \
|
||
|
|
INIT_CONTROLLER_PART(); \
|
||
|
|
INIT_MOTOR_PART(); \
|
||
|
|
} while(0)
|
||
|
|
|
||
|
|
|
||
|
|
#ifdef __cplusplus
|
||
|
|
#if __cplusplus
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
#endif /* __cplusplus */
|
||
|
|
|
||
|
|
|
||
|
|
#endif /* __ROBOT_H__ */
|