Raspberry Pi Power Controller by LPC1114

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
TareObjects
Date:
Fri Dec 01 08:27:11 2017 +0000
Parent:
3:b7b9d3d4eed8
Commit message:
???????????;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r b7b9d3d4eed8 -r 7117eb230044 main.cpp
--- a/main.cpp	Mon Jan 16 02:00:32 2017 +0000
+++ b/main.cpp	Fri Dec 01 08:27:11 2017 +0000
@@ -1,6 +1,21 @@
+//  RPi1114 firmware
+//
+//  TareObjects - koichi kurahashi
+//
+//  ver 1.00 2017-01-16 first version
+//      1.01 2017-01-17 fix bugs : led on when analog read command
+//                                 bad analog channel boudary
+//                                 
+//
+
+
+
 #include "mbed.h"
 
 
+
+const unsigned short version = 0x0101; //  ver 1.01
+
 const int   kMaxInteger      = 32767;
 const float fFloatScaleValue = 1024.0;  // factor to convert long <-> float
 
@@ -59,6 +74,8 @@
 //  endian : little endian
 //
 
+#define kCommandVersion     0x00    //              : get version number ver 1.01
+
 #define kCommandUp          0x10    //  i2c command : RPi power on
 #define kCommandDown        0x11    //              : RPi power off
 
@@ -78,6 +95,7 @@
 #define kCommandDigitalOut  0x60    //              : output digital
 
 
+
 #define kCommandModeBinary  0x00    //  binary mode
 #define kCommandModeASCII   0x10    //  ascii  mode    
 
@@ -227,7 +245,7 @@
 
 float execAnalogIn(int ch)
 {
-    if (ch >= 0 && kMaxAnalogChannels) {
+    if (ch >= 0 && ch < kMaxAnalogChannels) {   // fix ver 1.01
         return analogIn[ch];
     }
     return -1;
@@ -501,7 +519,7 @@
                         case kCommandDigitalIn:
                         case kCommandAnalogRead:
                         case kCommandAnalogLoad:
-                            ledOn();
+                        case kCommandVersion:           //  ver 1.01
                             prevCommand = command;
                             prevCh      = ch;
                             prevMode    = mode;
@@ -551,6 +569,10 @@
                             slave.write((const char *)strBuf, strlen(strBuf)+1);
                         }
                         break;
+                        
+                    case kCommandVersion:                                       // ver 1.01
+                        slave.write((const char *)&version, sizeof(version));
+                        break;
                 }
                 slave.stop();
                 break;