Merge pull request #2446 from wavexx/uvlo_late_init

Refuse to start a print if power is lost before arming uvlo
This commit is contained in:
DRracer 2020-01-30 11:16:49 +01:00 committed by GitHub
commit 1d3cd54670
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 7 deletions

View File

@ -10480,6 +10480,16 @@ void serialecho_temperatures() {
} }
#ifdef UVLO_SUPPORT #ifdef UVLO_SUPPORT
void uvlo_drain_reset()
{
// burn all that residual power
wdt_enable(WDTO_1S);
WRITE(BEEPER,HIGH);
lcd_clear();
lcd_puts_at_P(0, 1, MSG_POWERPANIC_DETECTED);
while(1);
}
void uvlo_() void uvlo_()
{ {
@ -10709,11 +10719,7 @@ void uvlo_tiny()
eeprom_update_word((uint16_t*)EEPROM_POWER_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_POWER_COUNT_TOT) + 1); eeprom_update_word((uint16_t*)EEPROM_POWER_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_POWER_COUNT_TOT) + 1);
printf_P(_N("UVLO_TINY - end %d\n"), _millis() - time_start); printf_P(_N("UVLO_TINY - end %d\n"), _millis() - time_start);
uvlo_drain_reset();
// burn all that residual power
wdt_enable(WDTO_1S);
WRITE(BEEPER,HIGH);
while(1);
} }
#endif //UVLO_SUPPORT #endif //UVLO_SUPPORT
@ -10760,12 +10766,19 @@ void setup_uvlo_interrupt() {
DDRE &= ~(1 << 4); //input pin DDRE &= ~(1 << 4); //input pin
PORTE &= ~(1 << 4); //no internal pull-up PORTE &= ~(1 << 4); //no internal pull-up
//sensing falling edge // sensing falling edge
EICRB |= (1 << 0); EICRB |= (1 << 0);
EICRB &= ~(1 << 1); EICRB &= ~(1 << 1);
//enable INT4 interrupt // enable INT4 interrupt
EIMSK |= (1 << 4); EIMSK |= (1 << 4);
// check if power was lost before we armed the interrupt
if(!(PINE & (1 << 4)) && eeprom_read_byte((uint8_t*)EEPROM_UVLO))
{
SERIAL_ECHOLNPGM("INT4");
uvlo_drain_reset();
}
} }
ISR(INT4_vect) { ISR(INT4_vect) {

View File

@ -171,3 +171,4 @@ const char MSG_M112_KILL[] PROGMEM_N1 = "M112 called. Emergency Stop."; ////c=20
#ifdef LA_LIVE_K #ifdef LA_LIVE_K
const char MSG_ADVANCE_K[] PROGMEM_N1 = "Advance K:"; ////c=13 const char MSG_ADVANCE_K[] PROGMEM_N1 = "Advance K:"; ////c=13
#endif #endif
const char MSG_POWERPANIC_DETECTED[] PROGMEM_N1 = "POWER PANIC DETECTED"; ////c=20

View File

@ -170,6 +170,7 @@ extern const char MSG_FANCHECK_EXTRUDER[];
extern const char MSG_FANCHECK_PRINT[]; extern const char MSG_FANCHECK_PRINT[];
extern const char MSG_M112_KILL[]; extern const char MSG_M112_KILL[];
extern const char MSG_ADVANCE_K[]; extern const char MSG_ADVANCE_K[];
extern const char MSG_POWERPANIC_DETECTED[];
#if defined(__cplusplus) #if defined(__cplusplus)
} }