acd52832 blinky example

Files at this revision

API Documentation at this revision

Comitter:
jurica238814
Date:
Fri Aug 25 06:53:07 2017 +0000
Branch:
TestBranch
Parent:
1:8fd903e4bcef
Child:
4:de5cf6b1e96b
Commit message:
New branch (test)

Changed in this revision

aconno_bsp.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show diff for this revision Revisions of this file
--- a/aconno_bsp.lib	Wed Oct 05 14:52:36 2016 +0000
+++ b/aconno_bsp.lib	Fri Aug 25 06:53:07 2017 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/jurica238814/code/aconno_bsp/#f36338abc91d
+http://mbed.org/users/jurica238814/code/aconno_bsp/#6d9c6c231034
--- a/main.cpp	Wed Oct 05 14:52:36 2016 +0000
+++ b/main.cpp	Fri Aug 25 06:53:07 2017 +0000
@@ -4,24 +4,87 @@
  * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
  * the file.
  *
- *   aconno simple example program
- *   blinky LED LD1
  */
 
 #include "mbed.h"
 #include "acd52832_bsp.h"
+#include "ble/BLE.h"
+#include "GapAdvertisingData.h"
 
-#define pause 1         // Pause in seconds
+#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
 
-DigitalOut LD1(PIN_LED_RED);
+#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){
-        // Turn LED OFF
-        LD1 = 1;
-        wait(pause);
-        // Turn LED ON
-        LD1 = 0;
-        wait(pause);
+        #if USE_BLE
+            ble.waitForEvent();
+        #endif
+        __WFI();
     }
 }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Fri Aug 25 06:53:07 2017 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#21dd7008a1540c02150f1b87c12294301db979bb
--- a/mbed.bld	Wed Oct 05 14:52:36 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/2e9cc70d1897
\ No newline at end of file