ADF7023

Dependencies:   mbed

Committer:
dheerajmpai23
Date:
Fri Jun 26 14:41:11 2015 +0000
Revision:
1:0a1e3fd2d4e3
Parent:
0:f8a9fca7e008
Child:
2:24459bb3d5cf
SUCCESSFULL TRANSMISSION CODE

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dheerajmpai23 0:f8a9fca7e008 1 #include "mbed.h"
dheerajmpai23 0:f8a9fca7e008 2 #include <iostream>
dheerajmpai23 0:f8a9fca7e008 3 using namespace std;
dheerajmpai23 0:f8a9fca7e008 4 #include <bitset>
dheerajmpai23 0:f8a9fca7e008 5
dheerajmpai23 0:f8a9fca7e008 6 #define ENDL "\r" << endl;
dheerajmpai23 0:f8a9fca7e008 7 #define START_ADDRESS 0x020;
dheerajmpai23 0:f8a9fca7e008 8
dheerajmpai23 0:f8a9fca7e008 9
dheerajmpai23 0:f8a9fca7e008 10
dheerajmpai23 0:f8a9fca7e008 11 //SPI
dheerajmpai23 0:f8a9fca7e008 12
dheerajmpai23 0:f8a9fca7e008 13 SPI adf(PTD6, PTD7, PTD5);
dheerajmpai23 0:f8a9fca7e008 14 //MOSI, MISO, CLOCK
dheerajmpai23 0:f8a9fca7e008 15
dheerajmpai23 0:f8a9fca7e008 16 DigitalOut CS(D10);
dheerajmpai23 0:f8a9fca7e008 17 Serial PC(USBTX, USBRX);
dheerajmpai23 0:f8a9fca7e008 18 DigitalOut ledr(LED_RED);
dheerajmpai23 0:f8a9fca7e008 19
dheerajmpai23 0:f8a9fca7e008 20 DigitalIn clk(D8);
dheerajmpai23 0:f8a9fca7e008 21 DigitalOut DT(D9);
dheerajmpai23 0:f8a9fca7e008 22 int j=0;
dheerajmpai23 0:f8a9fca7e008 23
dheerajmpai23 0:f8a9fca7e008 24 #define SPI_NOP 0xFF
dheerajmpai23 0:f8a9fca7e008 25
dheerajmpai23 0:f8a9fca7e008 26 enum con_type{ packet=0x18, bbram=0x19, mcr=0x1B, program=0x1E };
dheerajmpai23 0:f8a9fca7e008 27 enum discon_type{ packet2=0x08, bbram2=0x09, mcr2=0x0B };
dheerajmpai23 0:f8a9fca7e008 28
dheerajmpai23 0:f8a9fca7e008 29 enum discon_type_RD{ packet3=0x28, bbram3=0x29, mcr3=0x2B };
dheerajmpai23 0:f8a9fca7e008 30
dheerajmpai23 0:f8a9fca7e008 31 unsigned char data_TX [] = {0x65,0xD3,0x06,0x08,0xBB,0xE7,0xCD,0x16,0x65,0xD3,0x06,0x08,0xBB,0xE7,0xCD,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x20,0xE5,0xEE,0x00,0xEB,0x3D,0x35,0x66,0xDC,0xDA,0x33,0xA1,0x80,0x62,0xB7,0xB8,0x88,0x8A,0xCE,0x99,0x18,0xFA,0x24,0x42,0xD1,0x7C,0x2D,0x0E,0x72,0x9E,0xE9,0x7C,0xF9,0xBA,0x18,0xAA,0x4B,0xEC,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x20,0xE5,0xEE,0x00,0xCC,0xB3,0xB2,0x5B,0x96,0x38,0x71,0x96,0x54,0xE2,0x4A,0x7F,0xC9,0xB7,0x1E,0x56,0x09,0x30,0x18,0x5A,0x84,0xFA,0xC1,0x9D,0xA6,0x6A,0x17,0x50,0x6F,0xD4,0x34,0x1D,0xF0,0xE0,0xE2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x20,0xE5,0xEE,0x00,0x78,0xC9,0x9A,0x09,0xE2,0x34,0xF9,0x39,0x61,0x36,0x9C,0xC2,0x98,0xB9,0x54,0xC0,0xDC,0xE6,0x90,0xF6,0xF6,0x88,0xD1,0xA5,0x5A,0x75,0x83,0x78,0x08,0xD6,0x9D,0xDE,0xB8,0x58,0xD4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x20,0xE5,0xEE,0x00,0x13,0x3F,0x78,0xD9,0x4E,0xB7,0xE8,0xD6,0x0D,0x1E,0xF1,0xC4,0xB9,0xAB,0x90,0x39,0x6A,0x9E,0x8A,0xB8,0xC9,0xAF,0x5E,0x85,0x66,0xBF,0x4E,0xB3,0xD3,0x54,0x9B,0x7D,0xA3,0x3A,0x1A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x20,0xE5,0xEE,0x00,0x81,0x83,0x7B,0x88,0x8A,0xAB,0x31,0x91,0x8F,0xA0,0x91,0x05,0x17,0xC2,0xD2,0xB9,0xC1,0xEE,0x97,0xCE,0x66,0xE9,0x8A,0xA4,0xBC,0xB1,0xFC,0xCB,0x3B,0x24,0x6E,0x5B,0x87,0x19,0x64,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x97,0x4C,0x18,0x22,0xEF,0x9F,0x34,0x59,0x97,0x4C,0x18,0x22,0xEF,0x9F,0x34,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x97,0x4C,0x18,0x22,0xEF,0x9F,0x34,0x59,0x97,0x4C,0x18,0x22,0xEF,0x9F,0x34,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
dheerajmpai23 0:f8a9fca7e008 32
dheerajmpai23 0:f8a9fca7e008 33
dheerajmpai23 0:f8a9fca7e008 34 void send_data()
dheerajmpai23 0:f8a9fca7e008 35 {
dheerajmpai23 0:f8a9fca7e008 36
dheerajmpai23 0:f8a9fca7e008 37 // static int current_byte = 0;
dheerajmpai23 0:f8a9fca7e008 38 static int current_bit = 7;
dheerajmpai23 0:f8a9fca7e008 39
dheerajmpai23 0:f8a9fca7e008 40 DT = (data_TX[j] >> current_bit) & 1;
dheerajmpai23 0:f8a9fca7e008 41 --current_bit;
dheerajmpai23 0:f8a9fca7e008 42
dheerajmpai23 0:f8a9fca7e008 43 if(current_bit == -1){
dheerajmpai23 0:f8a9fca7e008 44 current_bit = 7;
dheerajmpai23 0:f8a9fca7e008 45 j++;
dheerajmpai23 0:f8a9fca7e008 46 cout<<"SENDING"<<ENDL;
dheerajmpai23 0:f8a9fca7e008 47 if(j>=sizeof(data_TX))
dheerajmpai23 0:f8a9fca7e008 48 {
dheerajmpai23 0:f8a9fca7e008 49 j=0;
dheerajmpai23 0:f8a9fca7e008 50
dheerajmpai23 0:f8a9fca7e008 51
dheerajmpai23 0:f8a9fca7e008 52 // while(true);
dheerajmpai23 0:f8a9fca7e008 53 }
dheerajmpai23 0:f8a9fca7e008 54 }
dheerajmpai23 0:f8a9fca7e008 55 }
dheerajmpai23 0:f8a9fca7e008 56
dheerajmpai23 0:f8a9fca7e008 57
dheerajmpai23 0:f8a9fca7e008 58 void write_con(con_type ram, uint8_t address, uint8_t *data, int length){
dheerajmpai23 0:f8a9fca7e008 59
dheerajmpai23 0:f8a9fca7e008 60 int *response = new int[length];
dheerajmpai23 0:f8a9fca7e008 61
dheerajmpai23 0:f8a9fca7e008 62
dheerajmpai23 0:f8a9fca7e008 63
dheerajmpai23 0:f8a9fca7e008 64
dheerajmpai23 0:f8a9fca7e008 65
dheerajmpai23 0:f8a9fca7e008 66 CS = 0;
dheerajmpai23 0:f8a9fca7e008 67
dheerajmpai23 0:f8a9fca7e008 68 // ignore recevived data
dheerajmpai23 0:f8a9fca7e008 69 adf.write( ram );
dheerajmpai23 0:f8a9fca7e008 70
dheerajmpai23 0:f8a9fca7e008 71 // write start address
dheerajmpai23 0:f8a9fca7e008 72 int r = adf.write( address );
dheerajmpai23 0:f8a9fca7e008 73
dheerajmpai23 0:f8a9fca7e008 74 // write data
dheerajmpai23 0:f8a9fca7e008 75 for(int i = 0 ; i < length ; ++i){
dheerajmpai23 0:f8a9fca7e008 76 response[i] = adf.write( data[i] );
dheerajmpai23 0:f8a9fca7e008 77 }
dheerajmpai23 0:f8a9fca7e008 78
dheerajmpai23 0:f8a9fca7e008 79 CS = 1;
dheerajmpai23 0:f8a9fca7e008 80
dheerajmpai23 0:f8a9fca7e008 81 cout << r << ENDL;
dheerajmpai23 0:f8a9fca7e008 82 for(int i = 0 ; i < length ; ++i){
dheerajmpai23 0:f8a9fca7e008 83 cout << response[i] << " ";
dheerajmpai23 0:f8a9fca7e008 84 }
dheerajmpai23 0:f8a9fca7e008 85 cout << ENDL;
dheerajmpai23 0:f8a9fca7e008 86
dheerajmpai23 0:f8a9fca7e008 87 }
dheerajmpai23 0:f8a9fca7e008 88
dheerajmpai23 0:f8a9fca7e008 89 void write_discon(discon_type ram, uint8_t *address, uint8_t *data, int length){
dheerajmpai23 0:f8a9fca7e008 90
dheerajmpai23 0:f8a9fca7e008 91 int *response1 = new int[length];
dheerajmpai23 0:f8a9fca7e008 92 int *response2 = new int[length];
dheerajmpai23 0:f8a9fca7e008 93
dheerajmpai23 0:f8a9fca7e008 94 CS = 0;
dheerajmpai23 0:f8a9fca7e008 95
dheerajmpai23 0:f8a9fca7e008 96 // ignore recevived data
dheerajmpai23 0:f8a9fca7e008 97 adf.write( ram );
dheerajmpai23 0:f8a9fca7e008 98
dheerajmpai23 0:f8a9fca7e008 99 for(int i = 0 ; i < length ; ++i){
dheerajmpai23 0:f8a9fca7e008 100
dheerajmpai23 0:f8a9fca7e008 101 // address[7:0] next 8 bits
dheerajmpai23 0:f8a9fca7e008 102 response1[i] = adf.write( address[i] );
dheerajmpai23 0:f8a9fca7e008 103
dheerajmpai23 0:f8a9fca7e008 104 // data next 8 bits
dheerajmpai23 0:f8a9fca7e008 105 response2[i] = adf.write( data[i] );
dheerajmpai23 0:f8a9fca7e008 106
dheerajmpai23 0:f8a9fca7e008 107 }
dheerajmpai23 0:f8a9fca7e008 108
dheerajmpai23 0:f8a9fca7e008 109 CS = 1;
dheerajmpai23 0:f8a9fca7e008 110
dheerajmpai23 0:f8a9fca7e008 111 for(int i = 0 ; i < length ; ++i){
dheerajmpai23 0:f8a9fca7e008 112 cout << response1[i] << "\t" << response2[i] << ENDL;
dheerajmpai23 0:f8a9fca7e008 113 }
dheerajmpai23 0:f8a9fca7e008 114
dheerajmpai23 0:f8a9fca7e008 115 }
dheerajmpai23 0:f8a9fca7e008 116
dheerajmpai23 0:f8a9fca7e008 117 int read_discon(discon_type_RD ram, uint8_t address){
dheerajmpai23 0:f8a9fca7e008 118
dheerajmpai23 0:f8a9fca7e008 119 CS = 0;
dheerajmpai23 0:f8a9fca7e008 120
dheerajmpai23 0:f8a9fca7e008 121 // ignore the reply
dheerajmpai23 0:f8a9fca7e008 122 adf.write( ram );
dheerajmpai23 0:f8a9fca7e008 123
dheerajmpai23 0:f8a9fca7e008 124 int stat1 = adf.write( address );
dheerajmpai23 0:f8a9fca7e008 125 int stat2 = adf.write( SPI_NOP );
dheerajmpai23 0:f8a9fca7e008 126 int reply = adf.write( SPI_NOP );
dheerajmpai23 0:f8a9fca7e008 127
dheerajmpai23 0:f8a9fca7e008 128 CS = 1;
dheerajmpai23 0:f8a9fca7e008 129
dheerajmpai23 0:f8a9fca7e008 130 return reply;
dheerajmpai23 0:f8a9fca7e008 131 }
dheerajmpai23 0:f8a9fca7e008 132
dheerajmpai23 0:f8a9fca7e008 133 void write_bbram_sequence(void){
dheerajmpai23 0:f8a9fca7e008 134
dheerajmpai23 0:f8a9fca7e008 135 adf.write(0x19);
dheerajmpai23 0:f8a9fca7e008 136 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 137 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 138 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 139
dheerajmpai23 0:f8a9fca7e008 140 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 141 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 142 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 143 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 144
dheerajmpai23 0:f8a9fca7e008 145 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 146 adf.write(0x33);
dheerajmpai23 0:f8a9fca7e008 147 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 148 adf.write(0xF9);
dheerajmpai23 0:f8a9fca7e008 149
dheerajmpai23 0:f8a9fca7e008 150 adf.write(0xC2);
dheerajmpai23 0:f8a9fca7e008 151 adf.write(0x10);
dheerajmpai23 0:f8a9fca7e008 152 adf.write(0xC0);
dheerajmpai23 0:f8a9fca7e008 153 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 154
dheerajmpai23 0:f8a9fca7e008 155 adf.write(0x30);
dheerajmpai23 0:f8a9fca7e008 156 adf.write(0x31);
dheerajmpai23 0:f8a9fca7e008 157 adf.write(0x07);
dheerajmpai23 0:f8a9fca7e008 158 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 159
dheerajmpai23 0:f8a9fca7e008 160 adf.write(0x01);
dheerajmpai23 0:f8a9fca7e008 161 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 162 adf.write(0x7F);
dheerajmpai23 0:f8a9fca7e008 163 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 164
dheerajmpai23 0:f8a9fca7e008 165 adf.write(0x0B);
dheerajmpai23 0:f8a9fca7e008 166 adf.write(0x37);
dheerajmpai23 0:f8a9fca7e008 167 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 168 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 169 adf.write(0x40);
dheerajmpai23 0:f8a9fca7e008 170 adf.write(0x0C);
dheerajmpai23 0:f8a9fca7e008 171 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 172 adf.write(0x05);
dheerajmpai23 0:f8a9fca7e008 173 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 174 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 175 adf.write(0x18);
dheerajmpai23 0:f8a9fca7e008 176 adf.write(0x12);
dheerajmpai23 0:f8a9fca7e008 177 adf.write(0x34);
dheerajmpai23 0:f8a9fca7e008 178 adf.write(0x56);
dheerajmpai23 0:f8a9fca7e008 179 adf.write(0x10);
dheerajmpai23 0:f8a9fca7e008 180 adf.write(0x10);
dheerajmpai23 0:f8a9fca7e008 181 adf.write(0x08);
dheerajmpai23 0:f8a9fca7e008 182 adf.write(0x14);
dheerajmpai23 0:f8a9fca7e008 183 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 184 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 185 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 186 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 187 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 188 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 189 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 190 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 191 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 192 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 193 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 194 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 195 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 196 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 197 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 198 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 199 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 200 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 201 adf.write(0x04);
dheerajmpai23 0:f8a9fca7e008 202 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 203 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 204 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 205 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 206 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 207
dheerajmpai23 0:f8a9fca7e008 208 }
dheerajmpai23 0:f8a9fca7e008 209
dheerajmpai23 0:f8a9fca7e008 210 void initiate(void){
dheerajmpai23 0:f8a9fca7e008 211
dheerajmpai23 0:f8a9fca7e008 212 // CS=0;
dheerajmpai23 0:f8a9fca7e008 213 // adf.write(0xB0);
dheerajmpai23 0:f8a9fca7e008 214 // CS=1;
dheerajmpai23 0:f8a9fca7e008 215 // wait_ms(2);
dheerajmpai23 0:f8a9fca7e008 216
dheerajmpai23 0:f8a9fca7e008 217 CS=0;
dheerajmpai23 0:f8a9fca7e008 218 adf.write(0x1B);
dheerajmpai23 0:f8a9fca7e008 219 adf.write(0xFA);
dheerajmpai23 0:f8a9fca7e008 220 adf.write(0xA0);
dheerajmpai23 0:f8a9fca7e008 221 CS=1;
dheerajmpai23 0:f8a9fca7e008 222 wait_ms(2);
dheerajmpai23 0:f8a9fca7e008 223
dheerajmpai23 0:f8a9fca7e008 224 CS=0;
dheerajmpai23 0:f8a9fca7e008 225 adf.write(0x18);
dheerajmpai23 0:f8a9fca7e008 226 adf.write(0x0D);
dheerajmpai23 0:f8a9fca7e008 227 adf.write(0x00);
dheerajmpai23 0:f8a9fca7e008 228 CS=1;
dheerajmpai23 0:f8a9fca7e008 229 wait_ms(2);
dheerajmpai23 0:f8a9fca7e008 230
dheerajmpai23 0:f8a9fca7e008 231 CS=0;
dheerajmpai23 0:f8a9fca7e008 232 adf.write(0xB0);
dheerajmpai23 0:f8a9fca7e008 233 CS=1;
dheerajmpai23 0:f8a9fca7e008 234 wait_ms(3);
dheerajmpai23 0:f8a9fca7e008 235
dheerajmpai23 0:f8a9fca7e008 236 CS=0;
dheerajmpai23 0:f8a9fca7e008 237 adf.write(0xB0);
dheerajmpai23 0:f8a9fca7e008 238 CS=1;
dheerajmpai23 0:f8a9fca7e008 239 wait_ms(3);
dheerajmpai23 0:f8a9fca7e008 240
dheerajmpai23 0:f8a9fca7e008 241
dheerajmpai23 0:f8a9fca7e008 242 CS=0;
dheerajmpai23 0:f8a9fca7e008 243 write_bbram_sequence();
dheerajmpai23 0:f8a9fca7e008 244 CS=1;
dheerajmpai23 0:f8a9fca7e008 245 wait_ms(2);
dheerajmpai23 0:f8a9fca7e008 246
dheerajmpai23 0:f8a9fca7e008 247 cout<<"BBRAM_SEQUENCE WRITTEN"<<ENDL;
dheerajmpai23 0:f8a9fca7e008 248
dheerajmpai23 0:f8a9fca7e008 249
dheerajmpai23 0:f8a9fca7e008 250 CS=0;
dheerajmpai23 0:f8a9fca7e008 251 adf.write(0xFF);
dheerajmpai23 0:f8a9fca7e008 252 adf.write(0xFF);
dheerajmpai23 0:f8a9fca7e008 253 CS=1;
dheerajmpai23 0:f8a9fca7e008 254 wait_ms(1);
dheerajmpai23 0:f8a9fca7e008 255
dheerajmpai23 0:f8a9fca7e008 256
dheerajmpai23 0:f8a9fca7e008 257 CS=0;
dheerajmpai23 0:f8a9fca7e008 258 adf.write(0xFF);
dheerajmpai23 0:f8a9fca7e008 259 adf.write(0xFF);
dheerajmpai23 0:f8a9fca7e008 260 CS=1;
dheerajmpai23 0:f8a9fca7e008 261 wait_ms(1);
dheerajmpai23 0:f8a9fca7e008 262
dheerajmpai23 0:f8a9fca7e008 263
dheerajmpai23 0:f8a9fca7e008 264 CS=0;
dheerajmpai23 0:f8a9fca7e008 265 adf.write(0xBB);//CONFIGURE_DEV
dheerajmpai23 0:f8a9fca7e008 266 CS=1;
dheerajmpai23 0:f8a9fca7e008 267 wait_ms(2);
dheerajmpai23 0:f8a9fca7e008 268
dheerajmpai23 0:f8a9fca7e008 269 cout<<"CONFIG_DEV"<<ENDL;
dheerajmpai23 0:f8a9fca7e008 270
dheerajmpai23 0:f8a9fca7e008 271 CS=0;
dheerajmpai23 0:f8a9fca7e008 272 adf.write(0xB1);//PHY_ON
dheerajmpai23 0:f8a9fca7e008 273 CS=1;
dheerajmpai23 0:f8a9fca7e008 274 wait_ms(2);
dheerajmpai23 0:f8a9fca7e008 275
dheerajmpai23 0:f8a9fca7e008 276 CS=0;
dheerajmpai23 0:f8a9fca7e008 277 adf.write(0xB5);//PHY_TX
dheerajmpai23 0:f8a9fca7e008 278 CS=1;
dheerajmpai23 0:f8a9fca7e008 279 wait_ms(2);
dheerajmpai23 0:f8a9fca7e008 280
dheerajmpai23 0:f8a9fca7e008 281 cout<<"PHY_TX"<<ENDL;
dheerajmpai23 0:f8a9fca7e008 282 }
dheerajmpai23 0:f8a9fca7e008 283
dheerajmpai23 0:f8a9fca7e008 284
dheerajmpai23 0:f8a9fca7e008 285
dheerajmpai23 0:f8a9fca7e008 286
dheerajmpai23 0:f8a9fca7e008 287 int main(){
dheerajmpai23 0:f8a9fca7e008 288
dheerajmpai23 0:f8a9fca7e008 289
dheerajmpai23 0:f8a9fca7e008 290 CS = 1;
dheerajmpai23 0:f8a9fca7e008 291 adf.format(8,0);
dheerajmpai23 0:f8a9fca7e008 292 adf.frequency( 1000000 );
dheerajmpai23 0:f8a9fca7e008 293
dheerajmpai23 0:f8a9fca7e008 294 cout << "Press s" << ENDL;
dheerajmpai23 0:f8a9fca7e008 295 ledr = 1;
dheerajmpai23 0:f8a9fca7e008 296 char c = 'a';
dheerajmpai23 0:f8a9fca7e008 297 while( c != 's'){
dheerajmpai23 0:f8a9fca7e008 298 c = PC.getc();
dheerajmpai23 0:f8a9fca7e008 299 PC.putc(c);
dheerajmpai23 0:f8a9fca7e008 300 }
dheerajmpai23 0:f8a9fca7e008 301 ledr = 0;
dheerajmpai23 0:f8a9fca7e008 302
dheerajmpai23 0:f8a9fca7e008 303 initiate();
dheerajmpai23 0:f8a9fca7e008 304 cout << "initiated" << ENDL;
dheerajmpai23 0:f8a9fca7e008 305 int state;
dheerajmpai23 0:f8a9fca7e008 306 if(clk == 0){
dheerajmpai23 0:f8a9fca7e008 307 state = 0;
dheerajmpai23 0:f8a9fca7e008 308 }
dheerajmpai23 0:f8a9fca7e008 309 else{
dheerajmpai23 0:f8a9fca7e008 310 state = 1;
dheerajmpai23 0:f8a9fca7e008 311 }
dheerajmpai23 0:f8a9fca7e008 312
dheerajmpai23 1:0a1e3fd2d4e3 313 int l=0;
dheerajmpai23 1:0a1e3fd2d4e3 314 while(l<=1000){
dheerajmpai23 0:f8a9fca7e008 315 cout << "in while" << ENDL;
dheerajmpai23 0:f8a9fca7e008 316
dheerajmpai23 0:f8a9fca7e008 317
dheerajmpai23 0:f8a9fca7e008 318 if(clk == 0){
dheerajmpai23 0:f8a9fca7e008 319 if(state == 1){
dheerajmpai23 0:f8a9fca7e008 320 state = 0;
dheerajmpai23 0:f8a9fca7e008 321 send_data();
dheerajmpai23 0:f8a9fca7e008 322 }
dheerajmpai23 0:f8a9fca7e008 323 }
dheerajmpai23 0:f8a9fca7e008 324 else{
dheerajmpai23 0:f8a9fca7e008 325 state = 1;
dheerajmpai23 0:f8a9fca7e008 326 }
dheerajmpai23 1:0a1e3fd2d4e3 327 l++;
dheerajmpai23 1:0a1e3fd2d4e3 328 }
dheerajmpai23 1:0a1e3fd2d4e3 329
dheerajmpai23 1:0a1e3fd2d4e3 330
dheerajmpai23 1:0a1e3fd2d4e3 331 CS=0;
dheerajmpai23 1:0a1e3fd2d4e3 332 adf.write(0xB1);
dheerajmpai23 1:0a1e3fd2d4e3 333 CS=1;
dheerajmpai23 1:0a1e3fd2d4e3 334 wait(1);
dheerajmpai23 1:0a1e3fd2d4e3 335 cout<<"Transmission should have stopped by now "<<ENDL;
dheerajmpai23 1:0a1e3fd2d4e3 336 }