Committer:
DomiSukic
Date:
Mon Mar 07 11:51:28 2016 +0000
Revision:
0:09cac0d76c5e

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DomiSukic 0:09cac0d76c5e 1 #include <mbed.h>
DomiSukic 0:09cac0d76c5e 2 //Checkbit-Defines
DomiSukic 0:09cac0d76c5e 3 #define CHECK_BIT(var,pos) ((var) & (1<<(pos))) //Checks if bits are set Input: Variable to chaeck adn the position of the bit to check
DomiSukic 0:09cac0d76c5e 4 //LED-Defines
DomiSukic 0:09cac0d76c5e 5 #define LED_OFF 0x00 // 0b0000 0000, All Leds are off
DomiSukic 0:09cac0d76c5e 6 #define LED_FL_WHITE 0x01 // 0b0000 0001, BERTL FORWARD Left-Side WHITE-LED
DomiSukic 0:09cac0d76c5e 7 #define LED_FL_YELLOW 0x02 // 0b0000 0010, BERTL FORWARD Left-Side YELLOW-LED
DomiSukic 0:09cac0d76c5e 8 #define LED_FR_WHITE 0x04 // 0b0000 0100, BERTL FORWARD Right-Side WHITE-LED
DomiSukic 0:09cac0d76c5e 9 #define LED_FR_YELLOW 0x08 // 0b0000 1000, BERTL FORWARD Right-Side YELLOW-LED
DomiSukic 0:09cac0d76c5e 10 #define LED_BL_RED 0x10 // 0b0001 0000, BERTL BACKWARD Left-Side RED-LED
DomiSukic 0:09cac0d76c5e 11 #define LED_BL_YELLOW 0x20 // 0b0010 0000, BERTL BACKWARD Left-Side YELLOW-LED
DomiSukic 0:09cac0d76c5e 12 #define LED_BR_RED 0x40 // 0b0100 0000, BERTL BACKWARD Right-Side RED-LED
DomiSukic 0:09cac0d76c5e 13 #define LED_BR_YELLOW 0x80 // 0b1000 0000, BERTL BACKWARD Right-Side YELLOW-LED
DomiSukic 0:09cac0d76c5e 14 #define LED_ON 0xFF // 0b1111 1111, All Leds are on
DomiSukic 0:09cac0d76c5e 15
DomiSukic 0:09cac0d76c5e 16 #define LED_R_YELLOW (LED_FR_YELLOW|LED_BR_YELLOW) // 0b1000 1000, BERTL Right Side, YELLOW-LEDs are on
DomiSukic 0:09cac0d76c5e 17 #define LED_L_YELLOW (LED_FL_YELLOW|LED_BL_YELLOW) // 0b0010 0010, BERTL Left Side, YELLOW-LEDs are on
DomiSukic 0:09cac0d76c5e 18 #define LED_F_WHITE (LED_FL_WHITE|LED_FR_WHITE) // 0b0000 0101, BERTL Forward, WHITE-LEDs are on
DomiSukic 0:09cac0d76c5e 19 #define LED_B_RED (LED_BL_RED|LED_BR_RED) // 0b0101 0000, BERTL Backward, RED LEDs are on
DomiSukic 0:09cac0d76c5e 20 #define LED_B_ALL (LED_B_RED|LED_BL_YELLOW|LED_BR_YELLOW) // 0b1111 0000, BERTL Backward, All LEDs are on
DomiSukic 0:09cac0d76c5e 21 #define LED_F_ALL (LED_F_WHITE|LED_FL_YELLOW|LED_FR_YELLOW) // 0b0000 1111, BERTL Forward, All LEDs are on
DomiSukic 0:09cac0d76c5e 22
DomiSukic 0:09cac0d76c5e 23 // Define PC9555 Routines
DomiSukic 0:09cac0d76c5e 24 #define PC9555_ADDR_W 0x40 //A2 = A1 = A0 = 0, WRITE-ADRESS
DomiSukic 0:09cac0d76c5e 25 #define PC9555_ADDR_R 0x41 // READ-ADRESS, to set the Read-bit
DomiSukic 0:09cac0d76c5e 26 #define PC9555_FREQUENCY 100000 // fI2C in Hz
DomiSukic 0:09cac0d76c5e 27
DomiSukic 0:09cac0d76c5e 28 // PC9555 Commands
DomiSukic 0:09cac0d76c5e 29 #define PC9555_PORT0_IN (0)
DomiSukic 0:09cac0d76c5e 30 #define PC9555_PORT1_IN (1)
DomiSukic 0:09cac0d76c5e 31 #define PC9555_PORT0_OUT (2)
DomiSukic 0:09cac0d76c5e 32 #define PC9555_PORT1_OUT (3)
DomiSukic 0:09cac0d76c5e 33 #define PC9555_PORT0_INV (4)
DomiSukic 0:09cac0d76c5e 34 #define PC9555_PORT1_INV (5)
DomiSukic 0:09cac0d76c5e 35 #define PC9555_PORT0_DIRCONFIG (6)
DomiSukic 0:09cac0d76c5e 36 #define PC9555_PORT1_DIRCONFIG (7)
DomiSukic 0:09cac0d76c5e 37
DomiSukic 0:09cac0d76c5e 38 // Define Motor Routines
DomiSukic 0:09cac0d76c5e 39 #define ENGINE_LEFT_BACKWARD P1_0 //IN1, EP10, MG1A => MG1 engine-Pin 2, left_Reverse
DomiSukic 0:09cac0d76c5e 40 #define ENGINE_LEFT_FORWARD P1_1 //IN2, EP11, MG1B => MG1 engine-Pin 1, left_Forward
DomiSukic 0:09cac0d76c5e 41 #define ENGINE_ENABLE_LEFT P1_15 //EN1, P34, left_ENABLE
DomiSukic 0:09cac0d76c5e 42 #define ENGINE_RIGHT_REVERSE P1_4 //IN4, EP13, MG2A => MG2 engine-Pin 2, right_Reverse
DomiSukic 0:09cac0d76c5e 43 #define ENGINE_RIGHT_FORWARD P1_3 //IN3, EP14, MG2B => MG2 engine-Pin 1, right_Forward
DomiSukic 0:09cac0d76c5e 44 #define ENGINE_ENABLE_RIGHT P0_21 //EN2, P36, right_ENABLE
DomiSukic 0:09cac0d76c5e 45 #define MAX_PWM 255 //Define the MAX Value of the PWM
DomiSukic 0:09cac0d76c5e 46
DomiSukic 0:09cac0d76c5e 47 // Motor Routines
DomiSukic 0:09cac0d76c5e 48 void bertl_engine(int left, int right);
DomiSukic 0:09cac0d76c5e 49 void bertl_engine_test();
DomiSukic 0:09cac0d76c5e 50
DomiSukic 0:09cac0d76c5e 51 // PC9555 routines
DomiSukic 0:09cac0d76c5e 52 void bertl_PC9555_init();
DomiSukic 0:09cac0d76c5e 53 void bertl_PC9555_leds(unsigned char leds);
DomiSukic 0:09cac0d76c5e 54 unsigned char bertl_PC9555_switches();
DomiSukic 0:09cac0d76c5e 55
DomiSukic 0:09cac0d76c5e 56 //Checkbit Routines
DomiSukic 0:09cac0d76c5e 57 bool checkbitFront();
DomiSukic 0:09cac0d76c5e 58 bool checkbitBack();