void status() { Serial.print(F("Runtime=")); Serial.print(heure); Serial.print(":"); Serial.println(minutes); check_reset_cause(); Serial.print(F("freeMemory=")); Serial.print(freeMemory()); Serial.println(F("Ko")); Serial.print("main cycle actual="); Serial.print(main_actual); Serial.print(", max="); Serial.println(main_max); Serial.print("main period actual="); Serial.print(main_period_actual); Serial.print(", max="); Serial.println(main_period_max); Serial.print("other cycle actual="); Serial.print(other_actual); Serial.print(", max="); Serial.println(other_max); }
void system_pre_init(void) { /* Enable direct NVIC */ MEC1322_EC_INT_CTRL |= 1; /* Disable ARM TRACE debug port */ MEC1322_EC_TRACE_EN &= ~1; /* Deassert nSIO_RESET */ MEC1322_PCR_PWR_RST_CTL &= ~(1 << 0); check_reset_cause(); }
int system_is_reboot_warm(void) { uint32_t reset_flags; /* * Check reset cause here, * gpio_pre_init is executed faster than system_pre_init */ check_reset_cause(); reset_flags = system_get_reset_flags(); if ((reset_flags & RESET_FLAG_RESET_PIN) || (reset_flags & RESET_FLAG_POWER_ON) || (reset_flags & RESET_FLAG_WATCHDOG) || (reset_flags & RESET_FLAG_HARD) || (reset_flags & RESET_FLAG_SOFT) || (reset_flags & RESET_FLAG_HIBERNATE)) return 0; else return 1; }
void setup() { // read the cause of the reset mcusr=MCUSR; MCUSR=0; pinMode(STATUS_LED, OUTPUT); pinMode(FAULT_LED, OUTPUT); digitalWrite(FAULT_LED, HIGH); digitalWrite(STATUS_LED, LOW); delay(500); initBitlash(115200); // must be first to initialize serial port //start serial Serial.begin(115200); check_reset_cause(); Serial.print(F("------------ Setup start - ")); Serial.print(freeMemory()); Serial.println(F("Ko ------------")); list_debug(); list_lib_version(); /* memory allocation in function of the config stored in eeprom */ Serial.println(F("---------- memory allocation -----------")); if (NumberOfBoardIn8R8) IN8R8 = (In8R8*) malloc((NumberOfBoardIn8R8)*sizeof(In8R8)); Serial.print(F("Create IN8R8: ")); Serial.println(NumberOfBoardIn8R8); if (NumberOfBoardIn16) IN16 = (Input16*) malloc((NumberOfBoardIn16)*sizeof(Input16)); Serial.print(F("Create IN16: ")); Serial.println(NumberOfBoardIn16); if (NumberOfBoardR8) R8 = (Relay8*) malloc((NumberOfBoardR8)*sizeof(Relay8)); Serial.print(F("Create R8: ")); Serial.println(NumberOfBoardR8); if (NumberOfBoardIn4Dimmer4) IN4DIM4 = (In4Dimmer4*) malloc((NumberOfBoardIn4Dimmer4)*sizeof(In4Dimmer4)); Serial.print(F("Create IN4DIM4 :")); Serial.println(NumberOfBoardIn4Dimmer4); if (NumberOfSwitch) SWITCH = (Switch*) malloc((NumberOfSwitch)*sizeof(Switch)); Serial.print(F("Create SWITCH:")); Serial.println(NumberOfSwitch); if (NumberOfShutter) SHUTTER = (Shutter*) malloc((NumberOfShutter)*sizeof(Shutter)); Serial.print(F("Create SHUTTER:")); Serial.println(NumberOfShutter); // create the instances of Lighting if (NumberOfLighting) LIGHTING = (Lighting*) malloc((NumberOfLighting)*sizeof(Lighting)); Serial.print(F("Create LIGHTING:")); Serial.println(NumberOfLighting); // create the instances of Temperature if (NumberOfTemp) TEMPERATURE = (Temperature*) malloc((NumberOfTemp)*sizeof(Temperature)); Serial.print(F("Create Temperature:")); Serial.println(NumberOfTemp); // create the instances of RF Device if (NumberOfRFDevice) RFDEVICE = (RFDevice*) malloc((NumberOfRFDevice)*sizeof(RFDevice)); Serial.print(F("Create RFDevice: ")); Serial.println(NumberOfRFDevice); pinMode(int_i2c,INPUT); // configure the pin of the i2c interrupt signal as input digitalWrite(int_i2c, HIGH); // active the internal pull-up setup_Udp(); // start Ethernet clock_setup(); // start pulse generator Serial.println(F("------------ setup i2c ------------")); Wire.begin(); // start i2c I2c16.begin() ; // start i2c I2c16.timeOut(1000); /// à valider, permet de ne pas rester bloquer par une operation i2c Serial.println(F("---------- setup i2c end -----------")); setup_bitlash(); // setup bitlash if(NumberOfTemp>0){ Serial.println(F("------------ setup DS2482 ------------")); DS2482_Init(); //initialize the DS2482 for OneWire Serial.println(F("---------- setup DS2482 end -----------")); delay(100); } if(NumberOfRFDevice>0){ Serial.println(F("------------ setup RF module ------------")); Setup_RF(); Serial.println(F("---------- setup RF module end -----------")); } /* configuration des cartes */ /// futurement sur lecture de l'eeprom config_board(); // cf custom.ino init_instance(); // cf custom.ino //~ Serial.println(F("---------- shutter initializ -----------")); /// initialise les volets au démarrage (devrait être optionnel, par config) => desormais on relit l'epprom //~ if(NumberOfShutter){ //~ for(int i=0; i<NumberOfShutter; i++){ //~ SHUTTER[i].reset(); //~ } //~ } digitalWrite(FAULT_LED, LOW); digitalWrite(STATUS_LED, HIGH); Serial.print(F("------------ Setup end - ")); Serial.print(freeMemory()); Serial.println(F("Ko ------------")); main_period_prev_millis=millis(); main_prev_millis=millis(); other_prev_millis=millis(); }
void system_pre_init(void) { check_reset_cause(); }