ADF7023

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
dheerajmpai23
Date:
Thu Jul 09 06:53:14 2015 +0000
Commit message:
PUBli

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jul 09 06:53:14 2015 +0000
@@ -0,0 +1,292 @@
+#include "mbed.h"
+#include <iostream>
+using namespace std;
+#include <bitset>
+
+#define ENDL "\r" << endl;
+#define START_ADDRESS 0x020;
+
+
+
+//SPI
+
+SPI adf(PTD6, PTD7, PTD5);
+//MOSI, MISO, CLOCK
+
+DigitalOut CS(D10);
+Serial PC(USBTX, USBRX);
+DigitalOut ledr(LED_RED);
+
+#define SPI_NOP 0xFF
+//
+//enum con_type{ packet=0x18, bbram=0x19, mcr=0x1B, program=0x1E };
+//enum discon_type{ packet2=0x08, bbram2=0x09, mcr2=0x0B };
+//
+//enum discon_type_RD{ packet3=0x28, bbram3=0x29, mcr3=0x2B };
+//
+//    void write_con(con_type ram, uint8_t address, uint8_t *data, int length){
+//   
+//    int *response = new int[length];
+//
+//    CS = 0;
+//   
+////    ignore recevived data
+//    adf.write( ram );
+//   
+////    write start address
+//    int r = adf.write( address );
+//   
+////    write data
+//    for(int i = 0 ; i < length ; ++i){
+//        response[i] = adf.write( data[i] );
+//    }
+//   
+//    CS = 1;
+//   
+//    cout << r << ENDL;
+//    for(int i = 0 ; i < length ; ++i){
+//        cout << response[i] << " ";
+//    }
+//    cout << ENDL;
+//   
+//}
+//
+//void write_discon(discon_type ram, uint8_t *address, uint8_t *data, int length){
+//   
+//    int *response1 = new int[length];
+//    int *response2 = new int[length];
+//   
+//    CS = 0;
+//   
+////    ignore recevived data
+//    adf.write( ram );
+//       
+//    for(int i = 0 ; i < length ; ++i){
+//
+////    address[7:0] next 8 bits
+//        response1[i] = adf.write( address[i] );
+//       
+////        data next 8 bits
+//        response2[i] = adf.write( data[i] );
+//       
+//    }
+//
+//    CS = 1;
+//   
+//    for(int i = 0 ; i < length ; ++i){
+//        cout << response1[i] << "\t" << response2[i] << ENDL;
+//    }
+//   
+//}
+//
+//int read_discon(discon_type_RD ram, uint8_t address){
+//   
+//    CS = 0;
+//   
+////    ignore the reply
+//    adf.write( ram );
+//   
+//    int stat1 = adf.write( address );
+//    int stat2 = adf.write( SPI_NOP );
+//    int reply = adf.write( SPI_NOP );
+////   
+//    CS = 1;
+//   
+//    return reply;
+//}
+
+void write_bbram_sequence_sprt_mode(void){
+   
+    adf.write(0x19);
+    adf.write(0x00);
+    adf.write(0x00);
+    adf.write(0x00);
+   
+    adf.write(0x00);   
+    adf.write(0x00);
+    adf.write(0x00);
+    adf.write(0x00);
+   
+    adf.write(0x00);
+    adf.write(0x33);
+    adf.write(0x00);
+    adf.write(0xF9);
+   
+    adf.write(0xC2);
+    adf.write(0x10);
+    adf.write(0xC0);   
+    adf.write(0x00);
+   
+    adf.write(0x30);
+    adf.write(0x31);
+    adf.write(0x07);   
+    adf.write(0x00);
+       
+    adf.write(0x01);
+    adf.write(0x00);
+    adf.write(0x7F);
+    adf.write(0x00);
+   
+    adf.write(0x0B);
+    adf.write(0x37);
+    adf.write(0x00);   
+    adf.write(0x00);
+    
+    adf.write(0x40);
+    adf.write(0x0C);
+    adf.write(0x00);
+    adf.write(0x05);
+    
+    adf.write(0x00);
+    adf.write(0x00);
+    adf.write(0x18);
+    adf.write(0x12);
+    
+    adf.write(0x34);
+    adf.write(0x56);
+    adf.write(0x10);
+    adf.write(0x10);
+    
+    adf.write(0x08);
+    adf.write(0x14);
+    adf.write(0x00);
+    adf.write(0x00);
+    
+    adf.write(0x00);
+    adf.write(0x00);
+    adf.write(0x00);
+    adf.write(0x00);
+    
+    adf.write(0x00);
+    adf.write(0x00);
+    adf.write(0x00);
+    adf.write(0x00);
+    
+    adf.write(0x00);
+    adf.write(0x00);
+    adf.write(0x00);
+    adf.write(0x00);
+    
+    adf.write(0x00);
+    adf.write(0x00);
+    adf.write(0x00);
+    adf.write(0x00);
+    
+    adf.write(0x04);
+    adf.write(0x00);
+    adf.write(0x00);
+    adf.write(0x00);
+    
+    adf.write(0x00);
+    adf.write(0x00);
+    
+    }
+   
+    void initiate(void){
+        
+        CS=0;
+        adf.write(0x1B);//sport mode
+        adf.write(0xFA);
+        adf.write(0xA0);
+        CS=1;
+        wait(2);
+        
+        
+        CS=0;
+        adf.write(0x18);//sprt mode
+        adf.write(0x0D);
+        adf.write(0x00);
+        CS=1;
+        wait(2);
+       
+        CS=0;
+        adf.write(0xB0);
+        CS=1;
+        wait(2);
+       
+        CS=0;
+        adf.write(0xB0);
+        CS=1;
+        wait(2);
+      
+     
+        CS=0;
+        adf.write(0x1B);
+        adf.write(0xFA);
+        adf.write(0xA0);
+        CS=1;
+        wait(2);
+           
+        CS=0;
+        adf.write(0x18);
+        adf.write(0x0D);
+        adf.write(0x00);
+        CS=1;
+        wait(2);
+       
+        CS=0;
+        write_bbram_sequence_sprt_mode();
+        CS=1;
+        wait(8);
+       
+        cout<<"BBRAM_SEQUENCE WRITTEN"<<ENDL;
+       
+        CS=0;
+        adf.write(0xBB);//CONFIGURE_DEV
+        CS=1;
+        wait(5);
+       
+        cout<<"CONFIG_DEV"<<ENDL;
+       
+        CS=0;
+        adf.write(0xB1);//PHY_ON
+        CS=1;
+        wait(2);
+        
+        
+        CS=0;
+        adf.write(0xFF);//Status Return
+        adf.write(0xFF);
+        CS=1;
+        wait(2);
+        
+        CS=0;
+        adf.write(0xB5);//PHY_TX
+        CS=1;
+        wait(2);
+        
+        
+        CS=0;
+        adf.write(0xFF);//Status Return
+        adf.write(0xFF);
+        CS=1;
+        wait(2);
+        
+        cout<<"Transmitting at 435.802Mhz"<<ENDL;
+     }
+
+
+         
+
+int main(){
+   
+    
+    CS = 1;
+    adf.format(8,3);
+    adf.frequency( 1000000 );
+   
+    cout << "Press s" << ENDL;
+    ledr = 1;
+    char c = 'a';
+    while( c != 's'){
+        c = PC.getc();
+        PC.putc(c);
+    }
+    ledr = 0;
+       
+    initiate();
+   
+}
+   
+   
+   
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jul 09 06:53:14 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7
\ No newline at end of file