bae wrking isr no bcn

Dependencies:   mbed-rtos mbed

Fork of TV_BAE_conops1_1_1 by Team Fox

Committer:
sakthipriya
Date:
Tue Nov 03 14:46:51 2015 +0000
Revision:
0:913c9e982740
i2c in rtos working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sakthipriya 0:913c9e982740 1 #include "mbed.h"
sakthipriya 0:913c9e982740 2 #include "pin_config.h"
sakthipriya 0:913c9e982740 3 //.............Power switching..........
sakthipriya 0:913c9e982740 4 #define TRXY_DR_EN PIN82 //torque rod driver enable
sakthipriya 0:913c9e982740 5 #define TRZ_DR_EN PIN88
sakthipriya 0:913c9e982740 6 #define ENBL3V3A PIN33
sakthipriya 0:913c9e982740 7 #define VBATT PIN20
sakthipriya 0:913c9e982740 8 #define BATT_HEAT PIN96
sakthipriya 0:913c9e982740 9 //#define BATT_HEAT_OUTPUT
sakthipriya 0:913c9e982740 10 //......................HK.....................
sakthipriya 0:913c9e982740 11 #define vstart 3.3
sakthipriya 0:913c9e982740 12 #define vstep 0.84667
sakthipriya 0:913c9e982740 13 #define cstart 0.0691
sakthipriya 0:913c9e982740 14 #define cstep 0.09133
sakthipriya 0:913c9e982740 15 #define tstart -40
sakthipriya 0:913c9e982740 16 #define tstep 8.33
sakthipriya 0:913c9e982740 17 #define rsens 0.025
sakthipriya 0:913c9e982740 18 #define Bnewvalue_start -100//in microTesla...max possible field is .0001 T
sakthipriya 0:913c9e982740 19 #define Bnewvalue_step 13.333
sakthipriya 0:913c9e982740 20 #define AngularSpeed_start -10//max possible ang. velocity in space is 10 deg/sec
sakthipriya 0:913c9e982740 21 #define AngularSpeed_step 1.3333
sakthipriya 0:913c9e982740 22 //...............Battery Gauge................
sakthipriya 0:913c9e982740 23 #define BG_ADDR (0x6C) //slave address of battery gauge
sakthipriya 0:913c9e982740 24 //I2C register addresses
sakthipriya 0:913c9e982740 25 #define REG_VCELL 0x02
sakthipriya 0:913c9e982740 26 #define REG_SOC 0x04
sakthipriya 0:913c9e982740 27 #define REG_MODE 0x06
sakthipriya 0:913c9e982740 28 #define REG_VERSION 0x08
sakthipriya 0:913c9e982740 29 #define REG_HIBRT 0x0A
sakthipriya 0:913c9e982740 30 #define REG_CONFIG 0x0C
sakthipriya 0:913c9e982740 31 #define REG_VALRT 0x14
sakthipriya 0:913c9e982740 32 #define REG_CRATE 0x16
sakthipriya 0:913c9e982740 33 #define REG_VRESET_ID 0x18
sakthipriya 0:913c9e982740 34 #define REG_STATUS 0x1A
sakthipriya 0:913c9e982740 35 #define REG_TABLE 0x40
sakthipriya 0:913c9e982740 36 #define REG_CMD 0xFE
sakthipriya 0:913c9e982740 37 //..............Battery heater...............
sakthipriya 0:913c9e982740 38 #define BHT_LOWTHRESH 30 // to be fixed
sakthipriya 0:913c9e982740 39 #define BHT_HIGHTHRESH 40 // to be fixed
sakthipriya 0:913c9e982740 40
sakthipriya 0:913c9e982740 41 typedef struct SensorData
sakthipriya 0:913c9e982740 42 {
sakthipriya 0:913c9e982740 43 float SOC; //added recently
sakthipriya 0:913c9e982740 44 float Vbatt; //added recently
sakthipriya 0:913c9e982740 45 float Voltage[15];
sakthipriya 0:913c9e982740 46 float Current[7];
sakthipriya 0:913c9e982740 47 float Temperature[1];
sakthipriya 0:913c9e982740 48 //float PanelTemperature[4]; // not finalised ///there wer 4 values here?
sakthipriya 0:913c9e982740 49 float BatteryTemperature[2];
sakthipriya 0:913c9e982740 50 char fault_poll; //polled faults
sakthipriya 0:913c9e982740 51 char fault_ir; //interrupted faults
sakthipriya 0:913c9e982740 52 char clear_fault_poll; //to be confirmed
sakthipriya 0:913c9e982740 53 char clear_fault_ir;
sakthipriya 0:913c9e982740 54 char power_mode; //power modes
sakthipriya 0:913c9e982740 55 float AngularSpeed[3]; //in order x,y,z
sakthipriya 0:913c9e982740 56 float Bnewvalue[3]; //in order Bx,By,Bz
sakthipriya 0:913c9e982740 57 } SensorData;
sakthipriya 0:913c9e982740 58
sakthipriya 0:913c9e982740 59
sakthipriya 0:913c9e982740 60 typedef struct SensorDataQuantised
sakthipriya 0:913c9e982740 61 {
sakthipriya 0:913c9e982740 62 char Voltage[8];
sakthipriya 0:913c9e982740 63 char Current[4];
sakthipriya 0:913c9e982740 64 char Temperature[1];
sakthipriya 0:913c9e982740 65 //char PanelTemperature[2];//read by the 4 thermistors on solar panels
sakthipriya 0:913c9e982740 66 char BatteryTemperature; //to be populated
sakthipriya 0:913c9e982740 67 char faultpoll; //polled faults
sakthipriya 0:913c9e982740 68 char faultir; //interrupted faults
sakthipriya 0:913c9e982740 69 char power_mode; //power modes
sakthipriya 0:913c9e982740 70 char AngularSpeed[2];
sakthipriya 0:913c9e982740 71 char Bnewvalue[2];
sakthipriya 0:913c9e982740 72
sakthipriya 0:913c9e982740 73 //float magnetometer,gyro=>to be addes
sakthipriya 0:913c9e982740 74 } SensorDataQuantised;
sakthipriya 0:913c9e982740 75
sakthipriya 0:913c9e982740 76
sakthipriya 0:913c9e982740 77 typedef struct ShortBeacon
sakthipriya 0:913c9e982740 78 {
sakthipriya 0:913c9e982740 79 char Voltage[1]; //battery voltage from gauge, needs to be quantised
sakthipriya 0:913c9e982740 80 char AngularSpeed[2]; //all the 3 data
sakthipriya 0:913c9e982740 81 char SubsystemStatus[1]; //power modes
sakthipriya 0:913c9e982740 82 char Temp[2]; //temp of solar panel
sakthipriya 0:913c9e982740 83 //Temp[0]'s LSB=> PanelTemperature[0], Temp[0]'s MSB=> PanelTemperature[1], Temp[1]'s LSB=> PanelTemperature[2], Temp[1]'s MSB=> PanelTemperature[3]
sakthipriya 0:913c9e982740 84 char ErrorFlag[1]; //fault
sakthipriya 0:913c9e982740 85 }ShortBeacy;
sakthipriya 0:913c9e982740 86
sakthipriya 0:913c9e982740 87
sakthipriya 0:913c9e982740 88 /******************************************************function headers************************************************************************/
sakthipriya 0:913c9e982740 89 void FCTN_EPS_INIT();
sakthipriya 0:913c9e982740 90 void FCTN_EPS_BTEMP_INIT();
sakthipriya 0:913c9e982740 91 void FCTN_EPS_BTEMP_MAIN(float*);
sakthipriya 0:913c9e982740 92 void FCTN_EPS_BTRY_HEATER();
sakthipriya 0:913c9e982740 93 void FCTN_EPS_BG_INIT();
sakthipriya 0:913c9e982740 94 void FCTN_EPS_BG_MAIN();
sakthipriya 0:913c9e982740 95 void FCTN_EPS_POWERMODE(float);
sakthipriya 0:913c9e982740 96 void FCTN_EPS_CTRLPOWER(int) ;
sakthipriya 0:913c9e982740 97 int FCTN_QUANTIZE(float ,float ,float );
sakthipriya 0:913c9e982740 98 void FCTN_WRITE_BEASTRUCT(ShortBeacy* ,SensorDataQuantised );
sakthipriya 0:913c9e982740 99 void FCTN_EPS_HK_MAIN();
sakthipriya 0:913c9e982740 100 void FCTN_HK_DATA_CATENATE();
sakthipriya 0:913c9e982740 101
sakthipriya 0:913c9e982740 102 extern void FLAG();
sakthipriya 0:913c9e982740 103
sakthipriya 0:913c9e982740 104
sakthipriya 0:913c9e982740 105 unsigned short BG_readReg(char);
sakthipriya 0:913c9e982740 106 void BG_writeReg(char, unsigned short);
sakthipriya 0:913c9e982740 107 void BG_reset(); //not used in code
sakthipriya 0:913c9e982740 108 void BG_quickStart(); //not used in code
sakthipriya 0:913c9e982740 109 void BG_disableSleep();
sakthipriya 0:913c9e982740 110 void BG_disableHibernate();
sakthipriya 0:913c9e982740 111 void BG_socChangeAlertEnabled(bool);
sakthipriya 0:913c9e982740 112 float BG_compensation(); //not used in code
sakthipriya 0:913c9e982740 113 void BG_compensation(char);
sakthipriya 0:913c9e982740 114 void BG_tempCompensation(float);
sakthipriya 0:913c9e982740 115 bool BG_alerting();
sakthipriya 0:913c9e982740 116 void BG_clearAlert();
sakthipriya 0:913c9e982740 117 void BG_emptyAlertThreshold(char);
sakthipriya 0:913c9e982740 118 void BG_vAlertMinMaxThreshold();
sakthipriya 0:913c9e982740 119 void BG_vResetThresholdSet();
sakthipriya 0:913c9e982740 120 void BG_vResetAlertEnabled(bool);
sakthipriya 0:913c9e982740 121 char BG_alertFlags();
sakthipriya 0:913c9e982740 122 void BG_clearAlertFlags();
sakthipriya 0:913c9e982740 123 float BG_vcell();
sakthipriya 0:913c9e982740 124 float BG_soc();
sakthipriya 0:913c9e982740 125
sakthipriya 0:913c9e982740 126
sakthipriya 0:913c9e982740 127