00001 00006 /* 00007 * The contents of this file are subject to the Mozilla Public License 00008 * Version 1.0 (the "License"); you may not use this file except in 00009 * compliance with the License. You may obtain a copy of the License 00010 * at http://www.mozilla.org/MPL/ 00011 * 00012 * Software distributed under the License is distributed on an "AS IS" 00013 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00014 * the License for the specific language governing rights and 00015 * limitations under the License. 00016 * 00017 * The Original Code is legOS code, released October 17, 1999. 00018 * 00019 * The Initial Developer of the Original Code is Markus L. Noga. 00020 * Portions created by Markus L. Noga are Copyright (C) 1999 00021 * Markus L. Noga. All Rights Reserved. 00022 * 00023 * Contributor(s): Markus L. Noga <markus@noga.de> 00024 */ 00025 00026 #ifndef __dmotor_h__ 00027 #define __dmotor_h__ 00028 00029 #ifdef __cplusplus 00030 extern "C" { 00031 #endif 00032 00033 #include <config.h> 00034 00035 #ifdef CONF_DMOTOR 00036 00038 // 00039 // Definitions 00040 // 00042 00044 typedef enum { 00045 off = 0, 00046 fwd = 1, 00047 rev = 2, 00048 brake = 3 00049 00050 } MotorDirection; 00051 00052 #ifndef DOXYGEN_SHOULD_SKIP_INTERNALS 00053 00054 typedef struct { 00055 union { 00056 unsigned assembler; 00057 00058 struct { 00059 unsigned char delta; 00060 00061 volatile unsigned char sum; 00062 00063 } c; 00064 } access; 00065 00066 unsigned char dir; 00067 00068 } MotorState; 00069 #endif // DOXYGEN_SHOULD_SKIP_INTERNALS 00070 00071 #define MIN_SPEED 0 00072 #define MAX_SPEED 255 00073 00074 00075 // 00076 // Variables 00077 // 00079 00081 00084 extern const unsigned char dm_a_pattern[4], 00085 dm_b_pattern[4], 00086 dm_c_pattern[4]; 00087 00088 extern MotorState dm_a, 00089 dm_b, 00090 dm_c; 00091 00093 // 00094 // Functions 00095 // 00097 00098 #ifdef CONF_VIS 00099 00100 /* 00101 ** motor_*_dir() functions will display direction arrows, so 00102 ** define them in kernel/dmotor.c 00103 */ 00104 extern void motor_a_dir(MotorDirection dir); 00105 extern void motor_b_dir(MotorDirection dir); 00106 extern void motor_c_dir(MotorDirection dir); 00107 00108 #else 00109 00110 /* 00111 ** No display, so make these functions inline 00112 */ 00114 00116 extern inline void motor_a_dir(MotorDirection dir) 00117 { 00118 dm_a.dir = dm_a_pattern[dir]; 00119 } 00120 00122 00124 extern inline void motor_b_dir(MotorDirection dir) 00125 { 00126 dm_b.dir = dm_b_pattern[dir]; 00127 } 00128 00130 00132 extern inline void motor_c_dir(MotorDirection dir) 00133 { 00134 dm_c.dir = dm_c_pattern[dir]; 00135 } 00136 00137 #endif // ifdef CONF_VIS 00138 00139 00141 00143 extern inline void motor_a_speed(unsigned char speed) 00144 { 00145 dm_a.access.c.delta = speed; 00146 } 00147 00149 00151 extern inline void motor_b_speed(unsigned char speed) 00152 { 00153 dm_b.access.c.delta = speed; 00154 } 00155 00157 00159 extern inline void motor_c_speed(unsigned char speed) 00160 { 00161 dm_c.access.c.delta = speed; 00162 } 00163 00164 #endif // CONF_DMOTOR 00165 00166 #ifdef __cplusplus 00167 } 00168 #endif 00169 00170 #endif // __dmotor_h__
brickOS is released under the
Mozilla Public License.
Original code copyright 1998-2002 by the authors. |