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 Serial pc(USBTX, USBRX); 00003 DigitalOut myled(LED1); 00004 SPI spi(p11, p12, p13); //mosi, miso, sclk 00005 DigitalOut cs(p14); 00006 DigitalOut pin21(p21); 00007 DigitalOut pin22(p22); 00008 #define DTIME 0.005 00009 00010 int main() { 00011 pc.printf("Hello World!\r\n"); 00012 00013 spi.format(8,0); 00014 spi.frequency(1000000); 00015 int teste; 00016 teste=0xAA; 00017 int testes; 00018 testes=0xAB; 00019 while(1){ 00020 pc.printf("Please hit key 'a'\r\n"); 00021 char mbed1=pc.getc(); 00022 if(mbed1=='a'){ 00023 cs=0; 00024 wait(DTIME); 00025 int result = spi.write(teste); 00026 pc.printf("Send to Slave = %d\n\r", teste); 00027 pc.printf("Reply from Slave = %d\n\r", result); 00028 pc.printf("\n\r"); 00029 wait(DTIME); 00030 cs=1; 00031 wait(1); 00032 } 00033 else if(mbed1=='b'){ 00034 cs=0; 00035 wait(DTIME); 00036 int result = spi.write(testes); 00037 pc.printf("Send to Slave = %d\n\r", testes); 00038 pc.printf("Reply from Slave = %d\n\r", result); 00039 pc.printf("\n\r"); 00040 wait(DTIME); 00041 cs=1; 00042 wait(1); 00043 } 00044 } 00045 }
Generated on Tue Nov 1 2022 05:08:45 by
1.7.2