00001 /* This file has been prepared for Doxygen automatic documentation generation.*/ 00025 #define MODULE_SAFETY 00026 #include "pack.h" //get macros we need 00027 #include "safety.h" 00028 //#include "iom406_320.h" 00029 #include "iom406.h" // IAR headerfile for Mega406 (EW 410) 00030 #include "pwrmgmt.h" 00031 00032 //Sets up h/w protection registers based on EEPROM values from Calibration procedure. 00033 // Also sets up necessary pieces for using the HWP interrupt. 00034 void HWProtectinit(void) 00035 { 00036 PACK_PROTECT_DUV //see pack.h for definitions & to make adjustments 00037 PACK_PROTECT_SHORT 00038 PACK_PROTECT_OVERC 00039 PACK_PROTECT_TIME 00040 00041 BPCR = 0; 00042 00043 BPIR = (1<<DUVIE) | (1<<COCIE) | (1<<DOCIE) | (1<<SCIE); 00044 00045 //Interrupts should really be disabled before attempting to lock! 00046 // BPPLR = (1<<BPPLE) | (1<<BPPL); 00047 // BPPLR = (1<<BPPL); 00048 00049 } 00050 00051 00052 00053 00054 // Handle hardware-protection trip. 00055 00056 #pragma vector = BPINT_vect 00057 __interrupt void HWP_int(void) 00058 { 00059 unsigned char temp = BPIR; 00060 00061 if(temp & (1<<DUVIF)) 00062 DoShutdown(SHUTDOWN_REASON_UNDERVOLTAGE); 00063 if(temp & (1<<COCIF)) 00064 DoShutdown(SHUTDOWN_REASON_CHARGE_OVERCURRENT); 00065 if(temp & (1<<DOCIF)) 00066 DoShutdown(SHUTDOWN_REASON_DISCHARGE_OVERCURRENT); 00067 if(temp & (1<<SCIF)) 00068 DoShutdown(SHUTDOWN_REASON_SHORTCIRCUIT); 00069 00070 BPIR |= 0xF0; //this actually won't execute, but is here as a reminder 00071 // that you need to MANUALLY reset these flags if you 00072 // choose to not shut down in here. 00073 } 00074 00075 00076 00077 00079 void SafetyScan(void) 00080 { 00081 ; 00082 00083 } 00084 00085 00086
1.5.3