![](/media/cache/profiles/profileJosh.jpg.50x50_q85.jpg)
A speedtest
Dependencies: aconno_SEGGER_RTT CustomService
main.cpp
- Committer:
- jurica238814
- Date:
- 2017-08-25
- Branch:
- TestBranch
- Revision:
- 2:84d964276266
- Parent:
- 1:8fd903e4bcef
- Child:
- 4:de5cf6b1e96b
File content as of revision 2:84d964276266:
/* Copyright (c) 2016 Aconno. All Rights Reserved. * * Licensees are granted free, non-transferable use of the information. NO * WARRANTY of ANY KIND is provided. This heading must NOT be removed from * the file. * */ #include "mbed.h" #include "acd52832_bsp.h" #include "ble/BLE.h" #include "GapAdvertisingData.h" #define USE_PWM (0) #define USE_BLE (1) #if USE_BLE BLE &ble = BLE::Instance(); #endif Ticker WakeSleepT; Ticker turnBuzzOffT; Ticker sleepChanger; #if USE_PWM PwmOut buzzer(p31); #endif #if USE_BLE void bleInitComplete(BLE::InitializationCompleteCallbackContext *params){ BLE& ble = params->ble; /* Ensure that it is the default instance of BLE */ if(ble.getInstanceID() != BLE::DEFAULT_INSTANCE) { return; } uint8_t MSD = 0x23; /* setup advertising */ ble.gap().setAdvertisingInterval(100); // --> Has to be at least 100ms! ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, &MSD, 1); ble.gap().stopAdvertising(); } #endif int main(){ #if USE_BLE ble.init(bleInitComplete); /* SpinWait for initialization to complete. This is necessary because the BLE object is used in the main loop below. */ while (ble.hasInitialized() == false){} #endif #if USE_PWM buzzer.period(0.0F); buzzer.write(0.0F); #endif /* // Disconnect and stop PWM0 NRF_PWM0->PSEL.OUT[0] = 0x80000000; NRF_PWM0->PSEL.OUT[1] = 0x80000000; NRF_PWM0->PSEL.OUT[2] = 0x80000000; NRF_PWM0->PSEL.OUT[3] = 0x80000000; NRF_PWM0->TASKS_STOP = 1; */ // Disconnect and stop PWM1 NRF_PWM1->PSEL.OUT[0] = 0x80000000; NRF_PWM1->PSEL.OUT[1] = 0x80000000; NRF_PWM1->PSEL.OUT[2] = 0x80000000; NRF_PWM1->PSEL.OUT[3] = 0x80000000; NRF_PWM1->TASKS_STOP = 1; // Disconnect and stop PWM2 NRF_PWM2->PSEL.OUT[0] = 0x80000000; NRF_PWM2->PSEL.OUT[1] = 0x80000000; NRF_PWM2->PSEL.OUT[2] = 0x80000000; NRF_PWM2->PSEL.OUT[3] = 0x80000000; NRF_PWM2->TASKS_STOP = 1; NRF_CLOCK->TASKS_LFCLKSTART = 1; while(!NRF_CLOCK->EVENTS_LFCLKSTARTED); NRF_CLOCK->TASKS_HFCLKSTOP; NRF_POWER->TASKS_LOWPWR = 0x00000001; while(1){ #if USE_BLE ble.waitForEvent(); #endif __WFI(); } }