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.
Dependencies: mbed
Fork of SPI_master_frdm by
Diff: main.cpp
- Revision:
- 5:8566031849f7
- Parent:
- 4:995eae7f13f4
--- a/main.cpp Wed Apr 01 13:03:01 2015 +0000
+++ b/main.cpp Wed Apr 01 15:53:29 2015 +0000
@@ -21,47 +21,33 @@
int main() {
- spi.format(8,1); //not usefull results
+ spi.format(8,1);
spi.frequency(1000000);
- //spi.frequency(4000000);
- uint8_t i;
- int j = 0;
- uint8_t fail;
- uint8_t success;
-
+ int i = 0;
while(1) {
- fail = 0;
- success = 0;
-
- for (i = 0; i < 10; i++) {
-
- cs = 0;
- spi.write(i);
- cs = 1;
-
- wait_ms(100);
-
- cs = 0;
- uint8_t response = spi.write(0xFF);
- cs = 1;
-
- printf("send: %x received: %x\r\n", i, response);
-
- if(response == i + 0x10) {
- success++;
- } else {
- fail++;
- }
-
- wait_ms(2000);
-
-
- }
+
+ cs = 0;
+ spi.write(0xFE);
+ cs = 1;
+
+ wait_ms(1);
+
+ cs = 0;
+ uint8_t response = spi.write(0xFF);
+ cs = 1;
- pc.printf("%d: fails: %d, success: %d\r\n",j++ , fail, success);
- wait(.5);
-
+ if(response != 0x0) {
+ printf("received keystroke %x\r\n", response);
+ }
+
+ wait_ms(1);
+
+ cs = 0;
+ spi.write(response);
+ cs = 1;
+
+ wait_ms(1);
}
