The Code Repository for the REV0 Steering Wheel.

Dependencies:   CANBuffer KS0108_fork mbed-rtos mbed CAN Addresses

Fork of REVO_Updated_Steering by Penn Electric

Steering.h

Committer:
palimar
Date:
2014-11-22
Revision:
35:b42afc973902
Parent:
32:535acb159709
Child:
36:8544a8900884

File content as of revision 35:b42afc973902:

#ifndef _STEERING_H
#define _STEERING_H

#include "mbed.h"
#include "rtos.h"
#include "KS0108.h"

#include "Arial10.h"
#include "Arial12.h"
#include "Arial14.h"
#include "Comic24.h"
#include "vivaldi16.h"
#include "CANBuffer.h"
#include "variables.h"


#include "LPCDigitalIn.h"

#define SWITCH_ID 410

#define BATTERY_VOLTAGE_ID 0x304
#define BATTERY_POWER_ID 0x306
#define BATTERY_CURRENT_ID 0x305

#define PCM_STATE_ID 0x201

#define BATTERY_MIN_CELLVOLTAGE_ID 0x301
#define BATTERY_MAX_CELLVOLTAGE_ID 0x300
#define BATTERY_AVG_CELLVOLTAGE_ID 0x302

#define BATTERY_MIN_CELLTEMPERATURE_ID 0x30A
#define BATTERY_MAX_CELLTEMPERATURE_ID 0x309
#define BATTERY_AVG_CELLTEMPERATURE_ID 0x30B
#define AMS_BATTERY_STATE 0x30E          // AIRS 7 and 6 // Precharge 3

#define NUM_SCREEN 2

#define HOME_SCREEN 0
#define BATTERY_SCREEN 1

Serial pc(USBTX,USBRX);
CANBuffer CAN_Steering_Buffer(CAN1, MEDIUM, p3_26);


KS0108 display(p26, p21, p22, p23, p25, p24, p8, p7, p6, p5, p13, p14, p12, p11); 
//Ticker call_ledstream;

LPCDigitalOut l1(p1_28,1);//    SW2
LPCDigitalOut l2(p1_26,1);//    SW4
    
LPCDigitalOut l3(p1_24,1);//    SW6
LPCDigitalOut l4(p0_24,1);//    SW8

LPCDigitalOut u1(p1_14,0);//    SW9 
LPCDigitalOut u2(p1_9,0);//     SW11

LPCDigitalOut u3(p1_4,0);//     SW13
LPCDigitalOut u4(p1_0,0);//     SW15

AnalogOut ledstream(p18);

//SW1 - SW3
LPCDigitalOut boSW1(p1_29,1);
LPCDigitalIn biSWBR(p1_27, PullDown);     //BRight

LPCDigitalOut boSW5(p1_25,1);
LPCDigitalIn biSWBL(p1_22, PullDown);     //BLeft

LPCDigitalOut boSW10(p1_10,1);
LPCDigitalIn biSWTR(p1_8, PullDown);     //TRight

LPCDigitalOut boSW14(p1_1,1);
LPCDigitalIn biSWTL(p0_25, PullDown);    //TLeft

typedef union convert{
        float FLOAT;
        char C_FLOAT[4];
        }ftc;

char SwitchName[15][13]={
    "fuse",
    "ams",
    "imd",
    "pcm",
    "brkp",
    "lft",
    "intl",
    "brko",
    "ckpt",
    "rgt",
    "hvd",
    "tsms"
};

int SwitchPosition[13][2]={
    {0,16},     //fuse
    {25,16},    //ams
    {50,16},    //imd
    {70,16},    //pcm
    {93,16},    //brkp
    {117,16},   //lft
    {0,32},     //intl
    {17,32},    //brko
    {42,32},    //ckpt
    {65,32},    //rgt
    {81,32},    //hvd
    {102,32},   //tsm
    };
    
int curr_screen;
int screen_flags[NUM_SCREEN]; 
bool should_redraw;

char drive_status;
char drive_status_request;
char reset_body;

node * id_node = NULL;
variables * vars_list;


Mutex ds_mutex;

/*
void read_messages(void const *args) {
    
    while (true) {
        CANMessage Rxmsg;
     
        if(CAN_Steering_Buffer.rxRead(Rxmsg))
            if(Rxmsg.id == PCM_STATE_ID){
              
                // Mutex to protex shared variables
                ds_mutex.lock();
                drive_status = Rxmsg.data[0];
                ds_mutex.unlock();
            }
            
            if(Rxmsg.id == BATTERY_POWER_ID)
            {
                float power_ratio;
                ftc rcv;
                rcv.FLOAT=0.0;
                
                for(int i=0; i<4; i++){
                    rcv.C_FLOAT[i] = Rxmsg.data[i];
                }
                power_ratio=rcv.FLOAT/80000;
                ledstream.write(power_ratio);
            }
        }
    }
*/

#endif /* STEERING_H */