TESTING CONNECTIONS IN BCN

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
spacelab
Date:
Wed Apr 13 16:38:24 2016 +0000
Commit message:
TESTING spi CONNECTIONS FOR BCN;

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
diff -r 000000000000 -r 2211888e98cf main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Apr 13 16:38:24 2016 +0000
@@ -0,0 +1,22 @@
+#include "mbed.h"
+Serial pc(USBTX, USBRX);          // tx, rx
+//SPI spi(D11, D12, D13);              // mosi, miso, sclk
+//DigitalOut cs(D10);                //slave select or chip select
+SPI spi(PTE18, PTE19, PTE17);              // mosi, miso, sclk
+DigitalOut cs(PTE5);                //slave select or chip select
+#define RF22_REG_00_DEVICE_TYPE                         0x00
+
+uint8_t readreg(uint8_t reg)
+{
+    int val;cs = 0;__disable_irq();spi.write(reg & ~0x80);val = spi.write(0);__enable_irq();cs = 1;return val;
+}
+int main()
+{
+    wait(1);                     // wait for POR to complete   //change the timing later
+    cs=1;                          // chip must be deselected
+    wait(1);                    //change the time later
+    spi.format(8,0);
+    spi.frequency(10000000);       //10MHz SCLK    
+    if (readreg(RF22_REG_00_DEVICE_TYPE) == 0x08) pc.printf("spi connection valid\n");
+    else pc.printf("error in spi connection\n");
+}
\ No newline at end of file
diff -r 000000000000 -r 2211888e98cf mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Apr 13 16:38:24 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/99a22ba036c9
\ No newline at end of file