The Code Repository for the REV0 Steering Wheel.
Dependencies: CANBuffer KS0108_fork mbed-rtos mbed CAN Addresses
Fork of REVO_Updated_Steering by
Steering.h@15:da14227cdd1d, 2014-10-18 (annotated)
- Committer:
- palimar
- Date:
- Sat Oct 18 17:19:43 2014 +0000
- Revision:
- 15:da14227cdd1d
- Parent:
- 14:3e21d6c764a5
- Parent:
- 13:1f05dcd9ae0e
- Child:
- 16:d2953809fb31
merged 2 tips
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kiran_mbed | 0:313541d8f8be | 1 | #ifndef _STEERING_H |
kiran_mbed | 0:313541d8f8be | 2 | #define _STEERING_H |
kiran_mbed | 0:313541d8f8be | 3 | |
kiran_mbed | 0:313541d8f8be | 4 | #include "mbed.h" |
palimar | 3:fcec60c7f2c6 | 5 | #include "rtos.h" |
kiran_mbed | 0:313541d8f8be | 6 | #include "Digital_InOut.h" |
kiran_mbed | 0:313541d8f8be | 7 | #include "KS0108.h" |
kiran_mbed | 0:313541d8f8be | 8 | |
kiran_mbed | 0:313541d8f8be | 9 | #include "Arial12.h" |
kiran_mbed | 0:313541d8f8be | 10 | #include "Arial14.h" |
kiran_mbed | 0:313541d8f8be | 11 | #include "Comic24.h" |
kiran_mbed | 0:313541d8f8be | 12 | #include "vivaldi16.h" |
kiran_mbed | 0:313541d8f8be | 13 | |
kiran_mbed | 0:313541d8f8be | 14 | #define SWITCH_ID 410 |
kiran_mbed | 0:313541d8f8be | 15 | |
kiran_mbed | 0:313541d8f8be | 16 | #define BATTERY_VOLTAGE_ID 0x304 |
kiran_mbed | 0:313541d8f8be | 17 | #define BATTERY_POWER_ID 0x306 |
kiran_mbed | 0:313541d8f8be | 18 | #define BATTERY_CURRENT_ID 0x305 |
kiran_mbed | 0:313541d8f8be | 19 | |
kiran_mbed | 0:313541d8f8be | 20 | #define PCM_STATE_ID 20 |
kiran_mbed | 0:313541d8f8be | 21 | |
kiran_mbed | 0:313541d8f8be | 22 | #define BATTERY_MIN_CELLVOLTAGE_ID 0x301 |
kiran_mbed | 0:313541d8f8be | 23 | #define BATTERY_MAX_CELLVOLTAGE_ID 0x300 |
kiran_mbed | 0:313541d8f8be | 24 | #define BATTERY_AVG_CELLVOLTAGE_ID 0x302 |
kiran_mbed | 0:313541d8f8be | 25 | |
kiran_mbed | 0:313541d8f8be | 26 | #define BATTERY_MIN_CELLTEMPERATURE_ID 0x30A |
kiran_mbed | 0:313541d8f8be | 27 | #define BATTERY_MAX_CELLTEMPERATURE_ID 0x309 |
kiran_mbed | 0:313541d8f8be | 28 | #define BATTERY_AVG_CELLTEMPERATURE_ID 0x30B |
kiran_mbed | 0:313541d8f8be | 29 | #define AMS_BATTERY_STATE 0x30E // AIRS 7 and 6 // Precharge 3 |
kiran_mbed | 0:313541d8f8be | 30 | |
kiran_mbed | 0:313541d8f8be | 31 | Serial pc(USBTX,USBRX); |
kiran_mbed | 0:313541d8f8be | 32 | CAN CAN_Steering(p9,p10); |
kiran_mbed | 0:313541d8f8be | 33 | Digital_InOut CAN_Silent(p3_26, 0, output); |
kiran_mbed | 0:313541d8f8be | 34 | |
kiran_mbed | 0:313541d8f8be | 35 | KS0108 display(p26, p21, p22, p23, p25, p24, p8, p7, p6, p5, p13, p14, p12, p11); |
kiran_mbed | 0:313541d8f8be | 36 | Ticker call_ledstream; |
kiran_mbed | 0:313541d8f8be | 37 | |
kiran_mbed | 0:313541d8f8be | 38 | Digital_InOut l1(p1_28,1,output);// SW2 |
kiran_mbed | 0:313541d8f8be | 39 | Digital_InOut l2(p1_26,1,output);// SW4 |
kiran_mbed | 0:313541d8f8be | 40 | |
kiran_mbed | 0:313541d8f8be | 41 | Digital_InOut l3(p1_24,1,output);// SW6 |
kiran_mbed | 0:313541d8f8be | 42 | Digital_InOut l4(p0_24,1,output);// SW8 |
kiran_mbed | 0:313541d8f8be | 43 | |
kiran_mbed | 0:313541d8f8be | 44 | Digital_InOut u1(p1_14,0,output);// SW9 |
kiran_mbed | 0:313541d8f8be | 45 | Digital_InOut u2(p1_9,0,output);// SW11 |
kiran_mbed | 0:313541d8f8be | 46 | |
kiran_mbed | 0:313541d8f8be | 47 | Digital_InOut u3(p1_4,0,output);// SW13 |
kiran_mbed | 0:313541d8f8be | 48 | Digital_InOut u4(p1_0,0,output);// SW15 |
kiran_mbed | 0:313541d8f8be | 49 | |
kiran_mbed | 0:313541d8f8be | 50 | AnalogOut ledstream(p18); |
kiran_mbed | 0:313541d8f8be | 51 | |
kiran_mbed | 0:313541d8f8be | 52 | //SW1 - SW3 |
kiran_mbed | 0:313541d8f8be | 53 | Digital_InOut boSW1(p1_29,1,output); |
kiran_mbed | 0:313541d8f8be | 54 | Digital_InOut biSWBR(p1_27,pull_down,input); //BRight |
kiran_mbed | 0:313541d8f8be | 55 | |
kiran_mbed | 0:313541d8f8be | 56 | Digital_InOut boSW5(p1_25,1,output); |
kiran_mbed | 0:313541d8f8be | 57 | Digital_InOut biSWBL(p1_22,pull_down,input); //BLeft |
kiran_mbed | 0:313541d8f8be | 58 | |
kiran_mbed | 0:313541d8f8be | 59 | //Digital_InOut boSW5(P1_25,1,output); |
kiran_mbed | 0:313541d8f8be | 60 | //Digital_InOut biSW7(P1_22,pull_down,input); |
kiran_mbed | 0:313541d8f8be | 61 | |
kiran_mbed | 0:313541d8f8be | 62 | Digital_InOut boSW10(p1_10,1,output); |
kiran_mbed | 0:313541d8f8be | 63 | Digital_InOut biSWTR(p1_8,pull_down,input); //TRight |
kiran_mbed | 0:313541d8f8be | 64 | |
kiran_mbed | 0:313541d8f8be | 65 | Digital_InOut boSW14(p1_1,1,output); |
kiran_mbed | 0:313541d8f8be | 66 | Digital_InOut biSWTL(p0_25,pull_down,input); //TLeft |
kiran_mbed | 0:313541d8f8be | 67 | |
kiran_mbed | 0:313541d8f8be | 68 | typedef union convert{ |
kiran_mbed | 0:313541d8f8be | 69 | float FLOAT; |
kiran_mbed | 0:313541d8f8be | 70 | char C_FLOAT[4]; |
kiran_mbed | 0:313541d8f8be | 71 | }ftc; |
kiran_mbed | 0:313541d8f8be | 72 | |
kiran_mbed | 0:313541d8f8be | 73 | char SwitchName[15][13]={ |
kiran_mbed | 0:313541d8f8be | 74 | "fuse", |
kiran_mbed | 0:313541d8f8be | 75 | "ams", |
kiran_mbed | 0:313541d8f8be | 76 | "imd", |
kiran_mbed | 0:313541d8f8be | 77 | "pcm", |
kiran_mbed | 0:313541d8f8be | 78 | "brkp", |
kiran_mbed | 0:313541d8f8be | 79 | "lft", |
kiran_mbed | 0:313541d8f8be | 80 | "intl", |
kiran_mbed | 0:313541d8f8be | 81 | "brko", |
kiran_mbed | 0:313541d8f8be | 82 | "ckpt", |
kiran_mbed | 0:313541d8f8be | 83 | "rgt", |
kiran_mbed | 0:313541d8f8be | 84 | "hvd", |
kiran_mbed | 0:313541d8f8be | 85 | "tsms" |
kiran_mbed | 0:313541d8f8be | 86 | }; |
kiran_mbed | 0:313541d8f8be | 87 | |
kiran_mbed | 0:313541d8f8be | 88 | int SwitchPosition[13][2]={ |
kiran_mbed | 0:313541d8f8be | 89 | {0,16}, //fuse |
kiran_mbed | 0:313541d8f8be | 90 | {25,16}, //ams |
kiran_mbed | 0:313541d8f8be | 91 | {50,16}, //imd |
kiran_mbed | 0:313541d8f8be | 92 | {70,16}, //pcm |
kiran_mbed | 0:313541d8f8be | 93 | {93,16}, //brkp |
kiran_mbed | 0:313541d8f8be | 94 | {117,16}, //lft |
kiran_mbed | 0:313541d8f8be | 95 | {0,32}, //intl |
kiran_mbed | 0:313541d8f8be | 96 | {17,32}, //brko |
kiran_mbed | 0:313541d8f8be | 97 | {42,32}, //ckpt |
kiran_mbed | 0:313541d8f8be | 98 | {65,32}, //rgt |
kiran_mbed | 0:313541d8f8be | 99 | {81,32}, //hvd |
kiran_mbed | 0:313541d8f8be | 100 | {102,32}, //tsm |
kiran_mbed | 0:313541d8f8be | 101 | }; |
kiran_mbed | 0:313541d8f8be | 102 | |
kiran_mbed | 0:313541d8f8be | 103 | int maxScreen=5; |
kiran_mbed | 0:313541d8f8be | 104 | int screen; |
palimar | 9:e946cafa3cae | 105 | |
palimar | 9:e946cafa3cae | 106 | char drive_status; |
palimar | 13:1f05dcd9ae0e | 107 | char drive_status_request; |
palimar | 9:e946cafa3cae | 108 | char reset_body; |
palimar | 9:e946cafa3cae | 109 | |
palimar | 13:1f05dcd9ae0e | 110 | CANMessage Txmsg_drive_status_request(0x501,&drive_status_request,1); |
palimar | 9:e946cafa3cae | 111 | CANMessage Txmsg_reset(0x502,&reset_body,1); |
palimar | 9:e946cafa3cae | 112 | |
kiran_mbed | 0:313541d8f8be | 113 | #endif /* STEERING_H */ |