Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of RAJANGAM_REVIEW_BAE_CODE by
Diff: EPS.cpp
- Revision:
- 52:daa685b0e390
- Parent:
- 51:661dc022613a
- Child:
- 53:459b71b1861c
--- a/EPS.cpp Fri Jul 22 17:32:41 2016 +0000
+++ b/EPS.cpp Fri Jul 22 22:21:05 2016 +0000
@@ -99,7 +99,7 @@
DigitalIn EPS_CHARGER_STATUS(PIN31);
DigitalIn EPS_BATTERY_GAUGE_ALERT(PIN73);
-//m_I2C.frequency(10000)
+//i2c.frequency(10000)
extern int eps_btg_read_flag; // flag to check I2C ack on reading from BTG
extern int eps_btg_writ_flag; // flag to check I2C ack on writing from BTG
@@ -115,7 +115,7 @@
//......................................Peripheral declarations.........................................................//
Serial pc_eps(USBTX,USBRX);
-I2C m_I2C(PIN85,PIN84);
+extern I2C i2c;
//any default values or states
//====================================
@@ -282,10 +282,12 @@
if(ACS_TR_Z_SW_STATUS != 0b11) //!disabled
{
if(ACS_TR_Z_SW_STATUS == 0b10) //oc fault and powered off
+ ACS_TR_Z_ENABLE = 0;
+ //printf("ACS_TR_Z_OC_FAULT : %d \r\n",(int)ACS_TR_Z_OC_FAULT.read());
+ //printf("ACS_TR_Z_FAULT : %d \r\n",(int)ACS_TR_Z_FAULT.read());
+ if( (ACS_TR_Z_OC_FAULT == 0) || (ACS_TR_Z_FAULT==0))
+ {
ACS_TR_Z_ENABLE = 1;
- if(ACS_TR_Z_OC_FAULT || ACS_TR_Z_FAULT)
- {
- ACS_TR_Z_ENABLE = 0;
ACS_TR_Z_FAULT_COUNTER++; //Temp name
if(ACS_TR_Z_FAULT_COUNTER == 3)
ACS_TR_Z_SW_STATUS = 0b11; //disabled
@@ -305,10 +307,13 @@
if(ACS_TR_XY_SW_STATUS != 0b11) //!disabled
{
if(ACS_TR_XY_SW_STATUS == 0b10) //oc fault and powered off
+ ACS_TR_XY_ENABLE = 0;
+
+ //printf("ACS_TR_XY_OC_FAULT : %d \r\n",(int)ACS_TR_XY_OC_FAULT.read());
+ //printf("ACS_TR_XY_FAULT : %d \r\n",(int)ACS_TR_XY_FAULT.read());
+ if( (ACS_TR_XY_OC_FAULT==0) || (ACS_TR_XY_FAULT==0))
+ {
ACS_TR_XY_ENABLE = 1;
- if(ACS_TR_XY_OC_FAULT || ACS_TR_XY_FAULT)
- {
- ACS_TR_XY_ENABLE = 0;
ACS_TR_XY_FAULT_COUNTER++; //Temp name
if(ACS_TR_XY_FAULT_COUNTER == 3)
ACS_TR_XY_SW_STATUS = 0b11; //disabled
@@ -322,7 +327,7 @@
ACS_TR_XY_FAULT_COUNTER = 0;
}
}
-
+/*
//--------ACS_ATS1--------//
//Same as ACS_ATS2
//if(ACS_ATS1_SW_STATUS & 0b1100 != 0b1100) //!disabled
@@ -330,10 +335,11 @@
{
//if(ACS_ATS1_SW_STATUS & 0b1100 == 0b1000) //oc fault and powered off
if(ACS_ATS_STATUS&0xC0!=0x80)
- ATS1_SW_ENABLE = 0; //Temp name
- if(ACS_ATS1_OC_FAULT)
+ ATS1_SW_ENABLE = 1; //Temp name
+ //if(ACS_ATS1_OC_FAULT)
+ if(0)
{
- ATS1_SW_ENABLE = 1;
+ ATS1_SW_ENABLE = 0;
ACS_ATS1_FAULT_COUNTER++; //Temp name
if(ACS_ATS1_FAULT_COUNTER == 3)
//ACS_ATS1_SW_STATUS = ACS_ATS1_SW_STATUS | 0b1100; //disabled
@@ -350,7 +356,7 @@
{
//if(ACS_ATS1_SW_STATUS & 0b1100 == 0b1000) //Device oc fault?
if(ACS_ATS_STATUS&0xC0==0x80)
- ATS1_SW_ENABLE = 1;
+ ATS1_SW_ENABLE = 0;
//ACS_ATS1_SW_STATUS = ACS_ATS1_SW_STATUS & 0b0011; //working but powered off
ACS_ATS_STATUS = ACS_ATS_STATUS&0x3F;
//Update in flash also
@@ -365,7 +371,8 @@
//if(ACS_ATS2_SW_STATUS & 0b1100 == 0b1000) //oc fault and powered off
if(ACS_ATS_STATUS&0x0C!=0x08)
ATS2_SW_ENABLE = 0; //Temp name
- if(ACS_ATS2_OC_FAULT)
+ //if(ACS_ATS2_OC_FAULT)
+ if(0)
{
ATS2_SW_ENABLE = 1;
ACS_ATS2_FAULT_COUNTER++; //Temp name
@@ -392,13 +399,18 @@
}
}
+ */
+
+ printf("");
+
+
//--------BCN_TX----------//
/* Commented out to test BCN TC
if(BCN_TX_SW_STATUS != 0b11) //!disabled
{
if(BCN_TX_SW_STATUS == 0b10) //oc fault and powered off
BCN_TX_ENABLE = 1; //Temp name
- if(BCN_TX_OC_FAULT)
+ if(BCN_TX_OC_FAULT==0)
{
BCN_TX_ENABLE = 0;
BCN_TX_FAULT_COUNTER++; //Temp name
@@ -942,11 +954,11 @@
buff[1] = data >> 8;
buff[2] = data;
- int flag = m_I2C.write(m_ADDR, buff, 3); //Write the data and return ack
+ int flag = i2c.write(m_ADDR, buff, 3); //Write the data and return ack
if( flag != 0 )
{
- flag = m_I2C.write(m_ADDR, buff, 3); //Write the data and return ack
+ flag = i2c.write(m_ADDR, buff, 3); //Write the data and return ack
if( data != read(reg) )
eps_btg_writ_flag = 1;
//EPS_BATTERY_GAUGE_STATUS = 0; //clear EPS_BATTERY_GAUGE_STATUS
@@ -965,14 +977,14 @@
char buff[2]; //Create a temporary buffer
//Select the register
- m_I2C.write(m_ADDR, ®, 1, true);
+ i2c.write(m_ADDR, ®, 1, true);
//Read the 16-bit register
- flag = m_I2C.read(m_ADDR, buff, 2);
+ flag = i2c.read(m_ADDR, buff, 2);
if( flag )
{
- m_I2C.write(m_ADDR, ®, 1, true);
- flag = m_I2C.read(m_ADDR, buff, 2);
+ i2c.write(m_ADDR, ®, 1, true);
+ flag = i2c.read(m_ADDR, buff, 2);
//if( flag )
// EPS_BATTERY_GAUGE_STATUS = 0; //clear EPS_BATTERY_GAUGE_STATUS
}
@@ -990,10 +1002,10 @@
char buff[2];
//Select the register
- m_I2C.write(m_ADDR, ®, 1, true);
+ i2c.write(m_ADDR, ®, 1, true);
//Read the 16-bit register
- m_I2C.read(m_ADDR, buff, 2);
+ i2c.read(m_ADDR, buff, 2);
//Return the combined 16-bit value
return (buff[0] << 8) | buff[1];
@@ -1014,7 +1026,7 @@
buff[2] = data;
//Write the data
- m_I2C.write(m_ADDR, buff, 3);
+ i2c.write(m_ADDR, buff, 3);
}
@@ -1227,12 +1239,12 @@
int ack = 1;
//Select the register
char reg = REG_SOC; // cannot pass the hash defined values directly
- m_I2C.write(m_ADDR, ®, 1, true);
+ i2c.write(m_ADDR, ®, 1, true);
//Read the 16-bit register
- ack = m_I2C.read(m_ADDR, buff, 2);
+ ack = i2c.read(m_ADDR, buff, 2);
//// eps_pc.printf("\n\r acknow %d", ack);
