![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Mej
Dependencies: MCP3208_SWSPI SWSPI mbed
Fork of MCP3208_STM32 by
Diff: main.cpp
- Revision:
- 12:a5672b85b4b5
- Parent:
- 11:0c855a410d68
diff -r 0c855a410d68 -r a5672b85b4b5 main.cpp --- a/main.cpp Sat Apr 15 01:48:22 2017 +0000 +++ b/main.cpp Sat Apr 15 02:02:39 2017 +0000 @@ -2,6 +2,10 @@ #include "mcp3208.h" MCP3208 input1(PA_7, PA_6, PA_5, PA_4); //MCP3208(PinName mosi, PinName miso, PinName clk, PinName cs) +MCP3208 input2(PA_7, PA_6, PA_5, PA_4); //MCP3208(PinName mosi, PinName miso, PinName clk, PinName cs) +MCP3208 input3(PA_7, PA_6, PA_5, PA_4); //MCP3208(PinName mosi, PinName miso, PinName clk, PinName cs) +MCP3208 input4(PA_7, PA_6, PA_5, PA_4); //MCP3208(PinName mosi, PinName miso, PinName clk, PinName cs) + //MCP3208 input1(PB_5, PB_4, PB_3, PA_11); //MCP3208 input1(p5, p6, p7, p8); @@ -22,12 +26,12 @@ char datastr6[5]; -int data0; -int data1; -int data2; -int data3; -int data4; -int data5; +int data0, data10, data20, data30; +int data1, data11, data21, data31; +int data2, data12, data22, data32; +int data3, data13, data23, data33; +int data4, data14, data24, data34; +int data5, data15, data25, data35; // Credit: Erik Olieman // http://developer.mbed.org/questions/5149/Serial-port-on-LPC1114-is-slow/ @@ -72,6 +76,7 @@ datalog.attach_us(&log_data,1000); // 1000us = 1ms while(1) { + data0 = input1.binary(0); data1 = input1.binary(1); data2 = input1.binary(2); @@ -79,12 +84,28 @@ data4 = input1.binary(4); data5 = input1.binary(5); - intToString(datastr0,input1.binary(0)); - intToString(datastr1,input1.binary(1)); - intToString(datastr2,input1.binary(2)); - intToString(datastr3,input1.binary(3)); - intToString(datastr4,input1.binary(4)); - intToString(datastr5,input1.binary(5)); + data10 = input2.binary(0); + data11 = input2.binary(1); + data12 = input2.binary(2); + data13 = input2.binary(3); + data14 = input2.binary(4); + data15 = input2.binary(5); + + data20 = input3.binary(0); + data21 = input3.binary(1); + data22 = input3.binary(2); + data23 = input3.binary(3); + data24 = input3.binary(4); + data25 = input3.binary(5); + + + data30 = input4.binary(0); + data31 = input4.binary(1); + data32 = input4.binary(2); + data33 = input4.binary(3); + data34 = input4.binary(4); + data35 = input4.binary(5); + // Timing methods to verify 1 ms loop time / 1 kHz update speed // tt = t.read_ms(); @@ -96,10 +117,11 @@ if(tickerActivated == true) { tickerActivated = false; -// pc.printf("%s,%s,%s,%s,%s,%s\n\r",datastr0,datastr1,datastr2,datastr3,datastr4,datastr5); pc.printf("%04d,%04d,%04d,%04d,%04d,%04d\n\r",data0,data1,data2,data3,data4,data5); -// pc.printf("%d\n\r",SPI1->DR); -// pc.printf("%d\n\r",input1.binary(0)); + pc.printf("%04d,%04d,%04d,%04d,%04d,%04d\n\r",data10,data11,data12,data13,data14,data15); + pc.printf("%04d,%04d,%04d,%04d,%04d,%04d\n\r",data20,data21,data22,data23,data24,data25); + pc.printf("%04d,%04d,%04d,%04d,%04d,%04d\n\r",data30,data31,data32,data33,data34,data35); + } }