Partially made code for adf7023

Dependencies:   mbed

Committer:
dheerajmpai23
Date:
Wed Oct 21 20:26:08 2015 +0000
Revision:
1:434b2062426b
Parent:
0:e80c23aacae6
Child:
2:599022fe2f99
Commited with functions for PHY_TX AND PHY_ON along with PHY_TX; ; Remaining:; SPI CMD Checkng

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dheerajmpai23 0:e80c23aacae6 1 ///ADF7023 From BIT BUCKET
dheerajmpai23 0:e80c23aacae6 2
dheerajmpai23 0:e80c23aacae6 3 #include "mbed.h"
dheerajmpai23 0:e80c23aacae6 4 #include <iostream>
dheerajmpai23 0:e80c23aacae6 5 #include <stdio.h>
dheerajmpai23 0:e80c23aacae6 6 using namespace std;
dheerajmpai23 0:e80c23aacae6 7 #include <bitset>
dheerajmpai23 0:e80c23aacae6 8 #define ENDL "\r" << endl;
dheerajmpai23 0:e80c23aacae6 9
dheerajmpai23 0:e80c23aacae6 10 #define MISO_PIN PTA17
dheerajmpai23 0:e80c23aacae6 11 #define THRS 20
dheerajmpai23 0:e80c23aacae6 12 #define STATE_ERR_THRS 20
dheerajmpai23 0:e80c23aacae6 13 #define PHY_OFF_EXEC_TIME 300
dheerajmpai23 1:434b2062426b 14 #define PHY_ON_EXEC_TIME 300
dheerajmpai23 1:434b2062426b 15 #define PHY_TX_EXEC_TIME 600
dheerajmpai23 0:e80c23aacae6 16 /******DEFINING OMMANDS*********/
dheerajmpai23 0:e80c23aacae6 17
dheerajmpai23 0:e80c23aacae6 18 #define CMD_HW_RESET 0xC8
dheerajmpai23 0:e80c23aacae6 19 SPI adf(PTA16, MISO_PIN, PTA15);
dheerajmpai23 0:e80c23aacae6 20 //MOSI, MISO, CLOCK
dheerajmpai23 0:e80c23aacae6 21 DigitalOut CS(D10);
dheerajmpai23 0:e80c23aacae6 22 //DigitalOut CS(PTD4);//D10==PTD4
dheerajmpai23 0:e80c23aacae6 23 Serial PC(USBTX, USBRX);
dheerajmpai23 0:e80c23aacae6 24 DigitalOut ledr(LED1);
dheerajmpai23 0:e80c23aacae6 25 DigitalOut led2(LED2);
dheerajmpai23 0:e80c23aacae6 26 InterruptIn IRQ(D8);
dheerajmpai23 0:e80c23aacae6 27 //InterruptIn IRQ(PTA13);//D8==PTA13
dheerajmpai23 0:e80c23aacae6 28 Ticker ticker;
dheerajmpai23 0:e80c23aacae6 29 //Timer t;
dheerajmpai23 0:e80c23aacae6 30 //Timer stop;
dheerajmpai23 0:e80c23aacae6 31 int x=IRQ;
dheerajmpai23 0:e80c23aacae6 32 int src=0;
dheerajmpai23 0:e80c23aacae6 33 int irqsrc = 0;
dheerajmpai23 0:e80c23aacae6 34 int j = 0;
dheerajmpai23 0:e80c23aacae6 35 int k = 0;
dheerajmpai23 0:e80c23aacae6 36 int irq1=0;
dheerajmpai23 0:e80c23aacae6 37 int r = 0;
dheerajmpai23 0:e80c23aacae6 38 unsigned char data[]={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,0x10,0x83,0x11,0x24,0x67,0xCE,0x05,0x50,0x01,0x45,0x9D,0x46,0x0D,0x6B,0xC1,0xF2,0xF3,0xE8,0xFE,0x52,0x0A,0x27,0x90,0x0A,0x3F,0x15,0xD1,0x68,0xD0,0x48,0x75,0x06,0x04,0xB7,0xE6,0xA0,0x82,0xF2,0x50,0x20,0x75,0x09,0x65,0x68,0x1A,0x9A,0xDD,0x1C,0x3F,0xC6,0xF5,0xD8,0xBD,0x96,0xB1,0xA0,0x92,0x29,0x44,0x78,0x60,0x0C,0x5D,0xCE,0xED,0x7A,0x85,0xF0,0x70,0x1C,0x7F,0x52,0x7B,0x14,0x43,0x4C,0x76,0xDD,0x41,0x86,0x59,0x6D,0x18,0x7C,0x63,0xF3,0x9F,0x74,0xB8,0x00,0x77,0xC0,0x18,0xDD,0xCE,0xA2,0xD1,0x2A,0xF3,0xFE,0x22,0xB5,0x0E,0x42,0xAF,0xB7,0x89,0x38,0x15,0xB0,0xCD,0xD6,0x27,0xEB,0x3F,0x5C,0x05,0xF7,0x26,0x5A,0x6A,0x4B,0x08,0x9E,0xAA,0x74,0xFF,0x30,0x0A,0x0A,0xBD,0x72,0xA2,0x44,0x20,0xC6,0x92,0x59,0xF3,0x80,0x55,0x00,0x51,0x64,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x20,0xE5,0xEE,0x00,0xD4,0x63,0x5A,0xF0,0x1F,0x1C,0xFA,0x3C,0xE5,0x22,0x89,0xE4,0x00,0xAF,0xC5,0x74,0x16,0xB4,0x12,0x1C,0x50,0x61,0x2D,0xF8,0x6A,0x20,0xBC,0x96,0x82,0x1D,0x42,0x5A,0xD6,0x86,0xA6,0xB4,0xD1,0xCF,0xF1,0xBC,0x5D,0xAF,0x65,0xAE,0x9A,0x24,0x8A,0x52,0xC7,0x98,0x03,0x14,0xDC,0xDB,0x5E,0xA0,0x5F,0x1C,0x07,0x1E,0x75,0x3E,0xC5,0x12,0xB4,0xDD,0xB7,0x50,0x18,0x76,0x5B,0x44,0x87,0xD8,0xFC,0xE4,0xF7,0x6E,0x00,0x1E,0xFC,0x06,0x37,0x70,0xEA,0x14,0x4A,0xBE,0xBF,0xE8,0xAD,0x42,0x64,0x0B,0xED,0xE2,0x13,0x85,0x6C,0x30,0xDD,0x69,0xFA,0xCC,0xF5,0xC1,0x7D,0xC8,0x65,0xBA,0x92,0xC0,0x89,0xCA,0x9D,0x3C,0xF3,0x02,0x82,0xAE,0x57,0x08,0x91,0x08,0x0C,0x44,0x96,0x7E,0xB8,0x15,0x40,0x14,0x16,0x75,0x18,0xD4,0xAF,0x07,0xC7,0x3C,0xA3,0xF9,0x48,0xA0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x20,0xE5,0xEE,0x00,0x9E,0x40,0x2B,0xF0,0x57,0x45,0xAD,0x04,0x21,0xD4,0x18,0x48,0xDF,0x9A,0x88,0x2C,0xC9,0x40,0x87,0x52,0xA5,0x95,0xA1,0xA8,0x6B,0x74,0x73,0xFC,0x1B,0xD7,0x6B,0xDA,0xDA,0xC6,0x89,0x22,0x25,0x11,0xE6,0x00,0x31,0x77,0x36,0xD6,0x6A,0x17,0xC7,0x02,0xF1,0xFD,0x4F,0xB0,0x51,0x0D,0x37,0x6E,0xF5,0x06,0x1D,0x96,0x34,0x61,0xF6,0x3C,0xCE,0x7D,0xDB,0x80,0x01,0xDF,0x01,0x8C,0x77,0x3A,0x85,0x10,0xAB,0xCF,0xFA,0x2A,0x54,0x39,0x02,0xFA,0x5E,0x24,0xE1,0x58,0xC3,0x37,0x5A,0x7C,0xAC,0xFD,0x70,0x5C,0xDC,0x99,0x6E,0xA6,0xAC,0x22,0x72,0xA6,0x53,0xFC,0xC0,0xA0,0x2A,0xF5,0xC2,0x24,0x10,0x83,0x11,0x24,0x67,0xCE,0x05,0x50,0x01,0x45,0x9D,0x46,0x0D,0x6B,0xC1,0xF2,0xF3,0xE8,0xFE,0x52,0x0A,0x27,0x90,0x0A,0x3F,0x15,0xD1,0x68,0xD0,0x48,0x75,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x20,0xE5,0xEE,0x00,0x04,0xB7,0xE6,0xA0,0x82,0xF2,0x50,0x20,0x75,0x09,0x65,0x68,0x1A,0x9A,0xDD,0x1C,0x3F,0xC6,0xF5,0xD8,0xBD,0x96,0xB1,0xA0,0x92,0x29,0x44,0x78,0x60,0x0C,0x5D,0xCE,0xED,0x7A,0x85,0xF0,0x70,0x1C,0x7F,0x52,0x7B,0x14,0x43,0x4C,0x76,0xDD,0x41,0x86,0x59,0x6D,0x18,0x7C,0x63,0xF3,0x9F,0x74,0xB8,0x00,0x77,0xC0,0x18,0xDD,0xCE,0xA2,0xD1,0x2A,0xF3,0xFE,0x22,0xB5,0x0E,0x42,0xAF,0xB7,0x89,0x38,0x15,0xB0,0xCD,0xD6,0x27,0xEB,0x3F,0x5C,0x05,0xF7,0x26,0x5A,0x6A,0x4B,0x08,0x9E,0xAA,0x74,0xFF,0x30,0x0A,0x0A,0xBD,0x72,0xA2,0x44,0x20,0xC6,0x92,0x59,0xF3,0x80,0x55,0x00,0x51,0x64,0xD4,0x63,0x5A,0xF0,0x1F,0x1C,0xFA,0x3C,0xE5,0x22,0x89,0xE4,0x00,0xAF,0xC5,0x74,0x16,0xB4,0x12,0x1C,0x50,0x61,0x2D,0xF8,0x6A,0x20,0xBC,0x96,0x82,0x1D,0x42,0x5A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x20,0xE5,0xEE,0x00,0xD6,0x86,0xA6,0xB4,0xD1,0xCF,0xF1,0xBC,0x5D,0xAF,0x65,0xAE,0x9A,0x24,0x8A,0x52,0xC7,0x98,0x03,0x14,0xDC,0xDB,0x5E,0xA0,0x5F,0x1C,0x07,0x1E,0x75,0x3E,0xC5,0x12,0xB4,0xDD,0xB7,0x50,0x18,0x76,0x5B,0x44,0x87,0xD8,0xFC,0xE4,0xF7,0x6E,0x00,0x1E,0xFC,0x06,0x37,0x70,0xEA,0x14,0x4A,0xBE,0xBF,0xE8,0xAD,0x42,0x64,0x0B,0xED,0xE2,0x13,0x85,0x6C,0x30,0xDD,0x69,0xFA,0xCC,0xF5,0xC1,0x7D,0xC8,0x65,0xBA,0x92,0xC0,0x89,0xCA,0x9D,0x3C,0xF3,0x02,0x82,0xAE,0x57,0x08,0x91,0x08,0x0C,0x44,0x96,0x7E,0xB8,0x15,0x40,0x14,0x16,0x75,0x18,0xD4,0xAF,0x07,0xC7,0x3C,0xA3,0xF9,0x48,0xA0,0x9E,0x40,0x2B,0xF0,0x57,0x45,0xAD,0x04,0x21,0xD4,0x18,0x48,0xDF,0x9A,0x88,0x2C,0xC9,0x40,0x87,0x52,0xA5,0x95,0xA1,0xA8,0x6B,0x74,0x73,0xFC,0x1B,0xD7,0x6B,0xDA,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:e80c23aacae6 39 int a[100];
dheerajmpai23 0:e80c23aacae6 40 int b[100];
dheerajmpai23 0:e80c23aacae6 41 int c[100];
dheerajmpai23 0:e80c23aacae6 42
dheerajmpai23 0:e80c23aacae6 43 /*****ERROR CHECKING ALGO*****/
dheerajmpai23 0:e80c23aacae6 44 unsigned char status =0;
dheerajmpai23 0:e80c23aacae6 45 unsigned int cmd_err_cnt=0;
dheerajmpai23 0:e80c23aacae6 46 unsigned int state_err_cnt=0;
dheerajmpai23 0:e80c23aacae6 47 /***********/
dheerajmpai23 0:e80c23aacae6 48
dheerajmpai23 0:e80c23aacae6 49 #define SPI_NOP 0xFF
dheerajmpai23 0:e80c23aacae6 50 /***********************************************************************************/
dheerajmpai23 0:e80c23aacae6 51 void bbram_write()
dheerajmpai23 0:e80c23aacae6 52 {
dheerajmpai23 0:e80c23aacae6 53 /* CS=0;
dheerajmpai23 0:e80c23aacae6 54 adf.write(0xB0);//PHY_OFF
dheerajmpai23 0:e80c23aacae6 55 wait_ms(2);
dheerajmpai23 0:e80c23aacae6 56 CS=1;
dheerajmpai23 0:e80c23aacae6 57 *///Commented on 21st October debugging
dheerajmpai23 0:e80c23aacae6 58 // Write bbram
dheerajmpai23 0:e80c23aacae6 59 CS=0;
dheerajmpai23 0:e80c23aacae6 60 adf.write(0x19);
dheerajmpai23 0:e80c23aacae6 61 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 62 adf.write(0x60);
dheerajmpai23 0:e80c23aacae6 63 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 64
dheerajmpai23 0:e80c23aacae6 65 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 66 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 67 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 68 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 69
dheerajmpai23 0:e80c23aacae6 70 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 71 adf.write(0x33);
dheerajmpai23 0:e80c23aacae6 72 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 73 adf.write(0xF4);//Frequency Register F9 = 435.802 MHz F4 = 435.800 MHz
dheerajmpai23 0:e80c23aacae6 74
dheerajmpai23 0:e80c23aacae6 75 adf.write(0xC2);
dheerajmpai23 0:e80c23aacae6 76 adf.write(0x10);
dheerajmpai23 0:e80c23aacae6 77 adf.write(0xC0);
dheerajmpai23 0:e80c23aacae6 78 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 79
dheerajmpai23 0:e80c23aacae6 80 adf.write(0x30);
dheerajmpai23 0:e80c23aacae6 81 adf.write(0x31);
dheerajmpai23 0:e80c23aacae6 82 adf.write(0x07);
dheerajmpai23 0:e80c23aacae6 83 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 84
dheerajmpai23 0:e80c23aacae6 85 adf.write(0x01);
dheerajmpai23 0:e80c23aacae6 86 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 87 adf.write(0x7F);
dheerajmpai23 0:e80c23aacae6 88 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 89
dheerajmpai23 0:e80c23aacae6 90 adf.write(0x0B);
dheerajmpai23 0:e80c23aacae6 91 adf.write(0x37);
dheerajmpai23 0:e80c23aacae6 92 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 93 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 94
dheerajmpai23 0:e80c23aacae6 95 adf.write(0x40);
dheerajmpai23 0:e80c23aacae6 96 adf.write(0x0C);
dheerajmpai23 0:e80c23aacae6 97 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 98 adf.write(0x05);
dheerajmpai23 0:e80c23aacae6 99
dheerajmpai23 0:e80c23aacae6 100 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 101 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 102 adf.write(0x18);
dheerajmpai23 0:e80c23aacae6 103 adf.write(0x12);
dheerajmpai23 0:e80c23aacae6 104
dheerajmpai23 0:e80c23aacae6 105 adf.write(0x34);
dheerajmpai23 0:e80c23aacae6 106 adf.write(0x56);
dheerajmpai23 0:e80c23aacae6 107 adf.write(0x10);
dheerajmpai23 0:e80c23aacae6 108 adf.write(0x10);
dheerajmpai23 0:e80c23aacae6 109
dheerajmpai23 0:e80c23aacae6 110 adf.write(0xC4); // Different
dheerajmpai23 0:e80c23aacae6 111 adf.write(0x14);
dheerajmpai23 0:e80c23aacae6 112 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 113 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 114
dheerajmpai23 0:e80c23aacae6 115 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 116 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 117 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 118 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 119
dheerajmpai23 0:e80c23aacae6 120 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 121 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 122 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 123 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 124
dheerajmpai23 0:e80c23aacae6 125 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 126 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 127 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 128 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 129
dheerajmpai23 0:e80c23aacae6 130 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 131 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 132 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 133 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 134
dheerajmpai23 0:e80c23aacae6 135 adf.write(0x04);
dheerajmpai23 0:e80c23aacae6 136 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 137 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 138 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 139
dheerajmpai23 0:e80c23aacae6 140 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 141 adf.write(0x00);
dheerajmpai23 0:e80c23aacae6 142 CS=1;
dheerajmpai23 0:e80c23aacae6 143 wait(1);
dheerajmpai23 0:e80c23aacae6 144
dheerajmpai23 0:e80c23aacae6 145 }
dheerajmpai23 0:e80c23aacae6 146
dheerajmpai23 0:e80c23aacae6 147
dheerajmpai23 0:e80c23aacae6 148 /******************************************************************************************/
dheerajmpai23 0:e80c23aacae6 149
dheerajmpai23 0:e80c23aacae6 150 void initiate(void){
dheerajmpai23 0:e80c23aacae6 151
dheerajmpai23 0:e80c23aacae6 152 CS=0;
dheerajmpai23 0:e80c23aacae6 153 adf.write(0xFF);
dheerajmpai23 0:e80c23aacae6 154 adf.write(0xFF);
dheerajmpai23 0:e80c23aacae6 155 CS=1;
dheerajmpai23 0:e80c23aacae6 156 wait_ms(2);
dheerajmpai23 0:e80c23aacae6 157
dheerajmpai23 0:e80c23aacae6 158 CS=0;
dheerajmpai23 0:e80c23aacae6 159 adf.write(0x08); // TRANSMIT_DATA LENGTH
dheerajmpai23 0:e80c23aacae6 160 adf.write(0x14);
dheerajmpai23 0:e80c23aacae6 161 adf.write(0xFF);
dheerajmpai23 0:e80c23aacae6 162 CS=1;
dheerajmpai23 0:e80c23aacae6 163 wait_ms(2);
dheerajmpai23 0:e80c23aacae6 164 CS=0;
dheerajmpai23 0:e80c23aacae6 165 adf.write(0x08); // TRANSMIT_DATA LENGTH
dheerajmpai23 0:e80c23aacae6 166 adf.write(0x15);
dheerajmpai23 0:e80c23aacae6 167 adf.write(0xFF);
dheerajmpai23 0:e80c23aacae6 168 CS=1;
dheerajmpai23 0:e80c23aacae6 169 wait_ms(2);
dheerajmpai23 0:e80c23aacae6 170
dheerajmpai23 0:e80c23aacae6 171 CS=0;
dheerajmpai23 0:e80c23aacae6 172 adf.write(0x09);
dheerajmpai23 0:e80c23aacae6 173 adf.write(0x24); // TX_BASE ADDRESS 0x20(starting Tx Byte)
dheerajmpai23 0:e80c23aacae6 174 adf.write(0x20);
dheerajmpai23 0:e80c23aacae6 175 CS=1;
dheerajmpai23 0:e80c23aacae6 176 wait_ms(2);
dheerajmpai23 0:e80c23aacae6 177
dheerajmpai23 0:e80c23aacae6 178 CS=0;
dheerajmpai23 0:e80c23aacae6 179 adf.write(0x09);
dheerajmpai23 0:e80c23aacae6 180 adf.write(0x37);// BUFFER SIZE 0xE0=224 Bytes 0x137 is adress of buffer size
dheerajmpai23 0:e80c23aacae6 181 adf.write(0xE0);
dheerajmpai23 0:e80c23aacae6 182 CS=1;
dheerajmpai23 0:e80c23aacae6 183 wait_ms(2);
dheerajmpai23 0:e80c23aacae6 184
dheerajmpai23 0:e80c23aacae6 185 CS=0;
dheerajmpai23 0:e80c23aacae6 186 adf.write(0x09);
dheerajmpai23 0:e80c23aacae6 187 adf.write(0x36);//BB_Tx_Buffer Signal when Buffer is half filled
dheerajmpai23 0:e80c23aacae6 188 adf.write(0x70);//0x70 = 112 >> When Half buffer interrupt is given
dheerajmpai23 0:e80c23aacae6 189 CS=1;
dheerajmpai23 0:e80c23aacae6 190 wait_ms(2);
dheerajmpai23 0:e80c23aacae6 191
dheerajmpai23 0:e80c23aacae6 192
dheerajmpai23 0:e80c23aacae6 193 CS=0;
dheerajmpai23 0:e80c23aacae6 194 adf.write(0x09);
dheerajmpai23 0:e80c23aacae6 195 adf.write(0x39);//BB_Tx_Buffer Signal when Buffer is half filled
dheerajmpai23 0:e80c23aacae6 196 adf.write(0x10);//0x70 = 112 >> When Half buffer interrupt is given
dheerajmpai23 0:e80c23aacae6 197 CS=1;
dheerajmpai23 0:e80c23aacae6 198 wait_ms(2);
dheerajmpai23 0:e80c23aacae6 199
dheerajmpai23 0:e80c23aacae6 200 }
dheerajmpai23 0:e80c23aacae6 201
dheerajmpai23 0:e80c23aacae6 202
dheerajmpai23 0:e80c23aacae6 203
dheerajmpai23 0:e80c23aacae6 204 /*int irq_src(void){
dheerajmpai23 0:e80c23aacae6 205
dheerajmpai23 0:e80c23aacae6 206 adf.write(0x2B);
dheerajmpai23 0:e80c23aacae6 207 adf.write(0x36);
dheerajmpai23 0:e80c23aacae6 208 adf.write(0xFF);
dheerajmpai23 0:e80c23aacae6 209 irqsrc = adf.write(0xFF);
dheerajmpai23 0:e80c23aacae6 210
dheerajmpai23 0:e80c23aacae6 211 irqsrc &= 0x60;
dheerajmpai23 0:e80c23aacae6 212 if (irqsrc == 0x20)
dheerajmpai23 0:e80c23aacae6 213 return 1;//Buffer is almost full
dheerajmpai23 0:e80c23aacae6 214 else if (irqsrc == 0x40)
dheerajmpai23 0:e80c23aacae6 215 return 2;// Buffer is Full
dheerajmpai23 0:e80c23aacae6 216 else
dheerajmpai23 0:e80c23aacae6 217 return 0;
dheerajmpai23 0:e80c23aacae6 218 }
dheerajmpai23 0:e80c23aacae6 219 */
dheerajmpai23 0:e80c23aacae6 220 int p=112;
dheerajmpai23 0:e80c23aacae6 221 int count = 0;
dheerajmpai23 0:e80c23aacae6 222 int intcount =0;
dheerajmpai23 0:e80c23aacae6 223
dheerajmpai23 0:e80c23aacae6 224 void write_data(void){
dheerajmpai23 0:e80c23aacae6 225 // t.reset();
dheerajmpai23 0:e80c23aacae6 226 // count++;
dheerajmpai23 0:e80c23aacae6 227 // cout<<"3"<<ENDL;
dheerajmpai23 0:e80c23aacae6 228 // ledr=!ledr;
dheerajmpai23 0:e80c23aacae6 229 // cout<<"irq detected"<<ENDL;
dheerajmpai23 0:e80c23aacae6 230 // src = irq_src();
dheerajmpai23 0:e80c23aacae6 231 p+=112;
dheerajmpai23 0:e80c23aacae6 232
dheerajmpai23 0:e80c23aacae6 233 //CS=0;
dheerajmpai23 0:e80c23aacae6 234 // adf.write(0x0B);//IRQ_SOURCE_Random write //To read CMD = 2B 36 FF FF
dheerajmpai23 0:e80c23aacae6 235 // adf.write(0x36);//Address : 0x336
dheerajmpai23 0:e80c23aacae6 236 // adf.write(0xFF);//Put Low
dheerajmpai23 0:e80c23aacae6 237 // CS=1;
dheerajmpai23 0:e80c23aacae6 238 // wait_us(80);
dheerajmpai23 0:e80c23aacae6 239 // CS=0;
dheerajmpai23 0:e80c23aacae6 240 // k=0;
dheerajmpai23 0:e80c23aacae6 241
dheerajmpai23 0:e80c23aacae6 242 if(!j){
dheerajmpai23 0:e80c23aacae6 243 adf.write(0x18);
dheerajmpai23 0:e80c23aacae6 244 adf.write(0x20);
dheerajmpai23 0:e80c23aacae6 245 while(k<=223){
dheerajmpai23 0:e80c23aacae6 246
dheerajmpai23 0:e80c23aacae6 247 adf.write(data[k]);
dheerajmpai23 0:e80c23aacae6 248 k++;
dheerajmpai23 0:e80c23aacae6 249 }
dheerajmpai23 0:e80c23aacae6 250
dheerajmpai23 0:e80c23aacae6 251 }
dheerajmpai23 0:e80c23aacae6 252
dheerajmpai23 0:e80c23aacae6 253 else if(k<sizeof(data)){
dheerajmpai23 0:e80c23aacae6 254 // if(src == 1){
dheerajmpai23 0:e80c23aacae6 255 if(j%2){ //src== Buffer Half Full src == 1
dheerajmpai23 0:e80c23aacae6 256 adf.write(0x18);
dheerajmpai23 0:e80c23aacae6 257 adf.write(0x20);
dheerajmpai23 0:e80c23aacae6 258 }
dheerajmpai23 0:e80c23aacae6 259
dheerajmpai23 0:e80c23aacae6 260 // else if(src==2){
dheerajmpai23 0:e80c23aacae6 261 else{ //src== Buffer is Full src==2
dheerajmpai23 0:e80c23aacae6 262 adf.write(0x18);
dheerajmpai23 0:e80c23aacae6 263 adf.write(0x90);
dheerajmpai23 0:e80c23aacae6 264 }
dheerajmpai23 0:e80c23aacae6 265
dheerajmpai23 0:e80c23aacae6 266
dheerajmpai23 0:e80c23aacae6 267 while(k<p){
dheerajmpai23 0:e80c23aacae6 268 adf.write(data[k]);
dheerajmpai23 0:e80c23aacae6 269 k++;
dheerajmpai23 0:e80c23aacae6 270
dheerajmpai23 0:e80c23aacae6 271 }
dheerajmpai23 0:e80c23aacae6 272 // if((k)>=sizeof(data))
dheerajmpai23 0:e80c23aacae6 273 // {
dheerajmpai23 0:e80c23aacae6 274 // ticker.detach();//Stop interrupt detection
dheerajmpai23 0:e80c23aacae6 275 // cout<<src<<ENDL;
dheerajmpai23 0:e80c23aacae6 276 // }
dheerajmpai23 0:e80c23aacae6 277
dheerajmpai23 0:e80c23aacae6 278
dheerajmpai23 0:e80c23aacae6 279 }
dheerajmpai23 0:e80c23aacae6 280
dheerajmpai23 0:e80c23aacae6 281 else if(k>=(sizeof(data)) ){
dheerajmpai23 0:e80c23aacae6 282 k=0;
dheerajmpai23 0:e80c23aacae6 283 j=1;
dheerajmpai23 0:e80c23aacae6 284 p=0;
dheerajmpai23 0:e80c23aacae6 285 // cout<<count<<" "<<sizeof(data)/112<<ENDL;
dheerajmpai23 0:e80c23aacae6 286 }
dheerajmpai23 0:e80c23aacae6 287
dheerajmpai23 0:e80c23aacae6 288
dheerajmpai23 0:e80c23aacae6 289 CS=0;
dheerajmpai23 0:e80c23aacae6 290 adf.write(0x0B);//IRQ_SOURCE_Random write //To read CMD = 2B 36 FF FF
dheerajmpai23 0:e80c23aacae6 291 adf.write(0x36);//Address : 0x336
dheerajmpai23 0:e80c23aacae6 292 adf.write(0xFF);//Put Low
dheerajmpai23 0:e80c23aacae6 293 CS=1;
dheerajmpai23 0:e80c23aacae6 294 wait_us(80);
dheerajmpai23 0:e80c23aacae6 295 CS=0;
dheerajmpai23 0:e80c23aacae6 296
dheerajmpai23 0:e80c23aacae6 297 // a[r]=t.read_us();
dheerajmpai23 0:e80c23aacae6 298 j++;
dheerajmpai23 0:e80c23aacae6 299 // r++;
dheerajmpai23 0:e80c23aacae6 300 CS=1;
dheerajmpai23 0:e80c23aacae6 301 wait_us(1);
dheerajmpai23 0:e80c23aacae6 302 }
dheerajmpai23 0:e80c23aacae6 303
dheerajmpai23 0:e80c23aacae6 304 void Interrupt(){
dheerajmpai23 0:e80c23aacae6 305 x = IRQ;
dheerajmpai23 0:e80c23aacae6 306 // intcount++;
dheerajmpai23 0:e80c23aacae6 307 if(x)
dheerajmpai23 0:e80c23aacae6 308 {
dheerajmpai23 0:e80c23aacae6 309 write_data();
dheerajmpai23 0:e80c23aacae6 310 }
dheerajmpai23 0:e80c23aacae6 311 }
dheerajmpai23 0:e80c23aacae6 312
dheerajmpai23 0:e80c23aacae6 313
dheerajmpai23 0:e80c23aacae6 314
dheerajmpai23 0:e80c23aacae6 315
dheerajmpai23 0:e80c23aacae6 316 void send_data(void){
dheerajmpai23 0:e80c23aacae6 317
dheerajmpai23 0:e80c23aacae6 318 CS=0;
dheerajmpai23 0:e80c23aacae6 319 adf.write(0xBB);
dheerajmpai23 0:e80c23aacae6 320 CS=1;
dheerajmpai23 0:e80c23aacae6 321 wait_ms(2);
dheerajmpai23 0:e80c23aacae6 322
dheerajmpai23 0:e80c23aacae6 323 CS=0;
dheerajmpai23 0:e80c23aacae6 324 adf.write(0xFF);
dheerajmpai23 0:e80c23aacae6 325 adf.write(0xFF);
dheerajmpai23 0:e80c23aacae6 326 CS=1;
dheerajmpai23 0:e80c23aacae6 327 wait_ms(2);
dheerajmpai23 0:e80c23aacae6 328
dheerajmpai23 0:e80c23aacae6 329 write_data();
dheerajmpai23 0:e80c23aacae6 330
dheerajmpai23 0:e80c23aacae6 331 CS=0;
dheerajmpai23 0:e80c23aacae6 332 adf.write(0xB1);
dheerajmpai23 0:e80c23aacae6 333 CS=1;
dheerajmpai23 0:e80c23aacae6 334 wait_ms(2);
dheerajmpai23 0:e80c23aacae6 335
dheerajmpai23 0:e80c23aacae6 336 CS=0;
dheerajmpai23 0:e80c23aacae6 337 adf.write(0xFF);
dheerajmpai23 0:e80c23aacae6 338 adf.write(0xFF);
dheerajmpai23 0:e80c23aacae6 339 CS=1;
dheerajmpai23 0:e80c23aacae6 340 wait_ms(2);
dheerajmpai23 0:e80c23aacae6 341
dheerajmpai23 0:e80c23aacae6 342 CS=0;
dheerajmpai23 0:e80c23aacae6 343 adf.write(0xB5);
dheerajmpai23 0:e80c23aacae6 344 CS=1;
dheerajmpai23 0:e80c23aacae6 345 wait_ms(2);
dheerajmpai23 0:e80c23aacae6 346
dheerajmpai23 0:e80c23aacae6 347 CS=0;
dheerajmpai23 0:e80c23aacae6 348 adf.write(0xFF);
dheerajmpai23 0:e80c23aacae6 349 adf.write(0xFF);
dheerajmpai23 0:e80c23aacae6 350 CS=1;
dheerajmpai23 0:e80c23aacae6 351 wait_ms(2);
dheerajmpai23 0:e80c23aacae6 352 }
dheerajmpai23 0:e80c23aacae6 353 /*******ADDITIONAL STUFF****************/
dheerajmpai23 0:e80c23aacae6 354 unsigned char check_status(void){
dheerajmpai23 0:e80c23aacae6 355 CS=0;
dheerajmpai23 0:e80c23aacae6 356 adf.write(0xFF);
dheerajmpai23 0:e80c23aacae6 357 unsigned char stat = adf.write(0xFF);
dheerajmpai23 0:e80c23aacae6 358 CS=1;
dheerajmpai23 0:e80c23aacae6 359 return stat;
dheerajmpai23 0:e80c23aacae6 360 }
dheerajmpai23 0:e80c23aacae6 361
dheerajmpai23 0:e80c23aacae6 362 unsigned char assrt_phy_off(int cmd_err_cnt,int spi_err_cnt,int state_err_cnt){
dheerajmpai23 0:e80c23aacae6 363 status=check_status();
dheerajmpai23 0:e80c23aacae6 364 if(status==0xB1){
dheerajmpai23 0:e80c23aacae6 365 return 0;
dheerajmpai23 0:e80c23aacae6 366 }
dheerajmpai23 0:e80c23aacae6 367 else if(cmd_err_cnt>THRS||spi_err_cnt>THRS){
dheerajmpai23 0:e80c23aacae6 368 return 1;//You need to Reset the hardware
dheerajmpai23 0:e80c23aacae6 369 }
dheerajmpai23 0:e80c23aacae6 370 else if(state_err_cnt>STATE_ERR_THRS){
dheerajmpai23 0:e80c23aacae6 371 return 1;//Again reset the hardware
dheerajmpai23 0:e80c23aacae6 372 }
dheerajmpai23 0:e80c23aacae6 373 else if((status&0xA0)==0xA0){ //If Status' first three bit ore 0b1X1 =>SPI ready, Dont care interrupt and CMD Ready.
dheerajmpai23 0:e80c23aacae6 374 CS=0;
dheerajmpai23 0:e80c23aacae6 375 adf.write(0xB0); //CMD_PHY_OFF
dheerajmpai23 0:e80c23aacae6 376 CS=1;
dheerajmpai23 0:e80c23aacae6 377 wait_us(PHY_OFF_EXEC_TIME);// Typical = 24us We are giving 300us
dheerajmpai23 0:e80c23aacae6 378 return assrt_phy_off(cmd_err_cnt,spi_err_cnt,state_err_cnt+1);
dheerajmpai23 0:e80c23aacae6 379 }
dheerajmpai23 0:e80c23aacae6 380 else if(status&0x80==0x00){
dheerajmpai23 0:e80c23aacae6 381 wait_ms(5);
dheerajmpai23 0:e80c23aacae6 382 //Error: SPI=0 Not ready CMD= Dont care
dheerajmpai23 0:e80c23aacae6 383 return assrt_phy_off(cmd_err_cnt,spi_err_cnt+1,state_err_cnt);
dheerajmpai23 0:e80c23aacae6 384 }
dheerajmpai23 0:e80c23aacae6 385 else {//if(status&0xA0==0x80){
dheerajmpai23 0:e80c23aacae6 386 wait_ms(1);
dheerajmpai23 0:e80c23aacae6 387 //Error: Command Not ready SPI Ready cmd_err_cnt is a global variable
dheerajmpai23 0:e80c23aacae6 388 return assrt_phy_off(cmd_err_cnt+1,spi_err_cnt,state_err_cnt);
dheerajmpai23 0:e80c23aacae6 389 }
dheerajmpai23 0:e80c23aacae6 390 }
dheerajmpai23 1:434b2062426b 391 /*****************************/
dheerajmpai23 1:434b2062426b 392 unsigned char assrt_phy_on(int cmd_err_cnt,int spi_err_cnt,int state_err_cnt){
dheerajmpai23 1:434b2062426b 393 status=check_status();
dheerajmpai23 1:434b2062426b 394 if(status==0xB2){
dheerajmpai23 1:434b2062426b 395 return 0;
dheerajmpai23 1:434b2062426b 396 }
dheerajmpai23 1:434b2062426b 397 else if(cmd_err_cnt>THRS||spi_err_cnt>THRS){
dheerajmpai23 1:434b2062426b 398 return 1;//You need to Reset the hardware
dheerajmpai23 1:434b2062426b 399 }
dheerajmpai23 1:434b2062426b 400 else if(state_err_cnt>STATE_ERR_THRS){
dheerajmpai23 1:434b2062426b 401 return 1;//Again reset the hardware
dheerajmpai23 1:434b2062426b 402 }
dheerajmpai23 1:434b2062426b 403 else if((status&0xA0)==0xA0){ //If Status' first three bit ore 0b1X1 =>SPI ready, Dont care interrupt and CMD Ready.
dheerajmpai23 1:434b2062426b 404 CS=0;
dheerajmpai23 1:434b2062426b 405 adf.write(0xB1); //CMD_PHY_OFF
dheerajmpai23 1:434b2062426b 406 CS=1;
dheerajmpai23 1:434b2062426b 407 wait_us(PHY_ON_EXEC_TIME);// Typical = 24us We are giving 300us
dheerajmpai23 1:434b2062426b 408 return assrt_phy_on(cmd_err_cnt,spi_err_cnt,state_err_cnt+1);
dheerajmpai23 1:434b2062426b 409 }
dheerajmpai23 1:434b2062426b 410 else if(status&0x80==0x00){
dheerajmpai23 1:434b2062426b 411 wait_ms(5);
dheerajmpai23 1:434b2062426b 412 //Error: SPI=0 Not ready CMD= Dont care
dheerajmpai23 1:434b2062426b 413 return assrt_phy_on(cmd_err_cnt,spi_err_cnt+1,state_err_cnt);
dheerajmpai23 1:434b2062426b 414 }
dheerajmpai23 1:434b2062426b 415 else if(status&0xA0==0x80){
dheerajmpai23 1:434b2062426b 416 wait_ms(1);
dheerajmpai23 1:434b2062426b 417 //Error: Command Not ready SPI Ready cmd_err_cnt is a global variable
dheerajmpai23 1:434b2062426b 418 return assrt_phy_on(cmd_err_cnt+1,spi_err_cnt,state_err_cnt);
dheerajmpai23 1:434b2062426b 419 }
dheerajmpai23 1:434b2062426b 420 }
dheerajmpai23 1:434b2062426b 421 /*****************************/
dheerajmpai23 1:434b2062426b 422 unsigned char assrt_phy_tx(int cmd_err_cnt,int spi_err_cnt,int state_err_cnt){
dheerajmpai23 1:434b2062426b 423 status=check_status();
dheerajmpai23 1:434b2062426b 424 if((status & 0x1F) == 0xB4){
dheerajmpai23 1:434b2062426b 425 return 0;
dheerajmpai23 1:434b2062426b 426 }
dheerajmpai23 1:434b2062426b 427 else if(cmd_err_cnt>THRS||spi_err_cnt>THRS){
dheerajmpai23 1:434b2062426b 428 return 1;//You need to Reset the hardware
dheerajmpai23 1:434b2062426b 429 }
dheerajmpai23 1:434b2062426b 430 else if(state_err_cnt>STATE_ERR_THRS){
dheerajmpai23 1:434b2062426b 431 return 1;//Again reset the hardware
dheerajmpai23 1:434b2062426b 432 }
dheerajmpai23 1:434b2062426b 433 else if((status&0xA0)==0xA0){ //If Status' first three bit ore 0b1X1 =>SPI ready, Dont care interrupt and CMD Ready.
dheerajmpai23 1:434b2062426b 434 CS=0;
dheerajmpai23 1:434b2062426b 435 adf.write(0xB1); //CMD_PHY_OFF
dheerajmpai23 1:434b2062426b 436 CS=1;
dheerajmpai23 1:434b2062426b 437 wait_us(PHY_TX_EXEC_TIME);// Typical = 24us We are giving 300us
dheerajmpai23 1:434b2062426b 438 return assrt_phy_tx(cmd_err_cnt,spi_err_cnt,state_err_cnt+1);
dheerajmpai23 1:434b2062426b 439 }
dheerajmpai23 1:434b2062426b 440 else if(status&0x80==0x00){
dheerajmpai23 1:434b2062426b 441 wait_ms(1);
dheerajmpai23 1:434b2062426b 442 //Error: SPI=0 Not ready CMD= Dont care
dheerajmpai23 1:434b2062426b 443 return assrt_phy_tx(cmd_err_cnt,spi_err_cnt+1,state_err_cnt);
dheerajmpai23 1:434b2062426b 444 }
dheerajmpai23 1:434b2062426b 445 else if(status&0xA0==0x80){
dheerajmpai23 1:434b2062426b 446 wait_us(50);
dheerajmpai23 1:434b2062426b 447 //Error: Command Not ready SPI Ready cmd_err_cnt is a global variable
dheerajmpai23 1:434b2062426b 448 return assrt_phy_tx(cmd_err_cnt+1,spi_err_cnt,state_err_cnt);
dheerajmpai23 1:434b2062426b 449 }
dheerajmpai23 1:434b2062426b 450 }
dheerajmpai23 1:434b2062426b 451
dheerajmpai23 0:e80c23aacae6 452 /***************************/
dheerajmpai23 0:e80c23aacae6 453 bool hardware_reset(int bcn_call){
dheerajmpai23 0:e80c23aacae6 454 if (bcn_call>20){
dheerajmpai23 0:e80c23aacae6 455 return 1;
dheerajmpai23 0:e80c23aacae6 456 }
dheerajmpai23 0:e80c23aacae6 457 int count=0;
dheerajmpai23 0:e80c23aacae6 458 CS=0;
dheerajmpai23 0:e80c23aacae6 459 adf.write(CMD_HW_RESET);
dheerajmpai23 0:e80c23aacae6 460 CS=1;
dheerajmpai23 0:e80c23aacae6 461 wait_us(2);// Typically 1 us
dheerajmpai23 0:e80c23aacae6 462 while(count<1000){
dheerajmpai23 0:e80c23aacae6 463 if(MISO_PIN){
dheerajmpai23 0:e80c23aacae6 464
dheerajmpai23 0:e80c23aacae6 465 if(!assrt_phy_off(0,0,0)){
dheerajmpai23 0:e80c23aacae6 466 break;
dheerajmpai23 0:e80c23aacae6 467 }
dheerajmpai23 0:e80c23aacae6 468 count++;
dheerajmpai23 0:e80c23aacae6 469 }
dheerajmpai23 0:e80c23aacae6 470 }
dheerajmpai23 0:e80c23aacae6 471 if(count==10){
dheerajmpai23 0:e80c23aacae6 472 return hardware_reset(bcn_call+1);
dheerajmpai23 0:e80c23aacae6 473 }
dheerajmpai23 0:e80c23aacae6 474 else
dheerajmpai23 0:e80c23aacae6 475 return 0;
dheerajmpai23 0:e80c23aacae6 476
dheerajmpai23 0:e80c23aacae6 477 }
dheerajmpai23 0:e80c23aacae6 478
dheerajmpai23 0:e80c23aacae6 479
dheerajmpai23 0:e80c23aacae6 480 /*******************************************/
dheerajmpai23 0:e80c23aacae6 481 int main()
dheerajmpai23 0:e80c23aacae6 482 {
dheerajmpai23 0:e80c23aacae6 483 adf.format(8,0);
dheerajmpai23 0:e80c23aacae6 484 adf.frequency(1000000);
dheerajmpai23 0:e80c23aacae6 485 /**ADDED On 21/10/2015 ***/
dheerajmpai23 0:e80c23aacae6 486 /******************/
dheerajmpai23 0:e80c23aacae6 487 /***********/
dheerajmpai23 0:e80c23aacae6 488 bool state_0=0;
dheerajmpai23 0:e80c23aacae6 489 state_0=assrt_phy_off(0,0,0);
dheerajmpai23 0:e80c23aacae6 490 while(1){
dheerajmpai23 0:e80c23aacae6 491 if(!state_0){
dheerajmpai23 0:e80c23aacae6 492 bbram_write();
dheerajmpai23 0:e80c23aacae6 493 break;
dheerajmpai23 0:e80c23aacae6 494 }
dheerajmpai23 0:e80c23aacae6 495 else{
dheerajmpai23 0:e80c23aacae6 496 hardware_reset(0);
dheerajmpai23 0:e80c23aacae6 497 }
dheerajmpai23 0:e80c23aacae6 498 }
dheerajmpai23 0:e80c23aacae6 499 state_0=assrt_phy_off(0,0,0);// We actually do not need this but make sure "we do not need this"
dheerajmpai23 0:e80c23aacae6 500
dheerajmpai23 0:e80c23aacae6 501 initiate();
dheerajmpai23 0:e80c23aacae6 502 send_data();
dheerajmpai23 0:e80c23aacae6 503 cout<<"Work"<<ENDL;
dheerajmpai23 0:e80c23aacae6 504 CS=0;
dheerajmpai23 0:e80c23aacae6 505 adf.write(0x0B);//IRQ_SOURCE_Random write //To read CMD = 2B 36 FF FF
dheerajmpai23 0:e80c23aacae6 506 adf.write(0x36);//Address : 0x336
dheerajmpai23 0:e80c23aacae6 507 adf.write(0xFF);//Put Low Clearing the MCR Value of the Source Register
dheerajmpai23 0:e80c23aacae6 508 CS=1;
dheerajmpai23 0:e80c23aacae6 509
dheerajmpai23 0:e80c23aacae6 510 ticker.attach_us(&Interrupt,32000);
dheerajmpai23 0:e80c23aacae6 511
dheerajmpai23 0:e80c23aacae6 512 }