Lizzy project

Dependencies:   aconno_I2C Lis2dh12 adc52832_common aconno_SEGGER_RTT

Revision:
6:55607d577a42
Parent:
5:9903738f2587
Child:
7:ac8277568115
diff -r 9903738f2587 -r 55607d577a42 source/main.cpp
--- a/source/main.cpp	Fri Mar 09 18:09:57 2018 +0000
+++ b/source/main.cpp	Tue Mar 13 15:41:35 2018 +0000
@@ -96,9 +96,67 @@
     }
 }
 
+void led_tick();
+
+void buzz_tick()
+{
+    static int start = 1;
+    
+    if (start)
+    {
+        buzzer.enable(BUZZER_FREQUENCY_HZ);
+        buzzer.enableChannel(0, BUZZER_PIN);
+        buzzer.setDuty(0,0.5f);
+        start = 0;
+    }
+    else
+    {
+        buzzer.enable(0);
+        buzzer.setDuty(0, 0);
+        buzzer.disable();
+        start = 1;
+        led_tick();
+        test_ticker.detach();
+        test_ticker.attach(led_tick, 0.5);
+    }
+}
+
+
+void led_tick()
+{
+    static int count = 0;
+    
+    switch(count)
+    {
+        case 0:
+            redLed = 0;
+            break;
+            
+        case 1:
+            redLed = 1;
+            blueLed = 0;
+            break;
+            
+        case 2:
+            blueLed = 1;
+            greenLed = 0;
+            break;
+        
+        default:
+            greenLed = 1;
+            count = -1;
+            buzz_tick();
+            test_ticker.detach();
+            test_ticker.attach(buzz_tick, BUZZ_TIME_S);
+    }
+    
+    count++;
+}
 
 int main(){
     
+    test_ticker.attach(led_tick, 0.5);
+    
     printf("Main program started.\r\n");
     
     NRF_NVMC->CONFIG = 0x00000002;      // Erase enable UICR
@@ -106,8 +164,11 @@
     NRF_NVMC->CONFIG = 0x00000001;      // Write enable UICR
     NRF_UICR->NFCPINS = 0xFFFFFFFE;     // Change NFC to GPIO function
     
-    redLed = 1;
+    redLed = 0;
     AccVcc = 1;
+    
+    blueLed = 1;
+    greenLed = 1;
     wait_ms(POWER_UP_DELAY_MS);
 
     /*