Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 00003 SPI spi (p11, p12, p13); 00004 DigitalOut cs (p10); 00005 00006 int main() { 00007 00008 spi.format(8, 3); // 8 bit, mode 3 (high clk, 2nd edge capture) 00009 spi.frequency(1000000); // 1MHz clock rate 00010 00011 // Enable the device, and all three channels 00012 cs = 0; 00013 spi.write(0x20); 00014 spi.write(0x40); 00015 cs = 1; 00016 00017 wait (0.01); 00018 00019 // Send the command to read the WHOAMI register 00020 cs = 0; 00021 spi.write(0x8F); 00022 char value = spi.write(0x00); 00023 cs = 1; 00024 00025 printf("WHOAMI register contains 0x%X\n", value); 00026 }
Generated on Fri Aug 12 2022 21:14:27 by
1.7.2