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 // Writes hex over SPI from pc input 00002 00003 #include "mbed.h" 00004 00005 SPI spi(p5, p6, p7); // mosi, miso, sclk 00006 DigitalOut cs(p10); 00007 00008 Serial pc(USBTX, USBRX); // tx, rx 00009 00010 int main() { 00011 spi.format(8,3); 00012 spi.frequency(1000000); 00013 wait(0.1); 00014 00015 while(1){ 00016 00017 00018 int n; 00019 pc.printf("hex: "); 00020 pc.scanf("%xx", &n); 00021 pc.printf("%xx", n); 00022 00023 int o; 00024 00025 pc.printf("hex2: "); 00026 pc.scanf("%xx", &o); 00027 pc.printf("%xx", o); 00028 00029 // Select the device 00030 cs=0; 00031 int dataA = spi.write(n); 00032 //wait(0.01); 00033 int dataB = spi.write(o); 00034 cs=1; 00035 pc.printf("Data out = 0x%X\n", dataA); 00036 00037 00038 pc.printf("data out = 0x%X\n", dataB); 00039 wait(0.1); 00040 00041 00042 00043 } 00044 00045 }
Generated on Thu Jul 14 2022 11:30:05 by
1.7.2