A Simple program that simplifies development of SPI devices. It alows you to read and write to registers using a PC serial terminal in real time.
Diff: main.cpp
- Revision:
- 0:4568a8086f47
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon May 31 18:20:25 2010 +0000 @@ -0,0 +1,45 @@ +// Writes hex over SPI from pc input + +#include "mbed.h" + +SPI spi(p5, p6, p7); // mosi, miso, sclk +DigitalOut cs(p10); + +Serial pc(USBTX, USBRX); // tx, rx + +int main() { + spi.format(8,3); + spi.frequency(1000000); + wait(0.1); + +while(1){ + + +int n; +pc.printf("hex: "); +pc.scanf("%xx", &n); +pc.printf("%xx", n); + + int o; + +pc.printf("hex2: "); +pc.scanf("%xx", &o); +pc.printf("%xx", o); + + // Select the device + cs=0; + int dataA = spi.write(n); + //wait(0.01); + int dataB = spi.write(o); + cs=1; + pc.printf("Data out = 0x%X\n", dataA); + + + pc.printf("data out = 0x%X\n", dataB); + wait(0.1); + + + +} + +} \ No newline at end of file