ADF7023

Dependencies:   mbed

main.cpp

Committer:
dheerajmpai23
Date:
2015-07-09
Revision:
2:ab1b1054c848
Parent:
1:5a395f2fcdc8

File content as of revision 2:ab1b1054c848:

#include "mbed.h"
#include <iostream>
using namespace std;
#include <bitset>

#define ENDL "\r" << endl;
#define START_ADDRESS 0x020;
#define PI 3.14
SPI adf(PTD6, PTD7, PTD5);
//MOSI, MISO, CLOCK

DigitalOut CS(D10);
Serial PC(USBTX, USBRX);
DigitalOut ledr(LED_RED);

#define SPI_NOP 0xFF


void initialise(void){
    
//    CS=0;
//    adf.write(0xB0);
//    CS=1;
//    wait_ms(2);
//    
//    CS=0;
//    write_bbram_sequence();
//    CS=1;
//    wait_ms(2);
    
    
/*    CS=0;
    adf.write(0xBB);//CONFIGURE BBRAM DATA
    CS=1;
    wait_ms(2);*/
    
    CS=0;
    adf.write(0xB1);
    CS=1;
    wait_ms(2);
    
    //
//    CS=0;
//    adf.write(0xB5);//PHY TX MODE
//    CS=1;
//    wait_ms(2);
    
    
    }




int main(){
    
    CS = 1;
    adf.format(8,0);
    adf.frequency( 1000000 );
    
    cout << " Press s" << ENDL;
    ledr = 1;
    char c = 'a';
    while( c != 's'){
        c = PC.getc();
        PC.putc(c);
    }
    ledr = 0;
    int d=0;
    
    
    initialise();
    


    while(true){
        CS = 0;
        d++;
        cout<<d<<ENDL;
  
      
        //CS=0;
        adf.write(0xB5);//PHY TX MODE
        CS=1;
        wait_ms(2);   
  
//    adf.write(0xB5);
        CS=0;  
        unsigned char reply1 = adf.write(0xFF);
        unsigned char reply2 = adf.write(0xFF);
        CS=1;        
        std::bitset<8> b = reply1;
        cout << b << " \t ";
        b = reply2;
        cout << b << " \t " << ENDL;
 

    }

}