.from: http://mbed.org/forum/mbed/topic/2444/
#include "mbed.h"
DigitalOut cs(p10);
SPI spi(p5, p6, p7);
Serial pc(USBTX, USBRX);
int adc;
int main()
{
pc.baud(115200);
pc.format(8,Serial::None,1);
spi.format(16,3);
spi.frequency(1000000);
// dump read
pc.printf("dump read\r\n");
cs = 0;
adc = spi.write(0x8300);
cs = 1;
pc.printf("ADC = %d\r\n", adc);
// real reading
pc.printf("real reading\r\n");
cs = 0;
adc = spi.write(0x0000);
cs = 1;
pc.printf("ADC = %d\r\n", adc);
}
DigitalOut cs(p10);
SPI spi(p5, p6, p7);
Serial pc(USBTX, USBRX);
int adc;
int main()
{
pc.baud(115200);
pc.format(8,Serial::None,1);
spi.format(16,3);
spi.frequency(1000000);
// dump read
pc.printf("dump read\r\n");
cs = 0;
adc = spi.write(0x8300);
cs = 1;
pc.printf("ADC = %d\r\n", adc);
// real reading
pc.printf("real reading\r\n");
cs = 0;
adc = spi.write(0x0000);
cs = 1;
pc.printf("ADC = %d\r\n", adc);
}
No comments:
Post a Comment