Dheeraj M Pai
/
ADF7023_mbed_Rolling_Buffer_6
ADF7023-mbed
Revision 3:09638e7d0923, committed 2015-07-09
- Comitter:
- dheerajmpai23
- Date:
- Thu Jul 09 06:46:10 2015 +0000
- Parent:
- 2:9958a83be730
- Commit message:
- FOr Publishing
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 9958a83be730 -r 09638e7d0923 main.cpp --- a/main.cpp Mon Jun 29 09:35:25 2015 +0000 +++ b/main.cpp Thu Jul 09 06:46:10 2015 +0000 @@ -1,9 +1,11 @@ #include "mbed.h" #define ENDL "\r" << endl #include<iostream> + +using namespace std; DigitalOut led(LED_RED); DigitalOut CS(D10); - +InterruptIn IRQ(); SPI adf(PTD6, PTD7, PTD5); // mosi, miso, sclk @@ -52,47 +54,68 @@ 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(0xC4); // Different 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(0x00); adf.write(0x00); + adf.write(0x04); adf.write(0x00); adf.write(0x00); adf.write(0x00); + adf.write(0x00); adf.write(0x00); CS=1; wait(1); + //CMD_CONFIG_DEV + CS=0; + adf.write(0xBB); + CS=1; + wait_ms(2); + + +} + + +void initiate_rolling_buffer(void){ // Testmode register CS=0; adf.write(0x09); @@ -106,18 +129,17 @@ adf.write(0xBB); CS=1; wait_ms(2); + + //Status ReadBack CS=0; adf.write(0xFF); adf.write(0xFF); CS=1; wait_ms(2); -} - -void data_write() -{ - // PHY_ON + + // PHY_Off CS=0; - adf.write(0xB1); + adf.write(0xB0); CS=1; wait(0.1); CS=0; @@ -125,321 +147,139 @@ adf.write(0xFF); CS=1; wait(0.1); + // TRANSMIT_DATA LENGTH CS=0; adf.write(0x08); adf.write(0x14); - adf.write(0xFF); + adf.write(0x05);//<--------Changed fromm FF to 05 CS=1; - wait(0.1); + wait_ms(2); CS=0; adf.write(0x08); adf.write(0x15); - adf.write(0xFF); + adf.write(0x40);//<------------Changed frok FF to 40 CS=1; - wait(0.1); + wait_ms(2); // TX_BASE ADDRESS CS=0; adf.write(0x09); adf.write(0x24); adf.write(0x20); CS=1; - wait(0.1); + wait_ms(2); // BUFFER SIZE CS=0; adf.write(0x09); adf.write(0x37); adf.write(0xE0); CS=1; - wait(0.1); + wait_ms(2); CS=0; adf.write(0x09); adf.write(0x36); adf.write(0x70); CS=1; - wait(0.1); - // PACKET WRITE + wait_ms(2); + } + +void data_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); + adf.write(0xB1); CS=1; wait_ms(2); - // TX MODE + CS=0; adf.write(0xB5); CS=1; wait_ms(20); - while(1) - { - pool_irq(); - CS=0; - adf.write(0x2B); - adf.write(0x36); - int irq1 = adf.write(0xFF); - int irq2 = adf.write(0xFF); - CS=1; - wait_us(500); - cout<<irq1<<"/t"<<irq2<<ENDL; - } + + +// while(1) +// { +// pool_irq(); +// CS=0; +// adf.write(0x2B); +// adf.write(0x36); +// int irq1 = adf.write(0xFF); +// int irq2 = adf.write(0xFF); +// CS=1; +// wait_us(500); +// cout<<irq1<<"/t"<<irq2<<ENDL; +// } } -void pool_irq(void){ + + +int reply1 =0;//Temp +int reply2 =0;//TEMP +void temp_read_all(void){ + + adf.write(); + adf.write(); + adf.write(); + adf.write(); + adf.write(); + adf.write(); + + cout<<""<<reply1<<""<<reply2<<ENDL; + + + adf.write(); + adf.write(); + adf.write(); + adf.write(); + adf.write(); + adf.write(); + + cout<<""<<reply1<<""<<reply2<<ENDL; + } +void temp_read_irqsrc(void){ + + adf.write();//Read 0x336 + status read1 = adf.write(); + status read2 = adf.write(); + irq336 = adf.write(); + adf.write(); + + irq336 &= 0x60; + + if (irq336 == 0x40){ + + tx_half(); + put_irq_zero(); + + } + else if (irq336 == 0x20){ + + tx_full(); + put_irq_zero(); + + } + else if (irq336 == 0x00){ + cout<<"error due to other interrupts"<<ENDL; + put_irq_zero(); + } + else + cout<<"Bitwise and not working check your code"<<ENDL; + } + +void put_irq_zero(void){ + adf.write(0x0B); adf.write(0x36); - adf.write(0x98); - - adf.write(0x09); adf.write(0x00); - adf.write(0x98); + adf.write(0x37); + adf.write(0x00);//incase not written write multiple times +// temp_read_all(); + } + - adf.write(0x29); - adf.write(0x00); - adf.write(0x00); - adf.write(0x00); - adf.write(0x00); - adf.write(0xFF); - adf.write(0xFF); - - adf.write(0x2B); - adf.write(0x36); - adf.write(0x36); - adf.write(0x36); - adf.write(0x36); - adf.write(0xFF); - adf.write(0xFF); - - } + int main() { @@ -447,5 +287,16 @@ adf.frequency(1000000); bbram_write(); data_write(); + while(true){ + cout<<"working"<<ENDL; + IRQ.rise(&temp_read_irqsrc); + } + + + + + + + } } \ No newline at end of file