Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 0:e79a950111c9
diff -r 000000000000 -r e79a950111c9 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Jun 23 18:51:42 2010 +0000
@@ -0,0 +1,143 @@
+#include "mbed.h"
+#include "MSCFileSystem.h"
+
+Serial usb(USBTX,USBRX);
+//Serial ft(p28,p27);
+DigitalOut led(LED1);
+//LocalFileSystem fs("fs");
+MSCFileSystem fs("fs");
+SPI spi(p5,p6,p7); //mosi,miso,sck
+
+DigitalOut ssnot(p8);
+DigitalOut reset(p9);
+DigitalIn drdy(p10);
+
+int x = 0;
+int y = 0;
+int z = 0;
+int heading = 0;
+float pauza = 0.0001;
+char subor[] = "/fs/data_1.csv";
+const char base1[] = "/fs/data_";
+const char base2[] = ".csv";
+FILE *fp;
+
+void setup() {
+ usb.baud(921600);
+ led = 1;
+ spi.format(8,3);
+ spi.frequency(1000000);
+
+
+
+}
+int main() {
+ int ps = 1;
+ // sprintf(subor, "%s%d%s",base1,ps,base2);
+ // FILE *fp = fopen(subor,"w");
+ setup();
+ int signx = 0;
+ int signy = 0;
+ int signz = 0;
+ int i = 0;
+
+
+ while (1) {
+
+
+
+
+ ssnot = 0;
+ /* if (i==0) {
+ FILE *fp = fopen(subor,"w");
+ }*/
+ led = 1;
+ reset = 0;
+ wait(pauza);
+ reset = 1;
+ wait(pauza);
+ reset = 0;
+
+
+ //ciatanie
+ wait(pauza);
+ spi.write(0x11);
+ while (drdy == 0) {
+ }
+
+ x = spi.write(0x00);
+ //signx = (x & 128) >> 7;
+ x = x << 8;
+ x |= spi.write(0x00);
+ signx = (x & 0x8000) >> 15;
+ x = x & 0x7FFF;
+ if (signx==1) {
+ x = x - 32768;
+ }
+
+ reset = 0;
+ wait(pauza);
+ reset = 1;
+ wait(pauza);
+ reset = 0;
+
+ wait(pauza);
+ spi.write(0x12);
+ while (drdy == 0) {
+ }
+
+ y = spi.write(0x00);
+ // signy = (y & 128) >> 7;
+ y = y << 8;
+ y |= spi.write(0x00);
+ signy = (y & 0x8000) >> 15;
+ y = y & 0x7FFF;
+
+ if (signy==1) {
+ y = y - 32768;
+ }
+
+ reset = 0;
+ wait(pauza);
+ reset = 1;
+ wait(pauza);
+ reset = 0;
+
+ wait(pauza);
+ spi.write(0x13);
+ while (drdy == 0) {
+ }
+
+ z = spi.write(0x00);
+ z = z << 8;
+ z |= spi.write(0x00);
+ signz = (z & 0x8000) >> 15;
+ z = z & 0x7FFF;
+
+
+ if (signz==1) {
+ z = z - 32768;
+ }
+ wait(0.0002);
+
+ usb.printf("%ld %ld %ld %ld\r\n",x,y,z,z);
+ /*if (i<=1024) {
+ fprintf(fp,"%ld %ld %ld %ld\r\n",x,y,z,z);
+ i++;
+ } else {
+ fclose(fp);
+ ps++;
+ sprintf(subor, "%s%d%s",base1,ps,base2);
+
+ i=0;
+ led = 0;
+ }*/
+
+ // led = 0;
+ wait(0.0003);
+ ssnot=1;
+
+ // wait(1);
+ }
+ }
+}