|
00001 /*!@addtogroup common_includes 00002 * @{ 00003 * @defgroup MMUX-common_h MMUX Functions 00004 * Commonly used types and defines used by Motor MUX drivers. 00005 * @{ 00006 */ 00007 00008 00009 /* 00010 * $Id: common-mmux.h 133 2013-03-10 15:15:38Z xander $ 00011 */ 00012 00013 /** \file common-MMUX.h 00014 * \brief Commonly used types and defines used by Motor MUX drivers. 00015 * 00016 * common-MMUX.h provides a number of frequently used types and defines that are useful for writing 00017 * Motor MUX drivers. 00018 * 00019 * License: You may use this code as you wish, provided you give credit where its due. 00020 * 00021 * THIS CODE WILL ONLY WORK WITH ROBOTC VERSION 3.59 AND HIGHER. 00022 00023 * 00024 * Changelog: 00025 * - 0.1: Initial release split from common.h 00026 * 00027 * \author Xander Soldaat (xander_at_botbench.com) 00028 * \date 18 January 2011 00029 * \version 0.1 00030 */ 00031 00032 #pragma systemFile 00033 00034 #ifndef __MMUX_H__ 00035 #define __MMUX_H__ 00036 00037 #ifndef SPORT 00038 #define SPORT(X) X / 4 /*!< Convert tMUXSensor to sensor port number */ 00039 #endif 00040 00041 #ifndef MPORT 00042 #define MPORT(X) X % 4 /*!< Convert tMUXSensor to MUX port number */ 00043 #endif 00044 00045 /*!< Struct to hold MMUX info */ 00046 typedef struct { 00047 bool initialised; /*!< Has the MMUX been initialised yet? */ 00048 bool runToTarget[4]; /*!< Indicate whether or not the motor is running to a target */ 00049 long target[4]; /*!< Target we want the motor to run to */ 00050 byte targetUnit[4]; /*!< Type of target we're running to, could be rotation, encoder or seconds */ 00051 bool relTarget[4]; /*!< Whether or not the target is relative to current position */ 00052 bool brake[4]; /*!< Whether or not to use braking or floating to stop motor */ 00053 bool pidcontrol[4]; /*!< Use constant speed or just power control */ 00054 byte ramping[4]; /*!< Ramp the motors, can be up, down, both */ 00055 } mmuxDataT; 00056 00057 00058 /*!< MUXmotor type, one for each permutation 00059 * 00060 * - mmotor_S1_1 means motor 1 connected to MMUX attached to sensor port 1 00061 * - mmotor_S4_2 means motor 2 connedted to MMUX attached to sensor port 4 00062 */ 00063 typedef enum { 00064 mmotor_S1_1 = 0, 00065 mmotor_S1_2 = 1, 00066 mmotor_S1_3 = 2, 00067 mmotor_S1_4 = 3, 00068 mmotor_S2_1 = 4, 00069 mmotor_S2_2 = 5, 00070 mmotor_S2_3 = 6, 00071 mmotor_S2_4 = 7, 00072 mmotor_S3_1 = 8, 00073 mmotor_S3_2 = 9, 00074 mmotor_S3_3 = 10, 00075 mmotor_S3_4 = 11, 00076 mmotor_S4_1 = 12, 00077 mmotor_S4_2 = 13, 00078 mmotor_S4_3 = 14, 00079 mmotor_S4_4 = 15 00080 } tMUXmotor; 00081 00082 mmuxDataT mmuxData[4]; /*!< Holds all the MMUX info, one for each sensor port */ 00083 00084 #endif // __MMUX_H__ 00085 00086 /* 00087 * $Id: common-mmux.h 133 2013-03-10 15:15:38Z xander $ 00088 */ 00089 /* @} */ 00090 /* @} */