void Reflow_ValidateNV(void) { if (NV_GetConfig(REFLOW_BEEP_DONE_LEN) == 255) { // Default 1 second beep length NV_SetConfig(REFLOW_BEEP_DONE_LEN, 10); } if (NV_GetConfig(REFLOW_MIN_FAN_SPEED) == 255) { // Default fan speed is now 8 NV_SetConfig(REFLOW_MIN_FAN_SPEED, 8); } if (NV_GetConfig(REFLOW_BAKE_SETPOINT_H) == 255 || NV_GetConfig(REFLOW_BAKE_SETPOINT_L) == 255) { NV_SetConfig(REFLOW_BAKE_SETPOINT_H, SETPOINT_DEFAULT >> 8); NV_SetConfig(REFLOW_BAKE_SETPOINT_L, (uint8_t)SETPOINT_DEFAULT); printf("Resetting bake setpoint to default."); }
void Setup_setValue(int item, int value) { NV_SetConfig(setupmenu[item].nvval, value); Reflow_ValidateNV(); }
int main(void) { char buf[22]; int len; PLLCFG = (1<<5) | (4<<0); //PLL MSEL=0x4 (+1), PSEL=0x1 (/2) so 11.0592*5 = 55.296MHz, Fcco = (2x55.296)*2 = 221MHz which is within 156 to 320MHz PLLCON = 0x01; PLLFEED = 0xaa; PLLFEED = 0x55; // Feed complete while(!(PLLSTAT & (1<<10))); // Wait for PLL to lock PLLCON = 0x03; PLLFEED = 0xaa; PLLFEED = 0x55; // Feed complete VPBDIV = 0x01; // APB runs at the same frequency as the CPU (55.296MHz) MAMTIM = 0x03; // 3 cycles flash access recommended >40MHz MAMCR = 0x02; // Fully enable memory accelerator Sched_Init(); IO_Init(); Set_Heater(0); Set_Fan(0); Serial_Init(); I2C_Init(); EEPROM_Init(); NV_Init(); if( NV_GetConfig(REFLOW_BEEP_DONE_LEN) == 255 ) { NV_SetConfig(REFLOW_BEEP_DONE_LEN, 10); // Default 1 second beep length } printf("\nInitializing improved reflow oven..."); LCD_Init(); LCD_BMPDisplay(logobmp,0,0); // Setup watchdog WDTC = PCLKFREQ / 3; // Some margin (PCLKFREQ/4 would be exactly the period the WD is fed by sleep_work) WDMOD = 0x03; // Enable WDFEED = 0xaa; WDFEED = 0x55; uint8_t resetreason = RSIR; RSIR = 0x0f; // Clear it out printf("\nReset reason(s): %s%s%s%s", (resetreason&(1<<0))?"[POR]":"", (resetreason&(1<<1))?"[EXTR]":"", (resetreason&(1<<2))?"[WDTR]":"", (resetreason&(1<<3))?"[BODR]":""); // Request part number command[0] = IAP_READ_PART; iap_entry(command, result); const char* partstrptr = NULL; for(int i=0; i<NUM_PARTS; i++) { if(result[1] == partmap[i].id) { partstrptr = partmap[i].name; break; } } // Read part revision partrev=*(uint8_t*)PART_REV_ADDR; if(partrev==0 || partrev > 0x1a) { partrev = '-'; } else { partrev += 'A' - 1; } len = snprintf(buf,sizeof(buf),"%s rev %c",partstrptr,partrev); LCD_disp_str((uint8_t*)buf, len, 0, 64-6, FONT6X6); printf("\nRunning on an %s", buf); LCD_FB_Update(); Keypad_Init(); Buzzer_Init(); ADC_Init(); RTC_Init(); OneWire_Init(); Reflow_Init(); Sched_SetWorkfunc( MAIN_WORK, Main_Work ); Sched_SetState( MAIN_WORK, 1, TICKS_SECS( 2 ) ); // Enable in 2 seconds Buzzer_Beep( BUZZ_1KHZ, 255, TICKS_MS(100) ); while(1) { int32_t sleeptime; sleeptime=Sched_Do( 0 ); // No fast-forward support //printf("\n%d ticks 'til next activity"),sleeptime); } return 0; }