test

Dependencies:   BLE_API nRF51822 mbed

Fork of KS7 by masaaki makabe

Branch:
KS3
Revision:
21:ab5b55d1947d
Parent:
20:c3fadeef5842
Child:
23:ca1806081f0c
--- a/main.cpp	Tue Feb 09 06:57:38 2016 +0000
+++ b/main.cpp	Thu Mar 17 00:13:26 2016 +0000
@@ -141,13 +141,16 @@
 #endif
     io.analog_pow(1);
 
-    /*
+#ifdef PCB_VER3
+    // check XTALFREQ for TaiyoYuden module in PCB_VER3
+/*
         if(NRF_UICR->XTALFREQ == 0xFFFFFF00){
             io.display_value = 3232;
         }else if(NRF_UICR->XTALFREQ == 0xFFFFFFFF){
             io.display_value = 1616;
         }
-    */
+*/
+#endif
 }
 
 /*
@@ -219,7 +222,20 @@
 #ifdef UART_DEBUG
     pc.baud(UART_BAUD_RATE);
 #endif
-#ifndef PCB_VER1
+/*
+    // debug for PCB_VER4
+    io.analog_pow(1);
+    //    0g = 0.509444 * 16777215 = 8547051
+    // 2000g = 0.588761 * 16777215 = 9877770
+    //     d = 0.079317/2kg = 1330719/2kg = 665.36/g
+    uint32_t d0 = io._get_adc_raw(0);
+    while(1) {
+        uint32_t d = io._get_adc_raw(0);
+        if (d > d0) d = d - d0; else d = 0;
+        pc.printf("%d %d %f\r\n", io.get_switch(), d, (float)d / 665.36);
+    }
+*/
+#ifdef PCB_VER3
     // set XTAL=32MHz for TaiyoYuden's module
     //  is moved to mbed-src/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/system_nrf51.c
     DEBUG("UICR->XTALFREQ=%x\r\n", NRF_UICR->XTALFREQ); // this should be 0xffffff00, not 0xffffffff
@@ -230,13 +246,17 @@
 
     led_mode = MODE_OFF;
     for (;; ) {
+        pc.printf("#");
         // 100msec waitForEvent
         t.reset();
         while(t.read_ms() < LED_INTERVAL_MSEC) {
+        pc.printf(".");
             t.start();
             ble.waitForEvent();
             t.stop();
         }
+        pc.printf("$");
+        pc.printf("%d %d\r\n", led_mode, io.get_switch());
         // ticker蜃ヲ逅・
         switch(led_mode) {
             case MODE_OFF:
@@ -249,6 +269,7 @@
             case MODE_START:
                 io.analog_pow(1);
                 led_brightness += BRIGHTNESS_ADDVALUE;
+                pc.printf("br=%f/%f\r\n", led_brightness, BRIGHTNESS_MAXVALUE);
                 io.display(led_brightness);
                 if(led_brightness >= BRIGHTNESS_MAXVALUE) {
                     update_counter = 0;
@@ -283,7 +304,7 @@
                     io.display_value = (uint16_t)weight;
 //                    io.display_value = 8888; // for LED soldering check
 #ifdef UART_DEBUG
-                    pc.printf("%d\r\n", io._get_adc_raw(0));
+//                    pc.printf("%d\r\n", io._get_adc_raw(0));
 //                    pc.printf("weight=%f %d / %d\r\n", weight, io.display_value, io._adc0);
 //                    pc.printf("%02x %02x %02x %02x\r\n", io._seg[0], io._seg[1], io._seg[2], io._seg[3]);
 #endif