int main() { CHIP_Init(); TRACE_SWOSetup(); ANTHRMSensor * hrm = ANTHRMSensor::getInstance(); AlarmManager * alm = AlarmManager::getInstance(); //USARTManager::getInstance()->getPort(USARTManagerPortLEUART0)->setSignalFrameHook(&frameHandler); //USARTManager::getInstance()->getPort(USARTManagerPortLEUART0)->setRxHook(&rxHook); bool OK = false; SensorMessage * msg; HeartRateMessage * hrm_msg; uint16_t size; while(1) { alm->lowPowerDelay(900, sleepModeEM2); if(OK) { hrm->sampleSensorData(); msg = (SensorMessage *) hrm->readSensorData(&size); hrm_msg = (HeartRateMessage *) msg->sensorMsgArray; printf("measured heart rate: %d bpm \n", hrm_msg->bpm); } else { OK = hrm->initializeNetwork(true); } } }
/**************************************************************************//** * @brief Main function *****************************************************************************/ int main(void) { TRACE_SWOSetup(); allSensorsOff(); AlarmManager * mgr = AlarmManager::getInstance(); gps = GPSSensor::getInstance(); gps->initialize(); gps->setParseOnReceive(true); gps->setSleepState(true); mgr->pause(); mgr->createAlarm(READ_PERIOD, false, &wakeupHandler); AlarmID readID = mgr->createAlarm(READ_PERIOD, false, &readHandler); mgr->setAlarmTimeout(readID, READ_PERIOD+READ_OFFSET); mgr->resume(); uint16_t size; GPSMessage * gpsMsg; SensorMessage * msg; while (1) { EMU_EnterEM2(true); if(wakeup) { printf("wakeup! \n"); wakeup = false; gps->setSleepState(false); } if(read) { printf("read! \n"); read = false; gps->sampleSensorData(); gps->setSleepState(true); msg = (SensorMessage *) gps->readSensorData(&size); gpsMsg = (GPSMessage *) msg->sensorMsgArray; if(gpsMsg->validPosFix) printf("GPS: position fixed! \n"); else printf("GPS: position not fixed \n"); printf("GPS: %d %d %d, %d %d %d \n", gpsMsg->latitude.degree, gpsMsg->latitude.minute, gpsMsg->latitude.second, gpsMsg->longitude.degree, gpsMsg->longitude.minute, gpsMsg->longitude.second); } } }
int main() { CHIP_Init(); TRACE_SWOSetup(); UARTManager::getInstance()->getPort(UARTManagerPortLEUART0)->setSignalFrameHook(&frameHandler); UARTManager::getInstance()->getPort(UARTManagerPortLEUART0)->setRxHook(&rxHook); gps = GPSSensor::getInstance(); while(1) { EMU_EnterEM2(true); } }
/**************************************************************************//** * @brief Profiler configuration for EFM32GG990F11024/EFM32GG-DK3750 * @return true if energyAware Profiler/SWO is enabled, false if not * @note If first word of the user page is zero, this will not * enable SWO profiler output *****************************************************************************/ bool TRACE_ProfilerSetup(void) { volatile uint32_t *userData = (uint32_t *) USER_PAGE; /* Check magic "trace" word in user page */ if(*userData == 0x00000000UL) { return false; } else { TRACE_SWOSetup(); return true; } }