krishan prajapat
/
sd_card_making_header_sss2
v2.0 working
Revision 2:2b08032d9678, committed 2015-07-30
- Comitter:
- krishanprajapat
- Date:
- Thu Jul 30 12:39:50 2015 +0000
- Parent:
- 1:436d836f2b8e
- Commit message:
- read from sd card and send to adf working;
Changed in this revision
diff -r 436d836f2b8e -r 2b08032d9678 SDCard_initionalisation.h --- a/SDCard_initionalisation.h Thu Jul 30 10:53:26 2015 +0000 +++ b/SDCard_initionalisation.h Thu Jul 30 12:39:50 2015 +0000 @@ -1,6 +1,6 @@ Serial PC(USBTX, USBRX); -DigitalOut cs(D9); +DigitalOut cs_SDCard(D9); #define SD_COMMAND_TIMEOUT 5000 @@ -48,7 +48,7 @@ void initialisation_SDCard(){ - CS =1; + cs_adf =1; // start_block_num =10 ; // Read from TC // end_block_num =Science_TMframe::SDC_address ; // Read from TC printf("welcome\n"); @@ -64,9 +64,9 @@ int initialise_card() { - // Set to 100kHz for initialisation, and clock card with cs = 1 + // Set to 100kHz for initialisation, and clock card with cs_SDCard = 1 spi.frequency(100000); - cs = 1; + cs_SDCard = 1; for (int i = 0; i < 16; i++) { spi.write(0xFF); } @@ -133,7 +133,7 @@ int cmd(int cmd, int arg) { - cs = 0; + cs_SDCard = 0; // send a command spi.write(0x40 | cmd); @@ -147,12 +147,12 @@ for (int i = 0; i < SD_COMMAND_TIMEOUT; i++) { int response = spi.write(0xFF); if (!(response & 0x80)) { - cs = 1; + cs_SDCard = 1; spi.write(0xFF); return response; } } - cs = 1; + cs_SDCard = 1; spi.write(0xFF); return -1; // timeout } @@ -160,7 +160,7 @@ int cmd58() { - cs = 0; + cs_SDCard = 0; int arg = 0; // send a command @@ -179,12 +179,12 @@ ocr |= spi.write(0xFF) << 16; ocr |= spi.write(0xFF) << 8; ocr |= spi.write(0xFF) << 0; - cs = 1; + cs_SDCard = 1; spi.write(0xFF); return response; } } - cs = 1; + cs_SDCard = 1; spi.write(0xFF); return -1; // timeout } @@ -192,7 +192,7 @@ int cmd8() { - cs = 0; + cs_SDCard = 0; // send a command spi.write(0x40 | 8); // CMD8 @@ -210,12 +210,12 @@ for (int j = 1; j < 5; j++) { response[i] = spi.write(0xFF); } - cs = 1; + cs_SDCard = 1; spi.write(0xFF); return response[0]; } } - cs = 1; + cs_SDCard = 1; spi.write(0xFF); return -1; // timeout } @@ -277,7 +277,7 @@ int cmdx(int cmd, int arg) { - cs = 0; + cs_SDCard = 0; // send a command spi.write(0x40 | cmd); @@ -294,7 +294,7 @@ return response; } } - cs = 1; + cs_SDCard = 1; spi.write(0xFF); return -1; // timeout } @@ -347,7 +347,7 @@ int write(const uint8_t*buffer, uint32_t length) { - cs = 0; + cs_SDCard = 0; // indicate start of block spi.write(0xFE); @@ -363,7 +363,7 @@ // check the response token if ((spi.write(0xFF) & 0x1F) != 0x05) { - cs = 1; + cs_SDCard = 1; spi.write(0xFF); return 1; } @@ -371,7 +371,7 @@ // wait for write to finish while (spi.write(0xFF) == 0); - cs = 1; + cs_SDCard = 1; spi.write(0xFF); return 0; } @@ -390,7 +390,7 @@ int read(uint8_t *buffer, uint32_t length) { - cs = 0; + cs_SDCard = 0; // read until start byte (0xFF) while (spi.write(0xFF) != 0xFE); @@ -402,7 +402,7 @@ spi.write(0xFF); // checksum spi.write(0xFF); - cs = 1; + cs_SDCard = 1; spi.write(0xFF); return 0; }
diff -r 436d836f2b8e -r 2b08032d9678 adf.h --- a/adf.h Thu Jul 30 10:53:26 2015 +0000 +++ b/adf.h Thu Jul 30 12:39:50 2015 +0000 @@ -2,7 +2,7 @@ SPI adf(PTA16, PTA17, PTA15); //MOSI, MISO, CLOCK -DigitalOut CS(D10); +DigitalOut cs_adf(D10); DigitalOut led2(LED_RED); InterruptIn IRQ(D8); Ticker ticker; @@ -14,13 +14,13 @@ void bbram_write() { - CS=0; + cs_adf=0; adf.write(0xB0);//PHY_OFF wait_us(300); - CS=1; + cs_adf=1; // Write bbram - CS=0; + cs_adf=0; adf.write(0x19); adf.write(0x00); adf.write(0x60); @@ -103,7 +103,7 @@ adf.write(0x00); adf.write(0x00); - CS=1; + cs_adf=1; // wait(1); } @@ -113,52 +113,52 @@ void initiate(void){ // printf("initiate"); - CS=0; + cs_adf=0; adf.write(0xFF); adf.write(0xFF); - CS=1; + cs_adf=1; // wait_ms(2); - CS=0; + cs_adf=0; adf.write(0x08); // TRANSMIT_DATA LENGTH adf.write(0x14); adf.write(0xFF); - CS=1; + cs_adf=1; // wait_ms(2); - CS=0; + cs_adf=0; adf.write(0x08); // TRANSMIT_DATA LENGTH adf.write(0x15); adf.write(0xFF); - CS=1; + cs_adf=1; // wait_ms(2); - CS=0; + cs_adf=0; adf.write(0x09); adf.write(0x24); // TX_BASE ADDRESS 0x20(starting Tx Byte) adf.write(0x20); - CS=1; + cs_adf=1; // wait_ms(2); - CS=0; + cs_adf=0; adf.write(0x09); adf.write(0x37);// BUFFER SIZE 0xE0=224 Bytes 0x137 is adress of buffer size adf.write(0xE0); - CS=1; + cs_adf=1; // wait_ms(2); - CS=0; + cs_adf=0; adf.write(0x09); adf.write(0x36);//BB_Tx_Buffer Signal when Buffer is half filled adf.write(0x70);//0x70 = 112 >> When Half buffer interrupt is given - CS=1; + cs_adf=1; // wait_ms(2); - CS=0; + cs_adf=0; adf.write(0x09); adf.write(0x39);//BB_Tx_Buffer Signal when Buffer is half filled adf.write(0x10);//0x70 = 112 >> When Half buffer interrupt is given - CS=1; + cs_adf=1; // wait_ms(2); } @@ -167,13 +167,13 @@ void write_data(void){ // wait_ms(0); - CS=0; + cs_adf=0; adf.write(0x0B);//IRQ_SOURCE_Random write //To read CMD = 2B 36 FF FF adf.write(0x36);//Address : 0x336 adf.write(0xFF);//Put Low - CS=1; + cs_adf=1; // wait_us(80); - CS=0; + cs_adf=0; static bool first_2_time = true; k=0; @@ -241,7 +241,7 @@ if(last_buffer){ - CS=0; + cs_adf=0; adf.write(0x18); adf.write(0x20); @@ -249,18 +249,18 @@ adf.write(buffer_112[k]); k++; } - CS=1; + cs_adf=1; ticker.detach(); - CS=0; + cs_adf=0; adf.write(0xB1); - CS=1; + cs_adf=1; printf("stopped"); cout<<"_"<<t1<<"_"<<t1<<"_"<<t1<<"_"<<t1<<"_"<<t1<<"_____________"<<t2<<"_"<<t2<<"_"<<t2<<"_"<<t2<<"_"<<t2<<"_"<<t2<<"_"<<t2<<endl; transmission_done=true; } - CS=1; + cs_adf=1; // wait_us(1); } @@ -283,15 +283,15 @@ void send_data(void){ - CS=0; + cs_adf=0; adf.write(0xBB); - CS=1; + cs_adf=1; // wait_us(300); - CS=0; + cs_adf=0; adf.write(0xFF); adf.write(0xFF); - CS=1; + cs_adf=1; // wait_ms(2); send_tm_from_SD_card(); // wait_ms(1); @@ -316,27 +316,27 @@ // snd_tm_from_SD_card(); // write_data(); // wait_ms(2); - CS=0; + cs_adf=0; adf.write(0xB1); - CS=1; + cs_adf=1; wait_us(300); - CS=0; + cs_adf=0; adf.write(0xFF); adf.write(0xFF); - CS=1; + cs_adf=1; // wait_ms(2); - CS=0; + cs_adf=0; adf.write(0xB5); - CS=1; + cs_adf=1; // cout<<"B5 given"<<endl; wait_us(300); // int b5=t.read_us(); - CS=0; + cs_adf=0; adf.write(0xFF); adf.write(0xFF); - CS=1; + cs_adf=1; // wait_ms(2); ticker.attach_us(&check,32000);
diff -r 436d836f2b8e -r 2b08032d9678 main.cpp --- a/main.cpp Thu Jul 30 10:53:26 2015 +0000 +++ b/main.cpp Thu Jul 30 12:39:50 2015 +0000 @@ -10,8 +10,8 @@ #include "SDCard_initionalisation.h" int main(){ - cs = 1; - CS = 1; + cs_SDCard = 1; + cs_adf = 1; unsigned char SRP[2190]; for(int i = 0 ; i < 2190 ; i++){ SRP[i] = 1;