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

Dependencies:   Display1602 mbed-rtos mbed nRF24L01P

Files at this revision

API Documentation at this revision

Comitter:
DorijanMacek
Date:
Mon Jan 25 16:06:10 2016 +0000
Child:
1:0f605b9eed83
Commit message:
funkcije uvedene

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
nRF24L01P.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Display1602.lib	Mon Jan 25 16:06:10 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/RichardUK/code/Display1602/#fc4c861451e1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Jan 25 16:06:10 2016 +0000
@@ -0,0 +1,158 @@
+#include "mbed.h"
+#include "nRF24L01P.h"
+#include "Display1602.h"
+
+
+I2C MSP430G(p9, p10); //sda, sc1
+nRF24L01P odasiljac(p11,p12,p13,p14,p28,p27);  //// mosi, miso, sck, csn, ce, irq
+AnalogIn upDown(p15);
+AnalogIn leftRight(p16);
+Display1602 display(p19, p20, p21, p22, p23, p24,p25,p26,p29,p30,p18); 
+Serial pc(USBTX, USBRX);
+
+DigitalOut myled1(LED1);
+DigitalOut myled2(LED2);
+DigitalOut myled3(LED3);
+DigitalOut myled4(LED4);
+
+void startLCD(void);
+void startNRF(int);
+void readJoystick(float &up, float &lr);
+void readTempFromMSP430G(int , int &temp);
+void readVoltFromMSP430G(int , int &volt);
+
+int main() 
+{
+    //nrf
+    const int transfer_size = 4;
+    char txData[transfer_size],rxData[transfer_size];
+    int txDataCnt = 0;
+    int rxDataCnt = 0;
+    
+    //joystick
+    float velocity=upDown;
+    float direction =leftRight;
+    
+    //MSP430g
+    const int addr= 94;
+    float temp=0.0;
+    float voltage=0.0;
+
+    
+    
+    startLCD();
+    startNRF(transfer_size);
+    readJoystick(velocity,direction);
+    
+    
+    while(1)
+    {
+        
+    }
+}
+
+void startLCD()
+{
+     display.Clear();
+     display.SetXY(0,0);
+     display.printf("Dorijan Macek"); // print on screen
+     display.SetXY(0,1);
+     display.printf("TVZ  2015 / 2016");
+     wait(1);
+     display.SetXY(0,0);
+     display.printf("Dobro dosli  ");
+     display.SetXY(0,1);
+     display.printf("................");
+     wait(0.5);    
+}
+void startNRF(int size)
+{
+    odasiljac.setTransferSize( size);
+    odasiljac.setTransmitMode();
+    odasiljac.enable();
+    
+    display.Clear();
+    display.SetXY(0,0);
+    display.printf( "Odasiljac ");
+    display.SetXY(0,1);
+    pc.printf( "                ");
+    wait(1);
+    display.Clear();
+    
+    display.printf( "Frequency : ");
+    display.SetXY(0,1);
+    display.printf ("%d MHz",odasiljac.getRfFrequency() );
+    wait(1);
+    display.Clear();
+    display.SetXY(0,0);
+    
+    display.printf( "Output power : ");
+    display.SetXY(0,1);
+    display.printf("%d dBm",  odasiljac.getRfOutputPower() );
+    wait(1);
+    display.Clear();
+    display.SetXY(0,0);
+    
+    display.printf( "Data Rate : ");
+    display.SetXY(0,1);
+    display.printf("%d kbps", odasiljac.getAirDataRate() );
+    wait(1);
+    display.Clear();
+    display.SetXY(0,0);
+    
+    display.printf( "TX Address : ");
+    display.SetXY(0,1);
+    display.printf("0x%010llX", odasiljac.getTxAddress() );
+    wait(1);
+    display.Clear();
+    display.SetXY(0,0);
+    
+    display.printf( "RX Address : ");
+    display.SetXY(0,1);
+    display.printf("0x%010llX", odasiljac.getRxAddress() );
+    wait(1);
+    display.Clear();
+    display.SetXY(0,0);
+    
+    wait(0.5);
+    
+} 
+
+void readJoystick(float &x, float &y)
+{
+    x=upDown;
+    y=leftRight;
+} 
+
+void readTempFromMSP430G(int ad, float &temperature)
+{
+    
+    char config_t[2]; // transmitt buffer
+    char value_read[2]; // read buffer     
+    MSP430G.write(ad, config_t, 2);
+    
+    float temp;
+    config_t[0] = 0xC0; //config slave to int temp
+    config_t[1] = 0x55; // config data byte1, BOut  
+            
+    MSP430G.read(ad, value_read, 2); //read the two-byte temp data 
+    temp = value_read[0]+value_read[1]*256;
+    temperature=temp/10.;
+        
+}    
+
+
+void readVoltFromMSP430G(int ad, float voltage)
+{
+    char config_t[2]; // transmitt buffer
+    char value_read[2]; // read buffer     
+    MSP430G.write(ad, config_t, 2);
+    
+    float volt;
+    config_t[0] = 0xC1; //config slave to int temp
+    config_t[1] = 0xff; // config data byte1, BOut  
+            
+    MSP430G.read(ad, value_read, 2); //read the two-byte temp data 
+    volt = value_read[0]+value_read[1]*256;
+    voltage = 1.5 * (volt / 1023);
+}  
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Jan 25 16:06:10 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6f327212ef96
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nRF24L01P.lib	Mon Jan 25 16:06:10 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/Owen/code/nRF24L01P/#8ae48233b4e4