#include "config.h"
Include dependency graph for df.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Data Structures | |
struct | s_format |
Defines | |
#define | DF_SECTOR_SIZE 512 |
#define | MEM_BSY 0 |
#define | MEM_OK 1 |
#define | MEM_KO 2 |
#define | DF_MSK_DENSITY ((Byte)0x3C) |
#define | DF_MSK_BIT_BUSY ((Byte)0x80) |
#define | DF_MEM_BUSY ((Byte)0x00) |
#define | DF_RD_STATUS ((Byte)0xD7) |
#define | DF_PG_ERASE ((Byte)0x81) |
#define | DF_BK_ERASE ((Byte)0x50) |
#define | DF_WR_BUF_1 ((Byte)0x84) |
#define | DF_WR_BUF_2 ((Byte)0x87) |
#define | DF_B1_MAIN ((Byte)0x83) |
#define | DF_B2_MAIN ((Byte)0x86) |
#define | DF_RD_MAIN ((Byte)0xD2) |
#define | DF_TF_BUF_1 ((Byte)0x53) |
#define | DF_TF_BUF_2 ((Byte)0x55) |
#define | DF_RD_BUF_1 ((Byte)0xD4) |
#define | DF_RD_BUF_2 ((Byte)0xD6) |
#define | DF_SIZE_4MB ((Uint32)(8192 - 1)) |
#define | DF_SIZE_8MB ((Uint32)(16384 - 1)) |
#define | DF_SIZE_16MB ((Uint32)(32768 - 1)) |
#define | DF_SIZE_32MB ((Uint32)(65536 - 1)) |
#define | DF_SIZE_64MB ((Uint32)(131072 - 1)) |
#define | DF_4MB ((Byte)0) |
#define | DF_8MB ((Byte)1) |
#define | DF_16MB ((Byte)2) |
#define | DF_32MB ((Byte)3) |
#define | DF_64MB ((Byte)4) |
#define | df_set_busy(i) (df_mem_busy |= (1<<i)) |
#define | df_release_busy(i) (df_mem_busy &= ~(1<<i)) |
#define | is_df_busy(i) (((df_mem_busy&(1<<i)) != 0) ? TRUE : FALSE) |
#define | MEM_DF0 0x00 |
#define | MEM_DF1 0x01 |
#define | MEM_DF2 0x02 |
#define | MEM_DF3 0x03 |
#define | Df_disk_size() ((Uint32)(DF_DISK_SIZE)) |
#define | Df_disk_size_0() ((Byte)(Df_disk_size() >> 24)) |
#define | Df_disk_size_1() ((Byte)(Df_disk_size() >> 16)) |
#define | Df_disk_size_2() ((Byte)(Df_disk_size() >> 8)) |
#define | Df_disk_size_3() ((Byte)(Df_disk_size())) |
#define | Df_block_size() ((Uint32)512) |
#define | Df_block_size_0() ((Byte)(Df_block_size() >> 24)) |
#define | Df_block_size_1() ((Byte)(Df_block_size() >> 16)) |
#define | Df_block_size_2() ((Byte)(Df_block_size() >> 8)) |
#define | Df_block_size_3() ((Byte)(Df_block_size())) |
Functions | |
bit | df_init (void) |
This function initializes the Dataflash controller & the SPI bus(over which the DF is controlled). | |
bit | df_mem_check (void) |
This function performs a memory check on all DF. | |
bit | df_read_open (Uint32) |
This function opens a DF memory in read mode at a given sector address. | |
void | df_read_close (void) |
This function unselects the current DF memory. | |
bit | df_write_open (Uint32) |
This function opens a DF memory in write mode at a given sector address. | |
void | df_write_close (void) |
This function fills the end of the logical sector (512B) and launch page programming. | |
bit | df_write_sector (Uint16) |
Funtions to link USB DEVICE flow with data flash. | |
bit | df_read_sector (Uint16) |
This function is optimized and writes nb-sector * 512 Bytes from DataFlash memory to USB controller. | |
bit | df_read_sector_2_ram (U8 *ram) |
Functions to read/write one sector (512btes) with ram buffer pointer. | |
bit | df_write_sector_from_ram (U8 *ram) |
This function write one DF sector from a ram buffer. | |
s_format * | df_format (void) |
#define DF_SECTOR_SIZE 512 |
Definition at line 24 of file df.h.
Referenced by df_read_sector_2_ram(), and df_write_sector_from_ram().
#define DF_MSK_DENSITY ((Byte)0x3C) |
#define DF_MSK_BIT_BUSY ((Byte)0x80) |
#define DF_MEM_BUSY ((Byte)0x00) |
#define DF_RD_STATUS ((Byte)0xD7) |
#define DF_RD_MAIN ((Byte)0xD2) |
#define DF_TF_BUF_1 ((Byte)0x53) |
#define DF_SIZE_4MB ((Uint32)(8192 - 1)) |
#define DF_SIZE_8MB ((Uint32)(16384 - 1)) |
#define DF_SIZE_16MB ((Uint32)(32768 - 1)) |
#define DF_SIZE_32MB ((Uint32)(65536 - 1)) |
#define DF_4MB ((Byte)0) |
#define DF_8MB ((Byte)1) |
#define DF_16MB ((Byte)2) |
#define DF_32MB ((Byte)3) |
#define df_set_busy | ( | i | ) | (df_mem_busy |= (1<<i)) |
#define df_release_busy | ( | i | ) | (df_mem_busy &= ~(1<<i)) |
#define is_df_busy | ( | i | ) | (((df_mem_busy&(1<<i)) != 0) ? TRUE : FALSE) |
#define MEM_DF0 0x00 |
Definition at line 84 of file df.h.
Referenced by df_chipselect_current(), df_chipselect_memzone(), and df_init().
#define MEM_DF1 0x01 |
Definition at line 85 of file df.h.
Referenced by df_chipselect_current(), and df_chipselect_memzone().
#define MEM_DF2 0x02 |
Definition at line 86 of file df.h.
Referenced by df_chipselect_current(), and df_chipselect_memzone().
#define MEM_DF3 0x03 |
#define Df_disk_size | ( | ) | ((Uint32)(DF_DISK_SIZE)) |
bit df_init | ( | void | ) |
This function initializes the Dataflash controller & the SPI bus(over which the DF is controlled).
none |
Definition at line 111 of file df.c.
References df_mem_busy, df_select, df_spi_init(), MEM_DF0, and OK.
Referenced by df_mem_init().
00112 { 00113 // Init the SPI communication link between the DF and the DF driver. 00114 df_spi_init(); 00115 00116 // Data Flash Controller init. 00117 df_mem_busy = 0; // all memories ready 00118 df_select = MEM_DF0; 00119 return(OK); 00120 }
Here is the call graph for this function:
bit df_mem_check | ( | void | ) |
This function performs a memory check on all DF.
none |
Definition at line 336 of file df.c.
References df_chipselect_current(), Df_desel_all, DF_MSK_DENSITY, DF_NB_MEM, DF_RD_STATUS, df_select, KO, OK, Spi_read_data, Spi_write_data, and Spi_write_dummy.
Referenced by df_test_unit_ready().
00337 { 00338 //# DF memory check. 00339 for(df_select=0; df_select<DF_NB_MEM; df_select++) 00340 { 00341 df_chipselect_current(); 00342 Spi_write_data(DF_RD_STATUS); /* Send the read status register cmd 00343 + 1st step to clear the SPIF bit */ 00344 Spi_write_dummy(); /* dummy write that: 00345 (.) finalize the clear of the SPIF bit (access to SPDR) 00346 (.) get status register 00347 (.) does the 1st step to clear the SPIF bit */ 00348 /* Following Spi_read_data() finalize the clear of SPIF by accessing SPDR. */ 00349 // Check the DF density. 00350 if ((Spi_read_data() & DF_MSK_DENSITY) != DF_DENSITY) 00351 { // Unexpected value. 00352 Df_desel_all(); 00353 return (KO); 00354 } 00355 Df_desel_all(); 00356 } 00357 00358 return OK; 00359 }
Here is the call graph for this function:
bit df_read_open | ( | Uint32 | pos | ) |
This function opens a DF memory in read mode at a given sector address.
NOTE: Address may not be synchronized on the beginning of a page (depending on the DF page size).
pos | Logical sector address |
Definition at line 406 of file df.c.
References df_chipselect_current(), df_chipselect_memzone(), DF_RD_MAIN, df_release_busy, df_select, df_translate_addr(), df_wait_busy(), gl_ptr_mem, is_df_busy, LSB0, MSB1, MSB2, MSB3, OK, Spi_ack_write, and Spi_write_data.
Referenced by df_df_2_ram(), df_read_10(), and df_read_sector().
00407 { 00408 // Set the global memory ptr at a Byte address. 00409 gl_ptr_mem = df_translate_addr(pos); 00410 00411 // Select the DF that memory "pos" points to (the "df_select" variable will be updated) 00412 df_chipselect_memzone(LSB0(pos)); 00413 00414 // If the DF memory is busy, wait until it's not. 00415 if (is_df_busy(df_select)) 00416 { 00417 df_release_busy(df_select); 00418 df_wait_busy(); /* wait end of programming */ 00419 } 00420 00421 // Physically assert the selected dataflash 00422 df_chipselect_current(); 00423 00424 //# 00425 //# Initiate a page read at a given sector address. 00426 //# 00427 // Send read main command, + first step to clear the SPIF bit 00428 Spi_write_data(DF_RD_MAIN); 00429 // Final step to clear the SPIF bit will be done on the next write 00430 00431 // Send the three address Bytes made of: 00432 // (.) the page-address(first xbits), 00433 // (.) the Byte-address within the page(last ybits). 00434 // (x and y depending on the DF type). 00435 // NOTE: the bits of gl_ptr_mem above the 24bits are not useful for the local 00436 // DF addressing. They are used for DF discrimination when there are several 00437 // DFs. 00438 Spi_write_data((MSB1(gl_ptr_mem) << DF_SHFT_B1) | (MSB2(gl_ptr_mem) >> DF_SHFT_B2)); 00439 Spi_write_data(((MSB2(gl_ptr_mem) & ~DF_PAGE_MASK) << DF_SHFT_B1) | (MSB2(gl_ptr_mem) & DF_PAGE_MASK)); 00440 Spi_write_data(MSB3(gl_ptr_mem)); 00441 // Final step to clear the SPIF bit will be done on the next write 00442 00443 // 4 dummy writes for reading delay 00444 Spi_write_data(0xFF); 00445 Spi_write_data(0xFF); 00446 Spi_write_data(0xFF); 00447 Spi_write_data(0xFF); /* Tx 0xFF, first step to clear the SPIF bit */ 00448 Spi_ack_write(); /* Final step to clear the SPIF bit. */ 00449 00450 return OK; 00451 }
Here is the call graph for this function:
void df_read_close | ( | void | ) |
This function unselects the current DF memory.
None |
Definition at line 463 of file df.c.
References Df_desel_all.
Referenced by df_df_2_ram(), and df_read_10().
00464 { 00465 Df_desel_all(); /* Unselect memory */ 00466 }
bit df_write_open | ( | Uint32 | pos | ) |
This function opens a DF memory in write mode at a given sector address.
NOTE: If page buffer > 512 bytes, page content is first loaded in buffer to be partially updated by write_byte or write64 functions.
pos | Sector address |
Definition at line 615 of file df.c.
References df_chipselect_current(), df_chipselect_memzone(), Df_desel_all, df_release_busy, df_select, DF_TF_BUF_1, df_translate_addr(), df_wait_busy(), gl_ptr_mem, is_df_busy, LSB0, MSB1, MSB2, MSB3, OK, Spi_ack_write, Spi_write_data, and Spi_write_dummy.
Referenced by df_ram_2_df(), df_write_10(), and df_write_sector().
00616 { 00617 // Set the global memory ptr at a Byte address. 00618 gl_ptr_mem = df_translate_addr(pos); 00619 00620 // Select the DF that memory "pos" points to 00621 df_chipselect_memzone(LSB0(pos)); 00622 00623 // If the DF memory is busy, wait until it's not. 00624 if (is_df_busy(df_select)) 00625 { 00626 df_release_busy(df_select); 00627 df_wait_busy(); /* wait end of programming */ 00628 } 00629 00630 #if DF_PAGE_SIZE > 512 00631 // Physically assert the selected dataflash 00632 df_chipselect_current(); 00633 00634 //# 00635 //# Transfer the current page content in buffer1. 00636 //# 00637 // Send Main Mem page to Buffer1 command, + first step to clear the SPIF bit 00638 Spi_write_data(DF_TF_BUF_1); 00639 // Final step to clear the SPIF bit will be done on the next write 00640 00641 // Send the three address Bytes made of: 00642 // (.) the page-address(first xbits), 00643 // (.) remaining don't care bits(last ybits). 00644 // (x and y depending on the DF type). 00645 // NOTE: the bits of gl_ptr_mem above the 24bits are not useful for the local 00646 // DF addressing. They are used for DF discrimination when there are several 00647 // DFs. 00648 Spi_write_data((MSB1(gl_ptr_mem) << DF_SHFT_B1) | (MSB2(gl_ptr_mem) >> DF_SHFT_B2)); 00649 Spi_write_data(MSB2(gl_ptr_mem) << DF_SHFT_B1); 00650 Spi_write_dummy(); // Remaining don't care bits. 00651 Spi_ack_write(); // Final step to clear the SPIF bit. 00652 00653 Df_desel_all(); // Unselect memory to validate the command 00654 00655 df_wait_busy(); // Wait end of page transfer 00656 #endif 00657 00658 // Physically assert the selected dataflash 00659 df_chipselect_current(); 00660 00661 //# 00662 //# Initiate a page write at a given sector address. 00663 //# 00664 // Send Main Memory Page Program Through Buffer1 command, 00665 // + first step to clear the SPIF bit 00666 Spi_write_data(DF_PG_BUF_1); 00667 // Final step to clear the SPIF bit will be done on the next write 00668 00669 // Send the three address Bytes made of: 00670 // (.) the page-address(first xbits), 00671 // (.) the Byte-address within the page(last ybits). 00672 // (x and y depending on the DF type). 00673 // NOTE: the bits of gl_ptr_mem above the 24bits are not useful for the local 00674 // DF addressing. They are used for DF discrimination when there are several 00675 // DFs. 00676 Spi_write_data((MSB1(gl_ptr_mem) << DF_SHFT_B1) | (MSB2(gl_ptr_mem) >> DF_SHFT_B2)); 00677 Spi_write_data(((MSB2(gl_ptr_mem) & ~DF_PAGE_MASK) << DF_SHFT_B1) | (MSB2(gl_ptr_mem) & DF_PAGE_MASK)); 00678 Spi_write_data(MSB3(gl_ptr_mem)); 00679 Spi_ack_write(); // Final step to clear the SPIF bit. 00680 00681 return OK; 00682 }
Here is the call graph for this function:
void df_write_close | ( | void | ) |
This function fills the end of the logical sector (512B) and launch page programming.
None |
Definition at line 695 of file df.c.
References Df_desel_all, df_select, df_set_busy, gl_ptr_mem, MSB2, MSB3, Spi_ack_write, and Spi_write_data.
Referenced by df_ram_2_df(), and df_write_10().
00696 { 00697 //# 00698 //# While end of logical sector (512B) not reached, zero-fill the remaining 00699 //# memory Bytes. 00700 //# 00701 while ((MSB3(gl_ptr_mem) != 0x00) || ((MSB2(gl_ptr_mem) & 0x01) != 0x00)) 00702 { 00703 Spi_write_data(0x00); // (.) Final step to clear the SPIF bit, 00704 // (.) Write 0x00 00705 // (.) first step to clear the SPIF bit. 00706 gl_ptr_mem++; 00707 } 00708 Spi_ack_write(); // Final step to clear the SPIF bit. 00709 00710 Df_desel_all(); // Launch page programming (or simply unselect memory 00711 // if the while loop was not performed). 00712 df_set_busy(df_select); // Current memory is busy 00713 }
bit df_write_sector | ( | Uint16 | nb_sector | ) |
Funtions to link USB DEVICE flow with data flash.
DATA FLOW is: USB => DF
NOTE:
nb_sector | number of contiguous sectors to write [IN] |
Definition at line 739 of file df.c.
References Df_desel_all, df_select, df_set_busy, df_write_open(), FALSE, gl_ptr_mem, Is_usb_read_enabled, MSB2, OK, Spi_ack_write, Spi_write_data, Usb_ack_receive_out, and Usb_read_byte.
Referenced by df_write_10().
00740 { 00741 Byte i; 00742 00743 do 00744 { 00745 //# Write 8x64b = 512b from the USB FIFO OUT. 00746 for (i = 8; i != 0; i--) 00747 { 00748 // Wait end of rx in USB EPOUT. 00749 while(Is_usb_read_enabled()==FALSE); 00750 00751 Disable_interrupt(); // Global disable. 00752 00753 // SPI write principle: send a Byte then clear the SPIF flag. 00754 // Spi_write_data(Usb_read_byte()): (.) Final step to clear the SPIF bit, 00755 // (.) send a Byte read from USB, 00756 // (.) 1st step to clear the SPIF bit. 00757 Spi_write_data(Usb_read_byte()); 00758 Spi_write_data(Usb_read_byte()); 00759 Spi_write_data(Usb_read_byte()); 00760 Spi_write_data(Usb_read_byte()); 00761 Spi_write_data(Usb_read_byte()); 00762 Spi_write_data(Usb_read_byte()); 00763 Spi_write_data(Usb_read_byte()); 00764 Spi_write_data(Usb_read_byte()); 00765 Spi_write_data(Usb_read_byte()); 00766 Spi_write_data(Usb_read_byte()); 00767 Spi_write_data(Usb_read_byte()); 00768 Spi_write_data(Usb_read_byte()); 00769 Spi_write_data(Usb_read_byte()); 00770 Spi_write_data(Usb_read_byte()); 00771 Spi_write_data(Usb_read_byte()); 00772 Spi_write_data(Usb_read_byte()); 00773 Spi_write_data(Usb_read_byte()); 00774 Spi_write_data(Usb_read_byte()); 00775 Spi_write_data(Usb_read_byte()); 00776 Spi_write_data(Usb_read_byte()); 00777 Spi_write_data(Usb_read_byte()); 00778 Spi_write_data(Usb_read_byte()); 00779 Spi_write_data(Usb_read_byte()); 00780 Spi_write_data(Usb_read_byte()); 00781 Spi_write_data(Usb_read_byte()); 00782 Spi_write_data(Usb_read_byte()); 00783 Spi_write_data(Usb_read_byte()); 00784 Spi_write_data(Usb_read_byte()); 00785 Spi_write_data(Usb_read_byte()); 00786 Spi_write_data(Usb_read_byte()); 00787 Spi_write_data(Usb_read_byte()); 00788 Spi_write_data(Usb_read_byte()); 00789 Spi_write_data(Usb_read_byte()); 00790 Spi_write_data(Usb_read_byte()); 00791 Spi_write_data(Usb_read_byte()); 00792 Spi_write_data(Usb_read_byte()); 00793 Spi_write_data(Usb_read_byte()); 00794 Spi_write_data(Usb_read_byte()); 00795 Spi_write_data(Usb_read_byte()); 00796 Spi_write_data(Usb_read_byte()); 00797 Spi_write_data(Usb_read_byte()); 00798 Spi_write_data(Usb_read_byte()); 00799 Spi_write_data(Usb_read_byte()); 00800 Spi_write_data(Usb_read_byte()); 00801 Spi_write_data(Usb_read_byte()); 00802 Spi_write_data(Usb_read_byte()); 00803 Spi_write_data(Usb_read_byte()); 00804 Spi_write_data(Usb_read_byte()); 00805 Spi_write_data(Usb_read_byte()); 00806 Spi_write_data(Usb_read_byte()); 00807 Spi_write_data(Usb_read_byte()); 00808 Spi_write_data(Usb_read_byte()); 00809 Spi_write_data(Usb_read_byte()); 00810 Spi_write_data(Usb_read_byte()); 00811 Spi_write_data(Usb_read_byte()); 00812 Spi_write_data(Usb_read_byte()); 00813 Spi_write_data(Usb_read_byte()); 00814 Spi_write_data(Usb_read_byte()); 00815 Spi_write_data(Usb_read_byte()); 00816 Spi_write_data(Usb_read_byte()); 00817 Spi_write_data(Usb_read_byte()); 00818 Spi_write_data(Usb_read_byte()); 00819 Spi_write_data(Usb_read_byte()); 00820 Spi_write_data(Usb_read_byte()); 00821 Spi_ack_write(); // Final step to clear the SPIF bit. 00822 00823 Usb_ack_receive_out(); // USB EPOUT read acknowledgement. 00824 00825 Enable_interrupt(); // Global re-enable. 00826 } // for (i = 8; i != 0; i--) 00827 00828 gl_ptr_mem += 512; // Update the memory pointer. 00829 nb_sector--; // 1 more sector written 00830 00831 //# Launch page programming if end of page. 00832 //# 00833 #if DF_PAGE_SIZE > 512 00834 // Check if end of 1024b page. 00835 if ((MSB2(gl_ptr_mem) & DF_PAGE_MASK) == 0x00) 00836 { 00837 Df_desel_all(); // Launch page programming 00838 df_set_busy(df_select); // memory is busy 00839 #if (DF_NB_MEM == 1) 00840 if (nb_sector != 0) 00841 df_write_open(gl_ptr_mem>>9); 00842 #endif 00843 } 00844 #else 00845 // Always end of page. 00846 Df_desel_all(); // Launch page programming 00847 df_set_busy(df_select); // memory is busy 00848 #if (DF_NB_MEM == 1) 00849 if (nb_sector != 0) 00850 df_write_open(gl_ptr_mem>>9); 00851 #endif 00852 #endif 00853 } 00854 while (nb_sector != 0); 00855 00856 return OK; // Write done 00857 }
Here is the call graph for this function:
bit df_read_sector | ( | Uint16 | nb_sector | ) |
This function is optimized and writes nb-sector * 512 Bytes from DataFlash memory to USB controller.
DATA FLOW is: DF => USB
NOTE:
nb_sector | number of contiguous sectors to read [IN] |
Definition at line 493 of file df.c.
References Df_desel_all, df_read_open(), FALSE, gl_ptr_mem, Is_usb_write_enabled, MSB2, OK, Spi_read_data, Spi_write_dummy, Usb_send_in, and Usb_write_byte.
Referenced by df_read_10().
00494 { 00495 U8 i; 00496 do 00497 { 00498 for (i = 8; i != 0; i--) 00499 { 00500 Disable_interrupt(); // Global disable. 00501 00502 // Principle: send any Byte to get a Byte. 00503 // Spi_write_dummy(): send any Byte + 1st step to clear the SPIF bit. 00504 // Spi_read_data(): get the Byte + final step to clear the SPIF bit. 00505 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00506 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00507 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00508 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00509 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00510 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00511 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00512 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00513 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00514 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00515 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00516 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00517 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00518 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00519 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00520 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00521 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00522 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00523 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00524 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00525 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00526 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00527 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00528 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00529 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00530 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00531 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00532 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00533 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00534 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00535 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00536 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00537 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00538 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00539 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00540 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00541 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00542 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00543 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00544 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00545 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00546 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00547 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00548 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00549 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00550 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00551 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00552 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00553 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00554 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00555 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00556 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00557 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00558 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00559 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00560 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00561 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00562 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00563 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00564 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00565 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00566 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00567 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00568 Spi_write_dummy(); Usb_write_byte(Spi_read_data()); 00569 00570 //# Send the USB FIFO IN content to the USB Host. 00571 Usb_send_in(); // Send the FIFO IN content to the USB Host. 00572 00573 Enable_interrupt(); // Global interrupt re-enable. 00574 00575 // Wait until the tx is done so that we may write to the FIFO IN again. 00576 while(Is_usb_write_enabled()==FALSE); 00577 } 00578 gl_ptr_mem += 512; // increment global address pointer 00579 nb_sector--; // 1 more sector read 00580 #if (DF_NB_MEM == 1) // end of page ? 00581 #if (DF_PAGE_SIZE == 512) 00582 Df_desel_all(); 00583 if (nb_sector != 0) 00584 df_read_open(gl_ptr_mem>>9); 00585 #else 00586 if ((MSB2(gl_ptr_mem) & DF_PAGE_MASK) == 0x00) 00587 { 00588 Df_desel_all(); 00589 if (nb_sector != 0) 00590 df_read_open(gl_ptr_mem>>9); 00591 } 00592 #endif 00593 #endif 00594 } 00595 while (nb_sector != 0); 00596 00597 return OK; // Read done. 00598 }
Here is the call graph for this function:
bit df_read_sector_2_ram | ( | U8 * | ram | ) |
Functions to read/write one sector (512btes) with ram buffer pointer.
DATA FLOW is: DF => RAM
NOTE:
*ram | pointer to ram buffer |
Definition at line 874 of file df.c.
References DF_SECTOR_SIZE, gl_ptr_mem, OK, Spi_read_data, and Spi_write_dummy.
Referenced by df_df_2_ram().
00875 { 00876 U16 i; 00877 for(i=0;i<DF_SECTOR_SIZE;i++) 00878 { 00879 Spi_write_dummy(); 00880 *ram=Spi_read_data(); 00881 ram++; 00882 } 00883 gl_ptr_mem += 512; // Update the memory pointer. 00884 return OK; 00885 }
bit df_write_sector_from_ram | ( | U8 * | ram | ) |
This function write one DF sector from a ram buffer.
DATA FLOW is: RAM => DF
NOTE:
*ram | pointer to ram buffer |
Definition at line 900 of file df.c.
References DF_SECTOR_SIZE, gl_ptr_mem, OK, Spi_ack_write, and Spi_write_data.
Referenced by df_ram_2_df().
00901 { 00902 U16 i; 00903 for(i=0;i<DF_SECTOR_SIZE;i++) 00904 { 00905 Spi_write_data(*ram); 00906 *ram++; 00907 } 00908 Spi_ack_write(); // Final step to clear the SPIF bit. 00909 gl_ptr_mem += 512; // Update the memory pointer. 00910 return OK; 00911 }
s_format* df_format | ( | void | ) |
Definition at line 939 of file df.c.
References DF_16MB, DF_32MB, DF_4MB, DF_8MB, DF_SIZE_16MB, DF_SIZE_32MB, DF_SIZE_4MB, DF_SIZE_8MB, df_tab_format, and NULL.
00940 { 00941 00942 /* -- DF Type Selection -- */ 00943 switch (DF_DISK_SIZE) 00944 { 00945 case DF_SIZE_4MB: 00946 return (s_format*)&df_tab_format[DF_4MB]; 00947 break; 00948 case DF_SIZE_8MB: 00949 return (s_format*)&df_tab_format[DF_8MB]; 00950 break; 00951 case DF_SIZE_16MB: 00952 return (s_format*)&df_tab_format[DF_16MB]; 00953 break; 00954 case DF_SIZE_32MB: 00955 return (s_format*)&df_tab_format[DF_32MB]; 00956 break; 00957 default: 00958 break; 00959 } 00960 return(NULL); 00961 }