Publication TP CAN

Dependencies:   Dashboard_BUS_CAN Programme_BUS_CAN mbed

Files at this revision

API Documentation at this revision

Comitter:
KEG
Date:
Tue Jun 05 16:49:19 2018 +0000
Commit message:
Pulication;

Changed in this revision

Dashboard.lib Show annotated file Show diff for this revision Revisions of this file
Grove_LCD_RGB_Backlight.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-os.lib 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 4eee0a42e29b Dashboard.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Dashboard.lib	Tue Jun 05 16:49:19 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/KEG/code/Dashboard_BUS_CAN/#666c0aa82871
diff -r 000000000000 -r 4eee0a42e29b Grove_LCD_RGB_Backlight.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Grove_LCD_RGB_Backlight.lib	Tue Jun 05 16:49:19 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/KEG/code/Programme_BUS_CAN/#852b9b565605
diff -r 000000000000 -r 4eee0a42e29b main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jun 05 16:49:19 2018 +0000
@@ -0,0 +1,87 @@
+#include "Dashboard.h"
+#include "mbed.h"
+
+#define SIG_RX_CAN  0x01
+#define SIG_AFF 0x01
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+
+Thread threadA;
+Thread threadB;
+
+CAN CanPort(p30, p29);
+CANMessage  MessageRx; 
+Dashboard dshbd(p28, p27);
+
+signed char dataToPrint[8];
+
+void canReader(void)
+{
+    if (CanPort.read(MessageRx))
+    {
+            led1 = !led1;
+            threadA.signal_set(SIG_RX_CAN);
+    }
+} 
+
+void readFrame(CANMessage msg){
+    if(msg.id==2){
+        int i=0;
+        for(i=0;i<8;i++){
+            dataToPrint[i]=msg.data[i];
+        }
+    }    
+}
+
+void thA() 
+{
+    while(true)
+    {
+        Thread::signal_wait(SIG_RX_CAN);  
+        readFrame(MessageRx);  
+        led2 = !led2;
+        threadB.signal_set(SIG_AFF);
+        //printf("RX FRAME ID = %X\n",MessageRx.id);
+    }
+}
+
+void thB() 
+{
+    //int i=0;
+    while(true){
+        Thread::signal_wait(SIG_AFF);
+        led3 = !led3;
+        dshbd.clear();
+        dshbd.printData(dataToPrint);
+        dshbd.changeColor(dataToPrint[0]);
+        //wait(5);
+        /*i++;
+        if(i>7){i=0;}*/
+        //printData();
+    }
+}
+
+int main()
+{
+   //Init CAN
+   CanPort.frequency(20000);
+   //Init LCD 
+   dshbd.setRGB(0xff, 0xff, 0xff);                 //set the color 
+   dshbd.print("Init System !");
+   dshbd.locate(0,1);
+   wait(5);
+   
+   CanPort.attach(canReader,CAN::RxIrq);
+        
+   threadA.start(thA);
+   threadB.start(thB);
+
+   while(1)
+   {
+    
+     
+   }
+}
+
diff -r 000000000000 -r 4eee0a42e29b mbed-os.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Tue Jun 05 16:49:19 2018 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#367dbdf5145f4d6aa3e483c147fe7bda1ce23a36
diff -r 000000000000 -r 4eee0a42e29b mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Jun 05 16:49:19 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/5aab5a7997ee
\ No newline at end of file