Maček Dorijan Miljković Dominik Napon i temperatura sa istog slave-a-jezgra

Dependencies:   Display1602 mbed

Files at this revision

API Documentation at this revision

Comitter:
DorijanMacek
Date:
Thu Jan 28 16:47:31 2016 +0000
Commit message:
Ma?ek Dorijan ; Miljkovi? Dominik; Napon i temperatura sa istog slave-a-jezgra;

Changed in this revision

Display1602.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
diff -r 000000000000 -r 2700b7e81050 Display1602.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Display1602.lib	Thu Jan 28 16:47:31 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/RichardUK/code/Display1602/#fc4c861451e1
diff -r 000000000000 -r 2700b7e81050 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jan 28 16:47:31 2016 +0000
@@ -0,0 +1,54 @@
+#include "mbed.h"
+#include "Display1602.h"
+
+
+I2C MSP430G( p9, p10);
+Serial pc(USBTX, USBRX);
+Display1602 display(p19, p20, p21, p22, p23, p24,p25,p26,p29,p30,p18); 
+
+
+const int addr0 = 0x94;
+const int addr1 = 0x94; 
+char config_t[2];  
+char config_v[2];                  // transmitt buffer 
+char temp_read[2];
+char volt_read[2];                   //  read buffer 
+float temp, Uin;
+
+int main()
+{
+    while(1) 
+    { 
+        config_v[0] = 0xC1;                 //config slave to Ain      
+        config_v[1] = 0xff; 
+        //MSP430G.stop();
+        //MSP430G.stop();
+        wait_us(200);                  // config data byte1, BOut      
+        MSP430G.write(addr0, config_v,2); 
+        //MSP430G.stop();          
+        wait_us(200);       
+        MSP430G.read(addr0, volt_read, 2);   //read the two-byte temp data      
+        float Uin = volt_read[0]+volt_read[1]*256;     
+        Uin = Uin/1023;        
+        pc.printf("Ain = %.4f V\n\r", Uin*1.5);  // print on screen 
+        //MSP430G.stop();
+         
+        wait(5);
+        
+        
+        
+        config_t[0] = 0xC0;                 //config slave to int temp        
+        config_t[1] = 0x55;  
+        //MSP430G.stop();
+        wait_us(200);                 
+        MSP430G.write(addr1, config_t, 2);
+        //MSP430G.stop();   
+        wait_us(200);
+        MSP430G.read(addr1, temp_read, 2);   //read the two-byte temp data  
+        float temp = temp_read[0]+temp_read[1]*256;        
+        pc.printf("Temp = %.1f degC\n\r", temp/10);  // print on screen   
+        //MSP430G.stop();      
+        wait(5);    
+        
+    }
+}
diff -r 000000000000 -r 2700b7e81050 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jan 28 16:47:31 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6f327212ef96
\ No newline at end of file