AirDemo2

Dependencies:   BLE_API mbed nRF51822

Files at this revision

API Documentation at this revision

Comitter:
AndreaP
Date:
Thu May 19 11:35:40 2016 +0000
Commit message:
.

Changed in this revision

BLE_API.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.bld Show annotated file Show diff for this revision Revisions of this file
nRF51822.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r a90a8367fa4c BLE_API.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BLE_API.lib	Thu May 19 11:35:40 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#66159681aa21
diff -r 000000000000 -r a90a8367fa4c main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu May 19 11:35:40 2016 +0000
@@ -0,0 +1,93 @@
+#include "mbed.h"
+#include "nRF5xGap.h" 
+#include "InterruptManager.h"
+#include "nrf_gpio.h"
+ 
+DigitalOut greenLed(P0_21);
+DigitalOut blueLed(P0_22);
+DigitalOut redLed(P0_23);
+
+#define LED_ON  0
+#define LED_OFF 1
+
+#define BTN_PRESSED 0 
+#define BTN_RELEASED 1 
+
+/*
+void RTC1_IRQHandler(void)
+{
+    if(NRF_RTC1->EVENTS_COMPARE[0] != 0) {
+        NRF_RTC1->EVENTS_COMPARE[0] = 0;
+        
+        NRF_RTC1->TASKS_CLEAR = 1;
+    }
+    
+}
+void rtc_handler(void)
+{
+    
+}
+*/
+
+void GPIOTE_IRQHandler(void)
+{
+    // This handler will be run after wakeup from system ON (GPIO wakeup) 
+    if(NRF_GPIOTE->EVENTS_PORT) 
+    { 
+        NRF_GPIOTE->EVENTS_PORT = 0; 
+        blueLed = LED_ON;
+        printf("P2 Premuto\r\n");
+    } 
+}
+
+//int RTC1_PRESCALER = 0;
+//int RTC1_CC0 = 100;
+
+int main() {
+
+    blueLed = LED_OFF;
+    greenLed = LED_OFF;
+    redLed = LED_OFF;
+
+    printf("\r\nInit\r\n");
+
+    //NRF_POWER->SYSTEMOFF=0;               //power ON
+    
+    //NRF_RTC1->INTENSET = RTC_INTENSET_COMPARE0_Msk;
+    //NRF_RTC1->PRESCALER = RTC1_PRESCALER;
+    //NRF_RTC1->CC[0] = RTC1_CC0;
+    
+    //NVIC_EnableIRQ(RTC1_IRQn);
+    
+    //InterruptManager::get()->add_handler(rtc_handler, RTC1_IRQn);
+
+    // Configure BUTTON0 as a regular input 
+    nrf_gpio_cfg_input(p16, NRF_GPIO_PIN_PULLUP); 
+    
+    // Configure BUTTON 2 with SENSE enabled so that CPU is enabled (exit System-On low power mode) when pressing Button 2 
+    nrf_gpio_cfg_sense_input(p17, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW); 
+    
+    blueLed = LED_ON;
+
+    NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_PORT_Msk;
+    NVIC_EnableIRQ(GPIOTE_IRQn);
+    //InterruptManager::get()->add_handler(p1_handler, GPIOTE_IRQn);
+    
+    
+    while(1) 
+    {      
+         // If BUTTON 1 is pressed.. 
+         if(nrf_gpio_pin_read(p16) == BTN_PRESSED) 
+         { 
+            printf("P1 Premuto\r\n");
+            blueLed = LED_OFF;
+            // Enter CONSTLAT mode if desired, otherwise LOWPWR mode will be used (LOWPWR is recommended for most applications) 
+            //NRF_POWER->TASKS_CONSTLAT = 1; 
+              
+            // Enter System ON sleep mode 
+            __WFE(); 
+            __SEV(); 
+            __WFE(); 
+        } 
+    } 
+}
diff -r 000000000000 -r a90a8367fa4c mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu May 19 11:35:40 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/7c328cabac7e
\ No newline at end of file
diff -r 000000000000 -r a90a8367fa4c nRF51822.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nRF51822.lib	Thu May 19 11:35:40 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#f7faad332abc