BERTL library, Kevin Heinrich

Dependents:   BertlPingPong_UEbung3_EB

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers bertl14.h Source File

bertl14.h

00001 #include <mbed.h>
00002 //LED-Defines
00003 #define LED_OFF 0x00            // 0b0000 0000, All Leds are off
00004 #define LED_FL_WHITE 0x01       // 0b0000 0001, BERTL FORWARD Left-Side WHITE-LED
00005 #define LED_FL_YELLOW 0x02      // 0b0000 0010, BERTL FORWARD Left-Side YELLOW-LED
00006 #define LED_FR_WHITE 0x04       // 0b0000 0100, BERTL FORWARD Right-Side WHITE-LED
00007 #define LED_FR_YELLOW 0x08      // 0b0000 1000, BERTL FORWARD Right-Side YELLOW-LED
00008 #define LED_BL_RED 0x10         // 0b0001 0000, BERTL BACKWARD Left-Side RED-LED
00009 #define LED_BL_YELLOW 0x20      // 0b0010 0000, BERTL BACKWARD Left-Side YELLOW-LED
00010 #define LED_BR_RED 0x40         // 0b0100 0000, BERTL BACKWARD Right-Side RED-LED
00011 #define LED_BR_YELLOW 0x80      // 0b1000 0000, BERTL BACKWARD Right-Side YELLOW-LED
00012 #define LED_ON 0xFF             // 0b1111 1111, All Leds are on
00013 
00014 #define LED_R_YELLOW (LED_FR_YELLOW|LED_BR_YELLOW)          // 0b1000 1000, BERTL Right Side, YELLOW-LEDs are on
00015 #define LED_L_YELLOW (LED_FL_YELLOW|LED_BL_YELLOW)          // 0b0010 0010, BERTL Left Side, YELLOW-LEDs are on
00016 #define LED_YELLOW (LED_L_YELLOW|LED_R_YELLOW)              // 0b1010 1010, BERTL, all YELLOW-LEDs are on
00017 #define LED_F_WHITE (LED_FL_WHITE|LED_FR_WHITE)             // 0b0000 0101, BERTL Forward, WHITE-LEDs are on
00018 #define LED_B_RED (LED_BL_RED|LED_BR_RED)                   // 0b0101 0000, BERTL Backward, RED LEDs are on
00019 #define LED_B_ALL (LED_B_RED|LED_BL_YELLOW|LED_BR_YELLOW)   // 0b1111 0000, BERTL Backward, All LEDs are on
00020 #define LED_F_ALL (LED_F_WHITE|LED_FL_YELLOW|LED_FR_YELLOW) // 0b0000 1111, BERTL Forward, All LEDs are on
00021 //--------------------------------------
00022 // Switches:
00023 // Switch TA1: DEZ = 1
00024 #define TA_FM 0x01  // front middle switch
00025 // Switch TA2: DEZ = 2
00026 #define TA_BM 0x02  // back middle switch
00027 // Switch TA3: DEZ = 4
00028 #define TA_FL 0x04  // front left switch
00029 // Switch TA4: DEZ = 8
00030 #define TA_FR 0x08  // front right switch
00031 // Switch TA5: DEZ = 16
00032 #define TA_BL 0x10  // back left switch
00033 // Switch TA6: DEZ = 32
00034 #define TA_BR 0x20  // back right switch
00035 // Switch TA7: DEZ = 64
00036 #define TA_BF_L 0x40    // bottom front left switch
00037 // Switch TA8: DEZ = 128
00038 #define TA_BF_R 0x80    // bottom front right switch
00039 
00040 #define TA_F (TA_FL|TA_FM|TA_FR)    // All front switches
00041 #define TA_B (TA_BL|TA_BM|TA_BR)    // All back switches
00042 //--------------------------------------
00043 // Define PC9555 Routines
00044 #define PC9555_ADDR_W 0x40 //A2 = A1 = A0 = 0, WRITE-ADRESS
00045 #define PC9555_ADDR_R 0x41 // READ-ADRESS, to set the Read-bit
00046 #define PC9555_FREQUENCY 100000 // fI2C in Hz
00047 // PC9555 Commands
00048 #define PC9555_PORT0_IN (0)
00049 #define PC9555_PORT1_IN (1)
00050 #define PC9555_PORT0_OUT (2)
00051 #define PC9555_PORT1_OUT (3)
00052 #define PC9555_PORT0_INV (4)
00053 #define PC9555_PORT1_INV (5)
00054 #define PC9555_PORT0_DIRCONFIG (6)
00055 #define PC9555_PORT1_DIRCONFIG (7)
00056 // Define Motor Routines
00057 #define ENGINE_LEFT_BACKWARD P1_0       //IN1, EP10, MG1A => MG1 engine-Pin 2, left_Reverse
00058 #define ENGINE_LEFT_FORWARD P1_1        //IN2, EP11, MG1B => MG1 engine-Pin 1, left_Forward
00059 #define ENGINE_ENABLE_LEFT P1_15        //EN1, P34, left_ENABLE
00060 #define ENGINE_RIGHT_REVERSE P1_4       //IN4, EP13, MG2A => MG2 engine-Pin 2, right_Reverse
00061 #define ENGINE_RIGHT_FORWARD P1_3       //IN3, EP14, MG2B => MG2 engine-Pin 1, right_Forward
00062 #define ENGINE_ENABLE_RIGHT P0_21       //EN2, P36, right_ENABLE
00063 #define MAX_PWM 255                     //Define the MAX Value of the PWM
00064 // Motor Routines
00065 void bertl_engine(int left, int right);
00066 void bertl_engine_test();
00067 
00068 // PC9555 routines
00069 void bertl_PC9555_init();
00070 void bertl_PC9555_leds(unsigned char leds);
00071 unsigned char bertl_PC9555_switches();