)))
Revision 0:69fc4661515e, committed 2019-03-25
- Comitter:
- lucem1n
- Date:
- Mon Mar 25 12:13:12 2019 +0000
- Commit message:
- gosha dinah)
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Mar 25 12:13:12 2019 +0000
@@ -0,0 +1,39 @@
+#include "mbed.h"
+
+SPI spi(D11, D12, D13);
+DigitalOut cs(D9);
+AnalogOut my_output(PA_4);
+int SIZE;
+
+int main() {
+ while(1)
+ {
+ // Chip must be deselected
+ cs = 1;
+
+ // Setup the spi for 8 bit data, high steady state clock,
+ // second edge capture, with a 1MHz clock rate
+ spi.format(8,0);
+ spi.frequency(1000000);
+
+ // Select the device by seting chip select low
+ cs = 0;
+
+ // Send 0x8f, the command to read the WHOAMI register
+ spi.write(0x03);
+ spi.write(0x00);
+ spi.write(0x00);
+ spi.write(0x00);
+
+ // Send a dummy byte to receive the contents of the WHOAMI register
+ SIZE = 600000;
+ for(int i=0; i<SIZE; i++)
+ {
+ uint16_t sample = spi.write(0x01);
+ // my_output.write_u16(sample);
+ //wait_us(125);
+ }
+ // Deselect the device
+ cs = 1;
+ }
+ }
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Mar 25 12:13:12 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file