alan broad
/
carbon_v5_arm_studio
arm studio build
Diff: src/main.cpp
- Revision:
- 8:a5316708e51d
- Parent:
- 7:fba1e8fc7693
- Child:
- 9:cc23b2049639
--- a/src/main.cpp Fri Aug 10 19:17:43 2018 +0000 +++ b/src/main.cpp Sat Aug 11 17:34:42 2018 +0000 @@ -56,8 +56,14 @@ #endif bool adr = false; //set adaptive data rate - - +//------------------------------------------------------------------------------------------------------ +//wait_after_sleep_usec +// -when xdot terminal display is disabled we need to add a delay between exiting sleep and polling for +// incoming i2c data from proc +// values of 300-5000 usec works +// - not sure why this is needed, it may take additional time for the uP to power up i2c io? +int16_t wait_after_sleep_usec =1000; +//------------------------------------------------------------------------------------------------------ @@ -66,6 +72,9 @@ // in sleep mode, IO state is maintained, RAM is retained, and application will resume after waking up // in deepsleep mode, IOs float, RAM is lost, and application will start from beginning after waking up // if deep_sleep == true, device will enter deepsleep mode +// asb: +// no longer use deepsleep since we want to retain state +// sleep uses only 1uA more current than deepsleep //======================================================================================================= static bool deep_sleep = false; //false; @@ -214,15 +223,14 @@ dot->setEvents(&events); nvmRead(pNvmData); - - //pNvmData->bLogOutputOn = 1; // TEST !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + if (pNvmData->bLogOutputOn == 0){ pc.printf("\r\nDISABLING TERMINAL OUTPUT\r\n"); -// dot->setLogLevel(mts::MTSLog::NONE_LEVEL); //doesn't work + dot->setLogLevel(mts::MTSLog::NONE_LEVEL); //doesn't work //dot->setLogLevel((true) ? mts::MTSLog::WARNING_LEVEL : mts::MTSLog::WARNING_LEVEL); //!!!!!!!!!!!! deosn't work //dot->setLogLevel((true) ? mts::MTSLog::INFO_LEVEL : mts::MTSLog::INFO_LEVEL); //!!!!!!!!!!!! this works - dot->setLogLevel((true) ? mts::MTSLog::TRACE_LEVEL : mts::MTSLog::TRACE_LEVEL); //!!!!!!!!!!!! this works - verbose = true; //TEST !!!!!!!!!!!!!!!!!!!!!!!!! + //dot->setLogLevel((true) ? mts::MTSLog::TRACE_LEVEL : mts::MTSLog::TRACE_LEVEL); //!!!!!!!!!!!! this works + verbose = false; } else{ printNmvData(pNvmData); @@ -263,11 +271,10 @@ eui = mts::Text::bin2hexString(dot->getDeviceId()).c_str(); if(verbose)pc.printf("\r\nEUI: %s\r\n",eui); bool joined = false; - - + i2c_proc_init(); //init i2c comm - sleep_wake_interrupt_only(deep_sleep); - + sleep_wake_interrupt_only(deep_sleep); //wake on rising edge of wake signal from proc + wait_us(wait_after_sleep_usec); //scope test // gpio1 =1; //============================================================================== @@ -289,10 +296,10 @@ if(verbose)pc.printf("\n\r xdot ack -> proc done,going to sleep\n\r "); bPulseLoraWake = false; // gpio1 =0; - sleep_wake_interrupt_only(deep_sleep); //wait for wake + sleep_wake_interrupt_only(deep_sleep); ////sleep until rising edge of wake signal from proc + wait_us(wait_after_sleep_usec); // gpio1 =1; - if(verbose)pc.printf("\n\r lora wake detected -> monitoring i2c bus\n\r "); - + if(verbose)pc.printf("\n\r lora wake detected -> monitoring i2c bus\n\r "); break; case I2C_READ: //xdot <- proc bPulseLoraWake = true; @@ -469,10 +476,9 @@ for (i=0; i< 4;i++) peui->apiLvlData[i] = api_level[i]; for (i=0; i< 4;i++) peui->verLvlData[i] = ver_level[i]; peui->dataLen = sizeof(pkt_eui)-3; //size of struc minus first 3 bytes - if(verbose)pc.printf("\n\r eui data length: %d",peui->dataLen); - - pc.printf("\n\r eui waiting min len: %d",I2C_MIN_WAIT_DELAY); - wait_ms(I2C_MIN_WAIT_DELAY); //TEST + if(verbose)pc.printf("\n\r eui data length: %d",peui->dataLen); + //if(verbose)pc.printf("\n\r eui waiting min len: %d",I2C_MIN_WAIT_DELAY); + //wait_ms(I2C_MIN_WAIT_DELAY); //TEST break; case XDOT_CMD_SET_NTWKSESS: //read or write network seesion to xdot flash