Asif Sattar / Mbed 2 deprecated mbed_mainboard_source

Dependencies:   USBDevice mbed motor

Fork of mbed_mainboard_source by Karl Oskar Lember

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers definitions.h Source File

definitions.h

00001 #ifndef DEFINITIONS_H_
00002 #define DEFINITIONS_H_ value
00003 
00004 #define NUMBER_OF_MOTORS 3
00005 
00006 #define MOTOR_PWM(n) MOTOR ## n ## _PWM
00007 #define MOTOR_DIR1(n) MOTOR ## n ## _DIR1
00008 #define MOTOR_DIR2(n) MOTOR ## n ## _DIR2
00009 #define MOTOR_FAULT(n) MOTOR ## n ## _FAULT
00010 #define MOTOR_ENCA(n) MOTOR ## n ## _ENCA
00011 #define MOTOR_ENCB(n) MOTOR ## n ## _ENCB
00012 
00013 #define MOTOR_ENC_TICK(i)   void motor ## i ## EncTick() { \
00014                                 uint8_t enc_dir; \
00015                                 motorEncNow[i] = MotorEncA[i]->read() | (MotorEncB[i]->read() << 1); \
00016                                 enc_dir = (motorEncLast[i] & 1) ^ ((motorEncNow[i] & 2) >> 1); \
00017                                 motorEncLast[i] = motorEncNow[i]; \
00018                                 \
00019                                 if (enc_dir & 1) motorTicks[i]++; \
00020                                 else motorTicks[i]--; \
00021                             }
00022 
00023 #define MOTOR_PID_TICK(i)   void motor ## i ## PidTick() { \
00024                                 motors[i].pid2(motorTicks[i]); \
00025                                 motorTicks[i] = 0; \
00026                             }
00027 #endif