ADF7023-mbed

Dependencies:   mbed

Revision:
0:4d10d51bf949
Child:
1:9112177c4643
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jun 30 10:03:45 2015 +0000
@@ -0,0 +1,363 @@
+#include "mbed.h"
+#define ENDL "\r" << endl
+#include<iostream>
+DigitalOut led(LED_RED);
+DigitalOut CS(D10);
+int irq0=0;
+int irq1=0;
+int irq2=0;
+int irq3=0;
+
+//int irq2=0;
+
+SPI adf(PTD6, PTD7, PTD5); // mosi, miso, sclk
+
+
+void bbram_write()
+{   
+    CS=0;
+    // To bring in off state
+    adf.write(0xB0);
+    wait(0.1);
+    wait(0.1);
+    
+    // Testmode register
+    CS=0;
+    adf.write(0x09);
+    adf.write(0x39);
+    adf.write(0x10);
+    CS=1;
+    wait(0.1);
+    
+    //CMD_CONFIG_DEV
+    CS=0;
+    adf.write(0xBB);
+    CS=1;
+    wait(0.1);
+    CS=0;
+    adf.write(0xFF);
+    adf.write(0xFF);
+    CS=1;
+    wait(0.1);    
+}
+
+void data_write()
+{
+     // PHY_ON
+    CS=0;
+    adf.write(0xB1);
+    CS=1;
+    wait(0.1);
+    CS=0;
+    adf.write(0xFF);
+    adf.write(0xFF);
+    CS=1;
+    wait(0.1);
+    // TRANSMIT_DATA LENGTH
+    CS=0;
+    adf.write(0x08);
+    adf.write(0x14);
+    adf.write(0xFF);
+    CS=1;
+    wait(0.1);
+    CS=0;
+    adf.write(0x08);
+    adf.write(0x15);
+    adf.write(0xFF);
+    CS=1;
+    wait(0.1);
+    // TX_BASE ADDRESS
+    CS=0;
+    adf.write(0x09);
+    adf.write(0x24);
+    adf.write(0x20);
+    CS=1;
+    wait(0.1);
+    // BUFFER SIZE
+    CS=0;
+    adf.write(0x09);
+    adf.write(0x37);
+    adf.write(0xE0);
+    CS=1;
+    wait(0.1);
+    CS=0;
+    adf.write(0x09);
+    adf.write(0x36);
+    adf.write(0x70);
+    CS=1;
+    wait(0.1);
+    // PACKET WRITE
+    CS=0;
+    adf.write(0x18);
+    adf.write(0x20);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+ -   adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);
+    adf.write(0xFF);  
+    CS=1;
+    wait(0.1);
+    // TX MODE
+    
+    CS=0;//Initiate the IRQ
+    
+    adf.write(0x09);
+    adf.write(0x00);
+    adf.write(0x60);
+    adf.write(0x00);
+    adf.write(0x60);
+    
+    
+    
+    CS=1;
+    
+    
+    
+    
+    
+    CS=0;
+    adf.write(0xB5);
+    CS=1;
+    wait_ms(1);
+    CS=0;
+    adf.write(0x09);
+    adf.write(0x00);
+    adf.write(0x);
+       
+    CS=1;
+    wait_ms(1);
+    
+    
+}
+
+int main()
+{
+    adf.format(8,0);
+    adf.frequency(1000000);
+    bbram_write();
+    data_write();
+    
+}
\ No newline at end of file