Allo Laurent

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
manl2003
Date:
Sun Jan 10 19:28:32 2016 +0000
Commit message:
Allo Laurent

Changed in this revision

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 52bd566d8b82 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Jan 10 19:28:32 2016 +0000
@@ -0,0 +1,63 @@
+#include "mbed.h"
+
+Serial pc(USBTX, USBRX);
+
+//Affichage
+SPI affichage(p5, p6, p7); // mosi, miso, sclk
+DigitalOut cs(p8);
+
+//Accéléro
+I2C accelero(p28, p27);
+const int ADDR_ACCELERO = 0x1D;
+const int ADDR_ACC_ACTIVATE = 0x2a;
+
+//Led
+DigitalOut myled(LED1);
+
+
+void readI2C(int addr, char* cmd, int bytesNumber)
+{
+    int addrShifter = ADDR_ACCELERO << 1;    
+    accelero.read(addrShifter, cmd, bytesNumber);  
+}
+
+void writeI2C(int addr, char* cmd, int bytesNumber)
+{
+    int addrShifter = (ADDR_ACCELERO << 1) | 0x01;
+    accelero.write(addrShifter, cmd, bytesNumber);       
+}
+
+int main() {
+    
+    //Setup affichage
+    cs = 1;
+    
+    affichage.format(8,0);
+    affichage.frequency(250000000);
+    
+    cs = 0;    
+    affichage.write(0x76);
+    
+    //Setup accelero
+    char cmd[2];
+    cmd[0] = ADDR_ACC_ACTIVATE;
+    readI2C(ADDR_ACCELERO, cmd, 2);
+    cmd[1] = cmd[1] | 0x01;
+    writeI2C(ADDR_ACCELERO | 0x01, cmd, 2);
+    pc.printf("Registre activité: %1f %1f\r\n", cmd[0], cmd[1]);
+    
+    affichage.write(1);
+    affichage.write(3);
+    affichage.write(3);
+    affichage.write(7);
+    
+    
+    /*
+    while(1) 
+    {
+        affichage.write(1337);
+        wait(0.25);
+    }*/
+}
+
+
diff -r 000000000000 -r 52bd566d8b82 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Jan 10 19:28:32 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c
\ No newline at end of file