Maček Dorijan Miljković Dominik Napon i temperatura sa istog slave-a
Dependencies: Display1602 mbed-rtos mbed nRF24L01P
Revision 3:07d5ce3c32e3, committed 2016-01-28
- Comitter:
- DorijanMacek
- Date:
- Thu Jan 28 16:46:15 2016 +0000
- Parent:
- 2:d0f85a573b89
- Commit message:
- Ma?ek Dorijan ; Miljkovi? Dominik; Napon i temperatura sa istog slave-a;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Jan 27 20:17:31 2016 +0000
+++ b/main.cpp Thu Jan 28 16:46:15 2016 +0000
@@ -3,7 +3,7 @@
#include "nRF24L01P.h"
#include "Display1602.h"
-Mutex stdio_mutex;
+//Mutex stdio_mutex;
Semaphore semMSP430G(1);
Semaphore semLCD(1);
Semaphore semJoystick(1);
@@ -20,6 +20,7 @@
DigitalOut myled2(LED2);
DigitalOut myled3(LED3);
DigitalOut myled4(LED4);
+DigitalOut res(p17);
void startLCD(void);
void startNRF(int);
@@ -43,27 +44,26 @@
//MSP430g
const int addr= 0x94;
-float temp=0.0;
-float volt=0.0;
+float temp=0.00;
+float volt=0.00;
int testT=0;
int testY=0;
-
int main()
{
-
+ res=1;
startLCD();
startNRF(transfer_size);
wait(1);
Thread t0(readJoystick, (void *)"readJoystick");
- Thread t1(readTempFromMSP430G, (void *)"readTemp");
- ////Thread t2(readVoltFromMSP430G, (void *)"readVoltage");
+ //Thread t1(readTempFromMSP430G, (void *)"readTemp");
+ Thread t2(readVoltFromMSP430G, (void *)"readVoltage");
Thread t3(printTempAndVoltOnLCD, (void *)"printTemp");
Thread t4(printJoystickOnLCD, (void *)"printJoytick");
@@ -172,10 +172,10 @@
display.printf("T = %.2f ",temp);
display.SetXY(8,1);
display.printf("V = %.2f ",volt);
- pc.printf("printTempAndVoltOnLCD \n\r");
+ //pc.printf("printTempAndVoltOnLCD \n\r");
-
- Thread::wait(1000);
+
+ Thread::wait(500);
semLCD.release();
}
}
@@ -190,10 +190,10 @@
display.printf("Up %.2f ",velocity);
display.SetXY(0,1);
display.printf("LR %.2f ",direction);
- pc.printf("printJoystickOnLCD \n\r ");
+ //pc.printf("printJoystickOnLCD \n\r ");
- Thread::wait(1000);
+ Thread::wait(500);
semLCD.release();
}
}
@@ -208,7 +208,7 @@
velocity=upDown;
direction =leftRight;
- pc.printf("readJoystick \n\r ");
+ //pc.printf("readJoystick \n\r ");
Thread::wait(50);
semJoystick.release();
@@ -221,20 +221,48 @@
while(true)
{
semMSP430G.wait();
+ //MSP430G.stop();
+ //Thread::wait(500);
+
+ //res=1;
char config_t[2]; // transmitt buffer
char value_read[2]; // read buffer
config_t[0] = 0xC0; //config slave to int temp
- wait(0.1);
config_t[1] = 0x55; // config data byte1, BOut
- wait(0.1);
+ //MSP430G.start();
+ //Thread::wait(20);
+
MSP430G.write(addr, config_t, 2);
- wait(0.1);
-
- MSP430G.read(addr, value_read, 2); //read the two-byte temp data
- temp = (value_read[0]+value_read[1]*256)/10.0;
- pc.printf("readTempFromMSP430G \n\r ");
-
+ Thread::wait(20);
+ //wait_us(20);
+ MSP430G.read(addr, value_read, 2); //read the two-byte temp data
+ temp = ((value_read[0]+value_read[1]*256)/10.0);
+ pc.printf("readTempFromMSP430G %f \n\r ",temp);
+ res=0;
+ Thread::wait(5);
+ res=1;
Thread::wait(500);
+
+ //MSP430G.abort_transfer();
+ //wait(0.5);
+
+
+ //config_t[0] = 0xC1; //config slave to int temp
+ //config_t[1] = 0xff; // config data byte1, BOut
+
+ //MSP430G.write(addr, config_t, 2);
+ //Thread::wait(20);
+ //wait_us(20);
+ //MSP430G.read(addr, value_read, 2); //read the two-byte temp data
+ //volt = ((value_read[0]+value_read[1]*256)*(1.5/1024));
+ //pc.printf("readVoltFromMSP430G \n\r %f",volt);
+
+ Thread::wait(500);
+
+ //wait(0.5);
+
+
+
semMSP430G.release();
}
}
@@ -245,20 +273,36 @@
while(true)
{
semMSP430G.wait();
+ //MSP430G.stop();
char config_t[2]; // transmitt buffer
char value_read[2]; // read buffer
config_t[0] = 0xC1; //config slave to int temp
- wait(0.1);
- config_t[1] = 0xff; // config data byte1, BOut
- wait(0.1);
+ config_t[1] = 0xff; // config data byte1, BOut
+ //MSP430G.start();
+
+ //Thread::wait(20);
+
MSP430G.write(addr, config_t, 2);
- wait(0.2);
+ //MSP430G.stop();
+ Thread::wait(20);
+
MSP430G.read(addr, value_read, 2); //read the two-byte temp data
+ //Thread::wait(500);
+
volt = (value_read[0]+value_read[1]*256)*(1.5/1024);
- pc.printf("readVoltFromMSP430G \n\r ");
+ pc.printf("readVoltFromMSP430G \n\r %f",volt);
+
+ //MSP430G.stop();
+ res=0;
+ Thread::wait(5);
+ res=1;
Thread::wait(500);
+
+ //MSP430G.stop();
semMSP430G.release();
}
-}
\ No newline at end of file
+}
+
+