Ryo Od
/
Nucleo_MCP3208_Test
MCP3208 Test
Revision 0:cc5e457b952c, committed 2017-06-09
- Comitter:
- ryood
- Date:
- Fri Jun 09 01:12:09 2017 +0000
- Commit message:
- first commit
Changed in this revision
diff -r 000000000000 -r cc5e457b952c main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jun 09 01:12:09 2017 +0000 @@ -0,0 +1,43 @@ +#include "mbed.h" +#include "mcp3208.h" + +int main() +{ + SPI spiM(SPI_MOSI, SPI_MISO, SPI_SCK); + spiM.frequency(2000000); + MCP3208 mcp3208_0(spiM, D10); + MCP3208 mcp3208_1(spiM, D9); + + DigitalOut checkPin(D2); + + float v0[8]; + float v1[8]; + + for (;;) { + for (int i = 0; i < 8; i++) { + checkPin = 1; + v0[i] = mcp3208_0.read_input(i); + checkPin = 0; + wait_us(1); + } + for (int i = 0; i < 8; i++) { + checkPin = 1; + v1[i] = mcp3208_1.read_input(i); + checkPin = 0; + wait_us(1); + } + + printf("Device0\t"); + for (int i = 0; i < 8; i++) { + printf("%.3f\t", v0[i]); + } + printf("\r\n"); + printf("Device1\t"); + for (int i = 0; i < 8; i++) { + printf("%.3f\t", v1[i]); + } + printf("\r\n"); + + wait(0.2); + } +}
diff -r 000000000000 -r cc5e457b952c mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jun 09 01:12:09 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/86740a56073b \ No newline at end of file
diff -r 000000000000 -r cc5e457b952c mcp3208.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mcp3208.lib Fri Jun 09 01:12:09 2017 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/Kemp/code/mcp3208/#e7de500b1f2d